106 return (h ^ protocol ^ tunnelid) & 0xFF;
109 static inline unsigned int hash_src(
__be32 *
src)
124 #define RSVP_APPLY_RESULT() \
126 int r = tcf_exts_exec(skb, &f->exts, res); \
144 #if RSVP_DST_LEN == 4
147 if (!pskb_network_may_pull(skb,
sizeof(*nhptr)))
149 nhptr = ipv6_hdr(skb);
153 if (!pskb_network_may_pull(skb,
sizeof(*nhptr)))
160 #if RSVP_DST_LEN == 4
161 src = &nhptr->
saddr.s6_addr32[0];
162 dst = &nhptr->
daddr.s6_addr32[0];
163 protocol = nhptr->nexthdr;
164 xprt = ((
u8 *)nhptr) +
sizeof(
struct ipv6hdr);
169 xprt = ((
u8 *)nhptr) + (nhptr->ihl<<2);
170 if (ip_is_fragment(nhptr))
174 h1 = hash_dst(dst, protocol, tunnelid);
177 for (s = sht[h1];
s; s = s->
next) {
181 (*(
u32 *)(xprt + s->
dpi.offset) ^ s->
dpi.key)) &&
183 dst[0] == s->
dst[0] &&
184 dst[1] == s->
dst[1] &&
185 dst[2] == s->
dst[2] &&
189 for (f = s->
ht[h2]; f; f = f->
next) {
191 !(f->
spi.mask & (*(
u32 *)(xprt + f->
spi.offset) ^ f->
spi.key))
194 src[0] == f->
src[0] &&
195 src[1] == f->
src[1] &&
206 tunnelid = f->
res.classid;
207 nhptr = (
void *)(xprt + f->
tunnelhdr -
sizeof(*nhptr));
213 for (f = s->
ht[16]; f; f = f->
next) {
229 unsigned int h1 = handle & 0xFF;
230 unsigned int h2 = (handle >> 8) & 0xFF;
235 for (s = sht[h1];
s; s = s->
next) {
236 for (f = s->
ht[h2]; f; f = f->
next) {
238 return (
unsigned long)
f;
244 static void rsvp_put(
struct tcf_proto *tp,
unsigned long f)
248 static int rsvp_init(
struct tcf_proto *tp)
263 tcf_unbind_filter(tp, &f->
res);
268 static void rsvp_destroy(
struct tcf_proto *tp)
279 for (h1 = 0; h1 < 256; h1++) {
282 while ((s = sht[h1]) !=
NULL) {
285 for (h2 = 0; h2 <= 16; h2++) {
288 while ((f = s->
ht[h2]) !=
NULL) {
290 rsvp_delete_filter(tp, f);
299 static int rsvp_delete(
struct tcf_proto *tp,
unsigned long arg)
307 for (fp = &s->
ht[(h >> 8) & 0xFF]; *
fp; fp = &(*fp)->
next) {
312 rsvp_delete_filter(tp, f);
316 for (i = 0; i <= 16; i++)
322 *sp; sp = &(*sp)->
next) {
339 static unsigned int gen_handle(
struct tcf_proto *tp,
unsigned salt)
350 if (rsvp_get(tp, h) == 0)
356 static int tunnel_bts(
struct rsvp_head *data)
361 if (data->
tmap[n] & b)
367 static void tunnel_recycle(
struct rsvp_head *data)
373 memset(tmap, 0,
sizeof(tmap));
375 for (h1 = 0; h1 < 256; h1++) {
377 for (s = sht[h1];
s; s = s->
next) {
378 for (h2 = 0; h2 <= 16; h2++) {
381 for (f = s->
ht[h2]; f; f = f->
next) {
398 for (k = 0; k < 2; k++) {
399 for (i = 255; i > 0; i--) {
402 if (tunnel_bts(data))
405 tunnel_recycle(data);
419 static int rsvp_change(
struct sk_buff *in_skb,
420 struct tcf_proto *tp,
unsigned long base,
437 return handle ? -
EINVAL : 0;
439 err = nla_parse_nested(tb,
TCA_RSVP_MAX, opt, rsvp_policy);
451 if (f->
handle != handle && handle)
454 f->
res.classid = nla_get_u32(tb[TCA_RSVP_CLASSID]);
455 tcf_bind_filter(tp, &f->
res, base);
476 memcpy(f->
src, nla_data(tb[TCA_RSVP_SRC]),
sizeof(f->
src));
477 h2 = hash_src(f->
src);
480 pinfo = nla_data(tb[TCA_RSVP_PINFO]);
485 f->
res.classid = nla_get_u32(tb[TCA_RSVP_CLASSID]);
488 h1 = hash_dst(dst, pinfo ? pinfo->
protocol : 0, pinfo ? pinfo->
tunnelid : 0);
491 if ((f->
handle = gen_handle(tp, h1 | (h2<<8))) == 0)
496 if (f->
res.classid > 255)
500 if (f->
res.classid == 0 &&
501 (f->
res.classid = gen_tunnel(data)) == 0)
505 for (sp = &data->
ht[h1]; (s = *sp) !=
NULL; sp = &s->
next) {
510 dst[0] == s->
dst[0] &&
511 dst[1] == s->
dst[1] &&
512 dst[2] == s->
dst[2] &&
523 tcf_bind_filter(tp, &f->
res, base);
527 for (fp = &s->
ht[h2]; *fp; fp = &(*fp)->
next)
528 if (((*fp)->spi.mask & f->
spi.mask) != f->
spi.mask)
534 *arg = (
unsigned long)f;
552 for (sp = &data->
ht[h1]; *sp; sp = &(*sp)->
next) {
553 if (((*sp)->dpi.mask&s->
dpi.mask) != s->
dpi.mask)
577 for (h = 0; h < 256; h++) {
580 for (s = head->
ht[h]; s; s = s->
next) {
581 for (h1 = 0; h1 <= 16; h1++) {
584 for (f = s->
ht[h1]; f; f = f->
next) {
589 if (arg->
fn(tp, (
unsigned long)f, arg) < 0) {
600 static int rsvp_dump(
struct tcf_proto *tp,
unsigned long fh,
605 unsigned char *b = skb_tail_pointer(skb);
617 goto nla_put_failure;
620 goto nla_put_failure;
627 if (
nla_put(skb, TCA_RSVP_PINFO,
sizeof(pinfo), &pinfo))
628 goto nla_put_failure;
629 if (f->
res.classid &&
630 nla_put_u32(skb, TCA_RSVP_CLASSID, f->
res.classid))
631 goto nla_put_failure;
632 if (((f->
handle >> 8) & 0xFF) != 16 &&
634 goto nla_put_failure;
637 goto nla_put_failure;
639 nla_nest_end(skb, nest);
642 goto nla_put_failure;
652 .classify = rsvp_classify,
654 .destroy = rsvp_destroy,
657 .change = rsvp_change,
658 .delete = rsvp_delete,
664 static int __init init_rsvp(
void)
669 static void __exit exit_rsvp(
void)