git: 0e82cd099e2a - stable/14 - ifconfig: fix removing IPv6 addresses

From: Zhenlei Huang <zlei_at_FreeBSD.org>
Date: Thu, 05 Feb 2026 18:12:20 UTC
The branch stable/14 has been updated by zlei:

URL: https://cgit.FreeBSD.org/src/commit/?id=0e82cd099e2ab5ad8aa67f98fa4b8b430c23947c

commit 0e82cd099e2ab5ad8aa67f98fa4b8b430c23947c
Author:     Kristof Provost <kp@FreeBSD.org>
AuthorDate: 2025-07-29 09:50:11 +0000
Commit:     Zhenlei Huang <zlei@FreeBSD.org>
CommitDate: 2026-02-05 18:10:36 +0000

    ifconfig: fix removing IPv6 addresses
    
    Sponsored by:   Rubicon Communications, LLC ("Netgate")
    
    (cherry picked from commit da50f49977cc4e6aae55cb2379313599249a8dd2)
---
 sbin/ifconfig/af_inet6.c     |  2 +-
 sbin/ifconfig/tests/inet6.sh | 30 ++++++++++++++++++++++++++++++
 2 files changed, 31 insertions(+), 1 deletion(-)

diff --git a/sbin/ifconfig/af_inet6.c b/sbin/ifconfig/af_inet6.c
index 511b25580f07..a5c406db8a0c 100644
--- a/sbin/ifconfig/af_inet6.c
+++ b/sbin/ifconfig/af_inet6.c
@@ -761,7 +761,7 @@ static struct afswtch af_inet6 = {
 #else
 	.af_difaddr	= NL_RTM_DELADDR,
 	.af_aifaddr	= NL_RTM_NEWADDR,
-	.af_ridreq	= &in6_add,
+	.af_ridreq	= &in6_del,
 	.af_addreq	= &in6_add,
 	.af_exec	= in6_exec_nl,
 #endif
diff --git a/sbin/ifconfig/tests/inet6.sh b/sbin/ifconfig/tests/inet6.sh
index edfd88d93af7..22399915a64d 100644
--- a/sbin/ifconfig/tests/inet6.sh
+++ b/sbin/ifconfig/tests/inet6.sh
@@ -76,8 +76,38 @@ broadcast_cleanup()
 	vnet_cleanup
 }
 
+atf_test_case "delete6" "cleanup"
+delete6_head()
+{
+	atf_set descr 'Test removing IPv6 addresses'
+	atf_set require.user root
+}
+
+delete6_body()
+{
+	vnet_init
+
+	ep=$(vnet_mkepair)
+
+	atf_check -s exit:0 \
+	    ifconfig ${ep}a inet6 fe80::42/64
+	atf_check -s exit:0 -o match:"fe80::42%${ep}" \
+	    ifconfig ${ep}a inet6
+
+	atf_check -s exit:0 \
+	    ifconfig ${ep}a inet6 -alias fe80::42
+	atf_check -s exit:0 -o not-match:"fe80::42%${ep}" \
+	    ifconfig ${ep}a inet6
+}
+
+delete6_cleanup()
+{
+	vnet_cleanup
+}
+
 atf_init_test_cases()
 {
 	atf_add_test_case netmask
 	atf_add_test_case broadcast
+	atf_add_test_case delete6
 }