Commit 19acc327258ac5bcd0f31c07853e6d9784010fb4
Committed by
David S. Miller
1 parent
54309fa60b
Exists in
smarc-l5.0.0_1.0.0-ga
and in
5 other branches
gso: Handle Trans-Ether-Bridging protocol in skb_network_protocol()
Rather than having logic to calculate inner protocol in every tunnel gso handler move it to gso code. This simplifies code. Cc: Eric Dumazet <eric.dumazet@gmail.com> Cc: Cong Wang <amwang@redhat.com> Cc: David S. Miller <davem@davemloft.net> Signed-off-by: Pravin B Shelar <pshelar@nicira.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Showing 3 changed files with 13 additions and 10 deletions Side-by-side Diff
net/core/dev.c
... | ... | @@ -2213,6 +2213,17 @@ |
2213 | 2213 | __be16 type = skb->protocol; |
2214 | 2214 | int vlan_depth = ETH_HLEN; |
2215 | 2215 | |
2216 | + /* Tunnel gso handlers can set protocol to ethernet. */ | |
2217 | + if (type == htons(ETH_P_TEB)) { | |
2218 | + struct ethhdr *eth; | |
2219 | + | |
2220 | + if (unlikely(!pskb_may_pull(skb, sizeof(struct ethhdr)))) | |
2221 | + return 0; | |
2222 | + | |
2223 | + eth = (struct ethhdr *)skb_mac_header(skb); | |
2224 | + type = eth->h_proto; | |
2225 | + } | |
2226 | + | |
2216 | 2227 | while (type == htons(ETH_P_8021Q) || type == htons(ETH_P_8021AD)) { |
2217 | 2228 | struct vlan_hdr *vh; |
2218 | 2229 |
net/ipv4/gre.c
... | ... | @@ -150,13 +150,7 @@ |
150 | 150 | csum = false; |
151 | 151 | |
152 | 152 | /* setup inner skb. */ |
153 | - if (greh->protocol == htons(ETH_P_TEB)) { | |
154 | - struct ethhdr *eth = (struct ethhdr *)skb_inner_mac_header(skb); | |
155 | - skb->protocol = eth->h_proto; | |
156 | - } else { | |
157 | - skb->protocol = greh->protocol; | |
158 | - } | |
159 | - | |
153 | + skb->protocol = greh->protocol; | |
160 | 154 | skb->encapsulation = 0; |
161 | 155 | |
162 | 156 | if (unlikely(!pskb_may_pull(skb, ghl))) |
net/ipv4/udp.c
... | ... | @@ -2311,7 +2311,6 @@ |
2311 | 2311 | struct sk_buff *segs = ERR_PTR(-EINVAL); |
2312 | 2312 | int mac_len = skb->mac_len; |
2313 | 2313 | int tnl_hlen = skb_inner_mac_header(skb) - skb_transport_header(skb); |
2314 | - struct ethhdr *inner_eth = (struct ethhdr *)skb_inner_mac_header(skb); | |
2315 | 2314 | __be16 protocol = skb->protocol; |
2316 | 2315 | netdev_features_t enc_features; |
2317 | 2316 | int outer_hlen; |
... | ... | @@ -2324,8 +2323,7 @@ |
2324 | 2323 | skb_reset_mac_header(skb); |
2325 | 2324 | skb_set_network_header(skb, skb_inner_network_offset(skb)); |
2326 | 2325 | skb->mac_len = skb_inner_network_offset(skb); |
2327 | - inner_eth = (struct ethhdr *)skb_mac_header(skb); | |
2328 | - skb->protocol = inner_eth->h_proto; | |
2326 | + skb->protocol = htons(ETH_P_TEB); | |
2329 | 2327 | |
2330 | 2328 | /* segment inner packet. */ |
2331 | 2329 | enc_features = skb->dev->hw_enc_features & netif_skb_features(skb); |