From 7cd4615505a3b2b6936cd61b82d30aba95d8f184 Mon Sep 17 00:00:00 2001 From: Simon Horman Date: Thu, 28 Mar 2013 12:01:17 -0700 Subject: [PATCH] datapath: net: add ETH_P_802_3_MIN Add a new constant ETH_P_802_3_MIN, the minimum ethernet type for an 802.3 frame. Frames with a lower value in the ethernet type field are Ethernet II. Also update all the users of this value that David Miller and I could find to use the new constant. Also correct a bug in util.c. The comparison with ETH_P_802_3_MIN should be >= not >. As suggested by Jesse Gross. Compile tested only. Cc: David Miller Cc: Jesse Gross Cc: Karsten Keil Cc: John W. Linville Cc: Johannes Berg Cc: Bart De Schuymer Cc: Stephen Hemminger Cc: Patrick McHardy Cc: Marcel Holtmann Cc: Gustavo Padovan Cc: Johan Hedberg Cc: linux-bluetooth@vger.kernel.org Cc: netfilter-devel@vger.kernel.org Cc: bridge@lists.linux-foundation.org Cc: linux-wireless@vger.kernel.org Cc: linux1394-devel@lists.sourceforge.net Cc: linux-media@vger.kernel.org Cc: netdev@vger.kernel.org Cc: dev@openvswitch.org Acked-by: Mauro Carvalho Chehab Acked-by: Stefan Richter Signed-off-by: Simon Horman Signed-off-by: Jesse Gross --- datapath/datapath.c | 2 +- datapath/flow.c | 6 +++--- datapath/linux/compat/include/linux/if_ether.h | 4 ++++ datapath/tunnel.c | 2 +- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/datapath/datapath.c b/datapath/datapath.c index 5964789de..bab29d21b 100644 --- a/datapath/datapath.c +++ b/datapath/datapath.c @@ -834,7 +834,7 @@ static int ovs_packet_cmd_execute(struct sk_buff *skb, struct genl_info *info) /* Normally, setting the skb 'protocol' field would be handled by a * call to eth_type_trans(), but it assumes there's a sending * device, which we may not have. */ - if (ntohs(eth->h_proto) >= 1536) + if (ntohs(eth->h_proto) >= ETH_P_802_3_MIN) packet->protocol = eth->h_proto; else packet->protocol = htons(ETH_P_802_2); diff --git a/datapath/flow.c b/datapath/flow.c index 2aeb7040d..841e8be0e 100644 --- a/datapath/flow.c +++ b/datapath/flow.c @@ -482,7 +482,7 @@ static __be16 parse_ethertype(struct sk_buff *skb) proto = *(__be16 *) skb->data; __skb_pull(skb, sizeof(__be16)); - if (ntohs(proto) >= 1536) + if (ntohs(proto) >= ETH_P_802_3_MIN) return proto; if (skb->len < sizeof(struct llc_snap_hdr)) @@ -499,7 +499,7 @@ static __be16 parse_ethertype(struct sk_buff *skb) __skb_pull(skb, sizeof(struct llc_snap_hdr)); - if (ntohs(llc->ethertype) >= 1536) + if (ntohs(llc->ethertype) >= ETH_P_802_3_MIN) return llc->ethertype; return htons(ETH_P_802_2); @@ -1181,7 +1181,7 @@ int ovs_flow_from_nlattrs(struct sw_flow_key *swkey, int *key_lenp, if (attrs & (1 << OVS_KEY_ATTR_ETHERTYPE)) { swkey->eth.type = nla_get_be16(a[OVS_KEY_ATTR_ETHERTYPE]); - if (ntohs(swkey->eth.type) < 1536) + if (ntohs(swkey->eth.type) < ETH_P_802_3_MIN) return -EINVAL; attrs &= ~(1 << OVS_KEY_ATTR_ETHERTYPE); } else { diff --git a/datapath/linux/compat/include/linux/if_ether.h b/datapath/linux/compat/include/linux/if_ether.h index 41cc05375..85b0d22ed 100644 --- a/datapath/linux/compat/include/linux/if_ether.h +++ b/datapath/linux/compat/include/linux/if_ether.h @@ -16,4 +16,8 @@ #endif /* linux kernel < 2.6.30 */ +#ifndef ETH_P_802_3_MIN +#define ETH_P_802_3_MIN 0x0600 +#endif + #endif diff --git a/datapath/tunnel.c b/datapath/tunnel.c index fca016c64..057aaed05 100644 --- a/datapath/tunnel.c +++ b/datapath/tunnel.c @@ -65,7 +65,7 @@ void ovs_tnl_rcv(struct vport *vport, struct sk_buff *skb) skb_reset_mac_header(skb); eh = eth_hdr(skb); - if (likely(ntohs(eh->h_proto) >= 1536)) + if (likely(ntohs(eh->h_proto) >= ETH_P_802_3_MIN)) skb->protocol = eh->h_proto; else skb->protocol = htons(ETH_P_802_2); -- 2.43.0