diff mbox series

[ovs-dev,v1,1/9] netdev-linux: Fix IFLA_IF_NETNSID value.

Message ID 20251222152356.301762-2-amorenoz@redhat.com
State New
Headers show
Series netdev-linux: Use event-driven netlink notifications. | expand

Checks

Context Check Description
ovsrobot/apply-robot success apply and check: success
ovsrobot/github-robot-_Build_and_Test success github build: passed

Commit Message

Adrián Moreno Dec. 22, 2025, 3:23 p.m. UTC
There are two issues with the way the value of IFLA_IF_NETNSID
is currently being determined.

Firstly, IFLA_IF_NETNSID is an enum value, not a preprocessor macro, but
a preprocessor conditional is being used to check if it exists.
So, from the preprocessor's PoV, it's always undefined.

Secondly, the value being set is wrong.

```
$ cat > main.c << EOF
int main() {
    return IFLA_IF_NETNSID;
}
EOF
$ gcc main.c && ./a.out; echo $?
46
```
I double checked just in case the value had changed since it was
introduced: it hasn't.

Fixes: 756819ddd788 ("netdev-linux: use netlink to update netdev.")
Signed-off-by: Adrian Moreno <amorenoz@redhat.com>
---
 acinclude.m4       | 8 ++++++++
 lib/netdev-linux.c | 4 ++--
 2 files changed, 10 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/acinclude.m4 b/acinclude.m4
index bbc872142..85e065c41 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -162,6 +162,14 @@  AC_DEFUN([OVS_CHECK_LINUX_NETLINK], [
     ])],
     [AC_DEFINE([HAVE_RTA_VIA], [1],
     [Define to 1 if struct rtvia is available.])])
+
+  AC_COMPILE_IFELSE([
+    AC_LANG_PROGRAM([#include <linux/if_link.h>], [
+        int netnsid =  IFLA_IF_NETNSID;
+    ])],
+    [AC_DEFINE([HAVE_IFLA_IF_NETNSID], [1],
+    [Define to 1 if IFLA_IF_NETNSID is available.])])
+
 ])
 
 dnl OVS_CHECK_LINUX_TC
diff --git a/lib/netdev-linux.c b/lib/netdev-linux.c
index 8bf1a29a0..ba9d87700 100644
--- a/lib/netdev-linux.c
+++ b/lib/netdev-linux.c
@@ -93,8 +93,8 @@  COVERAGE_DEFINE(netdev_linux_invalid_l4_csum);
 COVERAGE_DEFINE(netdev_linux_unknown_l4_csum);
 
 
-#ifndef IFLA_IF_NETNSID
-#define IFLA_IF_NETNSID 0x45
+#ifndef HAVE_IFLA_IF_NETNSID
+#define IFLA_IF_NETNSID 46
 #endif
 /* These were introduced in Linux 2.6.14, so they might be missing if we have
  * old headers. */