Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+65 -82
+2 -5
drivers/net/bonding/bond_alb.c
··· 1318 1318 tx_slave->dev->dev_addr); 1319 1319 } 1320 1320 1321 - bond_dev_queue_xmit(bond, skb, tx_slave->dev); 1322 - goto out; 1321 + return bond_dev_queue_xmit(bond, skb, tx_slave->dev); 1323 1322 } 1324 1323 1325 1324 if (tx_slave && bond->params.tlb_dynamic_lb) { ··· 1328 1329 } 1329 1330 1330 1331 /* no suitable interface, frame not sent */ 1331 - bond_tx_drop(bond->dev, skb); 1332 - out: 1333 - return NETDEV_TX_OK; 1332 + return bond_tx_drop(bond->dev, skb); 1334 1333 } 1335 1334 1336 1335 netdev_tx_t bond_tlb_xmit(struct sk_buff *skb, struct net_device *bond_dev)
+22 -38
drivers/net/bonding/bond_main.c
··· 287 287 * @skb: hw accel VLAN tagged skb to transmit 288 288 * @slave_dev: slave that is supposed to xmit this skbuff 289 289 */ 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, 291 291 struct net_device *slave_dev) 292 292 { 293 293 skb->dev = slave_dev; ··· 297 297 skb_set_queue_mapping(skb, qdisc_skb_cb(skb)->slave_dev_queue_mapping); 298 298 299 299 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); 303 303 } 304 304 305 305 /* In the following 2 functions, bond_vlan_rx_add_vid and bond_vlan_rx_kill_vid, ··· 3932 3932 * it fails, it tries to find the first available slave for transmission. 3933 3933 * The skb is consumed in all cases, thus the function is void. 3934 3934 */ 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) 3936 3936 { 3937 3937 struct list_head *iter; 3938 3938 struct slave *slave; ··· 3941 3941 /* Here we start from the slave with slave_id */ 3942 3942 bond_for_each_slave_rcu(bond, slave, iter) { 3943 3943 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); 3948 3946 } 3949 3947 } 3950 3948 ··· 3951 3953 bond_for_each_slave_rcu(bond, slave, iter) { 3952 3954 if (--i < 0) 3953 3955 break; 3954 - if (bond_slave_can_tx(slave)) { 3955 - bond_dev_queue_xmit(bond, skb, slave->dev); 3956 - return; 3957 - } 3956 + if (bond_slave_can_tx(slave)) 3957 + return bond_dev_queue_xmit(bond, skb, slave->dev); 3958 3958 } 3959 3959 /* no slave that can tx has been found */ 3960 - bond_tx_drop(bond->dev, skb); 3960 + return bond_tx_drop(bond->dev, skb); 3961 3961 } 3962 3962 3963 3963 /** ··· 4016 4020 if (iph->protocol == IPPROTO_IGMP) { 4017 4021 slave = rcu_dereference(bond->curr_active_slave); 4018 4022 if (slave) 4019 - bond_dev_queue_xmit(bond, skb, slave->dev); 4020 - else 4021 - bond_xmit_slave_id(bond, skb, 0); 4022 - return NETDEV_TX_OK; 4023 + return bond_dev_queue_xmit(bond, skb, slave->dev); 4024 + return bond_xmit_slave_id(bond, skb, 0); 4023 4025 } 4024 4026 } 4025 4027 ··· 4025 4031 slave_cnt = READ_ONCE(bond->slave_cnt); 4026 4032 if (likely(slave_cnt)) { 4027 4033 slave_id = bond_rr_gen_slave_id(bond); 4028 - bond_xmit_slave_id(bond, skb, slave_id % slave_cnt); 4029 - } else { 4030 - bond_tx_drop(bond_dev, skb); 4034 + return bond_xmit_slave_id(bond, skb, slave_id % slave_cnt); 4031 4035 } 4032 - return NETDEV_TX_OK; 4036 + return bond_tx_drop(bond_dev, skb); 4033 4037 } 4034 4038 4035 4039 /* In active-backup mode, we know that bond->curr_active_slave is always valid if ··· 4041 4049 4042 4050 slave = rcu_dereference(bond->curr_active_slave); 4043 4051 if (slave) 4044 - bond_dev_queue_xmit(bond, skb, slave->dev); 4045 - else 4046 - bond_tx_drop(bond_dev, skb); 4052 + return bond_dev_queue_xmit(bond, skb, slave->dev); 4047 4053 4048 - return NETDEV_TX_OK; 4054 + return bond_tx_drop(bond_dev, skb); 4049 4055 } 4050 4056 4051 4057 /* Use this to update slave_array when (a) it's not appropriate to update ··· 4186 4196 count = slaves ? READ_ONCE(slaves->count) : 0; 4187 4197 if (likely(count)) { 4188 4198 slave = slaves->arr[bond_xmit_hash(bond, skb) % count]; 4189 - bond_dev_queue_xmit(bond, skb, slave->dev); 4190 - } else { 4191 - bond_tx_drop(dev, skb); 4199 + return bond_dev_queue_xmit(bond, skb, slave->dev); 4192 4200 } 4193 - 4194 - return NETDEV_TX_OK; 4201 + return bond_tx_drop(dev, skb); 4195 4202 } 4196 4203 4197 4204 /* in broadcast mode, we send everything to all usable interfaces. */ ··· 4214 4227 } 4215 4228 } 4216 4229 if (slave && bond_slave_is_up(slave) && slave->link == BOND_LINK_UP) 4217 - bond_dev_queue_xmit(bond, skb, slave->dev); 4218 - else 4219 - bond_tx_drop(bond_dev, skb); 4230 + return bond_dev_queue_xmit(bond, skb, slave->dev); 4220 4231 4221 - return NETDEV_TX_OK; 4232 + return bond_tx_drop(bond_dev, skb); 4222 4233 } 4223 4234 4224 4235 /*------------------------- Device initialization ---------------------------*/ ··· 4295 4310 /* Should never happen, mode already checked */ 4296 4311 netdev_err(dev, "Unknown bonding mode %d\n", BOND_MODE(bond)); 4297 4312 WARN_ON_ONCE(1); 4298 - bond_tx_drop(dev, skb); 4299 - return NETDEV_TX_OK; 4313 + return bond_tx_drop(dev, skb); 4300 4314 } 4301 4315 } 4302 4316 ··· 4314 4330 if (bond_has_slaves(bond)) 4315 4331 ret = __bond_start_xmit(skb, dev); 4316 4332 else 4317 - bond_tx_drop(dev, skb); 4333 + ret = bond_tx_drop(dev, skb); 4318 4334 rcu_read_unlock(); 4319 4335 4320 4336 return ret;
+2 -3
drivers/net/macvlan.c
··· 542 542 static inline netdev_tx_t macvlan_netpoll_send_skb(struct macvlan_dev *vlan, struct sk_buff *skb) 543 543 { 544 544 #ifdef CONFIG_NET_POLL_CONTROLLER 545 - if (vlan->netpoll) 546 - netpoll_send_skb(vlan->netpoll, skb); 545 + return netpoll_send_skb(vlan->netpoll, skb); 547 546 #else 548 547 BUG(); 549 - #endif 550 548 return NETDEV_TX_OK; 549 + #endif 551 550 } 552 551 553 552 static netdev_tx_t macvlan_start_xmit(struct sk_buff *skb,
+1 -4
include/linux/if_team.h
··· 102 102 static inline void team_netpoll_send_skb(struct team_port *port, 103 103 struct sk_buff *skb) 104 104 { 105 - struct netpoll *np = port->np; 106 - 107 - if (np) 108 - netpoll_send_skb(np, skb); 105 + netpoll_send_skb(port->np, skb); 109 106 } 110 107 #else 111 108 static inline void team_netpoll_send_skb(struct team_port *port,
+1 -9
include/linux/netpoll.h
··· 63 63 void __netpoll_cleanup(struct netpoll *np); 64 64 void __netpoll_free(struct netpoll *np); 65 65 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); 75 67 76 68 #ifdef CONFIG_NETPOLL 77 69 static inline void *netpoll_poll_lock(struct napi_struct *napi)
+8 -8
include/net/bonding.h
··· 504 504 } 505 505 506 506 #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, 508 508 struct sk_buff *skb) 509 509 { 510 - struct netpoll *np = slave->np; 511 - 512 - if (np) 513 - netpoll_send_skb(np, skb); 510 + return netpoll_send_skb(slave->np, skb); 514 511 } 515 512 #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, 517 514 struct sk_buff *skb) 518 515 { 516 + BUG(); 517 + return NETDEV_TX_OK; 519 518 } 520 519 #endif 521 520 ··· 608 609 }; 609 610 610 611 int bond_arp_rcv(const struct sk_buff *skb, struct bonding *bond, struct slave *slave); 611 - void bond_dev_queue_xmit(struct bonding *bond, struct sk_buff *skb, struct net_device *slave_dev); 612 + netdev_tx_t bond_dev_queue_xmit(struct bonding *bond, struct sk_buff *skb, struct net_device *slave_dev); 612 613 int bond_create(struct net *net, const char *name); 613 614 int bond_create_sysfs(struct bond_net *net); 614 615 void bond_destroy_sysfs(struct bond_net *net); ··· 741 742 /* exported from bond_netlink.c */ 742 743 extern struct rtnl_link_ops bond_link_ops; 743 744 744 - static inline void bond_tx_drop(struct net_device *dev, struct sk_buff *skb) 745 + static inline netdev_tx_t bond_tx_drop(struct net_device *dev, struct sk_buff *skb) 745 746 { 746 747 atomic_long_inc(&dev->tx_dropped); 747 748 dev_kfree_skb_any(skb); 749 + return NET_XMIT_DROP; 748 750 } 749 751 750 752 #endif /* _NET_BONDING_H */
+2 -3
net/8021q/vlan_dev.c
··· 88 88 static inline netdev_tx_t vlan_netpoll_send_skb(struct vlan_dev_priv *vlan, struct sk_buff *skb) 89 89 { 90 90 #ifdef CONFIG_NET_POLL_CONTROLLER 91 - if (vlan->netpoll) 92 - netpoll_send_skb(vlan->netpoll, skb); 91 + return netpoll_send_skb(vlan->netpoll, skb); 93 92 #else 94 93 BUG(); 95 - #endif 96 94 return NETDEV_TX_OK; 95 + #endif 97 96 } 98 97 99 98 static netdev_tx_t vlan_dev_hard_start_xmit(struct sk_buff *skb,
+1 -4
net/bridge/br_private.h
··· 598 598 static inline void br_netpoll_send_skb(const struct net_bridge_port *p, 599 599 struct sk_buff *skb) 600 600 { 601 - struct netpoll *np = p->np; 602 - 603 - if (np) 604 - netpoll_send_skb(np, skb); 601 + netpoll_send_skb(p->np, skb); 605 602 } 606 603 607 604 int br_netpoll_enable(struct net_bridge_port *p);
+24 -5
net/core/netpoll.c
··· 305 305 } 306 306 307 307 /* 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) 310 309 { 311 310 netdev_tx_t status = NETDEV_TX_BUSY; 311 + struct net_device *dev; 312 312 unsigned long tries; 313 313 /* It is up to the caller to keep npinfo alive. */ 314 314 struct netpoll_info *npinfo; 315 315 316 316 lockdep_assert_irqs_disabled(); 317 317 318 - npinfo = rcu_dereference_bh(np->dev->npinfo); 318 + dev = np->dev; 319 + npinfo = rcu_dereference_bh(dev->npinfo); 320 + 319 321 if (!npinfo || !netif_running(dev) || !netif_device_present(dev)) { 320 322 dev_kfree_skb_irq(skb); 321 - return; 323 + return NET_XMIT_DROP; 322 324 } 323 325 324 326 /* don't get messages out of order, and no recursion */ ··· 359 357 skb_queue_tail(&npinfo->txq, skb); 360 358 schedule_delayed_work(&npinfo->tx_work,0); 361 359 } 360 + return NETDEV_TX_OK; 362 361 } 363 - EXPORT_SYMBOL(netpoll_send_skb_on_dev); 362 + 363 + netdev_tx_t netpoll_send_skb(struct netpoll *np, struct sk_buff *skb) 364 + { 365 + unsigned long flags; 366 + netdev_tx_t ret; 367 + 368 + if (unlikely(!np)) { 369 + dev_kfree_skb_irq(skb); 370 + ret = NET_XMIT_DROP; 371 + } else { 372 + local_irq_save(flags); 373 + ret = __netpoll_send_skb(np, skb); 374 + local_irq_restore(flags); 375 + } 376 + return ret; 377 + } 378 + EXPORT_SYMBOL(netpoll_send_skb); 364 379 365 380 void netpoll_send_udp(struct netpoll *np, const char *msg, int len) 366 381 {
+2 -3
net/dsa/slave.c
··· 445 445 #ifdef CONFIG_NET_POLL_CONTROLLER 446 446 struct dsa_slave_priv *p = netdev_priv(dev); 447 447 448 - if (p->netpoll) 449 - netpoll_send_skb(p->netpoll, skb); 448 + return netpoll_send_skb(p->netpoll, skb); 450 449 #else 451 450 BUG(); 452 - #endif 453 451 return NETDEV_TX_OK; 452 + #endif 454 453 } 455 454 456 455 static void dsa_skb_tx_timestamp(struct dsa_slave_priv *p,