From: YOSHIFUJI Hideaki / 吉藤英明 Date: Tue, 8 Jan 2013 06:47:08 +0000 (+0000) Subject: ipv6: Optimize ipv6_change_dsfield(). X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=a0376db0f234a8053100bddf26c073be79546b2b;p=GitHub%2FLineageOS%2FG12%2Fandroid_kernel_amlogic_linux-4.9.git 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 Signed-off-by: David S. Miller --- diff --git a/include/net/dsfield.h b/include/net/dsfield.h index 8a8d4e06900d..e1ad903a8d6a 100644 --- a/include/net/dsfield.h +++ b/include/net/dsfield.h @@ -43,11 +43,9 @@ static inline void ipv4_change_dsfield(struct iphdr *iph,__u8 mask, static inline void ipv6_change_dsfield(struct ipv6hdr *ipv6h,__u8 mask, __u8 value) { - __u16 tmp; + __be16 *p = (__force __be16 *)ipv6h; - tmp = ntohs(*(__be16 *) ipv6h); - tmp = (tmp & ((mask << 4) | 0xf00f)) | (value << 4); - *(__be16 *) ipv6h = htons(tmp); + *p = (*p & htons((((u16)mask << 4) | 0xf00f))) | htons((u16)value << 4); }