xen-netback: use skb to determine number of required (etc.)
Subsystems (3)
v2 cover xen-netback: use skb to determine number of required (etc.)
"xen-netback: use skb to determine number of required" plus two other minor fixes I found down the back of the sofa.
David
PATCH v2 1/3 xen-netback: use skb to determine number of required guest Rx requests
Using the MTU or GSO size to determine the number of required guest Rx requests for an skb was subtly broken since these value may change at runtime.
After 1650d5455bd2dc6b5ee134bd6fc1a3236c266b5b (xen-netback: always fully coalesce guest Rx packets) we always fully pack a packet into its guest Rx slots. Calculating the number of required slots from the packet length is then easy.
--- drivers/net/xen-netback/netback.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-)
drivers/net/xen-netback/netback.c +9 -11
@@ -149,20 +149,19 @@ static inline pending_ring_idx_t pending_index(unsigned i)return i & (MAX_PENDING_REQS -1 ); } -static int xenvif_rx_ring_slots_needed (struct xenvif *vif) -{ -if (vif->gso_mask) -return DIV_ROUND_UP (vif->dev->gso_max_size,XEN_PAGE_SIZE ) +1 ; -else -return DIV_ROUND_UP (vif->dev->mtu,XEN_PAGE_SIZE ); -} -static bool xenvif_rx_ring_slots_available (struct xenvif_queue *queue) {RING_IDX prod, cons; +struct sk_buff *skb;int needed; - needed =xenvif_rx_ring_slots_needed (queue->vif); + skb =skb_peek (&queue->rx_queue); +if (!skb) +return false; + + needed =DIV_ROUND_UP (skb->len,XEN_PAGE_SIZE ); +if (skb_is_gso (skb)) + needed++; do { prod = queue->rx.sring->req_prod;
@@ -2005,8 +2004,7 @@ static bool xenvif_rx_queue_ready(struct xenvif_queue *queue)static bool xenvif_have_rx_work (struct xenvif_queue *queue) { -return (!skb_queue_empty (&queue->rx_queue) - &&xenvif_rx_ring_slots_available (queue)) +return xenvif_rx_ring_slots_available (queue) || (queue->vif->stall_timeout && (xenvif_rx_queue_stalled (queue) ||xenvif_rx_queue_ready (queue)))
Signature · 1 line
2.1.4
PATCH v2 1/3 xen-netback: use skb to determine number of required guest Rx requests
In reply to David VrabelUsing the MTU or GSO size to determine the number of required guest Rx requests for an skb was subtly broken since these value may change at runtime.
After 1650d5455bd2dc6b5ee134bd6fc1a3236c266b5b (xen-netback: always fully coalesce guest Rx packets) we always fully pack a packet into its guest Rx slots. Calculating the number of required slots from the packet length is then easy.
--- drivers/net/xen-netback/netback.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-)
drivers/net/xen-netback/netback.c +9 -11
@@ -149,20 +149,19 @@ static inline pending_ring_idx_t pending_index(unsigned i)return i & (MAX_PENDING_REQS -1 ); } -static int xenvif_rx_ring_slots_needed (struct xenvif *vif) -{ -if (vif->gso_mask) -return DIV_ROUND_UP (vif->dev->gso_max_size,XEN_PAGE_SIZE ) +1 ; -else -return DIV_ROUND_UP (vif->dev->mtu,XEN_PAGE_SIZE ); -} -static bool xenvif_rx_ring_slots_available (struct xenvif_queue *queue) {RING_IDX prod, cons; +struct sk_buff *skb;int needed; - needed =xenvif_rx_ring_slots_needed (queue->vif); + skb =skb_peek (&queue->rx_queue); +if (!skb) +return false; + + needed =DIV_ROUND_UP (skb->len,XEN_PAGE_SIZE ); +if (skb_is_gso (skb)) + needed++; do { prod = queue->rx.sring->req_prod;
@@ -2005,8 +2004,7 @@ static bool xenvif_rx_queue_ready(struct xenvif_queue *queue)static bool xenvif_have_rx_work (struct xenvif_queue *queue) { -return (!skb_queue_empty (&queue->rx_queue) - &&xenvif_rx_ring_slots_available (queue)) +return xenvif_rx_ring_slots_available (queue) || (queue->vif->stall_timeout && (xenvif_rx_queue_stalled (queue) ||xenvif_rx_queue_ready (queue)))
Signature · 1 line
2.1.4
PATCH v2 2/3 xen-netback: delete NAPI instance when queue fails to initialize
In reply to David VrabelWhen xenvif_connect() fails it may leave a stale NAPI instance added to the device. Make sure we delete it in the error path.
--- drivers/net/xen-netback/interface.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/xen-netback/interface.c +1 -0
@@ -615,6 +615,7 @@ err_tx_unbind: queue->tx_irq =0 ; err_unmap:xenvif_unmap_frontend_rings (queue); +netif_napi_del (&queue->napi); err:module_put (THIS_MODULE );return err;
Signature · 1 line
2.1.4
PATCH v2 3/3 xen-netback: free queues after freeing the net device
In reply to David VrabelIf a queue still has a NAPI instance added to the net device, freeing the queues early results in a use-after-free.
The shouldn't ever happen because we disconnect and tear down all queues before freeing the net device, but doing this makes it obviously safe.
--- drivers/net/xen-netback/interface.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-)
drivers/net/xen-netback/interface.c +5 -11
@@ -685,22 +685,16 @@ void xenvif_deinit_queue(struct xenvif_queue *queue)void xenvif_free (struct xenvif *vif) { -struct xenvif_queue *queue =NULL ; +struct xenvif_queue *queues = vif->queues;unsigned int num_queues = vif->num_queues;unsigned int queue_index;unregister_netdev (vif->dev); - -for (queue_index =0 ; queue_index < num_queues; ++queue_index) { - queue = &vif->queues[queue_index]; -xenvif_deinit_queue (queue); - } - -vfree (vif->queues); - vif->queues =NULL ; - vif->num_queues =0 ; -free_netdev (vif->dev); +for (queue_index =0 ; queue_index < num_queues; ++queue_index) +xenvif_deinit_queue (&queues[queue_index]); +vfree (queues); +module_put (THIS_MODULE ); }
Signature · 1 line
2.1.4
David Miller
maintainerFrom: David Vrabel <[email protected]>
Date: Fri, 15 Jan 2016 14:55:33 +0000
Quoted 2 lines
"xen-netback: use skb to determine number of required" plus two other minor fixes I found down the back of the sofa.
Series applied, thanks David.
David Miller
maintainerFrom: David Vrabel <[email protected]>
Date: Fri, 15 Jan 2016 14:55:33 +0000
Quoted 2 lines
"xen-netback: use skb to determine number of required" plus two other minor fixes I found down the back of the sofa.
Series applied, thanks David.