[ovs-dev] [PATCH] netdev-afxdp: Error when no XDP program loaded.

William Tu u9012063 at gmail.com
Wed Jul 24 15:21:35 UTC 2019


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>
---
v2: combining if statement to avoid duplication
---
 lib/netdev-afxdp.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/lib/netdev-afxdp.c b/lib/netdev-afxdp.c
index 6b0b93e7f432..5fe00eaafb7b 100644
--- a/lib/netdev-afxdp.c
+++ b/lib/netdev-afxdp.c
@@ -277,8 +277,12 @@ xsk_configure_socket(struct xsk_umem_info *umem, uint32_t ifindex,
 
     /* Make sure the built-in AF_XDP program is loaded. */
     ret = bpf_get_link_xdp_id(ifindex, &prog_id, cfg.xdp_flags);
-    if (ret) {
-        VLOG_ERR("Get XDP prog ID failed (%s)", ovs_strerror(errno));
+    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);
+        }
         xsk_socket__delete(xsk->xsk);
         free(xsk);
         return NULL;
-- 
2.7.4



More information about the dev mailing list