Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <davem@davemloft.net>
Cc: Jesse Gross <jesse@nicira.com>
Cc: Karsten Keil <isdn@linux-pingi.de>
Cc: John W. Linville <linville@tuxdriver.com>
Cc: Johannes Berg <johannes@sipsolutions.net>
Cc: Bart De Schuymer <bart.de.schuymer@pandora.be>
Cc: Stephen Hemminger <stephen@networkplumber.org>
Cc: Patrick McHardy <kaber@trash.net>
Cc: Marcel Holtmann <marcel@holtmann.org>
Cc: Gustavo Padovan <gustavo@padovan.org>
Cc: Johan Hedberg <johan.hedberg@gmail.com>
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 <mchehab@redhat.com>
Acked-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Signed-off-by: Simon Horman <horms@verge.net.au>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Simon Horman and committed by
David S. Miller
e5c5d22e 8b49a4c7

+24 -21
+1 -1
drivers/firewire/net.c
··· 547 547 if (memcmp(eth->h_dest, net->dev_addr, net->addr_len)) 548 548 skb->pkt_type = PACKET_OTHERHOST; 549 549 } 550 - if (ntohs(eth->h_proto) >= 1536) { 550 + if (ntohs(eth->h_proto) >= ETH_P_802_3_MIN) { 551 551 protocol = eth->h_proto; 552 552 } else { 553 553 rawp = (u16 *)skb->data;
+1 -1
drivers/isdn/i4l/isdn_net.c
··· 1385 1385 if (memcmp(eth->h_dest, dev->dev_addr, ETH_ALEN)) 1386 1386 skb->pkt_type = PACKET_OTHERHOST; 1387 1387 } 1388 - if (ntohs(eth->h_proto) >= 1536) 1388 + if (ntohs(eth->h_proto) >= ETH_P_802_3_MIN) 1389 1389 return eth->h_proto; 1390 1390 1391 1391 rawp = skb->data;
+5 -5
drivers/media/dvb-core/dvb_net.c
··· 185 185 skb->pkt_type=PACKET_MULTICAST; 186 186 } 187 187 188 - if (ntohs(eth->h_proto) >= 1536) 188 + if (ntohs(eth->h_proto) >= ETH_P_802_3_MIN) 189 189 return eth->h_proto; 190 190 191 191 rawp = skb->data; ··· 228 228 static int ule_bridged_sndu( struct dvb_net_priv *p ) 229 229 { 230 230 struct ethhdr *hdr = (struct ethhdr*) p->ule_next_hdr; 231 - if(ntohs(hdr->h_proto) < 1536) { 231 + if(ntohs(hdr->h_proto) < ETH_P_802_3_MIN) { 232 232 int framelen = p->ule_sndu_len - ((p->ule_next_hdr+sizeof(struct ethhdr)) - p->ule_skb->data); 233 - /* A frame Type < 1536 for a bridged frame, introduces a LLC Length field. */ 233 + /* A frame Type < ETH_P_802_3_MIN for a bridged frame, introduces a LLC Length field. */ 234 234 if(framelen != ntohs(hdr->h_proto)) { 235 235 return -1; 236 236 } ··· 320 320 (int) p->ule_sndu_type, l, total_ext_len); 321 321 #endif 322 322 323 - } while (p->ule_sndu_type < 1536); 323 + } while (p->ule_sndu_type < ETH_P_802_3_MIN); 324 324 325 325 return total_ext_len; 326 326 } ··· 712 712 } 713 713 714 714 /* Handle ULE Extension Headers. */ 715 - if (priv->ule_sndu_type < 1536) { 715 + if (priv->ule_sndu_type < ETH_P_802_3_MIN) { 716 716 /* There is an extension header. Handle it accordingly. */ 717 717 int l = handle_ule_extensions(priv); 718 718 if (l < 0) {
+1 -1
drivers/net/ethernet/sun/niu.c
··· 6618 6618 (len << TXHDR_LEN_SHIFT) | 6619 6619 ((l3off / 2) << TXHDR_L3START_SHIFT) | 6620 6620 (ihl << TXHDR_IHL_SHIFT) | 6621 - ((eth_proto_inner < 1536) ? TXHDR_LLC : 0) | 6621 + ((eth_proto_inner < ETH_P_802_3_MIN) ? TXHDR_LLC : 0) | 6622 6622 ((eth_proto == ETH_P_8021Q) ? TXHDR_VLAN : 0) | 6623 6623 (ipv6 ? TXHDR_IP_VER : 0) | 6624 6624 csum_bits);
+1 -1
drivers/net/plip/plip.c
··· 560 560 * so don't forget to remove it. 561 561 */ 562 562 563 - if (ntohs(eth->h_proto) >= 1536) 563 + if (ntohs(eth->h_proto) >= ETH_P_802_3_MIN) 564 564 return eth->h_proto; 565 565 566 566 rawp = skb->data;
+1 -1
drivers/net/wireless/ray_cs.c
··· 953 953 unsigned char *data, int len) 954 954 { 955 955 __be16 proto = ((struct ethhdr *)data)->h_proto; 956 - if (ntohs(proto) >= 1536) { /* DIX II ethernet frame */ 956 + if (ntohs(proto) >= ETH_P_802_3_MIN) { /* DIX II ethernet frame */ 957 957 pr_debug("ray_cs translate_frame DIX II\n"); 958 958 /* Copy LLC header to card buffer */ 959 959 memcpy_toio(&ptx->var, eth2_llc, sizeof(eth2_llc));
+1 -1
include/linux/if_vlan.h
··· 339 339 */ 340 340 341 341 proto = vhdr->h_vlan_encapsulated_proto; 342 - if (ntohs(proto) >= 1536) { 342 + if (ntohs(proto) >= ETH_P_802_3_MIN) { 343 343 skb->protocol = proto; 344 344 return; 345 345 }
+3
include/uapi/linux/if_ether.h
··· 94 94 #define ETH_P_EDSA 0xDADA /* Ethertype DSA [ NOT AN OFFICIALLY REGISTERED ID ] */ 95 95 #define ETH_P_AF_IUCV 0xFBFB /* IBM af_iucv [ NOT AN OFFICIALLY REGISTERED ID ] */ 96 96 97 + #define ETH_P_802_3_MIN 0x0600 /* If the value in the ethernet type is less than this value 98 + * then the frame is Ethernet II. Else it is 802.3 */ 99 + 97 100 /* 98 101 * Non DIX types. Won't clash for 1500 types. 99 102 */
+1 -1
net/atm/lec.h
··· 58 58 * field in h_type field. Data follows immediately after header. 59 59 * 2. LLC Data frames whose total length, including LLC field and data, 60 60 * but not padding required to meet the minimum data frame length, 61 - * is less than 1536(0x0600) MUST be encoded by placing that length 61 + * is less than ETH_P_802_3_MIN MUST be encoded by placing that length 62 62 * in the h_type field. The LLC field follows header immediately. 63 63 * 3. LLC data frames longer than this maximum MUST be encoded by placing 64 64 * the value 0 in the h_type field.
+1 -1
net/bluetooth/bnep/netdev.c
··· 136 136 struct ethhdr *eh = (void *) skb->data; 137 137 u16 proto = ntohs(eh->h_proto); 138 138 139 - if (proto >= 1536) 139 + if (proto >= ETH_P_802_3_MIN) 140 140 return proto; 141 141 142 142 if (get_unaligned((__be16 *) skb->data) == htons(0xFFFF))
+1 -1
net/bridge/netfilter/ebtables.c
··· 138 138 ethproto = h->h_proto; 139 139 140 140 if (e->bitmask & EBT_802_3) { 141 - if (FWINV2(ntohs(ethproto) >= 1536, EBT_IPROTO)) 141 + if (FWINV2(ntohs(ethproto) >= ETH_P_802_3_MIN, EBT_IPROTO)) 142 142 return 1; 143 143 } else if (!(e->bitmask & EBT_NOPROTO) && 144 144 FWINV2(e->ethproto != ethproto, EBT_IPROTO))
+1 -1
net/ethernet/eth.c
··· 195 195 if (netdev_uses_trailer_tags(dev)) 196 196 return htons(ETH_P_TRAILER); 197 197 198 - if (ntohs(eth->h_proto) >= 1536) 198 + if (ntohs(eth->h_proto) >= ETH_P_802_3_MIN) 199 199 return eth->h_proto; 200 200 201 201 /*
+1 -1
net/mac80211/tx.c
··· 2085 2085 encaps_data = bridge_tunnel_header; 2086 2086 encaps_len = sizeof(bridge_tunnel_header); 2087 2087 skip_header_bytes -= 2; 2088 - } else if (ethertype >= 0x600) { 2088 + } else if (ethertype >= ETH_P_802_3_MIN) { 2089 2089 encaps_data = rfc1042_header; 2090 2090 encaps_len = sizeof(rfc1042_header); 2091 2091 skip_header_bytes -= 2;
+1 -1
net/openvswitch/datapath.c
··· 681 681 /* Normally, setting the skb 'protocol' field would be handled by a 682 682 * call to eth_type_trans(), but it assumes there's a sending 683 683 * device, which we may not have. */ 684 - if (ntohs(eth->h_proto) >= 1536) 684 + if (ntohs(eth->h_proto) >= ETH_P_802_3_MIN) 685 685 packet->protocol = eth->h_proto; 686 686 else 687 687 packet->protocol = htons(ETH_P_802_2);
+3 -3
net/openvswitch/flow.c
··· 466 466 proto = *(__be16 *) skb->data; 467 467 __skb_pull(skb, sizeof(__be16)); 468 468 469 - if (ntohs(proto) >= 1536) 469 + if (ntohs(proto) >= ETH_P_802_3_MIN) 470 470 return proto; 471 471 472 472 if (skb->len < sizeof(struct llc_snap_hdr)) ··· 483 483 484 484 __skb_pull(skb, sizeof(struct llc_snap_hdr)); 485 485 486 - if (ntohs(llc->ethertype) >= 1536) 486 + if (ntohs(llc->ethertype) >= ETH_P_802_3_MIN) 487 487 return llc->ethertype; 488 488 489 489 return htons(ETH_P_802_2); ··· 1038 1038 1039 1039 if (attrs & (1 << OVS_KEY_ATTR_ETHERTYPE)) { 1040 1040 swkey->eth.type = nla_get_be16(a[OVS_KEY_ATTR_ETHERTYPE]); 1041 - if (ntohs(swkey->eth.type) < 1536) 1041 + if (ntohs(swkey->eth.type) < ETH_P_802_3_MIN) 1042 1042 return -EINVAL; 1043 1043 attrs &= ~(1 << OVS_KEY_ATTR_ETHERTYPE); 1044 1044 } else {
+1 -1
net/wireless/util.c
··· 511 511 encaps_data = bridge_tunnel_header; 512 512 encaps_len = sizeof(bridge_tunnel_header); 513 513 skip_header_bytes -= 2; 514 - } else if (ethertype > 0x600) { 514 + } else if (ethertype >= ETH_P_802_3_MIN) { 515 515 encaps_data = rfc1042_header; 516 516 encaps_len = sizeof(rfc1042_header); 517 517 skip_header_bytes -= 2;