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-next>] [day] [month] [year] [list]
Date:   Sat, 22 Oct 2022 15:01:58 -0700
From:   Steven Hsieh <steven.hsieh@...adcom.com>
To:     Steven Hsieh <steven.hsieh@...adcom.com>
Cc:     Andy Gospodarek <andy@...yhouse.net>,
        "David S. Miller" <davem@...emloft.net>,
        Eric Dumazet <edumazet@...gle.com>,
        Jakub Kicinski <kuba@...nel.org>,
        Jay Vosburgh <j.vosburgh@...il.com>,
        Paolo Abeni <pabeni@...hat.com>,
        Veaceslav Falico <vfalico@...il.com>,
        linux-kernel@...r.kernel.org, netdev@...r.kernel.org
Subject: [PATCH net-next] bonding: 3ad: bonding of links with different data rate

Current Linux Bonding driver supports IEEE802.3ad-2000.
Operation across multiple data rates—
All links in a Link Aggregation Group operate at the same data rate.

In IEEE802.1AX-2014
Aggregation of links of different data rates is not prohibited
nor required by this standard.

This patch provides configuration option to allow aggregation of links
with different speed.

Enhancement is disabled by default and can be enabled thru
 echo 1 > /sys/class/net/bond*/bonding/async_linkspeed

Signed-off-by: Steven Hsieh <steven.hsieh@...adcom.com>

---

 drivers/net/bonding/bond_3ad.c     | 12 +++++++++++-
 drivers/net/bonding/bond_options.c | 26 ++++++++++++++++++++++++++
 drivers/net/bonding/bond_sysfs.c   | 15 +++++++++++++++
 include/net/bond_options.h         |  1 +
 include/net/bonding.h              |  1 +
 5 files changed, 54 insertions(+), 1 deletion(-)

diff --git a/drivers/net/bonding/bond_3ad.c b/drivers/net/bonding/bond_3ad.c
index e58a1e0cadd2..f5689dae88c3 100644
--- a/drivers/net/bonding/bond_3ad.c
+++ b/drivers/net/bonding/bond_3ad.c
@@ -385,6 +385,13 @@ static void __ad_actor_update_port(struct port *port)
 	port->actor_system_priority = BOND_AD_INFO(bond).system.sys_priority;
 }
 
+static inline u32 __get_agg_async_linkspeed(struct port *port)
+{
+	const struct bonding *bond = bond_get_bond_by_slave(port->slave);
+
+	return (bond) ? bond->params.async_linkspeed : 0;
+}
+
 /* Conversions */
 
 /**
@@ -2476,7 +2483,10 @@ static void ad_update_actor_keys(struct port *port, bool reset)
 		speed = __get_link_speed(port);
 		ospeed = (old_oper_key & AD_SPEED_KEY_MASKS) >> 1;
 		duplex = __get_duplex(port);
-		port->actor_admin_port_key |= (speed << 1) | duplex;
+		if (__get_agg_async_linkspeed(port))
+			port->actor_admin_port_key |= duplex;
+		else
+			port->actor_admin_port_key |= (speed << 1) | duplex;
 	}
 	port->actor_oper_port_key = port->actor_admin_port_key;
 
diff --git a/drivers/net/bonding/bond_options.c b/drivers/net/bonding/bond_options.c
index 3498db1c1b3c..cd871075b85c 100644
--- a/drivers/net/bonding/bond_options.c
+++ b/drivers/net/bonding/bond_options.c
@@ -84,6 +84,8 @@ static int bond_option_ad_user_port_key_set(struct bonding *bond,
 					    const struct bond_opt_value *newval);
 static int bond_option_missed_max_set(struct bonding *bond,
 				      const struct bond_opt_value *newval);
+static int bond_option_async_linkspeed_set(struct bonding *bond,
+					   const struct bond_opt_value *newval);
 
 
 static const struct bond_opt_value bond_mode_tbl[] = {
@@ -226,6 +228,12 @@ static const struct bond_opt_value bond_missed_max_tbl[] = {
 	{ NULL,		-1,	0},
 };
 
+static const struct bond_opt_value bond_async_linkspeed_tbl[] = {
+	{ "off", 0,  BOND_VALFLAG_DEFAULT},
+	{ "on",  1,  0},
+	{ NULL,  -1, 0},
+};
+
 static const struct bond_option bond_opts[BOND_OPT_LAST] = {
 	[BOND_OPT_MODE] = {
 		.id = BOND_OPT_MODE,
@@ -360,6 +368,14 @@ static const struct bond_option bond_opts[BOND_OPT_LAST] = {
 		.values = bond_num_peer_notif_tbl,
 		.set = bond_option_num_peer_notif_set
 	},
+	[BOND_OPT_ASYNC_LINKSPEED] = {
+		.id = BOND_OPT_ASYNC_LINKSPEED,
+		.name = "async_linkspeed",
+		.desc = "Enable aggregation of links of different data rates",
+		.unsuppmodes = BOND_MODE_ALL_EX(BIT(BOND_MODE_8023AD)),
+		.values = bond_async_linkspeed_tbl,
+		.set = bond_option_async_linkspeed_set
+	},
 	[BOND_OPT_MIIMON] = {
 		.id = BOND_OPT_MIIMON,
 		.name = "miimon",
@@ -1702,3 +1718,13 @@ static int bond_option_ad_user_port_key_set(struct bonding *bond,
 	bond->params.ad_user_port_key = newval->value;
 	return 0;
 }
+
+static int bond_option_async_linkspeed_set(struct bonding *bond,
+					   const struct bond_opt_value *newval)
+{
+	netdev_info(bond->dev, "Setting async_linkspeed to %s (%llu)\n",
+		    newval->string, newval->value);
+	bond->params.async_linkspeed = newval->value;
+
+	return 0;
+}
diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c
index 8996bd0a194a..6a0b4e1098af 100644
--- a/drivers/net/bonding/bond_sysfs.c
+++ b/drivers/net/bonding/bond_sysfs.c
@@ -753,6 +753,20 @@ static ssize_t bonding_show_ad_user_port_key(struct device *d,
 static DEVICE_ATTR(ad_user_port_key, 0644,
 		   bonding_show_ad_user_port_key, bonding_sysfs_store_option);
 
+static ssize_t bonding_show_async_linkspeed(struct device *d,
+					    struct device_attribute *attr,
+					    char *buf)
+{
+	struct bonding *bond = to_bond(d);
+	const struct bond_opt_value *val;
+
+	val = bond_opt_get_val(BOND_OPT_ASYNC_LINKSPEED, bond->params.async_linkspeed);
+
+	return sprintf(buf, "%s %d\n", val->string, bond->params.async_linkspeed);
+}
+static DEVICE_ATTR(async_linkspeed, (00400 | 00040 | 00004) | 00200, /*S_IRUGO | S_IWUSR,*/
+		   bonding_show_async_linkspeed, bonding_sysfs_store_option);
+
 static struct attribute *per_bond_attrs[] = {
 	&dev_attr_slaves.attr,
 	&dev_attr_mode.attr,
@@ -792,6 +806,7 @@ static struct attribute *per_bond_attrs[] = {
 	&dev_attr_ad_actor_system.attr,
 	&dev_attr_ad_user_port_key.attr,
 	&dev_attr_arp_missed_max.attr,
+	&dev_attr_async_linkspeed.attr,
 	NULL,
 };
 
diff --git a/include/net/bond_options.h b/include/net/bond_options.h
index 69292ecc0325..5b33f8b3e1c7 100644
--- a/include/net/bond_options.h
+++ b/include/net/bond_options.h
@@ -76,6 +76,7 @@ enum {
 	BOND_OPT_MISSED_MAX,
 	BOND_OPT_NS_TARGETS,
 	BOND_OPT_PRIO,
+	BOND_OPT_ASYNC_LINKSPEED,
 	BOND_OPT_LAST
 };
 
diff --git a/include/net/bonding.h b/include/net/bonding.h
index e999f851738b..5d83daab0669 100644
--- a/include/net/bonding.h
+++ b/include/net/bonding.h
@@ -146,6 +146,7 @@ struct bond_params {
 	int lp_interval;
 	int packets_per_slave;
 	int tlb_dynamic_lb;
+	int async_linkspeed;
 	struct reciprocal_value reciprocal_packets_per_slave;
 	u16 ad_actor_sys_prio;
 	u16 ad_user_port_key;
-- 
2.34.1


-- 
This electronic communication and the information and any files transmitted 
with it, or attached to it, are confidential and are intended solely for 
the use of the individual or entity to whom it is addressed and may contain 
information that is confidential, legally privileged, protected by privacy 
laws, or otherwise restricted from disclosure to anyone else. If you are 
not the intended recipient or the person responsible for delivering the 
e-mail to the intended recipient, you are hereby notified that any use, 
copying, distributing, dissemination, forwarding, printing, or copying of 
this e-mail is strictly prohibited. If you received this e-mail in error, 
please return the e-mail to the sender, delete it from your computer, and 
destroy any printed copy of it.

Download attachment "smime.p7s" of type "application/pkcs7-signature" (4209 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ