ax25: Use kernel universal linked list to implement ax25_dev_list
authorDuoming Zhou <duoming@zju.edu.cn>
Thu, 9 May 2024 09:36:33 +0000 (17:36 +0800)
committerJakub Kicinski <kuba@kernel.org>
Mon, 13 May 2024 23:09:38 +0000 (16:09 -0700)
commita7d6e36b9ad052926ba2ecba3a59d8bb67dabcb4
tree87e77f1b8faedbce60e03a092e63dff26c2bb340
parentecf848eb934b03959918f5269f64c0e52bc23998
ax25: Use kernel universal linked list to implement ax25_dev_list

The origin ax25_dev_list implements its own single linked list,
which is complicated and error-prone. For example, when deleting
the node of ax25_dev_list in ax25_dev_device_down(), we have to
operate on the head node and other nodes separately.

This patch uses kernel universal linked list to replace original
ax25_dev_list, which make the operation of ax25_dev_list easier.

We should do "dev->ax25_ptr = ax25_dev;" and "dev->ax25_ptr = NULL;"
while holding the spinlock, otherwise the ax25_dev_device_up() and
ax25_dev_device_down() could race.

Suggested-by: Dan Carpenter <dan.carpenter@linaro.org>
Signed-off-by: Duoming Zhou <duoming@zju.edu.cn>
Reviewed-by: Dan Carpenter <dan.carpenter@linaro.org>
Link: https://lore.kernel.org/r/85bba3af651ca0e1a519da8d0d715b949891171c.1715247018.git.duoming@zju.edu.cn
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
include/net/ax25.h
net/ax25/ax25_dev.c