aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorent Fourcot <florent.fourcot@enst-bretagne.fr>2013-12-08 09:46:57 -0500
committerDavid S. Miller <davem@davemloft.net>2013-12-09 21:03:49 -0500
commit1397ed35f22d7c30d0b89ba74b6b7829220dfcfd (patch)
treed6c3ce6a964fd25d5f0348523bf47c28e5af273d
parent5824d2d16d39a9c57aa3bacf955fbd0c2134061f (diff)
ipv6: add flowinfo for tcp6 pkt_options for all cases
The current implementation of IPV6_FLOWINFO only gives a result if pktoptions is available (thanks to the ip6_datagram_recv_ctl function). It gives inconsistent results to user space, sometimes there is a result for getsockopt(IPV6_FLOWINFO), sometimes not. This patch add rcv_flowinfo to store it, and return it to the userspace in the same way than other pkt_options. Signed-off-by: Florent Fourcot <florent.fourcot@enst-bretagne.fr> Reviewed-by: Hannes Frederic Sowa <hannes@stressinduktion.org> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--include/linux/ipv6.h1
-rw-r--r--net/ipv6/ipv6_sockglue.c4
-rw-r--r--net/ipv6/tcp_ipv6.c4
3 files changed, 9 insertions, 0 deletions
diff --git a/include/linux/ipv6.h b/include/linux/ipv6.h
index c56c350324e4..0b2ebfbbe0f4 100644
--- a/include/linux/ipv6.h
+++ b/include/linux/ipv6.h
@@ -201,6 +201,7 @@ struct ipv6_pinfo {
201 __u8 min_hopcount; 201 __u8 min_hopcount;
202 __u8 tclass; 202 __u8 tclass;
203 __u8 rcv_tclass; 203 __u8 rcv_tclass;
204 __be32 rcv_flowinfo;
204 205
205 __u32 dst_cookie; 206 __u32 dst_cookie;
206 __u32 rx_dst_cookie; 207 __u32 rx_dst_cookie;
diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
index 1c6ce3119ff8..c2db1df46385 100644
--- a/net/ipv6/ipv6_sockglue.c
+++ b/net/ipv6/ipv6_sockglue.c
@@ -1034,6 +1034,10 @@ static int do_ipv6_getsockopt(struct sock *sk, int level, int optname,
1034 int hlim = np->mcast_hops; 1034 int hlim = np->mcast_hops;
1035 put_cmsg(&msg, SOL_IPV6, IPV6_2292HOPLIMIT, sizeof(hlim), &hlim); 1035 put_cmsg(&msg, SOL_IPV6, IPV6_2292HOPLIMIT, sizeof(hlim), &hlim);
1036 } 1036 }
1037 if (np->rxopt.bits.rxflow) {
1038 int flowinfo = np->rcv_flowinfo;
1039 put_cmsg(&msg, SOL_IPV6, IPV6_FLOWINFO, sizeof(flowinfo), &flowinfo);
1040 }
1037 } 1041 }
1038 len -= msg.msg_controllen; 1042 len -= msg.msg_controllen;
1039 return put_user(len, optlen); 1043 return put_user(len, optlen);
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index 0740f93a114a..79a196369558 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -1136,6 +1136,7 @@ static struct sock * tcp_v6_syn_recv_sock(struct sock *sk, struct sk_buff *skb,
1136 newnp->mcast_oif = inet6_iif(skb); 1136 newnp->mcast_oif = inet6_iif(skb);
1137 newnp->mcast_hops = ipv6_hdr(skb)->hop_limit; 1137 newnp->mcast_hops = ipv6_hdr(skb)->hop_limit;
1138 newnp->rcv_tclass = ipv6_get_dsfield(ipv6_hdr(skb)); 1138 newnp->rcv_tclass = ipv6_get_dsfield(ipv6_hdr(skb));
1139 newnp->rcv_flowinfo = ip6_flowinfo(ipv6_hdr(skb));
1139 1140
1140 /* 1141 /*
1141 * No need to charge this sock to the relevant IPv6 refcnt debug socks count 1142 * No need to charge this sock to the relevant IPv6 refcnt debug socks count
@@ -1216,6 +1217,7 @@ static struct sock * tcp_v6_syn_recv_sock(struct sock *sk, struct sk_buff *skb,
1216 newnp->mcast_oif = inet6_iif(skb); 1217 newnp->mcast_oif = inet6_iif(skb);
1217 newnp->mcast_hops = ipv6_hdr(skb)->hop_limit; 1218 newnp->mcast_hops = ipv6_hdr(skb)->hop_limit;
1218 newnp->rcv_tclass = ipv6_get_dsfield(ipv6_hdr(skb)); 1219 newnp->rcv_tclass = ipv6_get_dsfield(ipv6_hdr(skb));
1220 newnp->rcv_flowinfo = ip6_flowinfo(ipv6_hdr(skb));
1219 1221
1220 /* Clone native IPv6 options from listening socket (if any) 1222 /* Clone native IPv6 options from listening socket (if any)
1221 1223
@@ -1427,6 +1429,8 @@ ipv6_pktoptions:
1427 np->mcast_hops = ipv6_hdr(opt_skb)->hop_limit; 1429 np->mcast_hops = ipv6_hdr(opt_skb)->hop_limit;
1428 if (np->rxopt.bits.rxtclass) 1430 if (np->rxopt.bits.rxtclass)
1429 np->rcv_tclass = ipv6_get_dsfield(ipv6_hdr(opt_skb)); 1431 np->rcv_tclass = ipv6_get_dsfield(ipv6_hdr(opt_skb));
1432 if (np->rxopt.bits.rxflow)
1433 np->rcv_flowinfo = ip6_flowinfo(ipv6_hdr(opt_skb));
1430 if (ipv6_opt_accepted(sk, opt_skb)) { 1434 if (ipv6_opt_accepted(sk, opt_skb)) {
1431 skb_set_owner_r(opt_skb, sk); 1435 skb_set_owner_r(opt_skb, sk);
1432 opt_skb = xchg(&np->pktoptions, opt_skb); 1436 opt_skb = xchg(&np->pktoptions, opt_skb);