Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b6ecfd46 authored by Johannes Berg's avatar Johannes Berg Committed by Johannes Berg
Browse files

cfg80211: preserve wdev ID across netns changes



When a wdev changes network namespace, its wdev ID will get
reassigned since NETDEV_REGISTER is called again, in the new
network namespace. Avoid that by checking if it was already
assigned before, and document why we do that.

Reported-and-tested-by: default avatarArend Van Spriel <arend.vanspriel@broadcom.com>
Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
parent 335d5349
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -1159,6 +1159,14 @@ static int cfg80211_netdev_notifier_call(struct notifier_block *nb,
		INIT_LIST_HEAD(&wdev->mgmt_registrations);
		spin_lock_init(&wdev->mgmt_registrations_lock);

		/*
		 * We get here also when the interface changes network namespaces,
		 * as it's registered into the new one, but we don't want it to
		 * change ID in that case. Checking if the ID is already assigned
		 * works, because 0 isn't considered a valid ID and the memory is
		 * 0-initialized.
		 */
		if (!wdev->identifier)
			wdev->identifier = ++rdev->wdev_id;
		list_add_rcu(&wdev->list, &rdev->wiphy.wdev_list);
		rdev->devlist_generation++;