From: Tom Herbert <tom@herbertland.com>
To: <davem@davemloft.net>, <netdev@vger.kernel.org>
Cc: <kernel-team@fb.com>
Subject: [PATCH net-next 6/8] tcp: Fix conditions to determine checksum offload
Date: Mon, 14 Dec 2015 11:19:45 -0800 [thread overview]
Message-ID: <1450120787-1773171-7-git-send-email-tom@herbertland.com> (raw)
In-Reply-To: <1450120787-1773171-1-git-send-email-tom@herbertland.com>
In tcp_send_sendpage and tcp_sendmsg we check the route capabilities to
determine if checksum offload can be performed. This check currently
does not take the IP protocol into account for devices that advertise
only one of NETIF_F_IPV6_CSUM or NETIF_F_IP_CSUM. This patch adds a
function to check capabilities for checksum offload with a socket
called sk_check_csum_caps. This function checks for specific IPv4 or
IPv6 offload support based on the family of the socket.
Signed-off-by: Tom Herbert <tom@herbertland.com>
---
include/net/sock.h | 9 +++++++++
net/ipv4/tcp.c | 4 ++--
2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/include/net/sock.h b/include/net/sock.h
index 0ca22b0..ab0269f 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -1791,6 +1791,15 @@ static inline void sk_nocaps_add(struct sock *sk, netdev_features_t flags)
sk->sk_route_caps &= ~flags;
}
+static inline bool sk_check_csum_caps(struct sock *sk)
+{
+ return (sk->sk_route_caps & NETIF_F_HW_CSUM) ||
+ (sk->sk_family == PF_INET &&
+ (sk->sk_route_caps & NETIF_F_IP_CSUM)) ||
+ (sk->sk_family == PF_INET6 &&
+ (sk->sk_route_caps & NETIF_F_IPV6_CSUM));
+}
+
static inline int skb_do_copy_data_nocache(struct sock *sk, struct sk_buff *skb,
struct iov_iter *from, char *to,
int copy, int offset)
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index cf7ef7b..92b3e61 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -1018,7 +1018,7 @@ int tcp_sendpage(struct sock *sk, struct page *page, int offset,
ssize_t res;
if (!(sk->sk_route_caps & NETIF_F_SG) ||
- !(sk->sk_route_caps & NETIF_F_CSUM_MASK))
+ !sk_check_csum_caps(sk))
return sock_no_sendpage(sk->sk_socket, page, offset, size,
flags);
@@ -1175,7 +1175,7 @@ new_segment:
/*
* Check whether we can use HW checksum.
*/
- if (sk->sk_route_caps & NETIF_F_CSUM_MASK)
+ if (sk_check_csum_caps(sk))
skb->ip_summed = CHECKSUM_PARTIAL;
skb_entail(sk, skb);
--
2.4.6
next prev parent reply other threads:[~2015-12-14 19:21 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-14 19:19 [PATCH net-next 0/8] net: The beginning of the end for NETIF_F_IP_CSUM and NETIF_F_IPV6_CSUM Tom Herbert
2015-12-14 19:19 ` [PATCH net-next 1/8] net: Add skb_inner_transport_offset function Tom Herbert
2015-12-14 19:19 ` [PATCH net-next 2/8] sctp: Rename NETIF_F_SCTP_CSUM to NETIF_F_SCTP_CRC Tom Herbert
2015-12-14 19:19 ` [PATCH net-next 3/8] fcoe: Use CHECKSUM_PARTIAL to indicate CRC offload Tom Herbert
2015-12-14 19:19 ` [PATCH net-next 4/8] net: Rename NETIF_F_ALL_CSUM to NETIF_F_CSUM_MASK Tom Herbert
2015-12-14 19:19 ` [PATCH net-next 5/8] net: Eliminate NETIF_F_GEN_CSUM and NETIF_F_V[46]_CSUM Tom Herbert
2015-12-14 19:19 ` Tom Herbert [this message]
2015-12-14 19:39 ` [PATCH net-next 6/8] tcp: Fix conditions to determine checksum offload Eric Dumazet
2015-12-14 20:39 ` Tom Herbert
2015-12-14 19:19 ` [PATCH net-next 7/8] net: Add driver helper functions to determine checksum offloadability Tom Herbert
2015-12-14 19:19 ` [PATCH net-next 8/8] net: Elaborate on checksum offload interface description Tom Herbert
2015-12-15 21:32 ` [PATCH net-next 0/8] net: The beginning of the end for NETIF_F_IP_CSUM and NETIF_F_IPV6_CSUM David Miller
2015-12-15 22:11 ` Tom Herbert
2015-12-15 22:18 ` Tom Herbert
2015-12-16 2:07 ` David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1450120787-1773171-7-git-send-email-tom@herbertland.com \
--to=tom@herbertland.com \
--cc=davem@davemloft.net \
--cc=kernel-team@fb.com \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).