summaryrefslogtreecommitdiff
path: root/net/core/dev.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/core/dev.c')
-rw-r--r--net/core/dev.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/net/core/dev.c b/net/core/dev.c
index df1a840b0334..3c58db732761 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -4207,6 +4207,18 @@ static struct sk_buff *validate_xmit_skb(struct sk_buff *skb, struct net_device
if (unlikely(!skb))
goto out_null;
+ /* Only fraglist GSO, whose segments already carry valid checksums,
+ * can be handed to a device as CHECKSUM_UNNECESSARY. Any other GSO
+ * skb has no csum_start for the device to segment from. NONE means
+ * the same on transmit, but makes netif_needs_gso() send it to the
+ * GSO code, which turns TCP into CHECKSUM_PARTIAL for TSO and
+ * segments anything the device cannot offload in software.
+ */
+ if (unlikely(skb->ip_summed == CHECKSUM_UNNECESSARY &&
+ skb_is_gso(skb) &&
+ !(skb_shinfo(skb)->gso_type & SKB_GSO_FRAGLIST)))
+ skb->ip_summed = CHECKSUM_NONE;
+
features = netif_skb_features(skb);
skb = validate_xmit_vlan(skb, features);
if (unlikely(!skb))
@@ -11101,6 +11113,14 @@ atomic_t dev_unreg_count = ATOMIC_INIT(0);
static void net_set_todo(struct net_device *dev)
{
list_add_tail(&dev->todo_list, &net_todo_list);
+ atomic_inc(&dev_net(dev)->dev_unreg_pending);
+}
+
+/* Paired with net_set_todo(). @net must not be used after this call. */
+static void net_unreg_done(struct net *net)
+{
+ if (atomic_dec_and_test(&net->dev_unreg_pending))
+ wake_up(&netdev_unregistering_wq);
}
static netdev_features_t netdev_sync_upper_features(struct net_device *lower,
@@ -12000,6 +12020,7 @@ void netdev_run_todo(void)
if (unlikely(dev->reg_state != NETREG_UNREGISTERING)) {
netdev_WARN(dev, "run_todo but not unregistering\n");
list_del(&dev->todo_list);
+ net_unreg_done(dev_net(dev));
continue;
}
@@ -12016,8 +12037,11 @@ void netdev_run_todo(void)
cnt = 0;
while (!list_empty(&list)) {
+ struct net *net;
+
dev = netdev_wait_allrefs_any(&list);
list_del(&dev->todo_list);
+ net = dev_net(dev);
/* paranoia */
BUG_ON(netdev_refcnt_read(dev) != 1);
@@ -12038,6 +12062,8 @@ void netdev_run_todo(void)
/* Free network device */
kobject_put(&dev->dev.kobj);
+
+ net_unreg_done(net);
}
if (cnt && atomic_sub_and_test(cnt, &dev_unreg_count))
wake_up(&netdev_unregistering_wq);
@@ -13486,6 +13512,17 @@ static void __net_exit default_device_exit_net(struct net *net)
}
}
+static bool __net_exit netns_dev_unreg_pending(const struct list_head *net_list)
+{
+ struct net *net;
+
+ list_for_each_entry(net, net_list, exit_list) {
+ if (atomic_read(&net->dev_unreg_pending))
+ return true;
+ }
+ return false;
+}
+
static void __net_exit default_device_exit_batch(struct list_head *net_list)
{
/* At exit all network devices most be removed from a network
@@ -13527,6 +13564,16 @@ static void __net_exit default_device_exit_batch(struct list_head *net_list)
unregister_netdevice_many(&dev_kill_list);
rtnl_unlock();
+ /* Devices of these netns unregistered from another context
+ * (e.g. a veth whose peer was deleted) can still be waiting
+ * in netdev_run_todo() for their last references, while
+ * NETDEV_UNREGISTER is rebroadcast for them. Wait for them
+ * before pernet exit handlers tear down the state used by
+ * netdevice notifiers, and before the netns is freed.
+ * No new unregistration can start: all devices are unlisted.
+ */
+ wait_event(netdev_unregistering_wq, !netns_dev_unreg_pending(net_list));
+
rtnl_net_flush_workqueue();
}