[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1528200262-11834-2-git-send-email-laoar.shao@gmail.com>
Date: Tue, 5 Jun 2018 08:04:22 -0400
From: Yafang Shao <laoar.shao@...il.com>
To: edumazet@...gle.com, davem@...emloft.net
Cc: netdev@...r.kernel.org, inux-kernel@...r.kernel.org,
Yafang Shao <laoar.shao@...il.com>
Subject: [PATCH net-next 2/2] ipv6: replace ip_hdr() with skb->data for optimization
In ipv6 receive path, when ip header hasn't been pulled yet, ip_hdr()
and skb->data are pointing to the same byte.
In ipv6 output path, when ip header is just pushed, ip_hdr() and skb->data
are pointing to the same byte.
As ip_hdr() is more expensive than using skb->data, so replace ip_hdr()
with skb->data in these situations for optimization.
Signed-off-by: Yafang Shao <laoar.shao@...il.com>
---
net/ipv6/ip6_input.c | 4 ++--
net/ipv6/ip6_output.c | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/net/ipv6/ip6_input.c b/net/ipv6/ip6_input.c
index f08d344..2ff4fe8 100644
--- a/net/ipv6/ip6_input.c
+++ b/net/ipv6/ip6_input.c
@@ -113,7 +113,7 @@ int ipv6_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt
if (unlikely(!pskb_may_pull(skb, sizeof(*hdr))))
goto err;
- hdr = ipv6_hdr(skb);
+ hdr = (const struct ipv6hdr *)skb->data;
if (hdr->version != 6)
goto err;
@@ -189,7 +189,7 @@ int ipv6_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt
__IP6_INC_STATS(net, idev, IPSTATS_MIB_INHDRERRORS);
goto drop;
}
- hdr = ipv6_hdr(skb);
+ hdr = (const struct ipv6hdr *)skb->data;
}
if (hdr->nexthdr == NEXTHDR_HOP) {
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
index 021e5ae..8bb3bc1 100644
--- a/net/ipv6/ip6_output.c
+++ b/net/ipv6/ip6_output.c
@@ -235,7 +235,7 @@ int ip6_xmit(const struct sock *sk, struct sk_buff *skb, struct flowi6 *fl6,
skb_push(skb, sizeof(struct ipv6hdr));
skb_reset_network_header(skb);
- hdr = ipv6_hdr(skb);
+ hdr = (struct ipv6hdr *)skb->data;
/*
* Fill in the IPv6 header
@@ -1659,7 +1659,7 @@ struct sk_buff *__ip6_make_skb(struct sock *sk,
skb_push(skb, sizeof(struct ipv6hdr));
skb_reset_network_header(skb);
- hdr = ipv6_hdr(skb);
+ hdr = (struct ipv6hdr *)skb->data;
ip6_flow_hdr(hdr, v6_cork->tclass,
ip6_make_flowlabel(net, skb, fl6->flowlabel,
--
1.8.3.1
Powered by blists - more mailing lists