From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ido Schimmel Subject: [PATCH net-next v2 11/18] net: Add netif_is_vxlan() Date: Wed, 17 Oct 2018 08:53:20 +0000 Message-ID: <20181017085215.26607-12-idosch@mellanox.com> References: <20181017085215.26607-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 , "jakub.kicinski@netronome.com" , "ivecera@redhat.com" , "roopa@cumulusnetworks.com" , "nikolay@cumulusnetworks.com" , "andrew@lunn.ch" , "vivien.didelot@savoirfairelinux.com" , "f.fainelli@gmail.com" , "stephen@networkplumber.org" , "bridge@lists.linux-foundation.org" , mlxsw , Ido Schimmel To: "netdev@vger.kernel.org" Return-path: Received: from mail-eopbgr50052.outbound.protection.outlook.com ([40.107.5.52]:45920 "EHLO EUR03-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726957AbeJQQsS (ORCPT ); Wed, 17 Oct 2018 12:48:18 -0400 In-Reply-To: <20181017085215.26607-1-idosch@mellanox.com> Content-Language: en-US Sender: netdev-owner@vger.kernel.org List-ID: Add the ability to determine whether a netdev is a VxLAN netdev by calling the above mentioned function that checks the netdev's rtnl_link_ops. This will allow modules to identify netdev events involving a VxLAN netdev and act accordingly. For example, drivers capable of VxLAN offload will need to configure the underlying device when a VxLAN netdev is being enslaved to an offloaded bridge. Convert nfp to use the newly introduced helper. Signed-off-by: Ido Schimmel Reviewed-by: Petr Machata --- drivers/net/ethernet/netronome/nfp/flower/tunnel_conf.c | 3 ++- include/net/vxlan.h | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/netronome/nfp/flower/tunnel_conf.c b/driv= ers/net/ethernet/netronome/nfp/flower/tunnel_conf.c index 30c926c4bc47..8e5bec04d1f9 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/tunnel_conf.c +++ b/drivers/net/ethernet/netronome/nfp/flower/tunnel_conf.c @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include @@ -187,7 +188,7 @@ static bool nfp_tun_is_netdev_to_offload(struct net_dev= ice *netdev) return false; if (!strcmp(netdev->rtnl_link_ops->kind, "openvswitch")) return true; - if (!strcmp(netdev->rtnl_link_ops->kind, "vxlan")) + if (netif_is_vxlan(netdev)) return true; =20 return false; diff --git a/include/net/vxlan.h b/include/net/vxlan.h index dd3d72ce64b6..95227fa925e8 100644 --- a/include/net/vxlan.h +++ b/include/net/vxlan.h @@ -5,6 +5,7 @@ #include #include #include +#include =20 /* VXLAN protocol (RFC 7348) header: * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ @@ -402,4 +403,10 @@ static inline bool vxlan_addr_multicast(const union vx= lan_addr *ipa) =20 #endif /* IS_ENABLED(CONFIG_IPV6) */ =20 +static inline bool netif_is_vxlan(const struct net_device *dev) +{ + return dev->rtnl_link_ops && + !strcmp(dev->rtnl_link_ops->kind, "vxlan"); +} + #endif --=20 2.17.2