Re: [PATCH v3] net: ip, diag -- Add diag interface for raw sockets

From: David Ahern
Date: Mon Sep 26 2016 - 21:54:52 EST


On 9/26/16 4:38 PM, Cyrill Gorcunov wrote:
> Something like
>
> Index: linux-ml.git/include/uapi/linux/inet_diag.h
> ===================================================================
> --- linux-ml.git.orig/include/uapi/linux/inet_diag.h 2016-09-11 20:56:18.191584145 +0300
> +++ linux-ml.git/include/uapi/linux/inet_diag.h 2016-09-27 01:34:08.413172394 +0300
> @@ -38,7 +38,7 @@ struct inet_diag_req_v2 {
> __u8 sdiag_family;
> __u8 sdiag_protocol;
> __u8 idiag_ext;
> - __u8 pad;
> + __u8 sdiag_raw_protocol; /* SOCK_RAW only, @pad for others */

Seems like that should be a union to keep the API.


> __u32 idiag_states;
> struct inet_diag_sockid id;
> };
>
> and in raw-diag module we will use @sdiag_raw_protocol instead of
> @sdiag_protocol field. Didn't cover ss tool source code yet but
> I think the idea is seen. Still not sure if start using @pad here
> is a good idea (it's uapi), maybe beter to ask nla attribute which would
> come right afterh the inet_diag_req_v2 message?
>

seems reasonable to me since 2 protocols need to be sent to the kernel.

Alternatively, sdiag_protocol could be the actual protocol and the pad union be a flag field with say bit 0 = INET_DIAG_FLAG_SOCK_RAW. Allows other overrides in the future if needed.