Re: [patch net-next 10/21] ipv6: fib: Add offload indication to routes

2017-08-03 Thread David Ahern
On 8/3/17 5:28 AM, Jiri Pirko wrote:
> diff --git a/include/uapi/linux/ipv6_route.h b/include/uapi/linux/ipv6_route.h
> index d496c02..33e2a57 100644
> --- a/include/uapi/linux/ipv6_route.h
> +++ b/include/uapi/linux/ipv6_route.h
> @@ -35,6 +35,7 @@
>  #define RTF_PREF(pref)   ((pref) << 27)
>  #define RTF_PREF_MASK0x1800
>  
> +#define RTF_OFFLOAD  0x2000  /* offloaded route  */
>  #define RTF_PCPU 0x4000  /* read-only: can not be set by user */
>  #define RTF_LOCAL0x8000

PCPU as a UAPI flag was a mistake; it is a flag internal to IPv6 stack
and really makes no sense to the user. The OFFLOAD should not follow
suit especially given the limited uapi bits left.


[patch net-next 10/21] ipv6: fib: Add offload indication to routes

2017-08-03 Thread Jiri Pirko
From: Ido Schimmel 

Allow user space applications to see which routes are offloaded and
which aren't by setting the RTNH_F_OFFLOAD flag when dumping them.

To be consistent with IPv4, offload indication is provided on a
per-nexthop basis.

Signed-off-by: Ido Schimmel 
Signed-off-by: Jiri Pirko 
---
 include/uapi/linux/ipv6_route.h | 1 +
 net/ipv6/route.c| 8 
 2 files changed, 9 insertions(+)

diff --git a/include/uapi/linux/ipv6_route.h b/include/uapi/linux/ipv6_route.h
index d496c02..33e2a57 100644
--- a/include/uapi/linux/ipv6_route.h
+++ b/include/uapi/linux/ipv6_route.h
@@ -35,6 +35,7 @@
 #define RTF_PREF(pref) ((pref) << 27)
 #define RTF_PREF_MASK  0x1800
 
+#define RTF_OFFLOAD0x2000  /* offloaded route  */
 #define RTF_PCPU   0x4000  /* read-only: can not be set by user */
 #define RTF_LOCAL  0x8000
 
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 4d30c96..aba07fc 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -1820,6 +1820,11 @@ static struct rt6_info *ip6_route_info_create(struct 
fib6_config *cfg,
goto out;
}
 
+   if (cfg->fc_flags & RTF_OFFLOAD) {
+   NL_SET_ERR_MSG(extack, "Userspace can not set RTF_OFFLOAD");
+   goto out;
+   }
+
if (cfg->fc_dst_len > 128) {
NL_SET_ERR_MSG(extack, "Invalid prefix length");
goto out;
@@ -3327,6 +3332,9 @@ static int rt6_nexthop_info(struct sk_buff *skb, struct 
rt6_info *rt,
goto nla_put_failure;
}
 
+   if (rt->rt6i_flags & RTF_OFFLOAD)
+   *flags |= RTNH_F_OFFLOAD;
+
/* not needed for multipath encoding b/c it has a rtnexthop struct */
if (!skip_oif && rt->dst.dev &&
nla_put_u32(skb, RTA_OIF, rt->dst.dev->ifindex))
-- 
2.9.3