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]
Message-ID: <e2d7436a1001070027u44dbb9abx94541bcf7d7e2418@mail.gmail.com>
Date:	Thu, 7 Jan 2010 09:27:48 +0100
From:	Michał Mirosław <mirqus@...il.com>
To:	"Michael S. Tsirkin" <mst@...hat.com>
Cc:	David Miller <davem@...emloft.net>, cfriesen@...tel.com,
	eric.dumazet@...il.com, nhorman@...driver.com,
	linux-kernel@...r.kernel.org, netdev@...r.kernel.org
Subject: Re: [PATCH] net: packet: option to only pass skb protocol

2010/1/6 Michael S. Tsirkin <mst@...hat.com>:
> On Tue, Jan 05, 2010 at 03:51:50PM -0800, David Miller wrote:
>> From: "Chris Friesen" <cfriesen@...tel.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
--
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