Skip to content

Commit fc4a7f1

Browse files
ssahaniyuwata
authored andcommitted
ndisc: honour MTU for onlink prefix
Fixes #26520
1 parent 37daa74 commit fc4a7f1

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

src/network/networkd-ndisc.c

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ static void ndisc_set_route_priority(Link *link, Route *route) {
168168
static int ndisc_request_route(Route *in, Link *link, sd_ndisc_router *rt) {
169169
_cleanup_(route_freep) Route *route = in;
170170
struct in6_addr router;
171+
uint32_t mtu = 0;
171172
bool is_new;
172173
int r;
173174

@@ -180,6 +181,12 @@ static int ndisc_request_route(Route *in, Link *link, sd_ndisc_router *rt) {
180181
if (r < 0)
181182
return r;
182183

184+
if (link->network->ipv6_accept_ra_use_mtu) {
185+
r = sd_ndisc_router_get_mtu(rt, &mtu);
186+
if (r < 0 && r != -ENODATA)
187+
return log_link_warning_errno(link, r, "Failed to get default router MTU from RA: %m");
188+
}
189+
183190
route->source = NETWORK_CONFIG_SOURCE_NDISC;
184191
route->provider.in6 = router;
185192
if (!route->table_set)
@@ -189,6 +196,8 @@ static int ndisc_request_route(Route *in, Link *link, sd_ndisc_router *rt) {
189196
route->protocol = RTPROT_RA;
190197
if (route->quickack < 0)
191198
route->quickack = link->network->ipv6_accept_ra_quickack;
199+
if (route->mtu == 0)
200+
route->mtu = mtu;
192201

193202
is_new = route_get(NULL, link, route, NULL) < 0;
194203

@@ -256,7 +265,6 @@ static int ndisc_router_process_default(Link *link, sd_ndisc_router *rt) {
256265
struct in6_addr gateway;
257266
uint16_t lifetime_sec;
258267
unsigned preference;
259-
uint32_t mtu = 0;
260268
int r;
261269

262270
assert(link);
@@ -292,12 +300,6 @@ static int ndisc_router_process_default(Link *link, sd_ndisc_router *rt) {
292300
if (r < 0)
293301
return log_link_warning_errno(link, r, "Failed to get default router preference from RA: %m");
294302

295-
if (link->network->ipv6_accept_ra_use_mtu) {
296-
r = sd_ndisc_router_get_mtu(rt, &mtu);
297-
if (r < 0 && r != -ENODATA)
298-
return log_link_warning_errno(link, r, "Failed to get default router MTU from RA: %m");
299-
}
300-
301303
if (link->network->ipv6_accept_ra_use_gateway) {
302304
_cleanup_(route_freep) Route *route = NULL;
303305

@@ -310,7 +312,6 @@ static int ndisc_router_process_default(Link *link, sd_ndisc_router *rt) {
310312
route->gw_family = AF_INET6;
311313
route->gw.in6 = gateway;
312314
route->lifetime_usec = lifetime_usec;
313-
route->mtu = mtu;
314315

315316
r = ndisc_request_route(TAKE_PTR(route), link, rt);
316317
if (r < 0)
@@ -335,8 +336,6 @@ static int ndisc_router_process_default(Link *link, sd_ndisc_router *rt) {
335336
if (!route->pref_set)
336337
route->pref = preference;
337338
route->lifetime_usec = lifetime_usec;
338-
if (route->mtu == 0)
339-
route->mtu = mtu;
340339

341340
r = ndisc_request_route(TAKE_PTR(route), link, rt);
342341
if (r < 0)

0 commit comments

Comments
 (0)