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: <1428907677-27204-2-git-send-email-simon.horman@netronome.com>
Date:	Mon, 13 Apr 2015 15:47:54 +0900
From:	Simon Horman <simon.horman@...ronome.com>
To:	Jiri Pirko <jiri@...nulli.us>, Scott Feldman <sfeldma@...il.com>
Cc:	netdev@...r.kernel.org, Simon Horman <simon.horman@...ronome.com>
Subject: [PATCH/RFC net-next 1/4] rocker: add helper for setting untagged VLAN

Add a helper for setting setting untagged VLAN and use it twice.

Also add a helper for returning the uppermost device of a port:
its bridge device if present otherwise the port's device. This seems
to be clean enough in the context of this patch. I also plan
to re-use it in a subsequent patch.

Signed-off-by: Simon Horman <simon.horman@...ronome.com>
---
 drivers/net/ethernet/rocker/rocker.c | 41 ++++++++++++++++++++----------------
 1 file changed, 23 insertions(+), 18 deletions(-)

diff --git a/drivers/net/ethernet/rocker/rocker.c b/drivers/net/ethernet/rocker/rocker.c
index a87b177bd723..955cf0ae33a7 100644
--- a/drivers/net/ethernet/rocker/rocker.c
+++ b/drivers/net/ethernet/rocker/rocker.c
@@ -325,6 +325,12 @@ static bool rocker_port_is_bridged(struct rocker_port *rocker_port)
 	return !!rocker_port->bridge_dev;
 }
 
+static struct net_device *rocker_port_uppermost_dev(struct rocker_port *rocker_port)
+{
+	return rocker_port_is_bridged(rocker_port) ?
+		rocker_port->bridge_dev : rocker_port->dev;
+}
+
 struct rocker_wait {
 	wait_queue_head_t wait;
 	bool done;
@@ -3758,6 +3764,21 @@ not_found:
 	spin_unlock_irqrestore(&rocker->internal_vlan_tbl_lock, lock_flags);
 }
 
+static int rocker_port_set_untagged_vlan(struct rocker_port *rocker_port)
+{
+	int err;
+	int ifindex;
+
+	err = rocker_port_vlan(rocker_port, ROCKER_OP_FLAG_REMOVE, 0);
+	if (err)
+		return err;
+
+	ifindex = rocker_port_uppermost_dev(rocker_port)->ifindex;
+	rocker_port->internal_vlan_id =
+		rocker_port_internal_vlan_id_get(rocker_port, ifindex);
+	return rocker_port_vlan(rocker_port, 0, 0);
+}
+
 static int rocker_port_fib_ipv4(struct rocker_port *rocker_port, __be32 dst,
 				int dst_len, struct fib_info *fi, u32 tb_id,
 				int flags)
@@ -4888,21 +4909,12 @@ static bool rocker_port_dev_check(struct net_device *dev)
 static int rocker_port_bridge_join(struct rocker_port *rocker_port,
 				   struct net_device *bridge)
 {
-	int err;
-
 	rocker_port_internal_vlan_id_put(rocker_port,
 					 rocker_port->dev->ifindex);
 
 	rocker_port->bridge_dev = bridge;
 
-	/* Use bridge internal VLAN ID for untagged pkts */
-	err = rocker_port_vlan(rocker_port, ROCKER_OP_FLAG_REMOVE, 0);
-	if (err)
-		return err;
-	rocker_port->internal_vlan_id =
-		rocker_port_internal_vlan_id_get(rocker_port,
-						 bridge->ifindex);
-	return rocker_port_vlan(rocker_port, 0, 0);
+	return rocker_port_set_untagged_vlan(rocker_port);
 }
 
 static int rocker_port_bridge_leave(struct rocker_port *rocker_port)
@@ -4914,14 +4926,7 @@ static int rocker_port_bridge_leave(struct rocker_port *rocker_port)
 
 	rocker_port->bridge_dev = NULL;
 
-	/* Use port internal VLAN ID for untagged pkts */
-	err = rocker_port_vlan(rocker_port, ROCKER_OP_FLAG_REMOVE, 0);
-	if (err)
-		return err;
-	rocker_port->internal_vlan_id =
-		rocker_port_internal_vlan_id_get(rocker_port,
-						 rocker_port->dev->ifindex);
-	err = rocker_port_vlan(rocker_port, 0, 0);
+	err = rocker_port_set_untagged_vlan(rocker_port);
 	if (err)
 		return err;
 
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ