[PATCH net/net-next] bonding:Don't received packets if bonding is not up

From: lichunhe
Date: Sun Aug 03 2014 - 23:16:25 EST


From: Chunhe Li <lichunhe@xxxxxxxxxx>

If the bonding device is down, it should not receive packets
to network stack or other upper flow stack.

Signed-off-by: Chunhe Li <lichunhe@xxxxxxxxxx>
---
drivers/net/bonding/bond_main.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 701f86c..48a127b 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -1110,6 +1110,12 @@ static rx_handler_result_t bond_handle_frame(struct sk_buff **pskb)
int (*recv_probe)(const struct sk_buff *, struct bonding *,
struct slave *);
int ret = RX_HANDLER_ANOTHER;
+
+ slave = bond_slave_get_rcu(skb->dev);
+ bond = slave->bond;
+
+ if (unlikely(!(bond->dev->flags & IFF_UP)))
+ return RX_HANDLER_PASS;

skb = skb_share_check(skb, GFP_ATOMIC);
if (unlikely(!skb))
@@ -1117,9 +1123,6 @@ static rx_handler_result_t bond_handle_frame(struct sk_buff **pskb)

*pskb = skb;

- slave = bond_slave_get_rcu(skb->dev);
- bond = slave->bond;
-
recv_probe = ACCESS_ONCE(bond->recv_probe);
if (recv_probe) {
ret = recv_probe(skb, bond, slave);
--
1.9.2.0


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/