]> Pileus Git - ~andy/linux/commitdiff
gso: Handle Trans-Ether-Bridging protocol in skb_network_protocol()
authorPravin B Shelar <pshelar@nicira.com>
Tue, 7 May 2013 20:41:07 +0000 (20:41 +0000)
committerDavid S. Miller <davem@davemloft.net>
Wed, 8 May 2013 20:13:30 +0000 (13:13 -0700)
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>
net/core/dev.c
net/ipv4/gre.c
net/ipv4/udp.c

index 40b1fadaf637cafb12a8aece038882f8ba045274..fc1e289397f5895f3d2191ee78c9b450cc33e5cf 100644 (file)
@@ -2213,6 +2213,17 @@ __be16 skb_network_protocol(struct sk_buff *skb)
        __be16 type = skb->protocol;
        int vlan_depth = ETH_HLEN;
 
+       /* Tunnel gso handlers can set protocol to ethernet. */
+       if (type == htons(ETH_P_TEB)) {
+               struct ethhdr *eth;
+
+               if (unlikely(!pskb_may_pull(skb, sizeof(struct ethhdr))))
+                       return 0;
+
+               eth = (struct ethhdr *)skb_mac_header(skb);
+               type = eth->h_proto;
+       }
+
        while (type == htons(ETH_P_8021Q) || type == htons(ETH_P_8021AD)) {
                struct vlan_hdr *vh;
 
index cc22363965d2a9a66d08e9368cc4e62e2ccea08a..b2e805af9b87a03675d7bac1a7e210124757e566 100644 (file)
@@ -150,13 +150,7 @@ static struct sk_buff *gre_gso_segment(struct sk_buff *skb,
                csum = false;
 
        /* setup inner skb. */
-       if (greh->protocol == htons(ETH_P_TEB)) {
-               struct ethhdr *eth = (struct ethhdr *)skb_inner_mac_header(skb);
-               skb->protocol = eth->h_proto;
-       } else {
-               skb->protocol = greh->protocol;
-       }
-
+       skb->protocol = greh->protocol;
        skb->encapsulation = 0;
 
        if (unlikely(!pskb_may_pull(skb, ghl)))
index 0ae038a4c7a80929e2083911d3fc17aa5432be3f..0bf5d399a03c1c0eaedeedd4a6a9db4ee2af68e6 100644 (file)
@@ -2311,7 +2311,6 @@ static struct sk_buff *skb_udp_tunnel_segment(struct sk_buff *skb,
        struct sk_buff *segs = ERR_PTR(-EINVAL);
        int mac_len = skb->mac_len;
        int tnl_hlen = skb_inner_mac_header(skb) - skb_transport_header(skb);
-       struct ethhdr *inner_eth = (struct ethhdr *)skb_inner_mac_header(skb);
        __be16 protocol = skb->protocol;
        netdev_features_t enc_features;
        int outer_hlen;
@@ -2324,8 +2323,7 @@ static struct sk_buff *skb_udp_tunnel_segment(struct sk_buff *skb,
        skb_reset_mac_header(skb);
        skb_set_network_header(skb, skb_inner_network_offset(skb));
        skb->mac_len = skb_inner_network_offset(skb);
-       inner_eth = (struct ethhdr *)skb_mac_header(skb);
-       skb->protocol = inner_eth->h_proto;
+       skb->protocol = htons(ETH_P_TEB);
 
        /* segment inner packet. */
        enc_features = skb->dev->hw_enc_features & netif_skb_features(skb);