Commit c661050
net: create a dummy net_device allocator
It is impossible to use init_dummy_netdev together with alloc_netdev()
as the 'setup' argument.
This is because alloc_netdev() initializes some fields in the net_device
structure, and later init_dummy_netdev() memzero them all. This causes
some problems as reported here:
https://lore.kernel.org/all/20240322082336.49f110cc@kernel.org/
Split the init_dummy_netdev() function in two. Create a new function called
init_dummy_netdev_core() that does not memzero the net_device structure.
Then have init_dummy_netdev() memzero-ing and calling
init_dummy_netdev_core(), keeping the old behaviour.
init_dummy_netdev_core() is the new function that could be called as an
argument for alloc_netdev().
Also, create a helper to allocate and initialize dummy net devices,
leveraging init_dummy_netdev_core() as the setup argument. This function
basically simplify the allocation of dummy devices, by allocating and
initializing it. Freeing the device continue to be done through
free_netdev()
Suggested-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Breno Leitao <leitao@debian.org>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>1 parent f8d0567 commit c661050
2 files changed
+41
-18
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4519 | 4519 | | |
4520 | 4520 | | |
4521 | 4521 | | |
| 4522 | + | |
| 4523 | + | |
| 4524 | + | |
4522 | 4525 | | |
4523 | 4526 | | |
4524 | 4527 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10420 | 10420 | | |
10421 | 10421 | | |
10422 | 10422 | | |
10423 | | - | |
10424 | | - | |
10425 | | - | |
10426 | | - | |
10427 | | - | |
10428 | | - | |
10429 | | - | |
10430 | | - | |
10431 | | - | |
| 10423 | + | |
| 10424 | + | |
| 10425 | + | |
10432 | 10426 | | |
10433 | | - | |
| 10427 | + | |
10434 | 10428 | | |
10435 | | - | |
10436 | | - | |
10437 | | - | |
10438 | | - | |
10439 | | - | |
10440 | | - | |
10441 | | - | |
10442 | 10429 | | |
10443 | 10430 | | |
10444 | 10431 | | |
| |||
10459 | 10446 | | |
10460 | 10447 | | |
10461 | 10448 | | |
10462 | | - | |
10463 | 10449 | | |
| 10450 | + | |
| 10451 | + | |
| 10452 | + | |
| 10453 | + | |
| 10454 | + | |
| 10455 | + | |
| 10456 | + | |
| 10457 | + | |
| 10458 | + | |
| 10459 | + | |
| 10460 | + | |
| 10461 | + | |
| 10462 | + | |
| 10463 | + | |
| 10464 | + | |
| 10465 | + | |
| 10466 | + | |
| 10467 | + | |
| 10468 | + | |
| 10469 | + | |
| 10470 | + | |
10464 | 10471 | | |
10465 | 10472 | | |
10466 | 10473 | | |
| |||
11080 | 11087 | | |
11081 | 11088 | | |
11082 | 11089 | | |
| 11090 | + | |
| 11091 | + | |
| 11092 | + | |
| 11093 | + | |
| 11094 | + | |
| 11095 | + | |
| 11096 | + | |
| 11097 | + | |
| 11098 | + | |
| 11099 | + | |
| 11100 | + | |
| 11101 | + | |
| 11102 | + | |
11083 | 11103 | | |
11084 | 11104 | | |
11085 | 11105 | | |
| |||
0 commit comments