Re: [PATCH v2 net-next 2/3] net: Add extack to fib_notifier_info

2017-10-28 Thread Ido Schimmel
On Fri, Oct 27, 2017 at 05:37:13PM -0700, David Ahern wrote:
> Add extack to fib_notifier_info and plumb through stack to
> call_fib_rule_notifiers, call_fib_entry_notifiers and
> call_fib6_entry_notifiers. This allows notifer handlers to
> return messages to user.
> 
> Signed-off-by: David Ahern 

Reviewed-by: Ido Schimmel 


[PATCH v2 net-next 2/3] net: Add extack to fib_notifier_info

2017-10-27 Thread David Ahern
Add extack to fib_notifier_info and plumb through stack to
call_fib_rule_notifiers, call_fib_entry_notifiers and
call_fib6_entry_notifiers. This allows notifer handlers to
return messages to user.

Signed-off-by: David Ahern 
---
 include/net/fib_notifier.h |  1 +
 net/core/fib_rules.c   |  9 ++---
 net/ipv4/fib_trie.c| 13 -
 net/ipv6/ip6_fib.c | 15 +--
 4 files changed, 24 insertions(+), 14 deletions(-)

diff --git a/include/net/fib_notifier.h b/include/net/fib_notifier.h
index 54cd6b839d2f..c91ec732afd6 100644
--- a/include/net/fib_notifier.h
+++ b/include/net/fib_notifier.h
@@ -9,6 +9,7 @@
 struct fib_notifier_info {
struct net *net;
int family;
+   struct netlink_ext_ack  *extack;
 };
 
 enum fib_event_type {
diff --git a/net/core/fib_rules.c b/net/core/fib_rules.c
index 9a6d97c1d810..fafd0a41e3f7 100644
--- a/net/core/fib_rules.c
+++ b/net/core/fib_rules.c
@@ -314,10 +314,12 @@ static int call_fib_rule_notifier(struct notifier_block 
*nb, struct net *net,
 static int call_fib_rule_notifiers(struct net *net,
   enum fib_event_type event_type,
   struct fib_rule *rule,
-  struct fib_rules_ops *ops)
+  struct fib_rules_ops *ops,
+  struct netlink_ext_ack *extack)
 {
struct fib_rule_notifier_info info = {
.info.family = ops->family,
+   .info.extack = extack,
.rule = rule,
};
 
@@ -609,7 +611,7 @@ int fib_nl_newrule(struct sk_buff *skb, struct nlmsghdr 
*nlh,
if (rule->tun_id)
ip_tunnel_need_metadata();
 
-   call_fib_rule_notifiers(net, FIB_EVENT_RULE_ADD, rule, ops);
+   call_fib_rule_notifiers(net, FIB_EVENT_RULE_ADD, rule, ops, extack);
notify_rule_change(RTM_NEWRULE, rule, ops, nlh, NETLINK_CB(skb).portid);
flush_route_cache(ops);
rules_ops_put(ops);
@@ -749,7 +751,8 @@ int fib_nl_delrule(struct sk_buff *skb, struct nlmsghdr 
*nlh,
}
}
 
-   call_fib_rule_notifiers(net, FIB_EVENT_RULE_DEL, rule, ops);
+   call_fib_rule_notifiers(net, FIB_EVENT_RULE_DEL, rule, ops,
+   NULL);
notify_rule_change(RTM_DELRULE, rule, ops, nlh,
   NETLINK_CB(skb).portid);
fib_rule_put(rule);
diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c
index aaa1ba09afaa..5ddc4aefff12 100644
--- a/net/ipv4/fib_trie.c
+++ b/net/ipv4/fib_trie.c
@@ -102,9 +102,11 @@ static int call_fib_entry_notifier(struct notifier_block 
*nb, struct net *net,
 
 static int call_fib_entry_notifiers(struct net *net,
enum fib_event_type event_type, u32 dst,
-   int dst_len, struct fib_alias *fa)
+   int dst_len, struct fib_alias *fa,
+   struct netlink_ext_ack *extack)
 {
struct fib_entry_notifier_info info = {
+   .info.extack = extack,
.dst = dst,
.dst_len = dst_len,
.fi = fa->fa_info,
@@ -1214,7 +1216,7 @@ int fib_table_insert(struct net *net, struct fib_table 
*tb,
new_fa->fa_default = -1;
 
call_fib_entry_notifiers(net, FIB_EVENT_ENTRY_REPLACE,
-key, plen, new_fa);
+key, plen, new_fa, extack);
rtmsg_fib(RTM_NEWROUTE, htonl(key), new_fa, plen,
  tb->tb_id, >fc_nlinfo, nlflags);
 
@@ -1269,7 +1271,7 @@ int fib_table_insert(struct net *net, struct fib_table 
*tb,
tb->tb_num_default++;
 
rt_cache_flush(cfg->fc_nlinfo.nl_net);
-   call_fib_entry_notifiers(net, event, key, plen, new_fa);
+   call_fib_entry_notifiers(net, event, key, plen, new_fa, extack);
rtmsg_fib(RTM_NEWROUTE, htonl(key), new_fa, plen, new_fa->tb_id,
  >fc_nlinfo, nlflags);
 succeeded:
@@ -1569,7 +1571,7 @@ int fib_table_delete(struct net *net, struct fib_table 
*tb,
return -ESRCH;
 
call_fib_entry_notifiers(net, FIB_EVENT_ENTRY_DEL, key, plen,
-fa_to_delete);
+fa_to_delete, extack);
rtmsg_fib(RTM_DELROUTE, htonl(key), fa_to_delete, plen, tb->tb_id,
  >fc_nlinfo, 0);
 
@@ -1886,7 +1888,8 @@ int fib_table_flush(struct net *net, struct fib_table *tb)
 
call_fib_entry_notifiers(net, FIB_EVENT_ENTRY_DEL,
 n->key,
-KEYLENGTH - fa->fa_slen, fa);
+