From nobody Sat Apr 5 15:11:58 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1737723836; cv=none; d=zohomail.com; s=zohoarc; b=KjL3Hdk+MCQnbNMuGMPNXwzzu7usTQZ0ys3pV0XjsVJr6EHzzDwaotlhixdqXFZH7IaadZNt6tsAVogN8Wu7TeMvdQyRAiW7Zwfmb7XOn820GAJ+LSbtFa/r9f7kEaONKV9B6aeeld2+d4DT1poq0nzfM2kxir/0ykZhXqoJTjI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1737723836; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=oU/vqoo23DWKyAOA6ILy3ggBRdG7V0yuoUZdGtJDNbQ=; b=Qva9+vkAzmJ9l2o+Btw6MulPK1JyWgn2N3DHRKyKy4HkonCSP220ooET/0F6Ghz0bZ1bF0Qo/ZXUIVStyb7jVAozLhIxkhfSGJe6BAblXw34rbWrpVQrPHq4RqAWfM5NnrhmFd7UGxj9i27Al2jnehJHBfX48I2K+IFD3XGpjVM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1737723836269184.40243829484768; Fri, 24 Jan 2025 05:03:56 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tbJLS-0000Tp-47; Fri, 24 Jan 2025 08:03:35 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tbJL4-0000Pt-Tb for qemu-devel@nongnu.org; Fri, 24 Jan 2025 08:03:14 -0500 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tbJL2-0007H3-Ig for qemu-devel@nongnu.org; Fri, 24 Jan 2025 08:03:10 -0500 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 1E0DC5C5A81; Fri, 24 Jan 2025 13:02:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B1A9BC4CED2; Fri, 24 Jan 2025 13:03:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1737723787; bh=+SMT1Ka5Xy6fyDrlOIaRE9P42fAh6RoCdIztHWEYvfE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Xl44rBIsQ4y5CJ160FYg9QT5IAPTMETvBBZX7aK8jFPSukKQWZwppOYeRfbclJIgo 55NW8qHeXfeWrnGw6zV8YVf+JKp7zDNchO8AfD0EkJwE3FH3cNei4cAU6FrxaBI3es uTOgLYr8plc4Xom/AMVsIwNbPZBsh5rqxjO4rlS025WCvVbEHROi0XNuSGuUg979SI ltyrek+FCa/iODyqei3AOUvpa2gQjgZ0F6W6MVislxUlI7ZWrYiASK3Z31uvIwChcx jVd7vyR4qGWAwCWO4jS7R5xW3mvUcNROjbLJJJlgszfgKBph6U/F6UHDWTSQGXHAFz Gc6hqb3obytzQ== From: deller@kernel.org To: Laurent Vivier , Stefan Hajnoczi , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Richard Henderson , qemu-devel@nongnu.org Cc: deller@gmx.de Subject: [PULL v3 5/6] linux-user: netlink: add netlink neighbour emulation Date: Fri, 24 Jan 2025 14:02:53 +0100 Message-ID: <20250124130254.3134-6-deller@kernel.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20250124130254.3134-1-deller@kernel.org> References: <20250124130254.3134-1-deller@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2604:1380:4641:c500::1; envelope-from=deller@kernel.org; helo=dfw.source.kernel.org X-Spam_score_int: -73 X-Spam_score: -7.4 X-Spam_bar: ------- X-Spam_report: (-7.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-2.996, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @kernel.org) X-ZM-MESSAGEID: 1737723839728019100 Content-Type: text/plain; charset="utf-8" From: Helge Deller Fixes various warnings in the testsuite while building gupnp: gssdp-net-DEBUG: Failed to send netlink message: Operation not supported gupnp-context-DEBUG: Mismatch between host header and host IP (example.com= , expected: 127.0.0.1) gupnp-context-DEBUG: Mismatch between host header and host port (80, expec= ted 4711) gupnp-context-DEBUG: Mismatch between host header and host IP (192.168.1.2= , expected: 127.0.0.1) gupnp-context-DEBUG: Mismatch between host header and host IP (fe80::01, e= xpected: 127.0.0.1) gupnp-context-DEBUG: Mismatch between host header and host port (80, expec= ted 4711) gupnp-context-DEBUG: Failed to parse HOST header from request: Invalid IPv= 6 address ?[fe80::01%1]? in URI gupnp-context-DEBUG: Failed to parse HOST header from request: Invalid IPv= 6 address ?[fe80::01%eth0]? in URI gupnp-context-DEBUG: Failed to parse HOST header from request: Could not p= arse port ?:1? in URI gupnp-context-DEBUG: Mismatch between host header and host IP (example.com= , expected: ::1) gupnp-context-DEBUG: Mismatch between host header and host port (80, expec= ted 4711) gupnp-context-DEBUG: Mismatch between host header and host IP (example.com= , expected: ::1) gupnp-context-DEBUG: Mismatch between host header and host port (80, expec= ted 4711) gupnp-context-DEBUG: Mismatch between host header and host IP (example.com= , expected: ::1) Signed-off-by: Helge Deller Reviewed-by: Laurent Vivier --- linux-user/fd-trans.c | 100 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) diff --git a/linux-user/fd-trans.c b/linux-user/fd-trans.c index 2e714c8e56..621e2248b4 100644 --- a/linux-user/fd-trans.c +++ b/linux-user/fd-trans.c @@ -25,12 +25,16 @@ #ifdef CONFIG_RTNETLINK #include #include +#include #endif #include "qemu.h" #include "user-internals.h" #include "fd-trans.h" #include "signal-common.h" =20 +#define NDM_RTA(r) ((struct rtattr*)(((char*)(r)) + \ + NLMSG_ALIGN(sizeof(struct ndmsg)))) + enum { QEMU_IFA_UNSPEC, QEMU_IFA_ADDRESS, @@ -1226,6 +1230,35 @@ static abi_long host_to_target_data_route_rtattr(str= uct rtattr *rtattr) return 0; } =20 +static abi_long host_to_target_data_neigh_rtattr(struct rtattr *rtattr) +{ + struct nda_cacheinfo *ndac; + uint32_t *u32; + + switch (rtattr->rta_type) { + case NDA_UNSPEC: + case NDA_DST: + case NDA_LLADDR: + break; + case NDA_PROBES: + u32 =3D RTA_DATA(rtattr); + *u32 =3D tswap32(*u32); + break; + case NDA_CACHEINFO: + ndac =3D RTA_DATA(rtattr); + ndac->ndm_confirmed =3D tswap32(ndac->ndm_confirmed); + ndac->ndm_used =3D tswap32(ndac->ndm_used); + ndac->ndm_updated =3D tswap32(ndac->ndm_updated); + ndac->ndm_refcnt =3D tswap32(ndac->ndm_refcnt); + break; + default: + qemu_log_mask(LOG_UNIMP, "Unknown host to target NEIGH type: %d\n", + rtattr->rta_type); + break; + } + return 0; +} + static abi_long host_to_target_link_rtattr(struct rtattr *rtattr, uint32_t rtattr_len) { @@ -1247,12 +1280,20 @@ static abi_long host_to_target_route_rtattr(struct = rtattr *rtattr, host_to_target_data_route_rtattr= ); } =20 +static abi_long host_to_target_neigh_rtattr(struct rtattr *rtattr, + uint32_t rtattr_len) +{ + return host_to_target_for_each_rtattr(rtattr, rtattr_len, + host_to_target_data_neigh_rtattr= ); +} + static abi_long host_to_target_data_route(struct nlmsghdr *nlh) { uint32_t nlmsg_len; struct ifinfomsg *ifi; struct ifaddrmsg *ifa; struct rtmsg *rtm; + struct ndmsg *ndm; =20 nlmsg_len =3D nlh->nlmsg_len; switch (nlh->nlmsg_type) { @@ -1279,6 +1320,17 @@ static abi_long host_to_target_data_route(struct nlm= sghdr *nlh) nlmsg_len - NLMSG_LENGTH(sizeof(*if= a))); } break; + case RTM_NEWNEIGH: + case RTM_DELNEIGH: + case RTM_GETNEIGH: + if (nlh->nlmsg_len >=3D NLMSG_LENGTH(sizeof(*ndm))) { + ndm =3D NLMSG_DATA(nlh); + ndm->ndm_ifindex =3D tswap32(ndm->ndm_ifindex); + ndm->ndm_state =3D tswap16(ndm->ndm_state); + host_to_target_neigh_rtattr(NDM_RTA(ndm), + nlmsg_len - NLMSG_LENGTH(sizeof(*ndm))= ); + } + break; case RTM_NEWROUTE: case RTM_DELROUTE: case RTM_GETROUTE: @@ -1426,6 +1478,35 @@ static abi_long target_to_host_data_addr_rtattr(stru= ct rtattr *rtattr) return 0; } =20 +static abi_long target_to_host_data_neigh_rtattr(struct rtattr *rtattr) +{ + struct nda_cacheinfo *ndac; + uint32_t *u32; + + switch (rtattr->rta_type) { + case NDA_UNSPEC: + case NDA_DST: + case NDA_LLADDR: + break; + case NDA_PROBES: + u32 =3D RTA_DATA(rtattr); + *u32 =3D tswap32(*u32); + break; + case NDA_CACHEINFO: + ndac =3D RTA_DATA(rtattr); + ndac->ndm_confirmed =3D tswap32(ndac->ndm_confirmed); + ndac->ndm_used =3D tswap32(ndac->ndm_used); + ndac->ndm_updated =3D tswap32(ndac->ndm_updated); + ndac->ndm_refcnt =3D tswap32(ndac->ndm_refcnt); + break; + default: + qemu_log_mask(LOG_UNIMP, "Unknown target NEIGH type: %d\n", + rtattr->rta_type); + break; + } + return 0; +} + static abi_long target_to_host_data_route_rtattr(struct rtattr *rtattr) { uint32_t *u32; @@ -1464,6 +1545,13 @@ static void target_to_host_addr_rtattr(struct rtattr= *rtattr, target_to_host_data_addr_rtattr); } =20 +static void target_to_host_neigh_rtattr(struct rtattr *rtattr, + uint32_t rtattr_len) +{ + target_to_host_for_each_rtattr(rtattr, rtattr_len, + target_to_host_data_neigh_rtattr); +} + static void target_to_host_route_rtattr(struct rtattr *rtattr, uint32_t rtattr_len) { @@ -1476,6 +1564,7 @@ static abi_long target_to_host_data_route(struct nlms= ghdr *nlh) struct ifinfomsg *ifi; struct ifaddrmsg *ifa; struct rtmsg *rtm; + struct ndmsg *ndm; =20 switch (nlh->nlmsg_type) { case RTM_NEWLINK: @@ -1502,6 +1591,17 @@ static abi_long target_to_host_data_route(struct nlm= sghdr *nlh) NLMSG_LENGTH(sizeof(*ifa))); } break; + case RTM_NEWNEIGH: + case RTM_DELNEIGH: + case RTM_GETNEIGH: + if (nlh->nlmsg_len >=3D NLMSG_LENGTH(sizeof(*ndm))) { + ndm =3D NLMSG_DATA(nlh); + ndm->ndm_ifindex =3D tswap32(ndm->ndm_ifindex); + ndm->ndm_state =3D tswap16(ndm->ndm_state); + target_to_host_neigh_rtattr(NDM_RTA(ndm), nlh->nlmsg_len - + NLMSG_LENGTH(sizeof(*ndm))); + } + break; case RTM_NEWROUTE: case RTM_DELROUTE: case RTM_GETROUTE: --=20 2.47.0