Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 05 Feb 2026 18:12:19 +0000
From:      Zhenlei Huang <zlei@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Cc:        Gleb Smirnoff <glebius@FreeBSD.org>
Subject:   git: 52ebb8a7d4f8 - stable/14 - ifconfig: fix 'ifconfig -l link'
Message-ID:  <6984dd83.31735.4fcf7909@gitrepo.freebsd.org>

index | next in thread | raw e-mail

The branch stable/14 has been updated by zlei:

URL: https://cgit.FreeBSD.org/src/commit/?id=52ebb8a7d4f8c77b9dacdeef1dff3caec1394bea

commit 52ebb8a7d4f8c77b9dacdeef1dff3caec1394bea
Author:     Gleb Smirnoff <glebius@FreeBSD.org>
AuthorDate: 2023-08-25 17:31:55 +0000
Commit:     Zhenlei Huang <zlei@FreeBSD.org>
CommitDate: 2026-02-05 18:10:36 +0000

    ifconfig: fix 'ifconfig -l link'
    
    The rtnetlink(4) RTM_GETADDR does not list link level addresses, thus
    the correct match for interfaces that have a link level address should
    be based on what was returned by RTM_GETLINK.
    
    Reviewed by:            melifaro
    Differential Revision:  https://reviews.freebsd.org/D41586
    
    (cherry picked from commit 6f3947be2aff9350514b5a414104d0afaeb53cdf)
---
 sbin/ifconfig/ifconfig_netlink.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/sbin/ifconfig/ifconfig_netlink.c b/sbin/ifconfig/ifconfig_netlink.c
index aadd7d1096c3..7145c037e54e 100644
--- a/sbin/ifconfig/ifconfig_netlink.c
+++ b/sbin/ifconfig/ifconfig_netlink.c
@@ -278,7 +278,13 @@ match_iface(struct ifconfig_args *args, struct iface *iface)
 			.sdl_alen = NLA_DATA_LEN(link->ifla_address),
 		};
 		return (match_ether(&sdl));
-	}
+	} else if (args->afp->af_af == AF_LINK)
+		/*
+		 * The rtnetlink(4) RTM_GETADDR does not list link level
+		 * addresses, so latter cycle won't match anything.  Short
+		 * circuit on RTM_GETLINK has provided us an address.
+		 */
+		return (link->ifla_address != NULL);
 
 	for (struct ifa *ifa = iface->ifa; ifa != NULL; ifa = ifa->next) {
 		if (args->afp->af_af == ifa->addr.ifa_family)


home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?6984dd83.31735.4fcf7909>