networkd: handle MTU field in IPv6 RA (#4719)
This patch handles the custom MTU field in IPv6 RA. fixes RFE #4464
This commit is contained in:
committed by
Lennart Poettering
parent
99245111ac
commit
d6fceaf1f7
@@ -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) {
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user