diff options
-rw-r--r-- | include/linux/udp.h | 16 | ||||
-rw-r--r-- | include/net/inet_sock.h | 17 | ||||
-rw-r--r-- | net/ipv4/fou.c | 2 | ||||
-rw-r--r-- | net/ipv4/udp.c | 2 | ||||
-rw-r--r-- | net/ipv4/udp_tunnel.c | 2 | ||||
-rw-r--r-- | 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 ee3277593222..247cfdcc4b08 100644 --- a/include/linux/udp.h +++ b/include/linux/udp.h | |||
@@ -49,11 +49,7 @@ struct udp_sock { | |||
49 | unsigned int corkflag; /* Cork is required */ | 49 | unsigned int corkflag; /* Cork is required */ |
50 | __u8 encap_type; /* Is this an Encapsulation socket? */ | 50 | __u8 encap_type; /* Is this an Encapsulation socket? */ |
51 | unsigned char no_check6_tx:1,/* Send zero UDP6 checksums on TX? */ | 51 | unsigned char no_check6_tx:1,/* Send zero UDP6 checksums on TX? */ |
52 | no_check6_rx:1,/* Allow zero UDP6 checksums on RX? */ | 52 | no_check6_rx:1;/* Allow zero UDP6 checksums on RX? */ |
53 | convert_csum:1;/* On receive, convert checksum | ||
54 | * unnecessary to checksum complete | ||
55 | * if possible. | ||
56 | */ | ||
57 | /* | 53 | /* |
58 | * Following member retains the information to create a UDP header | 54 | * Following member retains the information to create a UDP header |
59 | * when the socket is uncorked. | 55 | * when the socket is uncorked. |
@@ -102,16 +98,6 @@ static inline bool udp_get_no_check6_rx(struct sock *sk) | |||
102 | return udp_sk(sk)->no_check6_rx; | 98 | return udp_sk(sk)->no_check6_rx; |
103 | } | 99 | } |
104 | 100 | ||
105 | static inline void udp_set_convert_csum(struct sock *sk, bool val) | ||
106 | { | ||
107 | udp_sk(sk)->convert_csum = val; | ||
108 | } | ||
109 | |||
110 | static inline bool udp_get_convert_csum(struct sock *sk) | ||
111 | { | ||
112 | return udp_sk(sk)->convert_csum; | ||
113 | } | ||
114 | |||
115 | #define udp_portaddr_for_each_entry(__sk, node, list) \ | 101 | #define udp_portaddr_for_each_entry(__sk, node, list) \ |
116 | hlist_nulls_for_each_entry(__sk, node, list, __sk_common.skc_portaddr_node) | 102 | hlist_nulls_for_each_entry(__sk, node, list, __sk_common.skc_portaddr_node) |
117 | 103 | ||
diff --git a/include/net/inet_sock.h b/include/net/inet_sock.h index a829b77523cf..360b110b3e36 100644 --- a/include/net/inet_sock.h +++ b/include/net/inet_sock.h | |||
@@ -184,6 +184,7 @@ struct inet_sock { | |||
184 | mc_all:1, | 184 | mc_all:1, |
185 | nodefrag:1; | 185 | nodefrag:1; |
186 | __u8 rcv_tos; | 186 | __u8 rcv_tos; |
187 | __u8 convert_csum; | ||
187 | int uc_index; | 188 | int uc_index; |
188 | int mc_index; | 189 | int mc_index; |
189 | __be32 mc_addr; | 190 | __be32 mc_addr; |
@@ -250,4 +251,20 @@ static inline __u8 inet_sk_flowi_flags(const struct sock *sk) | |||
250 | return flags; | 251 | return flags; |
251 | } | 252 | } |
252 | 253 | ||
254 | static inline void inet_inc_convert_csum(struct sock *sk) | ||
255 | { | ||
256 | inet_sk(sk)->convert_csum++; | ||
257 | } | ||
258 | |||
259 | static inline void inet_dec_convert_csum(struct sock *sk) | ||
260 | { | ||
261 | if (inet_sk(sk)->convert_csum > 0) | ||
262 | inet_sk(sk)->convert_csum--; | ||
263 | } | ||
264 | |||
265 | static inline bool inet_get_convert_csum(struct sock *sk) | ||
266 | { | ||
267 | return !!inet_sk(sk)->convert_csum; | ||
268 | } | ||
269 | |||
253 | #endif /* _INET_SOCK_H */ | 270 | #endif /* _INET_SOCK_H */ |
diff --git a/net/ipv4/fou.c b/net/ipv4/fou.c index b986298a7ba3..2197c36f722f 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, | |||
490 | sk->sk_user_data = fou; | 490 | sk->sk_user_data = fou; |
491 | fou->sock = sock; | 491 | fou->sock = sock; |
492 | 492 | ||
493 | udp_set_convert_csum(sk, true); | 493 | inet_inc_convert_csum(sk); |
494 | 494 | ||
495 | sk->sk_allocation = GFP_ATOMIC; | 495 | sk->sk_allocation = GFP_ATOMIC; |
496 | 496 | ||
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c index 13b4dcf86ef6..53358d88f110 100644 --- a/net/ipv4/udp.c +++ b/net/ipv4/udp.c | |||
@@ -1806,7 +1806,7 @@ int __udp4_lib_rcv(struct sk_buff *skb, struct udp_table *udptable, | |||
1806 | if (sk != NULL) { | 1806 | if (sk != NULL) { |
1807 | int ret; | 1807 | int ret; |
1808 | 1808 | ||
1809 | if (udp_sk(sk)->convert_csum && uh->check && !IS_UDPLITE(sk)) | 1809 | if (inet_get_convert_csum(sk) && uh->check && !IS_UDPLITE(sk)) |
1810 | skb_checksum_try_convert(skb, IPPROTO_UDP, uh->check, | 1810 | skb_checksum_try_convert(skb, IPPROTO_UDP, uh->check, |
1811 | inet_compute_pseudo); | 1811 | inet_compute_pseudo); |
1812 | 1812 | ||
diff --git a/net/ipv4/udp_tunnel.c b/net/ipv4/udp_tunnel.c index 1671263e5fa0..9996e63ed304 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, | |||
63 | inet_sk(sk)->mc_loop = 0; | 63 | inet_sk(sk)->mc_loop = 0; |
64 | 64 | ||
65 | /* Enable CHECKSUM_UNNECESSARY to CHECKSUM_COMPLETE conversion */ | 65 | /* Enable CHECKSUM_UNNECESSARY to CHECKSUM_COMPLETE conversion */ |
66 | udp_set_convert_csum(sk, true); | 66 | inet_inc_convert_csum(sk); |
67 | 67 | ||
68 | rcu_assign_sk_user_data(sk, cfg->sk_user_data); | 68 | rcu_assign_sk_user_data(sk, cfg->sk_user_data); |
69 | 69 | ||
diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c index 189dc4ae3eca..e41f017cd479 100644 --- a/net/ipv6/udp.c +++ b/net/ipv6/udp.c | |||
@@ -909,7 +909,7 @@ int __udp6_lib_rcv(struct sk_buff *skb, struct udp_table *udptable, | |||
909 | goto csum_error; | 909 | goto csum_error; |
910 | } | 910 | } |
911 | 911 | ||
912 | if (udp_sk(sk)->convert_csum && uh->check && !IS_UDPLITE(sk)) | 912 | if (inet_get_convert_csum(sk) && uh->check && !IS_UDPLITE(sk)) |
913 | skb_checksum_try_convert(skb, IPPROTO_UDP, uh->check, | 913 | skb_checksum_try_convert(skb, IPPROTO_UDP, uh->check, |
914 | ip6_compute_pseudo); | 914 | ip6_compute_pseudo); |
915 | 915 | ||