<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel/linux.git/drivers/net/netdevsim/dev.c, branch linux-6.0.y</title>
<subtitle>Linux kernel stable tree (mirror)</subtitle>
<id>https://git.radix-linux.su/kernel/linux.git/atom?h=linux-6.0.y</id>
<link rel='self' href='https://git.radix-linux.su/kernel/linux.git/atom?h=linux-6.0.y'/>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/'/>
<updated>2022-11-26T08:27:40+00:00</updated>
<entry>
<title>netdevsim: Fix memory leak of nsim_dev-&gt;fa_cookie</title>
<updated>2022-11-26T08:27:40+00:00</updated>
<author>
<name>Wang Yufen</name>
<email>wangyufen@huawei.com</email>
</author>
<published>2022-11-15T09:30:25+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=207edad5717e0a5709ce8467f0eff41c607835c9'/>
<id>urn:sha1:207edad5717e0a5709ce8467f0eff41c607835c9</id>
<content type='text'>
[ Upstream commit 064bc7312bd09a48798418663090be0c776183db ]

kmemleak reports this issue:

unreferenced object 0xffff8881bac872d0 (size 8):
  comm "sh", pid 58603, jiffies 4481524462 (age 68.065s)
  hex dump (first 8 bytes):
    04 00 00 00 de ad be ef                          ........
  backtrace:
    [&lt;00000000c80b8577&gt;] __kmalloc+0x49/0x150
    [&lt;000000005292b8c6&gt;] nsim_dev_trap_fa_cookie_write+0xc1/0x210 [netdevsim]
    [&lt;0000000093d78e77&gt;] full_proxy_write+0xf3/0x180
    [&lt;000000005a662c16&gt;] vfs_write+0x1c5/0xaf0
    [&lt;000000007aabf84a&gt;] ksys_write+0xed/0x1c0
    [&lt;000000005f1d2e47&gt;] do_syscall_64+0x3b/0x90
    [&lt;000000006001c6ec&gt;] entry_SYSCALL_64_after_hwframe+0x63/0xcd

The issue occurs in the following scenarios:

nsim_dev_trap_fa_cookie_write()
  kmalloc() fa_cookie
  nsim_dev-&gt;fa_cookie = fa_cookie
..
nsim_drv_remove()

The fa_cookie allocked in nsim_dev_trap_fa_cookie_write() is not freed. To
fix, add kfree(nsim_dev-&gt;fa_cookie) to nsim_drv_remove().

Fixes: d3cbb907ae57 ("netdevsim: add ACL trap reporting cookie as a metadata")
Signed-off-by: Wang Yufen &lt;wangyufen@huawei.com&gt;
Cc: Jiri Pirko &lt;jiri@mellanox.com&gt;
Link: https://lore.kernel.org/r/1668504625-14698-1-git-send-email-wangyufen@huawei.com
Signed-off-by: Jakub Kicinski &lt;kuba@kernel.org&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>netdevsim: remove dir in nsim_dev_debugfs_init() when creating ports dir failed</title>
<updated>2022-11-03T15:00:33+00:00</updated>
<author>
<name>Zhengchao Shao</name>
<email>shaozhengchao@huawei.com</email>
</author>
<published>2022-10-26T01:46:42+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=5f946eb3ae4e9a580372ac3762b9778ed487c8ca'/>
<id>urn:sha1:5f946eb3ae4e9a580372ac3762b9778ed487c8ca</id>
<content type='text'>
[ Upstream commit a6aa8d0ce2cfba57ac0f23293fcb3be0b9f53fba ]

Remove dir in nsim_dev_debugfs_init() when creating ports dir failed.
Otherwise, the netdevsim device will not be created next time. Kernel
reports an error: debugfs: Directory 'netdevsim1' with parent 'netdevsim'
already present!

Fixes: ab1d0cc004d7 ("netdevsim: change debugfs tree topology")
Signed-off-by: Zhengchao Shao &lt;shaozhengchao@huawei.com&gt;
Signed-off-by: Jakub Kicinski &lt;kuba@kernel.org&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>netdevsim: fix memory leak in nsim_drv_probe() when nsim_dev_resources_register() failed</title>
<updated>2022-11-03T15:00:33+00:00</updated>
<author>
<name>Zhengchao Shao</name>
<email>shaozhengchao@huawei.com</email>
</author>
<published>2022-10-26T01:46:41+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=7c4957fe40e2a628b7cceaf4c9bfb5b701774d05'/>
<id>urn:sha1:7c4957fe40e2a628b7cceaf4c9bfb5b701774d05</id>
<content type='text'>
[ Upstream commit 6b1da9f7126f05e857da6db24c6a04aa7974d644 ]

If some items in nsim_dev_resources_register() fail, memory leak will
occur. The following is the memory leak information.

unreferenced object 0xffff888074c02600 (size 128):
  comm "echo", pid 8159, jiffies 4294945184 (age 493.530s)
  hex dump (first 32 bytes):
    40 47 ea 89 ff ff ff ff 01 00 00 00 00 00 00 00  @G..............
    ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff  ................
  backtrace:
    [&lt;0000000011a31c98&gt;] kmalloc_trace+0x22/0x60
    [&lt;0000000027384c69&gt;] devl_resource_register+0x144/0x4e0
    [&lt;00000000a16db248&gt;] nsim_drv_probe+0x37a/0x1260
    [&lt;000000007d1f448c&gt;] really_probe+0x20b/0xb10
    [&lt;00000000c416848a&gt;] __driver_probe_device+0x1b3/0x4a0
    [&lt;00000000077e0351&gt;] driver_probe_device+0x49/0x140
    [&lt;0000000054f2465a&gt;] __device_attach_driver+0x18c/0x2a0
    [&lt;000000008538f359&gt;] bus_for_each_drv+0x151/0x1d0
    [&lt;0000000038e09747&gt;] __device_attach+0x1c9/0x4e0
    [&lt;00000000dd86e533&gt;] bus_probe_device+0x1d5/0x280
    [&lt;00000000839bea35&gt;] device_add+0xae0/0x1cb0
    [&lt;000000009c2abf46&gt;] new_device_store+0x3b6/0x5f0
    [&lt;00000000fb823d7f&gt;] bus_attr_store+0x72/0xa0
    [&lt;000000007acc4295&gt;] sysfs_kf_write+0x106/0x160
    [&lt;000000005f50cb4d&gt;] kernfs_fop_write_iter+0x3a8/0x5a0
    [&lt;0000000075eb41bf&gt;] vfs_write+0x8f0/0xc80

Fixes: 37923ed6b8ce ("netdevsim: Add simple FIB resource controller via devlink")
Signed-off-by: Zhengchao Shao &lt;shaozhengchao@huawei.com&gt;
Signed-off-by: Jakub Kicinski &lt;kuba@kernel.org&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>net: devlink: convert reload command to take implicit devlink-&gt;lock</title>
<updated>2022-08-01T11:14:00+00:00</updated>
<author>
<name>Jiri Pirko</name>
<email>jiri@nvidia.com</email>
</author>
<published>2022-07-29T07:10:36+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=644a66c60f02f302d82c3008ae2ffe67cf495383'/>
<id>urn:sha1:644a66c60f02f302d82c3008ae2ffe67cf495383</id>
<content type='text'>
Convert reload command to behave the same way as the rest of the
commands and let if be called with devlink-&gt;lock held. Remove the
temporary devl_lock taking from drivers. As the DEVLINK_NL_FLAG_NO_LOCK
flag is no longer used, remove it alongside.

Signed-off-by: Jiri Pirko &lt;jiri@nvidia.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&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>
<entry>
<title>devlink: hold the instance lock during eswitch_mode callbacks</title>
<updated>2022-03-21T14:11:38+00:00</updated>
<author>
<name>Jakub Kicinski</name>
<email>kuba@kernel.org</email>
</author>
<published>2022-03-18T19:23:44+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=14e426bf1a4d77ac87d0fa2a964092a23f863e44'/>
<id>urn:sha1:14e426bf1a4d77ac87d0fa2a964092a23f863e44</id>
<content type='text'>
Make the devlink core hold the instance lock during eswitch_mode
callbacks. Cheat in case of mlx5 (see the cover letter).

Reviewed-by: Leon Romanovsky &lt;leonro@nvidia.com&gt;
Reviewed-by: Jiri Pirko &lt;jiri@nvidia.com&gt;
Signed-off-by: Jakub Kicinski &lt;kuba@kernel.org&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>netdevsim: replace vfs_lock with devlink instance lock</title>
<updated>2022-03-21T14:11:38+00:00</updated>
<author>
<name>Jakub Kicinski</name>
<email>kuba@kernel.org</email>
</author>
<published>2022-03-18T19:23:43+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=aff3a925094633a5b77058b9a715efbb12fc2698'/>
<id>urn:sha1:aff3a925094633a5b77058b9a715efbb12fc2698</id>
<content type='text'>
Similarly to the previous commit, use the devlink instance
lock and let it replace the vfs_lock.

nsim_esw_legacy_enable() was locked by both port lock and
vfs lock so one set of lock/unlocks goes away.

netdevsim's .eswitch_mode_set callback is now ready for
the callback to take the instance lock.

Signed-off-by: Jakub Kicinski &lt;kuba@kernel.org&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>netdevsim: replace port_list_lock with devlink instance lock</title>
<updated>2022-03-21T14:11:38+00:00</updated>
<author>
<name>Jakub Kicinski</name>
<email>kuba@kernel.org</email>
</author>
<published>2022-03-18T19:23:42+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=76eea6c2e663f7e9fbc258c82811ad9e657e085f'/>
<id>urn:sha1:76eea6c2e663f7e9fbc258c82811ad9e657e085f</id>
<content type='text'>
Take advantage of the devlink instance lock for protecting
the port list. This will simplify locking even more once
all devlink callbacks hold the instance lock.

We need to add locking in nsim_dev_port_add_all() which used
to assume higher layer protection when accessing the list.

Signed-off-by: Jakub Kicinski &lt;kuba@kernel.org&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>netdevsim: Introduce support for L3 offload xstats</title>
<updated>2022-03-15T13:00:51+00:00</updated>
<author>
<name>Petr Machata</name>
<email>petrm@nvidia.com</email>
</author>
<published>2022-03-14T14:01:15+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=1a6d7ae7d63c4572676f4cc94aa35a73dc14a757'/>
<id>urn:sha1:1a6d7ae7d63c4572676f4cc94aa35a73dc14a757</id>
<content type='text'>
Add support for testing of HW stats support that was added recently, namely
the L3 stats support. L3 stats are provided for devices for which the L3
stats have been turned on, and that were enabled for netdevsim through a
debugfs toggle:

    # echo $ifindex &gt; /sys/kernel/debug/netdevsim/$DEV/hwstats/l3/enable_ifindex

For fully enabled netdevices, netdevsim counts 10pps of ingress traffic and
20pps of egress traffic. Similarly, L3 stats can be disabled for a given
device, and netdevsim ceases pretending there is any HW traffic going on:

    # echo $ifindex &gt; /sys/kernel/debug/netdevsim/$DEV/hwstats/l3/disable_ifindex

Besides this, there is a third toggle to mark a device for future failure:

    # echo $ifindex &gt; /sys/kernel/debug/netdevsim/$DEV/hwstats/l3/fail_next_enable

A future request to enable L3 stats on such netdevice will be bounced by
netdevsim:

    # ip -j l sh dev d | jq '.[].ifindex'
    66
    # echo 66 &gt; /sys/kernel/debug/netdevsim/netdevsim10/hwstats/l3/enable_ifindex
    # echo 66 &gt; /sys/kernel/debug/netdevsim/netdevsim10/hwstats/l3/fail_next_enable
    # ip stats set dev d l3_stats on
    Error: netdevsim: Stats enablement set to fail.

Signed-off-by: Petr Machata &lt;petrm@nvidia.com&gt;
Reviewed-by: Ido Schimmel &lt;idosch@nvidia.com&gt;
Acked-by: Jakub Kicinski &lt;kuba@kernel.org&gt;
Signed-off-by: Paolo Abeni &lt;pabeni@redhat.com&gt;
</content>
</entry>
<entry>
<title>devlink: Simplify devlink resources unregister call</title>
<updated>2021-11-30T12:23:32+00:00</updated>
<author>
<name>Leon Romanovsky</name>
<email>leonro@nvidia.com</email>
</author>
<published>2021-11-30T10:16:20+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=4c897cfc46a554a523343fc3296333c473a2fc52'/>
<id>urn:sha1:4c897cfc46a554a523343fc3296333c473a2fc52</id>
<content type='text'>
The devlink_resources_unregister() used second parameter as an
entry point for the recursive removal of devlink resources. None
of the callers outside of devlink core needed to use this field,
so let's remove it.

As part of this removal, the "struct devlink_resource" was moved
from .h to .c file as it is not possible to use in any place in
the code except devlink.c.

Signed-off-by: Leon Romanovsky &lt;leonro@nvidia.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
</feed>
