Commit 038a5a99 authored by Petr Machata's avatar Petr Machata Committed by David S. Miller

vxlan: changelink: Postpone vxlan_config_apply()

When 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.
Signed-off-by: default avatarPetr Machata <petrm@mellanox.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 8db9427d
...@@ -3792,9 +3792,7 @@ static int vxlan_changelink(struct net_device *dev, struct nlattr *tb[], ...@@ -3792,9 +3792,7 @@ static int vxlan_changelink(struct net_device *dev, struct nlattr *tb[],
{ {
struct vxlan_dev *vxlan = netdev_priv(dev); struct vxlan_dev *vxlan = netdev_priv(dev);
struct vxlan_rdst *dst = &vxlan->default_dst; struct vxlan_rdst *dst = &vxlan->default_dst;
unsigned long old_age_interval;
struct net_device *lowerdev; struct net_device *lowerdev;
struct vxlan_rdst old_dst;
struct vxlan_config conf; struct vxlan_config conf;
int err; int err;
...@@ -3803,40 +3801,31 @@ static int vxlan_changelink(struct net_device *dev, struct nlattr *tb[], ...@@ -3803,40 +3801,31 @@ static int vxlan_changelink(struct net_device *dev, struct nlattr *tb[],
if (err) if (err)
return 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, err = vxlan_config_validate(vxlan->net, &conf, &lowerdev,
vxlan, extack); vxlan, extack);
if (err) if (err)
return 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 */ /* 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); 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, __vxlan_fdb_delete(vxlan, all_zeros_mac,
old_dst.remote_ip, dst->remote_ip,
vxlan->cfg.dst_port, vxlan->cfg.dst_port,
old_dst.remote_vni, dst->remote_vni,
old_dst.remote_vni, dst->remote_vni,
old_dst.remote_ifindex, dst->remote_ifindex,
true); true);
if (!vxlan_addr_any(&dst->remote_ip)) { if (!vxlan_addr_any(&conf.remote_ip)) {
err = vxlan_fdb_update(vxlan, all_zeros_mac, err = vxlan_fdb_update(vxlan, all_zeros_mac,
&dst->remote_ip, &conf.remote_ip,
NUD_REACHABLE | NUD_PERMANENT, NUD_REACHABLE | NUD_PERMANENT,
NLM_F_APPEND | NLM_F_CREATE, NLM_F_APPEND | NLM_F_CREATE,
vxlan->cfg.dst_port, vxlan->cfg.dst_port,
dst->remote_vni, conf.vni, conf.vni,
dst->remote_vni, conf.remote_ifindex,
dst->remote_ifindex,
NTF_SELF, true); NTF_SELF, true);
if (err) { if (err) {
spin_unlock_bh(&vxlan->hash_lock); spin_unlock_bh(&vxlan->hash_lock);
...@@ -3846,6 +3835,10 @@ static int vxlan_changelink(struct net_device *dev, struct nlattr *tb[], ...@@ -3846,6 +3835,10 @@ static int vxlan_changelink(struct net_device *dev, struct nlattr *tb[],
spin_unlock_bh(&vxlan->hash_lock); 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; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment