DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] net/bonding: fix bonding in 8023ad mode
@ 2017-08-08 12:56 Jacek Piasecki
  2017-09-04 13:37 ` Radu Nicolau
  0 siblings, 1 reply; 3+ messages in thread
From: Jacek Piasecki @ 2017-08-08 12:56 UTC (permalink / raw)
  To: dev; +Cc: danielx.t.mrzyglod, michalx.k.jastrzebski, Jacek Piasecki

This patch blocks possibility to set master bonding by
rte_eth_bond_mode_set() in 802.3ad mode, as the API
doesn't prevent this.

Fixes: 6d72657ce379 ("net/bonding: add other aggregator modes")
Cc: danielx.t.mrzyglod@intel.com

Signed-off-by: Jacek Piasecki <jacekx.piasecki@intel.com>
---
 drivers/net/bonding/rte_eth_bond_api.c     | 29 ++++++++++++++++++++++++++++-
 drivers/net/bonding/rte_eth_bond_private.h |  3 +++
 2 files changed, 31 insertions(+), 1 deletion(-)

diff --git a/drivers/net/bonding/rte_eth_bond_api.c b/drivers/net/bonding/rte_eth_bond_api.c
index de1d9e0..d6aaf07 100644
--- a/drivers/net/bonding/rte_eth_bond_api.c
+++ b/drivers/net/bonding/rte_eth_bond_api.c
@@ -63,6 +63,25 @@ valid_bonded_port_id(uint8_t port_id)
 }
 
 int
+check_for_master_bonded_ethdev(const struct rte_eth_dev *eth_dev)
+{
+	int i;
+	struct bond_dev_private *internals;
+
+	if (check_for_bonded_ethdev(eth_dev) != 0)
+		return 0;
+
+	internals = eth_dev->data->dev_private;
+
+	/* Check if any of slave devices is a bonded device */
+	for (i = 0; i < internals->slave_count; i++)
+		if (valid_bonded_port_id(internals->slaves[i].port_id) == 0)
+			return 1;
+
+	return 0;
+}
+
+int
 valid_slave_port_id(uint8_t port_id, uint8_t mode)
 {
 	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -1);
@@ -490,10 +509,18 @@ rte_eth_bond_slave_remove(uint8_t bonded_port_id, uint8_t slave_port_id)
 int
 rte_eth_bond_mode_set(uint8_t bonded_port_id, uint8_t mode)
 {
+	struct rte_eth_dev *bonded_eth_dev;
+
 	if (valid_bonded_port_id(bonded_port_id) != 0)
 		return -1;
 
-	return bond_ethdev_mode_set(&rte_eth_devices[bonded_port_id], mode);
+	bonded_eth_dev = &rte_eth_devices[bonded_port_id];
+
+	if (check_for_master_bonded_ethdev(bonded_eth_dev) != 0 &&
+			mode == BONDING_MODE_8023AD)
+		return -1;
+
+	return bond_ethdev_mode_set(bonded_eth_dev, mode);
 }
 
 int
diff --git a/drivers/net/bonding/rte_eth_bond_private.h b/drivers/net/bonding/rte_eth_bond_private.h
index 1fe6ff8..4dd7e5f 100644
--- a/drivers/net/bonding/rte_eth_bond_private.h
+++ b/drivers/net/bonding/rte_eth_bond_private.h
@@ -184,6 +184,9 @@ extern const struct eth_dev_ops default_dev_ops;
 int
 check_for_bonded_ethdev(const struct rte_eth_dev *eth_dev);
 
+int
+check_for_master_bonded_ethdev(const struct rte_eth_dev *eth_dev);
+
 /* Search given slave array to find position of given id.
  * Return slave pos or slaves_count if not found. */
 static inline uint8_t
-- 
2.7.4

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [dpdk-dev] [PATCH] net/bonding: fix bonding in 8023ad mode
  2017-08-08 12:56 [dpdk-dev] [PATCH] net/bonding: fix bonding in 8023ad mode Jacek Piasecki
@ 2017-09-04 13:37 ` Radu Nicolau
  2017-12-02  1:25   ` Ferruh Yigit
  0 siblings, 1 reply; 3+ messages in thread
From: Radu Nicolau @ 2017-09-04 13:37 UTC (permalink / raw)
  To: dev


On 8/8/2017 1:56 PM, Jacek Piasecki wrote:
> This patch blocks possibility to set master bonding by
> rte_eth_bond_mode_set() in 802.3ad mode, as the API
> doesn't prevent this.
>
> Fixes: 6d72657ce379 ("net/bonding: add other aggregator modes")
> Cc: danielx.t.mrzyglod@intel.com
>
> Signed-off-by: Jacek Piasecki <jacekx.piasecki@intel.com>
Reviewed-by:  Radu Nicolau <radu.nicolau@intel.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [dpdk-dev] [PATCH] net/bonding: fix bonding in 8023ad mode
  2017-09-04 13:37 ` Radu Nicolau
@ 2017-12-02  1:25   ` Ferruh Yigit
  0 siblings, 0 replies; 3+ messages in thread
From: Ferruh Yigit @ 2017-12-02  1:25 UTC (permalink / raw)
  To: Nicolau, Radu, Daniel Mrzyglod; +Cc: DPDK

On 9/4/2017 6:37 AM, radu.nicolau at intel.com (Radu Nicolau) wrote:
> On 8/8/2017 1:56 PM, Jacek Piasecki wrote:
>> This patch blocks possibility to set master bonding by
>> rte_eth_bond_mode_set() in 802.3ad mode, as the API
>> doesn't prevent this.
>>
>> Fixes: 6d72657ce379 ("net/bonding: add other aggregator modes")
>> Cc: danielx.t.mrzyglod at intel.com
>>
>> Signed-off-by: Jacek Piasecki <jacekx.piasecki at intel.com>
> Reviewed-by:  Radu Nicolau <radu.nicolau at intel.com>

Applied to dpdk-next-net/master, thanks.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-12-02  1:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-08 12:56 [dpdk-dev] [PATCH] net/bonding: fix bonding in 8023ad mode Jacek Piasecki
2017-09-04 13:37 ` Radu Nicolau
2017-12-02  1:25   ` Ferruh Yigit

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).