router: utilize interface ra_mtu for RA
authorPaul Donald <[email protected]>
Thu, 30 Oct 2025 00:53:44 +0000 (01:53 +0100)
committerÁlvaro Fernández Rojas <[email protected]>
Mon, 3 Nov 2025 07:17:12 +0000 (08:17 +0100)
MTU is now set at configure time.

Change ra_mtu to uint32 since it never stores a negative value.

Signed-off-by: Paul Donald <[email protected]>
Link: https://github.com/openwrt/odhcpd/pull/296
Signed-off-by: Álvaro Fernández Rojas <[email protected]>
src/odhcpd.h
src/router.c

index e503029f722a9cfd1a29d416cb14e27cf7f047ae..3659f085293ba404046898f10ff4d9dc3bee360c 100644 (file)
@@ -406,7 +406,7 @@ struct interface {
        uint32_t ra_reachabletime;
        uint32_t ra_retranstime;
        uint32_t ra_hoplimit;
-       int ra_mtu;
+       uint32_t ra_mtu;
        uint32_t max_preferred_lifetime;
        uint32_t max_valid_lifetime;
 
index f841b2fffc4287f5f2c9e271b63b7eee5159f532..82d3187d1cb65960674ff3596803484ce4167ade 100644 (file)
@@ -569,7 +569,7 @@ static int send_router_advert(struct interface *iface, const struct in6_addr *fr
         * for shortest lived prefix
         */
        uint32_t lowest_found_lifetime = UINT32_MAX, highest_found_lifetime = 0, maxival, ra_lifetime;
-       int msecs, mtu = iface->ra_mtu, hlim = iface->ra_hoplimit;
+       int msecs, hlim = iface->ra_hoplimit;
        bool default_route = false;
        bool valid_prefix = false;
        char buf[INET6_ADDRSTRLEN];
@@ -602,13 +602,7 @@ static int send_router_advert(struct interface *iface, const struct in6_addr *fr
        adv.mtu.nd_opt_mtu_type = ND_OPT_MTU;
        adv.mtu.nd_opt_mtu_len = 1;
 
-       if (mtu == 0)
-               mtu = odhcpd_get_interface_config(iface->ifname, "mtu");
-
-       if (mtu < 1280)
-               mtu = 1280;
-
-       adv.mtu.nd_opt_mtu_mtu = htonl(mtu);
+       adv.mtu.nd_opt_mtu_mtu = htonl(iface->ra_mtu);
 
        iov[IOV_RA_ADV].iov_base = (char *)&adv;
        iov[IOV_RA_ADV].iov_len = sizeof(adv);