[PATCH v2 3/6] linux-user: netlink: Add IP_PKTINFO cmsg parsing

deller@kernel.org posted 6 patches 3 months, 2 weeks ago
There is a newer version of this series
[PATCH v2 3/6] linux-user: netlink: Add IP_PKTINFO cmsg parsing
Posted by deller@kernel.org 3 months, 2 weeks ago
From: Helge Deller <deller@gmx.de>

Fixes those warnings:
 Unsupported host ancillary data: 0/8

Signed-off-by: Helge Deller <deller@gmx.de>
---
 linux-user/syscall.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 494323efba..bbe2560927 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -1996,6 +1996,18 @@ static inline abi_long host_to_target_cmsg(struct target_msghdr *target_msgh,
                     (void *) &errh->offender, sizeof(errh->offender));
                 break;
             }
+            case IP_PKTINFO:
+            {
+                struct in_pktinfo *pkti = data;
+                struct in_pktinfo *target_pkti = target_data;
+
+                __put_user(pkti->ipi_ifindex, &target_pkti->ipi_ifindex);
+                host_to_target_sockaddr((unsigned long) &target_pkti->ipi_spec_dst,
+                    (void *) &pkti->ipi_spec_dst, sizeof(pkti->ipi_spec_dst));
+                host_to_target_sockaddr((unsigned long) &target_pkti->ipi_addr,
+                    (void *) &pkti->ipi_addr, sizeof(pkti->ipi_addr));
+                break;
+            }
             default:
                 goto unimplemented;
             }
-- 
2.47.0
Re: [PATCH v2 3/6] linux-user: netlink: Add IP_PKTINFO cmsg parsing
Posted by Laurent Vivier 3 months ago
Le 27/12/2024 à 21:54, deller@kernel.org a écrit :
> From: Helge Deller <deller@gmx.de>
> 
> Fixes those warnings:
>   Unsupported host ancillary data: 0/8
> 
> Signed-off-by: Helge Deller <deller@gmx.de>
> ---
>   linux-user/syscall.c | 12 ++++++++++++
>   1 file changed, 12 insertions(+)
> 
> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> index 494323efba..bbe2560927 100644
> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c
> @@ -1996,6 +1996,18 @@ static inline abi_long host_to_target_cmsg(struct target_msghdr *target_msgh,
>                       (void *) &errh->offender, sizeof(errh->offender));
>                   break;
>               }
> +            case IP_PKTINFO:
> +            {
> +                struct in_pktinfo *pkti = data;
> +                struct in_pktinfo *target_pkti = target_data;

I think we need to define a target_in_pktinfo structure.

> +
> +                __put_user(pkti->ipi_ifindex, &target_pkti->ipi_ifindex);
> +                host_to_target_sockaddr((unsigned long) &target_pkti->ipi_spec_dst,
> +                    (void *) &pkti->ipi_spec_dst, sizeof(pkti->ipi_spec_dst));
> +                host_to_target_sockaddr((unsigned long) &target_pkti->ipi_addr,
> +                    (void *) &pkti->ipi_addr, sizeof(pkti->ipi_addr));

Why do you use host_to_target_sockaddr()? The type of ipi_spec_dst and ipi_addr is in_addr.
And in_addr is a __be32 so it doesn't need be translated from host endianness to target endianness.


> +                break;
> +            }
>               default:
>                   goto unimplemented;
>               }

Thanks,
Laurent