Linux 4.1.16
[linux/fpc-iii.git] / net / core / fib_rules.c
blob0ad144fb0c792e1999440eb6752aaec2adf4926a
1 /*
2 * net/core/fib_rules.c Generic Routing Rules
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation, version 2.
8 * Authors: Thomas Graf <tgraf@suug.ch>
9 */
11 #include <linux/types.h>
12 #include <linux/kernel.h>
13 #include <linux/slab.h>
14 #include <linux/list.h>
15 #include <linux/module.h>
16 #include <net/net_namespace.h>
17 #include <net/sock.h>
18 #include <net/fib_rules.h>
20 int fib_default_rule_add(struct fib_rules_ops *ops,
21 u32 pref, u32 table, u32 flags)
23 struct fib_rule *r;
25 r = kzalloc(ops->rule_size, GFP_KERNEL);
26 if (r == NULL)
27 return -ENOMEM;
29 atomic_set(&r->refcnt, 1);
30 r->action = FR_ACT_TO_TBL;
31 r->pref = pref;
32 r->table = table;
33 r->flags = flags;
34 r->fr_net = ops->fro_net;
36 r->suppress_prefixlen = -1;
37 r->suppress_ifgroup = -1;
39 /* The lock is not required here, the list in unreacheable
40 * at the moment this function is called */
41 list_add_tail(&r->list, &ops->rules_list);
42 return 0;
44 EXPORT_SYMBOL(fib_default_rule_add);
46 u32 fib_default_rule_pref(struct fib_rules_ops *ops)
48 struct list_head *pos;
49 struct fib_rule *rule;
51 if (!list_empty(&ops->rules_list)) {
52 pos = ops->rules_list.next;
53 if (pos->next != &ops->rules_list) {
54 rule = list_entry(pos->next, struct fib_rule, list);
55 if (rule->pref)
56 return rule->pref - 1;
60 return 0;
62 EXPORT_SYMBOL(fib_default_rule_pref);
64 static void notify_rule_change(int event, struct fib_rule *rule,
65 struct fib_rules_ops *ops, struct nlmsghdr *nlh,
66 u32 pid);
68 static struct fib_rules_ops *lookup_rules_ops(struct net *net, int family)
70 struct fib_rules_ops *ops;
72 rcu_read_lock();
73 list_for_each_entry_rcu(ops, &net->rules_ops, list) {
74 if (ops->family == family) {
75 if (!try_module_get(ops->owner))
76 ops = NULL;
77 rcu_read_unlock();
78 return ops;
81 rcu_read_unlock();
83 return NULL;
86 static void rules_ops_put(struct fib_rules_ops *ops)
88 if (ops)
89 module_put(ops->owner);
92 static void flush_route_cache(struct fib_rules_ops *ops)
94 if (ops->flush_cache)
95 ops->flush_cache(ops);
98 static int __fib_rules_register(struct fib_rules_ops *ops)
100 int err = -EEXIST;
101 struct fib_rules_ops *o;
102 struct net *net;
104 net = ops->fro_net;
106 if (ops->rule_size < sizeof(struct fib_rule))
107 return -EINVAL;
109 if (ops->match == NULL || ops->configure == NULL ||
110 ops->compare == NULL || ops->fill == NULL ||
111 ops->action == NULL)
112 return -EINVAL;
114 spin_lock(&net->rules_mod_lock);
115 list_for_each_entry(o, &net->rules_ops, list)
116 if (ops->family == o->family)
117 goto errout;
119 list_add_tail_rcu(&ops->list, &net->rules_ops);
120 err = 0;
121 errout:
122 spin_unlock(&net->rules_mod_lock);
124 return err;
127 struct fib_rules_ops *
128 fib_rules_register(const struct fib_rules_ops *tmpl, struct net *net)
130 struct fib_rules_ops *ops;
131 int err;
133 ops = kmemdup(tmpl, sizeof(*ops), GFP_KERNEL);
134 if (ops == NULL)
135 return ERR_PTR(-ENOMEM);
137 INIT_LIST_HEAD(&ops->rules_list);
138 ops->fro_net = net;
140 err = __fib_rules_register(ops);
141 if (err) {
142 kfree(ops);
143 ops = ERR_PTR(err);
146 return ops;
148 EXPORT_SYMBOL_GPL(fib_rules_register);
150 static void fib_rules_cleanup_ops(struct fib_rules_ops *ops)
152 struct fib_rule *rule, *tmp;
154 list_for_each_entry_safe(rule, tmp, &ops->rules_list, list) {
155 list_del_rcu(&rule->list);
156 if (ops->delete)
157 ops->delete(rule);
158 fib_rule_put(rule);
162 void fib_rules_unregister(struct fib_rules_ops *ops)
164 struct net *net = ops->fro_net;
166 spin_lock(&net->rules_mod_lock);
167 list_del_rcu(&ops->list);
168 spin_unlock(&net->rules_mod_lock);
170 fib_rules_cleanup_ops(ops);
171 kfree_rcu(ops, rcu);
173 EXPORT_SYMBOL_GPL(fib_rules_unregister);
175 static int fib_rule_match(struct fib_rule *rule, struct fib_rules_ops *ops,
176 struct flowi *fl, int flags)
178 int ret = 0;
180 if (rule->iifindex && (rule->iifindex != fl->flowi_iif))
181 goto out;
183 if (rule->oifindex && (rule->oifindex != fl->flowi_oif))
184 goto out;
186 if ((rule->mark ^ fl->flowi_mark) & rule->mark_mask)
187 goto out;
189 ret = ops->match(rule, fl, flags);
190 out:
191 return (rule->flags & FIB_RULE_INVERT) ? !ret : ret;
194 int fib_rules_lookup(struct fib_rules_ops *ops, struct flowi *fl,
195 int flags, struct fib_lookup_arg *arg)
197 struct fib_rule *rule;
198 int err;
200 rcu_read_lock();
202 list_for_each_entry_rcu(rule, &ops->rules_list, list) {
203 jumped:
204 if (!fib_rule_match(rule, ops, fl, flags))
205 continue;
207 if (rule->action == FR_ACT_GOTO) {
208 struct fib_rule *target;
210 target = rcu_dereference(rule->ctarget);
211 if (target == NULL) {
212 continue;
213 } else {
214 rule = target;
215 goto jumped;
217 } else if (rule->action == FR_ACT_NOP)
218 continue;
219 else
220 err = ops->action(rule, fl, flags, arg);
222 if (!err && ops->suppress && ops->suppress(rule, arg))
223 continue;
225 if (err != -EAGAIN) {
226 if ((arg->flags & FIB_LOOKUP_NOREF) ||
227 likely(atomic_inc_not_zero(&rule->refcnt))) {
228 arg->rule = rule;
229 goto out;
231 break;
235 err = -ESRCH;
236 out:
237 rcu_read_unlock();
239 return err;
241 EXPORT_SYMBOL_GPL(fib_rules_lookup);
243 static int validate_rulemsg(struct fib_rule_hdr *frh, struct nlattr **tb,
244 struct fib_rules_ops *ops)
246 int err = -EINVAL;
248 if (frh->src_len)
249 if (tb[FRA_SRC] == NULL ||
250 frh->src_len > (ops->addr_size * 8) ||
251 nla_len(tb[FRA_SRC]) != ops->addr_size)
252 goto errout;
254 if (frh->dst_len)
255 if (tb[FRA_DST] == NULL ||
256 frh->dst_len > (ops->addr_size * 8) ||
257 nla_len(tb[FRA_DST]) != ops->addr_size)
258 goto errout;
260 err = 0;
261 errout:
262 return err;
265 static int fib_nl_newrule(struct sk_buff *skb, struct nlmsghdr* nlh)
267 struct net *net = sock_net(skb->sk);
268 struct fib_rule_hdr *frh = nlmsg_data(nlh);
269 struct fib_rules_ops *ops = NULL;
270 struct fib_rule *rule, *r, *last = NULL;
271 struct nlattr *tb[FRA_MAX+1];
272 int err = -EINVAL, unresolved = 0;
274 if (nlh->nlmsg_len < nlmsg_msg_size(sizeof(*frh)))
275 goto errout;
277 ops = lookup_rules_ops(net, frh->family);
278 if (ops == NULL) {
279 err = -EAFNOSUPPORT;
280 goto errout;
283 err = nlmsg_parse(nlh, sizeof(*frh), tb, FRA_MAX, ops->policy);
284 if (err < 0)
285 goto errout;
287 err = validate_rulemsg(frh, tb, ops);
288 if (err < 0)
289 goto errout;
291 rule = kzalloc(ops->rule_size, GFP_KERNEL);
292 if (rule == NULL) {
293 err = -ENOMEM;
294 goto errout;
296 rule->fr_net = net;
298 if (tb[FRA_PRIORITY])
299 rule->pref = nla_get_u32(tb[FRA_PRIORITY]);
301 if (tb[FRA_IIFNAME]) {
302 struct net_device *dev;
304 rule->iifindex = -1;
305 nla_strlcpy(rule->iifname, tb[FRA_IIFNAME], IFNAMSIZ);
306 dev = __dev_get_by_name(net, rule->iifname);
307 if (dev)
308 rule->iifindex = dev->ifindex;
311 if (tb[FRA_OIFNAME]) {
312 struct net_device *dev;
314 rule->oifindex = -1;
315 nla_strlcpy(rule->oifname, tb[FRA_OIFNAME], IFNAMSIZ);
316 dev = __dev_get_by_name(net, rule->oifname);
317 if (dev)
318 rule->oifindex = dev->ifindex;
321 if (tb[FRA_FWMARK]) {
322 rule->mark = nla_get_u32(tb[FRA_FWMARK]);
323 if (rule->mark)
324 /* compatibility: if the mark value is non-zero all bits
325 * are compared unless a mask is explicitly specified.
327 rule->mark_mask = 0xFFFFFFFF;
330 if (tb[FRA_FWMASK])
331 rule->mark_mask = nla_get_u32(tb[FRA_FWMASK]);
333 rule->action = frh->action;
334 rule->flags = frh->flags;
335 rule->table = frh_get_table(frh, tb);
336 if (tb[FRA_SUPPRESS_PREFIXLEN])
337 rule->suppress_prefixlen = nla_get_u32(tb[FRA_SUPPRESS_PREFIXLEN]);
338 else
339 rule->suppress_prefixlen = -1;
341 if (tb[FRA_SUPPRESS_IFGROUP])
342 rule->suppress_ifgroup = nla_get_u32(tb[FRA_SUPPRESS_IFGROUP]);
343 else
344 rule->suppress_ifgroup = -1;
346 if (!tb[FRA_PRIORITY] && ops->default_pref)
347 rule->pref = ops->default_pref(ops);
349 err = -EINVAL;
350 if (tb[FRA_GOTO]) {
351 if (rule->action != FR_ACT_GOTO)
352 goto errout_free;
354 rule->target = nla_get_u32(tb[FRA_GOTO]);
355 /* Backward jumps are prohibited to avoid endless loops */
356 if (rule->target <= rule->pref)
357 goto errout_free;
359 list_for_each_entry(r, &ops->rules_list, list) {
360 if (r->pref == rule->target) {
361 RCU_INIT_POINTER(rule->ctarget, r);
362 break;
366 if (rcu_dereference_protected(rule->ctarget, 1) == NULL)
367 unresolved = 1;
368 } else if (rule->action == FR_ACT_GOTO)
369 goto errout_free;
371 err = ops->configure(rule, skb, frh, tb);
372 if (err < 0)
373 goto errout_free;
375 list_for_each_entry(r, &ops->rules_list, list) {
376 if (r->pref > rule->pref)
377 break;
378 last = r;
381 fib_rule_get(rule);
383 if (last)
384 list_add_rcu(&rule->list, &last->list);
385 else
386 list_add_rcu(&rule->list, &ops->rules_list);
388 if (ops->unresolved_rules) {
390 * There are unresolved goto rules in the list, check if
391 * any of them are pointing to this new rule.
393 list_for_each_entry(r, &ops->rules_list, list) {
394 if (r->action == FR_ACT_GOTO &&
395 r->target == rule->pref &&
396 rtnl_dereference(r->ctarget) == NULL) {
397 rcu_assign_pointer(r->ctarget, rule);
398 if (--ops->unresolved_rules == 0)
399 break;
404 if (rule->action == FR_ACT_GOTO)
405 ops->nr_goto_rules++;
407 if (unresolved)
408 ops->unresolved_rules++;
410 notify_rule_change(RTM_NEWRULE, rule, ops, nlh, NETLINK_CB(skb).portid);
411 flush_route_cache(ops);
412 rules_ops_put(ops);
413 return 0;
415 errout_free:
416 kfree(rule);
417 errout:
418 rules_ops_put(ops);
419 return err;
422 static int fib_nl_delrule(struct sk_buff *skb, struct nlmsghdr* nlh)
424 struct net *net = sock_net(skb->sk);
425 struct fib_rule_hdr *frh = nlmsg_data(nlh);
426 struct fib_rules_ops *ops = NULL;
427 struct fib_rule *rule, *tmp;
428 struct nlattr *tb[FRA_MAX+1];
429 int err = -EINVAL;
431 if (nlh->nlmsg_len < nlmsg_msg_size(sizeof(*frh)))
432 goto errout;
434 ops = lookup_rules_ops(net, frh->family);
435 if (ops == NULL) {
436 err = -EAFNOSUPPORT;
437 goto errout;
440 err = nlmsg_parse(nlh, sizeof(*frh), tb, FRA_MAX, ops->policy);
441 if (err < 0)
442 goto errout;
444 err = validate_rulemsg(frh, tb, ops);
445 if (err < 0)
446 goto errout;
448 list_for_each_entry(rule, &ops->rules_list, list) {
449 if (frh->action && (frh->action != rule->action))
450 continue;
452 if (frh_get_table(frh, tb) &&
453 (frh_get_table(frh, tb) != rule->table))
454 continue;
456 if (tb[FRA_PRIORITY] &&
457 (rule->pref != nla_get_u32(tb[FRA_PRIORITY])))
458 continue;
460 if (tb[FRA_IIFNAME] &&
461 nla_strcmp(tb[FRA_IIFNAME], rule->iifname))
462 continue;
464 if (tb[FRA_OIFNAME] &&
465 nla_strcmp(tb[FRA_OIFNAME], rule->oifname))
466 continue;
468 if (tb[FRA_FWMARK] &&
469 (rule->mark != nla_get_u32(tb[FRA_FWMARK])))
470 continue;
472 if (tb[FRA_FWMASK] &&
473 (rule->mark_mask != nla_get_u32(tb[FRA_FWMASK])))
474 continue;
476 if (!ops->compare(rule, frh, tb))
477 continue;
479 if (rule->flags & FIB_RULE_PERMANENT) {
480 err = -EPERM;
481 goto errout;
484 if (ops->delete) {
485 err = ops->delete(rule);
486 if (err)
487 goto errout;
490 list_del_rcu(&rule->list);
492 if (rule->action == FR_ACT_GOTO) {
493 ops->nr_goto_rules--;
494 if (rtnl_dereference(rule->ctarget) == NULL)
495 ops->unresolved_rules--;
499 * Check if this rule is a target to any of them. If so,
500 * disable them. As this operation is eventually very
501 * expensive, it is only performed if goto rules have
502 * actually been added.
504 if (ops->nr_goto_rules > 0) {
505 list_for_each_entry(tmp, &ops->rules_list, list) {
506 if (rtnl_dereference(tmp->ctarget) == rule) {
507 RCU_INIT_POINTER(tmp->ctarget, NULL);
508 ops->unresolved_rules++;
513 notify_rule_change(RTM_DELRULE, rule, ops, nlh,
514 NETLINK_CB(skb).portid);
515 fib_rule_put(rule);
516 flush_route_cache(ops);
517 rules_ops_put(ops);
518 return 0;
521 err = -ENOENT;
522 errout:
523 rules_ops_put(ops);
524 return err;
527 static inline size_t fib_rule_nlmsg_size(struct fib_rules_ops *ops,
528 struct fib_rule *rule)
530 size_t payload = NLMSG_ALIGN(sizeof(struct fib_rule_hdr))
531 + nla_total_size(IFNAMSIZ) /* FRA_IIFNAME */
532 + nla_total_size(IFNAMSIZ) /* FRA_OIFNAME */
533 + nla_total_size(4) /* FRA_PRIORITY */
534 + nla_total_size(4) /* FRA_TABLE */
535 + nla_total_size(4) /* FRA_SUPPRESS_PREFIXLEN */
536 + nla_total_size(4) /* FRA_SUPPRESS_IFGROUP */
537 + nla_total_size(4) /* FRA_FWMARK */
538 + nla_total_size(4); /* FRA_FWMASK */
540 if (ops->nlmsg_payload)
541 payload += ops->nlmsg_payload(rule);
543 return payload;
546 static int fib_nl_fill_rule(struct sk_buff *skb, struct fib_rule *rule,
547 u32 pid, u32 seq, int type, int flags,
548 struct fib_rules_ops *ops)
550 struct nlmsghdr *nlh;
551 struct fib_rule_hdr *frh;
553 nlh = nlmsg_put(skb, pid, seq, type, sizeof(*frh), flags);
554 if (nlh == NULL)
555 return -EMSGSIZE;
557 frh = nlmsg_data(nlh);
558 frh->family = ops->family;
559 frh->table = rule->table;
560 if (nla_put_u32(skb, FRA_TABLE, rule->table))
561 goto nla_put_failure;
562 if (nla_put_u32(skb, FRA_SUPPRESS_PREFIXLEN, rule->suppress_prefixlen))
563 goto nla_put_failure;
564 frh->res1 = 0;
565 frh->res2 = 0;
566 frh->action = rule->action;
567 frh->flags = rule->flags;
569 if (rule->action == FR_ACT_GOTO &&
570 rcu_access_pointer(rule->ctarget) == NULL)
571 frh->flags |= FIB_RULE_UNRESOLVED;
573 if (rule->iifname[0]) {
574 if (nla_put_string(skb, FRA_IIFNAME, rule->iifname))
575 goto nla_put_failure;
576 if (rule->iifindex == -1)
577 frh->flags |= FIB_RULE_IIF_DETACHED;
580 if (rule->oifname[0]) {
581 if (nla_put_string(skb, FRA_OIFNAME, rule->oifname))
582 goto nla_put_failure;
583 if (rule->oifindex == -1)
584 frh->flags |= FIB_RULE_OIF_DETACHED;
587 if ((rule->pref &&
588 nla_put_u32(skb, FRA_PRIORITY, rule->pref)) ||
589 (rule->mark &&
590 nla_put_u32(skb, FRA_FWMARK, rule->mark)) ||
591 ((rule->mark_mask || rule->mark) &&
592 nla_put_u32(skb, FRA_FWMASK, rule->mark_mask)) ||
593 (rule->target &&
594 nla_put_u32(skb, FRA_GOTO, rule->target)))
595 goto nla_put_failure;
597 if (rule->suppress_ifgroup != -1) {
598 if (nla_put_u32(skb, FRA_SUPPRESS_IFGROUP, rule->suppress_ifgroup))
599 goto nla_put_failure;
602 if (ops->fill(rule, skb, frh) < 0)
603 goto nla_put_failure;
605 nlmsg_end(skb, nlh);
606 return 0;
608 nla_put_failure:
609 nlmsg_cancel(skb, nlh);
610 return -EMSGSIZE;
613 static int dump_rules(struct sk_buff *skb, struct netlink_callback *cb,
614 struct fib_rules_ops *ops)
616 int idx = 0;
617 struct fib_rule *rule;
618 int err = 0;
620 rcu_read_lock();
621 list_for_each_entry_rcu(rule, &ops->rules_list, list) {
622 if (idx < cb->args[1])
623 goto skip;
625 err = fib_nl_fill_rule(skb, rule, NETLINK_CB(cb->skb).portid,
626 cb->nlh->nlmsg_seq, RTM_NEWRULE,
627 NLM_F_MULTI, ops);
628 if (err)
629 break;
630 skip:
631 idx++;
633 rcu_read_unlock();
634 cb->args[1] = idx;
635 rules_ops_put(ops);
637 return err;
640 static int fib_nl_dumprule(struct sk_buff *skb, struct netlink_callback *cb)
642 struct net *net = sock_net(skb->sk);
643 struct fib_rules_ops *ops;
644 int idx = 0, family;
646 family = rtnl_msg_family(cb->nlh);
647 if (family != AF_UNSPEC) {
648 /* Protocol specific dump request */
649 ops = lookup_rules_ops(net, family);
650 if (ops == NULL)
651 return -EAFNOSUPPORT;
653 dump_rules(skb, cb, ops);
655 return skb->len;
658 rcu_read_lock();
659 list_for_each_entry_rcu(ops, &net->rules_ops, list) {
660 if (idx < cb->args[0] || !try_module_get(ops->owner))
661 goto skip;
663 if (dump_rules(skb, cb, ops) < 0)
664 break;
666 cb->args[1] = 0;
667 skip:
668 idx++;
670 rcu_read_unlock();
671 cb->args[0] = idx;
673 return skb->len;
676 static void notify_rule_change(int event, struct fib_rule *rule,
677 struct fib_rules_ops *ops, struct nlmsghdr *nlh,
678 u32 pid)
680 struct net *net;
681 struct sk_buff *skb;
682 int err = -ENOBUFS;
684 net = ops->fro_net;
685 skb = nlmsg_new(fib_rule_nlmsg_size(ops, rule), GFP_KERNEL);
686 if (skb == NULL)
687 goto errout;
689 err = fib_nl_fill_rule(skb, rule, pid, nlh->nlmsg_seq, event, 0, ops);
690 if (err < 0) {
691 /* -EMSGSIZE implies BUG in fib_rule_nlmsg_size() */
692 WARN_ON(err == -EMSGSIZE);
693 kfree_skb(skb);
694 goto errout;
697 rtnl_notify(skb, net, pid, ops->nlgroup, nlh, GFP_KERNEL);
698 return;
699 errout:
700 if (err < 0)
701 rtnl_set_sk_err(net, ops->nlgroup, err);
704 static void attach_rules(struct list_head *rules, struct net_device *dev)
706 struct fib_rule *rule;
708 list_for_each_entry(rule, rules, list) {
709 if (rule->iifindex == -1 &&
710 strcmp(dev->name, rule->iifname) == 0)
711 rule->iifindex = dev->ifindex;
712 if (rule->oifindex == -1 &&
713 strcmp(dev->name, rule->oifname) == 0)
714 rule->oifindex = dev->ifindex;
718 static void detach_rules(struct list_head *rules, struct net_device *dev)
720 struct fib_rule *rule;
722 list_for_each_entry(rule, rules, list) {
723 if (rule->iifindex == dev->ifindex)
724 rule->iifindex = -1;
725 if (rule->oifindex == dev->ifindex)
726 rule->oifindex = -1;
731 static int fib_rules_event(struct notifier_block *this, unsigned long event,
732 void *ptr)
734 struct net_device *dev = netdev_notifier_info_to_dev(ptr);
735 struct net *net = dev_net(dev);
736 struct fib_rules_ops *ops;
738 ASSERT_RTNL();
740 switch (event) {
741 case NETDEV_REGISTER:
742 list_for_each_entry(ops, &net->rules_ops, list)
743 attach_rules(&ops->rules_list, dev);
744 break;
746 case NETDEV_CHANGENAME:
747 list_for_each_entry(ops, &net->rules_ops, list) {
748 detach_rules(&ops->rules_list, dev);
749 attach_rules(&ops->rules_list, dev);
751 break;
753 case NETDEV_UNREGISTER:
754 list_for_each_entry(ops, &net->rules_ops, list)
755 detach_rules(&ops->rules_list, dev);
756 break;
759 return NOTIFY_DONE;
762 static struct notifier_block fib_rules_notifier = {
763 .notifier_call = fib_rules_event,
766 static int __net_init fib_rules_net_init(struct net *net)
768 INIT_LIST_HEAD(&net->rules_ops);
769 spin_lock_init(&net->rules_mod_lock);
770 return 0;
773 static struct pernet_operations fib_rules_net_ops = {
774 .init = fib_rules_net_init,
777 static int __init fib_rules_init(void)
779 int err;
780 rtnl_register(PF_UNSPEC, RTM_NEWRULE, fib_nl_newrule, NULL, NULL);
781 rtnl_register(PF_UNSPEC, RTM_DELRULE, fib_nl_delrule, NULL, NULL);
782 rtnl_register(PF_UNSPEC, RTM_GETRULE, NULL, fib_nl_dumprule, NULL);
784 err = register_pernet_subsys(&fib_rules_net_ops);
785 if (err < 0)
786 goto fail;
788 err = register_netdevice_notifier(&fib_rules_notifier);
789 if (err < 0)
790 goto fail_unregister;
792 return 0;
794 fail_unregister:
795 unregister_pernet_subsys(&fib_rules_net_ops);
796 fail:
797 rtnl_unregister(PF_UNSPEC, RTM_NEWRULE);
798 rtnl_unregister(PF_UNSPEC, RTM_DELRULE);
799 rtnl_unregister(PF_UNSPEC, RTM_GETRULE);
800 return err;
803 subsys_initcall(fib_rules_init);