From 9c868abadd0950e818c233bb9250077908cfef78 Mon Sep 17 00:00:00 2001 From: Jeremy Kerr Date: Mon, 17 Aug 2026 10:53:39 +0800 Subject: [PATCH 1/2] tests: parse RTA_METRICS from route nlmsgs We would like to test MTU values in newly-added routes, so parse the RTAX_MTU (from the nested RTA_METRICS attribute) in NLSocket._parse_route(), and use the parsed valuq in the Route constructor. This resolves a pending TODO. Signed-off-by: Jeremy Kerr --- tests/mctpenv/__init__.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/mctpenv/__init__.py b/tests/mctpenv/__init__.py index 91f5323..d047f19 100644 --- a/tests/mctpenv/__init__.py +++ b/tests/mctpenv/__init__.py @@ -1227,7 +1227,10 @@ def _parse_route(self, msg): gw = msg.get_attr('RTA_GATEWAY') start_eid = msg.get_attr('RTA_DST') extent_eid = msg['dst_len'] - # todo: RTAX metrics: MTU + mtu = 0 + metrics = msg.get_attr('RTA_METRICS') + if metrics: + mtu = metrics.get_attr('RTAX_MTU', default=0) if ifindex: iface = self.system.find_interface_by_ifindex(ifindex) @@ -1236,7 +1239,7 @@ def _parse_route(self, msg): gw = (gw['net'], gw['eid']) iface = None - return System.Route(start_eid, extent_eid, iface=iface, gw=gw) + return System.Route(start_eid, extent_eid, iface=iface, gw=gw, mtu=mtu) async def _handle_getroute(self, msg): dump = bool(msg['header']['flags'] & netlink.NLM_F_DUMP) From f033b5f6f9fd88413a2f8cadfbe59283ae94ab34 Mon Sep 17 00:00:00 2001 From: Jeremy Kerr Date: Mon, 17 Aug 2026 10:59:33 +0800 Subject: [PATCH 2/2] mctpd: Set default peer MTU earlier Commit 83cbe46e moved peer route creation to an earlier point, before the peer->mtu had been set in setup_added_peer(). This means we never use the minimum MTU value in created routes, so lose the safety of a known-good MTU setting. The setup_added_peer() path is really the wrong place for MTU initialisation; this is for property querying. Instead, set the initial MTU when the peer is constructed. Fixes: 83cbe46e ("mctpd: remove add_peer_route() from setup_added_peer()") Reported-by: Brian McKenzie Signed-off-by: Jeremy Kerr --- CHANGELOG.md | 6 ++++++ src/mctpd.c | 7 ++++--- tests/test_mctpd.py | 16 ++++++++++++++++ 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1655ba5..77f8ced 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). 1. `mctp-client` binary now handles the `cxl-cci` MCTP message type +### Fixes + +1. In v2.6. we lost the peer initial MTU sematics, which gave us a safe minimum + MTU on peer routes when peers were added. This is now fixed - peer routes + will have an MTU set to the link-reported minimum, as introduced in v2.1. + ## [2.6] - 2026-07-21 ### Added diff --git a/src/mctpd.c b/src/mctpd.c index a1d2728..78363a5 100644 --- a/src/mctpd.c +++ b/src/mctpd.c @@ -2048,6 +2048,10 @@ static int add_peer(struct ctx *ctx, const dest_phys *dest, mctp_eid_t eid, peer->state = REMOTE; peer->ctx = ctx; + // Set minimum MTU by default for compatibility. Clients can increase + // this with .SetMTU as needed + peer->mtu = mctp_nl_min_mtu_byindex(ctx->nl, peer->phys.ifindex); + // Update network eid map n->peers[eid] = peer; @@ -3531,9 +3535,6 @@ static int setup_added_peer(struct peer *peer) bug_warn("%s Bad net %u", __func__, peer->net); return -EPROTO; } - // Set minimum MTU by default for compatibility. Clients can increase - // this with .SetMTU as needed - peer->mtu = mctp_nl_min_mtu_byindex(peer->ctx->nl, peer->phys.ifindex); rc = query_peer_properties(peer); if (rc < 0) diff --git a/tests/test_mctpd.py b/tests/test_mctpd.py index 7853794..5d3956a 100644 --- a/tests/test_mctpd.py +++ b/tests/test_mctpd.py @@ -216,6 +216,22 @@ async def test_setup_endpoint_no_get_uuid(dbus, mctpd): assert eid == ep.eid +async def test_setup_endpoint_mtu(dbus, mctpd): + """Newly-added endpoints should start with a minimum MTU""" + iface = mctpd.system.interfaces[0] + ep = mctpd.network.endpoints[0] + + # ensure we can distinguish a correct min mtu from a no-mtu case + assert iface.min_mtu != 0 + + mctp = await mctpd_mctp_iface_obj(dbus, iface) + (eid, net, path, new) = await mctp.call_setup_endpoint(ep.lladdr) + + assert len(mctpd.system.routes) == 1 + route = mctpd.system.routes[0] + assert route.mtu == iface.min_mtu + + async def test_remove_endpoint(dbus, mctpd): """Test neighbour removal""" iface = mctpd.system.interfaces[0]