summaryrefslogtreecommitdiff
path: root/include/net/dsfield.h
diff options
context:
space:
mode:
authorYOSHIFUJI Hideaki / 吉藤英明 <yoshfuji@linux-ipv6.org>2013-01-08 10:47:08 +0400
committerDavid S. Miller <davem@davemloft.net>2013-01-10 11:59:53 +0400
commita0376db0f234a8053100bddf26c073be79546b2b (patch)
tree8fbfb0a2e077ada7852ee08a405559d06c155bb7 /include/net/dsfield.h
parent6c40d100ce3311a44ef82c678fb46833a270c007 (diff)
downloadlinux-a0376db0f234a8053100bddf26c073be79546b2b.tar.xz
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>
Diffstat (limited to 'include/net/dsfield.h')
-rw-r--r--include/net/dsfield.h6
1 files changed, 2 insertions, 4 deletions
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);
}