From 84598adddffc5e135cc6c7ee632e028dc9d8201a Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Mon, 7 Feb 2022 19:35:05 +0100 Subject: [PATCH] libnm: allow configuring blackhole/unreachable/prohibit routes --- src/libnm-core-impl/nm-setting-ip-config.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/libnm-core-impl/nm-setting-ip-config.c b/src/libnm-core-impl/nm-setting-ip-config.c index 3cc0486e2a..52aa651570 100644 --- a/src/libnm-core-impl/nm-setting-ip-config.c +++ b/src/libnm-core-impl/nm-setting-ip-config.c @@ -1385,7 +1385,12 @@ _ip_route_attribute_validate(const char *name, string = g_variant_get_string(value, NULL); type = nm_net_aux_rtnl_rtntype_a2n(string); - if (!NM_IN_SET(type, RTN_UNICAST, RTN_LOCAL)) { + if (!NM_IN_SET(type, + RTN_UNICAST, + RTN_LOCAL, + RTN_BLACKHOLE, + RTN_UNREACHABLE, + RTN_PROHIBIT)) { g_set_error(error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_PROPERTY, @@ -1486,6 +1491,18 @@ _nm_ip_route_attribute_validate_all(const NMIPRoute *route, GError **error) return FALSE; } break; + case RTN_BLACKHOLE: + case RTN_UNREACHABLE: + case RTN_PROHIBIT: + if (route->next_hop) { + g_set_error(error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + _("a %s route cannot have a next-hop"), + nm_net_aux_rtnl_rtntype_n2a(parse_data.type)); + return FALSE; + } + break; } return TRUE;