mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jamal Hadi Salim <jhs@mojatatu.com>
To: Cyrill Gorcunov <gorcunov@gmail.com>,
	Eric Dumazet <eric.dumazet@gmail.com>,
	David Ahern <dsa@cumulusnetworks.com>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	David Miller <davem@davemloft.net>,
	kuznet@ms2.inr.ac.ru, jmorris@namei.org, yoshfuji@linux-ipv6.org,
	kaber@trash.net, avagin@openvz.org, stephen@networkplumber.org
Subject: Re: [PATCH v5] net: ip, diag -- Add diag interface for raw sockets
Date: Wed, 28 Sep 2016 06:08:00 -0400	[thread overview]
Message-ID: <caef7649-9d25-6429-eeab-96c027d6cbc2@mojatatu.com> (raw)
In-Reply-To: <20160928090357.GT1876@uranus.lan>

On 16-09-28 05:03 AM, Cyrill Gorcunov wrote:
> In criu we are actively using diag interface to collect sockets
> present in the system when dumping applications. And while for
> unix, tcp, udp[lite], packet, netlink it works as expected,
> the raw sockets do not have. Thus add it.
>
> v2:
>  - add missing sock_put calls in raw_diag_dump_one (by eric.dumazet@)
>  - implement @destroy for diag requests (by dsa@)
>
> v3:
>  - add export of raw_abort for IPv6 (by dsa@)
>  - pass net-admin flag into inet_sk_diag_fill due to
>    changes in net-next branch (by dsa@)
>
> v4:
>  - use @pad in struct inet_diag_req_v2 for raw socket
>    protocol specification: raw module carries sockets
>    which may have custom protocol passed from socket()
>    syscall and sole @sdiag_protocol is not enough to
>    match underlied ones
>  - start reporting protocol specifed in socket() call
>    when sockets are raw ones for the same reason: user
>    space tools like ss may parse this attribute and use
>    it for socket matching
>
> v5 (by eric.dumazet@):
>  - use sock_hold in raw_sock_get instead of atomic_inc,
>    we're holding (raw_v4_hashinfo|raw_v6_hashinfo)->lock
>    when looking up so counter won't be zero here.
>
> CC: David S. Miller <davem@davemloft.net>
> CC: Eric Dumazet <eric.dumazet@gmail.com>
> CC: David Ahern <dsa@cumulusnetworks.com>
> CC: Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>
> CC: James Morris <jmorris@namei.org>
> CC: Hideaki YOSHIFUJI <yoshfuji@linux-ipv6.org>
> CC: Patrick McHardy <kaber@trash.net>
> CC: Andrey Vagin <avagin@openvz.org>
> CC: Stephen Hemminger <stephen@networkplumber.org>
> Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
> ---
>
> Thanks all for feedback! Take a look please once time permit.
>
>  include/net/raw.h              |    6 +
>  include/net/rawv6.h            |    7 +
>  include/uapi/linux/inet_diag.h |    5
>  net/ipv4/Kconfig               |    8 +
>  net/ipv4/Makefile              |    1
>  net/ipv4/inet_diag.c           |    9 +
>  net/ipv4/raw.c                 |   21 +++
>  net/ipv4/raw_diag.c            |  233 +++++++++++++++++++++++++++++++++++++++++
>  net/ipv6/raw.c                 |    7 -
>  9 files changed, 292 insertions(+), 5 deletions(-)
>
> Index: linux-ml.git/include/net/raw.h
> ===================================================================
> --- linux-ml.git.orig/include/net/raw.h
> +++ linux-ml.git/include/net/raw.h
> @@ -23,6 +23,12 @@
>
>  extern struct proto raw_prot;
>
> +extern struct raw_hashinfo raw_v4_hashinfo;
> +struct sock *__raw_v4_lookup(struct net *net, struct sock *sk,
> +			     unsigned short num, __be32 raddr,
> +			     __be32 laddr, int dif);
> +
> +int raw_abort(struct sock *sk, int err);
>  void raw_icmp_error(struct sk_buff *, int, u32);
>  int raw_local_deliver(struct sk_buff *, int);
>
> Index: linux-ml.git/include/net/rawv6.h
> ===================================================================
> --- linux-ml.git.orig/include/net/rawv6.h
> +++ linux-ml.git/include/net/rawv6.h
> @@ -3,6 +3,13 @@
>
>  #include <net/protocol.h>
>
> +extern struct raw_hashinfo raw_v6_hashinfo;
> +struct sock *__raw_v6_lookup(struct net *net, struct sock *sk,
> +			     unsigned short num, const struct in6_addr *loc_addr,
> +			     const struct in6_addr *rmt_addr, int dif);
> +
> +int raw_abort(struct sock *sk, int err);
> +
>  void raw6_icmp_error(struct sk_buff *, int nexthdr,
>  		u8 type, u8 code, int inner_offset, __be32);
>  bool raw6_local_deliver(struct sk_buff *, int);
> Index: linux-ml.git/include/uapi/linux/inet_diag.h
> ===================================================================
> --- linux-ml.git.orig/include/uapi/linux/inet_diag.h
> +++ linux-ml.git/include/uapi/linux/inet_diag.h
> @@ -38,7 +38,10 @@ struct inet_diag_req_v2 {
>  	__u8	sdiag_family;
>  	__u8	sdiag_protocol;
>  	__u8	idiag_ext;
> -	__u8	pad;
> +	union {
> +		__u8	pad;
> +		__u8	sdiag_raw_protocol;	/* SOCK_RAW only, @pad for others */
> +	};


Above looks funny. Why is it a union? pad is for exposing a byte-hole
for padding/alignment reasons and i doubt anybody is using it.
Should you not just rename it?
Also I notice when things like __raw_v4_lookup() are claiming it is 
unsigned short instead of a u8?

cheers,
jamal

  reply	other threads:[~2016-09-28 10:08 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-28  9:03 Cyrill Gorcunov
2016-09-28 10:08 ` Jamal Hadi Salim [this message]
2016-09-28 10:17   ` Cyrill Gorcunov
2016-09-28 10:43     ` Jamal Hadi Salim
2016-09-28 10:51       ` Cyrill Gorcunov
2016-09-28 11:06         ` Jamal Hadi Salim
2016-09-28 11:27           ` Cyrill Gorcunov
2016-09-28 12:06             ` Jamal Hadi Salim
2016-09-28 12:09               ` David Miller
2016-09-28 12:21               ` Cyrill Gorcunov
2016-09-28 12:07             ` David Miller
2016-09-28 12:09               ` Jamal Hadi Salim
2016-09-28 12:16                 ` David Miller
2016-09-28 12:27                   ` Jamal Hadi Salim
2016-09-28 12:38                     ` Jamal Hadi Salim
2016-09-28 12:45                     ` Cyrill Gorcunov
2016-09-28 12:50                       ` Jamal Hadi Salim
2016-09-28 12:57                         ` Cyrill Gorcunov
2016-09-28 12:18               ` Cyrill Gorcunov
2016-09-28 12:57             ` Eric Dumazet
2016-09-28 13:02               ` Eric Dumazet
2016-09-28 13:09                 ` Cyrill Gorcunov
2016-09-28 13:03               ` Cyrill Gorcunov
2016-09-28 13:29                 ` Eric Dumazet
2016-09-28 13:43                   ` Cyrill Gorcunov
2016-09-28 13:49                     ` Eric Dumazet
2016-09-28 14:55                       ` Cyrill Gorcunov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=caef7649-9d25-6429-eeab-96c027d6cbc2@mojatatu.com \
    --to=jhs@mojatatu.com \
    --cc=avagin@openvz.org \
    --cc=davem@davemloft.net \
    --cc=dsa@cumulusnetworks.com \
    --cc=eric.dumazet@gmail.com \
    --cc=gorcunov@gmail.com \
    --cc=jmorris@namei.org \
    --cc=kaber@trash.net \
    --cc=kuznet@ms2.inr.ac.ru \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=stephen@networkplumber.org \
    --cc=yoshfuji@linux-ipv6.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®