]> bbs.cooldavid.org Git - net-next-2.6.git/blob - net/core/fib_rules.c
Merge branch 'master' of master.kernel.org:/pub/scm/linux/kernel/git/davem/net-2.6
[net-next-2.6.git] / net / core / fib_rules.c
1 /*
2  * net/core/fib_rules.c         Generic Routing Rules
3  *
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.
7  *
8  * Authors:     Thomas Graf <tgraf@suug.ch>
9  */
10
11 #include <linux/types.h>
12 #include <linux/kernel.h>
13 #include <linux/slab.h>
14 #include <linux/list.h>
15 #include <net/net_namespace.h>
16 #include <net/sock.h>
17 #include <net/fib_rules.h>
18
19 int fib_default_rule_add(struct fib_rules_ops *ops,
20                          u32 pref, u32 table, u32 flags)
21 {
22         struct fib_rule *r;
23
24         r = kzalloc(ops->rule_size, GFP_KERNEL);
25         if (r == NULL)
26                 return -ENOMEM;
27
28         atomic_set(&r->refcnt, 1);
29         r->action = FR_ACT_TO_TBL;
30         r->pref = pref;
31         r->table = table;
32         r->flags = flags;
33         r->fr_net = hold_net(ops->fro_net);
34
35         /* The lock is not required here, the list in unreacheable
36          * at the moment this function is called */
37         list_add_tail(&r->list, &ops->rules_list);
38         return 0;
39 }
40 EXPORT_SYMBOL(fib_default_rule_add);
41
42 static void notify_rule_change(int event, struct fib_rule *rule,
43                                struct fib_rules_ops *ops, struct nlmsghdr *nlh,
44                                u32 pid);
45
46 static struct fib_rules_ops *lookup_rules_ops(struct net *net, int family)
47 {
48         struct fib_rules_ops *ops;
49
50         rcu_read_lock();
51         list_for_each_entry_rcu(ops, &net->rules_ops, list) {
52                 if (ops->family == family) {
53                         if (!try_module_get(ops->owner))
54                                 ops = NULL;
55                         rcu_read_unlock();
56                         return ops;
57                 }
58         }
59         rcu_read_unlock();
60
61         return NULL;
62 }
63
64 static void rules_ops_put(struct fib_rules_ops *ops)
65 {
66         if (ops)
67                 module_put(ops->owner);
68 }
69
70 static void flush_route_cache(struct fib_rules_ops *ops)
71 {
72         if (ops->flush_cache)
73                 ops->flush_cache(ops);
74 }
75
76 static int __fib_rules_register(struct fib_rules_ops *ops)
77 {
78         int err = -EEXIST;
79         struct fib_rules_ops *o;
80         struct net *net;
81
82         net = ops->fro_net;
83
84         if (ops->rule_size < sizeof(struct fib_rule))
85                 return -EINVAL;
86
87         if (ops->match == NULL || ops->configure == NULL ||
88             ops->compare == NULL || ops->fill == NULL ||
89             ops->action == NULL)
90                 return -EINVAL;
91
92         spin_lock(&net->rules_mod_lock);
93         list_for_each_entry(o, &net->rules_ops, list)
94                 if (ops->family == o->family)
95                         goto errout;
96
97         hold_net(net);
98         list_add_tail_rcu(&ops->list, &net->rules_ops);
99         err = 0;
100 errout:
101         spin_unlock(&net->rules_mod_lock);
102
103         return err;
104 }
105
106 struct fib_rules_ops *
107 fib_rules_register(struct fib_rules_ops *tmpl, struct net *net)
108 {
109         struct fib_rules_ops *ops;
110         int err;
111
112         ops = kmemdup(tmpl, sizeof(*ops), GFP_KERNEL);
113         if (ops == NULL)
114                 return ERR_PTR(-ENOMEM);
115
116         INIT_LIST_HEAD(&ops->rules_list);
117         ops->fro_net = net;
118
119         err = __fib_rules_register(ops);
120         if (err) {
121                 kfree(ops);
122                 ops = ERR_PTR(err);
123         }
124
125         return ops;
126 }
127 EXPORT_SYMBOL_GPL(fib_rules_register);
128
129 void fib_rules_cleanup_ops(struct fib_rules_ops *ops)
130 {
131         struct fib_rule *rule, *tmp;
132
133         list_for_each_entry_safe(rule, tmp, &ops->rules_list, list) {
134                 list_del_rcu(&rule->list);
135                 fib_rule_put(rule);
136         }
137 }
138 EXPORT_SYMBOL_GPL(fib_rules_cleanup_ops);
139
140 static void fib_rules_put_rcu(struct rcu_head *head)
141 {
142         struct fib_rules_ops *ops = container_of(head, struct fib_rules_ops, rcu);
143         struct net *net = ops->fro_net;
144
145         release_net(net);
146         kfree(ops);
147 }
148
149 void fib_rules_unregister(struct fib_rules_ops *ops)
150 {
151         struct net *net = ops->fro_net;
152
153         spin_lock(&net->rules_mod_lock);
154         list_del_rcu(&ops->list);
155         fib_rules_cleanup_ops(ops);
156         spin_unlock(&net->rules_mod_lock);
157
158         call_rcu(&ops->rcu, fib_rules_put_rcu);
159 }
160 EXPORT_SYMBOL_GPL(fib_rules_unregister);
161
162 static int fib_rule_match(struct fib_rule *rule, struct fib_rules_ops *ops,
163                           struct flowi *fl, int flags)
164 {
165         int ret = 0;
166
167         if (rule->iifindex && (rule->iifindex != fl->iif))
168                 goto out;
169
170         if (rule->oifindex && (rule->oifindex != fl->oif))
171                 goto out;
172
173         if ((rule->mark ^ fl->mark) & rule->mark_mask)
174                 goto out;
175
176         ret = ops->match(rule, fl, flags);
177 out:
178         return (rule->flags & FIB_RULE_INVERT) ? !ret : ret;
179 }
180
181 int fib_rules_lookup(struct fib_rules_ops *ops, struct flowi *fl,
182                      int flags, struct fib_lookup_arg *arg)
183 {
184         struct fib_rule *rule;
185         int err;
186
187         rcu_read_lock();
188
189         list_for_each_entry_rcu(rule, &ops->rules_list, list) {
190 jumped:
191                 if (!fib_rule_match(rule, ops, fl, flags))
192                         continue;
193
194                 if (rule->action == FR_ACT_GOTO) {
195                         struct fib_rule *target;
196
197                         target = rcu_dereference(rule->ctarget);
198                         if (target == NULL) {
199                                 continue;
200                         } else {
201                                 rule = target;
202                                 goto jumped;
203                         }
204                 } else if (rule->action == FR_ACT_NOP)
205                         continue;
206                 else
207                         err = ops->action(rule, fl, flags, arg);
208
209                 if (err != -EAGAIN) {
210                         fib_rule_get(rule);
211                         arg->rule = rule;
212                         goto out;
213                 }
214         }
215
216         err = -ESRCH;
217 out:
218         rcu_read_unlock();
219
220         return err;
221 }
222 EXPORT_SYMBOL_GPL(fib_rules_lookup);
223
224 static int validate_rulemsg(struct fib_rule_hdr *frh, struct nlattr **tb,
225                             struct fib_rules_ops *ops)
226 {
227         int err = -EINVAL;
228
229         if (frh->src_len)
230                 if (tb[FRA_SRC] == NULL ||
231                     frh->src_len > (ops->addr_size * 8) ||
232                     nla_len(tb[FRA_SRC]) != ops->addr_size)
233                         goto errout;
234
235         if (frh->dst_len)
236                 if (tb[FRA_DST] == NULL ||
237                     frh->dst_len > (ops->addr_size * 8) ||
238                     nla_len(tb[FRA_DST]) != ops->addr_size)
239                         goto errout;
240
241         err = 0;
242 errout:
243         return err;
244 }
245
246 static int fib_nl_newrule(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg)
247 {
248         struct net *net = sock_net(skb->sk);
249         struct fib_rule_hdr *frh = nlmsg_data(nlh);
250         struct fib_rules_ops *ops = NULL;
251         struct fib_rule *rule, *r, *last = NULL;
252         struct nlattr *tb[FRA_MAX+1];
253         int err = -EINVAL, unresolved = 0;
254
255         if (nlh->nlmsg_len < nlmsg_msg_size(sizeof(*frh)))
256                 goto errout;
257
258         ops = lookup_rules_ops(net, frh->family);
259         if (ops == NULL) {
260                 err = -EAFNOSUPPORT;
261                 goto errout;
262         }
263
264         err = nlmsg_parse(nlh, sizeof(*frh), tb, FRA_MAX, ops->policy);
265         if (err < 0)
266                 goto errout;
267
268         err = validate_rulemsg(frh, tb, ops);
269         if (err < 0)
270                 goto errout;
271
272         rule = kzalloc(ops->rule_size, GFP_KERNEL);
273         if (rule == NULL) {
274                 err = -ENOMEM;
275                 goto errout;
276         }
277         rule->fr_net = hold_net(net);
278
279         if (tb[FRA_PRIORITY])
280                 rule->pref = nla_get_u32(tb[FRA_PRIORITY]);
281
282         if (tb[FRA_IIFNAME]) {
283                 struct net_device *dev;
284
285                 rule->iifindex = -1;
286                 nla_strlcpy(rule->iifname, tb[FRA_IIFNAME], IFNAMSIZ);
287                 dev = __dev_get_by_name(net, rule->iifname);
288                 if (dev)
289                         rule->iifindex = dev->ifindex;
290         }
291
292         if (tb[FRA_OIFNAME]) {
293                 struct net_device *dev;
294
295                 rule->oifindex = -1;
296                 nla_strlcpy(rule->oifname, tb[FRA_OIFNAME], IFNAMSIZ);
297                 dev = __dev_get_by_name(net, rule->oifname);
298                 if (dev)
299                         rule->oifindex = dev->ifindex;
300         }
301
302         if (tb[FRA_FWMARK]) {
303                 rule->mark = nla_get_u32(tb[FRA_FWMARK]);
304                 if (rule->mark)
305                         /* compatibility: if the mark value is non-zero all bits
306                          * are compared unless a mask is explicitly specified.
307                          */
308                         rule->mark_mask = 0xFFFFFFFF;
309         }
310
311         if (tb[FRA_FWMASK])
312                 rule->mark_mask = nla_get_u32(tb[FRA_FWMASK]);
313
314         rule->action = frh->action;
315         rule->flags = frh->flags;
316         rule->table = frh_get_table(frh, tb);
317
318         if (!tb[FRA_PRIORITY] && ops->default_pref)
319                 rule->pref = ops->default_pref(ops);
320
321         err = -EINVAL;
322         if (tb[FRA_GOTO]) {
323                 if (rule->action != FR_ACT_GOTO)
324                         goto errout_free;
325
326                 rule->target = nla_get_u32(tb[FRA_GOTO]);
327                 /* Backward jumps are prohibited to avoid endless loops */
328                 if (rule->target <= rule->pref)
329                         goto errout_free;
330
331                 list_for_each_entry(r, &ops->rules_list, list) {
332                         if (r->pref == rule->target) {
333                                 rule->ctarget = r;
334                                 break;
335                         }
336                 }
337
338                 if (rule->ctarget == NULL)
339                         unresolved = 1;
340         } else if (rule->action == FR_ACT_GOTO)
341                 goto errout_free;
342
343         err = ops->configure(rule, skb, frh, tb);
344         if (err < 0)
345                 goto errout_free;
346
347         list_for_each_entry(r, &ops->rules_list, list) {
348                 if (r->pref > rule->pref)
349                         break;
350                 last = r;
351         }
352
353         fib_rule_get(rule);
354
355         if (ops->unresolved_rules) {
356                 /*
357                  * There are unresolved goto rules in the list, check if
358                  * any of them are pointing to this new rule.
359                  */
360                 list_for_each_entry(r, &ops->rules_list, list) {
361                         if (r->action == FR_ACT_GOTO &&
362                             r->target == rule->pref) {
363                                 BUG_ON(r->ctarget != NULL);
364                                 rcu_assign_pointer(r->ctarget, rule);
365                                 if (--ops->unresolved_rules == 0)
366                                         break;
367                         }
368                 }
369         }
370
371         if (rule->action == FR_ACT_GOTO)
372                 ops->nr_goto_rules++;
373
374         if (unresolved)
375                 ops->unresolved_rules++;
376
377         if (last)
378                 list_add_rcu(&rule->list, &last->list);
379         else
380                 list_add_rcu(&rule->list, &ops->rules_list);
381
382         notify_rule_change(RTM_NEWRULE, rule, ops, nlh, NETLINK_CB(skb).pid);
383         flush_route_cache(ops);
384         rules_ops_put(ops);
385         return 0;
386
387 errout_free:
388         release_net(rule->fr_net);
389         kfree(rule);
390 errout:
391         rules_ops_put(ops);
392         return err;
393 }
394
395 static int fib_nl_delrule(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg)
396 {
397         struct net *net = sock_net(skb->sk);
398         struct fib_rule_hdr *frh = nlmsg_data(nlh);
399         struct fib_rules_ops *ops = NULL;
400         struct fib_rule *rule, *tmp;
401         struct nlattr *tb[FRA_MAX+1];
402         int err = -EINVAL;
403
404         if (nlh->nlmsg_len < nlmsg_msg_size(sizeof(*frh)))
405                 goto errout;
406
407         ops = lookup_rules_ops(net, frh->family);
408         if (ops == NULL) {
409                 err = -EAFNOSUPPORT;
410                 goto errout;
411         }
412
413         err = nlmsg_parse(nlh, sizeof(*frh), tb, FRA_MAX, ops->policy);
414         if (err < 0)
415                 goto errout;
416
417         err = validate_rulemsg(frh, tb, ops);
418         if (err < 0)
419                 goto errout;
420
421         list_for_each_entry(rule, &ops->rules_list, list) {
422                 if (frh->action && (frh->action != rule->action))
423                         continue;
424
425                 if (frh->table && (frh_get_table(frh, tb) != rule->table))
426                         continue;
427
428                 if (tb[FRA_PRIORITY] &&
429                     (rule->pref != nla_get_u32(tb[FRA_PRIORITY])))
430                         continue;
431
432                 if (tb[FRA_IIFNAME] &&
433                     nla_strcmp(tb[FRA_IIFNAME], rule->iifname))
434                         continue;
435
436                 if (tb[FRA_OIFNAME] &&
437                     nla_strcmp(tb[FRA_OIFNAME], rule->oifname))
438                         continue;
439
440                 if (tb[FRA_FWMARK] &&
441                     (rule->mark != nla_get_u32(tb[FRA_FWMARK])))
442                         continue;
443
444                 if (tb[FRA_FWMASK] &&
445                     (rule->mark_mask != nla_get_u32(tb[FRA_FWMASK])))
446                         continue;
447
448                 if (!ops->compare(rule, frh, tb))
449                         continue;
450
451                 if (rule->flags & FIB_RULE_PERMANENT) {
452                         err = -EPERM;
453                         goto errout;
454                 }
455
456                 list_del_rcu(&rule->list);
457
458                 if (rule->action == FR_ACT_GOTO)
459                         ops->nr_goto_rules--;
460
461                 /*
462                  * Check if this rule is a target to any of them. If so,
463                  * disable them. As this operation is eventually very
464                  * expensive, it is only performed if goto rules have
465                  * actually been added.
466                  */
467                 if (ops->nr_goto_rules > 0) {
468                         list_for_each_entry(tmp, &ops->rules_list, list) {
469                                 if (tmp->ctarget == rule) {
470                                         rcu_assign_pointer(tmp->ctarget, NULL);
471                                         ops->unresolved_rules++;
472                                 }
473                         }
474                 }
475
476                 synchronize_rcu();
477                 notify_rule_change(RTM_DELRULE, rule, ops, nlh,
478                                    NETLINK_CB(skb).pid);
479                 fib_rule_put(rule);
480                 flush_route_cache(ops);
481                 rules_ops_put(ops);
482                 return 0;
483         }
484
485         err = -ENOENT;
486 errout:
487         rules_ops_put(ops);
488         return err;
489 }
490
491 static inline size_t fib_rule_nlmsg_size(struct fib_rules_ops *ops,
492                                          struct fib_rule *rule)
493 {
494         size_t payload = NLMSG_ALIGN(sizeof(struct fib_rule_hdr))
495                          + nla_total_size(IFNAMSIZ) /* FRA_IIFNAME */
496                          + nla_total_size(IFNAMSIZ) /* FRA_OIFNAME */
497                          + nla_total_size(4) /* FRA_PRIORITY */
498                          + nla_total_size(4) /* FRA_TABLE */
499                          + nla_total_size(4) /* FRA_FWMARK */
500                          + nla_total_size(4); /* FRA_FWMASK */
501
502         if (ops->nlmsg_payload)
503                 payload += ops->nlmsg_payload(rule);
504
505         return payload;
506 }
507
508 static int fib_nl_fill_rule(struct sk_buff *skb, struct fib_rule *rule,
509                             u32 pid, u32 seq, int type, int flags,
510                             struct fib_rules_ops *ops)
511 {
512         struct nlmsghdr *nlh;
513         struct fib_rule_hdr *frh;
514
515         nlh = nlmsg_put(skb, pid, seq, type, sizeof(*frh), flags);
516         if (nlh == NULL)
517                 return -EMSGSIZE;
518
519         frh = nlmsg_data(nlh);
520         frh->table = rule->table;
521         NLA_PUT_U32(skb, FRA_TABLE, rule->table);
522         frh->res1 = 0;
523         frh->res2 = 0;
524         frh->action = rule->action;
525         frh->flags = rule->flags;
526
527         if (rule->action == FR_ACT_GOTO && rule->ctarget == NULL)
528                 frh->flags |= FIB_RULE_UNRESOLVED;
529
530         if (rule->iifname[0]) {
531                 NLA_PUT_STRING(skb, FRA_IIFNAME, rule->iifname);
532
533                 if (rule->iifindex == -1)
534                         frh->flags |= FIB_RULE_IIF_DETACHED;
535         }
536
537         if (rule->oifname[0]) {
538                 NLA_PUT_STRING(skb, FRA_OIFNAME, rule->oifname);
539
540                 if (rule->oifindex == -1)
541                         frh->flags |= FIB_RULE_OIF_DETACHED;
542         }
543
544         if (rule->pref)
545                 NLA_PUT_U32(skb, FRA_PRIORITY, rule->pref);
546
547         if (rule->mark)
548                 NLA_PUT_U32(skb, FRA_FWMARK, rule->mark);
549
550         if (rule->mark_mask || rule->mark)
551                 NLA_PUT_U32(skb, FRA_FWMASK, rule->mark_mask);
552
553         if (rule->target)
554                 NLA_PUT_U32(skb, FRA_GOTO, rule->target);
555
556         if (ops->fill(rule, skb, frh) < 0)
557                 goto nla_put_failure;
558
559         return nlmsg_end(skb, nlh);
560
561 nla_put_failure:
562         nlmsg_cancel(skb, nlh);
563         return -EMSGSIZE;
564 }
565
566 static int dump_rules(struct sk_buff *skb, struct netlink_callback *cb,
567                       struct fib_rules_ops *ops)
568 {
569         int idx = 0;
570         struct fib_rule *rule;
571
572         list_for_each_entry(rule, &ops->rules_list, list) {
573                 if (idx < cb->args[1])
574                         goto skip;
575
576                 if (fib_nl_fill_rule(skb, rule, NETLINK_CB(cb->skb).pid,
577                                      cb->nlh->nlmsg_seq, RTM_NEWRULE,
578                                      NLM_F_MULTI, ops) < 0)
579                         break;
580 skip:
581                 idx++;
582         }
583         cb->args[1] = idx;
584         rules_ops_put(ops);
585
586         return skb->len;
587 }
588
589 static int fib_nl_dumprule(struct sk_buff *skb, struct netlink_callback *cb)
590 {
591         struct net *net = sock_net(skb->sk);
592         struct fib_rules_ops *ops;
593         int idx = 0, family;
594
595         family = rtnl_msg_family(cb->nlh);
596         if (family != AF_UNSPEC) {
597                 /* Protocol specific dump request */
598                 ops = lookup_rules_ops(net, family);
599                 if (ops == NULL)
600                         return -EAFNOSUPPORT;
601
602                 return dump_rules(skb, cb, ops);
603         }
604
605         rcu_read_lock();
606         list_for_each_entry_rcu(ops, &net->rules_ops, list) {
607                 if (idx < cb->args[0] || !try_module_get(ops->owner))
608                         goto skip;
609
610                 if (dump_rules(skb, cb, ops) < 0)
611                         break;
612
613                 cb->args[1] = 0;
614 skip:
615                 idx++;
616         }
617         rcu_read_unlock();
618         cb->args[0] = idx;
619
620         return skb->len;
621 }
622
623 static void notify_rule_change(int event, struct fib_rule *rule,
624                                struct fib_rules_ops *ops, struct nlmsghdr *nlh,
625                                u32 pid)
626 {
627         struct net *net;
628         struct sk_buff *skb;
629         int err = -ENOBUFS;
630
631         net = ops->fro_net;
632         skb = nlmsg_new(fib_rule_nlmsg_size(ops, rule), GFP_KERNEL);
633         if (skb == NULL)
634                 goto errout;
635
636         err = fib_nl_fill_rule(skb, rule, pid, nlh->nlmsg_seq, event, 0, ops);
637         if (err < 0) {
638                 /* -EMSGSIZE implies BUG in fib_rule_nlmsg_size() */
639                 WARN_ON(err == -EMSGSIZE);
640                 kfree_skb(skb);
641                 goto errout;
642         }
643
644         rtnl_notify(skb, net, pid, ops->nlgroup, nlh, GFP_KERNEL);
645         return;
646 errout:
647         if (err < 0)
648                 rtnl_set_sk_err(net, ops->nlgroup, err);
649 }
650
651 static void attach_rules(struct list_head *rules, struct net_device *dev)
652 {
653         struct fib_rule *rule;
654
655         list_for_each_entry(rule, rules, list) {
656                 if (rule->iifindex == -1 &&
657                     strcmp(dev->name, rule->iifname) == 0)
658                         rule->iifindex = dev->ifindex;
659                 if (rule->oifindex == -1 &&
660                     strcmp(dev->name, rule->oifname) == 0)
661                         rule->oifindex = dev->ifindex;
662         }
663 }
664
665 static void detach_rules(struct list_head *rules, struct net_device *dev)
666 {
667         struct fib_rule *rule;
668
669         list_for_each_entry(rule, rules, list) {
670                 if (rule->iifindex == dev->ifindex)
671                         rule->iifindex = -1;
672                 if (rule->oifindex == dev->ifindex)
673                         rule->oifindex = -1;
674         }
675 }
676
677
678 static int fib_rules_event(struct notifier_block *this, unsigned long event,
679                             void *ptr)
680 {
681         struct net_device *dev = ptr;
682         struct net *net = dev_net(dev);
683         struct fib_rules_ops *ops;
684
685         ASSERT_RTNL();
686
687         switch (event) {
688         case NETDEV_REGISTER:
689                 list_for_each_entry(ops, &net->rules_ops, list)
690                         attach_rules(&ops->rules_list, dev);
691                 break;
692
693         case NETDEV_UNREGISTER:
694                 list_for_each_entry(ops, &net->rules_ops, list)
695                         detach_rules(&ops->rules_list, dev);
696                 break;
697         }
698
699         return NOTIFY_DONE;
700 }
701
702 static struct notifier_block fib_rules_notifier = {
703         .notifier_call = fib_rules_event,
704 };
705
706 static int __net_init fib_rules_net_init(struct net *net)
707 {
708         INIT_LIST_HEAD(&net->rules_ops);
709         spin_lock_init(&net->rules_mod_lock);
710         return 0;
711 }
712
713 static struct pernet_operations fib_rules_net_ops = {
714         .init = fib_rules_net_init,
715 };
716
717 static int __init fib_rules_init(void)
718 {
719         int err;
720         rtnl_register(PF_UNSPEC, RTM_NEWRULE, fib_nl_newrule, NULL);
721         rtnl_register(PF_UNSPEC, RTM_DELRULE, fib_nl_delrule, NULL);
722         rtnl_register(PF_UNSPEC, RTM_GETRULE, NULL, fib_nl_dumprule);
723
724         err = register_pernet_subsys(&fib_rules_net_ops);
725         if (err < 0)
726                 goto fail;
727
728         err = register_netdevice_notifier(&fib_rules_notifier);
729         if (err < 0)
730                 goto fail_unregister;
731
732         return 0;
733
734 fail_unregister:
735         unregister_pernet_subsys(&fib_rules_net_ops);
736 fail:
737         rtnl_unregister(PF_UNSPEC, RTM_NEWRULE);
738         rtnl_unregister(PF_UNSPEC, RTM_DELRULE);
739         rtnl_unregister(PF_UNSPEC, RTM_GETRULE);
740         return err;
741 }
742
743 subsys_initcall(fib_rules_init);