mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-30 10:50:11 +01:00
all: add support for route type "throw"
After adding support for "blackhole", "unreachable" and "prohibit" route types, let's also add support for "throw" type. It works basically the same as the other types, so supporting it seems very straight forward. https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1124
This commit is contained in:
parent
b2e559fab2
commit
b8f689ac53
8 changed files with 27 additions and 9 deletions
|
|
@ -1352,8 +1352,13 @@ nm_utils_ip_route_attribute_to_platform(int addr_family,
|
|||
int type;
|
||||
|
||||
type = nm_net_aux_rtnl_rtntype_a2n(g_variant_get_string(variant, NULL));
|
||||
nm_assert(
|
||||
NM_IN_SET(type, RTN_UNICAST, RTN_LOCAL, RTN_BLACKHOLE, RTN_UNREACHABLE, RTN_PROHIBIT));
|
||||
nm_assert(NM_IN_SET(type,
|
||||
RTN_UNICAST,
|
||||
RTN_LOCAL,
|
||||
RTN_BLACKHOLE,
|
||||
RTN_UNREACHABLE,
|
||||
RTN_PROHIBIT,
|
||||
RTN_THROW));
|
||||
|
||||
r->type_coerced = nm_platform_route_type_coerce(type);
|
||||
} else
|
||||
|
|
|
|||
|
|
@ -762,6 +762,7 @@ test_route_type_is_nodev(void)
|
|||
case RTN_BLACKHOLE:
|
||||
case RTN_UNREACHABLE:
|
||||
case RTN_PROHIBIT:
|
||||
case RTN_THROW:
|
||||
is_nodev = TRUE;
|
||||
break;
|
||||
default:
|
||||
|
|
|
|||
|
|
@ -1899,14 +1899,17 @@ test_blackhole(gconstpointer test_data)
|
|||
NMPlatformIPXRoute rr = {};
|
||||
int r = -1;
|
||||
int i;
|
||||
guint8 rtn_type;
|
||||
|
||||
rtn_type = nmtst_rand_select(RTN_BLACKHOLE, RTN_UNREACHABLE, RTN_PROHIBIT, RTN_THROW);
|
||||
|
||||
if (IS_IPv4) {
|
||||
rr.r4 = (const NMPlatformIP4Route){
|
||||
.type_coerced = nmtst_rand_select(RTN_BLACKHOLE, RTN_UNREACHABLE, RTN_PROHIBIT),
|
||||
.type_coerced = nm_platform_route_type_coerce(rtn_type),
|
||||
};
|
||||
} else {
|
||||
rr.r6 = (const NMPlatformIP6Route){
|
||||
.type_coerced = nmtst_rand_select(RTN_BLACKHOLE, RTN_UNREACHABLE, RTN_PROHIBIT),
|
||||
.type_coerced = nm_platform_route_type_coerce(rtn_type),
|
||||
.metric = 1000,
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1390,7 +1390,8 @@ _ip_route_attribute_validate(const char *name,
|
|||
RTN_LOCAL,
|
||||
RTN_BLACKHOLE,
|
||||
RTN_UNREACHABLE,
|
||||
RTN_PROHIBIT)) {
|
||||
RTN_PROHIBIT,
|
||||
RTN_THROW)) {
|
||||
g_set_error(error,
|
||||
NM_CONNECTION_ERROR,
|
||||
NM_CONNECTION_ERROR_INVALID_PROPERTY,
|
||||
|
|
@ -1494,6 +1495,7 @@ _nm_ip_route_attribute_validate_all(const NMIPRoute *route, GError **error)
|
|||
case RTN_BLACKHOLE:
|
||||
case RTN_UNREACHABLE:
|
||||
case RTN_PROHIBIT:
|
||||
case RTN_THROW:
|
||||
if (route->next_hop) {
|
||||
g_set_error(error,
|
||||
NM_CONNECTION_ERROR,
|
||||
|
|
|
|||
|
|
@ -1006,7 +1006,8 @@ nm_setting_ip4_config_class_init(NMSettingIP4ConfigClass *klass)
|
|||
* </listitem>
|
||||
* <listitem>
|
||||
* <para><literal>"type"</literal> - one of <literal>unicast</literal>, <literal>local</literal>, <literal>blackhole</literal>,
|
||||
* <literal>unavailable</literal>, <literal>prohibit</literal>. The default is <literal>unicast</literal>.</para>
|
||||
* <literal>unavailable</literal>, <literal>prohibit</literal>, <literal>throw</literal>.
|
||||
* The default is <literal>unicast</literal>.</para>
|
||||
* </listitem>
|
||||
* <listitem>
|
||||
* <para><literal>"window"</literal> - an unsigned 32 bit integer.</para>
|
||||
|
|
|
|||
|
|
@ -1042,7 +1042,8 @@ nm_setting_ip6_config_class_init(NMSettingIP6ConfigClass *klass)
|
|||
* </listitem>
|
||||
* <listitem>
|
||||
* <para><literal>"type"</literal> - one of <literal>unicast</literal>, <literal>local</literal>, <literal>blackhole</literal>,
|
||||
* <literal>unavailable</literal>, <literal>prohibit</literal>. The default is <literal>unicast</literal>.</para>
|
||||
* <literal>unavailable</literal>, <literal>prohibit</literal>, <literal>throw</literal>.
|
||||
* The default is <literal>unicast</literal>.</para>
|
||||
* </listitem>
|
||||
* <listitem>
|
||||
* <para><literal>"window"</literal> - an unsigned 32 bit integer.</para>
|
||||
|
|
|
|||
|
|
@ -3455,7 +3455,8 @@ _new_from_nl_route(struct nlmsghdr *nlh, gboolean id_only, ParseNlmsgIter *parse
|
|||
RTN_LOCAL,
|
||||
RTN_BLACKHOLE,
|
||||
RTN_UNREACHABLE,
|
||||
RTN_PROHIBIT))
|
||||
RTN_PROHIBIT,
|
||||
RTN_THROW))
|
||||
return NULL;
|
||||
|
||||
if (nlmsg_parse_arr(nlh, sizeof(struct rtmsg), tb, policy) < 0)
|
||||
|
|
|
|||
|
|
@ -1411,7 +1411,11 @@ _nm_platform_link_get_inet6_addr_gen_mode(const NMPlatformLink *pllink)
|
|||
static inline gboolean
|
||||
nm_platform_route_type_is_nodev(guint8 type)
|
||||
{
|
||||
return NM_IN_SET(type, 6 /* RTN_BLACKHOLE */, 7 /* RTN_UNREACHABLE */, 8 /* RTN_PROHIBIT */);
|
||||
return NM_IN_SET(type,
|
||||
6 /* RTN_BLACKHOLE */,
|
||||
7 /* RTN_UNREACHABLE */,
|
||||
8 /* RTN_PROHIBIT */,
|
||||
9 /* RTN_THROW */);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue