Skip to content

Commit 9ef513b

Browse files
Stephen HemmingerDavid S. Miller
authored andcommitted
[BRIDGE]: optimize conditional in forward path
Small optimizations of bridge forwarding path. Signed-off-by: Stephen Hemminger <shemminger@osdl.org> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent bc0e646 commit 9ef513b

1 file changed

Lines changed: 4 additions & 8 deletions

File tree

‎net/bridge/br_forward.c‎

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,11 @@
2020
#include <linux/netfilter_bridge.h>
2121
#include "br_private.h"
2222

23+
/* Don't forward packets to originating port or forwarding diasabled */
2324
static inline int should_deliver(const struct net_bridge_port *p,
2425
const struct sk_buff *skb)
2526
{
26-
if (skb->dev == p->dev ||
27-
p->state != BR_STATE_FORWARDING)
28-
return 0;
29-
30-
return 1;
27+
return (skb->dev != p->dev && p->state == BR_STATE_FORWARDING);
3128
}
3229

3330
static inline unsigned packet_length(const struct sk_buff *skb)
@@ -55,10 +52,9 @@ int br_dev_queue_push_xmit(struct sk_buff *skb)
5552

5653
int br_forward_finish(struct sk_buff *skb)
5754
{
58-
NF_HOOK(PF_BRIDGE, NF_BR_POST_ROUTING, skb, NULL, skb->dev,
59-
br_dev_queue_push_xmit);
55+
return NF_HOOK(PF_BRIDGE, NF_BR_POST_ROUTING, skb, NULL, skb->dev,
56+
br_dev_queue_push_xmit);
6057

61-
return 0;
6258
}
6359

6460
static void __br_deliver(const struct net_bridge_port *to, struct sk_buff *skb)

0 commit comments

Comments
 (0)