From nobody Fri Jan 06 19:19:01 2023 X-Original-To: dev-commits-src-main@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 4NpY6Y5JsJz2pFRZ; Fri, 6 Jan 2023 19:19:01 +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 4NpY6Y4nzrz3hTK; Fri, 6 Jan 2023 19:19:01 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1673032741; 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=XNC6KqVobCtXTG8ap71FCqOu3bVYjyJMqIPYtfgFXq8=; b=Q0HzXJRG25mldbAxKXQZmg253ovawkraKxwYmrchuwmrgfIk3GPZjNf9an9NCaWjEsf1yE hQDE5A5WR+LWye57y602/9NB2zRQAXYStP/OgT4UEprx3VTJEv5nWknieKvn2Si+LSNyGU e3lmP/kJB+tb0xQiskem0ldBewBTOLByKjB7JL4TjyPeH6PijaPAj7ralnbh3YbaCUghuK cUnedmBhhPp66rWM9AUrLWC/hczVimQVBIr0L7HsosSCgcg/vgbBKOxP1+EjvF5j4tIeK3 fvWLvhRoeOYOjl6KIBn+WgWddnXAaaSkRru97khrRzqokpe8+gZdI9IpU0FuTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1673032741; 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=XNC6KqVobCtXTG8ap71FCqOu3bVYjyJMqIPYtfgFXq8=; b=Jrq+ov9mTrCctNkGPFYuYmZFiRjFkNm3gEMu8+8tmDoPnDpaS/cSnVz1X6kTEMPdYd6Gx6 md0Jq/CQb3GD1vLk4PuPZ1UaQRdX2MejEVVytonbDd9sHH+VvaiSai3QHZBp43UH98MXw1 XdSl7vxYlRxo8NLUs/A61qyKWC+08tAwTdsev0nCHzJ0sTZqRQ2Myvs7Z+CChj3/ev7BEO Gi4+giMnvx5p05zR9UqEQNKfWKuvMpHi2YDNWgFYaaIKzUrGlnx4i8oO5Y2gD6NQhm0qS3 /UJw0QxcgtctZW3EPT8CJmYiwD1KHUo6MV6dOuC+RANRIEctP8SirjZi8uyFyg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1673032741; a=rsa-sha256; cv=none; b=Jl/ussRmkn0/jj8ExDd3H7+uiamXzU3a52o5C+FMXxARE31yau5ZhLtqcNFkSkN+7bMgiG IztIQXW6T+VoP5gtrx8FgAARcR/0LIuIUHUYiCdibjvD71Q9rWzGT1wi4u5pydRf1qH8+t /uFd8keMr+0uApxChHVsUUnMfjpv6X1iu5hqEWvmMpmPJ66VRSNa0kswtjNw+iS+BWHNFG ZT34VUoqHbNQurAQUhwI+AeMWcAsvh4KeBtpizNIkCsoZ+6SjJOH19VW+L199yeAUzbAU2 ua1iW7XS7JlG8tKp7MnA3mPqb6QxIVDTcPpdn5D9TNgXML2UdfqgOggVLspALQ== 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 4NpY6Y3rhKzgxS; Fri, 6 Jan 2023 19:19:01 +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 306JJ1Hh010354; Fri, 6 Jan 2023 19:19:01 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 306JJ1c2010353; Fri, 6 Jan 2023 19:19:01 GMT (envelope-from git) Date: Fri, 6 Jan 2023 19:19:01 GMT Message-Id: <202301061919.306JJ1c2010353@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: "Alexander V. Chernikov" Subject: git: 13214c601a49 - main - netlink: fix ifaddr reporting. List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: melifaro X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 13214c601a49d733bd17d42b927788bb9feea536 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by melifaro: URL: https://cgit.FreeBSD.org/src/commit/?id=13214c601a49d733bd17d42b927788bb9feea536 commit 13214c601a49d733bd17d42b927788bb9feea536 Author: Alexander V. Chernikov AuthorDate: 2023-01-06 19:13:42 +0000 Commit: Alexander V. Chernikov CommitDate: 2023-01-06 19:18:54 +0000 netlink: fix ifaddr reporting. Output the proper attributes for IPv4/IPvv6 ifaddrs: * IFA_ADDRESS contains local address in every case except p2p, in that case it contains the peer address * IFA_LOCAL contains local address. It is always present in IPv4, or in IPv6/p2p. * IFA_BROADCAST contains the network broadcast address (if any) Reported by: Adam Wood Tested by: Adam Wood --- sys/netlink/route/iface.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/sys/netlink/route/iface.c b/sys/netlink/route/iface.c index b033ba71009d..81ae5bc8090f 100644 --- a/sys/netlink/route/iface.c +++ b/sys/netlink/route/iface.c @@ -794,11 +794,23 @@ dump_iface_addr(struct nl_writer *nw, struct ifnet *ifp, struct ifaddr *ifa, ifamsg->ifa_scope = ifa_get_scope(ifa); ifamsg->ifa_index = ifp->if_index; - struct sockaddr *dst_sa = ifa->ifa_dstaddr; - if ((dst_sa == NULL) || (dst_sa->sa_family != sa->sa_family)) - dst_sa = sa; - dump_sa(nw, IFA_ADDRESS, dst_sa); - dump_sa(nw, IFA_LOCAL, sa); + if (ifp->if_flags & IFF_POINTOPOINT) { + dump_sa(nw, IFA_ADDRESS, ifa->ifa_dstaddr); + dump_sa(nw, IFA_LOCAL, sa); + } else { + dump_sa(nw, IFA_ADDRESS, sa); +#ifdef INET + /* + * In most cases, IFA_ADDRESS == IFA_LOCAL + * Skip IFA_LOCAL for anything except INET + */ + if (sa->sa_family == AF_INET) + dump_sa(nw, IFA_LOCAL, sa); +#endif + } + if (ifp->if_flags & IFF_BROADCAST) + dump_sa(nw, IFA_BROADCAST, ifa->ifa_broadaddr); + nlattr_add_string(nw, IFA_LABEL, if_name(ifp)); uint32_t val = 0; // ifa->ifa_flags;