* [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
* [PATCH net-next 2/5] ipv6: move IPV6_TCLASS_MASK definition in ipv6.h
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 ` 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
` (4 subsequent siblings)
5 siblings, 2 replies; 15+ messages in thread
From: Florent Fourcot @ 2013-12-08 14:46 UTC (permalink / raw)
To: netdev; +Cc: Florent Fourcot
Signed-off-by: Florent Fourcot <florent.fourcot@enst-bretagne.fr>
---
include/net/ipv6.h | 1 +
net/ipv6/ip6_gre.c | 1 -
net/ipv6/ip6_tunnel.c | 1 -
3 files changed, 1 insertion(+), 2 deletions(-)
diff --git a/include/net/ipv6.h b/include/net/ipv6.h
index eb198ac..f0edf00 100644
--- a/include/net/ipv6.h
+++ b/include/net/ipv6.h
@@ -237,6 +237,7 @@ struct ip6_flowlabel {
#define IPV6_FLOWINFO_MASK cpu_to_be32(0x0FFFFFFF)
#define IPV6_FLOWLABEL_MASK cpu_to_be32(0x000FFFFF)
+#define IPV6_TCLASS_MASK (IPV6_FLOWINFO_MASK & ~IPV6_FLOWLABEL_MASK)
struct ipv6_fl_socklist {
struct ipv6_fl_socklist __rcu *next;
diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
index 8acb286..c50de06 100644
--- a/net/ipv6/ip6_gre.c
+++ b/net/ipv6/ip6_gre.c
@@ -61,7 +61,6 @@ static bool log_ecn_error = true;
module_param(log_ecn_error, bool, 0644);
MODULE_PARM_DESC(log_ecn_error, "Log packets received with corrupted ECN");
-#define IPV6_TCLASS_MASK (IPV6_FLOWINFO_MASK & ~IPV6_FLOWLABEL_MASK)
#define IPV6_TCLASS_SHIFT 20
#define HASH_SIZE_SHIFT 5
diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
index d606232..f5e8a98 100644
--- a/net/ipv6/ip6_tunnel.c
+++ b/net/ipv6/ip6_tunnel.c
@@ -70,7 +70,6 @@ MODULE_ALIAS_NETDEV("ip6tnl0");
#define IP6_TNL_TRACE(x...) do {;} while(0)
#endif
-#define IPV6_TCLASS_MASK (IPV6_FLOWINFO_MASK & ~IPV6_FLOWLABEL_MASK)
#define IPV6_TCLASS_SHIFT 20
#define HASH_SIZE_SHIFT 5
--
1.8.4.3
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH net-next 3/5] ipv6: remove rcv_tclass of ipv6_pinfo
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-08 14:46 ` 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
` (3 subsequent siblings)
5 siblings, 2 replies; 15+ messages in thread
From: Florent Fourcot @ 2013-12-08 14:46 UTC (permalink / raw)
To: netdev; +Cc: Florent Fourcot
tclass information in now already stored in rcv_flowinfo
We do not need to store the same information twice.
Signed-off-by: Florent Fourcot <florent.fourcot@enst-bretagne.fr>
---
include/linux/ipv6.h | 1 -
net/ipv6/ipv6_sockglue.c | 2 +-
net/ipv6/tcp_ipv6.c | 6 +-----
3 files changed, 2 insertions(+), 7 deletions(-)
diff --git a/include/linux/ipv6.h b/include/linux/ipv6.h
index 6ba19dd..ecd9152 100644
--- a/include/linux/ipv6.h
+++ b/include/linux/ipv6.h
@@ -199,7 +199,6 @@ struct ipv6_pinfo {
dontfrag:1;
__u8 min_hopcount;
__u8 tclass;
- __u8 rcv_tclass;
__be32 rcv_flowinfo;
__u32 dst_cookie;
diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
index c2db1df..7d93915 100644
--- a/net/ipv6/ipv6_sockglue.c
+++ b/net/ipv6/ipv6_sockglue.c
@@ -1019,7 +1019,7 @@ static int do_ipv6_getsockopt(struct sock *sk, int level, int optname,
put_cmsg(&msg, SOL_IPV6, IPV6_HOPLIMIT, sizeof(hlim), &hlim);
}
if (np->rxopt.bits.rxtclass) {
- int tclass = np->rcv_tclass;
+ int tclass = ntohl(np->rcv_flowinfo & IPV6_TCLASS_MASK) >> 20;
put_cmsg(&msg, SOL_IPV6, IPV6_TCLASS, sizeof(tclass), &tclass);
}
if (np->rxopt.bits.rxoinfo) {
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index 79a1963..bd91e7f 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -1135,7 +1135,6 @@ static struct sock * tcp_v6_syn_recv_sock(struct sock *sk, struct sk_buff *skb,
newnp->opt = NULL;
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));
/*
@@ -1216,7 +1215,6 @@ static struct sock * tcp_v6_syn_recv_sock(struct sock *sk, struct sk_buff *skb,
newnp->opt = NULL;
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,9 +1425,7 @@ ipv6_pktoptions:
np->mcast_oif = inet6_iif(opt_skb);
if (np->rxopt.bits.rxhlim || np->rxopt.bits.rxohlim)
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)
+ if (np->rxopt.bits.rxflow || np->rxopt.bits.rxtclass)
np->rcv_flowinfo = ip6_flowinfo(ipv6_hdr(opt_skb));
if (ipv6_opt_accepted(sk, opt_skb)) {
skb_set_owner_r(opt_skb, sk);
--
1.8.4.3
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH net-next 4/5] ipv6: add ip6_flowlabel helper
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-08 14:46 ` [PATCH net-next 3/5] ipv6: remove rcv_tclass of ipv6_pinfo Florent Fourcot
@ 2013-12-08 14:47 ` 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
` (2 subsequent siblings)
5 siblings, 2 replies; 15+ messages in thread
From: Florent Fourcot @ 2013-12-08 14:47 UTC (permalink / raw)
To: netdev; +Cc: Florent Fourcot
And use it if possible.
Signed-off-by: Florent Fourcot <florent.fourcot@enst-bretagne.fr>
---
include/net/ipv6.h | 5 +++++
net/ipv6/ip6_gre.c | 2 +-
net/ipv6/ip6_tunnel.c | 2 +-
3 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/include/net/ipv6.h b/include/net/ipv6.h
index f0edf00..ff196b2 100644
--- a/include/net/ipv6.h
+++ b/include/net/ipv6.h
@@ -678,6 +678,11 @@ static inline __be32 ip6_flowinfo(const struct ipv6hdr *hdr)
return *(__be32 *)hdr & IPV6_FLOWINFO_MASK;
}
+static inline __be32 ip6_flowlabel(const struct ipv6hdr *hdr)
+{
+ return *(__be32 *)hdr & IPV6_FLOWLABEL_MASK;
+}
+
/*
* Prototypes exported by ipv6
*/
diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
index c50de06..e27fb78 100644
--- a/net/ipv6/ip6_gre.c
+++ b/net/ipv6/ip6_gre.c
@@ -845,7 +845,7 @@ static inline int ip6gre_xmit_ipv6(struct sk_buff *skb, struct net_device *dev)
if (t->parms.flags & IP6_TNL_F_USE_ORIG_TCLASS)
fl6.flowlabel |= (*(__be32 *) ipv6h & IPV6_TCLASS_MASK);
if (t->parms.flags & IP6_TNL_F_USE_ORIG_FLOWLABEL)
- fl6.flowlabel |= (*(__be32 *) ipv6h & IPV6_FLOWLABEL_MASK);
+ fl6.flowlabel |= ip6_flowlabel(ipv6h);
if (t->parms.flags & IP6_TNL_F_USE_ORIG_FWMARK)
fl6.flowi6_mark = skb->mark;
diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
index f5e8a98..8d7c986 100644
--- a/net/ipv6/ip6_tunnel.c
+++ b/net/ipv6/ip6_tunnel.c
@@ -1130,7 +1130,7 @@ ip6ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev)
if (t->parms.flags & IP6_TNL_F_USE_ORIG_TCLASS)
fl6.flowlabel |= (*(__be32 *) ipv6h & IPV6_TCLASS_MASK);
if (t->parms.flags & IP6_TNL_F_USE_ORIG_FLOWLABEL)
- fl6.flowlabel |= (*(__be32 *) ipv6h & IPV6_FLOWLABEL_MASK);
+ fl6.flowlabel |= ip6_flowlabel(ipv6h);
if (t->parms.flags & IP6_TNL_F_USE_ORIG_FWMARK)
fl6.flowi6_mark = skb->mark;
--
1.8.4.3
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH net-next 5/5] ipv6: use ip6_flowinfo helper
2013-12-08 14:46 [PATCH net-next 1/5] ipv6: add flowinfo for tcp6 pkt_options for all cases Florent Fourcot
` (2 preceding siblings ...)
2013-12-08 14:47 ` [PATCH net-next 4/5] ipv6: add ip6_flowlabel helper Florent Fourcot
@ 2013-12-08 14:47 ` 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
5 siblings, 2 replies; 15+ messages in thread
From: Florent Fourcot @ 2013-12-08 14:47 UTC (permalink / raw)
To: netdev; +Cc: Florent Fourcot
Signed-off-by: Florent Fourcot <florent.fourcot@enst-bretagne.fr>
---
net/ipv6/af_inet6.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c
index 4fbdb70..027615a 100644
--- a/net/ipv6/af_inet6.c
+++ b/net/ipv6/af_inet6.c
@@ -683,8 +683,7 @@ bool ipv6_opt_accepted(const struct sock *sk, const struct sk_buff *skb)
if (np->rxopt.all) {
if ((opt->hop && (np->rxopt.bits.hopopts ||
np->rxopt.bits.ohopopts)) ||
- ((IPV6_FLOWINFO_MASK &
- *(__be32 *)skb_network_header(skb)) &&
+ (ip6_flowinfo((struct ipv6hdr *) skb_network_header(skb)) &&
np->rxopt.bits.rxflow) ||
(opt->srcrt && (np->rxopt.bits.srcrt ||
np->rxopt.bits.osrcrt)) ||
--
1.8.4.3
^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [PATCH net-next 1/5] ipv6: add flowinfo for tcp6 pkt_options for all cases
2013-12-08 14:46 [PATCH net-next 1/5] ipv6: add flowinfo for tcp6 pkt_options for all cases Florent Fourcot
` (3 preceding siblings ...)
2013-12-08 14:47 ` [PATCH net-next 5/5] ipv6: use ip6_flowinfo helper Florent Fourcot
@ 2013-12-09 23:41 ` Hannes Frederic Sowa
2013-12-10 2:04 ` David Miller
5 siblings, 0 replies; 15+ messages in thread
From: Hannes Frederic Sowa @ 2013-12-09 23:41 UTC (permalink / raw)
To: Florent Fourcot; +Cc: netdev
On Sun, Dec 08, 2013 at 03:46:57PM +0100, Florent Fourcot wrote:
> 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>
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH net-next 1/5] ipv6: add flowinfo for tcp6 pkt_options for all cases
2013-12-08 14:46 [PATCH net-next 1/5] ipv6: add flowinfo for tcp6 pkt_options for all cases Florent Fourcot
` (4 preceding siblings ...)
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
5 siblings, 0 replies; 15+ messages in thread
From: David Miller @ 2013-12-10 2:04 UTC (permalink / raw)
To: florent.fourcot; +Cc: netdev
From: Florent Fourcot <florent.fourcot@enst-bretagne.fr>
Date: Sun, 8 Dec 2013 15:46:57 +0100
> 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>
Applied.
^ permalink raw reply [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).