~ubuntu-branches/ubuntu/precise/linux-ti-omap4/precise

« back to all changes in this revision

Viewing changes to net/ipv6/fib6_rules.c

  • Committer: Bazaar Package Importer
  • Author(s): Paolo Pisati
  • Date: 2011-06-29 15:23:51 UTC
  • mfrom: (26.1.1 natty-proposed)
  • Revision ID: james.westby@ubuntu.com-20110629152351-xs96tm303d95rpbk
Tags: 3.0.0-1200.2
* Rebased against 3.0.0-6.7
* BSP from TI based on 3.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
        u8                      tclass;
30
30
};
31
31
 
32
 
struct dst_entry *fib6_rule_lookup(struct net *net, struct flowi *fl,
 
32
struct dst_entry *fib6_rule_lookup(struct net *net, struct flowi6 *fl6,
33
33
                                   int flags, pol_lookup_t lookup)
34
34
{
35
35
        struct fib_lookup_arg arg = {
37
37
                .flags = FIB_LOOKUP_NOREF,
38
38
        };
39
39
 
40
 
        fib_rules_lookup(net->ipv6.fib6_rules_ops, fl, flags, &arg);
 
40
        fib_rules_lookup(net->ipv6.fib6_rules_ops,
 
41
                         flowi6_to_flowi(fl6), flags, &arg);
41
42
 
42
43
        if (arg.result)
43
44
                return arg.result;
49
50
static int fib6_rule_action(struct fib_rule *rule, struct flowi *flp,
50
51
                            int flags, struct fib_lookup_arg *arg)
51
52
{
 
53
        struct flowi6 *flp6 = &flp->u.ip6;
52
54
        struct rt6_info *rt = NULL;
53
55
        struct fib6_table *table;
54
56
        struct net *net = rule->fr_net;
71
73
 
72
74
        table = fib6_get_table(net, rule->table);
73
75
        if (table)
74
 
                rt = lookup(net, table, flp, flags);
 
76
                rt = lookup(net, table, flp6, flags);
75
77
 
76
78
        if (rt != net->ipv6.ip6_null_entry) {
77
79
                struct fib6_rule *r = (struct fib6_rule *)rule;
86
88
 
87
89
                        if (ipv6_dev_get_saddr(net,
88
90
                                               ip6_dst_idev(&rt->dst)->dev,
89
 
                                               &flp->fl6_dst,
 
91
                                               &flp6->daddr,
90
92
                                               rt6_flags2srcprefs(flags),
91
93
                                               &saddr))
92
94
                                goto again;
93
95
                        if (!ipv6_prefix_equal(&saddr, &r->src.addr,
94
96
                                               r->src.plen))
95
97
                                goto again;
96
 
                        ipv6_addr_copy(&flp->fl6_src, &saddr);
 
98
                        ipv6_addr_copy(&flp6->saddr, &saddr);
97
99
                }
98
100
                goto out;
99
101
        }
113
115
static int fib6_rule_match(struct fib_rule *rule, struct flowi *fl, int flags)
114
116
{
115
117
        struct fib6_rule *r = (struct fib6_rule *) rule;
 
118
        struct flowi6 *fl6 = &fl->u.ip6;
116
119
 
117
120
        if (r->dst.plen &&
118
 
            !ipv6_prefix_equal(&fl->fl6_dst, &r->dst.addr, r->dst.plen))
 
121
            !ipv6_prefix_equal(&fl6->daddr, &r->dst.addr, r->dst.plen))
119
122
                return 0;
120
123
 
121
124
        /*
125
128
         */
126
129
        if (r->src.plen) {
127
130
                if (flags & RT6_LOOKUP_F_HAS_SADDR) {
128
 
                        if (!ipv6_prefix_equal(&fl->fl6_src, &r->src.addr,
 
131
                        if (!ipv6_prefix_equal(&fl6->saddr, &r->src.addr,
129
132
                                               r->src.plen))
130
133
                                return 0;
131
134
                } else if (!(r->common.flags & FIB_RULE_FIND_SADDR))
132
135
                        return 0;
133
136
        }
134
137
 
135
 
        if (r->tclass && r->tclass != ((ntohl(fl->fl6_flowlabel) >> 20) & 0xff))
 
138
        if (r->tclass && r->tclass != ((ntohl(fl6->flowlabel) >> 20) & 0xff))
136
139
                return 0;
137
140
 
138
141
        return 1;