diff options
author | Herbert Xu <herbert@gondor.apana.org.au> | 2010-02-27 14:41:41 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-02-28 03:48:43 -0500 |
commit | b33084be192ee1e347d98bb5c9e38a53d98d35e2 (patch) | |
tree | 940c62309437ca5fa087275bc64b4ffd677c79c3 /net/bridge/br_forward.c | |
parent | 68b7c895be336b19f4c38d7cb500132fabba0afd (diff) |
bridge: Avoid unnecessary clone on forward path
When the packet is delivered to the local bridge device we may
end up cloning it unnecessarily if no bridge port can receive
the packet in br_flood.
This patch avoids this by moving the skb_clone into br_flood.
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/bridge/br_forward.c')
-rw-r--r-- | net/bridge/br_forward.c | 33 |
1 files changed, 22 insertions, 11 deletions
diff --git a/net/bridge/br_forward.c b/net/bridge/br_forward.c index bc1704ac6cd9..6cd50c6e57cf 100644 --- a/net/bridge/br_forward.c +++ b/net/bridge/br_forward.c | |||
@@ -105,8 +105,9 @@ void br_forward(const struct net_bridge_port *to, struct sk_buff *skb) | |||
105 | 105 | ||
106 | /* called under bridge lock */ | 106 | /* called under bridge lock */ |
107 | static void br_flood(struct net_bridge *br, struct sk_buff *skb, | 107 | static void br_flood(struct net_bridge *br, struct sk_buff *skb, |
108 | void (*__packet_hook)(const struct net_bridge_port *p, | 108 | struct sk_buff *skb0, |
109 | struct sk_buff *skb)) | 109 | void (*__packet_hook)(const struct net_bridge_port *p, |
110 | struct sk_buff *skb)) | ||
110 | { | 111 | { |
111 | struct net_bridge_port *p; | 112 | struct net_bridge_port *p; |
112 | struct net_bridge_port *prev; | 113 | struct net_bridge_port *prev; |
@@ -120,8 +121,7 @@ static void br_flood(struct net_bridge *br, struct sk_buff *skb, | |||
120 | 121 | ||
121 | if ((skb2 = skb_clone(skb, GFP_ATOMIC)) == NULL) { | 122 | if ((skb2 = skb_clone(skb, GFP_ATOMIC)) == NULL) { |
122 | br->dev->stats.tx_dropped++; | 123 | br->dev->stats.tx_dropped++; |
123 | kfree_skb(skb); | 124 | goto out; |
124 | return; | ||
125 | } | 125 | } |
126 | 126 | ||
127 | __packet_hook(prev, skb2); | 127 | __packet_hook(prev, skb2); |
@@ -131,23 +131,34 @@ static void br_flood(struct net_bridge *br, struct sk_buff *skb, | |||
131 | } | 131 | } |
132 | } | 132 | } |
133 | 133 | ||
134 | if (prev != NULL) { | 134 | if (!prev) |
135 | __packet_hook(prev, skb); | 135 | goto out; |
136 | return; | 136 | |
137 | if (skb0) { | ||
138 | skb = skb_clone(skb, GFP_ATOMIC); | ||
139 | if (!skb) { | ||
140 | br->dev->stats.tx_dropped++; | ||
141 | goto out; | ||
142 | } | ||
137 | } | 143 | } |
144 | __packet_hook(prev, skb); | ||
145 | return; | ||
138 | 146 | ||
139 | kfree_skb(skb); | 147 | out: |
148 | if (!skb0) | ||
149 | kfree_skb(skb); | ||
140 | } | 150 | } |
141 | 151 | ||
142 | 152 | ||
143 | /* called with rcu_read_lock */ | 153 | /* called with rcu_read_lock */ |
144 | void br_flood_deliver(struct net_bridge *br, struct sk_buff *skb) | 154 | void br_flood_deliver(struct net_bridge *br, struct sk_buff *skb) |
145 | { | 155 | { |
146 | br_flood(br, skb, __br_deliver); | 156 | br_flood(br, skb, NULL, __br_deliver); |
147 | } | 157 | } |
148 | 158 | ||
149 | /* called under bridge lock */ | 159 | /* called under bridge lock */ |
150 | void br_flood_forward(struct net_bridge *br, struct sk_buff *skb) | 160 | void br_flood_forward(struct net_bridge *br, struct sk_buff *skb, |
161 | struct sk_buff *skb2) | ||
151 | { | 162 | { |
152 | br_flood(br, skb, __br_forward); | 163 | br_flood(br, skb, skb2, __br_forward); |
153 | } | 164 | } |