]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
ndo_fdb_del: Add a parameter to report whether notification was sent
authorPetr Machata <petrm@nvidia.com>
Thu, 14 Nov 2024 14:09:54 +0000 (15:09 +0100)
committerJakub Kicinski <kuba@kernel.org>
Sat, 16 Nov 2024 00:39:18 +0000 (16:39 -0800)
In a similar fashion to ndo_fdb_add, which was covered in the previous
patch, add the bool *notified argument to ndo_fdb_del. Callees that send a
notification on their own set the flag to true.

Signed-off-by: Petr Machata <petrm@nvidia.com>
Reviewed-by: Amit Cohen <amcohen@nvidia.com>
Reviewed-by: Nikolay Aleksandrov <razor@blackwall.org>
Link: https://patch.msgid.link/06b1acf4953ef0a5ed153ef1f32d7292044f2be6.1731589511.git.petrm@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/intel/ice/ice_main.c
drivers/net/ethernet/mscc/ocelot_net.c
drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c
drivers/net/macvlan.c
drivers/net/vxlan/vxlan_core.c
include/linux/netdevice.h
net/bridge/br_fdb.c
net/bridge/br_private.h
net/core/rtnetlink.c

index c875036f654bcf03aff71499b4824ac710e4cedb..b79848fe2a9e3883293f25e2c55b89bb6ac64100 100644 (file)
@@ -6166,12 +6166,14 @@ ice_fdb_add(struct ndmsg *ndm, struct nlattr __always_unused *tb[],
  * @dev: the net device pointer
  * @addr: the MAC address entry being added
  * @vid: VLAN ID
+ * @notified: whether notification was emitted
  * @extack: netlink extended ack
  */
 static int
 ice_fdb_del(struct ndmsg *ndm, __always_unused struct nlattr *tb[],
            struct net_device *dev, const unsigned char *addr,
-           __always_unused u16 vid, struct netlink_ext_ack *extack)
+           __always_unused u16 vid, bool *notified,
+           struct netlink_ext_ack *extack)
 {
        int err;
 
index 4f15ba2c55257daf947eed40641c4ce6ae9b025b..558e03301aa8ed89e15c5f37d148a287feaf0018 100644 (file)
@@ -744,7 +744,7 @@ static int ocelot_port_fdb_add(struct ndmsg *ndm, struct nlattr *tb[],
 static int ocelot_port_fdb_del(struct ndmsg *ndm, struct nlattr *tb[],
                               struct net_device *dev,
                               const unsigned char *addr, u16 vid,
-                              struct netlink_ext_ack *extack)
+                              bool *notified, struct netlink_ext_ack *extack)
 {
        struct ocelot_port_private *priv = netdev_priv(dev);
        struct ocelot_port *ocelot_port = &priv->port;
index 2484cebd97d4b1b3b78235e29fa7654bf25e8267..eb69121df726cbed32a60c64269e06a0b6a844e3 100644 (file)
@@ -367,7 +367,7 @@ static int qlcnic_set_mac(struct net_device *netdev, void *p)
 
 static int qlcnic_fdb_del(struct ndmsg *ndm, struct nlattr *tb[],
                        struct net_device *netdev,
-                       const unsigned char *addr, u16 vid,
+                       const unsigned char *addr, u16 vid, bool *notified,
                        struct netlink_ext_ack *extack)
 {
        struct qlcnic_adapter *adapter = netdev_priv(netdev);
index dfb462e6324816c0323b36cd016af89072078fee..fed4fe2a4748f8f6b69a094dbe0362752da4699b 100644 (file)
@@ -1049,7 +1049,7 @@ static int macvlan_fdb_add(struct ndmsg *ndm, struct nlattr *tb[],
 
 static int macvlan_fdb_del(struct ndmsg *ndm, struct nlattr *tb[],
                           struct net_device *dev,
-                          const unsigned char *addr, u16 vid,
+                          const unsigned char *addr, u16 vid, bool *notified,
                           struct netlink_ext_ack *extack)
 {
        struct macvlan_dev *vlan = netdev_priv(dev);
index 22f17c5c7549fab3d829cf8e6eafcf7145aee6ae..9ea63059d52d75d8c4771fe55a81f6be9b213a5d 100644 (file)
@@ -1319,7 +1319,7 @@ out:
 /* Delete entry (via netlink) */
 static int vxlan_fdb_delete(struct ndmsg *ndm, struct nlattr *tb[],
                            struct net_device *dev,
-                           const unsigned char *addr, u16 vid,
+                           const unsigned char *addr, u16 vid, bool *notified,
                            struct netlink_ext_ack *extack)
 {
        struct vxlan_dev *vxlan = netdev_priv(dev);
@@ -1341,6 +1341,9 @@ static int vxlan_fdb_delete(struct ndmsg *ndm, struct nlattr *tb[],
                                 true);
        spin_unlock_bh(&vxlan->hash_lock[hash_index]);
 
+       if (!err)
+               *notified = true;
+
        return err;
 }
 
index 6a7fd191e1ee91b492cad5e8b1d405b542f77b21..ecc686409161ea8684926434a9dcb233e065dd6c 100644 (file)
@@ -1254,8 +1254,11 @@ struct netdev_net_notifier {
  *     notification(s). Otherwise core will send a generic one.
  * int (*ndo_fdb_del)(struct ndmsg *ndm, struct nlattr *tb[],
  *                   struct net_device *dev,
- *                   const unsigned char *addr, u16 vid)
+ *                   const unsigned char *addr, u16 vid
+ *                   bool *notified, struct netlink_ext_ack *extack);
  *     Deletes the FDB entry from dev corresponding to addr.
+ *     Callee shall set *notified to true if it sent any appropriate
+ *     notification(s). Otherwise core will send a generic one.
  * int (*ndo_fdb_del_bulk)(struct nlmsghdr *nlh, struct net_device *dev,
  *                        struct netlink_ext_ack *extack);
  * int (*ndo_fdb_dump)(struct sk_buff *skb, struct netlink_callback *cb,
@@ -1533,7 +1536,9 @@ struct net_device_ops {
                                               struct nlattr *tb[],
                                               struct net_device *dev,
                                               const unsigned char *addr,
-                                              u16 vid, struct netlink_ext_ack *extack);
+                                              u16 vid,
+                                              bool *notified,
+                                              struct netlink_ext_ack *extack);
        int                     (*ndo_fdb_del_bulk)(struct nlmsghdr *nlh,
                                                    struct net_device *dev,
                                                    struct netlink_ext_ack *extack);
index 5f29958f3dddcd213543b5e5bb4fc345e118981b..82bac2426631bcea63ea834e72f074fa2eaf0cee 100644 (file)
@@ -1287,7 +1287,7 @@ out:
 
 static int fdb_delete_by_addr_and_port(struct net_bridge *br,
                                       const struct net_bridge_port *p,
-                                      const u8 *addr, u16 vlan)
+                                      const u8 *addr, u16 vlan, bool *notified)
 {
        struct net_bridge_fdb_entry *fdb;
 
@@ -1296,18 +1296,19 @@ static int fdb_delete_by_addr_and_port(struct net_bridge *br,
                return -ENOENT;
 
        fdb_delete(br, fdb, true);
+       *notified = true;
 
        return 0;
 }
 
 static int __br_fdb_delete(struct net_bridge *br,
                           const struct net_bridge_port *p,
-                          const unsigned char *addr, u16 vid)
+                          const unsigned char *addr, u16 vid, bool *notified)
 {
        int err;
 
        spin_lock_bh(&br->hash_lock);
-       err = fdb_delete_by_addr_and_port(br, p, addr, vid);
+       err = fdb_delete_by_addr_and_port(br, p, addr, vid, notified);
        spin_unlock_bh(&br->hash_lock);
 
        return err;
@@ -1316,7 +1317,7 @@ static int __br_fdb_delete(struct net_bridge *br,
 /* Remove neighbor entry with RTM_DELNEIGH */
 int br_fdb_delete(struct ndmsg *ndm, struct nlattr *tb[],
                  struct net_device *dev,
-                 const unsigned char *addr, u16 vid,
+                 const unsigned char *addr, u16 vid, bool *notified,
                  struct netlink_ext_ack *extack)
 {
        struct net_bridge_vlan_group *vg;
@@ -1339,19 +1340,19 @@ int br_fdb_delete(struct ndmsg *ndm, struct nlattr *tb[],
        }
 
        if (vid) {
-               err = __br_fdb_delete(br, p, addr, vid);
+               err = __br_fdb_delete(br, p, addr, vid, notified);
        } else {
                struct net_bridge_vlan *v;
 
                err = -ENOENT;
-               err &= __br_fdb_delete(br, p, addr, 0);
+               err &= __br_fdb_delete(br, p, addr, 0, notified);
                if (!vg || !vg->num_vlans)
                        return err;
 
                list_for_each_entry(v, &vg->vlan_list, vlist) {
                        if (!br_vlan_should_use(v))
                                continue;
-                       err &= __br_fdb_delete(br, p, addr, v->vid);
+                       err &= __br_fdb_delete(br, p, addr, v->vid, notified);
                }
        }
 
index ebfc59049ec1963ead896d94e678841d11a5f3c4..9853cfbb9d144653ad23ade0162a5ada6f57591f 100644 (file)
@@ -853,7 +853,7 @@ void br_fdb_update(struct net_bridge *br, struct net_bridge_port *source,
 
 int br_fdb_delete(struct ndmsg *ndm, struct nlattr *tb[],
                  struct net_device *dev, const unsigned char *addr, u16 vid,
-                 struct netlink_ext_ack *extack);
+                 bool *notified, struct netlink_ext_ack *extack);
 int br_fdb_delete_bulk(struct nlmsghdr *nlh, struct net_device *dev,
                       struct netlink_ext_ack *extack);
 int br_fdb_add(struct ndmsg *nlh, struct nlattr *tb[], struct net_device *dev,
index f31b2436cde500c50369b38256a4683494dbf9f1..dd142f444659d9a5da084bddb26736b1602cc2cb 100644 (file)
@@ -4701,11 +4701,13 @@ static int rtnl_fdb_del(struct sk_buff *skb, struct nlmsghdr *nlh,
        if ((!ndm->ndm_flags || ndm->ndm_flags & NTF_MASTER) &&
            netif_is_bridge_port(dev)) {
                struct net_device *br_dev = netdev_master_upper_dev_get(dev);
+               bool notified = false;
 
                ops = br_dev->netdev_ops;
                if (!del_bulk) {
                        if (ops->ndo_fdb_del)
-                               err = ops->ndo_fdb_del(ndm, tb, dev, addr, vid, extack);
+                               err = ops->ndo_fdb_del(ndm, tb, dev, addr, vid,
+                                                      &notified, extack);
                } else {
                        if (ops->ndo_fdb_del_bulk)
                                err = ops->ndo_fdb_del_bulk(nlh, dev, extack);
@@ -4719,10 +4721,13 @@ static int rtnl_fdb_del(struct sk_buff *skb, struct nlmsghdr *nlh,
 
        /* Embedded bridge, macvlan, and any other device support */
        if (ndm->ndm_flags & NTF_SELF) {
+               bool notified = false;
+
                ops = dev->netdev_ops;
                if (!del_bulk) {
                        if (ops->ndo_fdb_del)
-                               err = ops->ndo_fdb_del(ndm, tb, dev, addr, vid, extack);
+                               err = ops->ndo_fdb_del(ndm, tb, dev, addr, vid,
+                                                      &notified, extack);
                        else
                                err = ndo_dflt_fdb_del(ndm, tb, dev, addr, vid);
                } else {
@@ -4733,7 +4738,7 @@ static int rtnl_fdb_del(struct sk_buff *skb, struct nlmsghdr *nlh,
                }
 
                if (!err) {
-                       if (!del_bulk)
+                       if (!del_bulk && !notified)
                                rtnl_fdb_notify(dev, addr, vid, RTM_DELNEIGH,
                                                ndm->ndm_state);
                        ndm->ndm_flags &= ~NTF_SELF;