提交 4a94445c 编写于 作者: E Eric Dumazet 提交者: David S. Miller

net: Use ip_route_input_noref() in input path

Use ip_route_input_noref() in ip fast path, to avoid two atomic ops per
incoming packet.

Note: loopback is excluded from this optimization in ip_rcv_finish()
Signed-off-by: NEric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 407eadd9
...@@ -854,7 +854,7 @@ static int arp_process(struct sk_buff *skb) ...@@ -854,7 +854,7 @@ static int arp_process(struct sk_buff *skb)
} }
if (arp->ar_op == htons(ARPOP_REQUEST) && if (arp->ar_op == htons(ARPOP_REQUEST) &&
ip_route_input(skb, tip, sip, 0, dev) == 0) { ip_route_input_noref(skb, tip, sip, 0, dev) == 0) {
rt = skb_rtable(skb); rt = skb_rtable(skb);
addr_type = rt->rt_type; addr_type = rt->rt_type;
......
...@@ -331,8 +331,8 @@ static int ip_rcv_finish(struct sk_buff *skb) ...@@ -331,8 +331,8 @@ static int ip_rcv_finish(struct sk_buff *skb)
* how the packet travels inside Linux networking. * how the packet travels inside Linux networking.
*/ */
if (skb_dst(skb) == NULL) { if (skb_dst(skb) == NULL) {
int err = ip_route_input(skb, iph->daddr, iph->saddr, iph->tos, int err = ip_route_input_noref(skb, iph->daddr, iph->saddr,
skb->dev); iph->tos, skb->dev);
if (unlikely(err)) { if (unlikely(err)) {
if (err == -EHOSTUNREACH) if (err == -EHOSTUNREACH)
IP_INC_STATS_BH(dev_net(skb->dev), IP_INC_STATS_BH(dev_net(skb->dev),
......
...@@ -27,8 +27,8 @@ static inline int xfrm4_rcv_encap_finish(struct sk_buff *skb) ...@@ -27,8 +27,8 @@ static inline int xfrm4_rcv_encap_finish(struct sk_buff *skb)
if (skb_dst(skb) == NULL) { if (skb_dst(skb) == NULL) {
const struct iphdr *iph = ip_hdr(skb); const struct iphdr *iph = ip_hdr(skb);
if (ip_route_input(skb, iph->daddr, iph->saddr, iph->tos, if (ip_route_input_noref(skb, iph->daddr, iph->saddr,
skb->dev)) iph->tos, skb->dev))
goto drop; goto drop;
} }
return dst_input(skb); return dst_input(skb);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册