[CRIU] Re: [PATCH] sockets: Fix file-bound socket check for dgram
sockets
Pavel Emelyanov
xemul at parallels.com
Wed Feb 8 06:24:43 EST 2012
On 02/08/2012 03:09 PM, Pavel Emelyanov wrote:
> On 02/08/2012 03:07 PM, Pavel Emelyanov wrote:
>> On 02/08/2012 03:03 PM, Cyrill Gorcunov wrote:
>>> On Wed, Feb 08, 2012 at 02:52:19PM +0400, Cyrill Gorcunov wrote:
>>>> DGRAM sockets do not care about mount point of
>>>> file-bound sockets and at time of connect() kernel
>>>> do not update this information once socket is cretaed,
>>>> thus do not eliminate dumping of suck sockets name
>>>> if at least inode match.
>>>>
>>>
>>> Sorry for such silly changelog. In short -- when connect is
>>> called on stream socket, the kernel updates dentry of sockets
>>> so that both ino and st_dev match, but in case of dgrams, they
>>> are not updated and then we will not dump socket name and at
>>> restore time there will be no way to resolve a name of a socket
>>> to call connect on (ie sockets00 test-case fails)
>>
>> Это неверный патч. Надо так:
>>
>> if (sk->type == SOCK_STREAM && (ino != vfs_ino || dev != vfs_dev)
>> /* drop bound name */
>
> Нет, стоп, все назад. Ты не прав, Кирил. По ядру пути connect-а
> не отличаются -- там делается тупой path_walk.
>
>>> Cyrill
>>>
>>
Надо примерно так, но после этого тест повисает где-то на синхронизации кто отресторился а кто нет :(
diff --git a/include/util.h b/include/util.h
index e9c1832..5fab3f4 100644
--- a/include/util.h
+++ b/include/util.h
@@ -264,4 +264,25 @@ FILE *fopen_proc(int pid_dir_fd, char *fmt, ...);
#define pr_img_head(type, ...) pr_info("\n"#type __VA_ARGS__ "\n----------------\n")
#define pr_img_tail(type) pr_info("----------------\n")
+#define KDEV_MINORBITS 20
+#define KDEV_MINORMASK ((1UL << KDEV_MINORBITS) - 1)
+
+static inline u32 kdev_major(u32 kdev)
+{
+ return kdev >> KDEV_MINORBITS;
+}
+
+static inline u32 kdev_minor(u32 kdev)
+{
+ return kdev & KDEV_MINORMASK;
+}
+
+static inline dev_t kdev_to_odev(u32 kdev)
+{
+ /*
+ * New kernels envcode devices in a new form
+ */
+ return (kdev_major(kdev) << 8) | kdev_minor(kdev);
+}
+
#endif /* UTIL_H_ */
diff --git a/sockets.c b/sockets.c
index 2b8a1b4..2c21e5e 100644
--- a/sockets.c
+++ b/sockets.c
@@ -466,7 +466,10 @@ static int unix_collect_one(struct unix_diag_msg *m, struct rtattr **tb)
}
if ((st.st_ino != uv->udiag_vfs_ino) ||
- (st.st_dev != uv->udiag_vfs_dev)) {
+ (st.st_dev != kdev_to_odev(uv->udiag_vfs_dev))) {
+ pr_info("unix: Dropping path for unlinked bound sk %x.%x real %x.%x\n",
+ (int)st.st_dev, (int)st.st_ino,
+ (int)uv->udiag_vfs_dev, (int)uv->udiag_vfs_ino);
/*
* When a listen socket is bound to
* unlinked file, we just drop his name,
More information about the CRIU
mailing list