aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWillem de Bruijn <willemb@google.com>2014-11-26 14:53:02 -0500
committerDavid S. Miller <davem@davemloft.net>2014-11-26 15:45:04 -0500
commitf4713a3dfad045d46afcb9c2a7d0bba288920ed4 (patch)
treede3059b95872e46370f0d61348044b6cb2b5981b
parenta7650238a0cf82d84d1d7aff4383f84807616d8f (diff)
net-timestamp: make tcp_recvmsg call ipv6_recv_error for AF_INET6 socks
TCP timestamping introduced MSG_ERRQUEUE handling for TCP sockets. If the socket is of family AF_INET6, call ipv6_recv_error instead of ip_recv_error. This change is more complex than a single branch due to the loadable ipv6 module. It reuses a pre-existing indirect function call from ping. The ping code is safe to call, because it is part of the core ipv6 module and always present when AF_INET6 sockets are active. Fixes: 4ed2d765 (net-timestamp: TCP timestamping) Signed-off-by: Willem de Bruijn <willemb@google.com> ---- It may also be worthwhile to add WARN_ON_ONCE(sk->family == AF_INET6) to ip_recv_error. Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--include/net/inet_common.h2
-rw-r--r--net/ipv4/af_inet.c11
-rw-r--r--net/ipv4/ping.c12
-rw-r--r--net/ipv4/tcp.c2
4 files changed, 16 insertions, 11 deletions
diff --git a/include/net/inet_common.h b/include/net/inet_common.h
index fe7994c48b75..b2828a06a5a6 100644
--- a/include/net/inet_common.h
+++ b/include/net/inet_common.h
@@ -37,6 +37,8 @@ int inet_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg);
37int inet_ctl_sock_create(struct sock **sk, unsigned short family, 37int inet_ctl_sock_create(struct sock **sk, unsigned short family,
38 unsigned short type, unsigned char protocol, 38 unsigned short type, unsigned char protocol,
39 struct net *net); 39 struct net *net);
40int inet_recv_error(struct sock *sk, struct msghdr *msg, int len,
41 int *addr_len);
40 42
41static inline void inet_ctl_sock_destroy(struct sock *sk) 43static inline void inet_ctl_sock_destroy(struct sock *sk)
42{ 44{
diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
index 8b7fe5b03906..e67da4e6c324 100644
--- a/net/ipv4/af_inet.c
+++ b/net/ipv4/af_inet.c
@@ -1386,6 +1386,17 @@ out:
1386 return pp; 1386 return pp;
1387} 1387}
1388 1388
1389int inet_recv_error(struct sock *sk, struct msghdr *msg, int len, int *addr_len)
1390{
1391 if (sk->sk_family == AF_INET)
1392 return ip_recv_error(sk, msg, len, addr_len);
1393#if IS_ENABLED(CONFIG_IPV6)
1394 if (sk->sk_family == AF_INET6)
1395 return pingv6_ops.ipv6_recv_error(sk, msg, len, addr_len);
1396#endif
1397 return -EINVAL;
1398}
1399
1389static int inet_gro_complete(struct sk_buff *skb, int nhoff) 1400static int inet_gro_complete(struct sk_buff *skb, int nhoff)
1390{ 1401{
1391 __be16 newlen = htons(skb->len - nhoff); 1402 __be16 newlen = htons(skb->len - nhoff);
diff --git a/net/ipv4/ping.c b/net/ipv4/ping.c
index 85a02a75ad83..5d740cccf69e 100644
--- a/net/ipv4/ping.c
+++ b/net/ipv4/ping.c
@@ -855,16 +855,8 @@ int ping_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
855 if (flags & MSG_OOB) 855 if (flags & MSG_OOB)
856 goto out; 856 goto out;
857 857
858 if (flags & MSG_ERRQUEUE) { 858 if (flags & MSG_ERRQUEUE)
859 if (family == AF_INET) { 859 return inet_recv_error(sk, msg, len, addr_len);
860 return ip_recv_error(sk, msg, len, addr_len);
861#if IS_ENABLED(CONFIG_IPV6)
862 } else if (family == AF_INET6) {
863 return pingv6_ops.ipv6_recv_error(sk, msg, len,
864 addr_len);
865#endif
866 }
867 }
868 860
869 skb = skb_recv_datagram(sk, flags, noblock, &err); 861 skb = skb_recv_datagram(sk, flags, noblock, &err);
870 if (!skb) 862 if (!skb)
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 39ec0c379545..38c2bcb8dd5d 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -1598,7 +1598,7 @@ int tcp_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
1598 u32 urg_hole = 0; 1598 u32 urg_hole = 0;
1599 1599
1600 if (unlikely(flags & MSG_ERRQUEUE)) 1600 if (unlikely(flags & MSG_ERRQUEUE))
1601 return ip_recv_error(sk, msg, len, addr_len); 1601 return inet_recv_error(sk, msg, len, addr_len);
1602 1602
1603 if (sk_can_busy_loop(sk) && skb_queue_empty(&sk->sk_receive_queue) && 1603 if (sk_can_busy_loop(sk) && skb_queue_empty(&sk->sk_receive_queue) &&
1604 (sk->sk_state == TCP_ESTABLISHED)) 1604 (sk->sk_state == TCP_ESTABLISHED))