bonding: fix crash when no slave devices
Subsystems (2)
PATCH 1/1 bonding: fix crash when no slave devices
If a bonded device is created when there are no slave devices there is loop in bond_ethdev_promiscous_enable() which results in a segmentation fault.
I have applied a similar fix to bond_ethdev_promiscous_disable() where a similar loop could occur.
--- drivers/net/bonding/rte_eth_bond_pmd.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/bonding/rte_eth_bond_pmd.c +4 -2
@@ -1870,7 +1870,8 @@ bond_ethdev_promiscuous_enable(struct rte_eth_dev *eth_dev)case BONDING_MODE_TLB :case BONDING_MODE_ALB :default : -rte_eth_promiscuous_enable (internals->current_primary_port); +if (internals->slave_count >0 ) +rte_eth_promiscuous_enable (internals->current_primary_port); } }
@@ -1898,7 +1899,8 @@ bond_ethdev_promiscuous_disable(struct rte_eth_dev *dev)case BONDING_MODE_TLB :case BONDING_MODE_ALB :default : -rte_eth_promiscuous_disable (internals->current_primary_port); +if (internals->slave_count >0 ) +rte_eth_promiscuous_disable (internals->current_primary_port); } }
Signature · 1 line
2.6.3
Quoted 28 lines · Bernard Iremonger
If a bonded device is created when there are no slave devices there is loop in
bond_ethdev_promiscous_enable()which results in a segmentation fault.
I have applied a similar fix tobond_ethdev_promiscous_disable()where a similar loop could occur.Fixes 2efb58cbab6e ("bond: new link bonding library")Signed-off-by Bernard Iremonger <[email protected]>--- drivers/net/bonding/rte_eth_bond_pmd.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)drivers/net/bonding/rte_eth_bond_pmd.c +2
-1@@ -1870,7 +1870,8 @@ bond_ethdev_promiscuous_enable(struct rte_eth_dev *eth_dev)case BONDING_MODE_TLB :case BONDING_MODE_ALB :default : -rte_eth_promiscuous_enable (internals->current_primary_port); +if (internals->slave_count >0 ) +rte_eth_promiscuous_enable (internals->current_primary_port); } }
drivers/net/bonding/rte_eth_bond_pmd.c bond_ethdev_promiscuous_disable(struct rte_eth_dev *dev) · line 1906
Quoted 9 lines
drivers/net/bonding/rte_eth_bond_pmd.c +2
-1@@ -1898,7 +1899,8 @@ bond_ethdev_promiscuous_disable(struct rte_eth_dev *dev)case BONDING_MODE_TLB :case BONDING_MODE_ALB :default : -rte_eth_promiscuous_disable (internals->current_primary_port); +if (internals->slave_count >0 ) +rte_eth_promiscuous_disable (internals->current_primary_port); } }
Hi Bernard,
The reason of this crash is when there is no slave, the value of current_primary_port is 0, which is valid port_id, is this correct?
Does it make sense, instead of slave_count check, to make default current_primary_port value a non valid port_id, like -1, so is_valid_port() check catches it to prevents crash? For this and any other cases.
Thanks,
ferruh
Hi Ferruh,
Quoted 53 lines
-----Original Message-----
From: Yigit, Ferruh
Sent: Friday, March 4, 2016 5:14 PM
To: Iremonger, Bernard <[email protected]>; [email protected]
Subject: Re: [dpdk-dev] [PATCH] bonding: fix crash when no slave devicesdrivers/net/bonding/rte_eth_bond_pmd.c bond_ethdev_promiscuous_enable(struct
Quoted 18 lines · Bernard Iremonger
If a bonded device is created when there are no slave devices there is loop in
bond_ethdev_promiscous_enable()which results in a segmentation fault.
I have applied a similar fix tobond_ethdev_promiscous_disable()where a similar loop could occur.Fixes 2efb58cbab6e ("bond: new link bonding library")Signed-off-by Bernard Iremonger <[email protected]>--- drivers/net/bonding/rte_eth_bond_pmd.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)drivers/net/bonding/rte_eth_bond_pmd.c +0
-0@@ -1870,7 +1870,8 @@ bond_ethdev_promiscuous_enable(struct
rte_eth_dev*eth_dev)drivers/net/bonding/rte_eth_bond_pmd.c bond_ethdev_promiscuous_disable(struct
Quoted 12 lines
drivers/net/bonding/rte_eth_bond_pmd.c +2
-1case BONDING_MODE_TLB :case BONDING_MODE_ALB :default : -rte_eth_promiscuous_enable (internals- current_primary_port); +if (internals->slave_count >0 ) +rte_eth_promiscuous_enable (internals- current_primary_port); }}
drivers/net/bonding/rte_eth_bond_pmd.c +0
-0@@ -1898,7 +1899,8 @@ bond_ethdev_promiscuous_disable(struct
rte_eth_dev*dev)Quoted 9 lines
drivers/net/bonding/rte_eth_bond_pmd.c +2
-1case BONDING_MODE_TLB :case BONDING_MODE_ALB :default : -rte_eth_promiscuous_disable (internals- current_primary_port); +if (internals->slave_count >0 ) +rte_eth_promiscuous_disable (internals- current_primary_port); }Quoted 3 lines
}
Hi Bernard,
Quoted 2 lines
The reason of this crash is when there is no slave, the value of
current_primary_portis 0, which is validport_id, is this correct?
Yes.
Quoted 7 lines
Does it make sense, instead of
slave_countcheck, to make defaultcurrent_primary_portvalue a non validport_id, like -1, sois_valid_port()check catches it to prevents crash? For this and any other cases.Thanks,
Ferruh
I will try initializing current_primary_port to -1 and see if this helps. Thanks for reviewing.
Regards,
Bernard.
PATCH v2 1/1 bonding: fix crash when no slave devices
In reply to Bernard IremongerIf a bonded device is created when there are no slave devices there is loop in bond_ethdev_promiscous_enable() which results in a segmentation fault.
The solution is to initialise the current_primary_port to an invalid port value when the bonded port is created.
---
Changes in V2:
Set current_primary_port to an invalid value.
drivers/net/bonding/rte_eth_bond_api.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/bonding/rte_eth_bond_api.c +1 -1
@@ -231,7 +231,7 @@ rte_eth_bond_create(const char *name, uint8_t mode, uint8_t socket_id) internals->port_id = eth_dev->data->port_id; internals->mode =BONDING_MODE_INVALID ; - internals->current_primary_port =0 ; + internals->current_primary_port =RTE_MAX_ETHPORTS +1 ; internals->balance_xmit_policy =BALANCE_XMIT_POLICY_LAYER2 ; internals->xmit_hash = xmit_l2_hash; internals->user_defined_mac =0 ;
Signature · 1 line
2.6.3
Quoted 9 lines · Bernard Iremonger
If a bonded device is created when there are no slave devices there is loop in
bond_ethdev_promiscous_enable()which results in a segmentation fault.The solution is to initialise the
current_primary_portto an invalid port value when the bonded port is created.Fixes 2efb58cbab6e ("bond: new link bonding library")Signed-off-by Bernard Iremonger <[email protected]>
Bruce Richardson
AppliedQuoted 5 lines · Ferruh Yigit
Quoted 4 lines · Bernard Iremonger
If a bonded device is created when there are no slave devices there is loop in
bond_ethdev_promiscous_enable()which results in a segmentation fault.
Quoted 7 lines
Quoted 5 lines
The solution is to initialise the
current_primary_portto an invalid port value when the bonded port is created.Fixes 2efb58cbab6e ("bond: new link bonding library")Signed-off-by Bernard Iremonger <[email protected]>Acked-by Ferruh Yigit <[email protected]>
Applied to dpdk-next-net/rel_16_04
/Bruce