diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2007-04-19 23:29:13 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2007-04-26 01:26:28 -0400 |
commit | 27a884dc3cb63b93c2b3b643f5b31eed5f8a4d26 (patch) | |
tree | 5a267e40f9b94014be38dad5de0a52b6628834e0 /net/xfrm | |
parent | be8bd86321fa7f06359d866ef61fb4d2f3e9dce9 (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/xfrm')
-rw-r--r-- | net/xfrm/xfrm_user.c | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c index 816e3690b60f..814bb3125ada 100644 --- a/net/xfrm/xfrm_user.c +++ b/net/xfrm/xfrm_user.c | |||
@@ -576,7 +576,7 @@ static int dump_one_state(struct xfrm_state *x, int count, void *ptr) | |||
576 | struct sk_buff *skb = sp->out_skb; | 576 | struct sk_buff *skb = sp->out_skb; |
577 | struct xfrm_usersa_info *p; | 577 | struct xfrm_usersa_info *p; |
578 | struct nlmsghdr *nlh; | 578 | struct nlmsghdr *nlh; |
579 | unsigned char *b = skb->tail; | 579 | unsigned char *b = skb_tail_pointer(skb); |
580 | 580 | ||
581 | if (sp->this_idx < sp->start_idx) | 581 | if (sp->this_idx < sp->start_idx) |
582 | goto out; | 582 | goto out; |
@@ -621,7 +621,7 @@ static int dump_one_state(struct xfrm_state *x, int count, void *ptr) | |||
621 | if (x->lastused) | 621 | if (x->lastused) |
622 | RTA_PUT(skb, XFRMA_LASTUSED, sizeof(x->lastused), &x->lastused); | 622 | RTA_PUT(skb, XFRMA_LASTUSED, sizeof(x->lastused), &x->lastused); |
623 | 623 | ||
624 | nlh->nlmsg_len = skb->tail - b; | 624 | nlh->nlmsg_len = skb_tail_pointer(skb) - b; |
625 | out: | 625 | out: |
626 | sp->this_idx++; | 626 | sp->this_idx++; |
627 | return 0; | 627 | return 0; |
@@ -1157,7 +1157,7 @@ static int dump_one_policy(struct xfrm_policy *xp, int dir, int count, void *ptr | |||
1157 | struct sk_buff *in_skb = sp->in_skb; | 1157 | struct sk_buff *in_skb = sp->in_skb; |
1158 | struct sk_buff *skb = sp->out_skb; | 1158 | struct sk_buff *skb = sp->out_skb; |
1159 | struct nlmsghdr *nlh; | 1159 | struct nlmsghdr *nlh; |
1160 | unsigned char *b = skb->tail; | 1160 | unsigned char *b = skb_tail_pointer(skb); |
1161 | 1161 | ||
1162 | if (sp->this_idx < sp->start_idx) | 1162 | if (sp->this_idx < sp->start_idx) |
1163 | goto out; | 1163 | goto out; |
@@ -1176,7 +1176,7 @@ static int dump_one_policy(struct xfrm_policy *xp, int dir, int count, void *ptr | |||
1176 | if (copy_to_user_policy_type(xp->type, skb) < 0) | 1176 | if (copy_to_user_policy_type(xp->type, skb) < 0) |
1177 | goto nlmsg_failure; | 1177 | goto nlmsg_failure; |
1178 | 1178 | ||
1179 | nlh->nlmsg_len = skb->tail - b; | 1179 | nlh->nlmsg_len = skb_tail_pointer(skb) - b; |
1180 | out: | 1180 | out: |
1181 | sp->this_idx++; | 1181 | sp->this_idx++; |
1182 | return 0; | 1182 | return 0; |
@@ -1330,7 +1330,7 @@ static int build_aevent(struct sk_buff *skb, struct xfrm_state *x, struct km_eve | |||
1330 | struct xfrm_aevent_id *id; | 1330 | struct xfrm_aevent_id *id; |
1331 | struct nlmsghdr *nlh; | 1331 | struct nlmsghdr *nlh; |
1332 | struct xfrm_lifetime_cur ltime; | 1332 | struct xfrm_lifetime_cur ltime; |
1333 | unsigned char *b = skb->tail; | 1333 | unsigned char *b = skb_tail_pointer(skb); |
1334 | 1334 | ||
1335 | nlh = NLMSG_PUT(skb, c->pid, c->seq, XFRM_MSG_NEWAE, sizeof(*id)); | 1335 | nlh = NLMSG_PUT(skb, c->pid, c->seq, XFRM_MSG_NEWAE, sizeof(*id)); |
1336 | id = NLMSG_DATA(nlh); | 1336 | id = NLMSG_DATA(nlh); |
@@ -1362,7 +1362,7 @@ static int build_aevent(struct sk_buff *skb, struct xfrm_state *x, struct km_eve | |||
1362 | RTA_PUT(skb,XFRMA_ETIMER_THRESH,sizeof(u32),&etimer); | 1362 | RTA_PUT(skb,XFRMA_ETIMER_THRESH,sizeof(u32),&etimer); |
1363 | } | 1363 | } |
1364 | 1364 | ||
1365 | nlh->nlmsg_len = skb->tail - b; | 1365 | nlh->nlmsg_len = skb_tail_pointer(skb) - b; |
1366 | return skb->len; | 1366 | return skb->len; |
1367 | 1367 | ||
1368 | rtattr_failure: | 1368 | rtattr_failure: |
@@ -1744,7 +1744,7 @@ static int build_migrate(struct sk_buff *skb, struct xfrm_migrate *m, | |||
1744 | struct xfrm_migrate *mp; | 1744 | struct xfrm_migrate *mp; |
1745 | struct xfrm_userpolicy_id *pol_id; | 1745 | struct xfrm_userpolicy_id *pol_id; |
1746 | struct nlmsghdr *nlh; | 1746 | struct nlmsghdr *nlh; |
1747 | unsigned char *b = skb->tail; | 1747 | unsigned char *b = skb_tail_pointer(skb); |
1748 | int i; | 1748 | int i; |
1749 | 1749 | ||
1750 | nlh = NLMSG_PUT(skb, 0, 0, XFRM_MSG_MIGRATE, sizeof(*pol_id)); | 1750 | nlh = NLMSG_PUT(skb, 0, 0, XFRM_MSG_MIGRATE, sizeof(*pol_id)); |
@@ -1764,7 +1764,7 @@ static int build_migrate(struct sk_buff *skb, struct xfrm_migrate *m, | |||
1764 | goto nlmsg_failure; | 1764 | goto nlmsg_failure; |
1765 | } | 1765 | } |
1766 | 1766 | ||
1767 | nlh->nlmsg_len = skb->tail - b; | 1767 | nlh->nlmsg_len = skb_tail_pointer(skb) - b; |
1768 | return skb->len; | 1768 | return skb->len; |
1769 | nlmsg_failure: | 1769 | nlmsg_failure: |
1770 | skb_trim(skb, b - skb->data); | 1770 | skb_trim(skb, b - skb->data); |
@@ -1942,7 +1942,7 @@ static int build_expire(struct sk_buff *skb, struct xfrm_state *x, struct km_eve | |||
1942 | { | 1942 | { |
1943 | struct xfrm_user_expire *ue; | 1943 | struct xfrm_user_expire *ue; |
1944 | struct nlmsghdr *nlh; | 1944 | struct nlmsghdr *nlh; |
1945 | unsigned char *b = skb->tail; | 1945 | unsigned char *b = skb_tail_pointer(skb); |
1946 | 1946 | ||
1947 | nlh = NLMSG_PUT(skb, c->pid, 0, XFRM_MSG_EXPIRE, | 1947 | nlh = NLMSG_PUT(skb, c->pid, 0, XFRM_MSG_EXPIRE, |
1948 | sizeof(*ue)); | 1948 | sizeof(*ue)); |
@@ -1952,7 +1952,7 @@ static int build_expire(struct sk_buff *skb, struct xfrm_state *x, struct km_eve | |||
1952 | copy_to_user_state(x, &ue->state); | 1952 | copy_to_user_state(x, &ue->state); |
1953 | ue->hard = (c->data.hard != 0) ? 1 : 0; | 1953 | ue->hard = (c->data.hard != 0) ? 1 : 0; |
1954 | 1954 | ||
1955 | nlh->nlmsg_len = skb->tail - b; | 1955 | nlh->nlmsg_len = skb_tail_pointer(skb) - b; |
1956 | return skb->len; | 1956 | return skb->len; |
1957 | 1957 | ||
1958 | nlmsg_failure: | 1958 | nlmsg_failure: |
@@ -1999,7 +1999,7 @@ static int xfrm_notify_sa_flush(struct km_event *c) | |||
1999 | struct xfrm_usersa_flush *p; | 1999 | struct xfrm_usersa_flush *p; |
2000 | struct nlmsghdr *nlh; | 2000 | struct nlmsghdr *nlh; |
2001 | struct sk_buff *skb; | 2001 | struct sk_buff *skb; |
2002 | unsigned char *b; | 2002 | sk_buff_data_t b; |
2003 | int len = NLMSG_LENGTH(sizeof(struct xfrm_usersa_flush)); | 2003 | int len = NLMSG_LENGTH(sizeof(struct xfrm_usersa_flush)); |
2004 | 2004 | ||
2005 | skb = alloc_skb(len, GFP_ATOMIC); | 2005 | skb = alloc_skb(len, GFP_ATOMIC); |
@@ -2045,7 +2045,7 @@ static int xfrm_notify_sa(struct xfrm_state *x, struct km_event *c) | |||
2045 | struct xfrm_usersa_id *id; | 2045 | struct xfrm_usersa_id *id; |
2046 | struct nlmsghdr *nlh; | 2046 | struct nlmsghdr *nlh; |
2047 | struct sk_buff *skb; | 2047 | struct sk_buff *skb; |
2048 | unsigned char *b; | 2048 | sk_buff_data_t b; |
2049 | int len = xfrm_sa_len(x); | 2049 | int len = xfrm_sa_len(x); |
2050 | int headlen; | 2050 | int headlen; |
2051 | 2051 | ||
@@ -2129,7 +2129,7 @@ static int build_acquire(struct sk_buff *skb, struct xfrm_state *x, | |||
2129 | { | 2129 | { |
2130 | struct xfrm_user_acquire *ua; | 2130 | struct xfrm_user_acquire *ua; |
2131 | struct nlmsghdr *nlh; | 2131 | struct nlmsghdr *nlh; |
2132 | unsigned char *b = skb->tail; | 2132 | unsigned char *b = skb_tail_pointer(skb); |
2133 | __u32 seq = xfrm_get_acqseq(); | 2133 | __u32 seq = xfrm_get_acqseq(); |
2134 | 2134 | ||
2135 | nlh = NLMSG_PUT(skb, 0, 0, XFRM_MSG_ACQUIRE, | 2135 | nlh = NLMSG_PUT(skb, 0, 0, XFRM_MSG_ACQUIRE, |
@@ -2153,7 +2153,7 @@ static int build_acquire(struct sk_buff *skb, struct xfrm_state *x, | |||
2153 | if (copy_to_user_policy_type(xp->type, skb) < 0) | 2153 | if (copy_to_user_policy_type(xp->type, skb) < 0) |
2154 | goto nlmsg_failure; | 2154 | goto nlmsg_failure; |
2155 | 2155 | ||
2156 | nlh->nlmsg_len = skb->tail - b; | 2156 | nlh->nlmsg_len = skb_tail_pointer(skb) - b; |
2157 | return skb->len; | 2157 | return skb->len; |
2158 | 2158 | ||
2159 | nlmsg_failure: | 2159 | nlmsg_failure: |
@@ -2249,7 +2249,7 @@ static int build_polexpire(struct sk_buff *skb, struct xfrm_policy *xp, | |||
2249 | struct xfrm_user_polexpire *upe; | 2249 | struct xfrm_user_polexpire *upe; |
2250 | struct nlmsghdr *nlh; | 2250 | struct nlmsghdr *nlh; |
2251 | int hard = c->data.hard; | 2251 | int hard = c->data.hard; |
2252 | unsigned char *b = skb->tail; | 2252 | unsigned char *b = skb_tail_pointer(skb); |
2253 | 2253 | ||
2254 | nlh = NLMSG_PUT(skb, c->pid, 0, XFRM_MSG_POLEXPIRE, sizeof(*upe)); | 2254 | nlh = NLMSG_PUT(skb, c->pid, 0, XFRM_MSG_POLEXPIRE, sizeof(*upe)); |
2255 | upe = NLMSG_DATA(nlh); | 2255 | upe = NLMSG_DATA(nlh); |
@@ -2264,7 +2264,7 @@ static int build_polexpire(struct sk_buff *skb, struct xfrm_policy *xp, | |||
2264 | goto nlmsg_failure; | 2264 | goto nlmsg_failure; |
2265 | upe->hard = !!hard; | 2265 | upe->hard = !!hard; |
2266 | 2266 | ||
2267 | nlh->nlmsg_len = skb->tail - b; | 2267 | nlh->nlmsg_len = skb_tail_pointer(skb) - b; |
2268 | return skb->len; | 2268 | return skb->len; |
2269 | 2269 | ||
2270 | nlmsg_failure: | 2270 | nlmsg_failure: |
@@ -2300,7 +2300,7 @@ static int xfrm_notify_policy(struct xfrm_policy *xp, int dir, struct km_event * | |||
2300 | struct xfrm_userpolicy_id *id; | 2300 | struct xfrm_userpolicy_id *id; |
2301 | struct nlmsghdr *nlh; | 2301 | struct nlmsghdr *nlh; |
2302 | struct sk_buff *skb; | 2302 | struct sk_buff *skb; |
2303 | unsigned char *b; | 2303 | sk_buff_data_t b; |
2304 | int len = RTA_SPACE(sizeof(struct xfrm_user_tmpl) * xp->xfrm_nr); | 2304 | int len = RTA_SPACE(sizeof(struct xfrm_user_tmpl) * xp->xfrm_nr); |
2305 | int headlen; | 2305 | int headlen; |
2306 | 2306 | ||
@@ -2357,7 +2357,7 @@ static int xfrm_notify_policy_flush(struct km_event *c) | |||
2357 | { | 2357 | { |
2358 | struct nlmsghdr *nlh; | 2358 | struct nlmsghdr *nlh; |
2359 | struct sk_buff *skb; | 2359 | struct sk_buff *skb; |
2360 | unsigned char *b; | 2360 | sk_buff_data_t b; |
2361 | int len = 0; | 2361 | int len = 0; |
2362 | #ifdef CONFIG_XFRM_SUB_POLICY | 2362 | #ifdef CONFIG_XFRM_SUB_POLICY |
2363 | len += RTA_SPACE(sizeof(struct xfrm_userpolicy_type)); | 2363 | len += RTA_SPACE(sizeof(struct xfrm_userpolicy_type)); |
@@ -2410,7 +2410,7 @@ static int build_report(struct sk_buff *skb, u8 proto, | |||
2410 | { | 2410 | { |
2411 | struct xfrm_user_report *ur; | 2411 | struct xfrm_user_report *ur; |
2412 | struct nlmsghdr *nlh; | 2412 | struct nlmsghdr *nlh; |
2413 | unsigned char *b = skb->tail; | 2413 | unsigned char *b = skb_tail_pointer(skb); |
2414 | 2414 | ||
2415 | nlh = NLMSG_PUT(skb, 0, 0, XFRM_MSG_REPORT, sizeof(*ur)); | 2415 | nlh = NLMSG_PUT(skb, 0, 0, XFRM_MSG_REPORT, sizeof(*ur)); |
2416 | ur = NLMSG_DATA(nlh); | 2416 | ur = NLMSG_DATA(nlh); |
@@ -2422,7 +2422,7 @@ static int build_report(struct sk_buff *skb, u8 proto, | |||
2422 | if (addr) | 2422 | if (addr) |
2423 | RTA_PUT(skb, XFRMA_COADDR, sizeof(*addr), addr); | 2423 | RTA_PUT(skb, XFRMA_COADDR, sizeof(*addr), addr); |
2424 | 2424 | ||
2425 | nlh->nlmsg_len = skb->tail - b; | 2425 | nlh->nlmsg_len = skb_tail_pointer(skb) - b; |
2426 | return skb->len; | 2426 | return skb->len; |
2427 | 2427 | ||
2428 | nlmsg_failure: | 2428 | nlmsg_failure: |