net/bonding: fix segfault when creating bonded device
Checks
Commit Message
After the patch below the call to rte_eth_bond_8023ad_agg_selection_set
from probe() segfaults; there is no need to call the function, just set
the mode directly.
Fixes: 391797f04208 ("drivers/bus: move driver assignment to end of probing")
Signed-off-by: Radu Nicolau <radu.nicolau@intel.com>
---
drivers/net/bonding/rte_eth_bond_pmd.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
Comments
31/10/2018 14:59, Radu Nicolau:
> After the patch below the call to rte_eth_bond_8023ad_agg_selection_set
> from probe() segfaults; there is no need to call the function, just set
> the mode directly.
>
> Fixes: 391797f04208 ("drivers/bus: move driver assignment to end of probing")
It would not segfault if you call rte_eth_dev_probing_finish() at the
real end of the probing function. Then the port will be considered not
valid in rte_eth_bond_8023ad_agg_selection_set().
It does not solve your problem but it is more correct.
So I suggest to revert this patch (which was a wrong fix):
http://git.dpdk.org/dpdk/commit/?id=1620175
Then the issue is to allow configuring a port before the end of probing.
This patch is workarounding the public API which checks port validity.
I think it is a good approach.
On 10/31/2018 3:06 PM, Thomas Monjalon wrote:
> 31/10/2018 14:59, Radu Nicolau:
>> After the patch below the call to rte_eth_bond_8023ad_agg_selection_set
>> from probe() segfaults; there is no need to call the function, just set
>> the mode directly.
>>
>> Fixes: 391797f04208 ("drivers/bus: move driver assignment to end of probing")
> It would not segfault if you call rte_eth_dev_probing_finish() at the
> real end of the probing function. Then the port will be considered not
> valid in rte_eth_bond_8023ad_agg_selection_set().
But we need to set the mode, the call to
rte_eth_bond_8023ad_agg_selection_set() assumed before that it will
actually succeed, which is not the case anymore.
I will look at reverting that patch/fix, it is likely not needed anymore
anyway if this patch is applied.
> It does not solve your problem but it is more correct.
> So I suggest to revert this patch (which was a wrong fix):
> http://git.dpdk.org/dpdk/commit/?id=1620175
>
> Then the issue is to allow configuring a port before the end of probing.
> This patch is workarounding the public API which checks port validity.
> I think it is a good approach.
>
In probe() we need to set the mode, and we know that the port is a valid
bonding port, so there is no need to check. Any other call bar the ones
in probe remain the same.
On 10/31/2018 11:06 AM, Thomas Monjalon wrote:
> 31/10/2018 14:59, Radu Nicolau:
>> After the patch below the call to rte_eth_bond_8023ad_agg_selection_set
>> from probe() segfaults; there is no need to call the function, just set
>> the mode directly.
>>
>> Fixes: 391797f04208 ("drivers/bus: move driver assignment to end of probing")
>
> It would not segfault if you call rte_eth_dev_probing_finish() at the
> real end of the probing function. Then the port will be considered not
> valid in rte_eth_bond_8023ad_agg_selection_set().
> It does not solve your problem but it is more correct.
> So I suggest to revert this patch (which was a wrong fix):
> http://git.dpdk.org/dpdk/commit/?id=1620175
Or just make the change proposed in this commit and also move this
section before the probing finish. This is performing initial setup of
the interface and it doesn't need to use the public API to do this.
And this should be done before the public API can access the device.
> Then the issue is to allow configuring a port before the end of probing.
That shouldn't be allowed of course.
> This patch is workarounding the public API which checks port validity.
> I think it is a good approach.
31/10/2018 16:37, Chas Williams:
>
> On 10/31/2018 11:06 AM, Thomas Monjalon wrote:
> > 31/10/2018 14:59, Radu Nicolau:
> >> After the patch below the call to rte_eth_bond_8023ad_agg_selection_set
> >> from probe() segfaults; there is no need to call the function, just set
> >> the mode directly.
> >>
> >> Fixes: 391797f04208 ("drivers/bus: move driver assignment to end of probing")
> >
> > It would not segfault if you call rte_eth_dev_probing_finish() at the
> > real end of the probing function. Then the port will be considered not
> > valid in rte_eth_bond_8023ad_agg_selection_set().
> > It does not solve your problem but it is more correct.
> > So I suggest to revert this patch (which was a wrong fix):
> > http://git.dpdk.org/dpdk/commit/?id=1620175
>
> Or just make the change proposed in this commit and also move this
> section before the probing finish. This is performing initial setup of
> the interface and it doesn't need to use the public API to do this.
> And this should be done before the public API can access the device.
Yes, this is what I proposed, but said differently :)
Please add Fixes: 1620175b400e ("net/bonding: fix invalid port id")
> > Then the issue is to allow configuring a port before the end of probing.
>
> That shouldn't be allowed of course.
>
> > This patch is workarounding the public API which checks port validity.
> > I think it is a good approach.
@@ -3230,10 +3230,9 @@ bond_probe(struct rte_vdev_device *dev)
}
if (internals->mode == BONDING_MODE_8023AD)
- rte_eth_bond_8023ad_agg_selection_set(port_id,
- agg_mode);
+ internals->mode4.agg_selection = agg_mode;
} else {
- rte_eth_bond_8023ad_agg_selection_set(port_id, AGG_STABLE);
+ internals->mode4.agg_selection = AGG_STABLE;
}
RTE_BOND_LOG(INFO, "Create bonded device %s on port %d in mode %u on "