xdp-project / xdp-tools

Utilities and example programs for use with XDP

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

xdp-loader fall back to SKB mode automatically when native mode not supported?

vincentmli opened this issue · comments

Hi @tohojo

is it possible to change xdp-loader program to automatically retry SKB mode when native mode not supported? I am porting xdp-tools to my BPFire which is fork of IPFire and I want XDP program automatically attached to network interface with SKB mode when the interface does not support native node, this is to make it more friendly to users with less technical skill and have no intention to manually re-try SKB mode, and support as many devices as possible without users manual intervention.

it does not need to be in xdp-loader official release if you think this is not good idea, but I would like to have this option for my project :)

I tried diff below, but it complains error when compiling, any code advice is greatly appreciated

@@ -206,9 +206,11 @@ retry:
 
                if (err == -EOPNOTSUPP &&
                    (opt->mode == XDP_MODE_NATIVE || opt->mode == XDP_MODE_HW)) {
-                       pr_warn("Attaching XDP program in %s mode not supported - try %s mode.\n",
+                       pr_warn("Attaching XDP program in %s mode not supported - re-try %s mode.\n",
                                opt->mode == XDP_MODE_NATIVE ? "native" : "HW",
                                opt->mode == XDP_MODE_NATIVE ? "SKB" : "native or SKB");
+                       opt->mode = XDP_MODE_SKB;
+                       goto retry;
CC       xdp-loader

xdp-loader.c: In function ‘do_load’:
xdp-loader.c:212:35: error: assignment of member ‘mode’ in read-only object
212 | opt->mode = XDP_MODE_SKB;
| ^
make[1]: *** [../lib/common.mk:107: xdp-loader] Error 1
make: *** [Makefile:40: xdp-loader] Error 2

understood, ipfire happens to target lot of home users with lower end mini PC or old PC, but then, I assume home users do not need XDP feature in most case.