From nobody Fri Aug 22 16:24:07 2025 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4c7lr81GVHz64YyD; Fri, 22 Aug 2025 16:24:08 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R12" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4c7lr80WXRz3d6D; Fri, 22 Aug 2025 16:24:08 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1755879848; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=5z4lF01nBklpFpwClCuc9IWIQAPdmN5BqHoBRYy4gSw=; b=Jlv44IeSozxTbvW9bUDw0nL9VRfBQTLWyqYsq2/X6AKTNR0qfx5MzuJtSSIT8D7Tir+C/7 bljrYSudhQUy9Ah+pM+MPWUD3punsbuG/lZ8y1Al3QCM4+ApYEZVibBc6/hRo6C1xSYrCe 32OsIbldjatVTaC1Fab6Cgyyd/qislStHlLtE1reLWpPZyQYtH4GYIs5cuV8vAM6IKqFlM 8RUin1GVHZ20Ur2WKHBaKJbIiXU2OfseRqSzGo3hABRnTHxsLo4DeAcEkgQTsv5l/pmDxg MBffVDbiucuMagmTqcsDmSynnS5yvuLno9nWq/AGFK1iuxHYTxHUxtCZ954xuw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1755879848; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=5z4lF01nBklpFpwClCuc9IWIQAPdmN5BqHoBRYy4gSw=; b=qzmGHfmNvRQgyHtXkE7ZkK0s4+13GNVUdberjasINscIZ+29b6b9IGkdkZyiZElKrgobxp hc9FxdEFfN3pEbf3UVvFege1xqZ0pfIPOsmpcCIFpZTXL6vwPBu5H/a/zDEfQC70PIOjlW 2Bvs95FR/8gsWYfUVRypCN1KGo++LwVfFiYQjKwYsjOJm7UTZT/ZfKF6icM8v2f0awZNjO ulIn/GWzpc3GtfnulV43H20vrb0LDgpv+fw+Xs5gNV0l7+65fs1bv0IJxMG/oasqGZE6dX DtkQldwrEUuhH12EBAW/re8TGlMswmE6IIOaYkO1qKnhUvZbF4MVHdanQ8BVFQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1755879848; a=rsa-sha256; cv=none; b=qmbb6ShSUuEo+27GN+zS2kLNkDdDDRZ3SrKIrnrLJ3h1v3+MC9O6mq+GI73jeozFl6XR4s jKxM2dB8csPb2jl+sweIXArzBTI9gu3kWao1yuRGePGkvdADst6ZGWUfzLVxv/TdPviWT0 tgD9pWUXFKA5pYC+8Y+RwJyVecA+44PbjNtNWkJlt92kfZWjVZgcw/X57z73+k70yiIL48 dswENFZmISLha/rp5ZBWWS78RBs19iWfm2j/GZbyiIxQutAqC8v7SkBKfUENcpW3HZsaPo 6/leIqyeD91OKnuJtVKxrjB09daIC9uXqf04ZSyQq5cfzifCizHSFKJc7Lb45w== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4c7lr76s9qztGg; Fri, 22 Aug 2025 16:24:07 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 57MGO71U022400; Fri, 22 Aug 2025 16:24:07 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 57MGO7qu022397; Fri, 22 Aug 2025 16:24:07 GMT (envelope-from git) Date: Fri, 22 Aug 2025 16:24:07 GMT Message-Id: <202508221624.57MGO7qu022397@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gleb Smirnoff Subject: git: 554907bac3b2 - main - linux: fix reporting NL_RTM_DELLINK to Netlink sockets List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: glebius X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 554907bac3b264863a051f75eedc35d180d3e18c Auto-Submitted: auto-generated The branch main has been updated by glebius: URL: https://cgit.FreeBSD.org/src/commit/?id=554907bac3b264863a051f75eedc35d180d3e18c commit 554907bac3b264863a051f75eedc35d180d3e18c Author: Gleb Smirnoff AuthorDate: 2025-08-22 16:23:28 +0000 Commit: Gleb Smirnoff CommitDate: 2025-08-22 16:23:28 +0000 linux: fix reporting NL_RTM_DELLINK to Netlink sockets The problem is that ifname_bsd_to_linux_name() requires the interface to exist. But when we are in the context of ifnet_departure_event EVENTHANDLER(9), it does not. Instead of silently dropping the message, let's send the FreeBSD name verbatim. At the moment special translation is done for IFT_LOOPBACK and IFT_ETHER only, and these two kinds of interfaces usually don't depart. So, this is not a final fix, but definitely an improvement. While here, simplify the associated code. Differential Revision: https://reviews.freebsd.org/D51927 --- sys/compat/linux/linux_netlink.c | 39 +++++++++++++-------------------------- 1 file changed, 13 insertions(+), 26 deletions(-) diff --git a/sys/compat/linux/linux_netlink.c b/sys/compat/linux/linux_netlink.c index f51838ee00d7..d414fad375c0 100644 --- a/sys/compat/linux/linux_netlink.c +++ b/sys/compat/linux/linux_netlink.c @@ -241,25 +241,10 @@ nlmsg_copy_nla(const struct nlattr *nla_orig, struct nl_writer *nw) return (false); } -/* - * Translate a FreeBSD interface name to a Linux interface name. - */ -static bool -nlmsg_translate_ifname_nla(struct nlattr *nla, struct nl_writer *nw) -{ - char ifname[LINUX_IFNAMSIZ]; - - if (ifname_bsd_to_linux_name((char *)(nla + 1), ifname, - sizeof(ifname)) <= 0) - return (false); - return (nlattr_add_string(nw, IFLA_IFNAME, ifname)); -} - -#define LINUX_NLA_UNHANDLED -1 /* * Translate a FreeBSD attribute to a Linux attribute. - * Returns LINUX_NLA_UNHANDLED when the attribute is not processed - * and the caller must take care of it, otherwise the result is returned. + * Returns false when the attribute is not processed and the caller must take + * care of it. */ static int nlmsg_translate_all_nla(struct nlmsghdr *hdr, struct nlattr *nla, @@ -271,22 +256,27 @@ nlmsg_translate_all_nla(struct nlmsghdr *hdr, struct nlattr *nla, case NL_RTM_DELLINK: case NL_RTM_GETLINK: switch (nla->nla_type) { - case IFLA_IFNAME: - return (nlmsg_translate_ifname_nla(nla, nw)); + case IFLA_IFNAME: { + char ifname[LINUX_IFNAMSIZ]; + + if (ifname_bsd_to_linux_name((char *)(nla + 1), ifname, + sizeof(ifname)) > 0) + return (true); + break; + } default: break; } default: break; } - return (LINUX_NLA_UNHANDLED); + return (false); } static bool nlmsg_copy_all_nla(struct nlmsghdr *hdr, int raw_hdrlen, struct nl_writer *nw) { struct nlattr *nla; - int ret; int hdrlen = NETLINK_ALIGN(raw_hdrlen); int attrs_len = hdr->nlmsg_len - sizeof(struct nlmsghdr) - hdrlen; @@ -297,15 +287,12 @@ nlmsg_copy_all_nla(struct nlmsghdr *hdr, int raw_hdrlen, struct nl_writer *nw) if (nla->nla_len < sizeof(struct nlattr)) { return (false); } - ret = nlmsg_translate_all_nla(hdr, nla, nw); - if (ret == LINUX_NLA_UNHANDLED) - ret = nlmsg_copy_nla(nla, nw); - if (!ret) + if (!nlmsg_translate_all_nla(hdr, nla, nw) && + !nlmsg_copy_nla(nla, nw)) return (false); } return (true); } -#undef LINUX_NLA_UNHANDLED static unsigned int rtnl_if_flags_to_linux(unsigned int if_flags)