Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ipv6: Optimize ipv6_change_dsfield().

Do not convert endian back and forth.
If the caller uses contant "mask" argument (and most callers do),
we can omit runtime endian conversion here.

Signed-off-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

YOSHIFUJI Hideaki / 吉藤英明 and committed by
David S. Miller
a0376db0 6c40d100

+2 -4
+2 -4
include/net/dsfield.h
··· 43 43 static inline void ipv6_change_dsfield(struct ipv6hdr *ipv6h,__u8 mask, 44 44 __u8 value) 45 45 { 46 - __u16 tmp; 46 + __be16 *p = (__force __be16 *)ipv6h; 47 47 48 - tmp = ntohs(*(__be16 *) ipv6h); 49 - tmp = (tmp & ((mask << 4) | 0xf00f)) | (value << 4); 50 - *(__be16 *) ipv6h = htons(tmp); 48 + *p = (*p & htons((((u16)mask << 4) | 0xf00f))) | htons((u16)value << 4); 51 49 } 52 50 53 51