xfs: remove nr_to_write writeback windup.
[safe/jmp/linux-2.6] / net / ipv4 / fib_rules.c
index 38904be..76daeb5 100644 (file)
@@ -94,7 +94,7 @@ static int fib4_rule_action(struct fib_rule *rule, struct flowi *flp,
        if ((tbl = fib_get_table(rule->fr_net, rule->table)) == NULL)
                goto errout;
 
-       err = tbl->tb_lookup(tbl, flp, (struct fib_result *) arg->result);
+       err = fib_table_lookup(tbl, flp, (struct fib_result *) arg->result);
        if (err > 0)
                err = -EAGAIN;
 errout:
@@ -209,11 +209,10 @@ static int fib4_rule_compare(struct fib_rule *rule, struct fib_rule_hdr *frh,
 }
 
 static int fib4_rule_fill(struct fib_rule *rule, struct sk_buff *skb,
-                         struct nlmsghdr *nlh, struct fib_rule_hdr *frh)
+                         struct fib_rule_hdr *frh)
 {
        struct fib4_rule *rule4 = (struct fib4_rule *) rule;
 
-       frh->family = AF_INET;
        frh->dst_len = rule4->dst_len;
        frh->src_len = rule4->src_len;
        frh->tos = rule4->tos;
@@ -234,23 +233,6 @@ nla_put_failure:
        return -ENOBUFS;
 }
 
-static u32 fib4_rule_default_pref(struct fib_rules_ops *ops)
-{
-       struct list_head *pos;
-       struct fib_rule *rule;
-
-       if (!list_empty(&ops->rules_list)) {
-               pos = ops->rules_list.next;
-               if (pos->next != &ops->rules_list) {
-                       rule = list_entry(pos->next, struct fib_rule, list);
-                       if (rule->pref)
-                               return rule->pref - 1;
-               }
-       }
-
-       return 0;
-}
-
 static size_t fib4_rule_nlmsg_payload(struct fib_rule *rule)
 {
        return nla_total_size(4) /* dst */
@@ -263,7 +245,7 @@ static void fib4_rule_flush_cache(struct fib_rules_ops *ops)
        rt_cache_flush(ops->fro_net, -1);
 }
 
-static struct fib_rules_ops fib4_rules_ops_template = {
+static const struct fib_rules_ops __net_initdata fib4_rules_ops_template = {
        .family         = AF_INET,
        .rule_size      = sizeof(struct fib4_rule),
        .addr_size      = sizeof(u32),
@@ -272,7 +254,7 @@ static struct fib_rules_ops fib4_rules_ops_template = {
        .configure      = fib4_rule_configure,
        .compare        = fib4_rule_compare,
        .fill           = fib4_rule_fill,
-       .default_pref   = fib4_rule_default_pref,
+       .default_pref   = fib_default_rule_pref,
        .nlmsg_payload  = fib4_rule_nlmsg_payload,
        .flush_cache    = fib4_rule_flush_cache,
        .nlgroup        = RTNLGRP_IPV4_RULE,
@@ -284,7 +266,7 @@ static int fib_default_rules_init(struct fib_rules_ops *ops)
 {
        int err;
 
-       err = fib_default_rule_add(ops, 0, RT_TABLE_LOCAL, FIB_RULE_PERMANENT);
+       err = fib_default_rule_add(ops, 0, RT_TABLE_LOCAL, 0);
        if (err < 0)
                return err;
        err = fib_default_rule_add(ops, 0x7FFE, RT_TABLE_MAIN, 0);
@@ -301,13 +283,9 @@ int __net_init fib4_rules_init(struct net *net)
        int err;
        struct fib_rules_ops *ops;
 
-       ops = kmemdup(&fib4_rules_ops_template, sizeof(*ops), GFP_KERNEL);
-       if (ops == NULL)
-               return -ENOMEM;
-       INIT_LIST_HEAD(&ops->rules_list);
-       ops->fro_net = net;
-
-       fib_rules_register(ops);
+       ops = fib_rules_register(&fib4_rules_ops_template, net);
+       if (IS_ERR(ops))
+               return PTR_ERR(ops);
 
        err = fib_default_rules_init(ops);
        if (err < 0)
@@ -318,12 +296,10 @@ int __net_init fib4_rules_init(struct net *net)
 fail:
        /* also cleans all rules already added */
        fib_rules_unregister(ops);
-       kfree(ops);
        return err;
 }
 
 void __net_exit fib4_rules_exit(struct net *net)
 {
        fib_rules_unregister(net->ipv4.rules_ops);
-       kfree(net->ipv4.rules_ops);
 }