[ovs-dev] [PATCH] netdev-afxdp: Error when no XDP program loaded.
Ilya Maximets
i.maximets at samsung.com
Wed Jul 24 14:14:14 UTC 2019
On 24.07.2019 1:58, William Tu wrote:
> netdev-afxdp requires XDP program to be loaded. When prog_id == 0,
> it indicates no XDP program, so return error and free resources.
>
> Signed-off-by: William Tu <u9012063 at gmail.com>
> ---
> lib/netdev-afxdp.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/lib/netdev-afxdp.c b/lib/netdev-afxdp.c
> index 6b0b93e7f432..79c7a442e9cf 100644
> --- a/lib/netdev-afxdp.c
> +++ b/lib/netdev-afxdp.c
> @@ -283,6 +283,12 @@ xsk_configure_socket(struct xsk_umem_info *umem, uint32_t ifindex,
> free(xsk);
> return NULL;
> }
> + if (!prog_id) {
> + VLOG_ERR("No XDP program is loaded at ifindex %d", ifindex);
> + xsk_socket__delete(xsk->xsk);
> + free(xsk);
> + return NULL;
> + }
What do you think about combining this 'if' with the previous error checking
like this:
if (ret || !prog_id) {
if (ret) {
VLOG_ERR("Get XDP prog ID failed (%s)", ovs_strerror(errno));
} else {
VLOG_ERR("No XDP program is loaded at ifindex %d", ifindex);
}
...
?
There is less code duplication this way.
Best regards, Ilya Maximets.
More information about the dev
mailing list