Skip to content

Commit 9eb87f3

Browse files
Daniel Lezcanodavem330
authored andcommitted
[IPV6]: Make fib6_rules_init to return an error code.
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 <[email protected]> Acked-by: Benjamin Thery <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 0013cab commit 9eb87f3

File tree

4 files changed

+21
-6
lines changed

4 files changed

+21
-6
lines changed

include/net/fib_rules.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ static inline u32 frh_get_table(struct fib_rule_hdr *frh, struct nlattr **nla)
103103

104104
extern int fib_rules_register(struct fib_rules_ops *);
105105
extern int fib_rules_unregister(struct fib_rules_ops *);
106+
extern void fib_rules_cleanup_ops(struct fib_rules_ops *);
106107

107108
extern int fib_rules_lookup(struct fib_rules_ops *,
108109
struct flowi *, int flags,

include/net/ip6_fib.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ extern void fib6_gc_cleanup(void);
226226

227227
extern int fib6_init(void);
228228

229-
extern void fib6_rules_init(void);
229+
extern int fib6_rules_init(void);
230230
extern void fib6_rules_cleanup(void);
231231

232232
#endif

net/core/fib_rules.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ int fib_rules_register(struct fib_rules_ops *ops)
102102

103103
EXPORT_SYMBOL_GPL(fib_rules_register);
104104

105-
static void cleanup_ops(struct fib_rules_ops *ops)
105+
void fib_rules_cleanup_ops(struct fib_rules_ops *ops)
106106
{
107107
struct fib_rule *rule, *tmp;
108108

@@ -111,6 +111,7 @@ static void cleanup_ops(struct fib_rules_ops *ops)
111111
fib_rule_put(rule);
112112
}
113113
}
114+
EXPORT_SYMBOL_GPL(fib_rules_cleanup_ops);
114115

115116
int fib_rules_unregister(struct fib_rules_ops *ops)
116117
{
@@ -121,7 +122,7 @@ int fib_rules_unregister(struct fib_rules_ops *ops)
121122
list_for_each_entry(o, &rules_ops, list) {
122123
if (o == ops) {
123124
list_del_rcu(&o->list);
124-
cleanup_ops(ops);
125+
fib_rules_cleanup_ops(ops);
125126
goto out;
126127
}
127128
}

net/ipv6/fib6_rules.c

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -265,10 +265,23 @@ static int __init fib6_default_rules_init(void)
265265
return 0;
266266
}
267267

268-
void __init fib6_rules_init(void)
268+
int __init fib6_rules_init(void)
269269
{
270-
BUG_ON(fib6_default_rules_init());
271-
fib_rules_register(&fib6_rules_ops);
270+
int ret;
271+
272+
ret = fib6_default_rules_init();
273+
if (ret)
274+
goto out;
275+
276+
ret = fib_rules_register(&fib6_rules_ops);
277+
if (ret)
278+
goto out_default_rules_init;
279+
out:
280+
return ret;
281+
282+
out_default_rules_init:
283+
fib_rules_cleanup_ops(&fib6_rules_ops);
284+
goto out;
272285
}
273286

274287
void fib6_rules_cleanup(void)

0 commit comments

Comments
 (0)