ipv4: use unlikely to optimise in ip_forward
Subsystems (3)
PATCH 1/1 ipv4: use unlikely to optimise in ip_forward
From: Li RongQing <[email protected]>
The condition that skb->pkt_type is not PACKET_HOST in ip_forward, should never happen, so use unlikely to optimise this check
--- net/ipv4/ip_forward.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv4/ip_forward.c +1 -1
@@ -128,7 +128,7 @@ int ip_forward(struct sk_buff *skb)struct ip_options *opt = &(IPCB (skb)->opt);/* that should never happen */ -if (skb->pkt_type !=PACKET_HOST ) +if (unlikely (skb->pkt_type !=PACKET_HOST )) goto drop;if (skb_warn_if_lro (skb))
Signature · 1 line
1.7.10.4
Quoted 15 lines · On Mon, 2014-03-10 at 13:10 +0800, [email protected] wrote:
From: Li RongQing <[email protected]>
The condition that
skb->pkt_typeis notPACKET_HOSTinip_forward, should never happen, so use unlikely to optimise this checkSigned-off-by Li RongQing <[email protected]>--- net/ipv4/ip_forward.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)net/ipv4/ip_forward.c +0
-0
net/ipv4/ip_forward.c int ip_forward(struct sk_buff *skb) · line 134
Quoted 8 lines
net/ipv4/ip_forward.c +1
-1@@ -128,7 +128,7 @@ int ip_forward(struct sk_buff *skb)struct ip_options *opt = &(IPCB (skb)->opt);/* that should never happen */ -if (skb->pkt_type !=PACKET_HOST ) +if (unlikely (skb->pkt_type !=PACKET_HOST )) goto drop;if (skb_warn_if_lro (skb))
Compilers already do the right thing.
This is one of the reason you see so many goto in the kernel.
Ok, thanks
-R
Quoted 31 lines · Eric Dumazet
Quoted 15 lines · On Mon, 2014-03-10 at 13:10 +0800, [email protected] wrote:
From: Li RongQing <[email protected]>
The condition that
skb->pkt_typeis notPACKET_HOSTinip_forward, should never happen, so use unlikely to optimise this checkSigned-off-by Li RongQing <[email protected]>--- net/ipv4/ip_forward.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)net/ipv4/ip_forward.c +0
-0net/ipv4/ip_forward.c int ip_forward(struct sk_buff *skb) · line 134
Quoted 8 lines
net/ipv4/ip_forward.c +1
-1@@ -128,7 +128,7 @@ int ip_forward(struct sk_buff *skb)struct ip_options *opt = &(IPCB (skb)->opt);/* that should never happen */ -if (skb->pkt_type !=PACKET_HOST ) +if (unlikely (skb->pkt_type !=PACKET_HOST )) goto drop;if (skb_warn_if_lro (skb))Compilers already do the right thing.
This is one of the reason you see so many goto in the kernel.