netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Michał Mirosław" <mirqus@gmail.com>
To: "Michael S. Tsirkin" <mst@redhat.com>
Cc: David Miller <davem@davemloft.net>,
	cfriesen@nortel.com, eric.dumazet@gmail.com,
	nhorman@tuxdriver.com, linux-kernel@vger.kernel.org,
	netdev@vger.kernel.org
Subject: Re: [PATCH] net: packet: option to only pass skb protocol
Date: Thu, 7 Jan 2010 09:27:48 +0100	[thread overview]
Message-ID: <e2d7436a1001070027u44dbb9abx94541bcf7d7e2418@mail.gmail.com> (raw)
In-Reply-To: <20100106091257.GB599@redhat.com>

2010/1/6 Michael S. Tsirkin <mst@redhat.com>:
> On Tue, Jan 05, 2010 at 03:51:50PM -0800, David Miller wrote:
>> From: "Chris Friesen" <cfriesen@nortel.com>
>> Date: Tue, 05 Jan 2010 16:13:29 -0600
>> > If SOCK_RAW packets are being sent, the protocol number is embedded in
>> > the packet data
>> Where exactly is that protocol value?  Not every link level protocol
>> is ethernet.
>> We support FDDI, HIPPI, wireless, VLAN, PPP, and a host of others.
>> So you can't know for sure unless you assume ethernet, which you
>> can't do.
> You are right.  This is TX though so the socket is bound to a specific
> device, and devices know which link protocol they use.  So we could add a
> get_protocol operation to each device type, and call it if the protocol
> passed is ETH_P_ALL to get the real one.
>
> Like this: except I only added this for ethernet, and I would have to
> add this for the rest of device types. But I would like to hear what
> others think about this before I do the rest of the work for the rest of
> device types.
>
> Does the below look sane?
>
[...]
> diff --git a/net/ethernet/eth.c b/net/ethernet/eth.c
> index 205a1c1..3e7761d 100644
> --- a/net/ethernet/eth.c
> +++ b/net/ethernet/eth.c
> @@ -231,6 +231,17 @@ int eth_header_parse(const struct sk_buff *skb, unsigned char *haddr)
>  EXPORT_SYMBOL(eth_header_parse);
>
>  /**
> + * eth_get_protocol - extract protocol value from packet
> + * @skb: packet to extract protocol from
> + * @dev: source device
> + */
> +__be16 eth_get_protocol(const struct sk_buff *skb, struct net_device *dev)
> +{
> +       const struct ethhdr *eth = eth_hdr(skb);
> +       return eth->h_proto
> +}
[...]

You might want taking fragment of eth_type_trans() for this function
so that 802.2/IPX would be detected too.

Best Regards,
Michał Mirosław

      parent reply	other threads:[~2010-01-07  8:27 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-05 18:57 [PATCH] net: packet: option to only pass skb protocol Michael S. Tsirkin
2010-01-05 19:27 ` Eric Dumazet
2010-01-05 20:50   ` Michael S. Tsirkin
2010-01-05 21:40     ` David Miller
2010-01-05 21:50       ` Michael S. Tsirkin
2010-01-05 21:28 ` Chris Friesen
2010-01-05 21:42   ` David Miller
2010-01-05 21:45     ` Michael S. Tsirkin
2010-01-05 22:05       ` Michael S. Tsirkin
2010-01-05 22:13     ` Chris Friesen
2010-01-05 22:27       ` Michael S. Tsirkin
2010-01-05 23:51       ` David Miller
2010-01-06  9:12         ` Michael S. Tsirkin
2010-01-06 19:24           ` Michael S. Tsirkin
2010-01-07  8:27           ` Michał Mirosław [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=e2d7436a1001070027u44dbb9abx94541bcf7d7e2418@mail.gmail.com \
    --to=mirqus@gmail.com \
    --cc=cfriesen@nortel.com \
    --cc=davem@davemloft.net \
    --cc=eric.dumazet@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mst@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=nhorman@tuxdriver.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).