lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:	Thu, 14 May 2015 23:44:08 +0300
From:	Vadim Kochan <vadim4j@...il.com>
To:	Willem de Bruijn <willemb@...gle.com>
Cc:	Vadim Kochan <vadim4j@...il.com>,
	Network Development <netdev@...r.kernel.org>
Subject: Re: [PATCH iproute2] ss: Show more info (ring,fanout) for packet
 socks

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@...il.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@...il.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)");
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ