From nobody Sat Mar 04 09:26:58 2023 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 4PTKH66Ngtz3vnqk; Sat, 4 Mar 2023 09:26:58 +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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4PTKH65f3Jz44Cl; Sat, 4 Mar 2023 09:26:58 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1677922018; 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=c5sNbJWsyXnT733aYv2OaBl6950ZtMB4cZgj8dMPNlU=; b=TQcq6JP2mWVgGfxUJNn4GFej+E643bEL0UUrJfvgbx/GrrWHa2cgCbt/+xF7khtkOEYBhJ EIYFS71UqOS0qFFaNjvLSShv+RMJVzF95T7QWoWCPYfbSUcy3XMGKmzzDjmTnmyvYXGtUn eezWCiZ5hQpRKYkH5TSIeBhh4z5BSKy4teJ7q6Snp2p2pHbPj4VmIf1c8MaU6dmw4YJWFm WZtoLmrUqTrTv5jXpsmZ2YEjshH4l5yygrngRBdXGtW6a2xxcV7m0UxQ8AQg2jNq0qLL/N rXXXFIQnPvsphjBkfrIz7I8A9UHGU9icdU9GtCPBcCRE5yPLj0nMkwqNL5E0uQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1677922018; 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=c5sNbJWsyXnT733aYv2OaBl6950ZtMB4cZgj8dMPNlU=; b=iU3eRQx9cNSHyJtbtWqnkGPOP6MHMYzLzcSs0CUGqbY8DNb5+RWQZY0pDTSAS4Jwae2bY2 2eqv2x8vIicEj95VXhqj30wpTnJkqiI/oFAkebWCxPo5Ncdj+dormiuO4WXIZbewbqQfju xNapuUGLBwhW+JYlY2/BR/tVTdZP7UO/gFNcW4/GOiekxvebObBzopIrl/9OTDN4UVjzpO IB8dnODP12xNw51zi5zSttz4eH+meeyMedQV2GtEmF9wwHznGFWUY1YcCnZKxP/xAMHFIK O2KsDG1rF4mnbITcLgiXH+cdb7r4p8YKR5oHrRUEVCmHOhKEO+uXAX4YbWI2Wg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1677922018; a=rsa-sha256; cv=none; b=BhcCOZud0gaLxSH8+iEOlOOhYHTLpiC1PhcwsekuRm9SjLAiNEBitiaplJSAf97XVfKBx9 GPb500ePPbxEH3ZDlQfPAqVqkwapj7LPdM8KwUvgXO2I6wEYrKIrpEYEPqtM6LaqrzQPN4 R73AUb1wng+UMQ+AZJXmzcO7v8uBgzttx7kPHMcRlQZ6zumOliEk8hDdkwfG68DC+kdPcR qC1xyBSGBx94NQHK7AGgBt9vsIy/8KjEp+ozxH+Ssl832ui2IBLNmBmt8tGskA4ouNK8yb oaDX5eRE1La5elqoq9rjpobhFT/j2UWAvFXJjCczJPEotlKfutLQAn7kDgJPMQ== 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 4PTKH64jrRzZSB; Sat, 4 Mar 2023 09:26:58 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 3249QwAC095525; Sat, 4 Mar 2023 09:26:58 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 3249QwjJ095524; Sat, 4 Mar 2023 09:26:58 GMT (envelope-from git) Date: Sat, 4 Mar 2023 09:26:58 GMT Message-Id: <202303040926.3249QwjJ095524@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dmitry Chagin Subject: git: 5c32488de0bb - main - linux(4): Add a counterpart to linux_ifflags 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: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dchagin X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 5c32488de0bbd9f7b52e3ff8be8ca2facc3169ba Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by dchagin: URL: https://cgit.FreeBSD.org/src/commit/?id=5c32488de0bbd9f7b52e3ff8be8ca2facc3169ba commit 5c32488de0bbd9f7b52e3ff8be8ca2facc3169ba Author: Dmitry Chagin AuthorDate: 2023-03-04 09:26:48 +0000 Commit: Dmitry Chagin CommitDate: 2023-03-04 09:26:48 +0000 linux(4): Add a counterpart to linux_ifflags For further use in linux_ioctl_socket add bsd_to_linux_ifflags() which accepts FreeBSD interface flags and translate it to Linux if flags. Reviewed by: melifaro Differential Revision: https://reviews.freebsd.org/D38873 --- sys/compat/linux/linux.c | 13 ++++++++++--- sys/compat/linux/linux_common.h | 1 + 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/sys/compat/linux/linux.c b/sys/compat/linux/linux.c index 53a874ebfab7..252645cf2ae5 100644 --- a/sys/compat/linux/linux.c +++ b/sys/compat/linux/linux.c @@ -434,10 +434,17 @@ ifname_linux_to_bsd(struct thread *td, const char *lxname, char *bsdname) unsigned short linux_ifflags(struct ifnet *ifp) { - unsigned short fl, flags; + unsigned short flags; + + flags = if_getflags(ifp) | if_getdrvflags(ifp); + return (bsd_to_linux_ifflags(flags)); +} + +unsigned short +bsd_to_linux_ifflags(int fl) +{ + unsigned short flags = 0; - fl = (if_getflags(ifp) | if_getdrvflags(ifp)) & 0xffff; - flags = 0; if (fl & IFF_UP) flags |= LINUX_IFF_UP; if (fl & IFF_BROADCAST) diff --git a/sys/compat/linux/linux_common.h b/sys/compat/linux/linux_common.h index 3392f55672f3..94ff5e49b57a 100644 --- a/sys/compat/linux/linux_common.h +++ b/sys/compat/linux/linux_common.h @@ -39,6 +39,7 @@ int ifname_linux_to_bsd(struct thread *, const char *, char *); unsigned short linux_ifflags(struct ifnet *); int linux_ifhwaddr(struct ifnet *ifp, struct l_sockaddr *lsa); +unsigned short bsd_to_linux_ifflags(int); int linux_to_bsd_domain(int domain); int bsd_to_linux_domain(int domain); int bsd_to_linux_sockaddr(const struct sockaddr *sa,