netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ido Schimmel <idosch@mellanox.com>
To: "netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"bridge@lists.linux-foundation.org"
	<bridge@lists.linux-foundation.org>
Cc: "davem@davemloft.net" <davem@davemloft.net>,
	Jiri Pirko <jiri@mellanox.com>, Petr Machata <petrm@mellanox.com>,
	"roopa@cumulusnetworks.com" <roopa@cumulusnetworks.com>,
	"nikolay@cumulusnetworks.com" <nikolay@cumulusnetworks.com>,
	Ido Schimmel <idosch@mellanox.com>
Subject: [PATCH net-next v2 01/12] vxlan: Add a function to init switchdev_notifier_vxlan_fdb_info
Date: Fri, 7 Dec 2018 19:55:03 +0000	[thread overview]
Message-ID: <20181207195433.22540-2-idosch@mellanox.com> (raw)
In-Reply-To: <20181207195433.22540-1-idosch@mellanox.com>

From: Petr Machata <petrm@mellanox.com>

There are currently two places that need to initialize the notifier info
structure, and one more is coming next when vxlan_fdb_replay() is
introduced. These three instances have / will have very similar code
that is easy to abstract away into a named function.

Add such function, vxlan_fdb_switchdev_notifier_info(), and call it from
vxlan_fdb_switchdev_call_notifiers() and vxlan_fdb_find_uc().

Signed-off-by: Petr Machata <petrm@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
---
 drivers/net/vxlan.c | 41 ++++++++++++++++++-----------------------
 1 file changed, 18 insertions(+), 23 deletions(-)

diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
index 901eef428280..d3db0313c97e 100644
--- a/drivers/net/vxlan.c
+++ b/drivers/net/vxlan.c
@@ -358,6 +358,22 @@ static void __vxlan_fdb_notify(struct vxlan_dev *vxlan, struct vxlan_fdb *fdb,
 		rtnl_set_sk_err(net, RTNLGRP_NEIGH, err);
 }
 
+static void vxlan_fdb_switchdev_notifier_info(const struct vxlan_dev *vxlan,
+			    const struct vxlan_fdb *fdb,
+			    const struct vxlan_rdst *rd,
+			    struct switchdev_notifier_vxlan_fdb_info *fdb_info)
+{
+	fdb_info->info.dev = vxlan->dev;
+	fdb_info->remote_ip = rd->remote_ip;
+	fdb_info->remote_port = rd->remote_port;
+	fdb_info->remote_vni = rd->remote_vni;
+	fdb_info->remote_ifindex = rd->remote_ifindex;
+	memcpy(fdb_info->eth_addr, fdb->eth_addr, ETH_ALEN);
+	fdb_info->vni = fdb->vni;
+	fdb_info->offloaded = rd->offloaded;
+	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,
@@ -371,18 +387,7 @@ static void vxlan_fdb_switchdev_call_notifiers(struct vxlan_dev *vxlan,
 
 	notifier_type = adding ? SWITCHDEV_VXLAN_FDB_ADD_TO_DEVICE
 			       : SWITCHDEV_VXLAN_FDB_DEL_TO_DEVICE;
-
-	info = (struct switchdev_notifier_vxlan_fdb_info){
-		.remote_ip = rd->remote_ip,
-		.remote_port = rd->remote_port,
-		.remote_vni = rd->remote_vni,
-		.remote_ifindex = rd->remote_ifindex,
-		.vni = fdb->vni,
-		.offloaded = rd->offloaded,
-		.added_by_user = fdb->flags & NTF_VXLAN_ADDED_BY_USER,
-	};
-	memcpy(info.eth_addr, fdb->eth_addr, ETH_ALEN);
-
+	vxlan_fdb_switchdev_notifier_info(vxlan, fdb, rd, &info);
 	call_switchdev_notifiers(notifier_type, vxlan->dev,
 				 &info.info);
 }
@@ -539,17 +544,7 @@ int vxlan_fdb_find_uc(struct net_device *dev, const u8 *mac, __be32 vni,
 	}
 
 	rdst = first_remote_rcu(f);
-
-	memset(fdb_info, 0, sizeof(*fdb_info));
-	fdb_info->info.dev = dev;
-	fdb_info->remote_ip = rdst->remote_ip;
-	fdb_info->remote_port = rdst->remote_port;
-	fdb_info->remote_vni = rdst->remote_vni;
-	fdb_info->remote_ifindex = rdst->remote_ifindex;
-	fdb_info->vni = vni;
-	fdb_info->offloaded = rdst->offloaded;
-	fdb_info->added_by_user = f->flags & NTF_VXLAN_ADDED_BY_USER;
-	ether_addr_copy(fdb_info->eth_addr, mac);
+	vxlan_fdb_switchdev_notifier_info(vxlan, f, rdst, fdb_info);
 
 out:
 	rcu_read_unlock();
-- 
2.19.1

  reply	other threads:[~2018-12-07 19:55 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-07 19:55 [PATCH net-next v2 00/12] mlxsw: Un/offload FDB on NVE detach/attach Ido Schimmel
2018-12-07 19:55 ` Ido Schimmel [this message]
2018-12-07 19:55 ` [PATCH net-next v2 02/12] vxlan: Add vxlan_fdb_replay() Ido Schimmel
2018-12-07 19:55 ` [PATCH net-next v2 03/12] vxlan: Add vxlan_fdb_clear_offload() Ido Schimmel
2018-12-07 19:55 ` [PATCH net-next v2 04/12] bridge: Add br_fdb_clear_offload() Ido Schimmel
2018-12-07 19:55 ` [PATCH net-next v2 05/12] mlxsw: spectrum: Track NVE type at FIDs Ido Schimmel
2018-12-07 19:55 ` [PATCH net-next v2 06/12] mlxsw: spectrum_switchdev: Publish mlxsw_sp_switchdev_notifier Ido Schimmel
2018-12-07 19:55 ` [PATCH net-next v2 07/12] mlxsw: spectrum_nve: Add mlxsw_sp_nve_ops.fdb_replay Ido Schimmel
2018-12-07 19:55 ` [PATCH net-next v2 08/12] mlxsw: spectrum_nve: Add mlxsw_sp_nve_ops.fdb_clear_offload Ido Schimmel
2018-12-07 19:55 ` [PATCH net-next v2 09/12] mlxsw: spectrum: Add mlxsw_sp_fid_ops.fdb_clear_offload Ido Schimmel
2018-12-07 19:55 ` [PATCH net-next v2 10/12] mlxsw: spectrum_nve: Un/offload FDB on nve_fid_disable/enable Ido Schimmel
2018-12-07 19:55 ` [PATCH net-next v2 11/12] selftests: mlxsw: vxlan: Test FDB un/marking on VXLAN join/leave Ido Schimmel
2018-12-07 19:55 ` [PATCH net-next v2 12/12] selftests: forwarding: Add PVID test case for VXLAN with VLAN-aware bridges Ido Schimmel
2018-12-07 21:05 ` [PATCH net-next v2 00/12] mlxsw: Un/offload FDB on NVE detach/attach David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181207195433.22540-2-idosch@mellanox.com \
    --to=idosch@mellanox.com \
    --cc=bridge@lists.linux-foundation.org \
    --cc=davem@davemloft.net \
    --cc=jiri@mellanox.com \
    --cc=netdev@vger.kernel.org \
    --cc=nikolay@cumulusnetworks.com \
    --cc=petrm@mellanox.com \
    --cc=roopa@cumulusnetworks.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).