diff options
| author | Andrea Bastoni <bastoni@cs.unc.edu> | 2010-05-30 19:16:45 -0400 |
|---|---|---|
| committer | Andrea Bastoni <bastoni@cs.unc.edu> | 2010-05-30 19:16:45 -0400 |
| commit | ada47b5fe13d89735805b566185f4885f5a3f750 (patch) | |
| tree | 644b88f8a71896307d71438e9b3af49126ffb22b /net/ipv6/fib6_rules.c | |
| parent | 43e98717ad40a4ae64545b5ba047c7b86aa44f4f (diff) | |
| parent | 3280f21d43ee541f97f8cda5792150d2dbec20d5 (diff) | |
Merge branch 'wip-2.6.34' into old-private-masterarchived-private-master
Diffstat (limited to 'net/ipv6/fib6_rules.c')
| -rw-r--r-- | net/ipv6/fib6_rules.c | 39 |
1 files changed, 12 insertions, 27 deletions
diff --git a/net/ipv6/fib6_rules.c b/net/ipv6/fib6_rules.c index 00a7a5e4ac97..5e463c43fcc2 100644 --- a/net/ipv6/fib6_rules.c +++ b/net/ipv6/fib6_rules.c | |||
| @@ -84,18 +84,11 @@ static int fib6_rule_action(struct fib_rule *rule, struct flowi *flp, | |||
| 84 | if ((rule->flags & FIB_RULE_FIND_SADDR) && | 84 | if ((rule->flags & FIB_RULE_FIND_SADDR) && |
| 85 | r->src.plen && !(flags & RT6_LOOKUP_F_HAS_SADDR)) { | 85 | r->src.plen && !(flags & RT6_LOOKUP_F_HAS_SADDR)) { |
| 86 | struct in6_addr saddr; | 86 | struct in6_addr saddr; |
| 87 | unsigned int srcprefs = 0; | ||
| 88 | |||
| 89 | if (flags & RT6_LOOKUP_F_SRCPREF_TMP) | ||
| 90 | srcprefs |= IPV6_PREFER_SRC_TMP; | ||
| 91 | if (flags & RT6_LOOKUP_F_SRCPREF_PUBLIC) | ||
| 92 | srcprefs |= IPV6_PREFER_SRC_PUBLIC; | ||
| 93 | if (flags & RT6_LOOKUP_F_SRCPREF_COA) | ||
| 94 | srcprefs |= IPV6_PREFER_SRC_COA; | ||
| 95 | 87 | ||
| 96 | if (ipv6_dev_get_saddr(net, | 88 | if (ipv6_dev_get_saddr(net, |
| 97 | ip6_dst_idev(&rt->u.dst)->dev, | 89 | ip6_dst_idev(&rt->u.dst)->dev, |
| 98 | &flp->fl6_dst, srcprefs, | 90 | &flp->fl6_dst, |
| 91 | rt6_flags2srcprefs(flags), | ||
| 99 | &saddr)) | 92 | &saddr)) |
| 100 | goto again; | 93 | goto again; |
| 101 | if (!ipv6_prefix_equal(&saddr, &r->src.addr, | 94 | if (!ipv6_prefix_equal(&saddr, &r->src.addr, |
| @@ -262,46 +255,38 @@ static struct fib_rules_ops fib6_rules_ops_template = { | |||
| 262 | .fro_net = &init_net, | 255 | .fro_net = &init_net, |
| 263 | }; | 256 | }; |
| 264 | 257 | ||
| 265 | static int fib6_rules_net_init(struct net *net) | 258 | static int __net_init fib6_rules_net_init(struct net *net) |
| 266 | { | 259 | { |
| 260 | struct fib_rules_ops *ops; | ||
| 267 | int err = -ENOMEM; | 261 | int err = -ENOMEM; |
| 268 | 262 | ||
| 269 | net->ipv6.fib6_rules_ops = kmemdup(&fib6_rules_ops_template, | 263 | ops = fib_rules_register(&fib6_rules_ops_template, net); |
| 270 | sizeof(*net->ipv6.fib6_rules_ops), | 264 | if (IS_ERR(ops)) |
| 271 | GFP_KERNEL); | 265 | return PTR_ERR(ops); |
| 272 | if (!net->ipv6.fib6_rules_ops) | 266 | net->ipv6.fib6_rules_ops = ops; |
| 273 | goto out; | ||
| 274 | 267 | ||
| 275 | net->ipv6.fib6_rules_ops->fro_net = net; | ||
| 276 | INIT_LIST_HEAD(&net->ipv6.fib6_rules_ops->rules_list); | ||
| 277 | 268 | ||
| 278 | err = fib_default_rule_add(net->ipv6.fib6_rules_ops, 0, | 269 | err = fib_default_rule_add(net->ipv6.fib6_rules_ops, 0, |
| 279 | RT6_TABLE_LOCAL, FIB_RULE_PERMANENT); | 270 | RT6_TABLE_LOCAL, 0); |
| 280 | if (err) | 271 | if (err) |
| 281 | goto out_fib6_rules_ops; | 272 | goto out_fib6_rules_ops; |
| 282 | 273 | ||
| 283 | err = fib_default_rule_add(net->ipv6.fib6_rules_ops, | 274 | err = fib_default_rule_add(net->ipv6.fib6_rules_ops, |
| 284 | 0x7FFE, RT6_TABLE_MAIN, 0); | 275 | 0x7FFE, RT6_TABLE_MAIN, 0); |
| 285 | if (err) | 276 | if (err) |
| 286 | goto out_fib6_default_rule_add; | 277 | goto out_fib6_rules_ops; |
| 287 | 278 | ||
| 288 | err = fib_rules_register(net->ipv6.fib6_rules_ops); | ||
| 289 | if (err) | ||
| 290 | goto out_fib6_default_rule_add; | ||
| 291 | out: | 279 | out: |
| 292 | return err; | 280 | return err; |
| 293 | 281 | ||
| 294 | out_fib6_default_rule_add: | ||
| 295 | fib_rules_cleanup_ops(net->ipv6.fib6_rules_ops); | ||
| 296 | out_fib6_rules_ops: | 282 | out_fib6_rules_ops: |
| 297 | kfree(net->ipv6.fib6_rules_ops); | 283 | fib_rules_unregister(ops); |
| 298 | goto out; | 284 | goto out; |
| 299 | } | 285 | } |
| 300 | 286 | ||
| 301 | static void fib6_rules_net_exit(struct net *net) | 287 | static void __net_exit fib6_rules_net_exit(struct net *net) |
| 302 | { | 288 | { |
| 303 | fib_rules_unregister(net->ipv6.fib6_rules_ops); | 289 | fib_rules_unregister(net->ipv6.fib6_rules_ops); |
| 304 | kfree(net->ipv6.fib6_rules_ops); | ||
| 305 | } | 290 | } |
| 306 | 291 | ||
| 307 | static struct pernet_operations fib6_rules_net_ops = { | 292 | static struct pernet_operations fib6_rules_net_ops = { |
