aboutsummaryrefslogtreecommitdiffstats
path: root/net/sched/act_api.c
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2007-04-19 23:29:13 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2007-04-26 01:26:28 -0400
commit27a884dc3cb63b93c2b3b643f5b31eed5f8a4d26 (patch)
tree5a267e40f9b94014be38dad5de0a52b6628834e0 /net/sched/act_api.c
parentbe8bd86321fa7f06359d866ef61fb4d2f3e9dce9 (diff)
[SK_BUFF]: Convert skb->tail to sk_buff_data_t
So that it is also an offset from skb->head, reduces its size from 8 to 4 bytes on 64bit architectures, allowing us to combine the 4 bytes hole left by the layer headers conversion, reducing struct sk_buff size to 256 bytes, i.e. 4 64byte cachelines, and since the sk_buff slab cache is SLAB_HWCACHE_ALIGN... :-) Many calculations that previously required that skb->{transport,network, mac}_header be first converted to a pointer now can be done directly, being meaningful as offsets or pointers. Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/sched/act_api.c')
-rw-r--r--net/sched/act_api.c52
1 files changed, 26 insertions, 26 deletions
diff --git a/net/sched/act_api.c b/net/sched/act_api.c
index cb21617a5670..28326fb1fc4e 100644
--- a/net/sched/act_api.c
+++ b/net/sched/act_api.c
@@ -93,7 +93,7 @@ static int tcf_dump_walker(struct sk_buff *skb, struct netlink_callback *cb,
93 continue; 93 continue;
94 a->priv = p; 94 a->priv = p;
95 a->order = n_i; 95 a->order = n_i;
96 r = (struct rtattr*) skb->tail; 96 r = (struct rtattr *)skb_tail_pointer(skb);
97 RTA_PUT(skb, a->order, 0, NULL); 97 RTA_PUT(skb, a->order, 0, NULL);
98 err = tcf_action_dump_1(skb, a, 0, 0); 98 err = tcf_action_dump_1(skb, a, 0, 0);
99 if (err < 0) { 99 if (err < 0) {
@@ -101,7 +101,7 @@ static int tcf_dump_walker(struct sk_buff *skb, struct netlink_callback *cb,
101 skb_trim(skb, (u8*)r - skb->data); 101 skb_trim(skb, (u8*)r - skb->data);
102 goto done; 102 goto done;
103 } 103 }
104 r->rta_len = skb->tail - (u8*)r; 104 r->rta_len = skb_tail_pointer(skb) - (u8 *)r;
105 n_i++; 105 n_i++;
106 if (n_i >= TCA_ACT_MAX_PRIO) 106 if (n_i >= TCA_ACT_MAX_PRIO)
107 goto done; 107 goto done;
@@ -125,7 +125,7 @@ static int tcf_del_walker(struct sk_buff *skb, struct tc_action *a,
125 struct rtattr *r ; 125 struct rtattr *r ;
126 int i= 0, n_i = 0; 126 int i= 0, n_i = 0;
127 127
128 r = (struct rtattr*) skb->tail; 128 r = (struct rtattr *)skb_tail_pointer(skb);
129 RTA_PUT(skb, a->order, 0, NULL); 129 RTA_PUT(skb, a->order, 0, NULL);
130 RTA_PUT(skb, TCA_KIND, IFNAMSIZ, a->ops->kind); 130 RTA_PUT(skb, TCA_KIND, IFNAMSIZ, a->ops->kind);
131 for (i = 0; i < (hinfo->hmask + 1); i++) { 131 for (i = 0; i < (hinfo->hmask + 1); i++) {
@@ -140,7 +140,7 @@ static int tcf_del_walker(struct sk_buff *skb, struct tc_action *a,
140 } 140 }
141 } 141 }
142 RTA_PUT(skb, TCA_FCNT, 4, &n_i); 142 RTA_PUT(skb, TCA_FCNT, 4, &n_i);
143 r->rta_len = skb->tail - (u8*)r; 143 r->rta_len = skb_tail_pointer(skb) - (u8 *)r;
144 144
145 return n_i; 145 return n_i;
146rtattr_failure: 146rtattr_failure:
@@ -423,7 +423,7 @@ int
423tcf_action_dump_1(struct sk_buff *skb, struct tc_action *a, int bind, int ref) 423tcf_action_dump_1(struct sk_buff *skb, struct tc_action *a, int bind, int ref)
424{ 424{
425 int err = -EINVAL; 425 int err = -EINVAL;
426 unsigned char *b = skb->tail; 426 unsigned char *b = skb_tail_pointer(skb);
427 struct rtattr *r; 427 struct rtattr *r;
428 428
429 if (a->ops == NULL || a->ops->dump == NULL) 429 if (a->ops == NULL || a->ops->dump == NULL)
@@ -432,10 +432,10 @@ tcf_action_dump_1(struct sk_buff *skb, struct tc_action *a, int bind, int ref)
432 RTA_PUT(skb, TCA_KIND, IFNAMSIZ, a->ops->kind); 432 RTA_PUT(skb, TCA_KIND, IFNAMSIZ, a->ops->kind);
433 if (tcf_action_copy_stats(skb, a, 0)) 433 if (tcf_action_copy_stats(skb, a, 0))
434 goto rtattr_failure; 434 goto rtattr_failure;
435 r = (struct rtattr*) skb->tail; 435 r = (struct rtattr *)skb_tail_pointer(skb);
436 RTA_PUT(skb, TCA_OPTIONS, 0, NULL); 436 RTA_PUT(skb, TCA_OPTIONS, 0, NULL);
437 if ((err = tcf_action_dump_old(skb, a, bind, ref)) > 0) { 437 if ((err = tcf_action_dump_old(skb, a, bind, ref)) > 0) {
438 r->rta_len = skb->tail - (u8*)r; 438 r->rta_len = skb_tail_pointer(skb) - (u8 *)r;
439 return err; 439 return err;
440 } 440 }
441 441
@@ -449,17 +449,17 @@ tcf_action_dump(struct sk_buff *skb, struct tc_action *act, int bind, int ref)
449{ 449{
450 struct tc_action *a; 450 struct tc_action *a;
451 int err = -EINVAL; 451 int err = -EINVAL;
452 unsigned char *b = skb->tail; 452 unsigned char *b = skb_tail_pointer(skb);
453 struct rtattr *r ; 453 struct rtattr *r ;
454 454
455 while ((a = act) != NULL) { 455 while ((a = act) != NULL) {
456 r = (struct rtattr*) skb->tail; 456 r = (struct rtattr *)skb_tail_pointer(skb);
457 act = a->next; 457 act = a->next;
458 RTA_PUT(skb, a->order, 0, NULL); 458 RTA_PUT(skb, a->order, 0, NULL);
459 err = tcf_action_dump_1(skb, a, bind, ref); 459 err = tcf_action_dump_1(skb, a, bind, ref);
460 if (err < 0) 460 if (err < 0)
461 goto errout; 461 goto errout;
462 r->rta_len = skb->tail - (u8*)r; 462 r->rta_len = skb_tail_pointer(skb) - (u8 *)r;
463 } 463 }
464 464
465 return 0; 465 return 0;
@@ -635,7 +635,7 @@ tca_get_fill(struct sk_buff *skb, struct tc_action *a, u32 pid, u32 seq,
635{ 635{
636 struct tcamsg *t; 636 struct tcamsg *t;
637 struct nlmsghdr *nlh; 637 struct nlmsghdr *nlh;
638 unsigned char *b = skb->tail; 638 unsigned char *b = skb_tail_pointer(skb);
639 struct rtattr *x; 639 struct rtattr *x;
640 640
641 nlh = NLMSG_NEW(skb, pid, seq, event, sizeof(*t), flags); 641 nlh = NLMSG_NEW(skb, pid, seq, event, sizeof(*t), flags);
@@ -645,15 +645,15 @@ tca_get_fill(struct sk_buff *skb, struct tc_action *a, u32 pid, u32 seq,
645 t->tca__pad1 = 0; 645 t->tca__pad1 = 0;
646 t->tca__pad2 = 0; 646 t->tca__pad2 = 0;
647 647
648 x = (struct rtattr*) skb->tail; 648 x = (struct rtattr *)skb_tail_pointer(skb);
649 RTA_PUT(skb, TCA_ACT_TAB, 0, NULL); 649 RTA_PUT(skb, TCA_ACT_TAB, 0, NULL);
650 650
651 if (tcf_action_dump(skb, a, bind, ref) < 0) 651 if (tcf_action_dump(skb, a, bind, ref) < 0)
652 goto rtattr_failure; 652 goto rtattr_failure;
653 653
654 x->rta_len = skb->tail - (u8*)x; 654 x->rta_len = skb_tail_pointer(skb) - (u8 *)x;
655 655
656 nlh->nlmsg_len = skb->tail - b; 656 nlh->nlmsg_len = skb_tail_pointer(skb) - b;
657 return skb->len; 657 return skb->len;
658 658
659rtattr_failure: 659rtattr_failure:
@@ -767,7 +767,7 @@ static int tca_action_flush(struct rtattr *rta, struct nlmsghdr *n, u32 pid)
767 return -ENOBUFS; 767 return -ENOBUFS;
768 } 768 }
769 769
770 b = (unsigned char *)skb->tail; 770 b = skb_tail_pointer(skb);
771 771
772 if (rtattr_parse_nested(tb, TCA_ACT_MAX, rta) < 0) 772 if (rtattr_parse_nested(tb, TCA_ACT_MAX, rta) < 0)
773 goto err_out; 773 goto err_out;
@@ -783,16 +783,16 @@ static int tca_action_flush(struct rtattr *rta, struct nlmsghdr *n, u32 pid)
783 t->tca__pad1 = 0; 783 t->tca__pad1 = 0;
784 t->tca__pad2 = 0; 784 t->tca__pad2 = 0;
785 785
786 x = (struct rtattr *) skb->tail; 786 x = (struct rtattr *)skb_tail_pointer(skb);
787 RTA_PUT(skb, TCA_ACT_TAB, 0, NULL); 787 RTA_PUT(skb, TCA_ACT_TAB, 0, NULL);
788 788
789 err = a->ops->walk(skb, &dcb, RTM_DELACTION, a); 789 err = a->ops->walk(skb, &dcb, RTM_DELACTION, a);
790 if (err < 0) 790 if (err < 0)
791 goto rtattr_failure; 791 goto rtattr_failure;
792 792
793 x->rta_len = skb->tail - (u8 *) x; 793 x->rta_len = skb_tail_pointer(skb) - (u8 *)x;
794 794
795 nlh->nlmsg_len = skb->tail - b; 795 nlh->nlmsg_len = skb_tail_pointer(skb) - b;
796 nlh->nlmsg_flags |= NLM_F_ROOT; 796 nlh->nlmsg_flags |= NLM_F_ROOT;
797 module_put(a->ops->owner); 797 module_put(a->ops->owner);
798 kfree(a); 798 kfree(a);
@@ -884,7 +884,7 @@ static int tcf_add_notify(struct tc_action *a, u32 pid, u32 seq, int event,
884 if (!skb) 884 if (!skb)
885 return -ENOBUFS; 885 return -ENOBUFS;
886 886
887 b = (unsigned char *)skb->tail; 887 b = skb_tail_pointer(skb);
888 888
889 nlh = NLMSG_NEW(skb, pid, seq, event, sizeof(*t), flags); 889 nlh = NLMSG_NEW(skb, pid, seq, event, sizeof(*t), flags);
890 t = NLMSG_DATA(nlh); 890 t = NLMSG_DATA(nlh);
@@ -892,15 +892,15 @@ static int tcf_add_notify(struct tc_action *a, u32 pid, u32 seq, int event,
892 t->tca__pad1 = 0; 892 t->tca__pad1 = 0;
893 t->tca__pad2 = 0; 893 t->tca__pad2 = 0;
894 894
895 x = (struct rtattr*) skb->tail; 895 x = (struct rtattr *)skb_tail_pointer(skb);
896 RTA_PUT(skb, TCA_ACT_TAB, 0, NULL); 896 RTA_PUT(skb, TCA_ACT_TAB, 0, NULL);
897 897
898 if (tcf_action_dump(skb, a, 0, 0) < 0) 898 if (tcf_action_dump(skb, a, 0, 0) < 0)
899 goto rtattr_failure; 899 goto rtattr_failure;
900 900
901 x->rta_len = skb->tail - (u8*)x; 901 x->rta_len = skb_tail_pointer(skb) - (u8 *)x;
902 902
903 nlh->nlmsg_len = skb->tail - b; 903 nlh->nlmsg_len = skb_tail_pointer(skb) - b;
904 NETLINK_CB(skb).dst_group = RTNLGRP_TC; 904 NETLINK_CB(skb).dst_group = RTNLGRP_TC;
905 905
906 err = rtnetlink_send(skb, pid, RTNLGRP_TC, flags&NLM_F_ECHO); 906 err = rtnetlink_send(skb, pid, RTNLGRP_TC, flags&NLM_F_ECHO);
@@ -1015,7 +1015,7 @@ static int
1015tc_dump_action(struct sk_buff *skb, struct netlink_callback *cb) 1015tc_dump_action(struct sk_buff *skb, struct netlink_callback *cb)
1016{ 1016{
1017 struct nlmsghdr *nlh; 1017 struct nlmsghdr *nlh;
1018 unsigned char *b = skb->tail; 1018 unsigned char *b = skb_tail_pointer(skb);
1019 struct rtattr *x; 1019 struct rtattr *x;
1020 struct tc_action_ops *a_o; 1020 struct tc_action_ops *a_o;
1021 struct tc_action a; 1021 struct tc_action a;
@@ -1048,7 +1048,7 @@ tc_dump_action(struct sk_buff *skb, struct netlink_callback *cb)
1048 t->tca__pad1 = 0; 1048 t->tca__pad1 = 0;
1049 t->tca__pad2 = 0; 1049 t->tca__pad2 = 0;
1050 1050
1051 x = (struct rtattr *) skb->tail; 1051 x = (struct rtattr *)skb_tail_pointer(skb);
1052 RTA_PUT(skb, TCA_ACT_TAB, 0, NULL); 1052 RTA_PUT(skb, TCA_ACT_TAB, 0, NULL);
1053 1053
1054 ret = a_o->walk(skb, cb, RTM_GETACTION, &a); 1054 ret = a_o->walk(skb, cb, RTM_GETACTION, &a);
@@ -1056,12 +1056,12 @@ tc_dump_action(struct sk_buff *skb, struct netlink_callback *cb)
1056 goto rtattr_failure; 1056 goto rtattr_failure;
1057 1057
1058 if (ret > 0) { 1058 if (ret > 0) {
1059 x->rta_len = skb->tail - (u8 *) x; 1059 x->rta_len = skb_tail_pointer(skb) - (u8 *)x;
1060 ret = skb->len; 1060 ret = skb->len;
1061 } else 1061 } else
1062 skb_trim(skb, (u8*)x - skb->data); 1062 skb_trim(skb, (u8*)x - skb->data);
1063 1063
1064 nlh->nlmsg_len = skb->tail - b; 1064 nlh->nlmsg_len = skb_tail_pointer(skb) - b;
1065 if (NETLINK_CB(cb->skb).pid && ret) 1065 if (NETLINK_CB(cb->skb).pid && ret)
1066 nlh->nlmsg_flags |= NLM_F_MULTI; 1066 nlh->nlmsg_flags |= NLM_F_MULTI;
1067 module_put(a_o->owner); 1067 module_put(a_o->owner);