router: Modify relayed RA PIO A flags according to interface policy
authorPaul Donald <newtwen+github@gmail.com>
Fri, 7 Nov 2025 18:54:41 +0000 (19:54 +0100)
committerÁlvaro Fernández Rojas <noltari@gmail.com>
Wed, 10 Dec 2025 17:41:34 +0000 (18:41 +0100)
Effectively:
-inherit the A flag from upstream, but retain the possibility to
disable SLAAC downstream.

h/t user @Shine-

Signed-off-by: Paul Donald <newtwen+github@gmail.com>
Link: https://github.com/openwrt/odhcpd/pull/317
Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
src/router.c

index 608a558d440e3f97b2c3c377cfd3402cc6665e58..3d1efa1779114fc9f1c13a9763c367e423c97f57 100644 (file)
@@ -1202,7 +1202,7 @@ static void forward_router_advertisement(const struct interface *iface, uint8_t
        // MTU option
        struct nd_opt_mtu *mtu_opt = NULL;
        uint32_t ingress_mtu_val = 0;
-       /* PIO L flag and RA M/O Flags */
+       /* PIO L/A flag and RA M/O Flags */
        uint8_t ra_flags;
        size_t pio_count = 0;
        struct fwd_pio_flags {
@@ -1286,6 +1286,15 @@ static void forward_router_advertisement(const struct interface *iface, uint8_t
                        *pio_flags[i].ptr = pio_flags[i].flags;
                        /* ensure L flag (on-link) cleared; relayed == not on-link */
                        *pio_flags[i].ptr &= ~ND_OPT_PI_FLAG_ONLINK;
+                       /*      upstream no SLAAC, downstream no SLAAC: no change
+                        *      upstream no SLAAC, downstream SLAAC: no change
+                        *      upstream SLAAC, downstream SLAAC: no change
+                        *      upstream SLAAC, downstream no SLAAC: clear flag
+                        *      Why? We shall not SLAAC downstream if upstream disables it. Sometimes
+                        *      we just inform about a prefix for DHCPv6 and routing info. 
+                        */
+                       if (!c->ra_slaac)
+                               *pio_flags[i].ptr &= ~ND_OPT_PI_FLAG_AUTO;/* ensure A flag cleared */
                }
 
                /* Apply per-interface modifications of upstream RA state */