aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/net/fib_rules.h4
-rw-r--r--net/core/fib_rules.c20
-rw-r--r--net/decnet/dn_rules.c4
-rw-r--r--net/ipv4/fib_rules.c6
-rw-r--r--net/ipv6/fib6_rules.c4
5 files changed, 22 insertions, 16 deletions
diff --git a/include/net/fib_rules.h b/include/net/fib_rules.h
index 6910e0195ca5..7f9f4aec8fc8 100644
--- a/include/net/fib_rules.h
+++ b/include/net/fib_rules.h
@@ -102,8 +102,8 @@ static inline u32 frh_get_table(struct fib_rule_hdr *frh, struct nlattr **nla)
102 return frh->table; 102 return frh->table;
103} 103}
104 104
105extern int fib_rules_register(struct net *, struct fib_rules_ops *); 105extern int fib_rules_register(struct fib_rules_ops *);
106extern void fib_rules_unregister(struct net *, struct fib_rules_ops *); 106extern void fib_rules_unregister(struct fib_rules_ops *);
107extern void fib_rules_cleanup_ops(struct fib_rules_ops *); 107extern void fib_rules_cleanup_ops(struct fib_rules_ops *);
108 108
109extern int fib_rules_lookup(struct fib_rules_ops *, 109extern int fib_rules_lookup(struct fib_rules_ops *,
diff --git a/net/core/fib_rules.c b/net/core/fib_rules.c
index 541728aa2bae..3cd4f13413f6 100644
--- a/net/core/fib_rules.c
+++ b/net/core/fib_rules.c
@@ -37,8 +37,7 @@ int fib_default_rule_add(struct fib_rules_ops *ops,
37} 37}
38EXPORT_SYMBOL(fib_default_rule_add); 38EXPORT_SYMBOL(fib_default_rule_add);
39 39
40static void notify_rule_change(struct net *net, int event, 40static void notify_rule_change(int event, struct fib_rule *rule,
41 struct fib_rule *rule,
42 struct fib_rules_ops *ops, struct nlmsghdr *nlh, 41 struct fib_rules_ops *ops, struct nlmsghdr *nlh,
43 u32 pid); 42 u32 pid);
44 43
@@ -72,10 +71,13 @@ static void flush_route_cache(struct fib_rules_ops *ops)
72 ops->flush_cache(); 71 ops->flush_cache();
73} 72}
74 73
75int fib_rules_register(struct net *net, struct fib_rules_ops *ops) 74int fib_rules_register(struct fib_rules_ops *ops)
76{ 75{
77 int err = -EEXIST; 76 int err = -EEXIST;
78 struct fib_rules_ops *o; 77 struct fib_rules_ops *o;
78 struct net *net;
79
80 net = ops->fro_net;
79 81
80 if (ops->rule_size < sizeof(struct fib_rule)) 82 if (ops->rule_size < sizeof(struct fib_rule))
81 return -EINVAL; 83 return -EINVAL;
@@ -112,8 +114,9 @@ void fib_rules_cleanup_ops(struct fib_rules_ops *ops)
112} 114}
113EXPORT_SYMBOL_GPL(fib_rules_cleanup_ops); 115EXPORT_SYMBOL_GPL(fib_rules_cleanup_ops);
114 116
115void fib_rules_unregister(struct net *net, struct fib_rules_ops *ops) 117void fib_rules_unregister(struct fib_rules_ops *ops)
116{ 118{
119 struct net *net = ops->fro_net;
117 120
118 spin_lock(&net->rules_mod_lock); 121 spin_lock(&net->rules_mod_lock);
119 list_del_rcu(&ops->list); 122 list_del_rcu(&ops->list);
@@ -333,7 +336,7 @@ static int fib_nl_newrule(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg)
333 else 336 else
334 list_add_rcu(&rule->list, &ops->rules_list); 337 list_add_rcu(&rule->list, &ops->rules_list);
335 338
336 notify_rule_change(net, RTM_NEWRULE, rule, ops, nlh, NETLINK_CB(skb).pid); 339 notify_rule_change(RTM_NEWRULE, rule, ops, nlh, NETLINK_CB(skb).pid);
337 flush_route_cache(ops); 340 flush_route_cache(ops);
338 rules_ops_put(ops); 341 rules_ops_put(ops);
339 return 0; 342 return 0;
@@ -423,7 +426,7 @@ static int fib_nl_delrule(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg)
423 } 426 }
424 427
425 synchronize_rcu(); 428 synchronize_rcu();
426 notify_rule_change(net, RTM_DELRULE, rule, ops, nlh, 429 notify_rule_change(RTM_DELRULE, rule, ops, nlh,
427 NETLINK_CB(skb).pid); 430 NETLINK_CB(skb).pid);
428 fib_rule_put(rule); 431 fib_rule_put(rule);
429 flush_route_cache(ops); 432 flush_route_cache(ops);
@@ -561,13 +564,15 @@ static int fib_nl_dumprule(struct sk_buff *skb, struct netlink_callback *cb)
561 return skb->len; 564 return skb->len;
562} 565}
563 566
564static void notify_rule_change(struct net *net, int event, struct fib_rule *rule, 567static void notify_rule_change(int event, struct fib_rule *rule,
565 struct fib_rules_ops *ops, struct nlmsghdr *nlh, 568 struct fib_rules_ops *ops, struct nlmsghdr *nlh,
566 u32 pid) 569 u32 pid)
567{ 570{
571 struct net *net;
568 struct sk_buff *skb; 572 struct sk_buff *skb;
569 int err = -ENOBUFS; 573 int err = -ENOBUFS;
570 574
575 net = ops->fro_net;
571 skb = nlmsg_new(fib_rule_nlmsg_size(ops, rule), GFP_KERNEL); 576 skb = nlmsg_new(fib_rule_nlmsg_size(ops, rule), GFP_KERNEL);
572 if (skb == NULL) 577 if (skb == NULL)
573 goto errout; 578 goto errout;
@@ -579,6 +584,7 @@ static void notify_rule_change(struct net *net, int event, struct fib_rule *rule
579 kfree_skb(skb); 584 kfree_skb(skb);
580 goto errout; 585 goto errout;
581 } 586 }
587
582 err = rtnl_notify(skb, net, pid, ops->nlgroup, nlh, GFP_KERNEL); 588 err = rtnl_notify(skb, net, pid, ops->nlgroup, nlh, GFP_KERNEL);
583errout: 589errout:
584 if (err < 0) 590 if (err < 0)
diff --git a/net/decnet/dn_rules.c b/net/decnet/dn_rules.c
index 964e65887603..5b7539b7fe0c 100644
--- a/net/decnet/dn_rules.c
+++ b/net/decnet/dn_rules.c
@@ -256,12 +256,12 @@ void __init dn_fib_rules_init(void)
256{ 256{
257 BUG_ON(fib_default_rule_add(&dn_fib_rules_ops, 0x7fff, 257 BUG_ON(fib_default_rule_add(&dn_fib_rules_ops, 0x7fff,
258 RT_TABLE_MAIN, 0)); 258 RT_TABLE_MAIN, 0));
259 fib_rules_register(&init_net, &dn_fib_rules_ops); 259 fib_rules_register(&dn_fib_rules_ops);
260} 260}
261 261
262void __exit dn_fib_rules_cleanup(void) 262void __exit dn_fib_rules_cleanup(void)
263{ 263{
264 fib_rules_unregister(&init_net, &dn_fib_rules_ops); 264 fib_rules_unregister(&dn_fib_rules_ops);
265} 265}
266 266
267 267
diff --git a/net/ipv4/fib_rules.c b/net/ipv4/fib_rules.c
index 8d0ebe7f360d..3b7affd5cb3b 100644
--- a/net/ipv4/fib_rules.c
+++ b/net/ipv4/fib_rules.c
@@ -317,7 +317,7 @@ int __net_init fib4_rules_init(struct net *net)
317 INIT_LIST_HEAD(&ops->rules_list); 317 INIT_LIST_HEAD(&ops->rules_list);
318 ops->fro_net = net; 318 ops->fro_net = net;
319 319
320 fib_rules_register(net, ops); 320 fib_rules_register(ops);
321 321
322 err = fib_default_rules_init(ops); 322 err = fib_default_rules_init(ops);
323 if (err < 0) 323 if (err < 0)
@@ -327,13 +327,13 @@ int __net_init fib4_rules_init(struct net *net)
327 327
328fail: 328fail:
329 /* also cleans all rules already added */ 329 /* also cleans all rules already added */
330 fib_rules_unregister(net, ops); 330 fib_rules_unregister(ops);
331 kfree(ops); 331 kfree(ops);
332 return err; 332 return err;
333} 333}
334 334
335void __net_exit fib4_rules_exit(struct net *net) 335void __net_exit fib4_rules_exit(struct net *net)
336{ 336{
337 fib_rules_unregister(net, net->ipv4.rules_ops); 337 fib_rules_unregister(net->ipv4.rules_ops);
338 kfree(net->ipv4.rules_ops); 338 kfree(net->ipv4.rules_ops);
339} 339}
diff --git a/net/ipv6/fib6_rules.c b/net/ipv6/fib6_rules.c
index ead5ab2da9a2..695c0ca8a417 100644
--- a/net/ipv6/fib6_rules.c
+++ b/net/ipv6/fib6_rules.c
@@ -274,7 +274,7 @@ int __init fib6_rules_init(void)
274 if (ret) 274 if (ret)
275 goto out; 275 goto out;
276 276
277 ret = fib_rules_register(&init_net, &fib6_rules_ops); 277 ret = fib_rules_register(&fib6_rules_ops);
278 if (ret) 278 if (ret)
279 goto out_default_rules_init; 279 goto out_default_rules_init;
280out: 280out:
@@ -287,5 +287,5 @@ out_default_rules_init:
287 287
288void fib6_rules_cleanup(void) 288void fib6_rules_cleanup(void)
289{ 289{
290 fib_rules_unregister(&init_net, &fib6_rules_ops); 290 fib_rules_unregister(&fib6_rules_ops);
291} 291}