diff --git a/drivers/net/vxlan/vxlan_core.c b/drivers/net/vxlan/vxlan_core.c index 223539099778..d11028b37472 100644 --- a/drivers/net/vxlan/vxlan_core.c +++ b/drivers/net/vxlan/vxlan_core.c @@ -1005,12 +1005,6 @@ static int vxlan_fdb_update_existing(struct vxlan_dev *vxlan, return -EOPNOTSUPP; } - if (rcu_access_pointer(f->nh) && - !(state & (NUD_PERMANENT | NUD_NOARP))) { - NL_SET_ERR_MSG(extack, "Cannot make a nexthop fdb dynamic"); - return -EOPNOTSUPP; - } - /* Do not allow an externally learned entry to take over an entry added * by the user. */ @@ -1274,11 +1268,6 @@ static int vxlan_fdb_add(struct ndmsg *ndm, struct nlattr *tb[], if (err) return err; - if (nhid && !(ndm->ndm_state & (NUD_PERMANENT | NUD_NOARP))) { - NL_SET_ERR_MSG(extack, "A nexthop fdb cannot be dynamic"); - return -EINVAL; - } - cfg = rtnl_dereference(vxlan->cfg); if (cfg->remote_ip.sa.sa_family != ip.sa.sa_family) return -EAFNOSUPPORT; @@ -2947,6 +2936,9 @@ static void vxlan_cleanup(struct timer_list *t) if (f->flags & NTF_EXT_LEARNED) continue; + if (rcu_access_pointer(f->nh)) + continue; + timeout = READ_ONCE(f->updated) + cfg->age_interval * HZ; if (time_before_eq(timeout, jiffies)) { spin_lock(&vxlan->hash_lock); diff --git a/tools/testing/selftests/net/fib_nexthops.sh b/tools/testing/selftests/net/fib_nexthops.sh index 431d7bed7622..adbec51917eb 100755 --- a/tools/testing/selftests/net/fib_nexthops.sh +++ b/tools/testing/selftests/net/fib_nexthops.sh @@ -425,6 +425,14 @@ stop_ip_monitor() return $rc } +fdb_entry_aged() +{ + local mac=$1 + local dev=$2 + + ! $BRIDGE fdb get to $mac dev $dev self &> /dev/null +} + check_nexthop_fdb_support() { $IP nexthop help 2>&1 | grep -q fdb @@ -538,14 +546,18 @@ ipv6_fdb_grp_fcnal() log_test $? 0 "Fdb mac add with nexthop group and static state" run_cmd "$BRIDGE fdb add 02:02:00:00:00:16 dev vx10 nhid 102 self dynamic" - log_test $? 255 "Fdb mac add with nexthop group and dynamic state" + log_test $? 0 "Fdb mac add with nexthop group and dynamic state" - run_cmd "$BRIDGE fdb add 02:02:00:00:00:17 dev vx10 nhid 102 self" - run_cmd "$BRIDGE fdb replace 02:02:00:00:00:17 dev vx10 dst 2001:db8:91::11 self dynamic" - log_test $? 255 "Fdb mac replace with nexthop group and dynamic state" + run_cmd "$BRIDGE fdb add 02:02:00:00:00:17 dev vx10 nhid 102 self dynamic extern_learn" + log_test $? 0 "Fdb mac add with nexthop group and extern_learn" - run_cmd "$BRIDGE fdb append 02:02:00:00:00:17 dev vx10 dst 2001:db8:91::11 self dynamic" - log_test $? 255 "Fdb mac append with nexthop group and dynamic state" + run_cmd "$IP link set dev vx10 up type vxlan ageing 1" + run_cmd "$BRIDGE fdb add 02:02:00:00:00:18 dev vx10 dst 2001:db8:91::11 self dynamic" + slowwait 20 fdb_entry_aged 02:02:00:00:00:18 vx10 + log_test $? 0 "Fdb mac without nexthop group aged out" + + run_cmd "$BRIDGE fdb get to 02:02:00:00:00:16 dev vx10 self" + log_test $? 0 "Fdb mac with nexthop group not aged out" run_cmd "$IP -6 ro add 2001:db8:101::1/128 nhid 66" log_test $? 2 "Route add with fdb nexthop" @@ -688,14 +700,18 @@ ipv4_fdb_grp_fcnal() log_test $? 0 "Fdb mac add with nexthop group and static state" run_cmd "$BRIDGE fdb add 02:02:00:00:00:16 dev vx10 nhid 102 self dynamic" - log_test $? 255 "Fdb mac add with nexthop group and dynamic state" + log_test $? 0 "Fdb mac add with nexthop group and dynamic state" - run_cmd "$BRIDGE fdb add 02:02:00:00:00:17 dev vx10 nhid 102 self" - run_cmd "$BRIDGE fdb replace 02:02:00:00:00:17 dev vx10 dst 10.0.0.3 self dynamic" - log_test $? 255 "Fdb mac replace with nexthop group and dynamic state" + run_cmd "$BRIDGE fdb add 02:02:00:00:00:17 dev vx10 nhid 102 self dynamic extern_learn" + log_test $? 0 "Fdb mac add with nexthop group and extern_learn" - run_cmd "$BRIDGE fdb append 02:02:00:00:00:17 dev vx10 dst 10.0.0.3 self dynamic" - log_test $? 255 "Fdb mac append with nexthop group and dynamic state" + run_cmd "$IP link set dev vx10 up type vxlan ageing 1" + run_cmd "$BRIDGE fdb add 02:02:00:00:00:18 dev vx10 dst 10.0.0.3 self dynamic" + slowwait 20 fdb_entry_aged 02:02:00:00:00:18 vx10 + log_test $? 0 "Fdb mac without nexthop group aged out" + + run_cmd "$BRIDGE fdb get to 02:02:00:00:00:16 dev vx10 self" + log_test $? 0 "Fdb mac with nexthop group not aged out" run_cmd "$IP ro add 172.16.0.0/22 nhid 16" log_test $? 2 "Route add with fdb nexthop"