From patchwork Wed May 8 06:41:07 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pravin B Shelar X-Patchwork-Id: 242505 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 843D32C00F3 for ; Wed, 8 May 2013 16:41:21 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752546Ab3EHGlO (ORCPT ); Wed, 8 May 2013 02:41:14 -0400 Received: from na3sys009aog120.obsmtp.com ([74.125.149.140]:46034 "HELO na3sys009aog120.obsmtp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1752082Ab3EHGlN (ORCPT ); Wed, 8 May 2013 02:41:13 -0400 Received: from mail-pa0-f43.google.com ([209.85.220.43]) (using TLSv1) by na3sys009aob120.postini.com ([74.125.148.12]) with SMTP ID DSNKUYnziQ/BO8uKzWjL12olTW85USaRFieL@postini.com; Tue, 07 May 2013 23:41:13 PDT Received: by mail-pa0-f43.google.com with SMTP id hz10so1101583pad.30 for ; Tue, 07 May 2013 23:41:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:x-received:from:to:cc:subject:date:message-id:x-mailer :x-gm-message-state; bh=hcKwUvPN01UrhUtuiUDhuDR45AhogJ6GZnl1/qfP3+4=; b=UHfFrCx/3ej0PZD53zXXLuxohDFD/jlXiPMM97A87cxk7RQGxC8O9u/d4W4S03duht nIyBZylDfyn5tXR7d3m0RzI2uHt4dBxQ34J5j2je1GkD30VG/S19N0yT4FoLfiSJOmAF Tqe+mBuzcBiAzxfJVj2PKbjy0Q+eEVy2OFwJ+PQ7NR3PwoEzHu+wPqyffr+g2dedpxfU jJ9Ul8u4T0uNeVi2Sv1TP9/XSjSQTJKEIHaEtokhxrgKd1G/USj1x9Z3+t/oddSuEd+L pcxowSROwNFAm2l/rtdn+MPa1IPeuyPeHxkf2ohLVyySHBiiNpWrsWYZp3A8xxz0tIeo gqmg== X-Received: by 10.66.139.198 with SMTP id ra6mr6536008pab.140.1367995273309; Tue, 07 May 2013 23:41:13 -0700 (PDT) X-Received: by 10.66.139.198 with SMTP id ra6mr6536004pab.140.1367995273214; Tue, 07 May 2013 23:41:13 -0700 (PDT) Received: from localhost ([75.98.92.113]) by mx.google.com with ESMTPSA id au5sm4280879pbc.40.2013.05.07.23.41.11 for (version=TLSv1.1 cipher=RC4-SHA bits=128/128); Tue, 07 May 2013 23:41:12 -0700 (PDT) From: Pravin B Shelar To: netdev@vger.kernel.org Cc: Pravin B Shelar , Eric Dumazet , Cong Wang , "David S. Miller" Subject: [PATCH] gso: Handle Trans-Ether-Bridging protocol in skb_network_protocol() Date: Tue, 7 May 2013 23:41:07 -0700 Message-Id: <1367995267-23443-1-git-send-email-pshelar@nicira.com> X-Mailer: git-send-email 1.8.2.135.g7b592fa X-Gm-Message-State: ALoCoQnTzT3PDJIbyaEsu5b0wGZQmYyTo5zfQTKZYsFRy5LcQrvnDGkN0D+9MkQ7VbCr7h7mJZ4ivA3CLlyuK49gXqkh8821rWFB3I5/BjQ9UFDv+Rapx5/nlxw19LffqDlmyB8J8S8UeoPdKCgtkAVEiFAfwxDn092ylDMUe5/ja4zKMVqsvkc= Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Rather than having logic to calculate inner protocol in every tunnel gso handler move it to gso code. This simplifies code. Cc: Eric Dumazet Cc: Cong Wang Cc: David S. Miller Signed-off-by: Pravin B Shelar --- net/core/dev.c | 11 +++++++++++ net/ipv4/gre.c | 8 +------- net/ipv4/udp.c | 4 +--- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/net/core/dev.c b/net/core/dev.c index 40b1fad..fc1e289 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -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; diff --git a/net/ipv4/gre.c b/net/ipv4/gre.c index cc22363..b2e805a 100644 --- a/net/ipv4/gre.c +++ b/net/ipv4/gre.c @@ -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))) diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c index 0ae038a..0bf5d39 100644 --- a/net/ipv4/udp.c +++ b/net/ipv4/udp.c @@ -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);