Commit 1397ed35 authored by Florent Fourcot's avatar Florent Fourcot Committed by David S. Miller

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: default avatarFlorent Fourcot <florent.fourcot@enst-bretagne.fr>
Reviewed-by: default avatarHannes Frederic Sowa <hannes@stressinduktion.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 5824d2d1
...@@ -201,6 +201,7 @@ struct ipv6_pinfo { ...@@ -201,6 +201,7 @@ struct ipv6_pinfo {
__u8 min_hopcount; __u8 min_hopcount;
__u8 tclass; __u8 tclass;
__u8 rcv_tclass; __u8 rcv_tclass;
__be32 rcv_flowinfo;
__u32 dst_cookie; __u32 dst_cookie;
__u32 rx_dst_cookie; __u32 rx_dst_cookie;
......
...@@ -1034,6 +1034,10 @@ static int do_ipv6_getsockopt(struct sock *sk, int level, int optname, ...@@ -1034,6 +1034,10 @@ static int do_ipv6_getsockopt(struct sock *sk, int level, int optname,
int hlim = np->mcast_hops; int hlim = np->mcast_hops;
put_cmsg(&msg, SOL_IPV6, IPV6_2292HOPLIMIT, sizeof(hlim), &hlim); put_cmsg(&msg, SOL_IPV6, IPV6_2292HOPLIMIT, sizeof(hlim), &hlim);
} }
if (np->rxopt.bits.rxflow) {
int flowinfo = np->rcv_flowinfo;
put_cmsg(&msg, SOL_IPV6, IPV6_FLOWINFO, sizeof(flowinfo), &flowinfo);
}
} }
len -= msg.msg_controllen; len -= msg.msg_controllen;
return put_user(len, optlen); return put_user(len, optlen);
......
...@@ -1136,6 +1136,7 @@ static struct sock * tcp_v6_syn_recv_sock(struct sock *sk, struct sk_buff *skb, ...@@ -1136,6 +1136,7 @@ static struct sock * tcp_v6_syn_recv_sock(struct sock *sk, struct sk_buff *skb,
newnp->mcast_oif = inet6_iif(skb); newnp->mcast_oif = inet6_iif(skb);
newnp->mcast_hops = ipv6_hdr(skb)->hop_limit; newnp->mcast_hops = ipv6_hdr(skb)->hop_limit;
newnp->rcv_tclass = ipv6_get_dsfield(ipv6_hdr(skb)); newnp->rcv_tclass = ipv6_get_dsfield(ipv6_hdr(skb));
newnp->rcv_flowinfo = ip6_flowinfo(ipv6_hdr(skb));
/* /*
* No need to charge this sock to the relevant IPv6 refcnt debug socks count * 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,6 +1217,7 @@ static struct sock * tcp_v6_syn_recv_sock(struct sock *sk, struct sk_buff *skb,
newnp->mcast_oif = inet6_iif(skb); newnp->mcast_oif = inet6_iif(skb);
newnp->mcast_hops = ipv6_hdr(skb)->hop_limit; newnp->mcast_hops = ipv6_hdr(skb)->hop_limit;
newnp->rcv_tclass = ipv6_get_dsfield(ipv6_hdr(skb)); newnp->rcv_tclass = ipv6_get_dsfield(ipv6_hdr(skb));
newnp->rcv_flowinfo = ip6_flowinfo(ipv6_hdr(skb));
/* Clone native IPv6 options from listening socket (if any) /* Clone native IPv6 options from listening socket (if any)
...@@ -1427,6 +1429,8 @@ static int tcp_v6_do_rcv(struct sock *sk, struct sk_buff *skb) ...@@ -1427,6 +1429,8 @@ static int tcp_v6_do_rcv(struct sock *sk, struct sk_buff *skb)
np->mcast_hops = ipv6_hdr(opt_skb)->hop_limit; np->mcast_hops = ipv6_hdr(opt_skb)->hop_limit;
if (np->rxopt.bits.rxtclass) if (np->rxopt.bits.rxtclass)
np->rcv_tclass = ipv6_get_dsfield(ipv6_hdr(opt_skb)); np->rcv_tclass = ipv6_get_dsfield(ipv6_hdr(opt_skb));
if (np->rxopt.bits.rxflow)
np->rcv_flowinfo = ip6_flowinfo(ipv6_hdr(opt_skb));
if (ipv6_opt_accepted(sk, opt_skb)) { if (ipv6_opt_accepted(sk, opt_skb)) {
skb_set_owner_r(opt_skb, sk); skb_set_owner_r(opt_skb, sk);
opt_skb = xchg(&np->pktoptions, opt_skb); opt_skb = xchg(&np->pktoptions, opt_skb);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment