From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ido Schimmel Subject: [PATCH net-next 04/16] vxlan: Don't override user-added entries with ext-learned ones Date: Wed, 21 Nov 2018 08:02:37 +0000 Message-ID: <20181121080141.16676-5-idosch@mellanox.com> References: <20181121080141.16676-1-idosch@mellanox.com> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Cc: "davem@davemloft.net" , Jiri Pirko , Petr Machata , "roopa@cumulusnetworks.com" , "nikolay@cumulusnetworks.com" , "stephen@networkplumber.org" , "ivecera@redhat.com" , mlxsw , Ido Schimmel To: "netdev@vger.kernel.org" , "bridge@lists.linux-foundation.org" Return-path: Received: from mail-eopbgr20054.outbound.protection.outlook.com ([40.107.2.54]:26130 "EHLO EUR02-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728078AbeKUSgV (ORCPT ); Wed, 21 Nov 2018 13:36:21 -0500 In-Reply-To: <20181121080141.16676-1-idosch@mellanox.com> Content-Language: en-US Sender: netdev-owner@vger.kernel.org List-ID: From: Petr Machata When an external learning event collides with an user-added entry, the user-added entry shouldn't be taken over. Otherwise on an unlearn event the entry would be completely lost, even though the user added it by hand. Therefore skip update of FDB flags and state for these cases. This is in accordance with the bridge behavior. Signed-off-by: Petr Machata Signed-off-by: Ido Schimmel --- drivers/net/vxlan.c | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c index 9171c1f42fe9..b50705a50686 100644 --- a/drivers/net/vxlan.c +++ b/drivers/net/vxlan.c @@ -780,16 +780,24 @@ static int vxlan_fdb_update(struct vxlan_dev *vxlan, "lost race to create %pM\n", mac); return -EEXIST; } - if (f->state !=3D state) { - f->state =3D state; - f->updated =3D jiffies; - notify =3D 1; - } - if (f->flags !=3D fdb_flags) { - f->flags =3D fdb_flags; - f->updated =3D jiffies; - notify =3D 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 !=3D state) { + f->state =3D state; + f->updated =3D jiffies; + notify =3D 1; + } + if (f->flags !=3D fdb_flags) { + f->flags =3D fdb_flags; + f->updated =3D jiffies; + notify =3D 1; + } } + if ((flags & NLM_F_REPLACE)) { /* Only change unicasts */ if (!(is_multicast_ether_addr(f->eth_addr) || --=20 2.19.1