netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Vadim Kochan <vadim4j@gmail.com>
To: Willem de Bruijn <willemb@google.com>
Cc: Vadim Kochan <vadim4j@gmail.com>,
	Network Development <netdev@vger.kernel.org>
Subject: Re: [PATCH iproute2] ss: Show more info (ring,fanout) for packet socks
Date: Thu, 14 May 2015 23:44:08 +0300	[thread overview]
Message-ID: <20150514204408.GA25513@angus-think.lan> (raw)
In-Reply-To: <CA+FuTSfzZCwz-FAiq_K3Sq2ALR7rnziWaXq_27Q8OKBAyGJ0gA@mail.gmail.com>

On Thu, May 14, 2015 at 04:39:01PM -0400, Willem de Bruijn wrote:
> On Thu, May 14, 2015 at 4:21 PM, Vadim Kochan <vadim4j@gmail.com> wrote:
> > On Thu, May 14, 2015 at 03:54:41PM -0400, Willem de Bruijn wrote:
> >> On Thu, May 14, 2015 at 7:09 AM, Vadim Kochan <vadim4j@gmail.com> wrote:
> >> > On Wed, May 13, 2015 at 05:10:38PM -0400, Willem de Bruijn wrote:
> >> >> > +               }
> >> >> > +               if (has_fanout) {
> >> >> > +                       uint16_t type = (fanout >> 16) & 0xffff;
> >> >>
> >> >> type can be modified by flags in the upper 8 bits. Better
> >> >> mask those out and report them separately.
> >> > Kernel puts only id & type in diag message, flags are stored in separated
> >> > member of 'struct packet_sock'.
> >>
> >> I don't mean pdi_flags, but
> >>
> >>   PACKET_FANOUT_FLAG_ROLLOVER
> >>   PACKET_FANOUT_FLAG_DEFRAG
> > sure, I understood what you meant.
> >>
> >> which are passed as part of this u32 by the process during setsockopt
> >> PACKET_FANOUT.
> >>
> > OK, its better to look into the kernel:
> >
> > net/packet/af_packet.c
> >
> > static int fanout_add(struct sock *sk, u16 id, u16 type_flags)
> > {
> >         struct packet_fanout *f, *match;
> >         u8 type = type_flags & 0xff;
> >         u8 flags = type_flags >> 8;
> >
> >         ...
> >
> >         match->id = id;
> >         match->type = type;
> >         match->flags = flags;
> >
> >         ...
> > }
> >
> > As I see this function is called from setsockopt, takes type_flags and splits it into type & flags
> > and store them separately in struct packet_fanout.
> >
> > Then what I see in:
> >
> > net/packet/diag.c:
> >
> >
> > static int pdiag_put_fanout(struct packet_sock *po, struct sk_buff *nlskb)
> > {
> >         int ret = 0;
> >
> >         mutex_lock(&fanout_mutex);
> >         if (po->fanout) {
> >                 u32 val;
> >
> >                 val = (u32)po->fanout->id | ((u32)po->fanout->type << 16);
> >                 ret = nla_put_u32(nlskb, PACKET_DIAG_FANOUT, val);
> >         }
> >         mutex_unlock(&fanout_mutex);
> >
> >         return ret;
> > }
> >
> > I see that to put flags here it needs to use po->fanout->flags and mix
> > them into u32 val, but instead I see that it uses only id & type.
> >
> > Please correct me if I am wrong.
> 
> Thanks for the details. You are correct. Flags are not mixed in, like
> are in the getsockopt case. In that case, type can only be 8 bits.
> 
> >
> > Thanks,
> >> >
> >> >>
> >> >> > +
> >> >> > +                       printf("\n\tfanout(");
> >> >> > +                       printf("id:%d,", fanout & 0xff);
> 
> ID can be 16 bits.
Right, will fix it in v2, thanks!

> 
> >> >> > +                       printf("type:0x%x", type);
> >> >> > +                       if (type == 0)
> >> >> > +                               printf("(hash)");
> >> >> > +                       else if (type == 1)
> >> >> > +                               printf("(lb)");
> >> >> > +                       else if (type == 2)
> >> >> > +                               printf("(cpu)");
> >> >> > +                       else if (type == 3)
> >> >> > +                               printf("(rollover)");
> >> >> > +                       else if (type == 4)
> >> >> > +                               printf("(random)");
> >> >> > +                       else if (type == 5)
> >> >> > +                               printf("(qm)");

      reply	other threads:[~2015-05-14 20:44 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-13  9:39 [PATCH iproute2] ss: Show more info (ring,fanout) for packet socks Vadim Kochan
2015-05-13 21:10 ` Willem de Bruijn
2015-05-14 11:09   ` Vadim Kochan
2015-05-14 19:54     ` Willem de Bruijn
2015-05-14 20:21       ` Vadim Kochan
2015-05-14 20:39         ` Willem de Bruijn
2015-05-14 20:44           ` Vadim Kochan [this message]

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=20150514204408.GA25513@angus-think.lan \
    --to=vadim4j@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=willemb@google.com \
    /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;
as well as URLs for NNTP newsgroup(s).