pf_packet fixes
Subsystems (3)
cover pf_packet fixes
Applies to net-next tree. Thanks!
Daniel Borkmann (2):
packet: report tx_dropped in packet_direct_xmit
packet: fix packet_direct_xmit for BQL enabled drivers
include/linux/netdevice.h | 24 +++++++++++++++++++----- net/packet/af_packet.c | 3 ++- 2 files changed, 21 insertions(+), 6 deletions(-)
Signature · 1 line
1.7.11.7
PATCH 1/2 packet: report tx_dropped in packet_direct_xmit
Since commit 015f0688f57c ("net: net: add a core netdev->tx_dropped counter"), we can now account for TX drops from within the core stack instead of drivers.
Therefore, fix packet_direct_xmit() and increase drop count when we encounter a problem before driver's xmit function was called (we do not want to doubly account for it).
--- net/packet/af_packet.c | 1 + 1 file changed, 1 insertion(+)
net/packet/af_packet.c +1 -0
@@ -275,6 +275,7 @@ static int packet_direct_xmit(struct sk_buff *skb)return ret; drop: +atomic_long_inc (&dev->tx_dropped);kfree_skb (skb);return NET_XMIT_DROP ; }
Signature · 1 line
1.7.11.7
PATCH 2/2 packet: fix packet_direct_xmit for BQL enabled drivers
In reply to Daniel BorkmannCurrently, in packet_direct_xmit() we test the assigned netdevice queue for netif_xmit_frozen_or_stopped() before doing an ndo_start_xmit().
This can have the side-effect that BQL enabled drivers which make use of netdev_tx_sent_queue() internally, set __QUEUE_STATE_STACK_XOFF from within the stack and would not fully fill the device's TX ring from packet sockets with PACKET_QDISC_BYPASS enabled.
Instead, use a test without BQL bit so that bursts can be absorbed into the NICs TX ring. Fix and code suggested by Eric Dumazet, thanks!
--- include/linux/netdevice.h | 24 +++++++++++++++++++----- net/packet/af_packet.c | 2 +- 2 files changed, 20 insertions(+), 6 deletions(-)
include/linux/netdevice.h +19 -5
@@ -519,11 +519,18 @@ enum netdev_queue_state_t { __QUEUE_STATE_DRV_XOFF, __QUEUE_STATE_STACK_XOFF, __QUEUE_STATE_FROZEN, -#define QUEUE_STATE_ANY_XOFF ((1 << __QUEUE_STATE_DRV_XOFF) | \ - (1 << __QUEUE_STATE_STACK_XOFF)) -#define QUEUE_STATE_ANY_XOFF_OR_FROZEN (QUEUE_STATE_ANY_XOFF | \ - (1 << __QUEUE_STATE_FROZEN)) }; + +#define QUEUE_STATE_DRV_XOFF (1 << __QUEUE_STATE_DRV_XOFF) +#define QUEUE_STATE_STACK_XOFF (1 << __QUEUE_STATE_STACK_XOFF) +#define QUEUE_STATE_FROZEN (1 << __QUEUE_STATE_FROZEN) + +#define QUEUE_STATE_ANY_XOFF (QUEUE_STATE_DRV_XOFF | QUEUE_STATE_STACK_XOFF) +#define QUEUE_STATE_ANY_XOFF_OR_FROZEN (QUEUE_STATE_ANY_XOFF | \ + QUEUE_STATE_FROZEN) +#define QUEUE_STATE_DRV_XOFF_OR_FROZEN (QUEUE_STATE_DRV_XOFF | \ + QUEUE_STATE_FROZEN) +/* * __QUEUE_STATE_DRV_XOFF is used by drivers to stop the transmit queue. The * netif_tx_* functions below are used to manipulate this flag. The
@@ -2252,11 +2259,18 @@ static inline bool netif_xmit_stopped(const struct netdev_queue *dev_queue)return dev_queue->state &QUEUE_STATE_ANY_XOFF ; } -static inline bool netif_xmit_frozen_or_stopped (const struct netdev_queue *dev_queue) +static inline bool +netif_xmit_frozen_or_stopped (const struct netdev_queue *dev_queue) {return dev_queue->state &QUEUE_STATE_ANY_XOFF_OR_FROZEN ; } +static inline bool +netif_xmit_frozen_or_drv_stopped (const struct netdev_queue *dev_queue) +{ +return dev_queue->state &QUEUE_STATE_DRV_XOFF_OR_FROZEN ; +} +static inline void netdev_tx_sent_queue (struct netdev_queue *dev_queue,unsigned int bytes) {
net/packet/af_packet.c +1 -1
@@ -261,7 +261,7 @@ static int packet_direct_xmit(struct sk_buff *skb)local_bh_disable ();HARD_TX_LOCK (dev, txq,smp_processor_id ()); -if (!netif_xmit_frozen_or_stopped (txq)) { +if (!netif_xmit_frozen_or_drv_stopped (txq)) { ret = ops->ndo_start_xmit (skb, dev);if (ret ==NETDEV_TX_OK )txq_trans_update (txq);
Signature · 1 line
1.7.11.7
David Miller
maintainerFrom: Daniel Borkmann <[email protected]>
Date: Wed, 2 Apr 2014 20:52:55 +0200
Quoted 5 lines
Applies to net-next tree. Thanks!
Daniel Borkmann (2):
packet: reporttx_droppedinpacket_direct_xmit
packet: fixpacket_direct_xmitfor BQL enabled drivers
Series applied, thanks a lot.