Thomas Graf | 14c0b97 | 2006-08-04 03:38:38 -0700 | [diff] [blame] | 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 | |
Thomas Graf | 14c0b97 | 2006-08-04 03:38:38 -0700 | [diff] [blame] | 11 | #include <linux/types.h> |
| 12 | #include <linux/kernel.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 13 | #include <linux/slab.h> |
Thomas Graf | 14c0b97 | 2006-08-04 03:38:38 -0700 | [diff] [blame] | 14 | #include <linux/list.h> |
Paul Gortmaker | 3a9a231 | 2011-05-27 09:12:25 -0400 | [diff] [blame] | 15 | #include <linux/module.h> |
Eric W. Biederman | e9dc865 | 2007-09-12 13:02:17 +0200 | [diff] [blame] | 16 | #include <net/net_namespace.h> |
Eric W. Biederman | 881d966 | 2007-09-17 11:56:21 -0700 | [diff] [blame] | 17 | #include <net/sock.h> |
Thomas Graf | 14c0b97 | 2006-08-04 03:38:38 -0700 | [diff] [blame] | 18 | #include <net/fib_rules.h> |
Thomas Graf | e703087 | 2015-07-21 10:44:01 +0200 | [diff] [blame] | 19 | #include <net/ip_tunnels.h> |
Thomas Graf | 14c0b97 | 2006-08-04 03:38:38 -0700 | [diff] [blame] | 20 | |
Denis V. Lunev | 2994c63 | 2007-11-10 22:12:03 -0800 | [diff] [blame] | 21 | int fib_default_rule_add(struct fib_rules_ops *ops, |
| 22 | u32 pref, u32 table, u32 flags) |
| 23 | { |
| 24 | struct fib_rule *r; |
| 25 | |
| 26 | r = kzalloc(ops->rule_size, GFP_KERNEL); |
| 27 | if (r == NULL) |
| 28 | return -ENOMEM; |
| 29 | |
| 30 | atomic_set(&r->refcnt, 1); |
| 31 | r->action = FR_ACT_TO_TBL; |
| 32 | r->pref = pref; |
| 33 | r->table = table; |
| 34 | r->flags = flags; |
Eric W. Biederman | efd7ef1 | 2015-03-11 23:04:08 -0500 | [diff] [blame] | 35 | r->fr_net = ops->fro_net; |
Lorenzo Colitti | 8dc318f | 2014-03-31 16:23:51 +0900 | [diff] [blame] | 36 | r->uid_start = INVALID_UID; |
| 37 | r->uid_end = INVALID_UID; |
Denis V. Lunev | 2994c63 | 2007-11-10 22:12:03 -0800 | [diff] [blame] | 38 | |
Stefan Tomanek | 73f5698 | 2013-08-03 14:14:43 +0200 | [diff] [blame] | 39 | r->suppress_prefixlen = -1; |
| 40 | r->suppress_ifgroup = -1; |
| 41 | |
Denis V. Lunev | 2994c63 | 2007-11-10 22:12:03 -0800 | [diff] [blame] | 42 | /* The lock is not required here, the list in unreacheable |
| 43 | * at the moment this function is called */ |
| 44 | list_add_tail(&r->list, &ops->rules_list); |
| 45 | return 0; |
| 46 | } |
| 47 | EXPORT_SYMBOL(fib_default_rule_add); |
| 48 | |
Phil Sutter | f53de1e | 2015-09-09 14:20:56 +0200 | [diff] [blame] | 49 | static u32 fib_default_rule_pref(struct fib_rules_ops *ops) |
Patrick McHardy | d8a566b | 2010-04-13 05:03:15 +0000 | [diff] [blame] | 50 | { |
| 51 | struct list_head *pos; |
| 52 | struct fib_rule *rule; |
| 53 | |
| 54 | if (!list_empty(&ops->rules_list)) { |
| 55 | pos = ops->rules_list.next; |
| 56 | if (pos->next != &ops->rules_list) { |
| 57 | rule = list_entry(pos->next, struct fib_rule, list); |
| 58 | if (rule->pref) |
| 59 | return rule->pref - 1; |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | return 0; |
| 64 | } |
Patrick McHardy | d8a566b | 2010-04-13 05:03:15 +0000 | [diff] [blame] | 65 | |
Denis V. Lunev | 9e3a548 | 2008-01-20 16:46:41 -0800 | [diff] [blame] | 66 | static void notify_rule_change(int event, struct fib_rule *rule, |
Thomas Graf | c17084d | 2006-08-15 00:32:48 -0700 | [diff] [blame] | 67 | struct fib_rules_ops *ops, struct nlmsghdr *nlh, |
| 68 | u32 pid); |
Thomas Graf | 14c0b97 | 2006-08-04 03:38:38 -0700 | [diff] [blame] | 69 | |
Denis V. Lunev | 5fd30ee | 2008-01-10 03:20:28 -0800 | [diff] [blame] | 70 | static struct fib_rules_ops *lookup_rules_ops(struct net *net, int family) |
Thomas Graf | 14c0b97 | 2006-08-04 03:38:38 -0700 | [diff] [blame] | 71 | { |
| 72 | struct fib_rules_ops *ops; |
| 73 | |
| 74 | rcu_read_lock(); |
Denis V. Lunev | 5fd30ee | 2008-01-10 03:20:28 -0800 | [diff] [blame] | 75 | list_for_each_entry_rcu(ops, &net->rules_ops, list) { |
Thomas Graf | 14c0b97 | 2006-08-04 03:38:38 -0700 | [diff] [blame] | 76 | if (ops->family == family) { |
| 77 | if (!try_module_get(ops->owner)) |
| 78 | ops = NULL; |
| 79 | rcu_read_unlock(); |
| 80 | return ops; |
| 81 | } |
| 82 | } |
| 83 | rcu_read_unlock(); |
| 84 | |
| 85 | return NULL; |
| 86 | } |
| 87 | |
| 88 | static void rules_ops_put(struct fib_rules_ops *ops) |
| 89 | { |
| 90 | if (ops) |
| 91 | module_put(ops->owner); |
| 92 | } |
| 93 | |
Thomas Graf | 73417f6 | 2007-03-27 13:56:52 -0700 | [diff] [blame] | 94 | static void flush_route_cache(struct fib_rules_ops *ops) |
| 95 | { |
| 96 | if (ops->flush_cache) |
Denis V. Lunev | ae299fc | 2008-07-05 19:01:28 -0700 | [diff] [blame] | 97 | ops->flush_cache(ops); |
Thomas Graf | 73417f6 | 2007-03-27 13:56:52 -0700 | [diff] [blame] | 98 | } |
| 99 | |
Eric W. Biederman | e9c5158 | 2009-12-03 12:22:55 -0800 | [diff] [blame] | 100 | static int __fib_rules_register(struct fib_rules_ops *ops) |
Thomas Graf | 14c0b97 | 2006-08-04 03:38:38 -0700 | [diff] [blame] | 101 | { |
| 102 | int err = -EEXIST; |
| 103 | struct fib_rules_ops *o; |
Denis V. Lunev | 9e3a548 | 2008-01-20 16:46:41 -0800 | [diff] [blame] | 104 | struct net *net; |
| 105 | |
| 106 | net = ops->fro_net; |
Thomas Graf | 14c0b97 | 2006-08-04 03:38:38 -0700 | [diff] [blame] | 107 | |
| 108 | if (ops->rule_size < sizeof(struct fib_rule)) |
| 109 | return -EINVAL; |
| 110 | |
| 111 | if (ops->match == NULL || ops->configure == NULL || |
| 112 | ops->compare == NULL || ops->fill == NULL || |
| 113 | ops->action == NULL) |
| 114 | return -EINVAL; |
| 115 | |
Denis V. Lunev | 5fd30ee | 2008-01-10 03:20:28 -0800 | [diff] [blame] | 116 | spin_lock(&net->rules_mod_lock); |
| 117 | list_for_each_entry(o, &net->rules_ops, list) |
Thomas Graf | 14c0b97 | 2006-08-04 03:38:38 -0700 | [diff] [blame] | 118 | if (ops->family == o->family) |
| 119 | goto errout; |
| 120 | |
Denis V. Lunev | 5fd30ee | 2008-01-10 03:20:28 -0800 | [diff] [blame] | 121 | list_add_tail_rcu(&ops->list, &net->rules_ops); |
Thomas Graf | 14c0b97 | 2006-08-04 03:38:38 -0700 | [diff] [blame] | 122 | err = 0; |
| 123 | errout: |
Denis V. Lunev | 5fd30ee | 2008-01-10 03:20:28 -0800 | [diff] [blame] | 124 | spin_unlock(&net->rules_mod_lock); |
Thomas Graf | 14c0b97 | 2006-08-04 03:38:38 -0700 | [diff] [blame] | 125 | |
| 126 | return err; |
| 127 | } |
| 128 | |
Eric W. Biederman | e9c5158 | 2009-12-03 12:22:55 -0800 | [diff] [blame] | 129 | struct fib_rules_ops * |
Patrick McHardy | 3d0c9c4 | 2010-04-26 16:02:04 +0200 | [diff] [blame] | 130 | fib_rules_register(const struct fib_rules_ops *tmpl, struct net *net) |
Eric W. Biederman | e9c5158 | 2009-12-03 12:22:55 -0800 | [diff] [blame] | 131 | { |
| 132 | struct fib_rules_ops *ops; |
| 133 | int err; |
| 134 | |
Eric Dumazet | 2fb3573 | 2010-03-09 20:03:38 +0000 | [diff] [blame] | 135 | ops = kmemdup(tmpl, sizeof(*ops), GFP_KERNEL); |
Eric W. Biederman | e9c5158 | 2009-12-03 12:22:55 -0800 | [diff] [blame] | 136 | if (ops == NULL) |
| 137 | return ERR_PTR(-ENOMEM); |
| 138 | |
| 139 | INIT_LIST_HEAD(&ops->rules_list); |
| 140 | ops->fro_net = net; |
| 141 | |
| 142 | err = __fib_rules_register(ops); |
| 143 | if (err) { |
| 144 | kfree(ops); |
| 145 | ops = ERR_PTR(err); |
| 146 | } |
| 147 | |
| 148 | return ops; |
| 149 | } |
Thomas Graf | 14c0b97 | 2006-08-04 03:38:38 -0700 | [diff] [blame] | 150 | EXPORT_SYMBOL_GPL(fib_rules_register); |
| 151 | |
stephen hemminger | 1df9916 | 2010-10-04 20:14:17 +0000 | [diff] [blame] | 152 | static void fib_rules_cleanup_ops(struct fib_rules_ops *ops) |
Thomas Graf | 14c0b97 | 2006-08-04 03:38:38 -0700 | [diff] [blame] | 153 | { |
| 154 | struct fib_rule *rule, *tmp; |
| 155 | |
Denis V. Lunev | 76c72d4 | 2007-09-16 15:44:27 -0700 | [diff] [blame] | 156 | list_for_each_entry_safe(rule, tmp, &ops->rules_list, list) { |
Thomas Graf | 14c0b97 | 2006-08-04 03:38:38 -0700 | [diff] [blame] | 157 | list_del_rcu(&rule->list); |
David S. Miller | 7a9bc9b | 2012-06-29 01:32:45 -0700 | [diff] [blame] | 158 | if (ops->delete) |
| 159 | ops->delete(rule); |
Thomas Graf | 14c0b97 | 2006-08-04 03:38:38 -0700 | [diff] [blame] | 160 | fib_rule_put(rule); |
| 161 | } |
| 162 | } |
| 163 | |
Denis V. Lunev | 9e3a548 | 2008-01-20 16:46:41 -0800 | [diff] [blame] | 164 | void fib_rules_unregister(struct fib_rules_ops *ops) |
Thomas Graf | 14c0b97 | 2006-08-04 03:38:38 -0700 | [diff] [blame] | 165 | { |
Denis V. Lunev | 9e3a548 | 2008-01-20 16:46:41 -0800 | [diff] [blame] | 166 | struct net *net = ops->fro_net; |
Thomas Graf | 14c0b97 | 2006-08-04 03:38:38 -0700 | [diff] [blame] | 167 | |
Denis V. Lunev | 5fd30ee | 2008-01-10 03:20:28 -0800 | [diff] [blame] | 168 | spin_lock(&net->rules_mod_lock); |
Denis V. Lunev | 72132c1b | 2008-01-14 22:59:30 -0800 | [diff] [blame] | 169 | list_del_rcu(&ops->list); |
Denis V. Lunev | 5fd30ee | 2008-01-10 03:20:28 -0800 | [diff] [blame] | 170 | spin_unlock(&net->rules_mod_lock); |
Thomas Graf | 14c0b97 | 2006-08-04 03:38:38 -0700 | [diff] [blame] | 171 | |
WANG Cong | 419df12 | 2015-03-31 11:01:46 -0700 | [diff] [blame] | 172 | fib_rules_cleanup_ops(ops); |
Eric W. Biederman | efd7ef1 | 2015-03-11 23:04:08 -0500 | [diff] [blame] | 173 | kfree_rcu(ops, rcu); |
Thomas Graf | 14c0b97 | 2006-08-04 03:38:38 -0700 | [diff] [blame] | 174 | } |
Thomas Graf | 14c0b97 | 2006-08-04 03:38:38 -0700 | [diff] [blame] | 175 | EXPORT_SYMBOL_GPL(fib_rules_unregister); |
| 176 | |
Lorenzo Colitti | 8dc318f | 2014-03-31 16:23:51 +0900 | [diff] [blame] | 177 | static inline kuid_t fib_nl_uid(struct nlattr *nla) |
| 178 | { |
| 179 | return make_kuid(current_user_ns(), nla_get_u32(nla)); |
| 180 | } |
| 181 | |
| 182 | static int nla_put_uid(struct sk_buff *skb, int idx, kuid_t uid) |
| 183 | { |
| 184 | return nla_put_u32(skb, idx, from_kuid_munged(current_user_ns(), uid)); |
| 185 | } |
| 186 | |
| 187 | static int fib_uid_range_match(struct flowi *fl, struct fib_rule *rule) |
| 188 | { |
| 189 | return (!uid_valid(rule->uid_start) && !uid_valid(rule->uid_end)) || |
| 190 | (uid_gte(fl->flowi_uid, rule->uid_start) && |
| 191 | uid_lte(fl->flowi_uid, rule->uid_end)); |
| 192 | } |
| 193 | |
Thomas Graf | 3dfbcc4 | 2006-11-09 15:23:20 -0800 | [diff] [blame] | 194 | static int fib_rule_match(struct fib_rule *rule, struct fib_rules_ops *ops, |
David Ahern | 96c63fa | 2016-06-08 10:55:39 -0700 | [diff] [blame] | 195 | struct flowi *fl, int flags, |
| 196 | struct fib_lookup_arg *arg) |
Thomas Graf | 3dfbcc4 | 2006-11-09 15:23:20 -0800 | [diff] [blame] | 197 | { |
| 198 | int ret = 0; |
| 199 | |
David S. Miller | 1d28f42 | 2011-03-12 00:29:39 -0500 | [diff] [blame] | 200 | if (rule->iifindex && (rule->iifindex != fl->flowi_iif)) |
Thomas Graf | 3dfbcc4 | 2006-11-09 15:23:20 -0800 | [diff] [blame] | 201 | goto out; |
| 202 | |
David S. Miller | 1d28f42 | 2011-03-12 00:29:39 -0500 | [diff] [blame] | 203 | if (rule->oifindex && (rule->oifindex != fl->flowi_oif)) |
Patrick McHardy | 1b038a5 | 2009-12-03 01:25:56 +0000 | [diff] [blame] | 204 | goto out; |
| 205 | |
David S. Miller | 1d28f42 | 2011-03-12 00:29:39 -0500 | [diff] [blame] | 206 | if ((rule->mark ^ fl->flowi_mark) & rule->mark_mask) |
Thomas Graf | 3dfbcc4 | 2006-11-09 15:23:20 -0800 | [diff] [blame] | 207 | goto out; |
| 208 | |
Thomas Graf | e703087 | 2015-07-21 10:44:01 +0200 | [diff] [blame] | 209 | if (rule->tun_id && (rule->tun_id != fl->flowi_tun_key.tun_id)) |
| 210 | goto out; |
| 211 | |
David Ahern | 96c63fa | 2016-06-08 10:55:39 -0700 | [diff] [blame] | 212 | if (rule->l3mdev && !l3mdev_fib_rule_match(rule->fr_net, fl, arg)) |
| 213 | goto out; |
| 214 | |
Lorenzo Colitti | 8dc318f | 2014-03-31 16:23:51 +0900 | [diff] [blame] | 215 | if (!fib_uid_range_match(fl, rule)) |
| 216 | goto out; |
| 217 | |
Thomas Graf | 3dfbcc4 | 2006-11-09 15:23:20 -0800 | [diff] [blame] | 218 | ret = ops->match(rule, fl, flags); |
| 219 | out: |
| 220 | return (rule->flags & FIB_RULE_INVERT) ? !ret : ret; |
| 221 | } |
| 222 | |
Thomas Graf | 14c0b97 | 2006-08-04 03:38:38 -0700 | [diff] [blame] | 223 | int fib_rules_lookup(struct fib_rules_ops *ops, struct flowi *fl, |
| 224 | int flags, struct fib_lookup_arg *arg) |
| 225 | { |
| 226 | struct fib_rule *rule; |
| 227 | int err; |
| 228 | |
| 229 | rcu_read_lock(); |
| 230 | |
Denis V. Lunev | 76c72d4 | 2007-09-16 15:44:27 -0700 | [diff] [blame] | 231 | list_for_each_entry_rcu(rule, &ops->rules_list, list) { |
Thomas Graf | 0947c9fe | 2007-03-26 17:14:15 -0700 | [diff] [blame] | 232 | jumped: |
David Ahern | 96c63fa | 2016-06-08 10:55:39 -0700 | [diff] [blame] | 233 | if (!fib_rule_match(rule, ops, fl, flags, arg)) |
Thomas Graf | 14c0b97 | 2006-08-04 03:38:38 -0700 | [diff] [blame] | 234 | continue; |
| 235 | |
Thomas Graf | 0947c9fe | 2007-03-26 17:14:15 -0700 | [diff] [blame] | 236 | if (rule->action == FR_ACT_GOTO) { |
| 237 | struct fib_rule *target; |
| 238 | |
| 239 | target = rcu_dereference(rule->ctarget); |
| 240 | if (target == NULL) { |
| 241 | continue; |
| 242 | } else { |
| 243 | rule = target; |
| 244 | goto jumped; |
| 245 | } |
Thomas Graf | fa0b2d1 | 2007-03-26 17:38:53 -0700 | [diff] [blame] | 246 | } else if (rule->action == FR_ACT_NOP) |
| 247 | continue; |
| 248 | else |
Thomas Graf | 0947c9fe | 2007-03-26 17:14:15 -0700 | [diff] [blame] | 249 | err = ops->action(rule, fl, flags, arg); |
| 250 | |
Stefan Tomanek | 7764a45 | 2013-08-01 02:17:15 +0200 | [diff] [blame] | 251 | if (!err && ops->suppress && ops->suppress(rule, arg)) |
| 252 | continue; |
| 253 | |
Thomas Graf | 14c0b97 | 2006-08-04 03:38:38 -0700 | [diff] [blame] | 254 | if (err != -EAGAIN) { |
Eric Dumazet | ebc0ffa | 2010-10-05 10:41:36 +0000 | [diff] [blame] | 255 | if ((arg->flags & FIB_LOOKUP_NOREF) || |
| 256 | likely(atomic_inc_not_zero(&rule->refcnt))) { |
Eric Dumazet | 7fa7cb7 | 2010-09-27 04:18:27 +0000 | [diff] [blame] | 257 | arg->rule = rule; |
| 258 | goto out; |
| 259 | } |
| 260 | break; |
Thomas Graf | 14c0b97 | 2006-08-04 03:38:38 -0700 | [diff] [blame] | 261 | } |
| 262 | } |
| 263 | |
Steven Whitehouse | 83886b6 | 2007-03-30 13:34:27 -0700 | [diff] [blame] | 264 | err = -ESRCH; |
Thomas Graf | 14c0b97 | 2006-08-04 03:38:38 -0700 | [diff] [blame] | 265 | out: |
| 266 | rcu_read_unlock(); |
| 267 | |
| 268 | return err; |
| 269 | } |
Thomas Graf | 14c0b97 | 2006-08-04 03:38:38 -0700 | [diff] [blame] | 270 | EXPORT_SYMBOL_GPL(fib_rules_lookup); |
| 271 | |
Thomas Graf | e1701c6 | 2007-03-24 12:46:02 -0700 | [diff] [blame] | 272 | static int validate_rulemsg(struct fib_rule_hdr *frh, struct nlattr **tb, |
| 273 | struct fib_rules_ops *ops) |
| 274 | { |
| 275 | int err = -EINVAL; |
| 276 | |
| 277 | if (frh->src_len) |
| 278 | if (tb[FRA_SRC] == NULL || |
| 279 | frh->src_len > (ops->addr_size * 8) || |
| 280 | nla_len(tb[FRA_SRC]) != ops->addr_size) |
| 281 | goto errout; |
| 282 | |
| 283 | if (frh->dst_len) |
| 284 | if (tb[FRA_DST] == NULL || |
| 285 | frh->dst_len > (ops->addr_size * 8) || |
| 286 | nla_len(tb[FRA_DST]) != ops->addr_size) |
| 287 | goto errout; |
| 288 | |
| 289 | err = 0; |
| 290 | errout: |
| 291 | return err; |
| 292 | } |
| 293 | |
Mateusz Bajorski | 153380e | 2016-06-29 09:22:10 +0200 | [diff] [blame] | 294 | static int rule_exists(struct fib_rules_ops *ops, struct fib_rule_hdr *frh, |
| 295 | struct nlattr **tb, struct fib_rule *rule) |
| 296 | { |
| 297 | struct fib_rule *r; |
| 298 | |
| 299 | list_for_each_entry(r, &ops->rules_list, list) { |
| 300 | if (r->action != rule->action) |
| 301 | continue; |
| 302 | |
| 303 | if (r->table != rule->table) |
| 304 | continue; |
| 305 | |
| 306 | if (r->pref != rule->pref) |
| 307 | continue; |
| 308 | |
| 309 | if (memcmp(r->iifname, rule->iifname, IFNAMSIZ)) |
| 310 | continue; |
| 311 | |
| 312 | if (memcmp(r->oifname, rule->oifname, IFNAMSIZ)) |
| 313 | continue; |
| 314 | |
| 315 | if (r->mark != rule->mark) |
| 316 | continue; |
| 317 | |
| 318 | if (r->mark_mask != rule->mark_mask) |
| 319 | continue; |
| 320 | |
| 321 | if (r->tun_id != rule->tun_id) |
| 322 | continue; |
| 323 | |
| 324 | if (r->fr_net != rule->fr_net) |
| 325 | continue; |
| 326 | |
| 327 | if (r->l3mdev != rule->l3mdev) |
| 328 | continue; |
| 329 | |
| 330 | if (!ops->compare(r, frh, tb)) |
| 331 | continue; |
| 332 | return 1; |
| 333 | } |
| 334 | return 0; |
| 335 | } |
| 336 | |
David Ahern | 96c63fa | 2016-06-08 10:55:39 -0700 | [diff] [blame] | 337 | int fib_nl_newrule(struct sk_buff *skb, struct nlmsghdr *nlh) |
Thomas Graf | 14c0b97 | 2006-08-04 03:38:38 -0700 | [diff] [blame] | 338 | { |
YOSHIFUJI Hideaki | 3b1e0a6 | 2008-03-26 02:26:21 +0900 | [diff] [blame] | 339 | struct net *net = sock_net(skb->sk); |
Thomas Graf | 14c0b97 | 2006-08-04 03:38:38 -0700 | [diff] [blame] | 340 | struct fib_rule_hdr *frh = nlmsg_data(nlh); |
| 341 | struct fib_rules_ops *ops = NULL; |
| 342 | struct fib_rule *rule, *r, *last = NULL; |
| 343 | struct nlattr *tb[FRA_MAX+1]; |
Thomas Graf | 0947c9fe | 2007-03-26 17:14:15 -0700 | [diff] [blame] | 344 | int err = -EINVAL, unresolved = 0; |
Thomas Graf | 14c0b97 | 2006-08-04 03:38:38 -0700 | [diff] [blame] | 345 | |
| 346 | if (nlh->nlmsg_len < nlmsg_msg_size(sizeof(*frh))) |
| 347 | goto errout; |
| 348 | |
Denis V. Lunev | 5fd30ee | 2008-01-10 03:20:28 -0800 | [diff] [blame] | 349 | ops = lookup_rules_ops(net, frh->family); |
Thomas Graf | 14c0b97 | 2006-08-04 03:38:38 -0700 | [diff] [blame] | 350 | if (ops == NULL) { |
Patrick McHardy | 2fe195c | 2008-07-01 19:59:37 -0700 | [diff] [blame] | 351 | err = -EAFNOSUPPORT; |
Thomas Graf | 14c0b97 | 2006-08-04 03:38:38 -0700 | [diff] [blame] | 352 | goto errout; |
| 353 | } |
| 354 | |
| 355 | err = nlmsg_parse(nlh, sizeof(*frh), tb, FRA_MAX, ops->policy); |
| 356 | if (err < 0) |
| 357 | goto errout; |
| 358 | |
Thomas Graf | e1701c6 | 2007-03-24 12:46:02 -0700 | [diff] [blame] | 359 | err = validate_rulemsg(frh, tb, ops); |
| 360 | if (err < 0) |
| 361 | goto errout; |
| 362 | |
Thomas Graf | 14c0b97 | 2006-08-04 03:38:38 -0700 | [diff] [blame] | 363 | rule = kzalloc(ops->rule_size, GFP_KERNEL); |
| 364 | if (rule == NULL) { |
| 365 | err = -ENOMEM; |
| 366 | goto errout; |
| 367 | } |
Eric W. Biederman | efd7ef1 | 2015-03-11 23:04:08 -0500 | [diff] [blame] | 368 | rule->fr_net = net; |
Thomas Graf | 14c0b97 | 2006-08-04 03:38:38 -0700 | [diff] [blame] | 369 | |
Phil Sutter | f53de1e | 2015-09-09 14:20:56 +0200 | [diff] [blame] | 370 | rule->pref = tb[FRA_PRIORITY] ? nla_get_u32(tb[FRA_PRIORITY]) |
| 371 | : fib_default_rule_pref(ops); |
Thomas Graf | 14c0b97 | 2006-08-04 03:38:38 -0700 | [diff] [blame] | 372 | |
Patrick McHardy | 491deb24b | 2009-12-03 01:25:54 +0000 | [diff] [blame] | 373 | if (tb[FRA_IIFNAME]) { |
Thomas Graf | 14c0b97 | 2006-08-04 03:38:38 -0700 | [diff] [blame] | 374 | struct net_device *dev; |
| 375 | |
Patrick McHardy | 491deb24b | 2009-12-03 01:25:54 +0000 | [diff] [blame] | 376 | rule->iifindex = -1; |
| 377 | nla_strlcpy(rule->iifname, tb[FRA_IIFNAME], IFNAMSIZ); |
| 378 | dev = __dev_get_by_name(net, rule->iifname); |
Thomas Graf | 14c0b97 | 2006-08-04 03:38:38 -0700 | [diff] [blame] | 379 | if (dev) |
Patrick McHardy | 491deb24b | 2009-12-03 01:25:54 +0000 | [diff] [blame] | 380 | rule->iifindex = dev->ifindex; |
Thomas Graf | 14c0b97 | 2006-08-04 03:38:38 -0700 | [diff] [blame] | 381 | } |
| 382 | |
Patrick McHardy | 1b038a5 | 2009-12-03 01:25:56 +0000 | [diff] [blame] | 383 | if (tb[FRA_OIFNAME]) { |
| 384 | struct net_device *dev; |
| 385 | |
| 386 | rule->oifindex = -1; |
| 387 | nla_strlcpy(rule->oifname, tb[FRA_OIFNAME], IFNAMSIZ); |
| 388 | dev = __dev_get_by_name(net, rule->oifname); |
| 389 | if (dev) |
| 390 | rule->oifindex = dev->ifindex; |
| 391 | } |
| 392 | |
Thomas Graf | b8964ed | 2006-11-09 15:22:18 -0800 | [diff] [blame] | 393 | if (tb[FRA_FWMARK]) { |
| 394 | rule->mark = nla_get_u32(tb[FRA_FWMARK]); |
| 395 | if (rule->mark) |
| 396 | /* compatibility: if the mark value is non-zero all bits |
| 397 | * are compared unless a mask is explicitly specified. |
| 398 | */ |
| 399 | rule->mark_mask = 0xFFFFFFFF; |
| 400 | } |
| 401 | |
| 402 | if (tb[FRA_FWMASK]) |
| 403 | rule->mark_mask = nla_get_u32(tb[FRA_FWMASK]); |
| 404 | |
Thomas Graf | e703087 | 2015-07-21 10:44:01 +0200 | [diff] [blame] | 405 | if (tb[FRA_TUN_ID]) |
| 406 | rule->tun_id = nla_get_be64(tb[FRA_TUN_ID]); |
| 407 | |
David Ahern | 96c63fa | 2016-06-08 10:55:39 -0700 | [diff] [blame] | 408 | if (tb[FRA_L3MDEV]) { |
| 409 | #ifdef CONFIG_NET_L3_MASTER_DEV |
| 410 | rule->l3mdev = nla_get_u8(tb[FRA_L3MDEV]); |
| 411 | if (rule->l3mdev != 1) |
| 412 | #endif |
| 413 | goto errout_free; |
| 414 | } |
| 415 | |
Thomas Graf | 14c0b97 | 2006-08-04 03:38:38 -0700 | [diff] [blame] | 416 | rule->action = frh->action; |
| 417 | rule->flags = frh->flags; |
Patrick McHardy | 9e762a4 | 2006-08-10 23:09:48 -0700 | [diff] [blame] | 418 | rule->table = frh_get_table(frh, tb); |
Stefan Tomanek | 73f5698 | 2013-08-03 14:14:43 +0200 | [diff] [blame] | 419 | if (tb[FRA_SUPPRESS_PREFIXLEN]) |
| 420 | rule->suppress_prefixlen = nla_get_u32(tb[FRA_SUPPRESS_PREFIXLEN]); |
| 421 | else |
| 422 | rule->suppress_prefixlen = -1; |
Thomas Graf | 14c0b97 | 2006-08-04 03:38:38 -0700 | [diff] [blame] | 423 | |
Stefan Tomanek | 6ef94cf | 2013-08-02 17:19:56 +0200 | [diff] [blame] | 424 | if (tb[FRA_SUPPRESS_IFGROUP]) |
| 425 | rule->suppress_ifgroup = nla_get_u32(tb[FRA_SUPPRESS_IFGROUP]); |
Stefan Tomanek | 73f5698 | 2013-08-03 14:14:43 +0200 | [diff] [blame] | 426 | else |
| 427 | rule->suppress_ifgroup = -1; |
Stefan Tomanek | 6ef94cf | 2013-08-02 17:19:56 +0200 | [diff] [blame] | 428 | |
Thomas Graf | 0947c9fe | 2007-03-26 17:14:15 -0700 | [diff] [blame] | 429 | err = -EINVAL; |
| 430 | if (tb[FRA_GOTO]) { |
| 431 | if (rule->action != FR_ACT_GOTO) |
| 432 | goto errout_free; |
| 433 | |
| 434 | rule->target = nla_get_u32(tb[FRA_GOTO]); |
| 435 | /* Backward jumps are prohibited to avoid endless loops */ |
| 436 | if (rule->target <= rule->pref) |
| 437 | goto errout_free; |
| 438 | |
Denis V. Lunev | 76c72d4 | 2007-09-16 15:44:27 -0700 | [diff] [blame] | 439 | list_for_each_entry(r, &ops->rules_list, list) { |
Thomas Graf | 0947c9fe | 2007-03-26 17:14:15 -0700 | [diff] [blame] | 440 | if (r->pref == rule->target) { |
Eric Dumazet | 7a2b03c | 2010-10-26 09:24:55 +0000 | [diff] [blame] | 441 | RCU_INIT_POINTER(rule->ctarget, r); |
Thomas Graf | 0947c9fe | 2007-03-26 17:14:15 -0700 | [diff] [blame] | 442 | break; |
| 443 | } |
| 444 | } |
| 445 | |
Eric Dumazet | 7a2b03c | 2010-10-26 09:24:55 +0000 | [diff] [blame] | 446 | if (rcu_dereference_protected(rule->ctarget, 1) == NULL) |
Thomas Graf | 0947c9fe | 2007-03-26 17:14:15 -0700 | [diff] [blame] | 447 | unresolved = 1; |
| 448 | } else if (rule->action == FR_ACT_GOTO) |
| 449 | goto errout_free; |
| 450 | |
David Ahern | 96c63fa | 2016-06-08 10:55:39 -0700 | [diff] [blame] | 451 | if (rule->l3mdev && rule->table) |
| 452 | goto errout_free; |
| 453 | |
Mateusz Bajorski | 153380e | 2016-06-29 09:22:10 +0200 | [diff] [blame] | 454 | if ((nlh->nlmsg_flags & NLM_F_EXCL) && |
| 455 | rule_exists(ops, frh, tb, rule)) { |
| 456 | err = -EEXIST; |
| 457 | goto errout_free; |
| 458 | } |
| 459 | |
Lorenzo Colitti | 8dc318f | 2014-03-31 16:23:51 +0900 | [diff] [blame] | 460 | /* UID start and end must either both be valid or both unspecified. */ |
| 461 | rule->uid_start = rule->uid_end = INVALID_UID; |
| 462 | if (tb[FRA_UID_START] || tb[FRA_UID_END]) { |
| 463 | if (tb[FRA_UID_START] && tb[FRA_UID_END]) { |
| 464 | rule->uid_start = fib_nl_uid(tb[FRA_UID_START]); |
| 465 | rule->uid_end = fib_nl_uid(tb[FRA_UID_END]); |
| 466 | } |
| 467 | if (!uid_valid(rule->uid_start) || |
| 468 | !uid_valid(rule->uid_end) || |
| 469 | !uid_lte(rule->uid_start, rule->uid_end)) |
| 470 | goto errout_free; |
| 471 | } |
| 472 | |
Rami Rosen | 8b3521e | 2009-05-11 05:52:49 +0000 | [diff] [blame] | 473 | err = ops->configure(rule, skb, frh, tb); |
Thomas Graf | 14c0b97 | 2006-08-04 03:38:38 -0700 | [diff] [blame] | 474 | if (err < 0) |
| 475 | goto errout_free; |
| 476 | |
Denis V. Lunev | 76c72d4 | 2007-09-16 15:44:27 -0700 | [diff] [blame] | 477 | list_for_each_entry(r, &ops->rules_list, list) { |
Thomas Graf | 14c0b97 | 2006-08-04 03:38:38 -0700 | [diff] [blame] | 478 | if (r->pref > rule->pref) |
| 479 | break; |
| 480 | last = r; |
| 481 | } |
| 482 | |
| 483 | fib_rule_get(rule); |
| 484 | |
Eric Dumazet | ebb9fed | 2010-10-23 09:44:25 +0000 | [diff] [blame] | 485 | if (last) |
| 486 | list_add_rcu(&rule->list, &last->list); |
| 487 | else |
| 488 | list_add_rcu(&rule->list, &ops->rules_list); |
| 489 | |
Thomas Graf | 0947c9fe | 2007-03-26 17:14:15 -0700 | [diff] [blame] | 490 | if (ops->unresolved_rules) { |
| 491 | /* |
| 492 | * There are unresolved goto rules in the list, check if |
| 493 | * any of them are pointing to this new rule. |
| 494 | */ |
Denis V. Lunev | 76c72d4 | 2007-09-16 15:44:27 -0700 | [diff] [blame] | 495 | list_for_each_entry(r, &ops->rules_list, list) { |
Thomas Graf | 0947c9fe | 2007-03-26 17:14:15 -0700 | [diff] [blame] | 496 | if (r->action == FR_ACT_GOTO && |
Gao feng | 561dac2 | 2011-09-11 15:36:05 +0000 | [diff] [blame] | 497 | r->target == rule->pref && |
| 498 | rtnl_dereference(r->ctarget) == NULL) { |
Thomas Graf | 0947c9fe | 2007-03-26 17:14:15 -0700 | [diff] [blame] | 499 | rcu_assign_pointer(r->ctarget, rule); |
| 500 | if (--ops->unresolved_rules == 0) |
| 501 | break; |
| 502 | } |
| 503 | } |
| 504 | } |
| 505 | |
| 506 | if (rule->action == FR_ACT_GOTO) |
| 507 | ops->nr_goto_rules++; |
| 508 | |
| 509 | if (unresolved) |
| 510 | ops->unresolved_rules++; |
| 511 | |
Thomas Graf | e703087 | 2015-07-21 10:44:01 +0200 | [diff] [blame] | 512 | if (rule->tun_id) |
| 513 | ip_tunnel_need_metadata(); |
| 514 | |
Eric W. Biederman | 15e4730 | 2012-09-07 20:12:54 +0000 | [diff] [blame] | 515 | notify_rule_change(RTM_NEWRULE, rule, ops, nlh, NETLINK_CB(skb).portid); |
Thomas Graf | 73417f6 | 2007-03-27 13:56:52 -0700 | [diff] [blame] | 516 | flush_route_cache(ops); |
Thomas Graf | 14c0b97 | 2006-08-04 03:38:38 -0700 | [diff] [blame] | 517 | rules_ops_put(ops); |
| 518 | return 0; |
| 519 | |
| 520 | errout_free: |
| 521 | kfree(rule); |
| 522 | errout: |
| 523 | rules_ops_put(ops); |
| 524 | return err; |
| 525 | } |
David Ahern | 96c63fa | 2016-06-08 10:55:39 -0700 | [diff] [blame] | 526 | EXPORT_SYMBOL_GPL(fib_nl_newrule); |
Thomas Graf | 14c0b97 | 2006-08-04 03:38:38 -0700 | [diff] [blame] | 527 | |
David Ahern | 96c63fa | 2016-06-08 10:55:39 -0700 | [diff] [blame] | 528 | int fib_nl_delrule(struct sk_buff *skb, struct nlmsghdr *nlh) |
Thomas Graf | 14c0b97 | 2006-08-04 03:38:38 -0700 | [diff] [blame] | 529 | { |
YOSHIFUJI Hideaki | 3b1e0a6 | 2008-03-26 02:26:21 +0900 | [diff] [blame] | 530 | struct net *net = sock_net(skb->sk); |
Thomas Graf | 14c0b97 | 2006-08-04 03:38:38 -0700 | [diff] [blame] | 531 | struct fib_rule_hdr *frh = nlmsg_data(nlh); |
| 532 | struct fib_rules_ops *ops = NULL; |
Thomas Graf | 0947c9fe | 2007-03-26 17:14:15 -0700 | [diff] [blame] | 533 | struct fib_rule *rule, *tmp; |
Thomas Graf | 14c0b97 | 2006-08-04 03:38:38 -0700 | [diff] [blame] | 534 | struct nlattr *tb[FRA_MAX+1]; |
| 535 | int err = -EINVAL; |
| 536 | |
| 537 | if (nlh->nlmsg_len < nlmsg_msg_size(sizeof(*frh))) |
| 538 | goto errout; |
| 539 | |
Denis V. Lunev | 5fd30ee | 2008-01-10 03:20:28 -0800 | [diff] [blame] | 540 | ops = lookup_rules_ops(net, frh->family); |
Thomas Graf | 14c0b97 | 2006-08-04 03:38:38 -0700 | [diff] [blame] | 541 | if (ops == NULL) { |
Patrick McHardy | 2fe195c | 2008-07-01 19:59:37 -0700 | [diff] [blame] | 542 | err = -EAFNOSUPPORT; |
Thomas Graf | 14c0b97 | 2006-08-04 03:38:38 -0700 | [diff] [blame] | 543 | goto errout; |
| 544 | } |
| 545 | |
| 546 | err = nlmsg_parse(nlh, sizeof(*frh), tb, FRA_MAX, ops->policy); |
| 547 | if (err < 0) |
| 548 | goto errout; |
| 549 | |
Thomas Graf | e1701c6 | 2007-03-24 12:46:02 -0700 | [diff] [blame] | 550 | err = validate_rulemsg(frh, tb, ops); |
| 551 | if (err < 0) |
| 552 | goto errout; |
| 553 | |
Denis V. Lunev | 76c72d4 | 2007-09-16 15:44:27 -0700 | [diff] [blame] | 554 | list_for_each_entry(rule, &ops->rules_list, list) { |
Thomas Graf | 14c0b97 | 2006-08-04 03:38:38 -0700 | [diff] [blame] | 555 | if (frh->action && (frh->action != rule->action)) |
| 556 | continue; |
| 557 | |
Andreas Henriksson | 13eb2ab | 2013-11-07 18:26:38 +0100 | [diff] [blame] | 558 | if (frh_get_table(frh, tb) && |
| 559 | (frh_get_table(frh, tb) != rule->table)) |
Thomas Graf | 14c0b97 | 2006-08-04 03:38:38 -0700 | [diff] [blame] | 560 | continue; |
| 561 | |
| 562 | if (tb[FRA_PRIORITY] && |
| 563 | (rule->pref != nla_get_u32(tb[FRA_PRIORITY]))) |
| 564 | continue; |
| 565 | |
Patrick McHardy | 491deb24b | 2009-12-03 01:25:54 +0000 | [diff] [blame] | 566 | if (tb[FRA_IIFNAME] && |
| 567 | nla_strcmp(tb[FRA_IIFNAME], rule->iifname)) |
Thomas Graf | 14c0b97 | 2006-08-04 03:38:38 -0700 | [diff] [blame] | 568 | continue; |
| 569 | |
Patrick McHardy | 1b038a5 | 2009-12-03 01:25:56 +0000 | [diff] [blame] | 570 | if (tb[FRA_OIFNAME] && |
| 571 | nla_strcmp(tb[FRA_OIFNAME], rule->oifname)) |
| 572 | continue; |
| 573 | |
Thomas Graf | b8964ed | 2006-11-09 15:22:18 -0800 | [diff] [blame] | 574 | if (tb[FRA_FWMARK] && |
| 575 | (rule->mark != nla_get_u32(tb[FRA_FWMARK]))) |
| 576 | continue; |
| 577 | |
| 578 | if (tb[FRA_FWMASK] && |
| 579 | (rule->mark_mask != nla_get_u32(tb[FRA_FWMASK]))) |
| 580 | continue; |
| 581 | |
Thomas Graf | e703087 | 2015-07-21 10:44:01 +0200 | [diff] [blame] | 582 | if (tb[FRA_TUN_ID] && |
| 583 | (rule->tun_id != nla_get_be64(tb[FRA_TUN_ID]))) |
| 584 | continue; |
| 585 | |
David Ahern | 96c63fa | 2016-06-08 10:55:39 -0700 | [diff] [blame] | 586 | if (tb[FRA_L3MDEV] && |
| 587 | (rule->l3mdev != nla_get_u8(tb[FRA_L3MDEV]))) |
| 588 | continue; |
| 589 | |
Lorenzo Colitti | 8dc318f | 2014-03-31 16:23:51 +0900 | [diff] [blame] | 590 | if (tb[FRA_UID_START] && |
| 591 | !uid_eq(rule->uid_start, fib_nl_uid(tb[FRA_UID_START]))) |
| 592 | continue; |
| 593 | |
| 594 | if (tb[FRA_UID_END] && |
| 595 | !uid_eq(rule->uid_end, fib_nl_uid(tb[FRA_UID_END]))) |
| 596 | continue; |
| 597 | |
Thomas Graf | 14c0b97 | 2006-08-04 03:38:38 -0700 | [diff] [blame] | 598 | if (!ops->compare(rule, frh, tb)) |
| 599 | continue; |
| 600 | |
| 601 | if (rule->flags & FIB_RULE_PERMANENT) { |
| 602 | err = -EPERM; |
| 603 | goto errout; |
| 604 | } |
| 605 | |
Alexander Duyck | 0ddcf43 | 2015-03-06 13:47:00 -0800 | [diff] [blame] | 606 | if (ops->delete) { |
| 607 | err = ops->delete(rule); |
| 608 | if (err) |
| 609 | goto errout; |
| 610 | } |
| 611 | |
Thomas Graf | e703087 | 2015-07-21 10:44:01 +0200 | [diff] [blame] | 612 | if (rule->tun_id) |
| 613 | ip_tunnel_unneed_metadata(); |
| 614 | |
Thomas Graf | 14c0b97 | 2006-08-04 03:38:38 -0700 | [diff] [blame] | 615 | list_del_rcu(&rule->list); |
Thomas Graf | 0947c9fe | 2007-03-26 17:14:15 -0700 | [diff] [blame] | 616 | |
Yan, Zheng | afaef73 | 2011-10-17 15:20:28 +0000 | [diff] [blame] | 617 | if (rule->action == FR_ACT_GOTO) { |
Thomas Graf | 0947c9fe | 2007-03-26 17:14:15 -0700 | [diff] [blame] | 618 | ops->nr_goto_rules--; |
Yan, Zheng | afaef73 | 2011-10-17 15:20:28 +0000 | [diff] [blame] | 619 | if (rtnl_dereference(rule->ctarget) == NULL) |
| 620 | ops->unresolved_rules--; |
| 621 | } |
Thomas Graf | 0947c9fe | 2007-03-26 17:14:15 -0700 | [diff] [blame] | 622 | |
| 623 | /* |
| 624 | * Check if this rule is a target to any of them. If so, |
| 625 | * disable them. As this operation is eventually very |
| 626 | * expensive, it is only performed if goto rules have |
| 627 | * actually been added. |
| 628 | */ |
| 629 | if (ops->nr_goto_rules > 0) { |
Denis V. Lunev | 76c72d4 | 2007-09-16 15:44:27 -0700 | [diff] [blame] | 630 | list_for_each_entry(tmp, &ops->rules_list, list) { |
Eric Dumazet | 7a2b03c | 2010-10-26 09:24:55 +0000 | [diff] [blame] | 631 | if (rtnl_dereference(tmp->ctarget) == rule) { |
Stephen Hemminger | a9b3cd7 | 2011-08-01 16:19:00 +0000 | [diff] [blame] | 632 | RCU_INIT_POINTER(tmp->ctarget, NULL); |
Thomas Graf | 0947c9fe | 2007-03-26 17:14:15 -0700 | [diff] [blame] | 633 | ops->unresolved_rules++; |
| 634 | } |
| 635 | } |
| 636 | } |
| 637 | |
Denis V. Lunev | 9e3a548 | 2008-01-20 16:46:41 -0800 | [diff] [blame] | 638 | notify_rule_change(RTM_DELRULE, rule, ops, nlh, |
Eric W. Biederman | 15e4730 | 2012-09-07 20:12:54 +0000 | [diff] [blame] | 639 | NETLINK_CB(skb).portid); |
Thomas Graf | 14c0b97 | 2006-08-04 03:38:38 -0700 | [diff] [blame] | 640 | fib_rule_put(rule); |
Thomas Graf | 73417f6 | 2007-03-27 13:56:52 -0700 | [diff] [blame] | 641 | flush_route_cache(ops); |
Thomas Graf | 14c0b97 | 2006-08-04 03:38:38 -0700 | [diff] [blame] | 642 | rules_ops_put(ops); |
| 643 | return 0; |
| 644 | } |
| 645 | |
| 646 | err = -ENOENT; |
| 647 | errout: |
| 648 | rules_ops_put(ops); |
| 649 | return err; |
| 650 | } |
David Ahern | 96c63fa | 2016-06-08 10:55:39 -0700 | [diff] [blame] | 651 | EXPORT_SYMBOL_GPL(fib_nl_delrule); |
Thomas Graf | 14c0b97 | 2006-08-04 03:38:38 -0700 | [diff] [blame] | 652 | |
Thomas Graf | 339bf98 | 2006-11-10 14:10:15 -0800 | [diff] [blame] | 653 | static inline size_t fib_rule_nlmsg_size(struct fib_rules_ops *ops, |
| 654 | struct fib_rule *rule) |
| 655 | { |
| 656 | size_t payload = NLMSG_ALIGN(sizeof(struct fib_rule_hdr)) |
Patrick McHardy | 491deb24b | 2009-12-03 01:25:54 +0000 | [diff] [blame] | 657 | + nla_total_size(IFNAMSIZ) /* FRA_IIFNAME */ |
Patrick McHardy | 1b038a5 | 2009-12-03 01:25:56 +0000 | [diff] [blame] | 658 | + nla_total_size(IFNAMSIZ) /* FRA_OIFNAME */ |
Thomas Graf | 339bf98 | 2006-11-10 14:10:15 -0800 | [diff] [blame] | 659 | + nla_total_size(4) /* FRA_PRIORITY */ |
| 660 | + nla_total_size(4) /* FRA_TABLE */ |
Stefan Tomanek | 73f5698 | 2013-08-03 14:14:43 +0200 | [diff] [blame] | 661 | + nla_total_size(4) /* FRA_SUPPRESS_PREFIXLEN */ |
Stefan Tomanek | 6ef94cf | 2013-08-02 17:19:56 +0200 | [diff] [blame] | 662 | + nla_total_size(4) /* FRA_SUPPRESS_IFGROUP */ |
Thomas Graf | 339bf98 | 2006-11-10 14:10:15 -0800 | [diff] [blame] | 663 | + nla_total_size(4) /* FRA_FWMARK */ |
Thomas Graf | e703087 | 2015-07-21 10:44:01 +0200 | [diff] [blame] | 664 | + nla_total_size(4) /* FRA_FWMASK */ |
Lorenzo Colitti | 8dc318f | 2014-03-31 16:23:51 +0900 | [diff] [blame] | 665 | + nla_total_size_64bit(8) /* FRA_TUN_ID */ |
| 666 | + nla_total_size(4) /* FRA_UID_START */ |
| 667 | + nla_total_size(4); /* FRA_UID_END */ |
Thomas Graf | 339bf98 | 2006-11-10 14:10:15 -0800 | [diff] [blame] | 668 | |
| 669 | if (ops->nlmsg_payload) |
| 670 | payload += ops->nlmsg_payload(rule); |
| 671 | |
| 672 | return payload; |
| 673 | } |
| 674 | |
Thomas Graf | 14c0b97 | 2006-08-04 03:38:38 -0700 | [diff] [blame] | 675 | static int fib_nl_fill_rule(struct sk_buff *skb, struct fib_rule *rule, |
| 676 | u32 pid, u32 seq, int type, int flags, |
| 677 | struct fib_rules_ops *ops) |
| 678 | { |
| 679 | struct nlmsghdr *nlh; |
| 680 | struct fib_rule_hdr *frh; |
| 681 | |
| 682 | nlh = nlmsg_put(skb, pid, seq, type, sizeof(*frh), flags); |
| 683 | if (nlh == NULL) |
Patrick McHardy | 2693256 | 2007-01-31 23:16:40 -0800 | [diff] [blame] | 684 | return -EMSGSIZE; |
Thomas Graf | 14c0b97 | 2006-08-04 03:38:38 -0700 | [diff] [blame] | 685 | |
| 686 | frh = nlmsg_data(nlh); |
Patrick McHardy | 28bb172 | 2010-04-13 05:03:16 +0000 | [diff] [blame] | 687 | frh->family = ops->family; |
Thomas Graf | 14c0b97 | 2006-08-04 03:38:38 -0700 | [diff] [blame] | 688 | frh->table = rule->table; |
David S. Miller | 0e3cea7 | 2012-04-01 20:47:01 -0400 | [diff] [blame] | 689 | if (nla_put_u32(skb, FRA_TABLE, rule->table)) |
| 690 | goto nla_put_failure; |
Stefan Tomanek | 73f5698 | 2013-08-03 14:14:43 +0200 | [diff] [blame] | 691 | if (nla_put_u32(skb, FRA_SUPPRESS_PREFIXLEN, rule->suppress_prefixlen)) |
Stefan Tomanek | 7764a45 | 2013-08-01 02:17:15 +0200 | [diff] [blame] | 692 | goto nla_put_failure; |
Thomas Graf | 14c0b97 | 2006-08-04 03:38:38 -0700 | [diff] [blame] | 693 | frh->res1 = 0; |
| 694 | frh->res2 = 0; |
| 695 | frh->action = rule->action; |
| 696 | frh->flags = rule->flags; |
| 697 | |
Eric Dumazet | 7a2b03c | 2010-10-26 09:24:55 +0000 | [diff] [blame] | 698 | if (rule->action == FR_ACT_GOTO && |
Eric Dumazet | 33d480c | 2011-08-11 19:30:52 +0000 | [diff] [blame] | 699 | rcu_access_pointer(rule->ctarget) == NULL) |
Thomas Graf | 0947c9fe | 2007-03-26 17:14:15 -0700 | [diff] [blame] | 700 | frh->flags |= FIB_RULE_UNRESOLVED; |
| 701 | |
Patrick McHardy | 491deb24b | 2009-12-03 01:25:54 +0000 | [diff] [blame] | 702 | if (rule->iifname[0]) { |
David S. Miller | 0e3cea7 | 2012-04-01 20:47:01 -0400 | [diff] [blame] | 703 | if (nla_put_string(skb, FRA_IIFNAME, rule->iifname)) |
| 704 | goto nla_put_failure; |
Patrick McHardy | 491deb24b | 2009-12-03 01:25:54 +0000 | [diff] [blame] | 705 | if (rule->iifindex == -1) |
| 706 | frh->flags |= FIB_RULE_IIF_DETACHED; |
Thomas Graf | 2b44368 | 2007-03-26 17:37:59 -0700 | [diff] [blame] | 707 | } |
| 708 | |
Patrick McHardy | 1b038a5 | 2009-12-03 01:25:56 +0000 | [diff] [blame] | 709 | if (rule->oifname[0]) { |
David S. Miller | 0e3cea7 | 2012-04-01 20:47:01 -0400 | [diff] [blame] | 710 | if (nla_put_string(skb, FRA_OIFNAME, rule->oifname)) |
| 711 | goto nla_put_failure; |
Patrick McHardy | 1b038a5 | 2009-12-03 01:25:56 +0000 | [diff] [blame] | 712 | if (rule->oifindex == -1) |
| 713 | frh->flags |= FIB_RULE_OIF_DETACHED; |
| 714 | } |
| 715 | |
David S. Miller | 0e3cea7 | 2012-04-01 20:47:01 -0400 | [diff] [blame] | 716 | if ((rule->pref && |
| 717 | nla_put_u32(skb, FRA_PRIORITY, rule->pref)) || |
| 718 | (rule->mark && |
| 719 | nla_put_u32(skb, FRA_FWMARK, rule->mark)) || |
| 720 | ((rule->mark_mask || rule->mark) && |
| 721 | nla_put_u32(skb, FRA_FWMASK, rule->mark_mask)) || |
| 722 | (rule->target && |
Thomas Graf | e703087 | 2015-07-21 10:44:01 +0200 | [diff] [blame] | 723 | nla_put_u32(skb, FRA_GOTO, rule->target)) || |
| 724 | (rule->tun_id && |
David Ahern | 96c63fa | 2016-06-08 10:55:39 -0700 | [diff] [blame] | 725 | nla_put_be64(skb, FRA_TUN_ID, rule->tun_id, FRA_PAD)) || |
| 726 | (rule->l3mdev && |
Lorenzo Colitti | 8dc318f | 2014-03-31 16:23:51 +0900 | [diff] [blame] | 727 | nla_put_u8(skb, FRA_L3MDEV, rule->l3mdev)) || |
| 728 | (uid_valid(rule->uid_start) && |
| 729 | nla_put_uid(skb, FRA_UID_START, rule->uid_start)) || |
| 730 | (uid_valid(rule->uid_end) && |
| 731 | nla_put_uid(skb, FRA_UID_END, rule->uid_end))) |
David S. Miller | 0e3cea7 | 2012-04-01 20:47:01 -0400 | [diff] [blame] | 732 | goto nla_put_failure; |
Stefan Tomanek | 6ef94cf | 2013-08-02 17:19:56 +0200 | [diff] [blame] | 733 | |
| 734 | if (rule->suppress_ifgroup != -1) { |
| 735 | if (nla_put_u32(skb, FRA_SUPPRESS_IFGROUP, rule->suppress_ifgroup)) |
| 736 | goto nla_put_failure; |
| 737 | } |
| 738 | |
Rami Rosen | 04af8cf | 2009-05-20 17:26:23 -0700 | [diff] [blame] | 739 | if (ops->fill(rule, skb, frh) < 0) |
Thomas Graf | 14c0b97 | 2006-08-04 03:38:38 -0700 | [diff] [blame] | 740 | goto nla_put_failure; |
| 741 | |
Johannes Berg | 053c095 | 2015-01-16 22:09:00 +0100 | [diff] [blame] | 742 | nlmsg_end(skb, nlh); |
| 743 | return 0; |
Thomas Graf | 14c0b97 | 2006-08-04 03:38:38 -0700 | [diff] [blame] | 744 | |
| 745 | nla_put_failure: |
Patrick McHardy | 2693256 | 2007-01-31 23:16:40 -0800 | [diff] [blame] | 746 | nlmsg_cancel(skb, nlh); |
| 747 | return -EMSGSIZE; |
Thomas Graf | 14c0b97 | 2006-08-04 03:38:38 -0700 | [diff] [blame] | 748 | } |
| 749 | |
Thomas Graf | c454673 | 2007-03-25 23:24:24 -0700 | [diff] [blame] | 750 | static int dump_rules(struct sk_buff *skb, struct netlink_callback *cb, |
| 751 | struct fib_rules_ops *ops) |
Thomas Graf | 14c0b97 | 2006-08-04 03:38:38 -0700 | [diff] [blame] | 752 | { |
| 753 | int idx = 0; |
| 754 | struct fib_rule *rule; |
Wilson Kok | 41fc014 | 2015-09-22 21:40:22 -0700 | [diff] [blame] | 755 | int err = 0; |
Thomas Graf | 14c0b97 | 2006-08-04 03:38:38 -0700 | [diff] [blame] | 756 | |
Eric Dumazet | e67f88d | 2011-04-27 22:56:07 +0000 | [diff] [blame] | 757 | rcu_read_lock(); |
| 758 | list_for_each_entry_rcu(rule, &ops->rules_list, list) { |
Thomas Graf | c454673 | 2007-03-25 23:24:24 -0700 | [diff] [blame] | 759 | if (idx < cb->args[1]) |
Thomas Graf | 14c0b97 | 2006-08-04 03:38:38 -0700 | [diff] [blame] | 760 | goto skip; |
| 761 | |
Wilson Kok | 41fc014 | 2015-09-22 21:40:22 -0700 | [diff] [blame] | 762 | err = fib_nl_fill_rule(skb, rule, NETLINK_CB(cb->skb).portid, |
| 763 | cb->nlh->nlmsg_seq, RTM_NEWRULE, |
| 764 | NLM_F_MULTI, ops); |
| 765 | if (err) |
Thomas Graf | 14c0b97 | 2006-08-04 03:38:38 -0700 | [diff] [blame] | 766 | break; |
| 767 | skip: |
| 768 | idx++; |
| 769 | } |
Eric Dumazet | 2907c35 | 2011-05-25 07:34:04 +0000 | [diff] [blame] | 770 | rcu_read_unlock(); |
Thomas Graf | c454673 | 2007-03-25 23:24:24 -0700 | [diff] [blame] | 771 | cb->args[1] = idx; |
Thomas Graf | 14c0b97 | 2006-08-04 03:38:38 -0700 | [diff] [blame] | 772 | rules_ops_put(ops); |
| 773 | |
Wilson Kok | 41fc014 | 2015-09-22 21:40:22 -0700 | [diff] [blame] | 774 | return err; |
Thomas Graf | 14c0b97 | 2006-08-04 03:38:38 -0700 | [diff] [blame] | 775 | } |
| 776 | |
Thomas Graf | c454673 | 2007-03-25 23:24:24 -0700 | [diff] [blame] | 777 | static int fib_nl_dumprule(struct sk_buff *skb, struct netlink_callback *cb) |
| 778 | { |
YOSHIFUJI Hideaki | 3b1e0a6 | 2008-03-26 02:26:21 +0900 | [diff] [blame] | 779 | struct net *net = sock_net(skb->sk); |
Thomas Graf | c454673 | 2007-03-25 23:24:24 -0700 | [diff] [blame] | 780 | struct fib_rules_ops *ops; |
| 781 | int idx = 0, family; |
| 782 | |
| 783 | family = rtnl_msg_family(cb->nlh); |
| 784 | if (family != AF_UNSPEC) { |
| 785 | /* Protocol specific dump request */ |
Denis V. Lunev | 5fd30ee | 2008-01-10 03:20:28 -0800 | [diff] [blame] | 786 | ops = lookup_rules_ops(net, family); |
Thomas Graf | c454673 | 2007-03-25 23:24:24 -0700 | [diff] [blame] | 787 | if (ops == NULL) |
| 788 | return -EAFNOSUPPORT; |
| 789 | |
Wilson Kok | 41fc014 | 2015-09-22 21:40:22 -0700 | [diff] [blame] | 790 | dump_rules(skb, cb, ops); |
| 791 | |
| 792 | return skb->len; |
Thomas Graf | c454673 | 2007-03-25 23:24:24 -0700 | [diff] [blame] | 793 | } |
| 794 | |
| 795 | rcu_read_lock(); |
Denis V. Lunev | 5fd30ee | 2008-01-10 03:20:28 -0800 | [diff] [blame] | 796 | list_for_each_entry_rcu(ops, &net->rules_ops, list) { |
Thomas Graf | c454673 | 2007-03-25 23:24:24 -0700 | [diff] [blame] | 797 | if (idx < cb->args[0] || !try_module_get(ops->owner)) |
| 798 | goto skip; |
| 799 | |
| 800 | if (dump_rules(skb, cb, ops) < 0) |
| 801 | break; |
| 802 | |
| 803 | cb->args[1] = 0; |
Eric Dumazet | 2fb3573 | 2010-03-09 20:03:38 +0000 | [diff] [blame] | 804 | skip: |
Thomas Graf | c454673 | 2007-03-25 23:24:24 -0700 | [diff] [blame] | 805 | idx++; |
| 806 | } |
| 807 | rcu_read_unlock(); |
| 808 | cb->args[0] = idx; |
| 809 | |
| 810 | return skb->len; |
| 811 | } |
Thomas Graf | 14c0b97 | 2006-08-04 03:38:38 -0700 | [diff] [blame] | 812 | |
Denis V. Lunev | 9e3a548 | 2008-01-20 16:46:41 -0800 | [diff] [blame] | 813 | static void notify_rule_change(int event, struct fib_rule *rule, |
Thomas Graf | c17084d | 2006-08-15 00:32:48 -0700 | [diff] [blame] | 814 | struct fib_rules_ops *ops, struct nlmsghdr *nlh, |
| 815 | u32 pid) |
Thomas Graf | 14c0b97 | 2006-08-04 03:38:38 -0700 | [diff] [blame] | 816 | { |
Denis V. Lunev | 9e3a548 | 2008-01-20 16:46:41 -0800 | [diff] [blame] | 817 | struct net *net; |
Thomas Graf | c17084d | 2006-08-15 00:32:48 -0700 | [diff] [blame] | 818 | struct sk_buff *skb; |
| 819 | int err = -ENOBUFS; |
Thomas Graf | 14c0b97 | 2006-08-04 03:38:38 -0700 | [diff] [blame] | 820 | |
Denis V. Lunev | 9e3a548 | 2008-01-20 16:46:41 -0800 | [diff] [blame] | 821 | net = ops->fro_net; |
Thomas Graf | 339bf98 | 2006-11-10 14:10:15 -0800 | [diff] [blame] | 822 | skb = nlmsg_new(fib_rule_nlmsg_size(ops, rule), GFP_KERNEL); |
Thomas Graf | 14c0b97 | 2006-08-04 03:38:38 -0700 | [diff] [blame] | 823 | if (skb == NULL) |
Thomas Graf | c17084d | 2006-08-15 00:32:48 -0700 | [diff] [blame] | 824 | goto errout; |
| 825 | |
| 826 | err = fib_nl_fill_rule(skb, rule, pid, nlh->nlmsg_seq, event, 0, ops); |
Patrick McHardy | 2693256 | 2007-01-31 23:16:40 -0800 | [diff] [blame] | 827 | if (err < 0) { |
| 828 | /* -EMSGSIZE implies BUG in fib_rule_nlmsg_size() */ |
| 829 | WARN_ON(err == -EMSGSIZE); |
| 830 | kfree_skb(skb); |
| 831 | goto errout; |
| 832 | } |
Denis V. Lunev | 9e3a548 | 2008-01-20 16:46:41 -0800 | [diff] [blame] | 833 | |
Pablo Neira Ayuso | 1ce85fe | 2009-02-24 23:18:28 -0800 | [diff] [blame] | 834 | rtnl_notify(skb, net, pid, ops->nlgroup, nlh, GFP_KERNEL); |
| 835 | return; |
Thomas Graf | c17084d | 2006-08-15 00:32:48 -0700 | [diff] [blame] | 836 | errout: |
| 837 | if (err < 0) |
Denis V. Lunev | 5fd30ee | 2008-01-10 03:20:28 -0800 | [diff] [blame] | 838 | rtnl_set_sk_err(net, ops->nlgroup, err); |
Thomas Graf | 14c0b97 | 2006-08-04 03:38:38 -0700 | [diff] [blame] | 839 | } |
| 840 | |
| 841 | static void attach_rules(struct list_head *rules, struct net_device *dev) |
| 842 | { |
| 843 | struct fib_rule *rule; |
| 844 | |
| 845 | list_for_each_entry(rule, rules, list) { |
Patrick McHardy | 491deb24b | 2009-12-03 01:25:54 +0000 | [diff] [blame] | 846 | if (rule->iifindex == -1 && |
| 847 | strcmp(dev->name, rule->iifname) == 0) |
| 848 | rule->iifindex = dev->ifindex; |
Patrick McHardy | 1b038a5 | 2009-12-03 01:25:56 +0000 | [diff] [blame] | 849 | if (rule->oifindex == -1 && |
| 850 | strcmp(dev->name, rule->oifname) == 0) |
| 851 | rule->oifindex = dev->ifindex; |
Thomas Graf | 14c0b97 | 2006-08-04 03:38:38 -0700 | [diff] [blame] | 852 | } |
| 853 | } |
| 854 | |
| 855 | static void detach_rules(struct list_head *rules, struct net_device *dev) |
| 856 | { |
| 857 | struct fib_rule *rule; |
| 858 | |
Patrick McHardy | 1b038a5 | 2009-12-03 01:25:56 +0000 | [diff] [blame] | 859 | list_for_each_entry(rule, rules, list) { |
Patrick McHardy | 491deb24b | 2009-12-03 01:25:54 +0000 | [diff] [blame] | 860 | if (rule->iifindex == dev->ifindex) |
| 861 | rule->iifindex = -1; |
Patrick McHardy | 1b038a5 | 2009-12-03 01:25:56 +0000 | [diff] [blame] | 862 | if (rule->oifindex == dev->ifindex) |
| 863 | rule->oifindex = -1; |
| 864 | } |
Thomas Graf | 14c0b97 | 2006-08-04 03:38:38 -0700 | [diff] [blame] | 865 | } |
| 866 | |
| 867 | |
| 868 | static int fib_rules_event(struct notifier_block *this, unsigned long event, |
Jiri Pirko | 351638e | 2013-05-28 01:30:21 +0000 | [diff] [blame] | 869 | void *ptr) |
Thomas Graf | 14c0b97 | 2006-08-04 03:38:38 -0700 | [diff] [blame] | 870 | { |
Jiri Pirko | 351638e | 2013-05-28 01:30:21 +0000 | [diff] [blame] | 871 | struct net_device *dev = netdev_notifier_info_to_dev(ptr); |
YOSHIFUJI Hideaki | c346dca | 2008-03-25 21:47:49 +0900 | [diff] [blame] | 872 | struct net *net = dev_net(dev); |
Thomas Graf | 14c0b97 | 2006-08-04 03:38:38 -0700 | [diff] [blame] | 873 | struct fib_rules_ops *ops; |
| 874 | |
Eric Dumazet | 748e2d9 | 2012-08-22 21:50:59 +0000 | [diff] [blame] | 875 | ASSERT_RTNL(); |
Thomas Graf | 14c0b97 | 2006-08-04 03:38:38 -0700 | [diff] [blame] | 876 | |
| 877 | switch (event) { |
| 878 | case NETDEV_REGISTER: |
Denis V. Lunev | 5fd30ee | 2008-01-10 03:20:28 -0800 | [diff] [blame] | 879 | list_for_each_entry(ops, &net->rules_ops, list) |
Denis V. Lunev | 76c72d4 | 2007-09-16 15:44:27 -0700 | [diff] [blame] | 880 | attach_rules(&ops->rules_list, dev); |
Thomas Graf | 14c0b97 | 2006-08-04 03:38:38 -0700 | [diff] [blame] | 881 | break; |
| 882 | |
Maciej Żenczykowski | 946c032 | 2014-02-07 16:23:48 -0800 | [diff] [blame] | 883 | case NETDEV_CHANGENAME: |
| 884 | list_for_each_entry(ops, &net->rules_ops, list) { |
| 885 | detach_rules(&ops->rules_list, dev); |
| 886 | attach_rules(&ops->rules_list, dev); |
| 887 | } |
| 888 | break; |
| 889 | |
Thomas Graf | 14c0b97 | 2006-08-04 03:38:38 -0700 | [diff] [blame] | 890 | case NETDEV_UNREGISTER: |
Denis V. Lunev | 5fd30ee | 2008-01-10 03:20:28 -0800 | [diff] [blame] | 891 | list_for_each_entry(ops, &net->rules_ops, list) |
Denis V. Lunev | 76c72d4 | 2007-09-16 15:44:27 -0700 | [diff] [blame] | 892 | detach_rules(&ops->rules_list, dev); |
Thomas Graf | 14c0b97 | 2006-08-04 03:38:38 -0700 | [diff] [blame] | 893 | break; |
| 894 | } |
| 895 | |
Thomas Graf | 14c0b97 | 2006-08-04 03:38:38 -0700 | [diff] [blame] | 896 | return NOTIFY_DONE; |
| 897 | } |
| 898 | |
| 899 | static struct notifier_block fib_rules_notifier = { |
| 900 | .notifier_call = fib_rules_event, |
| 901 | }; |
| 902 | |
Alexey Dobriyan | 2c8c1e7 | 2010-01-17 03:35:32 +0000 | [diff] [blame] | 903 | static int __net_init fib_rules_net_init(struct net *net) |
Denis V. Lunev | 5fd30ee | 2008-01-10 03:20:28 -0800 | [diff] [blame] | 904 | { |
| 905 | INIT_LIST_HEAD(&net->rules_ops); |
| 906 | spin_lock_init(&net->rules_mod_lock); |
| 907 | return 0; |
| 908 | } |
| 909 | |
| 910 | static struct pernet_operations fib_rules_net_ops = { |
| 911 | .init = fib_rules_net_init, |
| 912 | }; |
| 913 | |
Thomas Graf | 14c0b97 | 2006-08-04 03:38:38 -0700 | [diff] [blame] | 914 | static int __init fib_rules_init(void) |
| 915 | { |
Denis V. Lunev | 5fd30ee | 2008-01-10 03:20:28 -0800 | [diff] [blame] | 916 | int err; |
Greg Rose | c7ac867 | 2011-06-10 01:27:09 +0000 | [diff] [blame] | 917 | rtnl_register(PF_UNSPEC, RTM_NEWRULE, fib_nl_newrule, NULL, NULL); |
| 918 | rtnl_register(PF_UNSPEC, RTM_DELRULE, fib_nl_delrule, NULL, NULL); |
| 919 | rtnl_register(PF_UNSPEC, RTM_GETRULE, NULL, fib_nl_dumprule, NULL); |
Thomas Graf | 9d9e6a5 | 2007-03-25 23:20:05 -0700 | [diff] [blame] | 920 | |
Eric W. Biederman | 5d6d480 | 2008-11-07 22:52:34 -0800 | [diff] [blame] | 921 | err = register_pernet_subsys(&fib_rules_net_ops); |
Denis V. Lunev | 5fd30ee | 2008-01-10 03:20:28 -0800 | [diff] [blame] | 922 | if (err < 0) |
| 923 | goto fail; |
| 924 | |
Eric W. Biederman | 5d6d480 | 2008-11-07 22:52:34 -0800 | [diff] [blame] | 925 | err = register_netdevice_notifier(&fib_rules_notifier); |
Denis V. Lunev | 5fd30ee | 2008-01-10 03:20:28 -0800 | [diff] [blame] | 926 | if (err < 0) |
| 927 | goto fail_unregister; |
Eric W. Biederman | 5d6d480 | 2008-11-07 22:52:34 -0800 | [diff] [blame] | 928 | |
Denis V. Lunev | 5fd30ee | 2008-01-10 03:20:28 -0800 | [diff] [blame] | 929 | return 0; |
| 930 | |
| 931 | fail_unregister: |
Eric W. Biederman | 5d6d480 | 2008-11-07 22:52:34 -0800 | [diff] [blame] | 932 | unregister_pernet_subsys(&fib_rules_net_ops); |
Denis V. Lunev | 5fd30ee | 2008-01-10 03:20:28 -0800 | [diff] [blame] | 933 | fail: |
| 934 | rtnl_unregister(PF_UNSPEC, RTM_NEWRULE); |
| 935 | rtnl_unregister(PF_UNSPEC, RTM_DELRULE); |
| 936 | rtnl_unregister(PF_UNSPEC, RTM_GETRULE); |
| 937 | return err; |
Thomas Graf | 14c0b97 | 2006-08-04 03:38:38 -0700 | [diff] [blame] | 938 | } |
| 939 | |
| 940 | subsys_initcall(fib_rules_init); |