router: Modify relayed RA PIO P flag according to interface policy master
authorPaul Donald <newtwen+github@gmail.com>
Sat, 8 Nov 2025 17:43:35 +0000 (18:43 +0100)
committerÁlvaro Fernández Rojas <noltari@gmail.com>
Wed, 10 Dec 2025 17:42:00 +0000 (18:42 +0100)
Effectively:
-inherit the P flag from upstream, but retain the possibility to disable
its availability downstream, if any of the following are disabled:

-DHCPv6
-DHCPv6-PD
-DHCPv6-PD Preferred

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 3d1efa1779114fc9f1c13a9763c367e423c97f57..8334a1c86b9b20c6737f3ae8fb2a014890b1f890 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;
        // MTU option
        struct nd_opt_mtu *mtu_opt = NULL;
        uint32_t ingress_mtu_val = 0;
-       /* PIO L/A flag and RA M/O Flags */
+       /* PIO L/A/R/P flag and RA M/O Flags */
        uint8_t ra_flags;
        size_t pio_count = 0;
        struct fwd_pio_flags {
        uint8_t ra_flags;
        size_t pio_count = 0;
        struct fwd_pio_flags {
@@ -1295,6 +1295,11 @@ static void forward_router_advertisement(const struct interface *iface, uint8_t
                         */
                        if (!c->ra_slaac)
                                *pio_flags[i].ptr &= ~ND_OPT_PI_FLAG_AUTO;/* ensure A flag cleared */
                         */
                        if (!c->ra_slaac)
                                *pio_flags[i].ptr &= ~ND_OPT_PI_FLAG_AUTO;/* ensure A flag cleared */
+
+                       /* we have no opinion on the R flag - it can be forwarded */
+
+                       if (c->dhcpv6 == MODE_DISABLED || !c->dhcpv6_pd || !c->dhcpv6_pd_preferred)
+                               *pio_flags[i].ptr &= ~ND_OPT_PI_FLAG_PD_PREFERRED;/* ensure P flag (DHCPv6-PD) cleared */
                }
 
                /* Apply per-interface modifications of upstream RA state */
                }
 
                /* Apply per-interface modifications of upstream RA state */