From d6fceaf1f7ff765bdc3b135f3d3676ec689da312 Mon Sep 17 00:00:00 2001 From: Susant Sahani Date: Thu, 24 Nov 2016 03:02:19 +0530 Subject: networkd: handle MTU field in IPv6 RA (#4719) This patch handles the custom MTU field in IPv6 RA. fixes RFE #4464 --- src/network/networkd-ndisc.c | 8 ++++++++ src/network/networkd-route.c | 14 ++++++++++++++ src/network/networkd-route.h | 1 + 3 files changed, 23 insertions(+) (limited to 'src/network') diff --git a/src/network/networkd-ndisc.c b/src/network/networkd-ndisc.c index 70283e5347..5320592f7a 100644 --- a/src/network/networkd-ndisc.c +++ b/src/network/networkd-ndisc.c @@ -56,6 +56,7 @@ static void ndisc_router_process_default(Link *link, sd_ndisc_router *rt) { struct in6_addr gateway; uint16_t lifetime; unsigned preference; + uint32_t mtu; usec_t time_now; int r; Address *address; @@ -116,6 +117,12 @@ static void ndisc_router_process_default(Link *link, sd_ndisc_router *rt) { return; } + r = sd_ndisc_router_get_mtu(rt, &mtu); + if (r < 0) { + log_link_warning_errno(link, r, "Failed to get default router MTU from RA: %m"); + return; + } + r = route_new(&route); if (r < 0) { log_link_error_errno(link, r, "Could not allocate route: %m"); @@ -128,6 +135,7 @@ static void ndisc_router_process_default(Link *link, sd_ndisc_router *rt) { route->pref = preference; route->gw.in6 = gateway; route->lifetime = time_now + lifetime * USEC_PER_SEC; + route->mtu = mtu; r = route_configure(route, link, ndisc_netlink_handler); if (r < 0) { diff --git a/src/network/networkd-route.c b/src/network/networkd-route.c index f78e106991..bde26a42d4 100644 --- a/src/network/networkd-route.c +++ b/src/network/networkd-route.c @@ -605,6 +605,20 @@ int route_configure( if (r < 0) return log_error_errno(r, "Could not append RTA_OIF attribute: %m"); + r = sd_netlink_message_open_container(req, RTA_METRICS); + if (r < 0) + return log_error_errno(r, "Could not append RTA_METRICS attribute: %m"); + + if (route->mtu > 0) { + r = sd_netlink_message_append_u32(req, RTAX_MTU, route->mtu); + if (r < 0) + return log_error_errno(r, "Could not append RTAX_MTU attribute: %m"); + } + + r = sd_netlink_message_close_container(req); + if (r < 0) + return log_error_errno(r, "Could not append RTA_METRICS attribute: %m"); + r = sd_netlink_call_async(link->manager->rtnl, req, callback, link, 0, NULL); if (r < 0) return log_error_errno(r, "Could not send rtnetlink message: %m"); diff --git a/src/network/networkd-route.h b/src/network/networkd-route.h index d4e4dbac0b..02f0b27675 100644 --- a/src/network/networkd-route.h +++ b/src/network/networkd-route.h @@ -37,6 +37,7 @@ struct Route { unsigned char tos; uint32_t priority; /* note that ip(8) calls this 'metric' */ uint32_t table; + uint32_t mtu; unsigned char pref; unsigned flags; -- cgit v1.2.3-54-g00ecf