From 664f8f1bea7f3c46bdfcd637e694e2c3c627fa7b Mon Sep 17 00:00:00 2001 From: Thomas Egerer Date: Tue, 17 Oct 2023 11:10:26 +0000 Subject: [PATCH] xfrm: clear XFRM_SP_ATTR_TMPL when removing the last template from a policy Leaving XFRM_SP_ATTR_TMPL active in the mask may not impose a problem but, when removing the last template from a policy, the value signifying attached templates should be cleared. Signed-off-by: Thomas Egerer Conflict:NA Reference:https://github.com/thom311/libnl/commit/664f8f1bea7f3c46bdfcd637e694e2c3c627fa7b --- lib/xfrm/sp.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/xfrm/sp.c b/lib/xfrm/sp.c index 30f9182..ab7cf89 100644 --- a/lib/xfrm/sp.c +++ b/lib/xfrm/sp.c @@ -1317,6 +1317,8 @@ void xfrmnl_sp_remove_usertemplate(struct xfrmnl_sp *sp, struct xfrmnl_user_tmpl if (sp->ce_mask & XFRM_SP_ATTR_TMPL) { sp->nr_user_tmpl--; nl_list_del(&utmpl->utmpl_list); + if (sp->nr_user_tmpl == 0) + sp->ce_mask &= ~XFRM_SP_ATTR_TMPL; } } -- 2.33.0