]> git.karo-electronics.de Git - mv-sheeva.git/blobdiff - net/core/fib_rules.c
[PATCH] reduce MAX_NR_ZONES: remove two strange uses of MAX_NR_ZONES
[mv-sheeva.git] / net / core / fib_rules.c
index 873b04d5df81282673c5173e71d5cb32e34bf652..a99d87d82b7f1cd63a8667649650857f960db678 100644 (file)
@@ -18,7 +18,8 @@ static LIST_HEAD(rules_ops);
 static DEFINE_SPINLOCK(rules_mod_lock);
 
 static void notify_rule_change(int event, struct fib_rule *rule,
-                              struct fib_rules_ops *ops);
+                              struct fib_rules_ops *ops, struct nlmsghdr *nlh,
+                              u32 pid);
 
 static struct fib_rules_ops *lookup_rules_ops(int family)
 {
@@ -160,9 +161,6 @@ int fib_nl_newrule(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg)
        if (err < 0)
                goto errout;
 
-       if (tb[FRA_IFNAME] && nla_len(tb[FRA_IFNAME]) > IFNAMSIZ)
-               goto errout;
-
        rule = kzalloc(ops->rule_size, GFP_KERNEL);
        if (rule == NULL) {
                err = -ENOMEM;
@@ -176,10 +174,7 @@ int fib_nl_newrule(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg)
                struct net_device *dev;
 
                rule->ifindex = -1;
-               if (nla_strlcpy(rule->ifname, tb[FRA_IFNAME],
-                               IFNAMSIZ) >= IFNAMSIZ)
-                       goto errout_free;
-
+               nla_strlcpy(rule->ifname, tb[FRA_IFNAME], IFNAMSIZ);
                dev = __dev_get_by_name(rule->ifname);
                if (dev)
                        rule->ifindex = dev->ifindex;
@@ -209,7 +204,7 @@ 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(RTM_NEWRULE, rule, ops);
+       notify_rule_change(RTM_NEWRULE, rule, ops, nlh, NETLINK_CB(skb).pid);
        rules_ops_put(ops);
        return 0;
 
@@ -266,7 +261,8 @@ int fib_nl_delrule(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg)
 
                list_del_rcu(&rule->list);
                synchronize_rcu();
-               notify_rule_change(RTM_DELRULE, rule, ops);
+               notify_rule_change(RTM_DELRULE, rule, ops, nlh,
+                                  NETLINK_CB(skb).pid);
                fib_rule_put(rule);
                rules_ops_put(ops);
                return 0;
@@ -344,18 +340,26 @@ skip:
 EXPORT_SYMBOL_GPL(fib_rules_dump);
 
 static void notify_rule_change(int event, struct fib_rule *rule,
-                              struct fib_rules_ops *ops)
+                              struct fib_rules_ops *ops, struct nlmsghdr *nlh,
+                              u32 pid)
 {
-       int size = nlmsg_total_size(sizeof(struct fib_rule_hdr) + 128);
-       struct sk_buff *skb = alloc_skb(size, GFP_KERNEL);
+       struct sk_buff *skb;
+       int err = -ENOBUFS;
 
+       skb = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL);
        if (skb == NULL)
-               netlink_set_err(rtnl, 0, ops->nlgroup, ENOBUFS);
-       else if (fib_nl_fill_rule(skb, rule, 0, 0, event, 0, ops) < 0) {
+               goto errout;
+
+       err = fib_nl_fill_rule(skb, rule, pid, nlh->nlmsg_seq, event, 0, ops);
+       if (err < 0) {
                kfree_skb(skb);
-               netlink_set_err(rtnl, 0, ops->nlgroup, EINVAL);
-       } else
-               netlink_broadcast(rtnl, skb, 0, ops->nlgroup, GFP_KERNEL);
+               goto errout;
+       }
+
+       err = rtnl_notify(skb, pid, ops->nlgroup, nlh, GFP_KERNEL);
+errout:
+       if (err < 0)
+               rtnl_set_sk_err(ops->nlgroup, err);
 }
 
 static void attach_rules(struct list_head *rules, struct net_device *dev)