[PATCH v4 1/7] linux-user: netlink: Add missing IFA_PROTO to host_to_target_data_addr_rtattr()

deller@kernel.org posted 7 patches 2 months, 2 weeks ago
[PATCH v4 1/7] linux-user: netlink: Add missing IFA_PROTO to host_to_target_data_addr_rtattr()
Posted by deller@kernel.org 2 months, 2 weeks ago
From: Helge Deller <deller@gmx.de>

Fixes this warning:
 Unknown host IFA type: 11

IFA_PROTO has been introduced in kernel v5.18, and as such using it
unconditionally breaks build on Ubuntu 22.04.  Instead convert the IFA_XXX
values to QEMU_IDA_XXX values and use those instead.
Already existing IFA_XXX usages are converted to QEMU_IFA_XXX in a
followup-patch.

Signed-off-by: Helge Deller <deller@gmx.de>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
---
 linux-user/fd-trans.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/linux-user/fd-trans.c b/linux-user/fd-trans.c
index c04a97c73a..05a944b32e 100644
--- a/linux-user/fd-trans.c
+++ b/linux-user/fd-trans.c
@@ -31,6 +31,22 @@
 #include "fd-trans.h"
 #include "signal-common.h"
 
+enum {
+    QEMU_IFA_UNSPEC,
+    QEMU_IFA_ADDRESS,
+    QEMU_IFA_LOCAL,
+    QEMU_IFA_LABEL,
+    QEMU_IFA_BROADCAST,
+    QEMU_IFA_ANYCAST,
+    QEMU_IFA_CACHEINFO,
+    QEMU_IFA_MULTICAST,
+    QEMU_IFA_FLAGS,
+    QEMU_IFA_RT_PRIORITY,
+    QEMU_IFA_TARGET_NETNSID,
+    QEMU_IFA_PROTO,
+    QEMU__IFA__MAX,
+};
+
 enum {
     QEMU_IFLA_BR_UNSPEC,
     QEMU_IFLA_BR_FORWARD_DELAY,
@@ -1140,6 +1156,7 @@ static abi_long host_to_target_data_addr_rtattr(struct rtattr *rtattr)
     /* binary: depends on family type */
     case IFA_ADDRESS:
     case IFA_LOCAL:
+    case QEMU_IFA_PROTO:
         break;
     /* string */
     case IFA_LABEL:
-- 
2.47.0
Re: [PATCH v4 1/7] linux-user: netlink: Add missing IFA_PROTO to host_to_target_data_addr_rtattr()
Posted by Laurent Vivier 2 months, 1 week ago
Le 20/01/2025 à 22:33, deller@kernel.org a écrit :
> From: Helge Deller <deller@gmx.de>
> 
> Fixes this warning:
>   Unknown host IFA type: 11
> 
> IFA_PROTO has been introduced in kernel v5.18, and as such using it
> unconditionally breaks build on Ubuntu 22.04.  Instead convert the IFA_XXX
> values to QEMU_IDA_XXX values and use those instead.
> Already existing IFA_XXX usages are converted to QEMU_IFA_XXX in a
> followup-patch.
> 
> Signed-off-by: Helge Deller <deller@gmx.de>
> Reviewed-by: Laurent Vivier <laurent@vivier.eu>
> ---
>   linux-user/fd-trans.c | 17 +++++++++++++++++
>   1 file changed, 17 insertions(+)
> 
> diff --git a/linux-user/fd-trans.c b/linux-user/fd-trans.c
> index c04a97c73a..05a944b32e 100644
> --- a/linux-user/fd-trans.c
> +++ b/linux-user/fd-trans.c
> @@ -31,6 +31,22 @@
>   #include "fd-trans.h"
>   #include "signal-common.h"
>   
> +enum {
> +    QEMU_IFA_UNSPEC,
> +    QEMU_IFA_ADDRESS,
> +    QEMU_IFA_LOCAL,
> +    QEMU_IFA_LABEL,
> +    QEMU_IFA_BROADCAST,
> +    QEMU_IFA_ANYCAST,
> +    QEMU_IFA_CACHEINFO,
> +    QEMU_IFA_MULTICAST,
> +    QEMU_IFA_FLAGS,
> +    QEMU_IFA_RT_PRIORITY,
> +    QEMU_IFA_TARGET_NETNSID,
> +    QEMU_IFA_PROTO,
> +    QEMU__IFA__MAX,
> +};
> +
>   enum {
>       QEMU_IFLA_BR_UNSPEC,
>       QEMU_IFLA_BR_FORWARD_DELAY,
> @@ -1140,6 +1156,7 @@ static abi_long host_to_target_data_addr_rtattr(struct rtattr *rtattr)
>       /* binary: depends on family type */
>       case IFA_ADDRESS:
>       case IFA_LOCAL:
> +    case QEMU_IFA_PROTO:
>           break;
>       /* string */
>       case IFA_LABEL:

It would be cleaner to replace all the IFA_XXX by their QEMU_IFA_XXX.

Thanks,
Laurent

Re: [PATCH v4 1/7] linux-user: netlink: Add missing IFA_PROTO to host_to_target_data_addr_rtattr()
Posted by Helge Deller 2 months, 1 week ago
* Laurent Vivier <laurent@vivier.eu>:
> [...]
> It would be cleaner to replace all the IFA_XXX by their QEMU_IFA_XXX.

Thanks for review, Laurent!

Below I've merged patch #1 and #7, as suggested by you.
Is this OK?
Can you review?

Thanks!
Helge
________________________________________

From: Helge Deller <deller@gmx.de>
Date: Mon, 20 Jan 2025 22:20:41 +0100
Subject: [PATCH] linux-user: netlink: Add missing IFA_PROTO to
 host_to_target_data_addr_rtattr()

Fix this warning:
 Unknown host IFA type: 11

While adding IFA_PROTO, convert all IFA_XXX values over to QEMU_IFA_XXX values
to avoid a build failure on Ubuntu 22.04 (kernel v5.18 which does not know
IFA_PROTO yet).

Signed-off-by: Helge Deller <deller@gmx.de>

diff --git a/linux-user/fd-trans.c b/linux-user/fd-trans.c
index c04a97c73a..2e714c8e56 100644
--- a/linux-user/fd-trans.c
+++ b/linux-user/fd-trans.c
@@ -31,6 +31,22 @@
 #include "fd-trans.h"
 #include "signal-common.h"
 
+enum {
+    QEMU_IFA_UNSPEC,
+    QEMU_IFA_ADDRESS,
+    QEMU_IFA_LOCAL,
+    QEMU_IFA_LABEL,
+    QEMU_IFA_BROADCAST,
+    QEMU_IFA_ANYCAST,
+    QEMU_IFA_CACHEINFO,
+    QEMU_IFA_MULTICAST,
+    QEMU_IFA_FLAGS,
+    QEMU_IFA_RT_PRIORITY,
+    QEMU_IFA_TARGET_NETNSID,
+    QEMU_IFA_PROTO,
+    QEMU__IFA__MAX,
+};
+
 enum {
     QEMU_IFLA_BR_UNSPEC,
     QEMU_IFLA_BR_FORWARD_DELAY,
@@ -1138,20 +1154,21 @@ static abi_long host_to_target_data_addr_rtattr(struct rtattr *rtattr)
 
     switch (rtattr->rta_type) {
     /* binary: depends on family type */
-    case IFA_ADDRESS:
-    case IFA_LOCAL:
+    case QEMU_IFA_ADDRESS:
+    case QEMU_IFA_LOCAL:
+    case QEMU_IFA_PROTO:
         break;
     /* string */
-    case IFA_LABEL:
+    case QEMU_IFA_LABEL:
         break;
     /* u32 */
-    case IFA_FLAGS:
-    case IFA_BROADCAST:
+    case QEMU_IFA_FLAGS:
+    case QEMU_IFA_BROADCAST:
         u32 = RTA_DATA(rtattr);
         *u32 = tswap32(*u32);
         break;
     /* struct ifa_cacheinfo */
-    case IFA_CACHEINFO:
+    case QEMU_IFA_CACHEINFO:
         ci = RTA_DATA(rtattr);
         ci->ifa_prefered = tswap32(ci->ifa_prefered);
         ci->ifa_valid = tswap32(ci->ifa_valid);
@@ -1398,8 +1415,8 @@ static abi_long target_to_host_data_addr_rtattr(struct rtattr *rtattr)
 {
     switch (rtattr->rta_type) {
     /* binary: depends on family type */
-    case IFA_LOCAL:
-    case IFA_ADDRESS:
+    case QEMU_IFA_LOCAL:
+    case QEMU_IFA_ADDRESS:
         break;
     default:
         qemu_log_mask(LOG_UNIMP, "Unknown target IFA type: %d\n",
Re: [PATCH v4 1/7] linux-user: netlink: Add missing IFA_PROTO to host_to_target_data_addr_rtattr()
Posted by Laurent Vivier 2 months, 1 week ago
Le 22/01/2025 à 22:20, Helge Deller a écrit :
> * Laurent Vivier <laurent@vivier.eu>:
>> [...]
>> It would be cleaner to replace all the IFA_XXX by their QEMU_IFA_XXX.
> 
> Thanks for review, Laurent!
> 
> Below I've merged patch #1 and #7, as suggested by you.
> Is this OK?

Yes, thanks
> Can you review?

Reviewed-by: Laurent Vivier <laurent@vivier.eu>

> 
> Thanks!
> Helge
> ________________________________________
> 
> From: Helge Deller <deller@gmx.de>
> Date: Mon, 20 Jan 2025 22:20:41 +0100
> Subject: [PATCH] linux-user: netlink: Add missing IFA_PROTO to
>   host_to_target_data_addr_rtattr()
> 
> Fix this warning:
>   Unknown host IFA type: 11
> 
> While adding IFA_PROTO, convert all IFA_XXX values over to QEMU_IFA_XXX values
> to avoid a build failure on Ubuntu 22.04 (kernel v5.18 which does not know
> IFA_PROTO yet).
> 
> Signed-off-by: Helge Deller <deller@gmx.de>
> 
> diff --git a/linux-user/fd-trans.c b/linux-user/fd-trans.c
> index c04a97c73a..2e714c8e56 100644
> --- a/linux-user/fd-trans.c
> +++ b/linux-user/fd-trans.c
> @@ -31,6 +31,22 @@
>   #include "fd-trans.h"
>   #include "signal-common.h"
>   
> +enum {
> +    QEMU_IFA_UNSPEC,
> +    QEMU_IFA_ADDRESS,
> +    QEMU_IFA_LOCAL,
> +    QEMU_IFA_LABEL,
> +    QEMU_IFA_BROADCAST,
> +    QEMU_IFA_ANYCAST,
> +    QEMU_IFA_CACHEINFO,
> +    QEMU_IFA_MULTICAST,
> +    QEMU_IFA_FLAGS,
> +    QEMU_IFA_RT_PRIORITY,
> +    QEMU_IFA_TARGET_NETNSID,
> +    QEMU_IFA_PROTO,
> +    QEMU__IFA__MAX,
> +};
> +
>   enum {
>       QEMU_IFLA_BR_UNSPEC,
>       QEMU_IFLA_BR_FORWARD_DELAY,
> @@ -1138,20 +1154,21 @@ static abi_long host_to_target_data_addr_rtattr(struct rtattr *rtattr)
>   
>       switch (rtattr->rta_type) {
>       /* binary: depends on family type */
> -    case IFA_ADDRESS:
> -    case IFA_LOCAL:
> +    case QEMU_IFA_ADDRESS:
> +    case QEMU_IFA_LOCAL:
> +    case QEMU_IFA_PROTO:
>           break;
>       /* string */
> -    case IFA_LABEL:
> +    case QEMU_IFA_LABEL:
>           break;
>       /* u32 */
> -    case IFA_FLAGS:
> -    case IFA_BROADCAST:
> +    case QEMU_IFA_FLAGS:
> +    case QEMU_IFA_BROADCAST:
>           u32 = RTA_DATA(rtattr);
>           *u32 = tswap32(*u32);
>           break;
>       /* struct ifa_cacheinfo */
> -    case IFA_CACHEINFO:
> +    case QEMU_IFA_CACHEINFO:
>           ci = RTA_DATA(rtattr);
>           ci->ifa_prefered = tswap32(ci->ifa_prefered);
>           ci->ifa_valid = tswap32(ci->ifa_valid);
> @@ -1398,8 +1415,8 @@ static abi_long target_to_host_data_addr_rtattr(struct rtattr *rtattr)
>   {
>       switch (rtattr->rta_type) {
>       /* binary: depends on family type */
> -    case IFA_LOCAL:
> -    case IFA_ADDRESS:
> +    case QEMU_IFA_LOCAL:
> +    case QEMU_IFA_ADDRESS:
>           break;
>       default:
>           qemu_log_mask(LOG_UNIMP, "Unknown target IFA type: %d\n",