From patchwork Thu Dec 4 00:44:26 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Herbert X-Patchwork-Id: 417596 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 AF79F1400E2 for ; Thu, 4 Dec 2014 11:45:01 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752105AbaLDAo5 (ORCPT ); Wed, 3 Dec 2014 19:44:57 -0500 Received: from mail-ie0-f176.google.com ([209.85.223.176]:34018 "EHLO mail-ie0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751106AbaLDAo4 (ORCPT ); Wed, 3 Dec 2014 19:44:56 -0500 Received: by mail-ie0-f176.google.com with SMTP id tr6so14333985ieb.7 for ; Wed, 03 Dec 2014 16:44:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:subject:date:message-id:in-reply-to:references; bh=zWQQ8F75JaQOkGrHrSL+hIqEGBLFklcCPTd9X9Qi7lg=; b=i8bh1UI8+SHoF6ulxdqcQtxh1cGZp9dS9hrvuuTi/xy36UNuDMvettCTqoX9/DVyi9 Kas2qoEJwpaSzYNTgqodPltVg/oCZMp9sCupFpMHF/9haNbw/2KnbkvnU0TbxFOhOnvW /j4ZaJ8ZurNlktGHP6vsrIBdoXa74gyXz5kXEdDxhZnPgKGmdAfQbEao0r5Z6DtUkLzj CKQgcWlg7bmAL/+OMxk4CrK/pinCjgmtDEmMKmBjDthBUfucC4xy+ZLUHjRVC9l5AM8E 5Aov66+/oMiiLBwL+N7OBoSGMcd/8goA1Oak9NcbfOtpdXkSV5pXCbkKr4mxUU+yfBpy kb4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=zWQQ8F75JaQOkGrHrSL+hIqEGBLFklcCPTd9X9Qi7lg=; b=fWCj26Xi0uikW9bD3jFhftwrNhgPOKYjkjP42rXaBZ9f2gSMPeXVTw5ps0P9YwY3jv voXjLBU7bVbQ7anXDCZG1rrV5lAu0wV1xpEYMPU0siU0m+SvN71noSWtwrSgob8IGijc 2ZX1WxUWKuwGm4U+vI1mvkFdiZWM7Cr4sp0OAcgLzid+snfrZZO3iDjz7duurOVFtHsV 9x+3NiOOTWXSwXdTK1OS4Y3IO15Aeb8u8rJE8dcMfQ4mhWqNq+qG6RsAPmH0AVBmk88k q6joX7INLYd5OFV3ywNTYrZd7mdHGV/K7Btb7HinaMsclGasGzM6ISC3f8ENv+/c/h0G maIQ== X-Gm-Message-State: ALoCoQkqdwjMwLfvjwwN45oA6GWKCZTl21+cPtC6s4uPUv2gcSut0eOyN5yJirTdqlGy/wfhzxUN X-Received: by 10.50.40.8 with SMTP id t8mr240273igk.0.1417653895401; Wed, 03 Dec 2014 16:44:55 -0800 (PST) Received: from tomh.mtv.corp.google.com ([172.18.117.126]) by mx.google.com with ESMTPSA id qc7sm8354103igb.5.2014.12.03.16.44.54 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 03 Dec 2014 16:44:54 -0800 (PST) From: Tom Herbert To: davem@davemloft.net, netdev@vger.kernel.org Subject: [PATCH net-next 1/3] ip: Move checksum convert defines to inet Date: Wed, 3 Dec 2014 16:44:26 -0800 Message-Id: <1417653868-14922-2-git-send-email-therbert@google.com> X-Mailer: git-send-email 2.2.0.rc0.207.ga3a616c In-Reply-To: <1417653868-14922-1-git-send-email-therbert@google.com> References: <1417653868-14922-1-git-send-email-therbert@google.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Move convert_csum from udp_sock to inet_sock. This allows the possibility that we can use convert checksum for different types of sockets and also allows convert checksum to be enabled from inet layer (what we'll want to do when enabling IP_CHECKSUM cmsg). Signed-off-by: Tom Herbert --- include/linux/udp.h | 16 +--------------- include/net/inet_sock.h | 17 +++++++++++++++++ net/ipv4/fou.c | 2 +- net/ipv4/udp.c | 2 +- net/ipv4/udp_tunnel.c | 2 +- net/ipv6/udp.c | 2 +- 6 files changed, 22 insertions(+), 19 deletions(-) diff --git a/include/linux/udp.h b/include/linux/udp.h index ee32775..247cfdc 100644 --- a/include/linux/udp.h +++ b/include/linux/udp.h @@ -49,11 +49,7 @@ struct udp_sock { unsigned int corkflag; /* Cork is required */ __u8 encap_type; /* Is this an Encapsulation socket? */ unsigned char no_check6_tx:1,/* Send zero UDP6 checksums on TX? */ - no_check6_rx:1,/* Allow zero UDP6 checksums on RX? */ - convert_csum:1;/* On receive, convert checksum - * unnecessary to checksum complete - * if possible. - */ + no_check6_rx:1;/* Allow zero UDP6 checksums on RX? */ /* * Following member retains the information to create a UDP header * when the socket is uncorked. @@ -102,16 +98,6 @@ static inline bool udp_get_no_check6_rx(struct sock *sk) return udp_sk(sk)->no_check6_rx; } -static inline void udp_set_convert_csum(struct sock *sk, bool val) -{ - udp_sk(sk)->convert_csum = val; -} - -static inline bool udp_get_convert_csum(struct sock *sk) -{ - return udp_sk(sk)->convert_csum; -} - #define udp_portaddr_for_each_entry(__sk, node, list) \ hlist_nulls_for_each_entry(__sk, node, list, __sk_common.skc_portaddr_node) diff --git a/include/net/inet_sock.h b/include/net/inet_sock.h index a829b77..360b110 100644 --- a/include/net/inet_sock.h +++ b/include/net/inet_sock.h @@ -184,6 +184,7 @@ struct inet_sock { mc_all:1, nodefrag:1; __u8 rcv_tos; + __u8 convert_csum; int uc_index; int mc_index; __be32 mc_addr; @@ -250,4 +251,20 @@ static inline __u8 inet_sk_flowi_flags(const struct sock *sk) return flags; } +static inline void inet_inc_convert_csum(struct sock *sk) +{ + inet_sk(sk)->convert_csum++; +} + +static inline void inet_dec_convert_csum(struct sock *sk) +{ + if (inet_sk(sk)->convert_csum > 0) + inet_sk(sk)->convert_csum--; +} + +static inline bool inet_get_convert_csum(struct sock *sk) +{ + return !!inet_sk(sk)->convert_csum; +} + #endif /* _INET_SOCK_H */ diff --git a/net/ipv4/fou.c b/net/ipv4/fou.c index b986298..2197c36 100644 --- a/net/ipv4/fou.c +++ b/net/ipv4/fou.c @@ -490,7 +490,7 @@ static int fou_create(struct net *net, struct fou_cfg *cfg, sk->sk_user_data = fou; fou->sock = sock; - udp_set_convert_csum(sk, true); + inet_inc_convert_csum(sk); sk->sk_allocation = GFP_ATOMIC; diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c index b2d6068..221b53f 100644 --- a/net/ipv4/udp.c +++ b/net/ipv4/udp.c @@ -1793,7 +1793,7 @@ int __udp4_lib_rcv(struct sk_buff *skb, struct udp_table *udptable, if (sk != NULL) { int ret; - if (udp_sk(sk)->convert_csum && uh->check && !IS_UDPLITE(sk)) + if (inet_get_convert_csum(sk) && uh->check && !IS_UDPLITE(sk)) skb_checksum_try_convert(skb, IPPROTO_UDP, uh->check, inet_compute_pseudo); diff --git a/net/ipv4/udp_tunnel.c b/net/ipv4/udp_tunnel.c index 1671263..9996e63 100644 --- a/net/ipv4/udp_tunnel.c +++ b/net/ipv4/udp_tunnel.c @@ -63,7 +63,7 @@ void setup_udp_tunnel_sock(struct net *net, struct socket *sock, inet_sk(sk)->mc_loop = 0; /* Enable CHECKSUM_UNNECESSARY to CHECKSUM_COMPLETE conversion */ - udp_set_convert_csum(sk, true); + inet_inc_convert_csum(sk); rcu_assign_sk_user_data(sk, cfg->sk_user_data); diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c index 7cfb5d7..5d9900c 100644 --- a/net/ipv6/udp.c +++ b/net/ipv6/udp.c @@ -896,7 +896,7 @@ int __udp6_lib_rcv(struct sk_buff *skb, struct udp_table *udptable, goto csum_error; } - if (udp_sk(sk)->convert_csum && uh->check && !IS_UDPLITE(sk)) + if (inet_get_convert_csum(sk) && uh->check && !IS_UDPLITE(sk)) skb_checksum_try_convert(skb, IPPROTO_UDP, uh->check, ip6_compute_pseudo);