RE: [PATCH] net: tipc: add net device refcount tracker for bearer

From: Tung Quang Nguyen
Date: Sun Aug 06 2023 - 20:26:13 EST


>Add net device refcount tracker to the struct tipc_bearer.
>
>Signed-off-by: xu xin <xu.xin16@xxxxxxxxxx>
>Reviewed-by: Yang Yang <yang.yang.29@xxxxxxxxxx>
>Cc: Kuang Mingfu <kuang.mingfu@xxxxxxxxxx>
>---
> net/tipc/bearer.c | 10 +++++-----
> net/tipc/bearer.h | 1 +
> 2 files changed, 6 insertions(+), 5 deletions(-)
>
>diff --git a/net/tipc/bearer.c b/net/tipc/bearer.c index 2cde375477e3..01ffd1f2337a 100644
>--- a/net/tipc/bearer.c
>+++ b/net/tipc/bearer.c
>@@ -426,15 +426,15 @@ int tipc_enable_l2_media(struct net *net, struct tipc_bearer *b,
> struct net_device *dev;
>
> /* Find device with specified name */
>- dev = dev_get_by_name(net, dev_name);
>+ dev = netdev_get_by_name(net, dev_name, &b->devtracker, GFP_KERNEL);
> if (!dev)
> return -ENODEV;
> if (tipc_mtu_bad(dev)) {
>- dev_put(dev);
>+ netdev_put(dev, &b->devtracker);
> return -EINVAL;
> }
> if (dev == net->loopback_dev) {
>- dev_put(dev);
>+ netdev_put(dev, &b->devtracker);
Loopback device is using tn->loopback_pt.dev_tracker, not b->devtracker.
Did you try to configure bearer on a net namespace to test if your patch works ?