Skip to content

Commit 738fea3

Browse files
committed
Merge branch 'bonding-report-transmit-status-to-callers'
Eric Dumazet says: ==================== bonding: report transmit status to callers First patches cleanup netpoll, and make sure it provides tx status to its users. Last patch changes bonding to not pretend packets were sent without error. By providing more accurate status, TCP stack can avoid adding more packets if the slave qdisc is already full. This came while testing latest horizon feature in sch_fq, with very low pacing rate flows, but should benefit hosts under stress. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
2 parents 3a13f98 + ae46f18 commit 738fea3

10 files changed

Lines changed: 65 additions & 82 deletions

File tree

‎drivers/net/bonding/bond_alb.c‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1318,8 +1318,7 @@ static netdev_tx_t bond_do_alb_xmit(struct sk_buff *skb, struct bonding *bond,
13181318
tx_slave->dev->dev_addr);
13191319
}
13201320

1321-
bond_dev_queue_xmit(bond, skb, tx_slave->dev);
1322-
goto out;
1321+
return bond_dev_queue_xmit(bond, skb, tx_slave->dev);
13231322
}
13241323

13251324
if (tx_slave && bond->params.tlb_dynamic_lb) {
@@ -1329,9 +1328,7 @@ static netdev_tx_t bond_do_alb_xmit(struct sk_buff *skb, struct bonding *bond,
13291328
}
13301329

13311330
/* no suitable interface, frame not sent */
1332-
bond_tx_drop(bond->dev, skb);
1333-
out:
1334-
return NETDEV_TX_OK;
1331+
return bond_tx_drop(bond->dev, skb);
13351332
}
13361333

13371334
netdev_tx_t bond_tlb_xmit(struct sk_buff *skb, struct net_device *bond_dev)

‎drivers/net/bonding/bond_main.c‎

Lines changed: 22 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ const char *bond_mode_name(int mode)
287287
* @skb: hw accel VLAN tagged skb to transmit
288288
* @slave_dev: slave that is supposed to xmit this skbuff
289289
*/
290-
void bond_dev_queue_xmit(struct bonding *bond, struct sk_buff *skb,
290+
netdev_tx_t bond_dev_queue_xmit(struct bonding *bond, struct sk_buff *skb,
291291
struct net_device *slave_dev)
292292
{
293293
skb->dev = slave_dev;
@@ -297,9 +297,9 @@ void bond_dev_queue_xmit(struct bonding *bond, struct sk_buff *skb,
297297
skb_set_queue_mapping(skb, qdisc_skb_cb(skb)->slave_dev_queue_mapping);
298298

299299
if (unlikely(netpoll_tx_running(bond->dev)))
300-
bond_netpoll_send_skb(bond_get_slave_by_dev(bond, slave_dev), skb);
301-
else
302-
dev_queue_xmit(skb);
300+
return bond_netpoll_send_skb(bond_get_slave_by_dev(bond, slave_dev), skb);
301+
302+
return dev_queue_xmit(skb);
303303
}
304304

305305
/* In the following 2 functions, bond_vlan_rx_add_vid and bond_vlan_rx_kill_vid,
@@ -3932,7 +3932,7 @@ static int bond_set_mac_address(struct net_device *bond_dev, void *addr)
39323932
* it fails, it tries to find the first available slave for transmission.
39333933
* The skb is consumed in all cases, thus the function is void.
39343934
*/
3935-
static void bond_xmit_slave_id(struct bonding *bond, struct sk_buff *skb, int slave_id)
3935+
static netdev_tx_t bond_xmit_slave_id(struct bonding *bond, struct sk_buff *skb, int slave_id)
39363936
{
39373937
struct list_head *iter;
39383938
struct slave *slave;
@@ -3941,10 +3941,8 @@ static void bond_xmit_slave_id(struct bonding *bond, struct sk_buff *skb, int sl
39413941
/* Here we start from the slave with slave_id */
39423942
bond_for_each_slave_rcu(bond, slave, iter) {
39433943
if (--i < 0) {
3944-
if (bond_slave_can_tx(slave)) {
3945-
bond_dev_queue_xmit(bond, skb, slave->dev);
3946-
return;
3947-
}
3944+
if (bond_slave_can_tx(slave))
3945+
return bond_dev_queue_xmit(bond, skb, slave->dev);
39483946
}
39493947
}
39503948

@@ -3953,13 +3951,11 @@ static void bond_xmit_slave_id(struct bonding *bond, struct sk_buff *skb, int sl
39533951
bond_for_each_slave_rcu(bond, slave, iter) {
39543952
if (--i < 0)
39553953
break;
3956-
if (bond_slave_can_tx(slave)) {
3957-
bond_dev_queue_xmit(bond, skb, slave->dev);
3958-
return;
3959-
}
3954+
if (bond_slave_can_tx(slave))
3955+
return bond_dev_queue_xmit(bond, skb, slave->dev);
39603956
}
39613957
/* no slave that can tx has been found */
3962-
bond_tx_drop(bond->dev, skb);
3958+
return bond_tx_drop(bond->dev, skb);
39633959
}
39643960

39653961
/**
@@ -4020,22 +4016,18 @@ static netdev_tx_t bond_xmit_roundrobin(struct sk_buff *skb,
40204016
if (iph->protocol == IPPROTO_IGMP) {
40214017
slave = rcu_dereference(bond->curr_active_slave);
40224018
if (slave)
4023-
bond_dev_queue_xmit(bond, skb, slave->dev);
4024-
else
4025-
bond_xmit_slave_id(bond, skb, 0);
4026-
return NETDEV_TX_OK;
4019+
return bond_dev_queue_xmit(bond, skb, slave->dev);
4020+
return bond_xmit_slave_id(bond, skb, 0);
40274021
}
40284022
}
40294023

40304024
non_igmp:
40314025
slave_cnt = READ_ONCE(bond->slave_cnt);
40324026
if (likely(slave_cnt)) {
40334027
slave_id = bond_rr_gen_slave_id(bond);
4034-
bond_xmit_slave_id(bond, skb, slave_id % slave_cnt);
4035-
} else {
4036-
bond_tx_drop(bond_dev, skb);
4028+
return bond_xmit_slave_id(bond, skb, slave_id % slave_cnt);
40374029
}
4038-
return NETDEV_TX_OK;
4030+
return bond_tx_drop(bond_dev, skb);
40394031
}
40404032

40414033
/* In active-backup mode, we know that bond->curr_active_slave is always valid if
@@ -4049,11 +4041,9 @@ static netdev_tx_t bond_xmit_activebackup(struct sk_buff *skb,
40494041

40504042
slave = rcu_dereference(bond->curr_active_slave);
40514043
if (slave)
4052-
bond_dev_queue_xmit(bond, skb, slave->dev);
4053-
else
4054-
bond_tx_drop(bond_dev, skb);
4044+
return bond_dev_queue_xmit(bond, skb, slave->dev);
40554045

4056-
return NETDEV_TX_OK;
4046+
return bond_tx_drop(bond_dev, skb);
40574047
}
40584048

40594049
/* Use this to update slave_array when (a) it's not appropriate to update
@@ -4196,12 +4186,9 @@ static netdev_tx_t bond_3ad_xor_xmit(struct sk_buff *skb,
41964186
count = slaves ? READ_ONCE(slaves->count) : 0;
41974187
if (likely(count)) {
41984188
slave = slaves->arr[bond_xmit_hash(bond, skb) % count];
4199-
bond_dev_queue_xmit(bond, skb, slave->dev);
4200-
} else {
4201-
bond_tx_drop(dev, skb);
4189+
return bond_dev_queue_xmit(bond, skb, slave->dev);
42024190
}
4203-
4204-
return NETDEV_TX_OK;
4191+
return bond_tx_drop(dev, skb);
42054192
}
42064193

42074194
/* in broadcast mode, we send everything to all usable interfaces. */
@@ -4227,11 +4214,9 @@ static netdev_tx_t bond_xmit_broadcast(struct sk_buff *skb,
42274214
}
42284215
}
42294216
if (slave && bond_slave_is_up(slave) && slave->link == BOND_LINK_UP)
4230-
bond_dev_queue_xmit(bond, skb, slave->dev);
4231-
else
4232-
bond_tx_drop(bond_dev, skb);
4217+
return bond_dev_queue_xmit(bond, skb, slave->dev);
42334218

4234-
return NETDEV_TX_OK;
4219+
return bond_tx_drop(bond_dev, skb);
42354220
}
42364221

42374222
/*------------------------- Device initialization ---------------------------*/
@@ -4310,8 +4295,7 @@ static netdev_tx_t __bond_start_xmit(struct sk_buff *skb, struct net_device *dev
43104295
/* Should never happen, mode already checked */
43114296
netdev_err(dev, "Unknown bonding mode %d\n", BOND_MODE(bond));
43124297
WARN_ON_ONCE(1);
4313-
bond_tx_drop(dev, skb);
4314-
return NETDEV_TX_OK;
4298+
return bond_tx_drop(dev, skb);
43154299
}
43164300
}
43174301

@@ -4330,7 +4314,7 @@ static netdev_tx_t bond_start_xmit(struct sk_buff *skb, struct net_device *dev)
43304314
if (bond_has_slaves(bond))
43314315
ret = __bond_start_xmit(skb, dev);
43324316
else
4333-
bond_tx_drop(dev, skb);
4317+
ret = bond_tx_drop(dev, skb);
43344318
rcu_read_unlock();
43354319

43364320
return ret;

‎drivers/net/macvlan.c‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -542,12 +542,11 @@ static int macvlan_queue_xmit(struct sk_buff *skb, struct net_device *dev)
542542
static inline netdev_tx_t macvlan_netpoll_send_skb(struct macvlan_dev *vlan, struct sk_buff *skb)
543543
{
544544
#ifdef CONFIG_NET_POLL_CONTROLLER
545-
if (vlan->netpoll)
546-
netpoll_send_skb(vlan->netpoll, skb);
545+
return netpoll_send_skb(vlan->netpoll, skb);
547546
#else
548547
BUG();
549-
#endif
550548
return NETDEV_TX_OK;
549+
#endif
551550
}
552551

553552
static netdev_tx_t macvlan_start_xmit(struct sk_buff *skb,

‎include/linux/if_team.h‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,7 @@ static inline bool team_port_dev_txable(const struct net_device *port_dev)
102102
static inline void team_netpoll_send_skb(struct team_port *port,
103103
struct sk_buff *skb)
104104
{
105-
struct netpoll *np = port->np;
106-
107-
if (np)
108-
netpoll_send_skb(np, skb);
105+
netpoll_send_skb(port->np, skb);
109106
}
110107
#else
111108
static inline void team_netpoll_send_skb(struct team_port *port,

‎include/linux/netpoll.h‎

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,7 @@ int netpoll_setup(struct netpoll *np);
6363
void __netpoll_cleanup(struct netpoll *np);
6464
void __netpoll_free(struct netpoll *np);
6565
void netpoll_cleanup(struct netpoll *np);
66-
void netpoll_send_skb_on_dev(struct netpoll *np, struct sk_buff *skb,
67-
struct net_device *dev);
68-
static inline void netpoll_send_skb(struct netpoll *np, struct sk_buff *skb)
69-
{
70-
unsigned long flags;
71-
local_irq_save(flags);
72-
netpoll_send_skb_on_dev(np, skb, np->dev);
73-
local_irq_restore(flags);
74-
}
66+
netdev_tx_t netpoll_send_skb(struct netpoll *np, struct sk_buff *skb);
7567

7668
#ifdef CONFIG_NETPOLL
7769
static inline void *netpoll_poll_lock(struct napi_struct *napi)

‎include/net/bonding.h‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -504,18 +504,17 @@ static inline unsigned long slave_last_rx(struct bonding *bond,
504504
}
505505

506506
#ifdef CONFIG_NET_POLL_CONTROLLER
507-
static inline void bond_netpoll_send_skb(const struct slave *slave,
507+
static inline netdev_tx_t bond_netpoll_send_skb(const struct slave *slave,
508508
struct sk_buff *skb)
509509
{
510-
struct netpoll *np = slave->np;
511-
512-
if (np)
513-
netpoll_send_skb(np, skb);
510+
return netpoll_send_skb(slave->np, skb);
514511
}
515512
#else
516-
static inline void bond_netpoll_send_skb(const struct slave *slave,
513+
static inline netdev_tx_t bond_netpoll_send_skb(const struct slave *slave,
517514
struct sk_buff *skb)
518515
{
516+
BUG();
517+
return NETDEV_TX_OK;
519518
}
520519
#endif
521520

@@ -609,7 +608,7 @@ struct bond_net {
609608
};
610609

611610
int bond_arp_rcv(const struct sk_buff *skb, struct bonding *bond, struct slave *slave);
612-
void bond_dev_queue_xmit(struct bonding *bond, struct sk_buff *skb, struct net_device *slave_dev);
611+
netdev_tx_t bond_dev_queue_xmit(struct bonding *bond, struct sk_buff *skb, struct net_device *slave_dev);
613612
int bond_create(struct net *net, const char *name);
614613
int bond_create_sysfs(struct bond_net *net);
615614
void bond_destroy_sysfs(struct bond_net *net);
@@ -742,10 +741,11 @@ extern struct bond_parm_tbl ad_select_tbl[];
742741
/* exported from bond_netlink.c */
743742
extern struct rtnl_link_ops bond_link_ops;
744743

745-
static inline void bond_tx_drop(struct net_device *dev, struct sk_buff *skb)
744+
static inline netdev_tx_t bond_tx_drop(struct net_device *dev, struct sk_buff *skb)
746745
{
747746
atomic_long_inc(&dev->tx_dropped);
748747
dev_kfree_skb_any(skb);
748+
return NET_XMIT_DROP;
749749
}
750750

751751
#endif /* _NET_BONDING_H */

‎net/8021q/vlan_dev.c‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,11 @@ static int vlan_dev_hard_header(struct sk_buff *skb, struct net_device *dev,
8888
static inline netdev_tx_t vlan_netpoll_send_skb(struct vlan_dev_priv *vlan, struct sk_buff *skb)
8989
{
9090
#ifdef CONFIG_NET_POLL_CONTROLLER
91-
if (vlan->netpoll)
92-
netpoll_send_skb(vlan->netpoll, skb);
91+
return netpoll_send_skb(vlan->netpoll, skb);
9392
#else
9493
BUG();
95-
#endif
9694
return NETDEV_TX_OK;
95+
#endif
9796
}
9897

9998
static netdev_tx_t vlan_dev_hard_start_xmit(struct sk_buff *skb,

‎net/bridge/br_private.h‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -598,10 +598,7 @@ netdev_tx_t br_dev_xmit(struct sk_buff *skb, struct net_device *dev);
598598
static inline void br_netpoll_send_skb(const struct net_bridge_port *p,
599599
struct sk_buff *skb)
600600
{
601-
struct netpoll *np = p->np;
602-
603-
if (np)
604-
netpoll_send_skb(np, skb);
601+
netpoll_send_skb(p->np, skb);
605602
}
606603

607604
int br_netpoll_enable(struct net_bridge_port *p);

‎net/core/netpoll.c‎

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -305,20 +305,22 @@ static int netpoll_owner_active(struct net_device *dev)
305305
}
306306

307307
/* call with IRQ disabled */
308-
void netpoll_send_skb_on_dev(struct netpoll *np, struct sk_buff *skb,
309-
struct net_device *dev)
308+
static netdev_tx_t __netpoll_send_skb(struct netpoll *np, struct sk_buff *skb)
310309
{
311310
netdev_tx_t status = NETDEV_TX_BUSY;
311+
struct net_device *dev;
312312
unsigned long tries;
313313
/* It is up to the caller to keep npinfo alive. */
314314
struct netpoll_info *npinfo;
315315

316316
lockdep_assert_irqs_disabled();
317317

318-
npinfo = rcu_dereference_bh(np->dev->npinfo);
318+
dev = np->dev;
319+
npinfo = rcu_dereference_bh(dev->npinfo);
320+
319321
if (!npinfo || !netif_running(dev) || !netif_device_present(dev)) {
320322
dev_kfree_skb_irq(skb);
321-
return;
323+
return NET_XMIT_DROP;
322324
}
323325

324326
/* don't get messages out of order, and no recursion */
@@ -357,8 +359,25 @@ void netpoll_send_skb_on_dev(struct netpoll *np, struct sk_buff *skb,
357359
skb_queue_tail(&npinfo->txq, skb);
358360
schedule_delayed_work(&npinfo->tx_work,0);
359361
}
362+
return NETDEV_TX_OK;
363+
}
364+
365+
netdev_tx_t netpoll_send_skb(struct netpoll *np, struct sk_buff *skb)
366+
{
367+
unsigned long flags;
368+
netdev_tx_t ret;
369+
370+
if (unlikely(!np)) {
371+
dev_kfree_skb_irq(skb);
372+
ret = NET_XMIT_DROP;
373+
} else {
374+
local_irq_save(flags);
375+
ret = __netpoll_send_skb(np, skb);
376+
local_irq_restore(flags);
377+
}
378+
return ret;
360379
}
361-
EXPORT_SYMBOL(netpoll_send_skb_on_dev);
380+
EXPORT_SYMBOL(netpoll_send_skb);
362381

363382
void netpoll_send_udp(struct netpoll *np, const char *msg, int len)
364383
{

‎net/dsa/slave.c‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -445,12 +445,11 @@ static inline netdev_tx_t dsa_slave_netpoll_send_skb(struct net_device *dev,
445445
#ifdef CONFIG_NET_POLL_CONTROLLER
446446
struct dsa_slave_priv *p = netdev_priv(dev);
447447

448-
if (p->netpoll)
449-
netpoll_send_skb(p->netpoll, skb);
448+
return netpoll_send_skb(p->netpoll, skb);
450449
#else
451450
BUG();
452-
#endif
453451
return NETDEV_TX_OK;
452+
#endif
454453
}
455454

456455
static void dsa_skb_tx_timestamp(struct dsa_slave_priv *p,

0 commit comments

Comments
 (0)