From c4d54c21fd773557e8b91b9fc11e00436801b09a Mon Sep 17 00:00:00 2001
From: Ondrej Zajicek <santiago@crfreenet.org>
Date: Thu, 27 Nov 2025 17:59:44 +0100
Subject: [PATCH] RAdv: Fix flags for deprecated prefixes

When a prefix is deprecated (valid_lifetime == 0), it should be
announced with the same flags as before. The old code announced it
without any flags, which leads to being ignored by recipients.

Note that a prefix could be depreacted for two reason - it is removed
from the interface, or it is deconfigured in BIRD configuration.

Thanks to Michael Saxl for the bugreport.

Fixes: #323
---
 proto/radv/packets.c | 4 ++--
 proto/radv/radv.c    | 4 ++++
 proto/radv/radv.h    | 3 +++
 3 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/proto/radv/packets.c b/proto/radv/packets.c
index 77c987949..8b060a206 100644
--- a/proto/radv/packets.c
+++ b/proto/radv/packets.c
@@ -306,8 +306,8 @@ radv_prepare_prefix(struct radv_iface *ifa, struct radv_prefix *px,
   op->type = OPT_PREFIX;
   op->length = 4;
   op->pxlen = px->prefix.pxlen;
-  op->flags = (pc->onlink ? OPT_PX_ONLINK : 0) |
-    (pc->autonomous ? OPT_PX_AUTONOMOUS : 0);
+  op->flags = (px->onlink ? OPT_PX_ONLINK : 0) |
+	      (px->autonomous ? OPT_PX_AUTONOMOUS : 0);
   op->valid_lifetime = (ifa->ra->active || !pc->valid_lifetime_sensitive) ?
     htonl(pc->valid_lifetime) : 0;
   op->preferred_lifetime = (ifa->ra->active || !pc->preferred_lifetime_sensitive) ?
diff --git a/proto/radv/radv.c b/proto/radv/radv.c
index ba31e1a84..4ff075713 100644
--- a/proto/radv/radv.c
+++ b/proto/radv/radv.c
@@ -161,6 +161,10 @@ radv_prepare_prefixes(struct radv_iface *ifa)
     existing->valid = 1;
     existing->changed = now;
     existing->mark = 1;
+
+    existing->onlink = pc->onlink;
+    existing->autonomous = pc->autonomous;
+
     existing->cf = pc;
   }
 
diff --git a/proto/radv/radv.h b/proto/radv/radv.h
index ba4a1b6c7..d4d3a50f3 100644
--- a/proto/radv/radv.h
+++ b/proto/radv/radv.h
@@ -170,6 +170,9 @@ struct radv_prefix		/* One prefix we advertise */
   u8 valid;			/* Is the prefix valid? If not, we advertise it
 				   with 0 lifetime, so clients stop using it */
   u8 mark;			/* A temporary mark for processing */
+  u8 onlink;			/* Flags copied from prefix config */
+  u8 autonomous;
+
   btime changed;		/* Last time when the prefix changed */
   struct radv_prefix_config *cf; /* The config tied to this prefix */
 };
-- 
GitLab

