public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Atzm Watanabe <atzm@stratosphere.co.jp>
To: "David Laight" <David.Laight@ACULAB.COM>
Cc: <netdev@vger.kernel.org>,
	"Stephen Hemminger" <stephen@networkplumber.org>,
	"Ben Hutchings" <bhutchings@solarflare.com>,
	"David Miller" <davem@davemloft.net>,
	"Daniel Borkmann" <dborkman@redhat.com>
Subject: Re: [PATCH v2] packet: Deliver VLAN TPID to userspace
Date: Wed, 11 Dec 2013 21:53:09 +0900	[thread overview]
Message-ID: <87txef7dmy.wl%atzm@stratosphere.co.jp> (raw)
In-Reply-To: <AE90C24D6B3A694183C094C60CF0A2F6026B7476@saturn3.aculab.com>

At Tue, 10 Dec 2013 12:59:15 -0000,
David Laight wrote:
> 
> > From: Atzm Watanabe
> > Sent: 10 December 2013 12:41
> > After the 802.1AD support, userspace packet receivers (packet dumper,
> > software switch, and the like) need how to know VLAN TPID in order to
> > reconstruct original tagged frame.
> ...
> > -#define TP_STATUS_VLAN_VALID	(1 << 4) /* auxdata has valid tp_vlan_tci */
> > +#define TP_STATUS_VLAN_VALID	(1 << 4) /* auxdata has valid tp_vlan_tci and tp_vlan_tpid */
> 
> How can userland (I presume) determine whether tp_vlan_tpid is valid?

Thank you for pointing it.
I'll add a definition which indicates whether tp_vlan_tpid is valid.


> > +struct tpacket_hdr_variant2 {
> > +	__u32	tp_rxhash;
> > +	__u32	tp_vlan_tci;
> > +	__u32	tp_vlan_tpid;
> > +};
> > +
> >  struct tpacket3_hdr {
> >  	__u32		tp_next_offset;
> >  	__u32		tp_sec;
> > @@ -153,6 +159,7 @@ struct tpacket3_hdr {
> >  	/* pkt_hdr variants */
> >  	union {
> >  		struct tpacket_hdr_variant1 hv1;
> > +		struct tpacket_hdr_variant2 hv2;
> >  	};
> >  };
> 
> You've defined a new header variant, but all the code seems to rely
> on the fact that the 'new' variant is identical to the old one
> with the addition of an extra field at the end.
> 
> In which case it ought to be valid to just extend the old header variant.
> If the header really can change format there ought to be a discriminating
> member somewhere - which you don't seem to have changed.

Yes.  I think that struct tpacket3_hdr can grow safely until 48 bytes,
so I'd just like to extend tpacket_hdr_variant1 like you said.

But in the past discussions, there were mentions that a new member
cannot be added into struct tpacket_hdr_variant1, and possibly the
variant which includes a new member should be separated from the old
one.

  http://patchwork.ozlabs.org/patch/284671/
  http://patchwork.ozlabs.org/patch/285382/


Hmm...  I'll resend a patch v3 which includes fixes for your comments
and is using the method that just extends struct tpacket_hdr_variant1. 
If this has any problems, I'll add definition or flag that indicates
whether a new variant exists, and send it as the v3.
If you have any thoughts on that, would you please tell me?


> > diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
> > index 9d70f13..3c75878 100644
> > --- a/net/packet/af_packet.c
> > +++ b/net/packet/af_packet.c
> > @@ -975,11 +975,15 @@ static void prb_clear_rxhash(struct tpacket_kbdq_core *pkc,
> >  static void prb_fill_vlan_info(struct tpacket_kbdq_core *pkc,
> >  			struct tpacket3_hdr *ppd)
> >  {
> > +	BUILD_BUG_ON(TPACKET_ALIGN(sizeof(*ppd)) != 48);
> 
> I'd add a comment about why check matters.
> (ie the fact that it can safely grow until that is no longer true.)

Agreed, will add.


Thank you.

  reply	other threads:[~2013-12-11 12:53 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-10 12:41 [PATCH v2] packet: Deliver VLAN TPID to userspace Atzm Watanabe
2013-12-10 12:59 ` David Laight
2013-12-11 12:53   ` Atzm Watanabe [this message]
2013-12-11 13:19     ` David Laight
2013-12-12 10:30       ` Atzm Watanabe

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=87txef7dmy.wl%atzm@stratosphere.co.jp \
    --to=atzm@stratosphere.co.jp \
    --cc=David.Laight@ACULAB.COM \
    --cc=bhutchings@solarflare.com \
    --cc=davem@davemloft.net \
    --cc=dborkman@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=stephen@networkplumber.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