Skip to content

Commit e5c5d22

Browse files
hormsdavem330
authored andcommitted
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>
1 parent 8b49a4c commit e5c5d22

16 files changed

Lines changed: 24 additions & 21 deletions

File tree

‎drivers/firewire/net.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@ static int fwnet_finish_incoming_packet(struct net_device *net,
547547
if (memcmp(eth->h_dest, net->dev_addr, net->addr_len))
548548
skb->pkt_type = PACKET_OTHERHOST;
549549
}
550-
if (ntohs(eth->h_proto) >= 1536) {
550+
if (ntohs(eth->h_proto) >= ETH_P_802_3_MIN) {
551551
protocol = eth->h_proto;
552552
} else {
553553
rawp = (u16 *)skb->data;

‎drivers/isdn/i4l/isdn_net.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1385,7 +1385,7 @@ isdn_net_type_trans(struct sk_buff *skb, struct net_device *dev)
13851385
if (memcmp(eth->h_dest, dev->dev_addr, ETH_ALEN))
13861386
skb->pkt_type = PACKET_OTHERHOST;
13871387
}
1388-
if (ntohs(eth->h_proto) >= 1536)
1388+
if (ntohs(eth->h_proto) >= ETH_P_802_3_MIN)
13891389
return eth->h_proto;
13901390

13911391
rawp = skb->data;

‎drivers/media/dvb-core/dvb_net.c‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ static __be16 dvb_net_eth_type_trans(struct sk_buff *skb,
185185
skb->pkt_type=PACKET_MULTICAST;
186186
}
187187

188-
if (ntohs(eth->h_proto) >= 1536)
188+
if (ntohs(eth->h_proto) >= ETH_P_802_3_MIN)
189189
return eth->h_proto;
190190

191191
rawp = skb->data;
@@ -228,9 +228,9 @@ static int ule_test_sndu( struct dvb_net_priv *p )
228228
static int ule_bridged_sndu( struct dvb_net_priv *p )
229229
{
230230
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) {
232232
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. */
234234
if(framelen != ntohs(hdr->h_proto)) {
235235
return -1;
236236
}
@@ -320,7 +320,7 @@ static int handle_ule_extensions( struct dvb_net_priv *p )
320320
(int) p->ule_sndu_type, l, total_ext_len);
321321
#endif
322322

323-
} while (p->ule_sndu_type < 1536);
323+
} while (p->ule_sndu_type < ETH_P_802_3_MIN);
324324

325325
return total_ext_len;
326326
}
@@ -712,7 +712,7 @@ static void dvb_net_ule( struct net_device *dev, const u8 *buf, size_t buf_len )
712712
}
713713

714714
/* Handle ULE Extension Headers. */
715-
if (priv->ule_sndu_type < 1536) {
715+
if (priv->ule_sndu_type < ETH_P_802_3_MIN) {
716716
/* There is an extension header. Handle it accordingly. */
717717
int l = handle_ule_extensions(priv);
718718
if (l < 0) {

‎drivers/net/ethernet/sun/niu.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6618,7 +6618,7 @@ static u64 niu_compute_tx_flags(struct sk_buff *skb, struct ethhdr *ehdr,
66186618
(len << TXHDR_LEN_SHIFT) |
66196619
((l3off / 2) << TXHDR_L3START_SHIFT) |
66206620
(ihl << TXHDR_IHL_SHIFT) |
6621-
((eth_proto_inner < 1536) ? TXHDR_LLC : 0) |
6621+
((eth_proto_inner < ETH_P_802_3_MIN) ? TXHDR_LLC : 0) |
66226622
((eth_proto == ETH_P_8021Q) ? TXHDR_VLAN : 0) |
66236623
(ipv6 ? TXHDR_IP_VER : 0) |
66246624
csum_bits);

‎drivers/net/plip/plip.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,7 @@ static __be16 plip_type_trans(struct sk_buff *skb, struct net_device *dev)
560560
* so don't forget to remove it.
561561
*/
562562

563-
if (ntohs(eth->h_proto) >= 1536)
563+
if (ntohs(eth->h_proto) >= ETH_P_802_3_MIN)
564564
return eth->h_proto;
565565

566566
rawp = skb->data;

‎drivers/net/wireless/ray_cs.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -953,7 +953,7 @@ static int translate_frame(ray_dev_t *local, struct tx_msg __iomem *ptx,
953953
unsigned char *data, int len)
954954
{
955955
__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 */
957957
pr_debug("ray_cs translate_frame DIX II\n");
958958
/* Copy LLC header to card buffer */
959959
memcpy_toio(&ptx->var, eth2_llc, sizeof(eth2_llc));

‎include/linux/if_vlan.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ static inline void vlan_set_encap_proto(struct sk_buff *skb,
339339
*/
340340

341341
proto = vhdr->h_vlan_encapsulated_proto;
342-
if (ntohs(proto) >= 1536) {
342+
if (ntohs(proto) >= ETH_P_802_3_MIN) {
343343
skb->protocol = proto;
344344
return;
345345
}

‎include/uapi/linux/if_ether.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@
9494
#define ETH_P_EDSA 0xDADA /* Ethertype DSA [ NOT AN OFFICIALLY REGISTERED ID ] */
9595
#define ETH_P_AF_IUCV 0xFBFB /* IBM af_iucv [ NOT AN OFFICIALLY REGISTERED ID ] */
9696

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+
97100
/*
98101
* Non DIX types. Won't clash for 1500 types.
99102
*/

‎net/atm/lec.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ struct lane2_ops {
5858
* field in h_type field. Data follows immediately after header.
5959
* 2. LLC Data frames whose total length, including LLC field and data,
6060
* 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
6262
* in the h_type field. The LLC field follows header immediately.
6363
* 3. LLC data frames longer than this maximum MUST be encoded by placing
6464
* the value 0 in the h_type field.

‎net/bluetooth/bnep/netdev.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ static u16 bnep_net_eth_proto(struct sk_buff *skb)
136136
struct ethhdr *eh = (void *) skb->data;
137137
u16 proto = ntohs(eh->h_proto);
138138

139-
if (proto >= 1536)
139+
if (proto >= ETH_P_802_3_MIN)
140140
return proto;
141141

142142
if (get_unaligned((__be16 *) skb->data) == htons(0xFFFF))

0 commit comments

Comments
 (0)