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: <20211208034040.14457-2-ansuelsmth@gmail.com>
Date:   Wed,  8 Dec 2021 04:40:33 +0100
From:   Ansuel Smith <ansuelsmth@...il.com>
To:     Andrew Lunn <andrew@...n.ch>,
        Vivien Didelot <vivien.didelot@...il.com>,
        Florian Fainelli <f.fainelli@...il.com>,
        Vladimir Oltean <olteanv@...il.com>,
        "David S. Miller" <davem@...emloft.net>,
        Jakub Kicinski <kuba@...nel.org>, linux-kernel@...r.kernel.org,
        netdev@...r.kernel.org
Cc:     Ansuel Smith <ansuelsmth@...il.com>
Subject: [net-next RFC PATCH v2 1/8] net: das: Introduce support for tagger private data control

Introduce 2 new function for the tagger ops to permit the tagger to
allocate private data. This is useful for case where the tagger receive
some data that should be by the switch driver or require some special
handling for some special packet (example Ethernet mdio packet)

The tagger will use the dsa port priv to store his priv data.

connect() is used to allocate the private data. It's the tagger choice
how to allocate the data to the different ports.
disconnect() will free the priv data in the dsa port.

On switch setup the connect() ops is called.
On tagger change the disconnect() is called, the tagger will free the
priv data in dsa port and a connect() is called to allocate the new priv
data (if the new tagger requires it)

Signed-off-by: Ansuel Smith <ansuelsmth@...il.com>
---
 include/net/dsa.h |  3 +++
 net/dsa/dsa2.c    | 26 ++++++++++++++++++++++++++
 2 files changed, 29 insertions(+)

diff --git a/include/net/dsa.h b/include/net/dsa.h
index 8ca9d50cbbc2..33391d74be5c 100644
--- a/include/net/dsa.h
+++ b/include/net/dsa.h
@@ -82,8 +82,11 @@ enum dsa_tag_protocol {
 };
 
 struct dsa_switch;
+struct dsa_switch_tree;
 
 struct dsa_device_ops {
+	int (*connect)(struct dsa_switch_tree *dst);
+	void (*disconnect)(struct dsa_switch_tree *dst);
 	struct sk_buff *(*xmit)(struct sk_buff *skb, struct net_device *dev);
 	struct sk_buff *(*rcv)(struct sk_buff *skb, struct net_device *dev);
 	void (*flow_dissect)(const struct sk_buff *skb, __be16 *proto,
diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c
index 826957b6442b..15566c5ae8ae 100644
--- a/net/dsa/dsa2.c
+++ b/net/dsa/dsa2.c
@@ -1043,6 +1043,20 @@ static void dsa_tree_teardown_lags(struct dsa_switch_tree *dst)
 	kfree(dst->lags);
 }
 
+static int dsa_tree_bind_tag_proto(struct dsa_switch_tree *dst)
+{
+	const struct dsa_device_ops *tag_ops = dst->tag_ops;
+	int err;
+
+	if (tag_ops->connect) {
+		err = tag_ops->connect(dst);
+		if (err)
+			return err;
+	}
+
+	return 0;
+}
+
 static int dsa_tree_setup(struct dsa_switch_tree *dst)
 {
 	bool complete;
@@ -1066,6 +1080,10 @@ static int dsa_tree_setup(struct dsa_switch_tree *dst)
 	if (err)
 		goto teardown_cpu_ports;
 
+	err = dsa_tree_bind_tag_proto(dst);
+	if (err)
+		goto teardown_switches;
+
 	err = dsa_tree_setup_master(dst);
 	if (err)
 		goto teardown_switches;
@@ -1155,13 +1173,21 @@ int dsa_tree_change_tag_proto(struct dsa_switch_tree *dst,
 	if (err)
 		goto out_unwind_tagger;
 
+	if (dst->tag_ops->disconnect)
+		dst->tag_ops->disconnect(dst);
+
 	dst->tag_ops = tag_ops;
 
+	err = dsa_tree_bind_tag_proto(dst);
+	if (err)
+		goto out_unwind_tagger;
+
 	rtnl_unlock();
 
 	return 0;
 
 out_unwind_tagger:
+	dst->tag_ops = old_tag_ops;
 	info.tag_ops = old_tag_ops;
 	dsa_tree_notify(dst, DSA_NOTIFIER_TAG_PROTO, &info);
 out_unlock:
-- 
2.32.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ