[v2] ethdev: do not allow to close started device
Checks
Commit Message
Ethernet device must be stopped first before close in accordance
with the documentation.
Fixes: 980995f8cc56 ("ethdev: improve API comments of close and detach functions")
Cc: stable@dpdk.org
Signed-off-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
---
In fact the patch is required to fix segfault in the case of
net/virtio on close without stop after Rx interrupts enabled.
lib/ethdev/rte_ethdev.c | 6 ++++++
1 file changed, 6 insertions(+)
Comments
20/10/2021 15:15, Andrew Rybchenko:
> Ethernet device must be stopped first before close in accordance
> with the documentation.
>
> Fixes: 980995f8cc56 ("ethdev: improve API comments of close and detach functions")
> Cc: stable@dpdk.org
>
> Signed-off-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
Acked-by: Thomas Monjalon <thomas@monjalon.net>
On Wed, Oct 20, 2021 at 6:37 AM Thomas Monjalon <thomas@monjalon.net> wrote:
>
> 20/10/2021 15:15, Andrew Rybchenko:
> > Ethernet device must be stopped first before close in accordance
> > with the documentation.
> >
> > Fixes: 980995f8cc56 ("ethdev: improve API comments of close and detach functions")
> > Cc: stable@dpdk.org
> >
> > Signed-off-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
>
> Acked-by: Thomas Monjalon <thomas@monjalon.net>
Acked-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
>
>
On 10/20/2021 5:22 PM, Ajit Khaparde wrote:
> On Wed, Oct 20, 2021 at 6:37 AM Thomas Monjalon <thomas@monjalon.net> wrote:
>>
>> 20/10/2021 15:15, Andrew Rybchenko:
>>> Ethernet device must be stopped first before close in accordance
>>> with the documentation.
>>>
>>> Fixes: 980995f8cc56 ("ethdev: improve API comments of close and detach functions")
>>> Cc: stable@dpdk.org
>>>
>>> Signed-off-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
>>
>> Acked-by: Thomas Monjalon <thomas@monjalon.net>
> Acked-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
>
Applied to dpdk-next-net/main, thanks.
@@ -1893,6 +1893,12 @@ rte_eth_dev_close(uint16_t port_id)
RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
dev = &rte_eth_devices[port_id];
+ if (dev->data->dev_started) {
+ RTE_ETHDEV_LOG(ERR, "Cannot close started device (port %u)\n",
+ port_id);
+ return -EINVAL;
+ }
+
RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_close, -ENOTSUP);
*lasterr = (*dev->dev_ops->dev_close)(dev);
if (*lasterr != 0)