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: <20171106211153.26529-5-vivien.didelot@savoirfairelinux.com>
Date:   Mon,  6 Nov 2017 16:11:46 -0500
From:   Vivien Didelot <vivien.didelot@...oirfairelinux.com>
To:     netdev@...r.kernel.org
Cc:     linux-kernel@...r.kernel.org, kernel@...oirfairelinux.com,
        "David S. Miller" <davem@...emloft.net>,
        Florian Fainelli <f.fainelli@...il.com>,
        Andrew Lunn <andrew@...n.ch>,
        Vivien Didelot <vivien.didelot@...oirfairelinux.com>
Subject: [PATCH net-next 04/11] net: dsa: setup and teardown tree

This commit provides better scope for the DSA tree setup and teardown
functions. It renames the "applied" bool to "setup" and print a message
when the tree is setup, as it is done during teardown.

At the same time, check dst->setup in dsa_tree_setup, where it is set to
true.

Signed-off-by: Vivien Didelot <vivien.didelot@...oirfairelinux.com>
---
 include/net/dsa.h |  2 +-
 net/dsa/dsa2.c    | 32 ++++++++++++++++++--------------
 2 files changed, 19 insertions(+), 15 deletions(-)

diff --git a/include/net/dsa.h b/include/net/dsa.h
index 2a8613b5a23d..6c239257309b 100644
--- a/include/net/dsa.h
+++ b/include/net/dsa.h
@@ -122,7 +122,7 @@ struct dsa_switch_tree {
 	struct kref refcount;
 
 	/* Has this tree been applied to the hardware? */
-	bool applied;
+	bool setup;
 
 	/*
 	 * Configuration data for the platform device that owns
diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c
index c9b50339fcac..1a8df0a177b5 100644
--- a/net/dsa/dsa2.c
+++ b/net/dsa/dsa2.c
@@ -486,12 +486,18 @@ static void dsa_tree_teardown_master(struct dsa_switch_tree *dst)
 	return dsa_master_teardown(master);
 }
 
-static int dsa_dst_apply(struct dsa_switch_tree *dst)
+static int dsa_tree_setup(struct dsa_switch_tree *dst)
 {
 	struct dsa_switch *ds;
 	u32 index;
 	int err;
 
+	if (dst->setup) {
+		pr_err("DSA: tree %d already setup! Disjoint trees?\n",
+		       dst->index);
+		return -EEXIST;
+	}
+
 	err = dsa_tree_setup_default_cpu(dst);
 	if (err)
 		return err;
@@ -510,17 +516,19 @@ static int dsa_dst_apply(struct dsa_switch_tree *dst)
 	if (err)
 		return err;
 
-	dst->applied = true;
+	dst->setup = true;
+
+	pr_info("DSA: tree %d setup\n", dst->index);
 
 	return 0;
 }
 
-static void dsa_dst_unapply(struct dsa_switch_tree *dst)
+static void dsa_tree_teardown(struct dsa_switch_tree *dst)
 {
 	struct dsa_switch *ds;
 	u32 index;
 
-	if (!dst->applied)
+	if (!dst->setup)
 		return;
 
 	dsa_tree_teardown_master(dst);
@@ -535,8 +543,9 @@ static void dsa_dst_unapply(struct dsa_switch_tree *dst)
 
 	dsa_tree_teardown_default_cpu(dst);
 
-	pr_info("DSA: tree %d unapplied\n", dst->index);
-	dst->applied = false;
+	pr_info("DSA: tree %d torn down\n", dst->index);
+
+	dst->setup = false;
 }
 
 static void dsa_tree_remove_switch(struct dsa_switch_tree *dst,
@@ -794,14 +803,9 @@ static int _dsa_register_switch(struct dsa_switch *ds)
 	if (err == 1)
 		return 0;
 
-	if (dst->applied) {
-		pr_info("DSA: Disjoint trees?\n");
-		return -EINVAL;
-	}
-
-	err = dsa_dst_apply(dst);
+	err = dsa_tree_setup(dst);
 	if (err) {
-		dsa_dst_unapply(dst);
+		dsa_tree_teardown(dst);
 		goto out_del_dst;
 	}
 
@@ -852,7 +856,7 @@ static void _dsa_unregister_switch(struct dsa_switch *ds)
 	struct dsa_switch_tree *dst = ds->dst;
 	unsigned int index = ds->index;
 
-	dsa_dst_unapply(dst);
+	dsa_tree_teardown(dst);
 
 	dsa_tree_remove_switch(dst, index);
 }
-- 
2.14.3

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ