netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next 1/5] ipv6: add flowinfo for tcp6 pkt_options for all cases
@ 2013-12-08 14:46 Florent Fourcot
  2013-12-08 14:46 ` [PATCH net-next 2/5] ipv6: move IPV6_TCLASS_MASK definition in ipv6.h Florent Fourcot
                   ` (5 more replies)
  0 siblings, 6 replies; 15+ messages in thread
From: Florent Fourcot @ 2013-12-08 14:46 UTC (permalink / raw)
  To: netdev; +Cc: Florent Fourcot

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>
---
 include/linux/ipv6.h     | 1 +
 net/ipv6/ipv6_sockglue.c | 4 ++++
 net/ipv6/tcp_ipv6.c      | 4 ++++
 3 files changed, 9 insertions(+)

diff --git a/include/linux/ipv6.h b/include/linux/ipv6.h
index 5d89d1b..6ba19dd 100644
--- a/include/linux/ipv6.h
+++ b/include/linux/ipv6.h
@@ -200,6 +200,7 @@ struct ipv6_pinfo {
 	__u8			min_hopcount;
 	__u8			tclass;
 	__u8			rcv_tclass;
+	__be32			rcv_flowinfo;
 
 	__u32			dst_cookie;
 	__u32			rx_dst_cookie;
diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
index 1c6ce31..c2db1df 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,
 				int hlim = np->mcast_hops;
 				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;
 		return put_user(len, optlen);
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index 0740f93..79a1963 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,
 		newnp->mcast_oif   = inet6_iif(skb);
 		newnp->mcast_hops  = ipv6_hdr(skb)->hop_limit;
 		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
@@ -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_hops = ipv6_hdr(skb)->hop_limit;
 	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)
 
@@ -1427,6 +1429,8 @@ ipv6_pktoptions:
 			np->mcast_hops = ipv6_hdr(opt_skb)->hop_limit;
 		if (np->rxopt.bits.rxtclass)
 			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)) {
 			skb_set_owner_r(opt_skb, sk);
 			opt_skb = xchg(&np->pktoptions, opt_skb);
-- 
1.8.4.3

^ permalink raw reply related	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2013-12-10  2:04 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-08 14:46 [PATCH net-next 1/5] ipv6: add flowinfo for tcp6 pkt_options for all cases Florent Fourcot
2013-12-08 14:46 ` [PATCH net-next 2/5] ipv6: move IPV6_TCLASS_MASK definition in ipv6.h Florent Fourcot
2013-12-09 23:41   ` Hannes Frederic Sowa
2013-12-10  2:04   ` David Miller
2013-12-08 14:46 ` [PATCH net-next 3/5] ipv6: remove rcv_tclass of ipv6_pinfo Florent Fourcot
2013-12-09 23:42   ` Hannes Frederic Sowa
2013-12-10  2:04   ` David Miller
2013-12-08 14:47 ` [PATCH net-next 4/5] ipv6: add ip6_flowlabel helper Florent Fourcot
2013-12-09 23:42   ` Hannes Frederic Sowa
2013-12-10  2:04   ` David Miller
2013-12-08 14:47 ` [PATCH net-next 5/5] ipv6: use ip6_flowinfo helper Florent Fourcot
2013-12-09 23:42   ` Hannes Frederic Sowa
2013-12-10  2:04   ` David Miller
2013-12-09 23:41 ` [PATCH net-next 1/5] ipv6: add flowinfo for tcp6 pkt_options for all cases Hannes Frederic Sowa
2013-12-10  2:04 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).