* [PATCH net-next] ipv6: Optimize ipv6_change_dsfield().
@ 2013-01-08 16:47 YOSHIFUJI Hideaki
0 siblings, 0 replies; only message in thread
From: YOSHIFUJI Hideaki @ 2013-01-08 16:47 UTC (permalink / raw)
To: davem, netdev; +Cc: yoshfuji
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>
---
include/net/dsfield.h | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/include/net/dsfield.h b/include/net/dsfield.h
index 8a8d4e0..e1ad903 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);
}
--
1.7.9.5
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2013-01-08 16:47 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-08 16:47 [PATCH net-next] ipv6: Optimize ipv6_change_dsfield() YOSHIFUJI Hideaki
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).