Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 79284
b: refs/heads/master
c: 9e3a548
h: refs/heads/master
v: v3
  • Loading branch information
Denis V. Lunev authored and David S. Miller committed Jan 28, 2008
1 parent bb17ad7 commit a023c07
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 17 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 035923833369e4da5d3c4ad0700bc7c367a0fa37
refs/heads/master: 9e3a548781fc1c0da617fc65769a515f074be740
4 changes: 2 additions & 2 deletions trunk/include/net/fib_rules.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ static inline u32 frh_get_table(struct fib_rule_hdr *frh, struct nlattr **nla)
return frh->table;
}

extern int fib_rules_register(struct net *, struct fib_rules_ops *);
extern void fib_rules_unregister(struct net *, struct fib_rules_ops *);
extern int fib_rules_register(struct fib_rules_ops *);
extern void fib_rules_unregister(struct fib_rules_ops *);
extern void fib_rules_cleanup_ops(struct fib_rules_ops *);

extern int fib_rules_lookup(struct fib_rules_ops *,
Expand Down
20 changes: 13 additions & 7 deletions trunk/net/core/fib_rules.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ int fib_default_rule_add(struct fib_rules_ops *ops,
}
EXPORT_SYMBOL(fib_default_rule_add);

static void notify_rule_change(struct net *net, int event,
struct fib_rule *rule,
static void notify_rule_change(int event, struct fib_rule *rule,
struct fib_rules_ops *ops, struct nlmsghdr *nlh,
u32 pid);

Expand Down Expand Up @@ -72,10 +71,13 @@ static void flush_route_cache(struct fib_rules_ops *ops)
ops->flush_cache();
}

int fib_rules_register(struct net *net, struct fib_rules_ops *ops)
int fib_rules_register(struct fib_rules_ops *ops)
{
int err = -EEXIST;
struct fib_rules_ops *o;
struct net *net;

net = ops->fro_net;

if (ops->rule_size < sizeof(struct fib_rule))
return -EINVAL;
Expand Down Expand Up @@ -112,8 +114,9 @@ void fib_rules_cleanup_ops(struct fib_rules_ops *ops)
}
EXPORT_SYMBOL_GPL(fib_rules_cleanup_ops);

void fib_rules_unregister(struct net *net, struct fib_rules_ops *ops)
void fib_rules_unregister(struct fib_rules_ops *ops)
{
struct net *net = ops->fro_net;

spin_lock(&net->rules_mod_lock);
list_del_rcu(&ops->list);
Expand Down Expand Up @@ -333,7 +336,7 @@ static int fib_nl_newrule(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg)
else
list_add_rcu(&rule->list, &ops->rules_list);

notify_rule_change(net, RTM_NEWRULE, rule, ops, nlh, NETLINK_CB(skb).pid);
notify_rule_change(RTM_NEWRULE, rule, ops, nlh, NETLINK_CB(skb).pid);
flush_route_cache(ops);
rules_ops_put(ops);
return 0;
Expand Down Expand Up @@ -423,7 +426,7 @@ static int fib_nl_delrule(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg)
}

synchronize_rcu();
notify_rule_change(net, RTM_DELRULE, rule, ops, nlh,
notify_rule_change(RTM_DELRULE, rule, ops, nlh,
NETLINK_CB(skb).pid);
fib_rule_put(rule);
flush_route_cache(ops);
Expand Down Expand Up @@ -561,13 +564,15 @@ static int fib_nl_dumprule(struct sk_buff *skb, struct netlink_callback *cb)
return skb->len;
}

static void notify_rule_change(struct net *net, int event, struct fib_rule *rule,
static void notify_rule_change(int event, struct fib_rule *rule,
struct fib_rules_ops *ops, struct nlmsghdr *nlh,
u32 pid)
{
struct net *net;
struct sk_buff *skb;
int err = -ENOBUFS;

net = ops->fro_net;
skb = nlmsg_new(fib_rule_nlmsg_size(ops, rule), GFP_KERNEL);
if (skb == NULL)
goto errout;
Expand All @@ -579,6 +584,7 @@ static void notify_rule_change(struct net *net, int event, struct fib_rule *rule
kfree_skb(skb);
goto errout;
}

err = rtnl_notify(skb, net, pid, ops->nlgroup, nlh, GFP_KERNEL);
errout:
if (err < 0)
Expand Down
4 changes: 2 additions & 2 deletions trunk/net/decnet/dn_rules.c
Original file line number Diff line number Diff line change
Expand Up @@ -256,12 +256,12 @@ void __init dn_fib_rules_init(void)
{
BUG_ON(fib_default_rule_add(&dn_fib_rules_ops, 0x7fff,
RT_TABLE_MAIN, 0));
fib_rules_register(&init_net, &dn_fib_rules_ops);
fib_rules_register(&dn_fib_rules_ops);
}

void __exit dn_fib_rules_cleanup(void)
{
fib_rules_unregister(&init_net, &dn_fib_rules_ops);
fib_rules_unregister(&dn_fib_rules_ops);
}


6 changes: 3 additions & 3 deletions trunk/net/ipv4/fib_rules.c
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ int __net_init fib4_rules_init(struct net *net)
INIT_LIST_HEAD(&ops->rules_list);
ops->fro_net = net;

fib_rules_register(net, ops);
fib_rules_register(ops);

err = fib_default_rules_init(ops);
if (err < 0)
Expand All @@ -327,13 +327,13 @@ int __net_init fib4_rules_init(struct net *net)

fail:
/* also cleans all rules already added */
fib_rules_unregister(net, ops);
fib_rules_unregister(ops);
kfree(ops);
return err;
}

void __net_exit fib4_rules_exit(struct net *net)
{
fib_rules_unregister(net, net->ipv4.rules_ops);
fib_rules_unregister(net->ipv4.rules_ops);
kfree(net->ipv4.rules_ops);
}
4 changes: 2 additions & 2 deletions trunk/net/ipv6/fib6_rules.c
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ int __init fib6_rules_init(void)
if (ret)
goto out;

ret = fib_rules_register(&init_net, &fib6_rules_ops);
ret = fib_rules_register(&fib6_rules_ops);
if (ret)
goto out_default_rules_init;
out:
Expand All @@ -287,5 +287,5 @@ int __init fib6_rules_init(void)

void fib6_rules_cleanup(void)
{
fib_rules_unregister(&init_net, &fib6_rules_ops);
fib_rules_unregister(&fib6_rules_ops);
}

0 comments on commit a023c07

Please sign in to comment.