aboutsummaryrefslogtreecommitdiffstats
path: root/include/net
diff options
context:
space:
mode:
authorEric Dumazet <dada1@cosmosbay.com>2007-05-03 20:39:04 -0400
committerDavid S. Miller <davem@davemloft.net>2007-05-03 20:39:04 -0400
commitdb3459d1a71d885334831cdca6646a48f5ea0483 (patch)
tree62bd17f8abb8c4fac280103b6179e275490c5b15 /include/net
parentb40b4f79ce789e9e28d382c85006f62be2725282 (diff)
[IPV6]: Some cleanups in include/net/ipv6.h
1) struct ip6_flowlabel : moves 'users' field to avoid two 32bits holes for 64bit arches. Shrinks by 8 bytes sizeof(struct ip6_flowlabel) 2) ipv6_addr_cmp() and ipv6_addr_copy() dont need (void *) casts : Compiler might take into account natural alignement of in6_addr structs to emit better code for memcpy()/memcmp() Casts to (void *) force byte accesses. 3) ipv6_addr_prefix() optimization : Better to clear whole struct, as compiler can emit better code for memset(addr, 0, 16) (2 stores on x86_64), and avoid some conditional branches. # size vmlinux.after vmlinux.before text data bss dec hex filename 5262262 647612 557432 6467306 62aeea vmlinux.after 5262550 647612 557432 6467594 62b00a vmlinux.before thats 288 bytes saved. Signed-off-by: Eric Dumazet <dada1@cosmosbay.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/net')
-rw-r--r--include/net/ipv6.h13
1 files changed, 5 insertions, 8 deletions
diff --git a/include/net/ipv6.h b/include/net/ipv6.h
index 2ce3941d8993..4fa5dfe886c4 100644
--- a/include/net/ipv6.h
+++ b/include/net/ipv6.h
@@ -204,9 +204,9 @@ struct ip6_flowlabel
204{ 204{
205 struct ip6_flowlabel *next; 205 struct ip6_flowlabel *next;
206 __be32 label; 206 __be32 label;
207 atomic_t users;
207 struct in6_addr dst; 208 struct in6_addr dst;
208 struct ipv6_txoptions *opt; 209 struct ipv6_txoptions *opt;
209 atomic_t users;
210 unsigned long linger; 210 unsigned long linger;
211 u8 share; 211 u8 share;
212 u32 owner; 212 u32 owner;
@@ -291,7 +291,7 @@ static inline int ipv6_addr_src_scope(const struct in6_addr *addr)
291 291
292static inline int ipv6_addr_cmp(const struct in6_addr *a1, const struct in6_addr *a2) 292static inline int ipv6_addr_cmp(const struct in6_addr *a1, const struct in6_addr *a2)
293{ 293{
294 return memcmp((const void *) a1, (const void *) a2, sizeof(struct in6_addr)); 294 return memcmp(a1, a2, sizeof(struct in6_addr));
295} 295}
296 296
297static inline int 297static inline int
@@ -308,7 +308,7 @@ ipv6_masked_addr_cmp(const struct in6_addr *a1, const struct in6_addr *m,
308 308
309static inline void ipv6_addr_copy(struct in6_addr *a1, const struct in6_addr *a2) 309static inline void ipv6_addr_copy(struct in6_addr *a1, const struct in6_addr *a2)
310{ 310{
311 memcpy((void *) a1, (const void *) a2, sizeof(struct in6_addr)); 311 memcpy(a1, a2, sizeof(struct in6_addr));
312} 312}
313 313
314static inline void ipv6_addr_prefix(struct in6_addr *pfx, 314static inline void ipv6_addr_prefix(struct in6_addr *pfx,
@@ -319,13 +319,10 @@ static inline void ipv6_addr_prefix(struct in6_addr *pfx,
319 int o = plen >> 3, 319 int o = plen >> 3,
320 b = plen & 0x7; 320 b = plen & 0x7;
321 321
322 memset(pfx->s6_addr, 0, sizeof(pfx->s6_addr));
322 memcpy(pfx->s6_addr, addr, o); 323 memcpy(pfx->s6_addr, addr, o);
323 if (b != 0) { 324 if (b != 0)
324 pfx->s6_addr[o] = addr->s6_addr[o] & (0xff00 >> b); 325 pfx->s6_addr[o] = addr->s6_addr[o] & (0xff00 >> b);
325 o++;
326 }
327 if (o < 16)
328 memset(pfx->s6_addr + o, 0, 16 - o);
329} 326}
330 327
331static inline void ipv6_addr_set(struct in6_addr *addr, 328static inline void ipv6_addr_set(struct in6_addr *addr,