All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sevinj Aghayeva <sevinj.aghayeva@gmail.com>
To: Nikolay Aleksandrov <razor@blackwall.org>
Cc: aroulin@nvidia.com, netdev@vger.kernel.org,
	bridge@lists.linux-foundation.org, linux-kernel@vger.kernel.org,
	sbrivio@redhat.com, Eric Dumazet <edumazet@google.com>,
	roopa@nvidia.com, Jakub Kicinski <kuba@kernel.org>,
	Paolo Abeni <pabeni@redhat.com>,
	"David S. Miller" <davem@davemloft.net>
Subject: Re: [Bridge] [PATCH RFC net-next 0/3] net: vlan: fix bridge binding behavior and add selftests
Date: Mon, 22 Aug 2022 19:18:52 -0400	[thread overview]
Message-ID: <CAMWRUK4J_-siQTrObifPvfLE4CEXAYme6+6JqpR3+qsr5E0-kQ@mail.gmail.com> (raw)
In-Reply-To: <601ac27e-b1b1-43c0-34fd-15cdc2224d85@blackwall.org>

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

On Mon, Aug 22, 2022 at 4:01 AM Nikolay Aleksandrov <razor@blackwall.org>
wrote:

> On 20/08/2022 14:33, Sevinj Aghayeva wrote:
> > On Thu, Aug 18, 2022 at 8:00 AM Nikolay Aleksandrov <razor@blackwall.org>
> wrote:
> >>
> >> On 18/08/2022 14:50, Sevinj Aghayeva wrote:
> [snip]
> >>
> >> Hi,
> >> Handling all vlan device-related changes in br_vlan_device_event()
> sounds good to me.
> >> Please add it to br_vlan.c.
> >
> > Hi Nik,
> >
> > Can you please review this diff before I make it into a proper patchset?
> Thanks!
> >
>
> Hi,
> A few comments inline below, but in general when you prepare the rfc
> commit please
> explain the motivation in detail why this way was chosen and a new
> notification type
> is needed (e.g. why not use NETDEV_CHANGEINFODATA or extend NETDEV_CHANGE).
> As I mentioned earlier it'd be nice to get feedback from others about
> adding this
> new notification, so they should know the "why" in detail.
>

Sure, I will do that in the RFC patchset, but first I want to make sure I
got the details right before making the RFC patchset. Thanks for the
feedback. Please see inline.

>
> > diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
> > index 2563d30736e9..0ce3da42325e 100644
> > --- a/include/linux/netdevice.h
> > +++ b/include/linux/netdevice.h
> > @@ -2762,6 +2762,7 @@ enum netdev_cmd {
> >   NETDEV_UNREGISTER,
> >   NETDEV_CHANGEMTU, /* notify after mtu change happened */
> >   NETDEV_CHANGEADDR, /* notify after the address change */
> > + NETDEV_CHANGE_DETAILS,
> >   NETDEV_PRE_CHANGEADDR, /* notify before the address change */
> >   NETDEV_GOING_DOWN,
> >   NETDEV_CHANGENAME,
> > @@ -2837,6 +2838,13 @@ struct netdev_notifier_changelowerstate_info {
> >   void *lower_state_info; /* is lower dev state */
> >  };
> >
> > +struct netdev_notifier_change_details_info {
> > + struct netdev_notifier_info info; /* must be first */
> > + union {
> > + bool bridge_binding;
>
> this should be in a vlan-specific structure, defined in if_vlan.h
> every other link type which wants to use the notification would define its
> own struct type
>

Okay, will move it there.


>
> > + } details;
> > +};
> > +
> >  struct netdev_notifier_pre_changeaddr_info {
> >   struct netdev_notifier_info info; /* must be first */
> >   const unsigned char *dev_addr;
> > @@ -3836,6 +3844,8 @@ int __dev_set_mtu(struct net_device *, int);
> >  int dev_set_mtu(struct net_device *, int);
> >  int dev_pre_changeaddr_notify(struct net_device *dev, const char *addr,
> >         struct netlink_ext_ack *extack);
> > +int dev_change_details_notify(struct net_device *dev, bool
> bridge_binding,
> > +       struct netlink_ext_ack *extack);
>
> this helper is not needed


> >  int dev_set_mac_address(struct net_device *dev, struct sockaddr *sa,
> >   struct netlink_ext_ack *extack);
> >  int dev_set_mac_address_user(struct net_device *dev, struct sockaddr
> *sa,
> > diff --git a/net/8021q/vlan.h b/net/8021q/vlan.h
> > index 5eaf38875554..71947cdcfaaa 100644
> > --- a/net/8021q/vlan.h
> > +++ b/net/8021q/vlan.h
> > @@ -130,7 +130,7 @@ void vlan_dev_set_ingress_priority(const struct
> > net_device *dev,
> >  int vlan_dev_set_egress_priority(const struct net_device *dev,
> >   u32 skb_prio, u16 vlan_prio);
> >  void vlan_dev_free_egress_priority(const struct net_device *dev);
> > -int vlan_dev_change_flags(const struct net_device *dev, u32 flag, u32
> mask);
> > +int vlan_dev_change_flags(struct net_device *dev, u32 flag, u32 mask);
> >  void vlan_dev_get_realdev_name(const struct net_device *dev, char
> *result,
> >          size_t size);
> >
> > diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c
> > index 839f2020b015..489baa8435de 100644
> > --- a/net/8021q/vlan_dev.c
> > +++ b/net/8021q/vlan_dev.c
> > @@ -211,7 +211,7 @@ int vlan_dev_set_egress_priority(const struct
> > net_device *dev,
> >  /* Flags are defined in the vlan_flags enum in
> >   * include/uapi/linux/if_vlan.h file.
> >   */
> > -int vlan_dev_change_flags(const struct net_device *dev, u32 flags, u32
> mask)
> > +int vlan_dev_change_flags(struct net_device *dev, u32 flags, u32 mask)
>
> please don't remove the const, this function shouldn't change dev's struct
>

I tried not to remove const, but it seems impossible because
call_netdevice_notifiers_info that we eventually call from
vlan_dev_change_flags takes a non-const struct info that has a dev field
being set from the const vlan_dev_change_flags.


>
> >  {
> >   struct vlan_dev_priv *vlan = vlan_dev_priv(dev);
> >   u32 old_flags = vlan->flags;
> > @@ -223,19 +223,29 @@ int vlan_dev_change_flags(const struct
> > net_device *dev, u32 flags, u32 mask)
> >
> >   vlan->flags = (old_flags & ~mask) | (flags & mask);
> >
> > - if (netif_running(dev) && (vlan->flags ^ old_flags) & VLAN_FLAG_GVRP) {
> > + if (!netif_running(dev))
> > + return 0;
> > +
> > + if ((vlan->flags ^ old_flags) & VLAN_FLAG_GVRP) {
> >   if (vlan->flags & VLAN_FLAG_GVRP)
> >   vlan_gvrp_request_join(dev);
> >   else
> >   vlan_gvrp_request_leave(dev);
> >   }
> >
> > - if (netif_running(dev) && (vlan->flags ^ old_flags) & VLAN_FLAG_MVRP) {
> > + if ((vlan->flags ^ old_flags) & VLAN_FLAG_MVRP) {
> >   if (vlan->flags & VLAN_FLAG_MVRP)
> >   vlan_mvrp_request_join(dev);
> >   else
> >   vlan_mvrp_request_leave(dev);
> >   }
> > +
> > + if ((vlan->flags ^ old_flags) & VLAN_FLAG_BRIDGE_BINDING &&
> > +     netif_is_bridge_master(vlan->real_dev)) {
> > + dev_change_details_notify(dev,
> > +     !!(vlan->flags & VLAN_FLAG_BRIDGE_BINDING), NULL);
>
> this helper is not needed, just fill in the details here and send the
> notification
>
>
Okay, in that case I will need to export call_netdevice_notifiers_info so
that I can call it from here.

> + }
> > +
> >   return 0;
> >  }
> >
> > diff --git a/net/bridge/br.c b/net/bridge/br.c
> > index 96e91d69a9a8..62e939c6a3f0 100644
> > --- a/net/bridge/br.c
> > +++ b/net/bridge/br.c
> > @@ -51,6 +51,11 @@ static int br_device_event(struct notifier_block
> > *unused, unsigned long event, v
> >   }
> >   }
> >
> > + if (is_vlan_dev(dev)) {
> > + br_vlan_device_event(dev, event, ptr);
> > + return NOTIFY_DONE;
> > + }
> > +
> >   /* not a port of a bridge */
> >   p = br_port_get_rtnl(dev);
> >   if (!p)
> > diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h
> > index 06e5f6faa431..a9a08e49c76c 100644
> > --- a/net/bridge/br_private.h
> > +++ b/net/bridge/br_private.h
> > @@ -1470,6 +1470,8 @@ void br_vlan_get_stats(const struct
> net_bridge_vlan *v,
> >  void br_vlan_port_event(struct net_bridge_port *p, unsigned long event);
> >  int br_vlan_bridge_event(struct net_device *dev, unsigned long event,
> >   void *ptr);
> > +void br_vlan_device_event(struct net_device *dev, unsigned long event,
> > +   void *ptr);
> >  void br_vlan_rtnl_init(void);
> >  void br_vlan_rtnl_uninit(void);
> >  void br_vlan_notify(const struct net_bridge *br,
> > @@ -1701,6 +1703,11 @@ static inline int br_vlan_bridge_event(struct
> > net_device *dev,
> >   return 0;
> >  }
> >
> > +static void br_vlan_device_event(struct net_device *dev,
> > + unsigned long event, void *ptr)
> > +{
> > +}
> > +
> >  static inline void br_vlan_rtnl_init(void)
> >  {
> >  }
> > diff --git a/net/bridge/br_vlan.c b/net/bridge/br_vlan.c
> > index 0f5e75ccac79..70a9950df175 100644
> > --- a/net/bridge/br_vlan.c
> > +++ b/net/bridge/br_vlan.c
> > @@ -1768,6 +1768,20 @@ void br_vlan_port_event(struct net_bridge_port
> > *p, unsigned long event)
> >   }
> >  }
> >
> > +void br_vlan_device_event(struct net_device *dev, unsigned long
> > event, void *ptr)
> > +{
> > + struct netdev_notifier_change_details_info *info;
> > + struct net_device *br_dev;
> > +
> > + switch (event) {
> > + case NETDEV_CHANGE_DETAILS:
> > + info = ptr;
> > + br_dev = vlan_dev_priv(dev)->real_dev;
>
> you're not guaranteed to have a bridge device as its real_dev, so you
> should
> validate that the vlan's real dev is a bridge
>

Okay, will do.


>
> > + br_vlan_upper_change(br_dev, dev, info->details.bridge_binding);
> > + break;
> > + }
> > +}
> > +
> >  static bool br_vlan_stats_fill(struct sk_buff *skb,
> >          const struct net_bridge_vlan *v)
> >  {
> > diff --git a/net/core/dev.c b/net/core/dev.c
> > index 30a1603a7225..dcdbc625585d 100644
> > --- a/net/core/dev.c
> > +++ b/net/core/dev.c
> > @@ -1624,7 +1624,7 @@ const char *netdev_cmd_to_name(enum netdev_cmd cmd)
> >   N(POST_INIT) N(RELEASE) N(NOTIFY_PEERS) N(JOIN) N(CHANGEUPPER)
> >   N(RESEND_IGMP) N(PRECHANGEMTU) N(CHANGEINFODATA) N(BONDING_INFO)
> >   N(PRECHANGEUPPER) N(CHANGELOWERSTATE) N(UDP_TUNNEL_PUSH_INFO)
> > - N(UDP_TUNNEL_DROP_INFO) N(CHANGE_TX_QUEUE_LEN)
> > + N(UDP_TUNNEL_DROP_INFO) N(CHANGE_TX_QUEUE_LEN) N(CHANGE_DETAILS)
> >   N(CVLAN_FILTER_PUSH_INFO) N(CVLAN_FILTER_DROP_INFO)
> >   N(SVLAN_FILTER_PUSH_INFO) N(SVLAN_FILTER_DROP_INFO)
> >   N(PRE_CHANGEADDR) N(OFFLOAD_XSTATS_ENABLE) N(OFFLOAD_XSTATS_DISABLE)
> > @@ -8767,6 +8767,27 @@ int dev_pre_changeaddr_notify(struct net_device
> > *dev, const char *addr,
> >  }
> >  EXPORT_SYMBOL(dev_pre_changeaddr_notify);
> >
> > +/**
> > + * dev_change_details_notify - Call NETDEV_PRE_CHANGE_DETAILS.
> > + * @dev: device
> > + * @bridge_binding: bridge binding setting
> > + * @extack: netlink extended ack
> > + */
> > +int dev_change_details_notify(struct net_device *dev, bool
> bridge_binding,
> > +       struct netlink_ext_ack *extack)
> > +{
> > + struct netdev_notifier_change_details_info info = {
> > + .info.dev = dev,
> > + .info.extack = extack,
> > + .details.bridge_binding = bridge_binding,
> > + };
> > + int rc;
> > +
> > + rc = call_netdevice_notifiers_info(NETDEV_CHANGE_DETAILS, &info.info);
> > + return notifier_to_errno(rc);
> > +}
> > +EXPORT_SYMBOL(dev_change_details_notify);
> > +
>
> this helper is unnecessary, just fill in the struct at the caller site and
> send the notification directly
>

Okay, will remove it.

Thanks for the review! I will send the updated patch soon.

>
> >  /**
> >   * dev_set_mac_address - Change Media Access Control Address
> >   * @dev: device
> >
> >
> >>
> >> Thanks,
> >>  Nik
> >>
> >>
>
> Cheers,
>  Nik
>
>
>

-- 

Sevinj.Aghayeva

[-- Attachment #2: Type: text/html, Size: 13731 bytes --]

  reply	other threads:[~2022-08-22 23:18 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-10  3:11 [PATCH RFC net-next 0/3] net: vlan: fix bridge binding behavior and add selftests Sevinj Aghayeva
2022-08-10  3:11 ` [Bridge] " Sevinj Aghayeva
2022-08-10  3:11 ` [PATCH RFC net-next 1/3] net: core: export call_netdevice_notifiers_info Sevinj Aghayeva
2022-08-10  3:11   ` [Bridge] " Sevinj Aghayeva
2022-08-10  3:11 ` [PATCH RFC net-next 2/3] net: 8021q: fix bridge binding behavior for vlan interfaces Sevinj Aghayeva
2022-08-10  3:11   ` [Bridge] " Sevinj Aghayeva
2022-08-10  3:11 ` [PATCH RFC net-next 3/3] selftests: net: tests for bridge binding behavior Sevinj Aghayeva
2022-08-10  3:11   ` [Bridge] " Sevinj Aghayeva
2022-08-10  8:54 ` [PATCH RFC net-next 0/3] net: vlan: fix bridge binding behavior and add selftests Nikolay Aleksandrov
2022-08-10  8:54   ` [Bridge] " Nikolay Aleksandrov
2022-08-10 14:42   ` Sevinj Aghayeva
2022-08-10 14:50     ` Nikolay Aleksandrov
2022-08-10 14:50       ` [Bridge] " Nikolay Aleksandrov
2022-08-10 15:00       ` Sevinj Aghayeva
2022-08-10 15:00         ` [Bridge] " Sevinj Aghayeva
2022-08-10 15:10         ` Nikolay Aleksandrov
2022-08-10 15:10           ` [Bridge] " Nikolay Aleksandrov
2022-08-10 15:21           ` Sevinj Aghayeva
2022-08-10 15:21             ` [Bridge] " Sevinj Aghayeva
2022-08-12 15:30   ` Sevinj Aghayeva
2022-08-12 15:30     ` [Bridge] " Sevinj Aghayeva
2022-08-14  7:38     ` Nikolay Aleksandrov
2022-08-14  7:38       ` [Bridge] " Nikolay Aleksandrov
2022-08-18 11:50       ` Sevinj Aghayeva
2022-08-18 11:50         ` [Bridge] " Sevinj Aghayeva
2022-08-18 12:00         ` Nikolay Aleksandrov
2022-08-18 12:00           ` [Bridge] " Nikolay Aleksandrov
2022-08-20 11:33           ` Sevinj Aghayeva
2022-08-20 11:33             ` [Bridge] " Sevinj Aghayeva
2022-08-22  8:01             ` Nikolay Aleksandrov
2022-08-22  8:01               ` [Bridge] " Nikolay Aleksandrov
2022-08-22 23:18               ` Sevinj Aghayeva [this message]
2022-08-29 20:22                 ` Sevinj Aghayeva
2022-08-31 10:16                   ` Nikolay Aleksandrov
2022-08-31 10:16                     ` [Bridge] " Nikolay Aleksandrov

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=CAMWRUK4J_-siQTrObifPvfLE4CEXAYme6+6JqpR3+qsr5E0-kQ@mail.gmail.com \
    --to=sevinj.aghayeva@gmail.com \
    --cc=aroulin@nvidia.com \
    --cc=bridge@lists.linux-foundation.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=razor@blackwall.org \
    --cc=roopa@nvidia.com \
    --cc=sbrivio@redhat.com \
    /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.