[IPV6]: Make fib6_rules_init to return an error code.
authorDaniel Lezcano <dlezcano@fr.ibm.com>
Fri, 7 Dec 2007 08:42:52 +0000 (00:42 -0800)
committerDavid S. Miller <davem@davemloft.net>
Mon, 28 Jan 2008 22:56:46 +0000 (14:56 -0800)
When the fib_rules initialization finished, no return code is provided
so there is no way to know, for the caller, if the initialization has
been successful or has failed. This patch fix that.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
Acked-by: Benjamin Thery <benjamin.thery@bull.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/fib_rules.h
include/net/ip6_fib.h
net/core/fib_rules.c
net/ipv6/fib6_rules.c

index 41a301e386433006e659ae14409e1373f905d36b..2364db1a47e62e7c21f2b973db0999c9e6c7b852 100644 (file)
@@ -103,6 +103,7 @@ static inline u32 frh_get_table(struct fib_rule_hdr *frh, struct nlattr **nla)
 
 extern int                     fib_rules_register(struct fib_rules_ops *);
 extern int                     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 *,
                                                 struct flowi *, int flags,
index 5d39ce92afcf3699f9ca28e5c91e19050d165fc9..eaa315868792681eed7a99c94fa92e599c92b957 100644 (file)
@@ -226,7 +226,7 @@ extern void                 fib6_gc_cleanup(void);
 
 extern int                     fib6_init(void);
 
-extern void                    fib6_rules_init(void);
+extern int                     fib6_rules_init(void);
 extern void                    fib6_rules_cleanup(void);
 
 #endif
index 0af0538343da2bf878c8cb958ed55200d03413ca..fcbf41c0a5d490b0096fbaba083427a802d96bfa 100644 (file)
@@ -102,7 +102,7 @@ errout:
 
 EXPORT_SYMBOL_GPL(fib_rules_register);
 
-static void cleanup_ops(struct fib_rules_ops *ops)
+void fib_rules_cleanup_ops(struct fib_rules_ops *ops)
 {
        struct fib_rule *rule, *tmp;
 
@@ -111,6 +111,7 @@ static void cleanup_ops(struct fib_rules_ops *ops)
                fib_rule_put(rule);
        }
 }
+EXPORT_SYMBOL_GPL(fib_rules_cleanup_ops);
 
 int fib_rules_unregister(struct fib_rules_ops *ops)
 {
@@ -121,7 +122,7 @@ int fib_rules_unregister(struct fib_rules_ops *ops)
        list_for_each_entry(o, &rules_ops, list) {
                if (o == ops) {
                        list_del_rcu(&o->list);
-                       cleanup_ops(ops);
+                       fib_rules_cleanup_ops(ops);
                        goto out;
                }
        }
index 428c6b0e26d8e7238530e6b3d1c886f5c398af98..9ce2e0a6748a75a0a1947faa622b9d2f8853cf36 100644 (file)
@@ -265,10 +265,23 @@ static int __init fib6_default_rules_init(void)
        return 0;
 }
 
-void __init fib6_rules_init(void)
+int __init fib6_rules_init(void)
 {
-       BUG_ON(fib6_default_rules_init());
-       fib_rules_register(&fib6_rules_ops);
+       int ret;
+
+       ret = fib6_default_rules_init();
+       if (ret)
+               goto out;
+
+       ret = fib_rules_register(&fib6_rules_ops);
+       if (ret)
+               goto out_default_rules_init;
+out:
+       return ret;
+
+out_default_rules_init:
+       fib_rules_cleanup_ops(&fib6_rules_ops);
+       goto out;
 }
 
 void fib6_rules_cleanup(void)