All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sven Eckelmann <sven@narfation.org>
To: Marek Lindner <marek.lindner@mailbox.org>,
	Simon Wunderlich <sw@simonwunderlich.de>,
	Antonio Quartulli <antonio@mandelbit.com>,
	Matthias Schiffer <mschiffer@universe-factory.net>
Cc: "David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Simon Horman <horms@kernel.org>,
	b.a.t.m.a.n@lists.open-mesh.org, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH batadv 2/5] batman-adv: only create hardif while a netdev is part of a mesh
Date: Sat, 31 May 2025 11:16:30 +0200	[thread overview]
Message-ID: <7760123.MhkbZ0Pkbq@sven-desktop> (raw)
In-Reply-To: <e311c7d643fa1a7d13f2b518f6ee525eb6711f6c.1747687504.git.mschiffer@universe-factory.net>

[-- Attachment #1: Type: text/plain, Size: 3376 bytes --]

On Monday, 19 May 2025 22:46:29 CEST Matthias Schiffer wrote:
> @@ -734,9 +768,6 @@ int batadv_hardif_enable_interface(struct batadv_hard_iface *hard_iface,
>         if (ret < 0)
>                 goto err_upper;
>  
> -       hard_iface->if_status = BATADV_IF_INACTIVE;
> -
> -       kref_get(&hard_iface->refcount);
>         hard_iface->batman_adv_ptype.type = ethertype;
>         hard_iface->batman_adv_ptype.func = batadv_batman_skb_recv

This is confusing. You remove the reference for the batman_adv_ptype but kept 
the `batadv_hardif_put(hard_iface);` after 
`dev_remove_pack(&hard_iface->batman_adv_ptype);`.

I think this should be added again and instead following code should receive a 
`batadv_hardif_put(hard_iface);` after the `list_del_rcu(&hard_iface->list);`:


> @@ -818,11 +849,16 @@ void batadv_hardif_disable_interface(struct batadv_hard_iface *hard_iface)
>         struct batadv_priv *bat_priv = netdev_priv(hard_iface->mesh_iface);
>         struct batadv_hard_iface *primary_if = NULL;
>  
> +       ASSERT_RTNL();
> +
>         batadv_hardif_deactivate_interface(hard_iface);
>  
>         if (hard_iface->if_status != BATADV_IF_INACTIVE)
>                 goto out;
>  
> +       list_del_rcu(&hard_iface->list);
> +       batadv_hardif_generation++;
> +
>         batadv_info(hard_iface->mesh_iface, "Removing interface: %s\n",
>                     hard_iface->net_dev->name);
>         dev_remove_pack(&hard_iface->batman_adv_ptype);


And yes, this means that this needs to be removed in PATCH 3 again - together 
with the `kref_get` from this chunk (from PATCH 3):

On Monday, 19 May 2025 22:46:31 CEST Matthias Schiffer wrote:
> @@ -738,8 +735,6 @@ int batadv_hardif_enable_interface(struct net_device *net_dev,
>         batadv_v_hardif_init(hard_iface);
>  
>         kref_get(&hard_iface->refcount);
> -       list_add_tail_rcu(&hard_iface->list, &batadv_hardif_list);
> -       batadv_hardif_generation++;
>  
>         hardif_mtu = READ_ONCE(hard_iface->net_dev->mtu);
>         required_mtu = READ_ONCE(mesh_iface->mtu) + max_header_len;



Just a question about this part (you don't really need to change it - I am 
just interested). Why did you move this MTU check to such a late position in 
the code?

> -       hardif_mtu = READ_ONCE(hard_iface->net_dev->mtu);
> -       required_mtu = READ_ONCE(mesh_iface->mtu) + max_header_len;
> +       ASSERT_RTNL();
>  
> -       if (hardif_mtu < ETH_MIN_MTU + max_header_len)
> +       if (!batadv_is_valid_iface(net_dev))
>                 return -EINVAL;
>  
[...]
> +       hard_iface = kzalloc(sizeof(*hard_iface), GFP_ATOMIC);
> +       if (!hard_iface)
> +               return -ENOMEM;
> +
> +       netdev_hold(net_dev, &hard_iface->dev_tracker, GFP_ATOMIC);
> +       hard_iface->net_dev = net_dev;
[...]
> +       hardif_mtu = READ_ONCE(hard_iface->net_dev->mtu);
> +       required_mtu = READ_ONCE(mesh_iface->mtu) + max_header_len;
> +
> +       if (hardif_mtu < ETH_MIN_MTU + max_header_len) {
> +               ret = -EINVAL;
> +               goto err_put;
> +       }

It made the error handling more complicated. And at the moment, I don't see 
the reason. For me, It would have been been more logical to just a a minimal 
invasive change like:

> -       hardif_mtu = READ_ONCE(hard_iface->net_dev->mtu);
> +       hardif_mtu = READ_ONCE(net_dev->mtu);



Thanks,
	Sven

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

  reply	other threads:[~2025-05-31  9:17 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-19 20:46 [PATCH batadv 1/5] batman-adv: store hard_iface as iflink private data Matthias Schiffer
2025-05-19 20:46 ` [PATCH batadv 2/5] batman-adv: only create hardif while a netdev is part of a mesh Matthias Schiffer
2025-05-31  9:16   ` Sven Eckelmann [this message]
2025-05-31  9:21     ` Sven Eckelmann
2025-05-31  9:52   ` Sven Eckelmann
2026-05-10 13:59     ` Sven Eckelmann
2025-05-19 20:46 ` [PATCH batadv 3/5] batman-adv: remove BATADV_IF_NOT_IN_USE hardif state Matthias Schiffer
2025-05-31  9:18   ` Sven Eckelmann
2025-05-19 20:46 ` [PATCH batadv 4/5] batman-adv: remove global hardif list Matthias Schiffer
2025-05-31  9:56   ` Sven Eckelmann
2025-06-01  9:26     ` Matthias Schiffer
2025-06-01 13:10       ` Sven Eckelmann
2025-06-01 13:36         ` Sven Eckelmann
2026-05-10  7:30   ` Sven Eckelmann
2025-05-19 20:46 ` [PATCH batadv 5/5] batman-adv: move hardif generation counter into batadv_priv Matthias Schiffer
2025-05-31  9:59   ` Sven Eckelmann
2025-05-31  8:31 ` [PATCH batadv 1/5] batman-adv: store hard_iface as iflink private data Sven Eckelmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7760123.MhkbZ0Pkbq@sven-desktop \
    --to=sven@narfation.org \
    --cc=antonio@mandelbit.com \
    --cc=b.a.t.m.a.n@lists.open-mesh.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marek.lindner@mailbox.org \
    --cc=mschiffer@universe-factory.net \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=sw@simonwunderlich.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.