From patchwork Sun Mar 10 09:00:39 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cong Wang X-Patchwork-Id: 226416 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 3C8CB2C030B for ; Sun, 10 Mar 2013 20:01:22 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752521Ab3CJJBS (ORCPT ); Sun, 10 Mar 2013 05:01:18 -0400 Received: from mail-pb0-f43.google.com ([209.85.160.43]:59202 "EHLO mail-pb0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752488Ab3CJJBQ (ORCPT ); Sun, 10 Mar 2013 05:01:16 -0400 Received: by mail-pb0-f43.google.com with SMTP id md12so2692668pbc.2 for ; Sun, 10 Mar 2013 01:01:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer; bh=m9Kf59Ulz1i4/zXbxehDIIEoVaUzulj6Zorvw32u1UA=; b=hUxyLVPAXX4LPzuiCYAHUomeflHTTj/r6IXLsAY/dWUuXbehF9dNBrsmSvw0XSiDV9 3rsUD0XsxXSuTi5E4bviTHFeMSVxONg+KxtKG0GsB+6L1aXxXZYKw1IOf4erbU5ys9dn bWCHxxoHS/D5jb93j79S08hGUDNSejymnSmzuWw8Jq5k/z5kBo6Z3LOZGBV1TBxOn23w aJshwBZv2IxG1vBO34I7JIDXJhqoqhtLX3sGWWaVP92AD2KZJ2j8J4D/6/JSKXadFEcR Xop31i+IMMNwfODLgfXYmAM49SY4R39MszNM1LY1UEidj4I2TFWvwdmoWv7B41felWKp qa+g== X-Received: by 10.68.252.2 with SMTP id zo2mr18176200pbc.97.1362906076204; Sun, 10 Mar 2013 01:01:16 -0800 (PST) Received: from cr0.localdomain ([60.160.69.131]) by mx.google.com with ESMTPS id qd8sm14469709pbc.29.2013.03.10.01.01.07 (version=TLSv1 cipher=RC4-SHA bits=128/128); Sun, 10 Mar 2013 01:01:15 -0800 (PST) From: Cong Wang To: netdev@vger.kernel.org Cc: Eric Dumazet , Pravin B Shelar , "David S. Miller" , Cong Wang Subject: [Patch net-next] ipv6: introduce ip6tunnel_xmit() helper Date: Sun, 10 Mar 2013 17:00:39 +0800 Message-Id: <1362906039-8236-1-git-send-email-xiyou.wangcong@gmail.com> X-Mailer: git-send-email 1.7.7.6 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Cong Wang Similar to iptunnel_xmit(), group these operations into a helper function. This by the way fixes the missing u64_stats_update_begin() and u64_stats_update_end() for 32 bit arch. Cc: Eric Dumazet Cc: Pravin B Shelar Cc: "David S. Miller" Signed-off-by: Cong Wang --- include/net/ip6_tunnel.h | 20 ++++++++++++++++++++ net/ipv6/ip6_gre.c | 17 +---------------- net/ipv6/ip6_tunnel.c | 15 +-------------- 3 files changed, 22 insertions(+), 30 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/include/net/ip6_tunnel.h b/include/net/ip6_tunnel.h index e03047f..ebdef7f 100644 --- a/include/net/ip6_tunnel.h +++ b/include/net/ip6_tunnel.h @@ -68,4 +68,24 @@ __u16 ip6_tnl_parse_tlv_enc_lim(struct sk_buff *skb, __u8 *raw); __u32 ip6_tnl_get_cap(struct ip6_tnl *t, const struct in6_addr *laddr, const struct in6_addr *raddr); +static inline void ip6tunnel_xmit(struct sk_buff *skb, struct net_device *dev) +{ + struct net_device_stats *stats = &dev->stats; + int pkt_len, err; + + nf_reset(skb); + pkt_len = skb->len; + err = ip6_local_out(skb); + + if (net_xmit_eval(err) == 0) { + struct pcpu_tstats *tstats = this_cpu_ptr(dev->tstats); + u64_stats_update_begin(&tstats->syncp); + tstats->tx_bytes += pkt_len; + tstats->tx_packets++; + u64_stats_update_end(&tstats->syncp); + } else { + stats->tx_errors++; + stats->tx_aborted_errors++; + } +} #endif diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c index e4efffe..6a6ba73 100644 --- a/net/ipv6/ip6_gre.c +++ b/net/ipv6/ip6_gre.c @@ -667,7 +667,6 @@ static netdev_tx_t ip6gre_xmit2(struct sk_buff *skb, struct net_device_stats *stats = &tunnel->dev->stats; int err = -1; u8 proto; - int pkt_len; struct sk_buff *new_skb; if (dev->type == ARPHRD_ETHER) @@ -801,23 +800,9 @@ static netdev_tx_t ip6gre_xmit2(struct sk_buff *skb, } } - nf_reset(skb); - pkt_len = skb->len; - err = ip6_local_out(skb); - - if (net_xmit_eval(err) == 0) { - struct pcpu_tstats *tstats = this_cpu_ptr(tunnel->dev->tstats); - - tstats->tx_bytes += pkt_len; - tstats->tx_packets++; - } else { - stats->tx_errors++; - stats->tx_aborted_errors++; - } - + ip6tunnel_xmit(skb, dev); if (ndst) ip6_tnl_dst_store(tunnel, ndst); - return 0; tx_err_link_failure: stats->tx_carrier_errors++; diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c index fff83cb..bef3fed 100644 --- a/net/ipv6/ip6_tunnel.c +++ b/net/ipv6/ip6_tunnel.c @@ -955,7 +955,6 @@ static int ip6_tnl_xmit2(struct sk_buff *skb, unsigned int max_headroom = sizeof(struct ipv6hdr); u8 proto; int err = -1; - int pkt_len; if (!fl6->flowi6_mark) dst = ip6_tnl_dst_check(t); @@ -1035,19 +1034,7 @@ static int ip6_tnl_xmit2(struct sk_buff *skb, ipv6h->nexthdr = proto; ipv6h->saddr = fl6->saddr; ipv6h->daddr = fl6->daddr; - nf_reset(skb); - pkt_len = skb->len; - err = ip6_local_out(skb); - - if (net_xmit_eval(err) == 0) { - struct pcpu_tstats *tstats = this_cpu_ptr(t->dev->tstats); - - tstats->tx_bytes += pkt_len; - tstats->tx_packets++; - } else { - stats->tx_errors++; - stats->tx_aborted_errors++; - } + ip6tunnel_xmit(skb, dev); if (ndst) ip6_tnl_dst_store(t, ndst); return 0;