vxlan: Allow vetoing FDB operations
Subsystems (12)
cover vxlan: Allow vetoing FDB operations
mlxsw does not implement handling of the more advanced types of VXLAN FDB entries. In order to provide visibility to users, it is important to be able to reject such FDB entries, ideally with an explanation passed in extended ack. This patch set implements this.
In patches #1-#4, vxlan is gradually transformed to support vetoing of FDB entries added (or modified) through vxlan_fdb_update(), and the default FDB entry added in __vxlan_dev_create().
Patches #5-#7 deal with vxlan_changelink(). The existing code recognizes that vxlan_fdb_update() may fail, but doesn't attempt to keep things intact if it does. These patches change the function in several steps to gracefully handle vetoes (or other failures).
Then in patches #8-#11, extack arguments are added, respectively, to ndo_fdb_add(), mlxsw's mlxsw_sp_nve_ops.fdb_replay, the functions that connect to the VXLAN vetoing code, and call_switchdev_notifiers(). Note that call_switchdev_blocking_notifiers() already does support extack.
Finally in patch #12, mlxsw is extended to add extack messages to rejected FDB entries. In patch #13, the functionality is tested.
Petr Machata (13):
vxlan: Move up vxlan_fdb_free(), vxlan_fdb_destroy()
vxlan: Split vxlan_fdb_update() in two
vxlan: Have vxlan_fdb_replace() save original rdst value
vxlan: Allow vetoing of FDB notifications
vxlan: changelink: Inline vxlan_dev_configure()
vxlan: changelink: Postpone vxlan_config_apply()
vxlan: changelink: Delete remote after update
net: Add extack argument to ndo_fdb_add()
mlxsw: Add extack to mlxsw_sp_nve_ops.fdb_replay
vxlan: Add extack to switchdev operations
switchdev: Add extack argument to call_switchdev_notifiers()
mlxsw: spectrum: Add extack messages to VXLAN FDB rejection
selftests: mlxsw: Test veto of unsupported VXLAN FDBs
Documentation/networking/switchdev.txt | 2 +- drivers/net/ethernet/intel/i40e/i40e_main.c | 3 +- drivers/net/ethernet/intel/ice/ice_main.c | 3 +- drivers/net/ethernet/intel/igb/igb_main.c | 3 +- drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 3 +- drivers/net/ethernet/mellanox/mlxsw/spectrum_nve.c | 6 +- drivers/net/ethernet/mellanox/mlxsw/spectrum_nve.h | 3 +- .../ethernet/mellanox/mlxsw/spectrum_nve_vxlan.c | 6 +- .../net/ethernet/mellanox/mlxsw/spectrum_router.c | 6 +- .../ethernet/mellanox/mlxsw/spectrum_switchdev.c | 37 ++- drivers/net/ethernet/mscc/ocelot.c | 3 +- drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c | 3 +- drivers/net/ethernet/rocker/rocker_main.c | 2 +- drivers/net/ethernet/rocker/rocker_ofdpa.c | 4 +- drivers/net/macvlan.c | 3 +- drivers/net/vxlan.c | 352 +++++++++++++-------- include/linux/netdevice.h | 6 +- include/net/switchdev.h | 6 +- include/net/vxlan.h | 6 +- net/bridge/br_fdb.c | 3 +- net/bridge/br_private.h | 3 +- net/bridge/br_switchdev.c | 2 +- net/core/rtnetlink.c | 5 +- net/dsa/dsa_priv.h | 3 +- net/dsa/slave.c | 5 +- net/switchdev/switchdev.c | 5 +- .../selftests/drivers/net/mlxsw/vxlan_fdb_veto.sh | 126 ++++++++ 27 files changed, 421 insertions(+), 188 deletions(-) create mode 100755 tools/testing/selftests/drivers/net/mlxsw/vxlan_fdb_veto.sh
Signature · 1 line
2.4.11
PATCH 1/13 vxlan: Move up vxlan_fdb_free(), vxlan_fdb_destroy()
These functions will be needed for rollbacks of vetoed FDB entries. Move them up so that they are visible at their intended point of use.
--- drivers/net/vxlan.c | 59 ++++++++++++++++++++++++++--------------------------- 1 file changed, 29 insertions(+), 30 deletions(-)
drivers/net/vxlan.c +29 -30
@@ -826,6 +826,35 @@ static int vxlan_fdb_create(struct vxlan_dev *vxlan,return 0 ; } +static void vxlan_fdb_free (struct rcu_head *head) +{ + struct vxlan_fdb *f = container_of(head, struct vxlan_fdb, rcu); +struct vxlan_rdst *rd, *nd; + +list_for_each_entry_safe (rd, nd, &f->remotes, list) { +dst_cache_destroy (&rd->dst_cache); +kfree (rd); + } +kfree (f); +} + +static void vxlan_fdb_destroy (struct vxlan_dev *vxlan,struct vxlan_fdb *f, +bool do_notify,bool swdev_notify) +{ +struct vxlan_rdst *rd; + +netdev_dbg (vxlan->dev,"delete %pM\n" , f->eth_addr); + + --vxlan->addrcnt; +if (do_notify) +list_for_each_entry (rd, &f->remotes, list) +vxlan_fdb_notify (vxlan, f, rd,RTM_DELNEIGH , + swdev_notify); + +hlist_del_rcu (&f->hlist); +call_rcu (&f->rcu, vxlan_fdb_free); +} +/* Add new entry to forwarding table -- assumes lock held */ static int vxlan_fdb_update(struct vxlan_dev *vxlan, const u8 *mac, union vxlan_addr *ip,
@@ -912,36 +941,6 @@ static int vxlan_fdb_update(struct vxlan_dev *vxlan,return 0 ; } -static void vxlan_fdb_free (struct rcu_head *head) -{ - struct vxlan_fdb *f = container_of(head, struct vxlan_fdb, rcu); -struct vxlan_rdst *rd, *nd; - -list_for_each_entry_safe (rd, nd, &f->remotes, list) { -dst_cache_destroy (&rd->dst_cache); -kfree (rd); - } -kfree (f); -} - -static void vxlan_fdb_destroy (struct vxlan_dev *vxlan,struct vxlan_fdb *f, -bool do_notify,bool swdev_notify) -{ -struct vxlan_rdst *rd; - -netdev_dbg (vxlan->dev, -"delete %pM\n" , f->eth_addr); - - --vxlan->addrcnt; -if (do_notify) -list_for_each_entry (rd, &f->remotes, list) -vxlan_fdb_notify (vxlan, f, rd,RTM_DELNEIGH , - swdev_notify); - -hlist_del_rcu (&f->hlist); -call_rcu (&f->rcu, vxlan_fdb_free); -} -static void vxlan_dst_free (struct rcu_head *head) { struct vxlan_rdst *rd = container_of(head, struct vxlan_rdst, rcu);
Signature · 1 line
2.4.11
PATCH 2/13 vxlan: Split vxlan_fdb_update() in two
In reply to Petr MachataIn order to make it easier to implement rollbacks after FDB update vetoing, separate the FDB update code to two parts: one that deals with updates of existing FDB entries, and one that creates new entries.
--- drivers/net/vxlan.c | 158 ++++++++++++++++++++++++++++++++-------------------- 1 file changed, 97 insertions(+), 61 deletions(-)
drivers/net/vxlan.c +97 -61
@@ -855,92 +855,128 @@ static void vxlan_fdb_destroy(struct vxlan_dev *vxlan, struct vxlan_fdb *f,call_rcu (&f->rcu, vxlan_fdb_free); } -/* Add new entry to forwarding table -- assumes lock held */ -static int vxlan_fdb_update (struct vxlan_dev *vxlan, -const u8 *mac,union vxlan_addr *ip, -__u16 state,__u16 flags, -__be16 port,__be32 src_vni,__be32 vni, -__u32 ifindex,__u16 ndm_flags, -bool swdev_notify) +static int vxlan_fdb_update_existing (struct vxlan_dev *vxlan, +union vxlan_addr *ip, +__u16 state,__u16 flags, +__be16 port,__be32 vni, +__u32 ifindex,__u16 ndm_flags, +struct vxlan_fdb *f, +bool swdev_notify) {__u16 fdb_flags = (ndm_flags & ~NTF_USE );struct vxlan_rdst *rd =NULL ; -struct vxlan_fdb *f;int notify =0 ;int rc; - f =__vxlan_find_mac (vxlan, mac, src_vni); -if (f) { -if (flags &NLM_F_EXCL ) { -netdev_dbg (vxlan->dev, -"lost race to create %pM\n" , mac); -return -EEXIST ; - } - -/* Do not allow an externally learned entry to take over an -* entry added by the user. -*/ -if (!(fdb_flags &NTF_EXT_LEARNED ) || - !(f->flags &NTF_VXLAN_ADDED_BY_USER )) { -if (f->state != state) { - f->state = state; - f->updated = jiffies; - notify =1 ; - } -if (f->flags != fdb_flags) { - f->flags = fdb_flags; - f->updated = jiffies; - notify =1 ; - } +/* Do not allow an externally learned entry to take over an entry added +* by the user. +*/ +if (!(fdb_flags &NTF_EXT_LEARNED ) || + !(f->flags &NTF_VXLAN_ADDED_BY_USER )) { +if (f->state != state) { + f->state = state; + f->updated = jiffies; + notify =1 ; } - -if ((flags &NLM_F_REPLACE )) { -/* Only change unicasts */ -if (!(is_multicast_ether_addr (f->eth_addr) || -is_zero_ether_addr (f->eth_addr))) { - notify |=vxlan_fdb_replace (f, ip, port, vni, - ifindex); - }else -return -EOPNOTSUPP ; +if (f->flags != fdb_flags) { + f->flags = fdb_flags; + f->updated = jiffies; + notify =1 ; } -if ((flags &NLM_F_APPEND ) && - (is_multicast_ether_addr (f->eth_addr) || -is_zero_ether_addr (f->eth_addr))) { - rc =vxlan_fdb_append (f, ip, port, vni, ifindex, &rd); + } -if (rc <0 ) -return rc; +if ((flags &NLM_F_REPLACE )) { +/* Only change unicasts */ +if (!(is_multicast_ether_addr (f->eth_addr) || +is_zero_ether_addr (f->eth_addr))) { + rc =vxlan_fdb_replace (f, ip, port, vni, + ifindex); notify |= rc; - } - -if (ndm_flags &NTF_USE ) - f->used = jiffies; - }else { -if (!(flags &NLM_F_CREATE )) -return -ENOENT ; - -/* Disallow replace to add a multicast entry */ -if ((flags &NLM_F_REPLACE ) && - (is_multicast_ether_addr (mac) ||is_zero_ether_addr (mac))) + }else {return -EOPNOTSUPP ; + } + } +if ((flags &NLM_F_APPEND ) && + (is_multicast_ether_addr (f->eth_addr) || +is_zero_ether_addr (f->eth_addr))) { + rc =vxlan_fdb_append (f, ip, port, vni, ifindex, &rd); -netdev_dbg (vxlan->dev,"add %pM -> %pIS\n" , mac, ip); - rc =vxlan_fdb_create (vxlan, mac, ip, state, port, src_vni, - vni, ifindex, fdb_flags, &f);if (rc <0 )return rc; - notify =1 ; + notify |= rc; } +if (ndm_flags &NTF_USE ) + f->used = jiffies; +if (notify) {if (rd ==NULL ) rd =first_remote_rtnl (f); +vxlan_fdb_notify (vxlan, f, rd,RTM_NEWNEIGH , swdev_notify); }return 0 ; } +static int vxlan_fdb_update_create (struct vxlan_dev *vxlan, +const u8 *mac,union vxlan_addr *ip, +__u16 state,__u16 flags, +__be16 port,__be32 src_vni,__be32 vni, +__u32 ifindex,__u16 ndm_flags, +bool swdev_notify) +{ +__u16 fdb_flags = (ndm_flags & ~NTF_USE ); +struct vxlan_fdb *f; +int rc; + +/* Disallow replace to add a multicast entry */ +if ((flags &NLM_F_REPLACE ) && + (is_multicast_ether_addr (mac) ||is_zero_ether_addr (mac))) +return -EOPNOTSUPP ; + +netdev_dbg (vxlan->dev,"add %pM -> %pIS\n" , mac, ip); + rc =vxlan_fdb_create (vxlan, mac, ip, state, port, src_vni, + vni, ifindex, fdb_flags, &f); +if (rc <0 ) +return rc; + +vxlan_fdb_notify (vxlan, f,first_remote_rtnl (f),RTM_NEWNEIGH , + swdev_notify); +return 0 ; +} + +/* Add new entry to forwarding table -- assumes lock held */ +static int vxlan_fdb_update (struct vxlan_dev *vxlan, +const u8 *mac,union vxlan_addr *ip, +__u16 state,__u16 flags, +__be16 port,__be32 src_vni,__be32 vni, +__u32 ifindex,__u16 ndm_flags, +bool swdev_notify) +{ +struct vxlan_fdb *f; + + f =__vxlan_find_mac (vxlan, mac, src_vni); +if (f) { +if (flags &NLM_F_EXCL ) { +netdev_dbg (vxlan->dev, +"lost race to create %pM\n" , mac); +return -EEXIST ; + } + +return vxlan_fdb_update_existing (vxlan, ip, state, flags, port, + vni, ifindex, ndm_flags, f, + swdev_notify); + }else { +if (!(flags &NLM_F_CREATE )) +return -ENOENT ; + +return vxlan_fdb_update_create (vxlan, mac, ip, state, flags, + port, src_vni, vni, ifindex, + ndm_flags, swdev_notify); + } +} +static void vxlan_dst_free (struct rcu_head *head) { struct vxlan_rdst *rd = container_of(head, struct vxlan_rdst, rcu);
Signature · 1 line
2.4.11
PATCH 3/13 vxlan: Have vxlan_fdb_replace() save original rdst value
In reply to Petr MachataTo enable rollbacks after vetoed FDB updates, extend vxlan_fdb_replace() to take an additional argument where it should store the original values of a modified rdst. Update the sole caller.
The following patch will make use of the saved value.
--- drivers/net/vxlan.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/vxlan.c +4 -2
@@ -625,7 +625,7 @@ EXPORT_SYMBOL_GPL(vxlan_fdb_clear_offload);/* Replace destination of unicast mac */ static int vxlan_fdb_replace (struct vxlan_fdb *f,union vxlan_addr *ip,__be16 port,__be32 vni, -__u32 ifindex) +__u32 ifindex,struct vxlan_rdst *oldrd) {struct vxlan_rdst *rd;
@@ -637,6 +637,7 @@ static int vxlan_fdb_replace(struct vxlan_fdb *f,if (!rd)return 0 ; + *oldrd = *rd;dst_cache_reset (&rd->dst_cache); rd->remote_ip = *ip; rd->remote_port = port;
@@ -865,6 +866,7 @@ static int vxlan_fdb_update_existing(struct vxlan_dev *vxlan, {__u16 fdb_flags = (ndm_flags & ~NTF_USE );struct vxlan_rdst *rd =NULL ; +struct vxlan_rdst oldrd;int notify =0 ;int rc;
@@ -890,7 +892,7 @@ static int vxlan_fdb_update_existing(struct vxlan_dev *vxlan,if (!(is_multicast_ether_addr (f->eth_addr) ||is_zero_ether_addr (f->eth_addr))) { rc =vxlan_fdb_replace (f, ip, port, vni, - ifindex); + ifindex, &oldrd); notify |= rc; }else {return -EOPNOTSUPP ;
Signature · 1 line
2.4.11
PATCH 4/13 vxlan: Allow vetoing of FDB notifications
In reply to Petr MachataChange vxlan_fdb_switchdev_call_notifiers() to return the result from calling switchdev notifiers. Propagate the error number up the stack.
In vxlan_fdb_update_existing() and vxlan_fdb_update_create() add rollbacks to clean up the work that was done before the veto.
--- drivers/net/vxlan.c | 64 ++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 46 insertions(+), 18 deletions(-)
drivers/net/vxlan.c +46 -18
@@ -375,32 +375,38 @@ static void vxlan_fdb_switchdev_notifier_info(const struct vxlan_dev *vxlan, fdb_info->added_by_user = fdb->flags &NTF_VXLAN_ADDED_BY_USER ; } -static void vxlan_fdb_switchdev_call_notifiers (struct vxlan_dev *vxlan, -struct vxlan_fdb *fdb, -struct vxlan_rdst *rd, -bool adding) +static int vxlan_fdb_switchdev_call_notifiers (struct vxlan_dev *vxlan, +struct vxlan_fdb *fdb, +struct vxlan_rdst *rd, +bool adding) {struct switchdev_notifier_vxlan_fdb_info info;enum switchdev_notifier_type notifier_type; +int ret;if (WARN_ON (!rd)) -return ; +return 0 ; notifier_type = adding ?SWITCHDEV_VXLAN_FDB_ADD_TO_DEVICE :SWITCHDEV_VXLAN_FDB_DEL_TO_DEVICE ;vxlan_fdb_switchdev_notifier_info (vxlan, fdb, rd, &info); -call_switchdev_notifiers (notifier_type, vxlan->dev, - &info.info); + ret =call_switchdev_notifiers (notifier_type, vxlan->dev, + &info.info); +return notifier_to_errno (ret); } -static void vxlan_fdb_notify (struct vxlan_dev *vxlan,struct vxlan_fdb *fdb, -struct vxlan_rdst *rd,int type,bool swdev_notify) +static int vxlan_fdb_notify (struct vxlan_dev *vxlan,struct vxlan_fdb *fdb, +struct vxlan_rdst *rd,int type,bool swdev_notify) { +int err; +if (swdev_notify) {switch (type) {case RTM_NEWNEIGH : -vxlan_fdb_switchdev_call_notifiers (vxlan, fdb, rd, - true); + err =vxlan_fdb_switchdev_call_notifiers (vxlan, fdb, rd, + true); +if (err) +return err;break ;case RTM_DELNEIGH : vxlan_fdb_switchdev_call_notifiers(vxlan, fdb, rd,
@@ -410,6 +416,7 @@ static void vxlan_fdb_notify(struct vxlan_dev *vxlan, struct vxlan_fdb *fdb, }__vxlan_fdb_notify (vxlan, fdb, rd, type); +return 0 ; }static void vxlan_ip_miss (struct net_device *dev,union vxlan_addr *ipa)
@@ -868,7 +875,8 @@ static int vxlan_fdb_update_existing(struct vxlan_dev *vxlan,struct vxlan_rdst *rd =NULL ;struct vxlan_rdst oldrd;int notify =0 ; -int rc; +int rc =0 ; +int err;/* Do not allow an externally learned entry to take over an entry added * by the user.
@@ -915,10 +923,20 @@ static int vxlan_fdb_update_existing(struct vxlan_dev *vxlan,if (rd ==NULL ) rd =first_remote_rtnl (f); -vxlan_fdb_notify (vxlan, f, rd,RTM_NEWNEIGH , swdev_notify); + err =vxlan_fdb_notify (vxlan, f, rd,RTM_NEWNEIGH , + swdev_notify); +if (err) + goto err_notify; }return 0 ; + +err_notify: +if ((flags &NLM_F_REPLACE ) && rc) + *rd = oldrd; +else if ((flags &NLM_F_APPEND ) && rc) +list_del_rcu (&rd->list); +return err; } static int vxlan_fdb_update_create(struct vxlan_dev *vxlan,
@@ -943,9 +961,16 @@ static int vxlan_fdb_update_create(struct vxlan_dev *vxlan,if (rc <0 )return rc; -vxlan_fdb_notify (vxlan, f,first_remote_rtnl (f),RTM_NEWNEIGH , - swdev_notify); + rc =vxlan_fdb_notify (vxlan, f,first_remote_rtnl (f),RTM_NEWNEIGH , + swdev_notify); +if (rc) + goto err_notify; +return 0 ; + +err_notify: +vxlan_fdb_destroy (vxlan, f, false, false); +return rc; }/* Add new entry to forwarding table -- assumes lock held */
@@ -3515,9 +3540,12 @@ static int __vxlan_dev_create(struct net *net, struct net_device *dev, goto errout;/* notify default fdb entry */ -if (f) -vxlan_fdb_notify (vxlan, f,first_remote_rtnl (f),RTM_NEWNEIGH , - true); +if (f) { + err =vxlan_fdb_notify (vxlan, f,first_remote_rtnl (f), +RTM_NEWNEIGH , true); +if (err) + goto errout; + }list_add (&vxlan->next, &vn->vxlan_list);return 0 ;
Signature · 1 line
2.4.11
PATCH 5/13 vxlan: changelink: Inline vxlan_dev_configure()
In reply to Petr MachataThe changelink operation may cause change in remote address, and therefore an FDB update, which can be vetoed. To properly handle vetoing, vxlan_changelink() needs to be gradually updated.
In this patch simply replace vxlan_dev_configure() with the two constituent calls.
--- drivers/net/vxlan.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/net/vxlan.c +5 -1
@@ -3793,6 +3793,7 @@ static int vxlan_changelink(struct net_device *dev, struct nlattr *tb[],struct vxlan_dev *vxlan =netdev_priv (dev);struct vxlan_rdst *dst = &vxlan->default_dst;unsigned long old_age_interval; +struct net_device *lowerdev;struct vxlan_rdst old_dst;struct vxlan_config conf;int err;
@@ -3805,10 +3806,13 @@ static int vxlan_changelink(struct net_device *dev, struct nlattr *tb[], old_age_interval = vxlan->cfg.age_interval;memcpy (&old_dst, dst,sizeof (struct vxlan_rdst )); - err =vxlan_dev_configure (vxlan->net, dev, &conf, true, extack); + err =vxlan_config_validate (vxlan->net, &conf, &lowerdev, + vxlan, extack);if (err)return err; +vxlan_config_apply (dev, &conf, lowerdev, vxlan->net, true); +if (old_age_interval != vxlan->cfg.age_interval)mod_timer (&vxlan->age_timer, jiffies);
Signature · 1 line
2.4.11
PATCH 6/13 vxlan: changelink: Postpone vxlan_config_apply()
In reply to Petr MachataWhen an FDB entry is vetoed, it is necessary to unroll the changes that have already been done. To avoid having to unroll vxlan_config_apply(), postpone the call after the point where the vetoing takes place. Since the call can't fail, it doesn't necessitate any cleanups in the preceding FDB update logic.
Correspondingly, move down the mod_timer() call as well.
References to *dst need to be replaced with references to conf. Additionally, old_dst and old_age_interval are not necessary anymore, and therefore drop them.
--- drivers/net/vxlan.c | 35 ++++++++++++++--------------------- 1 file changed, 14 insertions(+), 21 deletions(-)
drivers/net/vxlan.c +14 -21
@@ -3792,9 +3792,7 @@ static int vxlan_changelink(struct net_device *dev, struct nlattr *tb[], {struct vxlan_dev *vxlan =netdev_priv (dev);struct vxlan_rdst *dst = &vxlan->default_dst; -unsigned long old_age_interval;struct net_device *lowerdev; -struct vxlan_rdst old_dst;struct vxlan_config conf;int err;
@@ -3803,40 +3801,31 @@ static int vxlan_changelink(struct net_device *dev, struct nlattr *tb[],if (err)return err; - old_age_interval = vxlan->cfg.age_interval; -memcpy (&old_dst, dst,sizeof (struct vxlan_rdst )); - err =vxlan_config_validate (vxlan->net, &conf, &lowerdev, vxlan, extack);if (err)return err; -vxlan_config_apply (dev, &conf, lowerdev, vxlan->net, true); - -if (old_age_interval != vxlan->cfg.age_interval) -mod_timer (&vxlan->age_timer, jiffies); -/* handle default dst entry */ -if (!vxlan_addr_equal (&dst->remote_ip, &old_dst.remote_ip)) { +if (!vxlan_addr_equal (&conf.remote_ip, &dst->remote_ip)) {spin_lock_bh (&vxlan->hash_lock); -if (!vxlan_addr_any (&old_dst.remote_ip)) +if (!vxlan_addr_any (&dst->remote_ip))__vxlan_fdb_delete (vxlan, all_zeros_mac, - old_dst.remote_ip, + dst->remote_ip, vxlan->cfg.dst_port, - old_dst.remote_vni, - old_dst.remote_vni, - old_dst.remote_ifindex, + dst->remote_vni, + dst->remote_vni, + dst->remote_ifindex, true); -if (!vxlan_addr_any (&dst->remote_ip)) { +if (!vxlan_addr_any (&conf.remote_ip)) { err =vxlan_fdb_update (vxlan, all_zeros_mac, - &dst->remote_ip, + &conf.remote_ip,NUD_REACHABLE |NUD_PERMANENT ,NLM_F_APPEND |NLM_F_CREATE , vxlan->cfg.dst_port, - dst->remote_vni, - dst->remote_vni, - dst->remote_ifindex, + conf.vni, conf.vni, + conf.remote_ifindex,NTF_SELF , true);if (err) {spin_unlock_bh (&vxlan->hash_lock);
@@ -3846,6 +3835,10 @@ static int vxlan_changelink(struct net_device *dev, struct nlattr *tb[],spin_unlock_bh (&vxlan->hash_lock); } +if (conf.age_interval != vxlan->cfg.age_interval) +mod_timer (&vxlan->age_timer, jiffies); + +vxlan_config_apply (dev, &conf, lowerdev, vxlan->net, true);return 0 ; }
Signature · 1 line
2.4.11
PATCH 7/13 vxlan: changelink: Delete remote after update
In reply to Petr MachataIf a change in remote address prompts a change in a default FDB entry, that change might be vetoed. If that happens, it would then be necessary to reinstate the already-removed default FDB entry corresponding to the previous remote address.
Instead, arrange to have the previous address removed only after the FDB is successfully vetted.
--- drivers/net/vxlan.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-)
drivers/net/vxlan.c +8 -9
@@ -3809,15 +3809,6 @@ static int vxlan_changelink(struct net_device *dev, struct nlattr *tb[],/* handle default dst entry */ if (!vxlan_addr_equal (&conf.remote_ip, &dst->remote_ip)) {spin_lock_bh (&vxlan->hash_lock); -if (!vxlan_addr_any (&dst->remote_ip)) -__vxlan_fdb_delete (vxlan, all_zeros_mac, - dst->remote_ip, - vxlan->cfg.dst_port, - dst->remote_vni, - dst->remote_vni, - dst->remote_ifindex, - true); -if (!vxlan_addr_any (&conf.remote_ip)) { err = vxlan_fdb_update(vxlan, all_zeros_mac, &conf.remote_ip,
@@ -3832,6 +3823,14 @@ static int vxlan_changelink(struct net_device *dev, struct nlattr *tb[],return err; } } +if (!vxlan_addr_any (&dst->remote_ip)) +__vxlan_fdb_delete (vxlan, all_zeros_mac, + dst->remote_ip, + vxlan->cfg.dst_port, + dst->remote_vni, + dst->remote_vni, + dst->remote_ifindex, + true);spin_unlock_bh (&vxlan->hash_lock); }
Signature · 1 line
2.4.11
PATCH 8/13 net: Add extack argument to ndo_fdb_add()
In reply to Petr MachataDrivers may not be able to support certain FDB entries, and an error code is insufficient to give clear hints as to the reasons of rejection.
In order to make it possible to communicate the rejection reason, extend ndo_fdb_add() with an extack argument. Adapt the existing implementations of ndo_fdb_add() to take the parameter (and ignore it). Pass the extack parameter when invoking ndo_fdb_add() from rtnl_fdb_add().
--- drivers/net/ethernet/intel/i40e/i40e_main.c | 3 ++- drivers/net/ethernet/intel/ice/ice_main.c | 3 ++- drivers/net/ethernet/intel/igb/igb_main.c | 3 ++- drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 3 ++- drivers/net/ethernet/mscc/ocelot.c | 3 ++- drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c | 3 ++- drivers/net/macvlan.c | 3 ++- drivers/net/vxlan.c | 3 ++- include/linux/netdevice.h | 6 ++++-- net/bridge/br_fdb.c | 3 ++- net/bridge/br_private.h | 3 ++- net/core/rtnetlink.c | 5 +++-- net/dsa/dsa_priv.h | 3 ++- net/dsa/slave.c | 3 ++- 14 files changed, 31 insertions(+), 16 deletions(-)
drivers/net/ethernet/intel/i40e/i40e_main.c +2 -1
@@ -11644,7 +11644,8 @@ static int i40e_get_phys_port_id(struct net_device *netdev,static int i40e_ndo_fdb_add (struct ndmsg *ndm,struct nlattr *tb[],struct net_device *dev,const unsigned char *addr,u16 vid, -u16 flags) +u16 flags, +struct netlink_ext_ack *extack) {struct i40e_netdev_priv *np =netdev_priv (dev);struct i40e_pf *pf = np->vsi->back;
drivers/net/ethernet/intel/ice/ice_main.c +2 -1
@@ -2438,7 +2438,8 @@ static void ice_set_rx_mode(struct net_device *netdev)*/ static int ice_fdb_add (struct ndmsg *ndm,struct nlattr __always_unused *tb[],struct net_device *dev,const unsigned char *addr, -u16 vid,u16 flags) +u16 vid,u16 flags, +struct netlink_ext_ack *extack) {int err;
drivers/net/ethernet/intel/igb/igb_main.c +2 -1
@@ -2486,7 +2486,8 @@ static int igb_set_features(struct net_device *netdev,static int igb_ndo_fdb_add (struct ndmsg *ndm,struct nlattr *tb[],struct net_device *dev,const unsigned char *addr,u16 vid, -u16 flags) +u16 flags, +struct netlink_ext_ack *extack) {/* guarantee we can provide a unique filter for the unicast address */ if (is_unicast_ether_addr (addr) ||is_link_local_ether_addr (addr)) {
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +2 -1
@@ -9910,7 +9910,8 @@ static void ixgbe_del_udp_tunnel_port(struct net_device *dev,static int ixgbe_ndo_fdb_add (struct ndmsg *ndm,struct nlattr *tb[],struct net_device *dev,const unsigned char *addr,u16 vid, -u16 flags) +u16 flags, +struct netlink_ext_ack *extack) {/* guarantee we can provide a unique filter for the unicast address */ if (is_unicast_ether_addr (addr) ||is_link_local_ether_addr (addr)) {
drivers/net/ethernet/mscc/ocelot.c +2 -1
@@ -721,7 +721,8 @@ static void ocelot_get_stats64(struct net_device *dev,static int ocelot_fdb_add (struct ndmsg *ndm,struct nlattr *tb[],struct net_device *dev,const unsigned char *addr, -u16 vid,u16 flags) +u16 vid,u16 flags, +struct netlink_ext_ack *extack) {struct ocelot_port *port =netdev_priv (dev);struct ocelot *ocelot = port->ocelot;
drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c +2 -1
@@ -396,7 +396,8 @@ static int qlcnic_fdb_del(struct ndmsg *ndm, struct nlattr *tb[],static int qlcnic_fdb_add (struct ndmsg *ndm,struct nlattr *tb[],struct net_device *netdev, -const unsigned char *addr,u16 vid,u16 flags) +const unsigned char *addr,u16 vid,u16 flags, +struct netlink_ext_ack *extack) {struct qlcnic_adapter *adapter =netdev_priv (netdev);int err =0 ;
drivers/net/macvlan.c +2 -1
@@ -963,7 +963,8 @@ static int macvlan_vlan_rx_kill_vid(struct net_device *dev,static int macvlan_fdb_add (struct ndmsg *ndm,struct nlattr *tb[],struct net_device *dev,const unsigned char *addr,u16 vid, -u16 flags) +u16 flags, +struct netlink_ext_ack *extack) {struct macvlan_dev *vlan =netdev_priv (dev);int err = -EINVAL ;
drivers/net/vxlan.c +2 -1
@@ -1087,7 +1087,8 @@ static int vxlan_fdb_parse(struct nlattr *tb[], struct vxlan_dev *vxlan,/* Add static entry (via netlink) */ static int vxlan_fdb_add (struct ndmsg *ndm,struct nlattr *tb[],struct net_device *dev, -const unsigned char *addr,u16 vid,u16 flags) +const unsigned char *addr,u16 vid,u16 flags, +struct netlink_ext_ack *extack) {struct vxlan_dev *vxlan =netdev_priv (dev);/* struct net *net = dev_net(vxlan->dev); */
include/linux/netdevice.h +4 -2
@@ -1152,7 +1152,8 @@ struct dev_ifalias {* * int (*ndo_fdb_add)(struct ndmsg *ndm, struct nlattr *tb[], * struct net_device *dev, -* const unsigned char *addr, u16 vid, u16 flags) +* const unsigned char *addr, u16 vid, u16 flags, +* struct netlink_ext_ack *extack); * Adds an FDB entry to dev for addr. * int (*ndo_fdb_del)(struct ndmsg *ndm, struct nlattr *tb[], * struct net_device *dev,
@@ -1376,7 +1377,8 @@ struct net_device_ops {struct net_device *dev, const unsigned char *addr, u16 vid, - u16 flags); + u16 flags, + struct netlink_ext_ack *extack); int (*ndo_fdb_del)(struct ndmsg *ndm, struct nlattr *tb[], struct net_device *dev,
net/bridge/br_fdb.c +2 -1
@@ -915,7 +915,8 @@ static int __br_fdb_add(struct ndmsg *ndm, struct net_bridge *br,/* Add new permanent fdb entry with RTM_NEWNEIGH */ int br_fdb_add (struct ndmsg *ndm,struct nlattr *tb[],struct net_device *dev, -const unsigned char *addr,u16 vid,u16 nlh_flags) +const unsigned char *addr,u16 vid,u16 nlh_flags, +struct netlink_ext_ack *extack) {struct net_bridge_vlan_group *vg;struct net_bridge_port *p =NULL ;
net/bridge/br_private.h +2 -1
@@ -573,7 +573,8 @@ 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);int br_fdb_add (struct ndmsg *nlh,struct nlattr *tb[],struct net_device *dev, -const unsigned char *addr,u16 vid,u16 nlh_flags); +const unsigned char *addr,u16 vid,u16 nlh_flags, +struct netlink_ext_ack *extack);int br_fdb_dump (struct sk_buff *skb,struct netlink_callback *cb,struct net_device *dev,struct net_device *fdev,int *idx); int br_fdb_get(struct sk_buff *skb, struct nlattr *tb[], struct net_device *dev,
net/core/rtnetlink.c +3 -2
@@ -3639,7 +3639,7 @@ static int rtnl_fdb_add(struct sk_buff *skb, struct nlmsghdr *nlh,const struct net_device_ops *ops = br_dev->netdev_ops; err = ops->ndo_fdb_add (ndm, tb, dev, addr, vid, - nlh->nlmsg_flags); + nlh->nlmsg_flags, extack);if (err) goto out;else
@@ -3651,7 +3651,8 @@ static int rtnl_fdb_add(struct sk_buff *skb, struct nlmsghdr *nlh,if (dev->netdev_ops->ndo_fdb_add) err = dev->netdev_ops->ndo_fdb_add (ndm, tb, dev, addr, vid, - nlh->nlmsg_flags); + nlh->nlmsg_flags, + extack);else err =ndo_dflt_fdb_add (ndm, tb, dev, addr, vid, nlh->nlmsg_flags);
net/dsa/dsa_priv.h +2 -1
@@ -103,7 +103,8 @@ static inline void dsa_legacy_unregister(void) { }int dsa_legacy_fdb_add (struct ndmsg *ndm,struct nlattr *tb[],struct net_device *dev,const unsigned char *addr,u16 vid, -u16 flags); +u16 flags, +struct netlink_ext_ack *extack);int dsa_legacy_fdb_del (struct ndmsg *ndm,struct nlattr *tb[],struct net_device *dev,const unsigned char *addr,u16 vid);
net/dsa/slave.c +2 -1
@@ -1009,7 +1009,8 @@ static const struct ethtool_ops dsa_slave_ethtool_ops = {int dsa_legacy_fdb_add (struct ndmsg *ndm,struct nlattr *tb[],struct net_device *dev,const unsigned char *addr,u16 vid, -u16 flags) +u16 flags, +struct netlink_ext_ack *extack) {struct dsa_port *dp =dsa_slave_to_port (dev);
Signature · 1 line
2.4.11
PATCH 9/13 mlxsw: Add extack to mlxsw_sp_nve_ops.fdb_replay
In reply to Petr MachataA follow-up patch will extend vxlan_fdb_replay() with an extack argument. Extend the fdb_replay callback in mlxsw likewise so that the argument is ready for the vxlan conversion.
--- drivers/net/ethernet/mellanox/mlxsw/spectrum_nve.c | 2 +- drivers/net/ethernet/mellanox/mlxsw/spectrum_nve.h | 3 ++- drivers/net/ethernet/mellanox/mlxsw/spectrum_nve_vxlan.c | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-)
drivers/net/ethernet/mellanox/mlxsw/spectrum_nve.c +1 -1
@@ -841,7 +841,7 @@ int mlxsw_sp_nve_fid_enable(struct mlxsw_sp *mlxsw_sp, struct mlxsw_sp_fid *fid, nve->config = config; - err = ops->fdb_replay (params->dev, params->vni); + err = ops->fdb_replay (params->dev, params->vni, extack);if (err) {NL_SET_ERR_MSG_MOD (extack,"Failed to offload the FDB" ); goto err_fdb_replay;
drivers/net/ethernet/mellanox/mlxsw/spectrum_nve.h +2 -1
@@ -41,7 +41,8 @@ struct mlxsw_sp_nve_ops {int (*init)(struct mlxsw_sp_nve *nve,const struct mlxsw_sp_nve_config *config);void (*fini)(struct mlxsw_sp_nve *nve); -int (*fdb_replay)(const struct net_device *nve_dev,__be32 vni); +int (*fdb_replay)(const struct net_device *nve_dev,__be32 vni, +struct netlink_ext_ack *extack);void (*fdb_clear_offload)(const struct net_device *nve_dev,__be32 vni); };
drivers/net/ethernet/mellanox/mlxsw/spectrum_nve_vxlan.c +2 -1
@@ -212,7 +212,8 @@ static void mlxsw_sp1_nve_vxlan_fini(struct mlxsw_sp_nve *nve) }static int -mlxsw_sp_nve_vxlan_fdb_replay (const struct net_device *nve_dev,__be32 vni) +mlxsw_sp_nve_vxlan_fdb_replay (const struct net_device *nve_dev,__be32 vni, +struct netlink_ext_ack *extack) {if (WARN_ON (!netif_is_vxlan (nve_dev)))return -EINVAL ;
Signature · 1 line
2.4.11
PATCH 10/13 vxlan: Add extack to switchdev operations
In reply to Petr MachataThere are four sources of VXLAN switchdev notifier calls:
- the changelink() link operation, which already supports extack,
- ndo_fdb_add() which got extack support in a previous patch,
- FDB updates due to packet forwarding,
- and vxlan_fdb_replay().
Extend vxlan_fdb_switchdev_call_notifiers() to include extack in the switchdev message that it sends, and propagate the argument upwards to the callers. For the first two cases, pass in the extack gotten through the operation. For case #3, pass in NULL.
To cover the last case, extend vxlan_fdb_replay() to take extack argument, which might come from whatever operation necessitated the FDB replay.
--- .../ethernet/mellanox/mlxsw/spectrum_nve_vxlan.c | 3 +- drivers/net/vxlan.c | 68 +++++++++++++--------- include/net/vxlan.h | 6 +- 3 files changed, 46 insertions(+), 31 deletions(-)
drivers/net/ethernet/mellanox/mlxsw/spectrum_nve_vxlan.c +2 -1
@@ -217,7 +217,8 @@ mlxsw_sp_nve_vxlan_fdb_replay(const struct net_device *nve_dev, __be32 vni, {if (WARN_ON (!netif_is_vxlan (nve_dev)))return -EINVAL ; -return vxlan_fdb_replay (nve_dev, vni, &mlxsw_sp_switchdev_notifier); +return vxlan_fdb_replay (nve_dev, vni, &mlxsw_sp_switchdev_notifier, + extack); } static void
drivers/net/vxlan.c +40 -28
244 lines not on this page · raw message
include/net/vxlan.h +4 -2
@@ -428,7 +428,8 @@ struct switchdev_notifier_vxlan_fdb_info {int vxlan_fdb_find_uc (struct net_device *dev,const u8 *mac,__be32 vni,struct switchdev_notifier_vxlan_fdb_info *fdb_info);int vxlan_fdb_replay (const struct net_device *dev,__be32 vni, -struct notifier_block *nb); +struct notifier_block *nb, +struct netlink_ext_ack *extack);void vxlan_fdb_clear_offload (const struct net_device *dev,__be32 vni);#else
@@ -440,7 +441,8 @@ vxlan_fdb_find_uc(struct net_device *dev, const u8 *mac, __be32 vni, }static inline int vxlan_fdb_replay (const struct net_device *dev,__be32 vni, -struct notifier_block *nb) +struct notifier_block *nb, +struct netlink_ext_ack *extack) {return -EOPNOTSUPP ; }
Signature · 1 line
2.4.11
PATCH 11/13 switchdev: Add extack argument to call_switchdev_notifiers()
In reply to Petr MachataA follow-up patch will enable vetoing of FDB entries. Make it possible to communicate details of why an FDB entry is not acceptable back to the user.
--- Documentation/networking/switchdev.txt | 2 +- drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c | 6 ++++-- drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c | 12 ++++++------ drivers/net/ethernet/rocker/rocker_main.c | 2 +- drivers/net/ethernet/rocker/rocker_ofdpa.c | 4 ++-- drivers/net/vxlan.c | 2 +- include/net/switchdev.h | 6 ++++-- net/bridge/br_switchdev.c | 2 +- net/dsa/slave.c | 2 +- net/switchdev/switchdev.c | 5 +++-- 10 files changed, 24 insertions(+), 19 deletions(-)
Documentation/networking/switchdev.txt +1 -1
@@ -196,7 +196,7 @@ The switch device will learn/forget source MAC address/VLAN on ingress packets and notify the switch driver of the mac/vlan/port tuples. The switch driver, in turn, will notify the bridge driver using the switchdev notifier call: - err = call_switchdev_notifiers(val, dev, info); + err = call_switchdev_notifiers(val, dev, info, extack); Where val is SWITCHDEV_FDB_ADD when learning and SWITCHDEV_FDB_DEL when forgetting, and info points to a struct switchdev_notifier_fdb_info. On
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c +4 -2
@@ -7294,7 +7294,8 @@ static void mlxsw_sp_rif_vlan_fdb_del(struct mlxsw_sp_rif *rif, const char *mac) info.addr = mac; info.vid = vid; -call_switchdev_notifiers (SWITCHDEV_FDB_DEL_TO_BRIDGE , dev, &info.info); +call_switchdev_notifiers (SWITCHDEV_FDB_DEL_TO_BRIDGE , dev, &info.info, +NULL ); }static const struct mlxsw_sp_rif_ops mlxsw_sp_rif_vlan_ops = {
@@ -7381,7 +7382,8 @@ static void mlxsw_sp_rif_fid_fdb_del(struct mlxsw_sp_rif *rif, const char *mac) info.addr = mac; info.vid =0 ; -call_switchdev_notifiers (SWITCHDEV_FDB_DEL_TO_BRIDGE , dev, &info.info); +call_switchdev_notifiers (SWITCHDEV_FDB_DEL_TO_BRIDGE , dev, &info.info, +NULL ); }static const struct mlxsw_sp_rif_ops mlxsw_sp_rif_fid_ops = {
drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c +6 -6
@@ -2443,7 +2443,7 @@ static void mlxsw_sp_fdb_vxlan_call_notifiers(struct net_device *dev,ether_addr_copy (info.eth_addr, mac); info.vni = vni; info.offloaded = adding; -call_switchdev_notifiers (type, dev, &info.info); +call_switchdev_notifiers (type, dev, &info.info,NULL ); } static void mlxsw_sp_fdb_nve_call_notifiers(struct net_device *dev,
@@ -2468,7 +2468,7 @@ mlxsw_sp_fdb_call_notifiers(enum switchdev_notifier_type type, info.addr = mac; info.vid = vid; info.offloaded = offloaded; -call_switchdev_notifiers (type, dev, &info.info); +call_switchdev_notifiers (type, dev, &info.info,NULL ); } static void mlxsw_sp_fdb_notify_mac_process(struct mlxsw_sp *mlxsw_sp,
@@ -2819,7 +2819,7 @@ mlxsw_sp_switchdev_bridge_vxlan_fdb_event(struct mlxsw_sp *mlxsw_sp,return ; vxlan_fdb_info.offloaded = true;call_switchdev_notifiers (SWITCHDEV_VXLAN_FDB_OFFLOADED , dev, - &vxlan_fdb_info.info); + &vxlan_fdb_info.info,NULL );mlxsw_sp_fdb_call_notifiers (SWITCHDEV_FDB_OFFLOADED , vxlan_fdb_info.eth_addr, fdb_info->vid, dev, true);
@@ -2832,7 +2832,7 @@ mlxsw_sp_switchdev_bridge_vxlan_fdb_event(struct mlxsw_sp *mlxsw_sp, false); vxlan_fdb_info.offloaded = false;call_switchdev_notifiers (SWITCHDEV_VXLAN_FDB_OFFLOADED , dev, - &vxlan_fdb_info.info); + &vxlan_fdb_info.info,NULL );break ; } }
@@ -2977,7 +2977,7 @@ mlxsw_sp_switchdev_vxlan_fdb_add(struct mlxsw_sp *mlxsw_sp, } vxlan_fdb_info->offloaded = true;call_switchdev_notifiers (SWITCHDEV_VXLAN_FDB_OFFLOADED , dev, - &vxlan_fdb_info->info); + &vxlan_fdb_info->info,NULL );mlxsw_sp_fid_put (fid);return ; }
@@ -2998,7 +2998,7 @@ mlxsw_sp_switchdev_vxlan_fdb_add(struct mlxsw_sp *mlxsw_sp, goto err_fdb_tunnel_uc_op; vxlan_fdb_info->offloaded = true;call_switchdev_notifiers (SWITCHDEV_VXLAN_FDB_OFFLOADED , dev, - &vxlan_fdb_info->info); + &vxlan_fdb_info->info,NULL );mlxsw_sp_fdb_call_notifiers (SWITCHDEV_FDB_OFFLOADED , vxlan_fdb_info->eth_addr, vid, dev, true);
drivers/net/ethernet/rocker/rocker_main.c +1 -1
@@ -2725,7 +2725,7 @@ rocker_fdb_offload_notify(struct rocker_port *rocker_port, info.vid = recv_info->vid; info.offloaded = true;call_switchdev_notifiers (SWITCHDEV_FDB_OFFLOADED , - rocker_port->dev, &info.info); + rocker_port->dev, &info.info,NULL ); }static void rocker_switchdev_event_work (struct work_struct *work)
drivers/net/ethernet/rocker/rocker_ofdpa.c +2 -2
@@ -1833,10 +1833,10 @@ static void ofdpa_port_fdb_learn_work(struct work_struct *work)rtnl_lock ();if (learned && removing)call_switchdev_notifiers (SWITCHDEV_FDB_DEL_TO_BRIDGE , - lw->ofdpa_port->dev, &info.info); + lw->ofdpa_port->dev, &info.info,NULL );else if (learned && !removing)call_switchdev_notifiers (SWITCHDEV_FDB_ADD_TO_BRIDGE , - lw->ofdpa_port->dev, &info.info); + lw->ofdpa_port->dev, &info.info,NULL );rtnl_unlock ();kfree (work);
drivers/net/vxlan.c +1 -1
@@ -393,7 +393,7 @@ static int vxlan_fdb_switchdev_call_notifiers(struct vxlan_dev *vxlan, : SWITCHDEV_VXLAN_FDB_DEL_TO_DEVICE;vxlan_fdb_switchdev_notifier_info (vxlan, fdb, rd,NULL , &info); ret =call_switchdev_notifiers (notifier_type, vxlan->dev, - &info.info); + &info.info, extack);return notifier_to_errno (ret); }
include/net/switchdev.h +4 -2
@@ -195,7 +195,8 @@ int switchdev_port_obj_del(struct net_device *dev,int register_switchdev_notifier (struct notifier_block *nb);int unregister_switchdev_notifier (struct notifier_block *nb);int call_switchdev_notifiers (unsigned long val,struct net_device *dev, -struct switchdev_notifier_info *info); +struct switchdev_notifier_info *info, +struct netlink_ext_ack *extack);int register_switchdev_blocking_notifier (struct notifier_block *nb);int unregister_switchdev_blocking_notifier (struct notifier_block *nb);
@@ -267,7 +268,8 @@ static inline int unregister_switchdev_notifier(struct notifier_block *nb)static inline int call_switchdev_notifiers (unsigned long val,struct net_device *dev, -struct switchdev_notifier_info *info) +struct switchdev_notifier_info *info, +struct netlink_ext_ack *extack) {return NOTIFY_DONE ; }
net/bridge/br_switchdev.c +1 -1
@@ -113,7 +113,7 @@ br_switchdev_fdb_call_notifiers(bool adding, const unsigned char *mac, info.added_by_user = added_by_user; info.offloaded = offloaded; notifier_type = adding ?SWITCHDEV_FDB_ADD_TO_DEVICE :SWITCHDEV_FDB_DEL_TO_DEVICE ; -call_switchdev_notifiers (notifier_type, dev, &info.info); +call_switchdev_notifiers (notifier_type, dev, &info.info,NULL ); }void
net/dsa/slave.c +1 -1
@@ -1451,7 +1451,7 @@ static void dsa_slave_switchdev_event_work(struct work_struct *work) } fdb_info->offloaded = true;call_switchdev_notifiers (SWITCHDEV_FDB_OFFLOADED , dev, - &fdb_info->info); + &fdb_info->info,NULL );break ;case SWITCHDEV_FDB_DEL_TO_DEVICE :
net/switchdev/switchdev.c +3 -2
@@ -556,10 +556,11 @@ EXPORT_SYMBOL_GPL(unregister_switchdev_notifier);* Call all network notifier blocks. */ int call_switchdev_notifiers (unsigned long val,struct net_device *dev, -struct switchdev_notifier_info *info) +struct switchdev_notifier_info *info, +struct netlink_ext_ack *extack) { info->dev = dev; - info->extack =NULL ; + info->extack = extack;return atomic_notifier_call_chain (&switchdev_notif_chain, val, info); }EXPORT_SYMBOL_GPL (call_switchdev_notifiers);
Signature · 1 line
2.4.11
PATCH 12/13 mlxsw: spectrum: Add extack messages to VXLAN FDB rejection
In reply to Petr MachataAnnotate the rejections in mlxsw_sp_switchdev_vxlan_work_prepare() with textual reasons.
Because this code ends up being invoked for FDB replay as well, drop the default message from there, so that the more accurate error message is not overwritten.
--- drivers/net/ethernet/mellanox/mlxsw/spectrum_nve.c | 4 +--- .../ethernet/mellanox/mlxsw/spectrum_switchdev.c | 25 ++++++++++++++++------ 2 files changed, 19 insertions(+), 10 deletions(-)
drivers/net/ethernet/mellanox/mlxsw/spectrum_nve.c +1 -3
@@ -842,10 +842,8 @@ int mlxsw_sp_nve_fid_enable(struct mlxsw_sp *mlxsw_sp, struct mlxsw_sp_fid *fid, nve->config = config; err = ops->fdb_replay (params->dev, params->vni, extack); -if (err) { -NL_SET_ERR_MSG_MOD (extack,"Failed to offload the FDB" ); +if (err) goto err_fdb_replay; - }return 0 ;
drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c +18 -7
@@ -3099,23 +3099,34 @@ mlxsw_sp_switchdev_vxlan_work_prepare(struct mlxsw_sp_switchdev_event_work *struct vxlan_dev *vxlan =netdev_priv (switchdev_work->dev);struct switchdev_notifier_vxlan_fdb_info *vxlan_fdb_info;struct vxlan_config *cfg = &vxlan->cfg; +struct netlink_ext_ack *extack; + extack =switchdev_notifier_info_to_extack (info); vxlan_fdb_info =container_of (info, struct switchdev_notifier_vxlan_fdb_info, info); -if (vxlan_fdb_info->remote_port != cfg->dst_port) -return -EOPNOTSUPP ; -if (vxlan_fdb_info->remote_vni != cfg->vni) +if (vxlan_fdb_info->remote_port != cfg->dst_port) { +NL_SET_ERR_MSG_MOD (extack,"VxLAN: FDB: Non-default remote port is not supported" );return -EOPNOTSUPP ; -if (vxlan_fdb_info->vni != cfg->vni) + } +if (vxlan_fdb_info->remote_vni != cfg->vni || + vxlan_fdb_info->vni != cfg->vni) { +NL_SET_ERR_MSG_MOD (extack,"VxLAN: FDB: Non-default VNI is not supported" );return -EOPNOTSUPP ; -if (vxlan_fdb_info->remote_ifindex) + } +if (vxlan_fdb_info->remote_ifindex) { +NL_SET_ERR_MSG_MOD (extack,"VxLAN: FDB: Local interface is not supported" );return -EOPNOTSUPP ; -if (is_multicast_ether_addr (vxlan_fdb_info->eth_addr)) + } +if (is_multicast_ether_addr (vxlan_fdb_info->eth_addr)) { +NL_SET_ERR_MSG_MOD (extack,"VxLAN: FDB: Multicast MAC addresses not supported" );return -EOPNOTSUPP ; -if (vxlan_addr_multicast (&vxlan_fdb_info->remote_ip)) + } +if (vxlan_addr_multicast (&vxlan_fdb_info->remote_ip)) { +NL_SET_ERR_MSG_MOD (extack,"VxLAN: FDB: Multicast destination IP is not supported" );return -EOPNOTSUPP ; + } switchdev_work->vxlan_fdb_info = *vxlan_fdb_info;
Signature · 1 line
2.4.11
PATCH 13/13 selftests: mlxsw: Test veto of unsupported VXLAN FDBs
In reply to Petr Machatamlxsw doesn't implement offloading of all types of FDB entries that the VXLAN driver supports. Test that such FDB entries are rejected. That makes sure that the decision made by the existing validation code in mlxsw propagates up the stack. It also exercises rollback functionality in VXLAN, and tests that extack is returned.
--- .../selftests/drivers/net/mlxsw/vxlan_fdb_veto.sh | 126 +++++++++++++++++++++ 1 file changed, 126 insertions(+) create mode 100755 tools/testing/selftests/drivers/net/mlxsw/vxlan_fdb_veto.sh
tools/testing/selftests/drivers/net/mlxsw/vxlan_fdb_veto.sh new file +126 -0
@@ -0,0 +1,126 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 +# +# Test vetoing of FDB entries that mlxsw can not offload. This exercises several +# different veto vectors to test various rollback scenarios in the vxlan driver. + +lib_dir=$(dirname $0)/../../../net/forwarding + +ALL_TESTS=" + fdb_create_veto_test + fdb_replace_veto_test + fdb_append_veto_test + fdb_changelink_veto_test +" +NUM_NETIFS=2 +source $lib_dir/lib.sh + +setup_prepare() +{ + swp1=${NETIFS[p1]} + swp2=${NETIFS[p2]} + + ip link add dev br0 type bridge mcast_snooping 0 + + ip link set dev $swp1 up + ip link set dev $swp1 master br0 + ip link set dev $swp2 up + + ip link add name vxlan0 up type vxlan id 10 nolearning noudpcsum \ + ttl 20 tos inherit local 198.51.100.1 dstport 4789 + ip link set dev vxlan0 master br0 +} + +cleanup() +{ + pre_cleanup + + ip link set dev vxlan0 nomaster + ip link del dev vxlan0 + + ip link set dev $swp2 down + ip link set dev $swp1 nomaster + ip link set dev $swp1 down + + ip link del dev br0 +} + +fdb_create_veto_test() +{ + RET=0 + + bridge fdb add 01:02:03:04:05:06 dev vxlan0 self static \ + dst 198.51.100.2 2>/dev/null + check_fail $? "multicast MAC not rejected" + + bridge fdb add 01:02:03:04:05:06 dev vxlan0 self static \ + dst 198.51.100.2 2>&1 >/dev/null | grep -q mlxsw_spectrum + check_err $? "multicast MAC rejected without extack" + + log_test "vxlan FDB veto - create" +} + +fdb_replace_veto_test() +{ + RET=0 + + bridge fdb add 00:01:02:03:04:05 dev vxlan0 self static \ + dst 198.51.100.2 + check_err $? "valid FDB rejected" + + bridge fdb replace 00:01:02:03:04:05 dev vxlan0 self static \ + dst 198.51.100.2 port 1234 2>/dev/null + check_fail $? "FDB with an explicit port not rejected" + + bridge fdb replace 00:01:02:03:04:05 dev vxlan0 self static \ + dst 198.51.100.2 port 1234 2>&1 >/dev/null \ + | grep -q mlxsw_spectrum + check_err $? "FDB with an explicit port rejected without extack" + + log_test "vxlan FDB veto - replace" +} + +fdb_append_veto_test() +{ + RET=0 + + bridge fdb add 00:00:00:00:00:00 dev vxlan0 self static \ + dst 198.51.100.2 + check_err $? "valid FDB rejected" + + bridge fdb append 00:00:00:00:00:00 dev vxlan0 self static \ + dst 198.51.100.3 port 1234 2>/dev/null + check_fail $? "FDB with an explicit port not rejected" + + bridge fdb append 00:00:00:00:00:00 dev vxlan0 self static \ + dst 198.51.100.3 port 1234 2>&1 >/dev/null \ + | grep -q mlxsw_spectrum + check_err $? "FDB with an explicit port rejected without extack" + + log_test "vxlan FDB veto - append" +} + +fdb_changelink_veto_test() +{ + RET=0 + + ip link set dev vxlan0 type vxlan \ + group 224.0.0.1 dev lo 2>/dev/null + check_fail $? "FDB with a multicast IP not rejected" + + ip link set dev vxlan0 type vxlan \ + group 224.0.0.1 dev lo 2>&1 >/dev/null \ + | grep -q mlxsw_spectrum + check_err $? "FDB with a multicast IP rejected without extack" + + log_test "vxlan FDB veto - changelink" +} + +trap cleanup EXIT + +setup_prepare +setup_wait + +tests_run + +exit $EXIT_STATUS
Signature · 1 line
2.4.11
David Miller
maintainerFrom: Petr Machata <[email protected]>
Date: Wed, 16 Jan 2019 23:06:28 +0000
Quoted 14 lines
mlxsw does not implement handling of the more advanced types of VXLAN FDB entries. In order to provide visibility to users, it is important to be able to reject such FDB entries, ideally with an explanation passed in extended ack. This patch set implements this.
In patches #1-#4, vxlan is gradually transformed to support vetoing of FDB entries added (or modified) through
vxlan_fdb_update(), and the default FDB entry added in__vxlan_dev_create().Patches #5-#7 deal with
vxlan_changelink(). The existing code recognizes thatvxlan_fdb_update()may fail, but doesn't attempt to keep things intact if it does. These patches change the function in several steps to gracefully handle vetoes (or other failures).
Quoted 7 lines
Then in patches #8-#11, extack arguments are added, respectively, to
ndo_fdb_add(), mlxsw's mlxsw_sp_nve_ops.fdb_replay, the functions that connect to the VXLAN vetoing code, andcall_switchdev_notifiers(). Note thatcall_switchdev_blocking_notifiers()already does support extack.Finally in patch #12, mlxsw is extended to add extack messages to rejected FDB entries. In patch #13, the functionality is tested.
Series applied, thanks Petr.