diff options
Diffstat (limited to 'net/sched/cls_api.c')
-rw-r--r-- | net/sched/cls_api.c | 36 |
1 files changed, 14 insertions, 22 deletions
diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c index 5c6ffdb77d2d..ebf94edf0478 100644 --- a/net/sched/cls_api.c +++ b/net/sched/cls_api.c | |||
@@ -29,9 +29,10 @@ | |||
29 | #include <linux/interrupt.h> | 29 | #include <linux/interrupt.h> |
30 | #include <linux/netdevice.h> | 30 | #include <linux/netdevice.h> |
31 | #include <linux/skbuff.h> | 31 | #include <linux/skbuff.h> |
32 | #include <linux/rtnetlink.h> | ||
33 | #include <linux/init.h> | 32 | #include <linux/init.h> |
34 | #include <linux/kmod.h> | 33 | #include <linux/kmod.h> |
34 | #include <linux/netlink.h> | ||
35 | #include <net/netlink.h> | ||
35 | #include <net/sock.h> | 36 | #include <net/sock.h> |
36 | #include <net/pkt_sched.h> | 37 | #include <net/pkt_sched.h> |
37 | #include <net/pkt_cls.h> | 38 | #include <net/pkt_cls.h> |
@@ -323,7 +324,7 @@ tcf_fill_node(struct sk_buff *skb, struct tcf_proto *tp, unsigned long fh, | |||
323 | { | 324 | { |
324 | struct tcmsg *tcm; | 325 | struct tcmsg *tcm; |
325 | struct nlmsghdr *nlh; | 326 | struct nlmsghdr *nlh; |
326 | unsigned char *b = skb->tail; | 327 | unsigned char *b = skb_tail_pointer(skb); |
327 | 328 | ||
328 | nlh = NLMSG_NEW(skb, pid, seq, event, sizeof(*tcm), flags); | 329 | nlh = NLMSG_NEW(skb, pid, seq, event, sizeof(*tcm), flags); |
329 | tcm = NLMSG_DATA(nlh); | 330 | tcm = NLMSG_DATA(nlh); |
@@ -340,12 +341,12 @@ tcf_fill_node(struct sk_buff *skb, struct tcf_proto *tp, unsigned long fh, | |||
340 | if (tp->ops->dump && tp->ops->dump(tp, fh, skb, tcm) < 0) | 341 | if (tp->ops->dump && tp->ops->dump(tp, fh, skb, tcm) < 0) |
341 | goto rtattr_failure; | 342 | goto rtattr_failure; |
342 | } | 343 | } |
343 | nlh->nlmsg_len = skb->tail - b; | 344 | nlh->nlmsg_len = skb_tail_pointer(skb) - b; |
344 | return skb->len; | 345 | return skb->len; |
345 | 346 | ||
346 | nlmsg_failure: | 347 | nlmsg_failure: |
347 | rtattr_failure: | 348 | rtattr_failure: |
348 | skb_trim(skb, b - skb->data); | 349 | nlmsg_trim(skb, b); |
349 | return -1; | 350 | return -1; |
350 | } | 351 | } |
351 | 352 | ||
@@ -399,7 +400,6 @@ static int tc_dump_tfilter(struct sk_buff *skb, struct netlink_callback *cb) | |||
399 | if ((dev = dev_get_by_index(tcm->tcm_ifindex)) == NULL) | 400 | if ((dev = dev_get_by_index(tcm->tcm_ifindex)) == NULL) |
400 | return skb->len; | 401 | return skb->len; |
401 | 402 | ||
402 | read_lock(&qdisc_tree_lock); | ||
403 | if (!tcm->tcm_parent) | 403 | if (!tcm->tcm_parent) |
404 | q = dev->qdisc_sleeping; | 404 | q = dev->qdisc_sleeping; |
405 | else | 405 | else |
@@ -456,7 +456,6 @@ errout: | |||
456 | if (cl) | 456 | if (cl) |
457 | cops->put(q, cl); | 457 | cops->put(q, cl); |
458 | out: | 458 | out: |
459 | read_unlock(&qdisc_tree_lock); | ||
460 | dev_put(dev); | 459 | dev_put(dev); |
461 | return skb->len; | 460 | return skb->len; |
462 | } | 461 | } |
@@ -563,30 +562,30 @@ tcf_exts_dump(struct sk_buff *skb, struct tcf_exts *exts, | |||
563 | * to work with both old and new modes of entering | 562 | * to work with both old and new modes of entering |
564 | * tc data even if iproute2 was newer - jhs | 563 | * tc data even if iproute2 was newer - jhs |
565 | */ | 564 | */ |
566 | struct rtattr * p_rta = (struct rtattr*) skb->tail; | 565 | struct rtattr *p_rta = (struct rtattr *)skb_tail_pointer(skb); |
567 | 566 | ||
568 | if (exts->action->type != TCA_OLD_COMPAT) { | 567 | if (exts->action->type != TCA_OLD_COMPAT) { |
569 | RTA_PUT(skb, map->action, 0, NULL); | 568 | RTA_PUT(skb, map->action, 0, NULL); |
570 | if (tcf_action_dump(skb, exts->action, 0, 0) < 0) | 569 | if (tcf_action_dump(skb, exts->action, 0, 0) < 0) |
571 | goto rtattr_failure; | 570 | goto rtattr_failure; |
572 | p_rta->rta_len = skb->tail - (u8*)p_rta; | 571 | p_rta->rta_len = skb_tail_pointer(skb) - (u8 *)p_rta; |
573 | } else if (map->police) { | 572 | } else if (map->police) { |
574 | RTA_PUT(skb, map->police, 0, NULL); | 573 | RTA_PUT(skb, map->police, 0, NULL); |
575 | if (tcf_action_dump_old(skb, exts->action, 0, 0) < 0) | 574 | if (tcf_action_dump_old(skb, exts->action, 0, 0) < 0) |
576 | goto rtattr_failure; | 575 | goto rtattr_failure; |
577 | p_rta->rta_len = skb->tail - (u8*)p_rta; | 576 | p_rta->rta_len = skb_tail_pointer(skb) - (u8 *)p_rta; |
578 | } | 577 | } |
579 | } | 578 | } |
580 | #elif defined CONFIG_NET_CLS_POLICE | 579 | #elif defined CONFIG_NET_CLS_POLICE |
581 | if (map->police && exts->police) { | 580 | if (map->police && exts->police) { |
582 | struct rtattr * p_rta = (struct rtattr*) skb->tail; | 581 | struct rtattr *p_rta = (struct rtattr *)skb_tail_pointer(skb); |
583 | 582 | ||
584 | RTA_PUT(skb, map->police, 0, NULL); | 583 | RTA_PUT(skb, map->police, 0, NULL); |
585 | 584 | ||
586 | if (tcf_police_dump(skb, exts->police) < 0) | 585 | if (tcf_police_dump(skb, exts->police) < 0) |
587 | goto rtattr_failure; | 586 | goto rtattr_failure; |
588 | 587 | ||
589 | p_rta->rta_len = skb->tail - (u8*)p_rta; | 588 | p_rta->rta_len = skb_tail_pointer(skb) - (u8 *)p_rta; |
590 | } | 589 | } |
591 | #endif | 590 | #endif |
592 | return 0; | 591 | return 0; |
@@ -614,18 +613,11 @@ rtattr_failure: __attribute__ ((unused)) | |||
614 | 613 | ||
615 | static int __init tc_filter_init(void) | 614 | static int __init tc_filter_init(void) |
616 | { | 615 | { |
617 | struct rtnetlink_link *link_p = rtnetlink_links[PF_UNSPEC]; | 616 | rtnl_register(PF_UNSPEC, RTM_NEWTFILTER, tc_ctl_tfilter, NULL); |
617 | rtnl_register(PF_UNSPEC, RTM_DELTFILTER, tc_ctl_tfilter, NULL); | ||
618 | rtnl_register(PF_UNSPEC, RTM_GETTFILTER, tc_ctl_tfilter, | ||
619 | tc_dump_tfilter); | ||
618 | 620 | ||
619 | /* Setup rtnetlink links. It is made here to avoid | ||
620 | exporting large number of public symbols. | ||
621 | */ | ||
622 | |||
623 | if (link_p) { | ||
624 | link_p[RTM_NEWTFILTER-RTM_BASE].doit = tc_ctl_tfilter; | ||
625 | link_p[RTM_DELTFILTER-RTM_BASE].doit = tc_ctl_tfilter; | ||
626 | link_p[RTM_GETTFILTER-RTM_BASE].doit = tc_ctl_tfilter; | ||
627 | link_p[RTM_GETTFILTER-RTM_BASE].dumpit = tc_dump_tfilter; | ||
628 | } | ||
629 | return 0; | 621 | return 0; |
630 | } | 622 | } |
631 | 623 | ||