* [PATCH net-next v3 1/3] ipv6: enable IPV6_FLOWLABEL_MGR for getsockopt
@ 2013-11-07 16:53 Florent Fourcot
2013-11-07 16:53 ` [PATCH net-next 2/3] ipv6: increase maximum lifetime of flow labels Florent Fourcot
` (3 more replies)
0 siblings, 4 replies; 10+ messages in thread
From: Florent Fourcot @ 2013-11-07 16:53 UTC (permalink / raw)
To: netdev; +Cc: Florent Fourcot
It is already possible to set/put/renew a label
with IPV6_FLOWLABEL_MGR and setsockopt. This patch
add the possibility to get information about this
label (current value, time before expiration, etc).
It helps application to take decision for a renew
or a release of the label.
v2:
* Add spin_lock to prevent race condition
* return -ENOENT if no result found
* check if flr_action is GET
v3:
* move the spin_lock to protect only the
relevant code
Signed-off-by: Florent Fourcot <florent.fourcot@enst-bretagne.fr>
---
include/net/ipv6.h | 1 +
net/ipv6/ip6_flowlabel.c | 26 ++++++++++++++++++++++++++
net/ipv6/ipv6_sockglue.c | 28 ++++++++++++++++++++++++++++
3 files changed, 55 insertions(+)
diff --git a/include/net/ipv6.h b/include/net/ipv6.h
index dd96638..2a5f668 100644
--- a/include/net/ipv6.h
+++ b/include/net/ipv6.h
@@ -250,6 +250,7 @@ struct ipv6_txoptions *fl6_merge_options(struct ipv6_txoptions *opt_space,
struct ipv6_txoptions *fopt);
void fl6_free_socklist(struct sock *sk);
int ipv6_flowlabel_opt(struct sock *sk, char __user *optval, int optlen);
+int ipv6_flowlabel_opt_get(struct sock *sk, struct in6_flowlabel_req *freq);
int ip6_flowlabel_init(void);
void ip6_flowlabel_cleanup(void);
diff --git a/net/ipv6/ip6_flowlabel.c b/net/ipv6/ip6_flowlabel.c
index 819578e..4a06ed0 100644
--- a/net/ipv6/ip6_flowlabel.c
+++ b/net/ipv6/ip6_flowlabel.c
@@ -475,6 +475,32 @@ static inline void fl_link(struct ipv6_pinfo *np, struct ipv6_fl_socklist *sfl,
spin_unlock_bh(&ip6_sk_fl_lock);
}
+int ipv6_flowlabel_opt_get(struct sock *sk, struct in6_flowlabel_req *freq)
+{
+ struct ipv6_pinfo *np = inet6_sk(sk);
+ struct ipv6_fl_socklist *sfl;
+
+ rcu_read_lock_bh();
+
+ for_each_sk_fl_rcu(np, sfl) {
+ if (sfl->fl->label == (np->flow_label & IPV6_FLOWLABEL_MASK)) {
+ spin_lock_bh(&ip6_fl_lock);
+ freq->flr_label = sfl->fl->label;
+ freq->flr_dst = sfl->fl->dst;
+ freq->flr_share = sfl->fl->share;
+ freq->flr_expires = (sfl->fl->expires - jiffies) / HZ;
+ freq->flr_linger = sfl->fl->linger / HZ;
+
+ spin_unlock_bh(&ip6_fl_lock);
+ rcu_read_unlock_bh();
+ return 0;
+ }
+ }
+ rcu_read_unlock_bh();
+
+ return -ENOENT;
+}
+
int ipv6_flowlabel_opt(struct sock *sk, char __user *optval, int optlen)
{
int uninitialized_var(err);
diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
index 4919a8e..1c6ce31 100644
--- a/net/ipv6/ipv6_sockglue.c
+++ b/net/ipv6/ipv6_sockglue.c
@@ -1212,6 +1212,34 @@ static int do_ipv6_getsockopt(struct sock *sk, int level, int optname,
val = np->sndflow;
break;
+ case IPV6_FLOWLABEL_MGR:
+ {
+ struct in6_flowlabel_req freq;
+
+ if (len < sizeof(freq))
+ return -EINVAL;
+
+ if (copy_from_user(&freq, optval, sizeof(freq)))
+ return -EFAULT;
+
+ if (freq.flr_action != IPV6_FL_A_GET)
+ return -EINVAL;
+
+ len = sizeof(freq);
+ memset(&freq, 0, sizeof(freq));
+
+ val = ipv6_flowlabel_opt_get(sk, &freq);
+ if (val < 0)
+ return val;
+
+ if (put_user(len, optlen))
+ return -EFAULT;
+ if (copy_to_user(optval, &freq, len))
+ return -EFAULT;
+
+ return 0;
+ }
+
case IPV6_ADDR_PREFERENCES:
val = 0;
--
1.8.4.rc3
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH net-next 2/3] ipv6: increase maximum lifetime of flow labels
2013-11-07 16:53 [PATCH net-next v3 1/3] ipv6: enable IPV6_FLOWLABEL_MGR for getsockopt Florent Fourcot
@ 2013-11-07 16:53 ` Florent Fourcot
2013-11-08 12:34 ` Hannes Frederic Sowa
2013-11-08 18:44 ` David Miller
2013-11-07 16:53 ` [PATCH net-next v2 3/3] ipv6: protect flow label renew against GC Florent Fourcot
` (2 subsequent siblings)
3 siblings, 2 replies; 10+ messages in thread
From: Florent Fourcot @ 2013-11-07 16:53 UTC (permalink / raw)
To: netdev; +Cc: Florent Fourcot
If the last RFC 6437 does not give any constraints
for lifetime of flow labels, the previous RFC 3697
spoke of a minimum of 120 seconds between
reattribution of a flow label.
The maximum linger is currently set to 60 seconds
and does not allow this configuration without
CAP_NET_ADMIN right.
This patch increase the maximum linger to 150
seconds, allowing more flexibility to standard
users.
Signed-off-by: Florent Fourcot <florent.fourcot@enst-bretagne.fr>
---
net/ipv6/ip6_flowlabel.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/ipv6/ip6_flowlabel.c b/net/ipv6/ip6_flowlabel.c
index 4a06ed0..5f10b0d 100644
--- a/net/ipv6/ip6_flowlabel.c
+++ b/net/ipv6/ip6_flowlabel.c
@@ -41,7 +41,7 @@
#define FL_MIN_LINGER 6 /* Minimal linger. It is set to 6sec specified
in old IPv6 RFC. Well, it was reasonable value.
*/
-#define FL_MAX_LINGER 60 /* Maximal linger timeout */
+#define FL_MAX_LINGER 150 /* Maximal linger timeout */
/* FL hash table */
--
1.8.4.rc3
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH net-next 2/3] ipv6: increase maximum lifetime of flow labels
2013-11-07 16:53 ` [PATCH net-next 2/3] ipv6: increase maximum lifetime of flow labels Florent Fourcot
@ 2013-11-08 12:34 ` Hannes Frederic Sowa
2013-11-08 18:44 ` David Miller
1 sibling, 0 replies; 10+ messages in thread
From: Hannes Frederic Sowa @ 2013-11-08 12:34 UTC (permalink / raw)
To: Florent Fourcot; +Cc: netdev
On Thu, Nov 07, 2013 at 05:53:13PM +0100, Florent Fourcot wrote:
> If the last RFC 6437 does not give any constraints
> for lifetime of flow labels, the previous RFC 3697
> spoke of a minimum of 120 seconds between
> reattribution of a flow label.
>
> The maximum linger is currently set to 60 seconds
> and does not allow this configuration without
> CAP_NET_ADMIN right.
>
> This patch increase the maximum linger to 150
> seconds, allowing more flexibility to standard
> users.
Acked-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH net-next 2/3] ipv6: increase maximum lifetime of flow labels
2013-11-07 16:53 ` [PATCH net-next 2/3] ipv6: increase maximum lifetime of flow labels Florent Fourcot
2013-11-08 12:34 ` Hannes Frederic Sowa
@ 2013-11-08 18:44 ` David Miller
1 sibling, 0 replies; 10+ messages in thread
From: David Miller @ 2013-11-08 18:44 UTC (permalink / raw)
To: florent.fourcot; +Cc: netdev
From: Florent Fourcot <florent.fourcot@enst-bretagne.fr>
Date: Thu, 7 Nov 2013 17:53:13 +0100
> If the last RFC 6437 does not give any constraints
> for lifetime of flow labels, the previous RFC 3697
> spoke of a minimum of 120 seconds between
> reattribution of a flow label.
>
> The maximum linger is currently set to 60 seconds
> and does not allow this configuration without
> CAP_NET_ADMIN right.
>
> This patch increase the maximum linger to 150
> seconds, allowing more flexibility to standard
> users.
>
> Signed-off-by: Florent Fourcot <florent.fourcot@enst-bretagne.fr>
Applied.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH net-next v2 3/3] ipv6: protect flow label renew against GC
2013-11-07 16:53 [PATCH net-next v3 1/3] ipv6: enable IPV6_FLOWLABEL_MGR for getsockopt Florent Fourcot
2013-11-07 16:53 ` [PATCH net-next 2/3] ipv6: increase maximum lifetime of flow labels Florent Fourcot
@ 2013-11-07 16:53 ` Florent Fourcot
2013-11-08 12:29 ` Hannes Frederic Sowa
2013-11-08 18:44 ` David Miller
2013-11-07 16:56 ` [PATCH net-next v3 1/3] ipv6: enable IPV6_FLOWLABEL_MGR for getsockopt Florent Fourcot
2013-11-08 12:27 ` Hannes Frederic Sowa
3 siblings, 2 replies; 10+ messages in thread
From: Florent Fourcot @ 2013-11-07 16:53 UTC (permalink / raw)
To: netdev; +Cc: Florent Fourcot
Take ip6_fl_lock before to read and update
a label.
v2: protect only the relevant code
Reported-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
Signed-off-by: Florent Fourcot <florent.fourcot@enst-bretagne.fr>
---
net/ipv6/ip6_flowlabel.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/net/ipv6/ip6_flowlabel.c b/net/ipv6/ip6_flowlabel.c
index 5f10b0d..98fdcc6 100644
--- a/net/ipv6/ip6_flowlabel.c
+++ b/net/ipv6/ip6_flowlabel.c
@@ -345,6 +345,8 @@ static int fl6_renew(struct ip6_flowlabel *fl, unsigned long linger, unsigned lo
expires = check_linger(expires);
if (!expires)
return -EPERM;
+
+ spin_lock_bh(&ip6_fl_lock);
fl->lastuse = jiffies;
if (time_before(fl->linger, linger))
fl->linger = linger;
@@ -352,6 +354,8 @@ static int fl6_renew(struct ip6_flowlabel *fl, unsigned long linger, unsigned lo
expires = fl->linger;
if (time_before(fl->expires, fl->lastuse + expires))
fl->expires = fl->lastuse + expires;
+ spin_unlock_bh(&ip6_fl_lock);
+
return 0;
}
--
1.8.4.rc3
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH net-next v3 1/3] ipv6: enable IPV6_FLOWLABEL_MGR for getsockopt
2013-11-07 16:53 [PATCH net-next v3 1/3] ipv6: enable IPV6_FLOWLABEL_MGR for getsockopt Florent Fourcot
2013-11-07 16:53 ` [PATCH net-next 2/3] ipv6: increase maximum lifetime of flow labels Florent Fourcot
2013-11-07 16:53 ` [PATCH net-next v2 3/3] ipv6: protect flow label renew against GC Florent Fourcot
@ 2013-11-07 16:56 ` Florent Fourcot
2013-11-08 12:27 ` Hannes Frederic Sowa
3 siblings, 0 replies; 10+ messages in thread
From: Florent Fourcot @ 2013-11-07 16:56 UTC (permalink / raw)
To: netdev
This series replaces the previous one, sent the 5th November.
Regards,
--
Florent
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH net-next v3 1/3] ipv6: enable IPV6_FLOWLABEL_MGR for getsockopt
2013-11-07 16:53 [PATCH net-next v3 1/3] ipv6: enable IPV6_FLOWLABEL_MGR for getsockopt Florent Fourcot
` (2 preceding siblings ...)
2013-11-07 16:56 ` [PATCH net-next v3 1/3] ipv6: enable IPV6_FLOWLABEL_MGR for getsockopt Florent Fourcot
@ 2013-11-08 12:27 ` Hannes Frederic Sowa
2013-11-08 18:43 ` David Miller
3 siblings, 1 reply; 10+ messages in thread
From: Hannes Frederic Sowa @ 2013-11-08 12:27 UTC (permalink / raw)
To: Florent Fourcot; +Cc: netdev
On Thu, Nov 07, 2013 at 05:53:12PM +0100, Florent Fourcot wrote:
> It is already possible to set/put/renew a label
> with IPV6_FLOWLABEL_MGR and setsockopt. This patch
> add the possibility to get information about this
> label (current value, time before expiration, etc).
>
> It helps application to take decision for a renew
> or a release of the label.
>
> v2:
> * Add spin_lock to prevent race condition
> * return -ENOENT if no result found
> * check if flr_action is GET
>
> v3:
> * move the spin_lock to protect only the
> relevant code
>
> Signed-off-by: Florent Fourcot <florent.fourcot@enst-bretagne.fr>
There still are some locking anomalies in ip6_flowlabel. But none
has something to do with your patches. E.g. mem_check runs without
rcu_read_lock.
Acked-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
Thanks,
Hannes
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH net-next v3 1/3] ipv6: enable IPV6_FLOWLABEL_MGR for getsockopt
2013-11-08 12:27 ` Hannes Frederic Sowa
@ 2013-11-08 18:43 ` David Miller
0 siblings, 0 replies; 10+ messages in thread
From: David Miller @ 2013-11-08 18:43 UTC (permalink / raw)
To: hannes; +Cc: florent.fourcot, netdev
From: Hannes Frederic Sowa <hannes@stressinduktion.org>
Date: Fri, 8 Nov 2013 13:27:49 +0100
> On Thu, Nov 07, 2013 at 05:53:12PM +0100, Florent Fourcot wrote:
>> It is already possible to set/put/renew a label
>> with IPV6_FLOWLABEL_MGR and setsockopt. This patch
>> add the possibility to get information about this
>> label (current value, time before expiration, etc).
>>
>> It helps application to take decision for a renew
>> or a release of the label.
>>
>> v2:
>> * Add spin_lock to prevent race condition
>> * return -ENOENT if no result found
>> * check if flr_action is GET
>>
>> v3:
>> * move the spin_lock to protect only the
>> relevant code
>>
>> Signed-off-by: Florent Fourcot <florent.fourcot@enst-bretagne.fr>
>
> There still are some locking anomalies in ip6_flowlabel. But none
> has something to do with your patches. E.g. mem_check runs without
> rcu_read_lock.
>
> Acked-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
Applied, thanks.
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2013-11-08 18:44 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-07 16:53 [PATCH net-next v3 1/3] ipv6: enable IPV6_FLOWLABEL_MGR for getsockopt Florent Fourcot
2013-11-07 16:53 ` [PATCH net-next 2/3] ipv6: increase maximum lifetime of flow labels Florent Fourcot
2013-11-08 12:34 ` Hannes Frederic Sowa
2013-11-08 18:44 ` David Miller
2013-11-07 16:53 ` [PATCH net-next v2 3/3] ipv6: protect flow label renew against GC Florent Fourcot
2013-11-08 12:29 ` Hannes Frederic Sowa
2013-11-08 18:44 ` David Miller
2013-11-07 16:56 ` [PATCH net-next v3 1/3] ipv6: enable IPV6_FLOWLABEL_MGR for getsockopt Florent Fourcot
2013-11-08 12:27 ` Hannes Frederic Sowa
2013-11-08 18:43 ` 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).