Skip to content

Commit bf9ae53

Browse files
Octavian Purdiladavem330
authored andcommitted
llc: use dev_hard_header
Using dev_hard_header allows us to use LLC with VLANs and potentially other Ethernet/TokernRing specific encapsulations. It also removes code duplication between LLC and Ethernet/TokenRing core code. Signed-off-by: Octavian Purdila <opurdila@ixiacom.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent f83d664 commit bf9ae53

4 files changed

Lines changed: 17 additions & 47 deletions

File tree

‎drivers/net/myri_sbus.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -716,10 +716,10 @@ static int myri_header(struct sk_buff *skb, struct net_device *dev,
716716
pad[0] = MYRI_PAD_LEN;
717717
pad[1] = 0xab;
718718

719-
/* Set the protocol type. For a packet of type ETH_P_802_3 we put the length
720-
* in here instead. It is up to the 802.2 layer to carry protocol information.
719+
/* Set the protocol type. For a packet of type ETH_P_802_3/2 we put the
720+
* length in here instead.
721721
*/
722-
if (type != ETH_P_802_3)
722+
if (type != ETH_P_802_3 && type != ETH_P_802_2)
723723
eth->h_proto = htons(type);
724724
else
725725
eth->h_proto = htons(len);

‎net/8021q/vlan_dev.c‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -263,11 +263,10 @@ static int vlan_dev_hard_header(struct sk_buff *skb, struct net_device *dev,
263263
vhdr->h_vlan_TCI = htons(vlan_tci);
264264

265265
/*
266-
* Set the protocol type. For a packet of type ETH_P_802_3 we
267-
* put the length in here instead. It is up to the 802.2
268-
* layer to carry protocol information.
266+
* Set the protocol type. For a packet of type ETH_P_802_3/2 we
267+
* put the length in here instead.
269268
*/
270-
if (type != ETH_P_802_3)
269+
if (type != ETH_P_802_3 && type != ETH_P_802_2)
271270
vhdr->h_vlan_encapsulated_proto = htons(type);
272271
else
273272
vhdr->h_vlan_encapsulated_proto = htons(len);

‎net/ethernet/eth.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,16 +73,16 @@ __setup("ether=", netdev_boot_setup);
7373
* @len: packet length (<= skb->len)
7474
*
7575
*
76-
* Set the protocol type. For a packet of type ETH_P_802_3 we put the length
77-
* in here instead. It is up to the 802.2 layer to carry protocol information.
76+
* Set the protocol type. For a packet of type ETH_P_802_3/2 we put the length
77+
* in here instead.
7878
*/
7979
int eth_header(struct sk_buff *skb, struct net_device *dev,
8080
unsigned short type,
8181
const void *daddr, const void *saddr, unsigned len)
8282
{
8383
struct ethhdr *eth = (struct ethhdr *)skb_push(skb, ETH_HLEN);
8484

85-
if (type != ETH_P_802_3)
85+
if (type != ETH_P_802_3 && type != ETH_P_802_2)
8686
eth->h_proto = htons(type);
8787
else
8888
eth->h_proto = htons(len);

‎net/llc/llc_output.c‎

Lines changed: 8 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -33,48 +33,19 @@
3333
int llc_mac_hdr_init(struct sk_buff *skb,
3434
const unsigned char *sa, const unsigned char *da)
3535
{
36-
int rc = 0;
36+
int rc = -EINVAL;
3737

3838
switch (skb->dev->type) {
39-
#ifdef CONFIG_TR
40-
case ARPHRD_IEEE802_TR: {
41-
struct net_device *dev = skb->dev;
42-
struct trh_hdr *trh;
43-
44-
skb_push(skb, sizeof(*trh));
45-
skb_reset_mac_header(skb);
46-
trh = tr_hdr(skb);
47-
trh->ac = AC;
48-
trh->fc = LLC_FRAME;
49-
if (sa)
50-
memcpy(trh->saddr, sa, dev->addr_len);
51-
else
52-
memset(trh->saddr, 0, dev->addr_len);
53-
if (da) {
54-
memcpy(trh->daddr, da, dev->addr_len);
55-
tr_source_route(skb, trh, dev);
56-
skb_reset_mac_header(skb);
57-
}
58-
break;
59-
}
60-
#endif
39+
case ARPHRD_IEEE802_TR:
6140
case ARPHRD_ETHER:
62-
case ARPHRD_LOOPBACK: {
63-
unsigned short len = skb->len;
64-
struct ethhdr *eth;
65-
66-
skb_push(skb, sizeof(*eth));
67-
skb_reset_mac_header(skb);
68-
eth = eth_hdr(skb);
69-
eth->h_proto = htons(len);
70-
memcpy(eth->h_dest, da, ETH_ALEN);
71-
memcpy(eth->h_source, sa, ETH_ALEN);
41+
case ARPHRD_LOOPBACK:
42+
rc = dev_hard_header(skb, skb->dev, ETH_P_802_2, da, sa,
43+
skb->len);
44+
if (rc > 0)
45+
rc = 0;
7246
break;
73-
}
7447
default:
75-
printk(KERN_WARNING "device type not supported: %d\n",
76-
skb->dev->type);
77-
rc = -EINVAL;
48+
WARN(1, "device type not supported: %d\n", skb->dev->type);
7849
}
7950
return rc;
8051
}

0 commit comments

Comments
 (0)