[v4,08/15] unix: Dump DGRAM packets and sockets senders

Submitted by Kirill Tkhai on June 1, 2016, 4:02 p.m.

Details

Message ID 146479696797.23002.15288671222465866351.stgit@pro
State Rejected
Series "Support for packet's msg_name in receive queue of promiscous DGRAM sockets"
Headers show

Commit Message

Kirill Tkhai June 1, 2016, 4:02 p.m.
Add a method to get a DGRAM packet sender. This allows dump_sk_queue()
to dump its inode. If there is the only sender for whole socket's packets,
dump its inode at UnixSkEntry::sender_ino.

Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
---
 criu/sk-unix.c |   20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)

Patch hide | download patch | download mbox

diff --git a/criu/sk-unix.c b/criu/sk-unix.c
index 9db911b..4bda078 100644
--- a/criu/sk-unix.c
+++ b/criu/sk-unix.c
@@ -133,6 +133,16 @@  static struct unix_sk_desc *find_unix_sk_by_name(const char *name, int namelen)
 	return NULL;
 }
 
+static u64 find_unix_dgram_ino_by_name(const char *name, int namelen)
+{
+	struct unix_sk_desc *sk = find_unix_sk_by_name(name, namelen);
+
+	if (sk && sk->type != SOCK_DGRAM)
+		sk = NULL;
+
+	return sk ? sk->sd.ino : SK_NONAME_SENDER;
+}
+
 static void show_one_unix(char *act, const struct unix_sk_desc *sk)
 {
 	pr_debug("\t%s: ino %#x peer_ino %#x family %4d type %4d state %2d name %s\n",
@@ -462,9 +472,15 @@  static int dump_one_unix_fd(int lfd, u32 id, const struct fd_parms *p)
 	 * (i stands for in-flight, cons -- for connections) things.
 	 */
 	if (sk->rqlen != 0 && !(sk->type == SOCK_STREAM &&
-				sk->state == TCP_LISTEN))
-		if (dump_sk_queue(lfd, id, NULL))
+				sk->state == TCP_LISTEN)) {
+		u64 (*f)(const char *, int) = NULL;
+
+		if (sk->type == SOCK_DGRAM)
+			f = find_unix_dgram_ino_by_name;
+		if (dump_sk_queue(lfd, id, f))
 			goto err;
+	} else if (sk->rqlen == 0)
+		ue->uflags |= USK_EMPTY_Q;
 
 	pr_info("Dumping unix socket at %d\n", p->fd);
 	show_one_unix("Dumping", sk);

Comments

Pavel Emelyanov June 9, 2016, 1:10 p.m.
On 06/01/2016 07:02 PM, Kirill Tkhai wrote:
> Add a method to get a DGRAM packet sender. This allows dump_sk_queue()
> to dump its inode. If there is the only sender for whole socket's packets,
> dump its inode at UnixSkEntry::sender_ino.
> 
> Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
> ---
>  criu/sk-unix.c |   20 ++++++++++++++++++--
>  1 file changed, 18 insertions(+), 2 deletions(-)
> 
> diff --git a/criu/sk-unix.c b/criu/sk-unix.c
> index 9db911b..4bda078 100644
> --- a/criu/sk-unix.c
> +++ b/criu/sk-unix.c
> @@ -133,6 +133,16 @@ static struct unix_sk_desc *find_unix_sk_by_name(const char *name, int namelen)
>  	return NULL;
>  }
>  
> +static u64 find_unix_dgram_ino_by_name(const char *name, int namelen)
> +{
> +	struct unix_sk_desc *sk = find_unix_sk_by_name(name, namelen);
> +
> +	if (sk && sk->type != SOCK_DGRAM)

How can this happen?

> +		sk = NULL;
> +
> +	return sk ? sk->sd.ino : SK_NONAME_SENDER;
> +}
> +
>  static void show_one_unix(char *act, const struct unix_sk_desc *sk)
>  {
>  	pr_debug("\t%s: ino %#x peer_ino %#x family %4d type %4d state %2d name %s\n",
> @@ -462,9 +472,15 @@ static int dump_one_unix_fd(int lfd, u32 id, const struct fd_parms *p)
>  	 * (i stands for in-flight, cons -- for connections) things.
>  	 */
>  	if (sk->rqlen != 0 && !(sk->type == SOCK_STREAM &&
> -				sk->state == TCP_LISTEN))
> -		if (dump_sk_queue(lfd, id, NULL))
> +				sk->state == TCP_LISTEN)) {
> +		u64 (*f)(const char *, int) = NULL;
> +
> +		if (sk->type == SOCK_DGRAM)
> +			f = find_unix_dgram_ino_by_name;
> +		if (dump_sk_queue(lfd, id, f))
>  			goto err;
> +	} else if (sk->rqlen == 0)
> +		ue->uflags |= USK_EMPTY_Q;

Don't add this bit into ui image. Emptiness of the queue should be
determined restore-time by collecting sk-packet image.

>  
>  	pr_info("Dumping unix socket at %d\n", p->fd);
>  	show_one_unix("Dumping", sk);
> 
> _______________________________________________
> CRIU mailing list
> CRIU@openvz.org
> https://lists.openvz.org/mailman/listinfo/criu
> .
>
Kirill Tkhai June 9, 2016, 1:28 p.m.
On 09.06.2016 16:10, Pavel Emelyanov wrote:
> On 06/01/2016 07:02 PM, Kirill Tkhai wrote:
>> Add a method to get a DGRAM packet sender. This allows dump_sk_queue()
>> to dump its inode. If there is the only sender for whole socket's packets,
>> dump its inode at UnixSkEntry::sender_ino.
>>
>> Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
>> ---
>>  criu/sk-unix.c |   20 ++++++++++++++++++--
>>  1 file changed, 18 insertions(+), 2 deletions(-)
>>
>> diff --git a/criu/sk-unix.c b/criu/sk-unix.c
>> index 9db911b..4bda078 100644
>> --- a/criu/sk-unix.c
>> +++ b/criu/sk-unix.c
>> @@ -133,6 +133,16 @@ static struct unix_sk_desc *find_unix_sk_by_name(const char *name, int namelen)
>>  	return NULL;
>>  }
>>  
>> +static u64 find_unix_dgram_ino_by_name(const char *name, int namelen)
>> +{
>> +	struct unix_sk_desc *sk = find_unix_sk_by_name(name, namelen);
>> +
>> +	if (sk && sk->type != SOCK_DGRAM)
> 
> How can this happen?

DGRAM socket had died, before its STREAM namesake was created. So, DGRAM
packets has msg_name of died socket.

>> +		sk = NULL;
>> +
>> +	return sk ? sk->sd.ino : SK_NONAME_SENDER;
>> +}
>> +
>>  static void show_one_unix(char *act, const struct unix_sk_desc *sk)
>>  {
>>  	pr_debug("\t%s: ino %#x peer_ino %#x family %4d type %4d state %2d name %s\n",
>> @@ -462,9 +472,15 @@ static int dump_one_unix_fd(int lfd, u32 id, const struct fd_parms *p)
>>  	 * (i stands for in-flight, cons -- for connections) things.
>>  	 */
>>  	if (sk->rqlen != 0 && !(sk->type == SOCK_STREAM &&
>> -				sk->state == TCP_LISTEN))
>> -		if (dump_sk_queue(lfd, id, NULL))
>> +				sk->state == TCP_LISTEN)) {
>> +		u64 (*f)(const char *, int) = NULL;
>> +
>> +		if (sk->type == SOCK_DGRAM)
>> +			f = find_unix_dgram_ino_by_name;
>> +		if (dump_sk_queue(lfd, id, f))
>>  			goto err;
>> +	} else if (sk->rqlen == 0)
>> +		ue->uflags |= USK_EMPTY_Q;
> 
> Don't add this bit into ui image. Emptiness of the queue should be
> determined restore-time by collecting sk-packet image.
> 
>>  
>>  	pr_info("Dumping unix socket at %d\n", p->fd);
>>  	show_one_unix("Dumping", sk);
>>
>> _______________________________________________
>> CRIU mailing list
>> CRIU@openvz.org
>> https://lists.openvz.org/mailman/listinfo/criu
>> .
>>
>