From mboxrd@z Thu Jan 1 00:00:00 1970 From: Vadim Kochan Subject: Re: [PATCH iproute2] ss: Show more info (ring,fanout) for packet socks Date: Thu, 14 May 2015 23:44:08 +0300 Message-ID: <20150514204408.GA25513@angus-think.lan> References: <1431509966-5054-1-git-send-email-vadim4j@gmail.com> <20150514110900.GA28582@angus-think.wlc.globallogic.com> <20150514202143.GA22330@angus-think.lan> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Vadim Kochan , Network Development To: Willem de Bruijn Return-path: Received: from mail-wi0-f176.google.com ([209.85.212.176]:38558 "EHLO mail-wi0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932953AbbENUot (ORCPT ); Thu, 14 May 2015 16:44:49 -0400 Received: by wicnf17 with SMTP id nf17so109336534wic.1 for ; Thu, 14 May 2015 13:44:48 -0700 (PDT) Content-Disposition: inline In-Reply-To: Sender: netdev-owner@vger.kernel.org List-ID: 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 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 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)");