Skip to content

Commit a2288d4

Browse files
Igor Druzhinindavem330
authored andcommitted
xen-netback: don't populate the hash cache on XenBus disconnect
Occasionally, during the disconnection procedure on XenBus which includes hash cache deinitialization there might be some packets still in-flight on other processors. Handling of these packets includes hashing and hash cache population that finally results in hash cache data structure corruption. In order to avoid this we prevent hashing of those packets if there are no queues initialized. In that case RCU protection of queues guards the hash cache as well. Signed-off-by: Igor Druzhinin <igor.druzhinin@citrix.com> Reviewed-by: Paul Durrant <paul.durrant@citrix.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 99e87f5 commit a2288d4

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

drivers/net/xen-netback/hash.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,8 @@ void xenvif_init_hash(struct xenvif *vif)
454454
if (xenvif_hash_cache_size == 0)
455455
return;
456456

457+
BUG_ON(vif->hash.cache.count);
458+
457459
spin_lock_init(&vif->hash.cache.lock);
458460
INIT_LIST_HEAD(&vif->hash.cache.list);
459461
}

drivers/net/xen-netback/interface.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,13 @@ static u16 xenvif_select_queue(struct net_device *dev, struct sk_buff *skb,
153153
{
154154
struct xenvif *vif = netdev_priv(dev);
155155
unsigned int size = vif->hash.size;
156+
unsigned int num_queues;
157+
158+
/* If queues are not set up internally - always return 0
159+
* as the packet going to be dropped anyway */
160+
num_queues = READ_ONCE(vif->num_queues);
161+
if (num_queues < 1)
162+
return 0;
156163

157164
if (vif->hash.alg == XEN_NETIF_CTRL_HASH_ALGORITHM_NONE)
158165
return fallback(dev, skb, NULL) % dev->real_num_tx_queues;

0 commit comments

Comments
 (0)