summaryrefslogtreecommitdiffstats
path: root/include/net/sock.h
diff options
context:
space:
mode:
authorTom Herbert2015-12-14 20:19:45 +0100
committerDavid S. Miller2015-12-15 22:50:20 +0100
commit9a49850d0af7b9fd14d091dfe61ef6cb369f86b9 (patch)
tree32d6e3173c2bd3e92084884f8006d5a2a73e3ffb /include/net/sock.h
parentnet: Eliminate NETIF_F_GEN_CSUM and NETIF_F_V[46]_CSUM (diff)
downloadkernel-qcow2-linux-9a49850d0af7b9fd14d091dfe61ef6cb369f86b9.tar.gz
kernel-qcow2-linux-9a49850d0af7b9fd14d091dfe61ef6cb369f86b9.tar.xz
kernel-qcow2-linux-9a49850d0af7b9fd14d091dfe61ef6cb369f86b9.zip
tcp: Fix conditions to determine checksum offload
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> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/net/sock.h')
-rw-r--r--include/net/sock.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/include/net/sock.h b/include/net/sock.h
index 0ca22b014de1..ab0269f4b2cc 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)