blob: 5824b2644f26b6d8c3dc4743626b7c1c8050d9dd [file] [log] [blame]
Thomas Graf14c0b972006-08-04 03:38:38 -07001/*
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
Thomas Graf14c0b972006-08-04 03:38:38 -070011#include <linux/types.h>
12#include <linux/kernel.h>
13#include <linux/list.h>
14#include <net/fib_rules.h>
15
16static LIST_HEAD(rules_ops);
17static DEFINE_SPINLOCK(rules_mod_lock);
18
19static void notify_rule_change(int event, struct fib_rule *rule,
Thomas Grafc17084d2006-08-15 00:32:48 -070020 struct fib_rules_ops *ops, struct nlmsghdr *nlh,
21 u32 pid);
Thomas Graf14c0b972006-08-04 03:38:38 -070022
23static struct fib_rules_ops *lookup_rules_ops(int family)
24{
25 struct fib_rules_ops *ops;
26
27 rcu_read_lock();
28 list_for_each_entry_rcu(ops, &rules_ops, list) {
29 if (ops->family == family) {
30 if (!try_module_get(ops->owner))
31 ops = NULL;
32 rcu_read_unlock();
33 return ops;
34 }
35 }
36 rcu_read_unlock();
37
38 return NULL;
39}
40
41static void rules_ops_put(struct fib_rules_ops *ops)
42{
43 if (ops)
44 module_put(ops->owner);
45}
46
47int fib_rules_register(struct fib_rules_ops *ops)
48{
49 int err = -EEXIST;
50 struct fib_rules_ops *o;
51
52 if (ops->rule_size < sizeof(struct fib_rule))
53 return -EINVAL;
54
55 if (ops->match == NULL || ops->configure == NULL ||
56 ops->compare == NULL || ops->fill == NULL ||
57 ops->action == NULL)
58 return -EINVAL;
59
60 spin_lock(&rules_mod_lock);
61 list_for_each_entry(o, &rules_ops, list)
62 if (ops->family == o->family)
63 goto errout;
64
65 list_add_tail_rcu(&ops->list, &rules_ops);
66 err = 0;
67errout:
68 spin_unlock(&rules_mod_lock);
69
70 return err;
71}
72
73EXPORT_SYMBOL_GPL(fib_rules_register);
74
75static void cleanup_ops(struct fib_rules_ops *ops)
76{
77 struct fib_rule *rule, *tmp;
78
79 list_for_each_entry_safe(rule, tmp, ops->rules_list, list) {
80 list_del_rcu(&rule->list);
81 fib_rule_put(rule);
82 }
83}
84
85int fib_rules_unregister(struct fib_rules_ops *ops)
86{
87 int err = 0;
88 struct fib_rules_ops *o;
89
90 spin_lock(&rules_mod_lock);
91 list_for_each_entry(o, &rules_ops, list) {
92 if (o == ops) {
93 list_del_rcu(&o->list);
94 cleanup_ops(ops);
95 goto out;
96 }
97 }
98
99 err = -ENOENT;
100out:
101 spin_unlock(&rules_mod_lock);
102
103 synchronize_rcu();
104
105 return err;
106}
107
108EXPORT_SYMBOL_GPL(fib_rules_unregister);
109
Thomas Graf3dfbcc42006-11-09 15:23:20 -0800110static int fib_rule_match(struct fib_rule *rule, struct fib_rules_ops *ops,
111 struct flowi *fl, int flags)
112{
113 int ret = 0;
114
115 if (rule->ifindex && (rule->ifindex != fl->iif))
116 goto out;
117
118 if ((rule->mark ^ fl->mark) & rule->mark_mask)
119 goto out;
120
121 ret = ops->match(rule, fl, flags);
122out:
123 return (rule->flags & FIB_RULE_INVERT) ? !ret : ret;
124}
125
Thomas Graf14c0b972006-08-04 03:38:38 -0700126int fib_rules_lookup(struct fib_rules_ops *ops, struct flowi *fl,
127 int flags, struct fib_lookup_arg *arg)
128{
129 struct fib_rule *rule;
130 int err;
131
132 rcu_read_lock();
133
134 list_for_each_entry_rcu(rule, ops->rules_list, list) {
Thomas Graf0947c9fe2007-03-26 17:14:15 -0700135jumped:
Thomas Graf3dfbcc42006-11-09 15:23:20 -0800136 if (!fib_rule_match(rule, ops, fl, flags))
Thomas Graf14c0b972006-08-04 03:38:38 -0700137 continue;
138
Thomas Graf0947c9fe2007-03-26 17:14:15 -0700139 if (rule->action == FR_ACT_GOTO) {
140 struct fib_rule *target;
141
142 target = rcu_dereference(rule->ctarget);
143 if (target == NULL) {
144 continue;
145 } else {
146 rule = target;
147 goto jumped;
148 }
Thomas Graffa0b2d12007-03-26 17:38:53 -0700149 } else if (rule->action == FR_ACT_NOP)
150 continue;
151 else
Thomas Graf0947c9fe2007-03-26 17:14:15 -0700152 err = ops->action(rule, fl, flags, arg);
153
Thomas Graf14c0b972006-08-04 03:38:38 -0700154 if (err != -EAGAIN) {
155 fib_rule_get(rule);
156 arg->rule = rule;
157 goto out;
158 }
159 }
160
Steven Whitehouse83886b62007-03-30 13:34:27 -0700161 err = -ESRCH;
Thomas Graf14c0b972006-08-04 03:38:38 -0700162out:
163 rcu_read_unlock();
164
165 return err;
166}
167
168EXPORT_SYMBOL_GPL(fib_rules_lookup);
169
Thomas Grafe1701c62007-03-24 12:46:02 -0700170static int validate_rulemsg(struct fib_rule_hdr *frh, struct nlattr **tb,
171 struct fib_rules_ops *ops)
172{
173 int err = -EINVAL;
174
175 if (frh->src_len)
176 if (tb[FRA_SRC] == NULL ||
177 frh->src_len > (ops->addr_size * 8) ||
178 nla_len(tb[FRA_SRC]) != ops->addr_size)
179 goto errout;
180
181 if (frh->dst_len)
182 if (tb[FRA_DST] == NULL ||
183 frh->dst_len > (ops->addr_size * 8) ||
184 nla_len(tb[FRA_DST]) != ops->addr_size)
185 goto errout;
186
187 err = 0;
188errout:
189 return err;
190}
191
Thomas Graf9d9e6a52007-03-25 23:20:05 -0700192static int fib_nl_newrule(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg)
Thomas Graf14c0b972006-08-04 03:38:38 -0700193{
194 struct fib_rule_hdr *frh = nlmsg_data(nlh);
195 struct fib_rules_ops *ops = NULL;
196 struct fib_rule *rule, *r, *last = NULL;
197 struct nlattr *tb[FRA_MAX+1];
Thomas Graf0947c9fe2007-03-26 17:14:15 -0700198 int err = -EINVAL, unresolved = 0;
Thomas Graf14c0b972006-08-04 03:38:38 -0700199
200 if (nlh->nlmsg_len < nlmsg_msg_size(sizeof(*frh)))
201 goto errout;
202
203 ops = lookup_rules_ops(frh->family);
204 if (ops == NULL) {
205 err = EAFNOSUPPORT;
206 goto errout;
207 }
208
209 err = nlmsg_parse(nlh, sizeof(*frh), tb, FRA_MAX, ops->policy);
210 if (err < 0)
211 goto errout;
212
Thomas Grafe1701c62007-03-24 12:46:02 -0700213 err = validate_rulemsg(frh, tb, ops);
214 if (err < 0)
215 goto errout;
216
Thomas Graf14c0b972006-08-04 03:38:38 -0700217 rule = kzalloc(ops->rule_size, GFP_KERNEL);
218 if (rule == NULL) {
219 err = -ENOMEM;
220 goto errout;
221 }
222
223 if (tb[FRA_PRIORITY])
224 rule->pref = nla_get_u32(tb[FRA_PRIORITY]);
225
226 if (tb[FRA_IFNAME]) {
227 struct net_device *dev;
228
229 rule->ifindex = -1;
Thomas Graf5176f912006-08-26 20:13:18 -0700230 nla_strlcpy(rule->ifname, tb[FRA_IFNAME], IFNAMSIZ);
Thomas Graf14c0b972006-08-04 03:38:38 -0700231 dev = __dev_get_by_name(rule->ifname);
232 if (dev)
233 rule->ifindex = dev->ifindex;
234 }
235
Thomas Grafb8964ed2006-11-09 15:22:18 -0800236 if (tb[FRA_FWMARK]) {
237 rule->mark = nla_get_u32(tb[FRA_FWMARK]);
238 if (rule->mark)
239 /* compatibility: if the mark value is non-zero all bits
240 * are compared unless a mask is explicitly specified.
241 */
242 rule->mark_mask = 0xFFFFFFFF;
243 }
244
245 if (tb[FRA_FWMASK])
246 rule->mark_mask = nla_get_u32(tb[FRA_FWMASK]);
247
Thomas Graf14c0b972006-08-04 03:38:38 -0700248 rule->action = frh->action;
249 rule->flags = frh->flags;
Patrick McHardy9e762a42006-08-10 23:09:48 -0700250 rule->table = frh_get_table(frh, tb);
Thomas Graf14c0b972006-08-04 03:38:38 -0700251
252 if (!rule->pref && ops->default_pref)
253 rule->pref = ops->default_pref();
254
Thomas Graf0947c9fe2007-03-26 17:14:15 -0700255 err = -EINVAL;
256 if (tb[FRA_GOTO]) {
257 if (rule->action != FR_ACT_GOTO)
258 goto errout_free;
259
260 rule->target = nla_get_u32(tb[FRA_GOTO]);
261 /* Backward jumps are prohibited to avoid endless loops */
262 if (rule->target <= rule->pref)
263 goto errout_free;
264
265 list_for_each_entry(r, ops->rules_list, list) {
266 if (r->pref == rule->target) {
267 rule->ctarget = r;
268 break;
269 }
270 }
271
272 if (rule->ctarget == NULL)
273 unresolved = 1;
274 } else if (rule->action == FR_ACT_GOTO)
275 goto errout_free;
276
Thomas Graf14c0b972006-08-04 03:38:38 -0700277 err = ops->configure(rule, skb, nlh, frh, tb);
278 if (err < 0)
279 goto errout_free;
280
281 list_for_each_entry(r, ops->rules_list, list) {
282 if (r->pref > rule->pref)
283 break;
284 last = r;
285 }
286
287 fib_rule_get(rule);
288
Thomas Graf0947c9fe2007-03-26 17:14:15 -0700289 if (ops->unresolved_rules) {
290 /*
291 * There are unresolved goto rules in the list, check if
292 * any of them are pointing to this new rule.
293 */
294 list_for_each_entry(r, ops->rules_list, list) {
295 if (r->action == FR_ACT_GOTO &&
296 r->target == rule->pref) {
297 BUG_ON(r->ctarget != NULL);
298 rcu_assign_pointer(r->ctarget, rule);
299 if (--ops->unresolved_rules == 0)
300 break;
301 }
302 }
303 }
304
305 if (rule->action == FR_ACT_GOTO)
306 ops->nr_goto_rules++;
307
308 if (unresolved)
309 ops->unresolved_rules++;
310
Thomas Graf14c0b972006-08-04 03:38:38 -0700311 if (last)
312 list_add_rcu(&rule->list, &last->list);
313 else
314 list_add_rcu(&rule->list, ops->rules_list);
315
Thomas Grafc17084d2006-08-15 00:32:48 -0700316 notify_rule_change(RTM_NEWRULE, rule, ops, nlh, NETLINK_CB(skb).pid);
Thomas Graf14c0b972006-08-04 03:38:38 -0700317 rules_ops_put(ops);
318 return 0;
319
320errout_free:
321 kfree(rule);
322errout:
323 rules_ops_put(ops);
324 return err;
325}
326
Thomas Graf9d9e6a52007-03-25 23:20:05 -0700327static int fib_nl_delrule(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg)
Thomas Graf14c0b972006-08-04 03:38:38 -0700328{
329 struct fib_rule_hdr *frh = nlmsg_data(nlh);
330 struct fib_rules_ops *ops = NULL;
Thomas Graf0947c9fe2007-03-26 17:14:15 -0700331 struct fib_rule *rule, *tmp;
Thomas Graf14c0b972006-08-04 03:38:38 -0700332 struct nlattr *tb[FRA_MAX+1];
333 int err = -EINVAL;
334
335 if (nlh->nlmsg_len < nlmsg_msg_size(sizeof(*frh)))
336 goto errout;
337
338 ops = lookup_rules_ops(frh->family);
339 if (ops == NULL) {
340 err = EAFNOSUPPORT;
341 goto errout;
342 }
343
344 err = nlmsg_parse(nlh, sizeof(*frh), tb, FRA_MAX, ops->policy);
345 if (err < 0)
346 goto errout;
347
Thomas Grafe1701c62007-03-24 12:46:02 -0700348 err = validate_rulemsg(frh, tb, ops);
349 if (err < 0)
350 goto errout;
351
Thomas Graf14c0b972006-08-04 03:38:38 -0700352 list_for_each_entry(rule, ops->rules_list, list) {
353 if (frh->action && (frh->action != rule->action))
354 continue;
355
Patrick McHardy9e762a42006-08-10 23:09:48 -0700356 if (frh->table && (frh_get_table(frh, tb) != rule->table))
Thomas Graf14c0b972006-08-04 03:38:38 -0700357 continue;
358
359 if (tb[FRA_PRIORITY] &&
360 (rule->pref != nla_get_u32(tb[FRA_PRIORITY])))
361 continue;
362
363 if (tb[FRA_IFNAME] &&
364 nla_strcmp(tb[FRA_IFNAME], rule->ifname))
365 continue;
366
Thomas Grafb8964ed2006-11-09 15:22:18 -0800367 if (tb[FRA_FWMARK] &&
368 (rule->mark != nla_get_u32(tb[FRA_FWMARK])))
369 continue;
370
371 if (tb[FRA_FWMASK] &&
372 (rule->mark_mask != nla_get_u32(tb[FRA_FWMASK])))
373 continue;
374
Thomas Graf14c0b972006-08-04 03:38:38 -0700375 if (!ops->compare(rule, frh, tb))
376 continue;
377
378 if (rule->flags & FIB_RULE_PERMANENT) {
379 err = -EPERM;
380 goto errout;
381 }
382
383 list_del_rcu(&rule->list);
Thomas Graf0947c9fe2007-03-26 17:14:15 -0700384
385 if (rule->action == FR_ACT_GOTO)
386 ops->nr_goto_rules--;
387
388 /*
389 * Check if this rule is a target to any of them. If so,
390 * disable them. As this operation is eventually very
391 * expensive, it is only performed if goto rules have
392 * actually been added.
393 */
394 if (ops->nr_goto_rules > 0) {
395 list_for_each_entry(tmp, ops->rules_list, list) {
396 if (tmp->ctarget == rule) {
397 rcu_assign_pointer(tmp->ctarget, NULL);
398 ops->unresolved_rules++;
399 }
400 }
401 }
402
Thomas Graf14c0b972006-08-04 03:38:38 -0700403 synchronize_rcu();
Thomas Grafc17084d2006-08-15 00:32:48 -0700404 notify_rule_change(RTM_DELRULE, rule, ops, nlh,
405 NETLINK_CB(skb).pid);
Thomas Graf14c0b972006-08-04 03:38:38 -0700406 fib_rule_put(rule);
407 rules_ops_put(ops);
408 return 0;
409 }
410
411 err = -ENOENT;
412errout:
413 rules_ops_put(ops);
414 return err;
415}
416
Thomas Graf339bf982006-11-10 14:10:15 -0800417static inline size_t fib_rule_nlmsg_size(struct fib_rules_ops *ops,
418 struct fib_rule *rule)
419{
420 size_t payload = NLMSG_ALIGN(sizeof(struct fib_rule_hdr))
421 + nla_total_size(IFNAMSIZ) /* FRA_IFNAME */
422 + nla_total_size(4) /* FRA_PRIORITY */
423 + nla_total_size(4) /* FRA_TABLE */
424 + nla_total_size(4) /* FRA_FWMARK */
425 + nla_total_size(4); /* FRA_FWMASK */
426
427 if (ops->nlmsg_payload)
428 payload += ops->nlmsg_payload(rule);
429
430 return payload;
431}
432
Thomas Graf14c0b972006-08-04 03:38:38 -0700433static int fib_nl_fill_rule(struct sk_buff *skb, struct fib_rule *rule,
434 u32 pid, u32 seq, int type, int flags,
435 struct fib_rules_ops *ops)
436{
437 struct nlmsghdr *nlh;
438 struct fib_rule_hdr *frh;
439
440 nlh = nlmsg_put(skb, pid, seq, type, sizeof(*frh), flags);
441 if (nlh == NULL)
Patrick McHardy26932562007-01-31 23:16:40 -0800442 return -EMSGSIZE;
Thomas Graf14c0b972006-08-04 03:38:38 -0700443
444 frh = nlmsg_data(nlh);
445 frh->table = rule->table;
Patrick McHardy9e762a42006-08-10 23:09:48 -0700446 NLA_PUT_U32(skb, FRA_TABLE, rule->table);
Thomas Graf14c0b972006-08-04 03:38:38 -0700447 frh->res1 = 0;
448 frh->res2 = 0;
449 frh->action = rule->action;
450 frh->flags = rule->flags;
451
Thomas Graf0947c9fe2007-03-26 17:14:15 -0700452 if (rule->action == FR_ACT_GOTO && rule->ctarget == NULL)
453 frh->flags |= FIB_RULE_UNRESOLVED;
454
Thomas Graf2b443682007-03-26 17:37:59 -0700455 if (rule->ifname[0]) {
Thomas Graf14c0b972006-08-04 03:38:38 -0700456 NLA_PUT_STRING(skb, FRA_IFNAME, rule->ifname);
457
Thomas Graf2b443682007-03-26 17:37:59 -0700458 if (rule->ifindex == -1)
459 frh->flags |= FIB_RULE_DEV_DETACHED;
460 }
461
Thomas Graf14c0b972006-08-04 03:38:38 -0700462 if (rule->pref)
463 NLA_PUT_U32(skb, FRA_PRIORITY, rule->pref);
464
Thomas Grafb8964ed2006-11-09 15:22:18 -0800465 if (rule->mark)
466 NLA_PUT_U32(skb, FRA_FWMARK, rule->mark);
467
468 if (rule->mark_mask || rule->mark)
469 NLA_PUT_U32(skb, FRA_FWMASK, rule->mark_mask);
470
Thomas Graf0947c9fe2007-03-26 17:14:15 -0700471 if (rule->target)
472 NLA_PUT_U32(skb, FRA_GOTO, rule->target);
473
Thomas Graf14c0b972006-08-04 03:38:38 -0700474 if (ops->fill(rule, skb, nlh, frh) < 0)
475 goto nla_put_failure;
476
477 return nlmsg_end(skb, nlh);
478
479nla_put_failure:
Patrick McHardy26932562007-01-31 23:16:40 -0800480 nlmsg_cancel(skb, nlh);
481 return -EMSGSIZE;
Thomas Graf14c0b972006-08-04 03:38:38 -0700482}
483
Thomas Grafc4546732007-03-25 23:24:24 -0700484static int dump_rules(struct sk_buff *skb, struct netlink_callback *cb,
485 struct fib_rules_ops *ops)
Thomas Graf14c0b972006-08-04 03:38:38 -0700486{
487 int idx = 0;
488 struct fib_rule *rule;
Thomas Graf14c0b972006-08-04 03:38:38 -0700489
490 rcu_read_lock();
Patrick McHardyec256152007-03-22 12:24:38 -0700491 list_for_each_entry_rcu(rule, ops->rules_list, list) {
Thomas Grafc4546732007-03-25 23:24:24 -0700492 if (idx < cb->args[1])
Thomas Graf14c0b972006-08-04 03:38:38 -0700493 goto skip;
494
495 if (fib_nl_fill_rule(skb, rule, NETLINK_CB(cb->skb).pid,
496 cb->nlh->nlmsg_seq, RTM_NEWRULE,
497 NLM_F_MULTI, ops) < 0)
498 break;
499skip:
500 idx++;
501 }
502 rcu_read_unlock();
Thomas Grafc4546732007-03-25 23:24:24 -0700503 cb->args[1] = idx;
Thomas Graf14c0b972006-08-04 03:38:38 -0700504 rules_ops_put(ops);
505
506 return skb->len;
507}
508
Thomas Grafc4546732007-03-25 23:24:24 -0700509static int fib_nl_dumprule(struct sk_buff *skb, struct netlink_callback *cb)
510{
511 struct fib_rules_ops *ops;
512 int idx = 0, family;
513
514 family = rtnl_msg_family(cb->nlh);
515 if (family != AF_UNSPEC) {
516 /* Protocol specific dump request */
517 ops = lookup_rules_ops(family);
518 if (ops == NULL)
519 return -EAFNOSUPPORT;
520
521 return dump_rules(skb, cb, ops);
522 }
523
524 rcu_read_lock();
525 list_for_each_entry_rcu(ops, &rules_ops, list) {
526 if (idx < cb->args[0] || !try_module_get(ops->owner))
527 goto skip;
528
529 if (dump_rules(skb, cb, ops) < 0)
530 break;
531
532 cb->args[1] = 0;
533 skip:
534 idx++;
535 }
536 rcu_read_unlock();
537 cb->args[0] = idx;
538
539 return skb->len;
540}
Thomas Graf14c0b972006-08-04 03:38:38 -0700541
542static void notify_rule_change(int event, struct fib_rule *rule,
Thomas Grafc17084d2006-08-15 00:32:48 -0700543 struct fib_rules_ops *ops, struct nlmsghdr *nlh,
544 u32 pid)
Thomas Graf14c0b972006-08-04 03:38:38 -0700545{
Thomas Grafc17084d2006-08-15 00:32:48 -0700546 struct sk_buff *skb;
547 int err = -ENOBUFS;
Thomas Graf14c0b972006-08-04 03:38:38 -0700548
Thomas Graf339bf982006-11-10 14:10:15 -0800549 skb = nlmsg_new(fib_rule_nlmsg_size(ops, rule), GFP_KERNEL);
Thomas Graf14c0b972006-08-04 03:38:38 -0700550 if (skb == NULL)
Thomas Grafc17084d2006-08-15 00:32:48 -0700551 goto errout;
552
553 err = fib_nl_fill_rule(skb, rule, pid, nlh->nlmsg_seq, event, 0, ops);
Patrick McHardy26932562007-01-31 23:16:40 -0800554 if (err < 0) {
555 /* -EMSGSIZE implies BUG in fib_rule_nlmsg_size() */
556 WARN_ON(err == -EMSGSIZE);
557 kfree_skb(skb);
558 goto errout;
559 }
Thomas Grafc17084d2006-08-15 00:32:48 -0700560 err = rtnl_notify(skb, pid, ops->nlgroup, nlh, GFP_KERNEL);
561errout:
562 if (err < 0)
563 rtnl_set_sk_err(ops->nlgroup, err);
Thomas Graf14c0b972006-08-04 03:38:38 -0700564}
565
566static void attach_rules(struct list_head *rules, struct net_device *dev)
567{
568 struct fib_rule *rule;
569
570 list_for_each_entry(rule, rules, list) {
571 if (rule->ifindex == -1 &&
572 strcmp(dev->name, rule->ifname) == 0)
573 rule->ifindex = dev->ifindex;
574 }
575}
576
577static void detach_rules(struct list_head *rules, struct net_device *dev)
578{
579 struct fib_rule *rule;
580
581 list_for_each_entry(rule, rules, list)
582 if (rule->ifindex == dev->ifindex)
583 rule->ifindex = -1;
584}
585
586
587static int fib_rules_event(struct notifier_block *this, unsigned long event,
588 void *ptr)
589{
590 struct net_device *dev = ptr;
591 struct fib_rules_ops *ops;
592
593 ASSERT_RTNL();
594 rcu_read_lock();
595
596 switch (event) {
597 case NETDEV_REGISTER:
598 list_for_each_entry(ops, &rules_ops, list)
599 attach_rules(ops->rules_list, dev);
600 break;
601
602 case NETDEV_UNREGISTER:
603 list_for_each_entry(ops, &rules_ops, list)
604 detach_rules(ops->rules_list, dev);
605 break;
606 }
607
608 rcu_read_unlock();
609
610 return NOTIFY_DONE;
611}
612
613static struct notifier_block fib_rules_notifier = {
614 .notifier_call = fib_rules_event,
615};
616
617static int __init fib_rules_init(void)
618{
Thomas Graf9d9e6a52007-03-25 23:20:05 -0700619 rtnl_register(PF_UNSPEC, RTM_NEWRULE, fib_nl_newrule, NULL);
620 rtnl_register(PF_UNSPEC, RTM_DELRULE, fib_nl_delrule, NULL);
Thomas Grafc4546732007-03-25 23:24:24 -0700621 rtnl_register(PF_UNSPEC, RTM_GETRULE, NULL, fib_nl_dumprule);
Thomas Graf9d9e6a52007-03-25 23:20:05 -0700622
Thomas Graf14c0b972006-08-04 03:38:38 -0700623 return register_netdevice_notifier(&fib_rules_notifier);
624}
625
626subsys_initcall(fib_rules_init);