git: edc19f8d0fd0 - stable/13 - netlink: restore the ability to delete PINNED routes

From: Andrey V. Elsukov <ae_at_FreeBSD.org>
Date: Tue, 21 Jan 2025 11:46:40 UTC
The branch stable/13 has been updated by ae:

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

commit edc19f8d0fd03c21cd24cbd0e2e004713bb112f6
Author:     Andrey V. Elsukov <ae@FreeBSD.org>
AuthorDate: 2025-01-11 08:25:50 +0000
Commit:     Andrey V. Elsukov <ae@FreeBSD.org>
CommitDate: 2025-01-21 11:45:57 +0000

    netlink: restore the ability to delete PINNED routes
    
    route(8) had such ability before migration to netlink. To be able
    to delete PINNED routes we pass RTM_F_FORCE to rib_del_route_px()
    when userland uses RTF_PINNED flag with RTM_DELETE command.
    This is hackish way for route(8) tool, that third-party software
    usually doesn't use.
    
    PR:             279988
    Tested by:      franco at opnsense org
    Discussed with: glebius
    Differential Revision:  https://reviews.freebsd.org/D46301
    
    (cherry picked from commit 3ce003c8b6151f7764b7934de11c789d6b84ee5c)
---
 sys/netlink/route/rt.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/sys/netlink/route/rt.c b/sys/netlink/route/rt.c
index 24d8c4c9d714..3eed4c4361cf 100644
--- a/sys/netlink/route/rt.c
+++ b/sys/netlink/route/rt.c
@@ -940,7 +940,8 @@ rtnl_handle_delroute(struct nlmsghdr *hdr, struct nlpcb *nlp,
 	}
 
 	error = rib_del_route_px(attrs.rta_table, attrs.rta_dst,
-	    attrs.rtm_dst_len, path_match_func, &attrs, 0, &rc);
+	    attrs.rtm_dst_len, path_match_func, &attrs,
+	    (attrs.rta_rtflags & RTF_PINNED) ? RTM_F_FORCE : 0, &rc);
 	if (error == 0)
 		report_operation(attrs.rta_table, &rc, nlp, hdr);
 	return (error);