lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <7133d2507c0619e7727c1c44250241fdc9625d2c.1704449760.git.ante.knezic@helmholz.de>
Date: Fri, 5 Jan 2024 11:46:15 +0100
From: Ante Knezic <ante.knezic@...mholz.de>
To: <netdev@...r.kernel.org>
CC: <andrew@...n.ch>, <f.fainelli@...il.com>, <olteanv@...il.com>,
	<davem@...emloft.net>, <edumazet@...gle.com>, <kuba@...nel.org>,
	<pabeni@...hat.com>, <ante.knezic@...mholz.de>
Subject: [RFC PATCH net-next 2/6] net: dsa: add groundwork for cross chip mirroring

cross chip mirroring require routing mirrored data
from source to destination switch. Add the necessary
groundwork.

Signed-off-by: Ante Knezic <ante.knezic@...mholz.de>
---
 include/net/dsa.h | 18 ++++++++++++++++++
 net/dsa/dsa.c     | 14 ++++++++++++++
 2 files changed, 32 insertions(+)

diff --git a/include/net/dsa.h b/include/net/dsa.h
index c1fbe89f8f81..aa0e97150bc3 100644
--- a/include/net/dsa.h
+++ b/include/net/dsa.h
@@ -162,6 +162,9 @@ struct dsa_switch_tree {
 
 	/* Track the largest switch index within a tree */
 	unsigned int last_switch;
+
+	/* List of port mirror routes */
+	struct list_head mirrors;
 };
 
 /* LAG IDs are one-based, the dst->lags array is zero-based */
@@ -368,6 +371,21 @@ struct dsa_vlan {
 	struct list_head list;
 };
 
+struct dsa_mirror {
+	struct list_head list;
+	const struct dsa_port *from_dp;
+	const struct dsa_port *to_dp;
+	bool ingress;
+	struct list_head route;
+};
+
+struct dsa_route {
+	struct list_head list;
+	int sw_index;
+	int from_local_p;
+	int to_local_p;
+};
+
 struct dsa_switch {
 	struct device *dev;
 
diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c
index ac7be864e80d..304c7100cf55 100644
--- a/net/dsa/dsa.c
+++ b/net/dsa/dsa.c
@@ -228,6 +228,8 @@ static struct dsa_switch_tree *dsa_tree_alloc(int index)
 
 	kref_init(&dst->refcount);
 
+	INIT_LIST_HEAD(&dst->mirrors);
+
 	return dst;
 }
 
@@ -923,6 +925,8 @@ static int dsa_tree_setup(struct dsa_switch_tree *dst)
 static void dsa_tree_teardown(struct dsa_switch_tree *dst)
 {
 	struct dsa_link *dl, *next;
+	struct dsa_mirror *dm, *m;
+	struct dsa_route *dr, *r;
 
 	if (!dst->setup)
 		return;
@@ -942,6 +946,16 @@ static void dsa_tree_teardown(struct dsa_switch_tree *dst)
 		kfree(dl);
 	}
 
+	list_for_each_entry_safe(dm, m, &dst->mirrors, list) {
+		list_for_each_entry_safe(dr, r, &dm->route, list) {
+			list_del(&dr->list);
+			kfree(dr);
+		}
+
+		list_del(&dm->list);
+		kfree(dm);
+	}
+
 	pr_info("DSA: tree %d torn down\n", dst->index);
 
 	dst->setup = false;
-- 
2.11.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ