Commit a0376db0 authored by YOSHIFUJI Hideaki / 吉藤英明's avatar YOSHIFUJI Hideaki / 吉藤英明 Committed by David S. Miller

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: default avatarYOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 6c40d100
...@@ -43,11 +43,9 @@ static inline void ipv4_change_dsfield(struct iphdr *iph,__u8 mask, ...@@ -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, static inline void ipv6_change_dsfield(struct ipv6hdr *ipv6h,__u8 mask,
__u8 value) __u8 value)
{ {
__u16 tmp; __be16 *p = (__force __be16 *)ipv6h;
tmp = ntohs(*(__be16 *) ipv6h); *p = (*p & htons((((u16)mask << 4) | 0xf00f))) | htons((u16)value << 4);
tmp = (tmp & ((mask << 4) | 0xf00f)) | (value << 4);
*(__be16 *) ipv6h = htons(tmp);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment