aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4
diff options
context:
space:
mode:
authorTom Herbert <therbert@google.com>2014-05-23 11:47:32 -0400
committerDavid S. Miller <davem@davemloft.net>2014-05-23 16:28:53 -0400
commit1c19448c9ba6545b80ded18488a64a7f3d8e6998 (patch)
tree7323d68eaf334d9040a9d5a709c56caf2a7aaeeb /net/ipv4
parent28448b80456feafe07e2d05b6363b00f61f6171e (diff)
net: Make enabling of zero UDP6 csums more restrictive
RFC 6935 permits zero checksums to be used in IPv6 however this is recommended only for certain tunnel protocols, it does not make checksums completely optional like they are in IPv4. This patch restricts the use of IPv6 zero checksums that was previously intoduced. no_check6_tx and no_check6_rx have been added to control the use of checksums in UDP6 RX and TX path. The normal sk_no_check_{rx,tx} settings are not used (this avoids ambiguity when dealing with a dual stack socket). A helper function has been added (udp_set_no_check6) which can be called by tunnel impelmentations to all zero checksums (send on the socket, and accept them as valid). Signed-off-by: Tom Herbert <therbert@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4')
-rw-r--r--net/ipv4/udp.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index 12c6175b29cd..e07d52b8617a 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -1968,7 +1968,7 @@ int udp_lib_setsockopt(struct sock *sk, int level, int optname,
1968 int (*push_pending_frames)(struct sock *)) 1968 int (*push_pending_frames)(struct sock *))
1969{ 1969{
1970 struct udp_sock *up = udp_sk(sk); 1970 struct udp_sock *up = udp_sk(sk);
1971 int val; 1971 int val, valbool;
1972 int err = 0; 1972 int err = 0;
1973 int is_udplite = IS_UDPLITE(sk); 1973 int is_udplite = IS_UDPLITE(sk);
1974 1974
@@ -1978,6 +1978,8 @@ int udp_lib_setsockopt(struct sock *sk, int level, int optname,
1978 if (get_user(val, (int __user *)optval)) 1978 if (get_user(val, (int __user *)optval))
1979 return -EFAULT; 1979 return -EFAULT;
1980 1980
1981 valbool = val ? 1 : 0;
1982
1981 switch (optname) { 1983 switch (optname) {
1982 case UDP_CORK: 1984 case UDP_CORK:
1983 if (val != 0) { 1985 if (val != 0) {
@@ -2007,6 +2009,14 @@ int udp_lib_setsockopt(struct sock *sk, int level, int optname,
2007 } 2009 }
2008 break; 2010 break;
2009 2011
2012 case UDP_NO_CHECK6_TX:
2013 up->no_check6_tx = valbool;
2014 break;
2015
2016 case UDP_NO_CHECK6_RX:
2017 up->no_check6_rx = valbool;
2018 break;
2019
2010 /* 2020 /*
2011 * UDP-Lite's partial checksum coverage (RFC 3828). 2021 * UDP-Lite's partial checksum coverage (RFC 3828).
2012 */ 2022 */
@@ -2089,6 +2099,14 @@ int udp_lib_getsockopt(struct sock *sk, int level, int optname,
2089 val = up->encap_type; 2099 val = up->encap_type;
2090 break; 2100 break;
2091 2101
2102 case UDP_NO_CHECK6_TX:
2103 val = up->no_check6_tx;
2104 break;
2105
2106 case UDP_NO_CHECK6_RX:
2107 val = up->no_check6_rx;
2108 break;
2109
2092 /* The following two cannot be changed on UDP sockets, the return is 2110 /* The following two cannot be changed on UDP sockets, the return is
2093 * always 0 (which corresponds to the full checksum coverage of UDP). */ 2111 * always 0 (which corresponds to the full checksum coverage of UDP). */
2094 case UDPLITE_SEND_CSCOV: 2112 case UDPLITE_SEND_CSCOV: