diff options
Diffstat (limited to 'net')
-rw-r--r-- | net/8021q/vlan_core.c | 60 | ||||
-rw-r--r-- | net/core/dev.c | 2 |
2 files changed, 34 insertions, 28 deletions
diff --git a/net/8021q/vlan_core.c b/net/8021q/vlan_core.c index 41495dc2a4c9..fcc684678af6 100644 --- a/net/8021q/vlan_core.c +++ b/net/8021q/vlan_core.c | |||
@@ -23,6 +23,31 @@ bool vlan_do_receive(struct sk_buff **skbp) | |||
23 | return false; | 23 | return false; |
24 | 24 | ||
25 | skb->dev = vlan_dev; | 25 | skb->dev = vlan_dev; |
26 | if (skb->pkt_type == PACKET_OTHERHOST) { | ||
27 | /* Our lower layer thinks this is not local, let's make sure. | ||
28 | * This allows the VLAN to have a different MAC than the | ||
29 | * underlying device, and still route correctly. */ | ||
30 | if (!compare_ether_addr(eth_hdr(skb)->h_dest, | ||
31 | vlan_dev->dev_addr)) | ||
32 | skb->pkt_type = PACKET_HOST; | ||
33 | } | ||
34 | |||
35 | if (!(vlan_dev_info(vlan_dev)->flags & VLAN_FLAG_REORDER_HDR)) { | ||
36 | unsigned int offset = skb->data - skb_mac_header(skb); | ||
37 | |||
38 | /* | ||
39 | * vlan_insert_tag expect skb->data pointing to mac header. | ||
40 | * So change skb->data before calling it and change back to | ||
41 | * original position later | ||
42 | */ | ||
43 | skb_push(skb, offset); | ||
44 | skb = *skbp = vlan_insert_tag(skb, skb->vlan_tci); | ||
45 | if (!skb) | ||
46 | return false; | ||
47 | skb_pull(skb, offset + VLAN_HLEN); | ||
48 | skb_reset_mac_len(skb); | ||
49 | } | ||
50 | |||
26 | skb->priority = vlan_get_ingress_priority(vlan_dev, skb->vlan_tci); | 51 | skb->priority = vlan_get_ingress_priority(vlan_dev, skb->vlan_tci); |
27 | skb->vlan_tci = 0; | 52 | skb->vlan_tci = 0; |
28 | 53 | ||
@@ -31,22 +56,8 @@ bool vlan_do_receive(struct sk_buff **skbp) | |||
31 | u64_stats_update_begin(&rx_stats->syncp); | 56 | u64_stats_update_begin(&rx_stats->syncp); |
32 | rx_stats->rx_packets++; | 57 | rx_stats->rx_packets++; |
33 | rx_stats->rx_bytes += skb->len; | 58 | rx_stats->rx_bytes += skb->len; |
34 | 59 | if (skb->pkt_type == PACKET_MULTICAST) | |
35 | switch (skb->pkt_type) { | ||
36 | case PACKET_BROADCAST: | ||
37 | break; | ||
38 | case PACKET_MULTICAST: | ||
39 | rx_stats->rx_multicast++; | 60 | rx_stats->rx_multicast++; |
40 | break; | ||
41 | case PACKET_OTHERHOST: | ||
42 | /* Our lower layer thinks this is not local, let's make sure. | ||
43 | * This allows the VLAN to have a different MAC than the | ||
44 | * underlying device, and still route correctly. */ | ||
45 | if (!compare_ether_addr(eth_hdr(skb)->h_dest, | ||
46 | vlan_dev->dev_addr)) | ||
47 | skb->pkt_type = PACKET_HOST; | ||
48 | break; | ||
49 | } | ||
50 | u64_stats_update_end(&rx_stats->syncp); | 61 | u64_stats_update_end(&rx_stats->syncp); |
51 | 62 | ||
52 | return true; | 63 | return true; |
@@ -89,18 +100,13 @@ gro_result_t vlan_gro_frags(struct napi_struct *napi, struct vlan_group *grp, | |||
89 | } | 100 | } |
90 | EXPORT_SYMBOL(vlan_gro_frags); | 101 | EXPORT_SYMBOL(vlan_gro_frags); |
91 | 102 | ||
92 | static struct sk_buff *vlan_check_reorder_header(struct sk_buff *skb) | 103 | static struct sk_buff *vlan_reorder_header(struct sk_buff *skb) |
93 | { | 104 | { |
94 | if (vlan_dev_info(skb->dev)->flags & VLAN_FLAG_REORDER_HDR) { | 105 | if (skb_cow(skb, skb_headroom(skb)) < 0) |
95 | if (skb_cow(skb, skb_headroom(skb)) < 0) | 106 | return NULL; |
96 | skb = NULL; | 107 | memmove(skb->data - ETH_HLEN, skb->data - VLAN_ETH_HLEN, 2 * ETH_ALEN); |
97 | if (skb) { | 108 | skb->mac_header += VLAN_HLEN; |
98 | /* Lifted from Gleb's VLAN code... */ | 109 | skb_reset_mac_len(skb); |
99 | memmove(skb->data - ETH_HLEN, | ||
100 | skb->data - VLAN_ETH_HLEN, 12); | ||
101 | skb->mac_header += VLAN_HLEN; | ||
102 | } | ||
103 | } | ||
104 | return skb; | 110 | return skb; |
105 | } | 111 | } |
106 | 112 | ||
@@ -161,7 +167,7 @@ struct sk_buff *vlan_untag(struct sk_buff *skb) | |||
161 | skb_pull_rcsum(skb, VLAN_HLEN); | 167 | skb_pull_rcsum(skb, VLAN_HLEN); |
162 | vlan_set_encap_proto(skb, vhdr); | 168 | vlan_set_encap_proto(skb, vhdr); |
163 | 169 | ||
164 | skb = vlan_check_reorder_header(skb); | 170 | skb = vlan_reorder_header(skb); |
165 | if (unlikely(!skb)) | 171 | if (unlikely(!skb)) |
166 | goto err_free; | 172 | goto err_free; |
167 | 173 | ||
diff --git a/net/core/dev.c b/net/core/dev.c index a54c9f87ddbb..9c58c1ec41a9 100644 --- a/net/core/dev.c +++ b/net/core/dev.c | |||
@@ -3114,7 +3114,7 @@ static int __netif_receive_skb(struct sk_buff *skb) | |||
3114 | 3114 | ||
3115 | skb_reset_network_header(skb); | 3115 | skb_reset_network_header(skb); |
3116 | skb_reset_transport_header(skb); | 3116 | skb_reset_transport_header(skb); |
3117 | skb->mac_len = skb->network_header - skb->mac_header; | 3117 | skb_reset_mac_len(skb); |
3118 | 3118 | ||
3119 | pt_prev = NULL; | 3119 | pt_prev = NULL; |
3120 | 3120 | ||