netlink: Store interface MTU at link change
authorPaul Donald <[email protected]>
Sun, 2 Nov 2025 16:40:14 +0000 (17:40 +0100)
committerÁlvaro Fernández Rojas <[email protected]>
Mon, 3 Nov 2025 07:17:01 +0000 (08:17 +0100)
This is used for clamping MTU values.

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/netlink.c
src/odhcpd.h

index 5b3dc666adca5b998755522f3bae1e0261743e08..6de9ae74c807a4be97e31797abf70d6dd1eb1be1 100644 (file)
@@ -257,6 +257,13 @@ static int handle_rtm_link(struct nlmsghdr *hdr)
 
                iface->ifflags = ifi->ifi_flags;
 
+               /* store current MTU if available */
+               if (nla[IFLA_MTU]) {
+                       iface->if_mtu = nla_get_u32(nla[IFLA_MTU]);
+                       debug("Netlink setting interface '%s' if_mtu MTU to %d",
+                                       iface->name, iface->if_mtu);
+               }
+
                /*
                 * Assume for link event of the same index, that link changed
                 * and reload services to enable or disable them based on the
index 55107e509a08a466a07aa5a4c7faa9be6ac47667..e503029f722a9cfd1a29d416cb14e27cf7f047ae 100644 (file)
@@ -333,6 +333,7 @@ struct interface {
        int ifindex;
        char *ifname;
        const char *name;
+       uint32_t if_mtu;
 
        // IPv6 runtime data
        struct odhcpd_ipaddr *addr6;