2
0
mirror of https://github.com/openvswitch/ovs synced 2025-09-03 15:55:19 +00:00

netdev-afxdp: Fix use of unconfigured device.

In case of failure of 'xsk_configure_all()', 'n_rxq' and 'xdpmode'
will remain in a new state. This will result in successful
reconfiguration (immediate return, because configuration is already
applied) if 'netdev_reconfigure()' will be called again.

Same issue was fixed previously for netdev-dpdk using 'dev->started'
flag in commit:
606f665072 ("netdev-dpdk: Don't use PMD driver if not configured successfully")

Let's use similar approach with checking the 'dev->xsks' which only
exists if configuration was successful.

Additionally implemented 'netdev_afxdp_construct()' function to
explicitly initialize all the specific fields and request the
reconfiguration.

CC: William Tu <u9012063@gmail.com>
Fixes: 0de1b42596 ("netdev-afxdp: add new netdev type for AF_XDP.")
Acked-by: William Tu <u9012063@gmail.com>
Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
This commit is contained in:
Ilya Maximets
2019-07-22 09:05:20 -04:00
parent 91a38e891d
commit f627cf1dd9
4 changed files with 33 additions and 3 deletions

View File

@@ -525,7 +525,8 @@ netdev_afxdp_reconfigure(struct netdev *netdev)
ovs_mutex_lock(&dev->mutex); ovs_mutex_lock(&dev->mutex);
if (netdev->n_rxq == dev->requested_n_rxq if (netdev->n_rxq == dev->requested_n_rxq
&& dev->xdpmode == dev->requested_xdpmode) { && dev->xdpmode == dev->requested_xdpmode
&& dev->xsks) {
goto out; goto out;
} }
@@ -965,6 +966,33 @@ netdev_afxdp_rxq_destruct(struct netdev_rxq *rxq_ OVS_UNUSED)
/* Nothing. */ /* Nothing. */
} }
int
netdev_afxdp_construct(struct netdev *netdev)
{
struct netdev_linux *dev = netdev_linux_cast(netdev);
int ret;
/* Configure common netdev-linux first. */
ret = netdev_linux_construct(netdev);
if (ret) {
return ret;
}
/* Queues should not be used before the first reconfiguration. Clearing. */
netdev->n_rxq = 0;
netdev->n_txq = 0;
dev->xdpmode = 0;
dev->requested_n_rxq = NR_QUEUE;
dev->requested_xdpmode = XDP_COPY;
dev->xsks = NULL;
dev->tx_locks = NULL;
netdev_request_reconfigure(netdev);
return 0;
}
void void
netdev_afxdp_destruct(struct netdev *netdev) netdev_afxdp_destruct(struct netdev *netdev)
{ {

View File

@@ -36,6 +36,7 @@ struct netdev_stats;
int netdev_afxdp_rxq_construct(struct netdev_rxq *rxq_); int netdev_afxdp_rxq_construct(struct netdev_rxq *rxq_);
void netdev_afxdp_rxq_destruct(struct netdev_rxq *rxq_); void netdev_afxdp_rxq_destruct(struct netdev_rxq *rxq_);
int netdev_afxdp_construct(struct netdev *netdev_);
void netdev_afxdp_destruct(struct netdev *netdev_); void netdev_afxdp_destruct(struct netdev *netdev_);
int netdev_afxdp_rxq_recv(struct netdev_rxq *rxq_, int netdev_afxdp_rxq_recv(struct netdev_rxq *rxq_,

View File

@@ -43,6 +43,7 @@ struct netdev_rxq_linux {
int fd; int fd;
}; };
int netdev_linux_construct(struct netdev *);
void netdev_linux_run(const struct netdev_class *); void netdev_linux_run(const struct netdev_class *);
int get_stats_via_netlink(const struct netdev *netdev_, int get_stats_via_netlink(const struct netdev *netdev_,

View File

@@ -906,7 +906,7 @@ netdev_linux_common_construct(struct netdev *netdev_)
} }
/* Creates system and internal devices. */ /* Creates system and internal devices. */
static int int
netdev_linux_construct(struct netdev *netdev_) netdev_linux_construct(struct netdev *netdev_)
{ {
struct netdev_linux *netdev = netdev_linux_cast(netdev_); struct netdev_linux *netdev = netdev_linux_cast(netdev_);
@@ -3290,7 +3290,7 @@ const struct netdev_class netdev_afxdp_class = {
NETDEV_LINUX_CLASS_COMMON, NETDEV_LINUX_CLASS_COMMON,
.type = "afxdp", .type = "afxdp",
.is_pmd = true, .is_pmd = true,
.construct = netdev_linux_construct, .construct = netdev_afxdp_construct,
.destruct = netdev_afxdp_destruct, .destruct = netdev_afxdp_destruct,
.get_stats = netdev_afxdp_get_stats, .get_stats = netdev_afxdp_get_stats,
.get_status = netdev_linux_get_status, .get_status = netdev_linux_get_status,