aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4
diff options
context:
space:
mode:
authorHannes Frederic Sowa <hannes@stressinduktion.org>2014-01-19 21:43:08 -0500
committerDavid S. Miller <davem@davemloft.net>2014-01-19 22:53:18 -0500
commit4b261c75a99f29c93a0b6babfc180cdf566bd654 (patch)
tree2c1fcebd79d2fcb1625f89ef5067605151953010 /net/ipv4
parenta6e2fe17eba47681e82cdb9cfed5a67b57802a78 (diff)
ipv6: make IPV6_RECVPKTINFO work for ipv4 datagrams
We currently don't report IPV6_RECVPKTINFO in cmsg access ancillary data for IPv4 datagrams on IPv6 sockets. This patch splits the ip6_datagram_recv_ctl into two functions, one which handles both protocol families, AF_INET and AF_INET6, while the ip6_datagram_recv_specific_ctl only handles IPv6 cmsg data. ip6_datagram_recv_*_ctl never reported back any errors, so we can make them return void. Also provide a helper for protocols which don't offer dual personality to further use ip6_datagram_recv_ctl, which is exported to modules. I needed to shuffle the code for ping around a bit to make it easier to implement dual personality for ping ipv6 sockets in future. Reported-by: Gert Doering <gert@space.net> Signed-off-by: Hannes Frederic Sowa <hannes@stressinduktion.org> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4')
-rw-r--r--net/ipv4/ip_sockglue.c6
-rw-r--r--net/ipv4/ping.c7
2 files changed, 9 insertions, 4 deletions
diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c
index 22f15eb1c260..580dd96666e0 100644
--- a/net/ipv4/ip_sockglue.c
+++ b/net/ipv4/ip_sockglue.c
@@ -56,7 +56,6 @@
56/* 56/*
57 * SOL_IP control messages. 57 * SOL_IP control messages.
58 */ 58 */
59#define PKTINFO_SKB_CB(__skb) ((struct in_pktinfo *)((__skb)->cb))
60 59
61static void ip_cmsg_recv_pktinfo(struct msghdr *msg, struct sk_buff *skb) 60static void ip_cmsg_recv_pktinfo(struct msghdr *msg, struct sk_buff *skb)
62{ 61{
@@ -1055,9 +1054,10 @@ e_inval:
1055void ipv4_pktinfo_prepare(const struct sock *sk, struct sk_buff *skb) 1054void ipv4_pktinfo_prepare(const struct sock *sk, struct sk_buff *skb)
1056{ 1055{
1057 struct in_pktinfo *pktinfo = PKTINFO_SKB_CB(skb); 1056 struct in_pktinfo *pktinfo = PKTINFO_SKB_CB(skb);
1057 bool prepare = (inet_sk(sk)->cmsg_flags & IP_CMSG_PKTINFO) ||
1058 ipv6_sk_rxinfo(sk);
1058 1059
1059 if ((inet_sk(sk)->cmsg_flags & IP_CMSG_PKTINFO) && 1060 if (prepare && skb_rtable(skb)) {
1060 skb_rtable(skb)) {
1061 pktinfo->ipi_ifindex = inet_iif(skb); 1061 pktinfo->ipi_ifindex = inet_iif(skb);
1062 pktinfo->ipi_spec_dst.s_addr = fib_compute_spec_dst(skb); 1062 pktinfo->ipi_spec_dst.s_addr = fib_compute_spec_dst(skb);
1063 } else { 1063 } else {
diff --git a/net/ipv4/ping.c b/net/ipv4/ping.c
index e09e8839d622..4a9e4266a0c3 100644
--- a/net/ipv4/ping.c
+++ b/net/ipv4/ping.c
@@ -906,7 +906,12 @@ int ping_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
906 } 906 }
907 907
908 if (inet6_sk(sk)->rxopt.all) 908 if (inet6_sk(sk)->rxopt.all)
909 pingv6_ops.ip6_datagram_recv_ctl(sk, msg, skb); 909 pingv6_ops.ip6_datagram_recv_common_ctl(sk, msg, skb);
910 if (skb->protocol == htons(ETH_P_IPV6) &&
911 inet6_sk(sk)->rxopt.all)
912 pingv6_ops.ip6_datagram_recv_specific_ctl(sk, msg, skb);
913 else if (skb->protocol == htons(ETH_P_IP) && isk->cmsg_flags)
914 ip_cmsg_recv(msg, skb);
910#endif 915#endif
911 } else { 916 } else {
912 BUG(); 917 BUG();