fib6_rules.c (2cc67cc731d9b693a08e781e98fec0e3a6d6ba44) fib6_rules.c (75bff8f023e02b045a8f68f36fa7da98dca124b8)
1/*
2 * net/ipv6/fib6_rules.c IPv6 Routing Policy Rules
3 *
4 * Copyright (C)2003-2006 Helsinki University of Technology
5 * Copyright (C)2003-2006 USAGI/WIDE Project
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as

--- 12 unchanged lines hidden (view full) ---

21#include <net/ip6_route.h>
22#include <net/netlink.h>
23
24struct fib6_rule
25{
26 struct fib_rule common;
27 struct rt6key src;
28 struct rt6key dst;
1/*
2 * net/ipv6/fib6_rules.c IPv6 Routing Policy Rules
3 *
4 * Copyright (C)2003-2006 Helsinki University of Technology
5 * Copyright (C)2003-2006 USAGI/WIDE Project
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as

--- 12 unchanged lines hidden (view full) ---

21#include <net/ip6_route.h>
22#include <net/netlink.h>
23
24struct fib6_rule
25{
26 struct fib_rule common;
27 struct rt6key src;
28 struct rt6key dst;
29#ifdef CONFIG_IPV6_ROUTE_FWMARK
30 u8 fwmark;
31#endif
29 u8 tclass;
30};
31
32static struct fib_rules_ops fib6_rules_ops;
33
34static struct fib6_rule main_rule = {
35 .common = {
36 .refcnt = ATOMIC_INIT(2),

--- 82 unchanged lines hidden (view full) ---

119
120 if ((flags & RT6_LOOKUP_F_HAS_SADDR) &&
121 !ipv6_prefix_equal(&fl->fl6_src, &r->src.addr, r->src.plen))
122 return 0;
123
124 if (r->tclass && r->tclass != ((ntohl(fl->fl6_flowlabel) >> 20) & 0xff))
125 return 0;
126
32 u8 tclass;
33};
34
35static struct fib_rules_ops fib6_rules_ops;
36
37static struct fib6_rule main_rule = {
38 .common = {
39 .refcnt = ATOMIC_INIT(2),

--- 82 unchanged lines hidden (view full) ---

122
123 if ((flags & RT6_LOOKUP_F_HAS_SADDR) &&
124 !ipv6_prefix_equal(&fl->fl6_src, &r->src.addr, r->src.plen))
125 return 0;
126
127 if (r->tclass && r->tclass != ((ntohl(fl->fl6_flowlabel) >> 20) & 0xff))
128 return 0;
129
130#ifdef CONFIG_IPV6_ROUTE_FWMARK
131 if (r->fwmark && (r->fwmark != fl->fl6_fwmark))
132 return 0;
133#endif
134
127 return 1;
128}
129
130static struct nla_policy fib6_rule_policy[RTA_MAX+1] __read_mostly = {
131 [FRA_IFNAME] = { .type = NLA_STRING },
132 [FRA_PRIORITY] = { .type = NLA_U32 },
133 [FRA_SRC] = { .minlen = sizeof(struct in6_addr) },
134 [FRA_DST] = { .minlen = sizeof(struct in6_addr) },

--- 24 unchanged lines hidden (view full) ---

159 if (tb[FRA_SRC])
160 nla_memcpy(&rule6->src.addr, tb[FRA_SRC],
161 sizeof(struct in6_addr));
162
163 if (tb[FRA_DST])
164 nla_memcpy(&rule6->dst.addr, tb[FRA_DST],
165 sizeof(struct in6_addr));
166
135 return 1;
136}
137
138static struct nla_policy fib6_rule_policy[RTA_MAX+1] __read_mostly = {
139 [FRA_IFNAME] = { .type = NLA_STRING },
140 [FRA_PRIORITY] = { .type = NLA_U32 },
141 [FRA_SRC] = { .minlen = sizeof(struct in6_addr) },
142 [FRA_DST] = { .minlen = sizeof(struct in6_addr) },

--- 24 unchanged lines hidden (view full) ---

167 if (tb[FRA_SRC])
168 nla_memcpy(&rule6->src.addr, tb[FRA_SRC],
169 sizeof(struct in6_addr));
170
171 if (tb[FRA_DST])
172 nla_memcpy(&rule6->dst.addr, tb[FRA_DST],
173 sizeof(struct in6_addr));
174
175#ifdef CONFIG_IPV6_ROUTE_FWMARK
176 if (tb[FRA_FWMARK])
177 rule6->fwmark = nla_get_u32(tb[FRA_FWMARK]);
178#endif
179
167 rule6->src.plen = frh->src_len;
168 rule6->dst.plen = frh->dst_len;
169 rule6->tclass = frh->tos;
170
171 err = 0;
172errout:
173 return err;
174}

--- 15 unchanged lines hidden (view full) ---

190 if (tb[FRA_SRC] &&
191 nla_memcmp(tb[FRA_SRC], &rule6->src.addr, sizeof(struct in6_addr)))
192 return 0;
193
194 if (tb[FRA_DST] &&
195 nla_memcmp(tb[FRA_DST], &rule6->dst.addr, sizeof(struct in6_addr)))
196 return 0;
197
180 rule6->src.plen = frh->src_len;
181 rule6->dst.plen = frh->dst_len;
182 rule6->tclass = frh->tos;
183
184 err = 0;
185errout:
186 return err;
187}

--- 15 unchanged lines hidden (view full) ---

203 if (tb[FRA_SRC] &&
204 nla_memcmp(tb[FRA_SRC], &rule6->src.addr, sizeof(struct in6_addr)))
205 return 0;
206
207 if (tb[FRA_DST] &&
208 nla_memcmp(tb[FRA_DST], &rule6->dst.addr, sizeof(struct in6_addr)))
209 return 0;
210
211#ifdef CONFIG_IPV6_ROUTE_FWMARK
212 if (tb[FRA_FWMARK] && (rule6->fwmark != nla_get_u32(tb[FRA_FWMARK])))
213 return 0;
214#endif
215
198 return 1;
199}
200
201static int fib6_rule_fill(struct fib_rule *rule, struct sk_buff *skb,
202 struct nlmsghdr *nlh, struct fib_rule_hdr *frh)
203{
204 struct fib6_rule *rule6 = (struct fib6_rule *) rule;
205

--- 5 unchanged lines hidden (view full) ---

211 if (rule6->dst.plen)
212 NLA_PUT(skb, FRA_DST, sizeof(struct in6_addr),
213 &rule6->dst.addr);
214
215 if (rule6->src.plen)
216 NLA_PUT(skb, FRA_SRC, sizeof(struct in6_addr),
217 &rule6->src.addr);
218
216 return 1;
217}
218
219static int fib6_rule_fill(struct fib_rule *rule, struct sk_buff *skb,
220 struct nlmsghdr *nlh, struct fib_rule_hdr *frh)
221{
222 struct fib6_rule *rule6 = (struct fib6_rule *) rule;
223

--- 5 unchanged lines hidden (view full) ---

229 if (rule6->dst.plen)
230 NLA_PUT(skb, FRA_DST, sizeof(struct in6_addr),
231 &rule6->dst.addr);
232
233 if (rule6->src.plen)
234 NLA_PUT(skb, FRA_SRC, sizeof(struct in6_addr),
235 &rule6->src.addr);
236
237#ifdef CONFIG_IPV6_ROUTE_FWMARK
238 if (rule6->fwmark)
239 NLA_PUT_U32(skb, FRA_FWMARK, rule6->fwmark);
240#endif
241
219 return 0;
220
221nla_put_failure:
222 return -ENOBUFS;
223}
224
225int fib6_rules_dump(struct sk_buff *skb, struct netlink_callback *cb)
226{

--- 35 unchanged lines hidden ---
242 return 0;
243
244nla_put_failure:
245 return -ENOBUFS;
246}
247
248int fib6_rules_dump(struct sk_buff *skb, struct netlink_callback *cb)
249{

--- 35 unchanged lines hidden ---