Commit bf9ae538 authored by Octavian Purdila's avatar Octavian Purdila Committed by David S. Miller

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: default avatarOctavian Purdila <opurdila@ixiacom.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent f83d664e
...@@ -716,10 +716,10 @@ static int myri_header(struct sk_buff *skb, struct net_device *dev, ...@@ -716,10 +716,10 @@ static int myri_header(struct sk_buff *skb, struct net_device *dev,
pad[0] = MYRI_PAD_LEN; pad[0] = MYRI_PAD_LEN;
pad[1] = 0xab; pad[1] = 0xab;
/* Set the protocol type. For a packet of type ETH_P_802_3 we put the length /* Set the protocol type. For a packet of type ETH_P_802_3/2 we put the
* in here instead. It is up to the 802.2 layer to carry protocol information. * length in here instead.
*/ */
if (type != ETH_P_802_3) if (type != ETH_P_802_3 && type != ETH_P_802_2)
eth->h_proto = htons(type); eth->h_proto = htons(type);
else else
eth->h_proto = htons(len); eth->h_proto = htons(len);
......
...@@ -263,11 +263,10 @@ static int vlan_dev_hard_header(struct sk_buff *skb, struct net_device *dev, ...@@ -263,11 +263,10 @@ static int vlan_dev_hard_header(struct sk_buff *skb, struct net_device *dev,
vhdr->h_vlan_TCI = htons(vlan_tci); vhdr->h_vlan_TCI = htons(vlan_tci);
/* /*
* Set the protocol type. For a packet of type ETH_P_802_3 we * Set the protocol type. For a packet of type ETH_P_802_3/2 we
* put the length in here instead. It is up to the 802.2 * put the length in here instead.
* layer to carry protocol information.
*/ */
if (type != ETH_P_802_3) if (type != ETH_P_802_3 && type != ETH_P_802_2)
vhdr->h_vlan_encapsulated_proto = htons(type); vhdr->h_vlan_encapsulated_proto = htons(type);
else else
vhdr->h_vlan_encapsulated_proto = htons(len); vhdr->h_vlan_encapsulated_proto = htons(len);
......
...@@ -73,8 +73,8 @@ __setup("ether=", netdev_boot_setup); ...@@ -73,8 +73,8 @@ __setup("ether=", netdev_boot_setup);
* @len: packet length (<= skb->len) * @len: packet length (<= skb->len)
* *
* *
* Set the protocol type. For a packet of type ETH_P_802_3 we put the length * Set the protocol type. For a packet of type ETH_P_802_3/2 we put the length
* in here instead. It is up to the 802.2 layer to carry protocol information. * in here instead.
*/ */
int eth_header(struct sk_buff *skb, struct net_device *dev, int eth_header(struct sk_buff *skb, struct net_device *dev,
unsigned short type, unsigned short type,
...@@ -82,7 +82,7 @@ int eth_header(struct sk_buff *skb, struct net_device *dev, ...@@ -82,7 +82,7 @@ int eth_header(struct sk_buff *skb, struct net_device *dev,
{ {
struct ethhdr *eth = (struct ethhdr *)skb_push(skb, ETH_HLEN); struct ethhdr *eth = (struct ethhdr *)skb_push(skb, ETH_HLEN);
if (type != ETH_P_802_3) if (type != ETH_P_802_3 && type != ETH_P_802_2)
eth->h_proto = htons(type); eth->h_proto = htons(type);
else else
eth->h_proto = htons(len); eth->h_proto = htons(len);
......
...@@ -33,48 +33,19 @@ ...@@ -33,48 +33,19 @@
int llc_mac_hdr_init(struct sk_buff *skb, int llc_mac_hdr_init(struct sk_buff *skb,
const unsigned char *sa, const unsigned char *da) const unsigned char *sa, const unsigned char *da)
{ {
int rc = 0; int rc = -EINVAL;
switch (skb->dev->type) { switch (skb->dev->type) {
#ifdef CONFIG_TR case ARPHRD_IEEE802_TR:
case ARPHRD_IEEE802_TR: {
struct net_device *dev = skb->dev;
struct trh_hdr *trh;
skb_push(skb, sizeof(*trh));
skb_reset_mac_header(skb);
trh = tr_hdr(skb);
trh->ac = AC;
trh->fc = LLC_FRAME;
if (sa)
memcpy(trh->saddr, sa, dev->addr_len);
else
memset(trh->saddr, 0, dev->addr_len);
if (da) {
memcpy(trh->daddr, da, dev->addr_len);
tr_source_route(skb, trh, dev);
skb_reset_mac_header(skb);
}
break;
}
#endif
case ARPHRD_ETHER: case ARPHRD_ETHER:
case ARPHRD_LOOPBACK: { case ARPHRD_LOOPBACK:
unsigned short len = skb->len; rc = dev_hard_header(skb, skb->dev, ETH_P_802_2, da, sa,
struct ethhdr *eth; skb->len);
if (rc > 0)
skb_push(skb, sizeof(*eth)); rc = 0;
skb_reset_mac_header(skb);
eth = eth_hdr(skb);
eth->h_proto = htons(len);
memcpy(eth->h_dest, da, ETH_ALEN);
memcpy(eth->h_source, sa, ETH_ALEN);
break; break;
}
default: default:
printk(KERN_WARNING "device type not supported: %d\n", WARN(1, "device type not supported: %d\n", skb->dev->type);
skb->dev->type);
rc = -EINVAL;
} }
return rc; return rc;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment