Skip to content

Commit 31aa860

Browse files
edumazetdavem330
authored andcommitted
bonding: add bond_tx_drop() helper
Because bonding stats are usually sum of slave stats, it was not easy to account for tx drops at bonding layer. We can use dev->tx_dropped for this, as this counter is later added to the device stats (in dev_get_stats()) This extends the idea we had in commit ee63771 ("bonding: Simplify the xmit function for modes that use xmit_hash") for bond_3ad_xor_xmit() to other bonding modes. Signed-off-by: Eric Dumazet <edumazet@google.com> Cc: Mahesh Bandewar <maheshb@google.com> Reviewed-by: Nikolay Aleksandrov <nikolay@redhat.com> Acked-by: Mahesh Bandewar <maheshb@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent f0c6556 commit 31aa860

File tree

3 files changed

+14
-9
lines changed

3 files changed

+14
-9
lines changed

drivers/net/bonding/bond_alb.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1326,7 +1326,7 @@ static int bond_do_alb_xmit(struct sk_buff *skb, struct bonding *bond,
13261326
}
13271327

13281328
/* no suitable interface, frame not sent */
1329-
dev_kfree_skb_any(skb);
1329+
bond_tx_drop(bond->dev, skb);
13301330
out:
13311331
return NETDEV_TX_OK;
13321332
}

drivers/net/bonding/bond_main.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3522,7 +3522,7 @@ static void bond_xmit_slave_id(struct bonding *bond, struct sk_buff *skb, int sl
35223522
}
35233523
}
35243524
/* no slave that can tx has been found */
3525-
dev_kfree_skb_any(skb);
3525+
bond_tx_drop(bond->dev, skb);
35263526
}
35273527

35283528
/**
@@ -3584,7 +3584,7 @@ static int bond_xmit_roundrobin(struct sk_buff *skb, struct net_device *bond_dev
35843584
slave_id = bond_rr_gen_slave_id(bond);
35853585
bond_xmit_slave_id(bond, skb, slave_id % slave_cnt);
35863586
} else {
3587-
dev_kfree_skb_any(skb);
3587+
bond_tx_drop(bond_dev, skb);
35883588
}
35893589
}
35903590

@@ -3603,7 +3603,7 @@ static int bond_xmit_activebackup(struct sk_buff *skb, struct net_device *bond_d
36033603
if (slave)
36043604
bond_dev_queue_xmit(bond, skb, slave->dev);
36053605
else
3606-
dev_kfree_skb_any(skb);
3606+
bond_tx_drop(bond_dev, skb);
36073607

36083608
return NETDEV_TX_OK;
36093609
}
@@ -3747,8 +3747,7 @@ int bond_3ad_xor_xmit(struct sk_buff *skb, struct net_device *dev)
37473747
slave = slaves->arr[bond_xmit_hash(bond, skb) % count];
37483748
bond_dev_queue_xmit(bond, skb, slave->dev);
37493749
} else {
3750-
dev_kfree_skb_any(skb);
3751-
atomic_long_inc(&dev->tx_dropped);
3750+
bond_tx_drop(dev, skb);
37523751
}
37533752

37543753
return NETDEV_TX_OK;
@@ -3778,7 +3777,7 @@ static int bond_xmit_broadcast(struct sk_buff *skb, struct net_device *bond_dev)
37783777
if (slave && bond_slave_is_up(slave) && slave->link == BOND_LINK_UP)
37793778
bond_dev_queue_xmit(bond, skb, slave->dev);
37803779
else
3781-
dev_kfree_skb_any(skb);
3780+
bond_tx_drop(bond_dev, skb);
37823781

37833782
return NETDEV_TX_OK;
37843783
}
@@ -3858,7 +3857,7 @@ static netdev_tx_t __bond_start_xmit(struct sk_buff *skb, struct net_device *dev
38583857
/* Should never happen, mode already checked */
38593858
netdev_err(dev, "Unknown bonding mode %d\n", BOND_MODE(bond));
38603859
WARN_ON_ONCE(1);
3861-
dev_kfree_skb_any(skb);
3860+
bond_tx_drop(dev, skb);
38623861
return NETDEV_TX_OK;
38633862
}
38643863
}
@@ -3878,7 +3877,7 @@ static netdev_tx_t bond_start_xmit(struct sk_buff *skb, struct net_device *dev)
38783877
if (bond_has_slaves(bond))
38793878
ret = __bond_start_xmit(skb, dev);
38803879
else
3881-
dev_kfree_skb_any(skb);
3880+
bond_tx_drop(dev, skb);
38823881
rcu_read_unlock();
38833882

38843883
return ret;

drivers/net/bonding/bonding.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -645,4 +645,10 @@ extern struct bond_parm_tbl ad_select_tbl[];
645645
/* exported from bond_netlink.c */
646646
extern struct rtnl_link_ops bond_link_ops;
647647

648+
static inline void bond_tx_drop(struct net_device *dev, struct sk_buff *skb)
649+
{
650+
atomic_long_inc(&dev->tx_dropped);
651+
dev_kfree_skb_any(skb);
652+
}
653+
648654
#endif /* _LINUX_BONDING_H */

0 commit comments

Comments
 (0)