@@ -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) {
@@ -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,
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@gmail.com> --- net/ipv6/ip6_input.c | 4 ++-- net/ipv6/ip6_output.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)