From: Paul Donald Date: Sun, 2 Nov 2025 16:40:14 +0000 (+0100) Subject: netlink: Store interface MTU at link change X-Git-Url: http://git.openwrt.org/?a=commitdiff_plain;h=ee4f0df6bd686bf58594fca394dfaf3ba153d92c;p=project%2Fodhcpd.git netlink: Store interface MTU at link change This is used for clamping MTU values. Signed-off-by: Paul Donald Link: https://github.com/openwrt/odhcpd/pull/296 Signed-off-by: Álvaro Fernández Rojas --- diff --git a/src/netlink.c b/src/netlink.c index 5b3dc66..6de9ae7 100644 --- a/src/netlink.c +++ b/src/netlink.c @@ -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 diff --git a/src/odhcpd.h b/src/odhcpd.h index 55107e5..e503029 100644 --- a/src/odhcpd.h +++ b/src/odhcpd.h @@ -333,6 +333,7 @@ struct interface { int ifindex; char *ifname; const char *name; + uint32_t if_mtu; // IPv6 runtime data struct odhcpd_ipaddr *addr6;