<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel/linux.git/drivers/net/netdevsim/bus.c, branch v6.19.11</title>
<subtitle>Linux kernel stable tree (mirror)</subtitle>
<id>https://git.radix-linux.su/kernel/linux.git/atom?h=v6.19.11</id>
<link rel='self' href='https://git.radix-linux.su/kernel/linux.git/atom?h=v6.19.11'/>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/'/>
<updated>2026-01-07T02:04:00+00:00</updated>
<entry>
<title>net: netdevsim: fix inconsistent carrier state after link/unlink</title>
<updated>2026-01-07T02:04:00+00:00</updated>
<author>
<name>Yohei Kojima</name>
<email>yk@y-koj.net</email>
</author>
<published>2026-01-05T15:17:32+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=d83dddffe1904e4a576d11a541878850a8e64cd2'/>
<id>urn:sha1:d83dddffe1904e4a576d11a541878850a8e64cd2</id>
<content type='text'>
This patch fixes the edge case behavior on ifup/ifdown and
linking/unlinking two netdevsim interfaces:

1. unlink two interfaces netdevsim1 and netdevsim2
2. ifdown netdevsim1
3. ifup netdevsim1
4. link two interfaces netdevsim1 and netdevsim2
5. (Now two interfaces are linked in terms of netdevsim peer, but
    carrier state of the two interfaces remains DOWN.)

This inconsistent behavior is caused by the current implementation,
which only cares about the "link, then ifup" order, not "ifup, then
link" order. This patch fixes the inconsistency by calling
netif_carrier_on() when two netdevsim interfaces are linked.

This patch fixes buggy behavior on NetworkManager-based systems which
causes the netdevsim test to fail with the following error:

  # timeout set to 600
  # selftests: drivers/net/netdevsim: peer.sh
  # 2025/12/25 00:54:03 socat[9115] W address is opened in read-write mode but only supports read-only
  # 2025/12/25 00:56:17 socat[9115] W connect(7, AF=2 192.168.1.1:1234, 16): Connection timed out
  # 2025/12/25 00:56:17 socat[9115] E TCP:192.168.1.1:1234: Connection timed out
  # expected 3 bytes, got 0
  # 2025/12/25 00:56:17 socat[9109] W exiting on signal 15
  not ok 13 selftests: drivers/net/netdevsim: peer.sh # exit=1

This patch also solves timeout on TCP Fast Open (TFO) test in
NetworkManager-based systems because it also depends on netdevsim's
carrier consistency.

Fixes: 1a8fed52f7be ("netdevsim: set the carrier when the device goes up")
Signed-off-by: Yohei Kojima &lt;yk@y-koj.net&gt;
Reviewed-by: Breno Leitao &lt;leitao@debian.org&gt;
Link: https://patch.msgid.link/602c9e1ba5bb2ee1997bb38b1d866c9c3b807ae9.1767624906.git.yk@y-koj.net
Signed-off-by: Jakub Kicinski &lt;kuba@kernel.org&gt;
</content>
</entry>
<entry>
<title>netdevsim: implement peer queue flow control</title>
<updated>2025-07-15T00:36:50+00:00</updated>
<author>
<name>Breno Leitao</name>
<email>leitao@debian.org</email>
</author>
<published>2025-07-11T17:06:59+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=ff2ac4df58adb6d7721bb0ce6069e1bd0e613126'/>
<id>urn:sha1:ff2ac4df58adb6d7721bb0ce6069e1bd0e613126</id>
<content type='text'>
Add flow control mechanism between paired netdevsim devices to stop the
TX queue during high traffic scenarios. When a receive queue becomes
congested (approaching NSIM_RING_SIZE limit), the corresponding transmit
queue on the peer device is stopped using netif_subqueue_try_stop().

Once the receive queue has sufficient capacity again, the peer's
transmit queue is resumed with netif_tx_wake_queue().

Key changes:
  * Add nsim_stop_peer_tx_queue() to pause peer TX when RX queue is full
  * Add nsim_start_peer_tx_queue() to resume peer TX when RX queue drains
  * Implement queue mapping validation to ensure TX/RX queue count match
  * Wake all queues during device unlinking to prevent stuck queues
  * Use RCU protection when accessing peer device references
  * wake the queues when changing the queue numbers
  * Remove IFF_NO_QUEUE given it will enqueue packets now

The flow control only activates when devices have matching TX/RX queue
counts to ensure proper queue mapping.

Suggested-by: Jakub Kicinski &lt;kuba@kernel.org&gt;
Signed-off-by: Breno Leitao &lt;leitao@debian.org&gt;
Link: https://patch.msgid.link/20250711-netdev_flow_control-v3-1-aa1d5a155762@debian.org
Signed-off-by: Jakub Kicinski &lt;kuba@kernel.org&gt;
</content>
</entry>
<entry>
<title>net: netdevsim: Support setting dev-&gt;perm_addr on port creation</title>
<updated>2025-07-12T00:00:18+00:00</updated>
<author>
<name>Toke Høiland-Jørgensen</name>
<email>toke@redhat.com</email>
</author>
<published>2025-07-10T11:18:33+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=54cb59cf81b02de847178c054eed7957170e9386'/>
<id>urn:sha1:54cb59cf81b02de847178c054eed7957170e9386</id>
<content type='text'>
Network management daemons that match on the device permanent address
currently have no virtual interface types to test against.
NetworkManager, in particular, has carried an out of tree patch to set
the permanent address on netdevsim devices to use in its CI for this
purpose.

To support this use case, support setting netdev-&gt;perm_addr when
creating a netdevsim port.

Reviewed-by: Simon Horman &lt;horms@kernel.org&gt;
Signed-off-by: Toke Høiland-Jørgensen &lt;toke@redhat.com&gt;
Link: https://patch.msgid.link/20250710-netdevsim-perm_addr-v4-1-c9db2fecf3bf@redhat.com
Signed-off-by: Jakub Kicinski &lt;kuba@kernel.org&gt;
</content>
</entry>
<entry>
<title>netdevsim: allow two netdevsim ports to be connected</title>
<updated>2024-03-01T10:43:10+00:00</updated>
<author>
<name>David Wei</name>
<email>dw@davidwei.uk</email>
</author>
<published>2024-02-28T23:22:49+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=f532957d76de89b8ee2545cb6ad5265e1701d0ba'/>
<id>urn:sha1:f532957d76de89b8ee2545cb6ad5265e1701d0ba</id>
<content type='text'>
Add two netdevsim bus attribute to sysfs:
/sys/bus/netdevsim/link_device
/sys/bus/netdevsim/unlink_device

Writing "A M B N" to link_device will link netdevsim M in netnsid A with
netdevsim N in netnsid B.

Writing "A M" to unlink_device will unlink netdevsim M in netnsid A from
its peer, if any.

rtnl_lock is taken to ensure nothing changes during the linking.

Signed-off-by: David Wei &lt;dw@davidwei.uk&gt;
Reviewed-by: Maciek Machnikowski &lt;maciek@machnikowski.net&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>net: netdevsim: constify the struct device_type usage</title>
<updated>2024-02-21T09:45:23+00:00</updated>
<author>
<name>Ricardo B. Marliere</name>
<email>ricardo@marliere.net</email>
</author>
<published>2024-02-17T20:13:32+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=52042e092ba9cf9120ffe516dd03acb1d1e572b9'/>
<id>urn:sha1:52042e092ba9cf9120ffe516dd03acb1d1e572b9</id>
<content type='text'>
Since commit aed65af1cc2f ("drivers: make device_type const"), the driver
core can properly handle constant struct device_type. Move the
nsim_bus_dev_type variable to be a constant structure as well, placing it
into read-only memory which can not be modified at runtime.

Cc: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
Signed-off-by: Ricardo B. Marliere &lt;ricardo@marliere.net&gt;
Reviewed-by: Simon Horman &lt;horms@kernel.org&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>netdevsim: make nsim_bus const</title>
<updated>2024-02-07T13:40:27+00:00</updated>
<author>
<name>Ricardo B. Marliere</name>
<email>ricardo@marliere.net</email>
</author>
<published>2024-02-04T20:16:34+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=56b93cd358b304b2d1945c0330dffe8f872bc0d3'/>
<id>urn:sha1:56b93cd358b304b2d1945c0330dffe8f872bc0d3</id>
<content type='text'>
Now that the driver core can properly handle constant struct bus_type,
move the nsim_bus variable to be a constant structure as well,
placing it into read-only memory which can not be modified at runtime.

Cc: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
Suggested-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
Signed-off-by: Ricardo B. Marliere &lt;ricardo@marliere.net&gt;
Reviewed-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>netdevsim: Block until all devices are released</title>
<updated>2023-10-27T21:48:36+00:00</updated>
<author>
<name>Ido Schimmel</name>
<email>idosch@nvidia.com</email>
</author>
<published>2023-10-26T08:33:43+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=6aff7cbfe7bfafbed86a6948e660e280848c4d97'/>
<id>urn:sha1:6aff7cbfe7bfafbed86a6948e660e280848c4d97</id>
<content type='text'>
Like other buses, devices on the netdevsim bus have a release callback
that is invoked when the reference count of the device drops to zero.
However, unlike other buses such as PCI, the release callback is not
necessarily built into the kernel, as netdevsim can be built as a
module.

The above is problematic as nothing prevents the module from being
unloaded before the release callback has been invoked, which can happen
asynchronously. One such example can be found in commit a380687200e0
("devlink: take device reference for devlink object") where devlink
calls put_device() from an RCU callback.

The issue is not theoretical and the reproducer in [1] can reliably
crash the kernel. The conclusion of this discussion was that the issue
should be solved in netdevsim, which is what this patch is trying to do.

Add a reference count that is increased when a device is added to the
bus and decreased when a device is released. Signal a completion when
the reference count drops to zero and wait for the completion when
unloading the module so that the module will not be unloaded before all
the devices were released. The reference count is initialized to one so
that completion is only signaled when unloading the module.

With this patch, the reproducer in [1] no longer crashes the kernel.

[1] https://lore.kernel.org/netdev/20230619125015.1541143-2-idosch@nvidia.com/

Fixes: a380687200e0 ("devlink: take device reference for devlink object")
Signed-off-by: Ido Schimmel &lt;idosch@nvidia.com&gt;
Reviewed-by: Jiri Pirko &lt;jiri@nvidia.com&gt;
Link: https://lore.kernel.org/r/20231026083343.890689-1-idosch@nvidia.com
Signed-off-by: Jakub Kicinski &lt;kuba@kernel.org&gt;
</content>
</entry>
<entry>
<title>driver core: bus: mark the struct bus_type for sysfs callbacks as constant</title>
<updated>2023-03-23T12:20:40+00:00</updated>
<author>
<name>Greg Kroah-Hartman</name>
<email>gregkh@linuxfoundation.org</email>
</author>
<published>2023-03-13T18:29:05+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=75cff725d9566699a670a02b3cfd1c6e9e9ed53e'/>
<id>urn:sha1:75cff725d9566699a670a02b3cfd1c6e9e9ed53e</id>
<content type='text'>
struct bus_type should never be modified in a sysfs callback as there is
nothing in the structure to modify, and frankly, the structure is almost
never used in a sysfs callback, so mark it as constant to allow struct
bus_type to be moved to read-only memory.

Cc: "David S. Miller" &lt;davem@davemloft.net&gt;
Cc: "James E.J. Bottomley" &lt;jejb@linux.ibm.com&gt;
Cc: "K. Y. Srinivasan" &lt;kys@microsoft.com&gt;
Cc: Alexander Gordeev &lt;agordeev@linux.ibm.com&gt;
Cc: Alexandre Bounine &lt;alex.bou9@gmail.com&gt;
Cc: Alison Schofield &lt;alison.schofield@intel.com&gt;
Cc: Ben Widawsky &lt;bwidawsk@kernel.org&gt;
Cc: Dexuan Cui &lt;decui@microsoft.com&gt;
Cc: Eric Dumazet &lt;edumazet@google.com&gt;
Cc: Haiyang Zhang &lt;haiyangz@microsoft.com&gt;
Cc: Hannes Reinecke &lt;hare@suse.de&gt;
Cc: Harald Freudenberger &lt;freude@linux.ibm.com&gt;
Cc: Heiko Carstens &lt;hca@linux.ibm.com&gt;
Cc: Hu Haowen &lt;src.res@email.cn&gt;
Cc: Jakub Kicinski &lt;kuba@kernel.org&gt;
Cc: Jens Axboe &lt;axboe@kernel.dk&gt;
Cc: Jonathan Corbet &lt;corbet@lwn.net&gt;
Cc: Laurentiu Tudor &lt;laurentiu.tudor@nxp.com&gt;
Cc: Matt Porter &lt;mporter@kernel.crashing.org&gt;
Cc: Michael Ellerman &lt;mpe@ellerman.id.au&gt;
Cc: Paolo Abeni &lt;pabeni@redhat.com&gt;
Cc: Stuart Yoder &lt;stuyoder@gmail.com&gt;
Cc: Vasily Gorbik &lt;gor@linux.ibm.com&gt;
Cc: Vishal Verma &lt;vishal.l.verma@intel.com&gt;
Cc: Yanteng Si &lt;siyanteng@loongson.cn&gt;
Acked-by: Ilya Dryomov &lt;idryomov@gmail.com&gt; # rbd
Acked-by: Ira Weiny &lt;ira.weiny@intel.com&gt; # cxl
Reviewed-by: Alex Shi &lt;alexs@kernel.org&gt;
Acked-by: Iwona Winiarska &lt;iwona.winiarska@intel.com&gt;
Acked-by: Dan Williams &lt;dan.j.williams@intel.com&gt;
Acked-by: Bjorn Helgaas &lt;bhelgaas@google.com&gt;	# pci
Acked-by: Wei Liu &lt;wei.liu@kernel.org&gt;
Acked-by: Martin K. Petersen &lt;martin.petersen@oracle.com&gt; # scsi
Link: https://lore.kernel.org/r/20230313182918.1312597-23-gregkh@linuxfoundation.org
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>netdevsim: fix memory leak in nsim_bus_dev_new()</title>
<updated>2022-10-27T17:47:09+00:00</updated>
<author>
<name>Zhengchao Shao</name>
<email>shaozhengchao@huawei.com</email>
</author>
<published>2022-10-26T01:54:05+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=cf2010aa1c739bab067cbc90b690d28eaa0b47da'/>
<id>urn:sha1:cf2010aa1c739bab067cbc90b690d28eaa0b47da</id>
<content type='text'>
If device_register() failed in nsim_bus_dev_new(), the value of reference
in nsim_bus_dev-&gt;dev is 1. obj-&gt;name in nsim_bus_dev-&gt;dev will not be
released.

unreferenced object 0xffff88810352c480 (size 16):
  comm "echo", pid 5691, jiffies 4294945921 (age 133.270s)
  hex dump (first 16 bytes):
    6e 65 74 64 65 76 73 69 6d 31 00 00 00 00 00 00  netdevsim1......
  backtrace:
    [&lt;000000005e2e5e26&gt;] __kmalloc_node_track_caller+0x3a/0xb0
    [&lt;0000000094ca4fc8&gt;] kvasprintf+0xc3/0x160
    [&lt;00000000aad09bcc&gt;] kvasprintf_const+0x55/0x180
    [&lt;000000009bac868d&gt;] kobject_set_name_vargs+0x56/0x150
    [&lt;000000007c1a5d70&gt;] dev_set_name+0xbb/0xf0
    [&lt;00000000ad0d126b&gt;] device_add+0x1f8/0x1cb0
    [&lt;00000000c222ae24&gt;] new_device_store+0x3b6/0x5e0
    [&lt;0000000043593421&gt;] bus_attr_store+0x72/0xa0
    [&lt;00000000cbb1833a&gt;] sysfs_kf_write+0x106/0x160
    [&lt;00000000d0dedb8a&gt;] kernfs_fop_write_iter+0x3a8/0x5a0
    [&lt;00000000770b66e2&gt;] vfs_write+0x8f0/0xc80
    [&lt;0000000078bb39be&gt;] ksys_write+0x106/0x210
    [&lt;00000000005e55a4&gt;] do_syscall_64+0x35/0x80
    [&lt;00000000eaa40bbc&gt;] entry_SYSCALL_64_after_hwframe+0x46/0xb0

Fixes: 40e4fe4ce115 ("netdevsim: move device registration and related code to bus.c")
Signed-off-by: Zhengchao Shao &lt;shaozhengchao@huawei.com&gt;
Link: https://lore.kernel.org/r/20221026015405.128795-1-shaozhengchao@huawei.com
Signed-off-by: Jakub Kicinski &lt;kuba@kernel.org&gt;
</content>
</entry>
<entry>
<title>netdevsim: convert driver to use unlocked devlink API during init/fini</title>
<updated>2022-07-19T03:10:48+00:00</updated>
<author>
<name>Jiri Pirko</name>
<email>jiri@nvidia.com</email>
</author>
<published>2022-07-16T11:02:40+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=012ec02ae4410207f796a9b280a60b80b6cc790a'/>
<id>urn:sha1:012ec02ae4410207f796a9b280a60b80b6cc790a</id>
<content type='text'>
Prepare for devlink reload being called with devlink-&gt;lock held and
convert the netdevsim driver to use unlocked devlink API during init and
fini flows. Take devl_lock() in reload_down() and reload_up() ops in the
meantime before reload cmd is converted to take the lock itself.

Signed-off-by: Jiri Pirko &lt;jiri@nvidia.com&gt;
Signed-off-by: Jakub Kicinski &lt;kuba@kernel.org&gt;
</content>
</entry>
</feed>
