mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-25 13:00:16 +01:00
libnm,core: add support for {rto_min,quickack,advmss} route attributes
This commit is contained in:
parent
2cc02a3a1b
commit
90e7afc2cd
11 changed files with 93 additions and 3 deletions
|
|
@ -1388,16 +1388,20 @@ nm_utils_ip_route_attribute_to_platform(int addr_family,
|
|||
|
||||
r->r_rtm_flags = ((onlink) ? (unsigned) RTNH_F_ONLINK : 0u);
|
||||
|
||||
GET_ATTR(NM_IP_ROUTE_ATTRIBUTE_ADVMSS, r->mss, UINT32, uint32, 0);
|
||||
GET_ATTR(NM_IP_ROUTE_ATTRIBUTE_WINDOW, r->window, UINT32, uint32, 0);
|
||||
GET_ATTR(NM_IP_ROUTE_ATTRIBUTE_CWND, r->cwnd, UINT32, uint32, 0);
|
||||
GET_ATTR(NM_IP_ROUTE_ATTRIBUTE_INITCWND, r->initcwnd, UINT32, uint32, 0);
|
||||
GET_ATTR(NM_IP_ROUTE_ATTRIBUTE_INITRWND, r->initrwnd, UINT32, uint32, 0);
|
||||
GET_ATTR(NM_IP_ROUTE_ATTRIBUTE_MTU, r->mtu, UINT32, uint32, 0);
|
||||
GET_ATTR(NM_IP_ROUTE_ATTRIBUTE_RTO_MIN, r->rto_min, UINT32, uint32, 0);
|
||||
GET_ATTR(NM_IP_ROUTE_ATTRIBUTE_QUICKACK, r->quickack, BOOLEAN, boolean, FALSE);
|
||||
GET_ATTR(NM_IP_ROUTE_ATTRIBUTE_LOCK_WINDOW, r->lock_window, BOOLEAN, boolean, FALSE);
|
||||
GET_ATTR(NM_IP_ROUTE_ATTRIBUTE_LOCK_CWND, r->lock_cwnd, BOOLEAN, boolean, FALSE);
|
||||
GET_ATTR(NM_IP_ROUTE_ATTRIBUTE_LOCK_INITCWND, r->lock_initcwnd, BOOLEAN, boolean, FALSE);
|
||||
GET_ATTR(NM_IP_ROUTE_ATTRIBUTE_LOCK_INITRWND, r->lock_initrwnd, BOOLEAN, boolean, FALSE);
|
||||
GET_ATTR(NM_IP_ROUTE_ATTRIBUTE_LOCK_MTU, r->lock_mtu, BOOLEAN, boolean, FALSE);
|
||||
GET_ATTR(NM_IP_ROUTE_ATTRIBUTE_LOCK_ADVMSS, r->lock_mss, BOOLEAN, boolean, FALSE);
|
||||
|
||||
if ((variant = nm_ip_route_get_attribute(s_route, NM_IP_ROUTE_ATTRIBUTE_SRC))
|
||||
&& g_variant_is_of_type(variant, G_VARIANT_TYPE_STRING)) {
|
||||
|
|
|
|||
|
|
@ -646,6 +646,9 @@ test_ip4_route_options(gconstpointer test_data)
|
|||
.initrwnd = 50,
|
||||
.mtu = 1350,
|
||||
.lock_cwnd = TRUE,
|
||||
.mss = 1300,
|
||||
.quickack = TRUE,
|
||||
.rto_min = 1000,
|
||||
});
|
||||
break;
|
||||
case 2:
|
||||
|
|
|
|||
|
|
@ -879,6 +879,9 @@ enum {
|
|||
PARSE_LINE_ATTR_ROUTE_INITCWND,
|
||||
PARSE_LINE_ATTR_ROUTE_INITRWND,
|
||||
PARSE_LINE_ATTR_ROUTE_MTU,
|
||||
PARSE_LINE_ATTR_ROUTE_ADVMSS,
|
||||
PARSE_LINE_ATTR_ROUTE_RTO_MIN,
|
||||
PARSE_LINE_ATTR_ROUTE_QUICKACK,
|
||||
|
||||
/* iproute2 arguments that only matter when parsing the file. */
|
||||
PARSE_LINE_ATTR_ROUTE_TO,
|
||||
|
|
@ -979,6 +982,11 @@ parse_route_line(const char *line,
|
|||
.key = NM_IP_ROUTE_ATTRIBUTE_CWND,
|
||||
.type = PARSE_LINE_TYPE_UINT32_WITH_LOCK,
|
||||
},
|
||||
[PARSE_LINE_ATTR_ROUTE_ADVMSS] =
|
||||
{
|
||||
.key = NM_IP_ROUTE_ATTRIBUTE_ADVMSS,
|
||||
.type = PARSE_LINE_TYPE_UINT32_WITH_LOCK,
|
||||
},
|
||||
[PARSE_LINE_ATTR_ROUTE_INITCWND] =
|
||||
{
|
||||
.key = NM_IP_ROUTE_ATTRIBUTE_INITCWND,
|
||||
|
|
@ -994,7 +1002,16 @@ parse_route_line(const char *line,
|
|||
.key = NM_IP_ROUTE_ATTRIBUTE_MTU,
|
||||
.type = PARSE_LINE_TYPE_UINT32_WITH_LOCK,
|
||||
},
|
||||
|
||||
[PARSE_LINE_ATTR_ROUTE_QUICKACK] =
|
||||
{
|
||||
.key = NM_IP_ROUTE_ATTRIBUTE_QUICKACK,
|
||||
.type = PARSE_LINE_TYPE_BOOL,
|
||||
},
|
||||
[PARSE_LINE_ATTR_ROUTE_RTO_MIN] =
|
||||
{
|
||||
.key = NM_IP_ROUTE_ATTRIBUTE_RTO_MIN,
|
||||
.type = PARSE_LINE_TYPE_UINT32,
|
||||
},
|
||||
[PARSE_LINE_ATTR_ROUTE_TO] =
|
||||
{
|
||||
.key = "to",
|
||||
|
|
|
|||
|
|
@ -2321,6 +2321,7 @@ get_route_attributes_string(NMIPRoute *route, int family)
|
|||
continue;
|
||||
|
||||
if (NM_IN_STRSET(names[i],
|
||||
NM_IP_ROUTE_ATTRIBUTE_ADVMSS,
|
||||
NM_IP_ROUTE_ATTRIBUTE_WINDOW,
|
||||
NM_IP_ROUTE_ATTRIBUTE_CWND,
|
||||
NM_IP_ROUTE_ATTRIBUTE_INITCWND,
|
||||
|
|
@ -2350,8 +2351,12 @@ get_route_attributes_string(NMIPRoute *route, int family)
|
|||
g_string_append_printf(str, "%s %u", names[i], (unsigned) g_variant_get_byte(attr));
|
||||
} else if (nm_streq(names[i], NM_IP_ROUTE_ATTRIBUTE_TOS)) {
|
||||
g_string_append_printf(str, "%s 0x%02x", names[i], (unsigned) g_variant_get_byte(attr));
|
||||
} else if (nm_streq(names[i], NM_IP_ROUTE_ATTRIBUTE_TABLE)) {
|
||||
} else if (NM_IN_STRSET(names[i],
|
||||
NM_IP_ROUTE_ATTRIBUTE_TABLE,
|
||||
NM_IP_ROUTE_ATTRIBUTE_RTO_MIN)) {
|
||||
g_string_append_printf(str, "%s %u", names[i], (unsigned) g_variant_get_uint32(attr));
|
||||
} else if (nm_streq(names[i], NM_IP_ROUTE_ATTRIBUTE_QUICKACK)) {
|
||||
g_string_append_printf(str, "%s %u", names[i], (unsigned) g_variant_get_boolean(attr));
|
||||
} else if (nm_streq(names[i], NM_IP_ROUTE_ATTRIBUTE_ONLINK)) {
|
||||
if (g_variant_get_boolean(attr))
|
||||
g_string_append(str, "onlink");
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ ADDRESS1=44.55.66.77
|
|||
NETMASK1=255.255.255.255
|
||||
GATEWAY1=192.168.1.7
|
||||
METRIC1=3
|
||||
OPTIONS1="mtu lock 9000 cwnd 12 src 1.1.1.1 tos 0x28 window 30000 scope 10 initcwnd lock 13 initrwnd 14"
|
||||
OPTIONS1="mtu lock 9000 cwnd 12 src 1.1.1.1 tos 0x28 window 30000 scope 10 initcwnd lock 13 initrwnd 14 rto_min 300 advmss 1300 quickack 1"
|
||||
|
||||
ADDRESS2=44.55.66.78
|
||||
NETMASK2=255.255.255.255
|
||||
|
|
|
|||
|
|
@ -1352,6 +1352,7 @@ test_read_wired_static_routes(void)
|
|||
g_assert_cmpint(nm_ip_route_get_prefix(ip4_route), ==, 32);
|
||||
g_assert_cmpstr(nm_ip_route_get_next_hop(ip4_route), ==, "192.168.1.7");
|
||||
g_assert_cmpint(nm_ip_route_get_metric(ip4_route), ==, 3);
|
||||
nmtst_assert_route_attribute_uint32(ip4_route, NM_IP_ROUTE_ATTRIBUTE_ADVMSS, 1300);
|
||||
nmtst_assert_route_attribute_byte(ip4_route, NM_IP_ROUTE_ATTRIBUTE_TOS, 0x28);
|
||||
nmtst_assert_route_attribute_uint32(ip4_route, NM_IP_ROUTE_ATTRIBUTE_WINDOW, 30000);
|
||||
nmtst_assert_route_attribute_uint32(ip4_route, NM_IP_ROUTE_ATTRIBUTE_CWND, 12);
|
||||
|
|
@ -1360,6 +1361,8 @@ test_read_wired_static_routes(void)
|
|||
nmtst_assert_route_attribute_uint32(ip4_route, NM_IP_ROUTE_ATTRIBUTE_MTU, 9000);
|
||||
nmtst_assert_route_attribute_boolean(ip4_route, NM_IP_ROUTE_ATTRIBUTE_LOCK_MTU, TRUE);
|
||||
nmtst_assert_route_attribute_boolean(ip4_route, NM_IP_ROUTE_ATTRIBUTE_LOCK_INITCWND, TRUE);
|
||||
nmtst_assert_route_attribute_uint32(ip4_route, NM_IP_ROUTE_ATTRIBUTE_RTO_MIN, 300);
|
||||
nmtst_assert_route_attribute_boolean(ip4_route, NM_IP_ROUTE_ATTRIBUTE_QUICKACK, TRUE);
|
||||
nmtst_assert_route_attribute_string(ip4_route, NM_IP_ROUTE_ATTRIBUTE_SRC, "1.1.1.1");
|
||||
nmtst_assert_route_attribute_byte(ip4_route, NM_IP_ROUTE_ATTRIBUTE_SCOPE, 10);
|
||||
|
||||
|
|
|
|||
|
|
@ -1197,6 +1197,10 @@ nm_ip_route_set_attribute(NMIPRoute *route, const char *name, GVariant *value)
|
|||
}
|
||||
|
||||
static const NMVariantAttributeSpec *const ip_route_attribute_spec[] = {
|
||||
NM_VARIANT_ATTRIBUTE_SPEC_DEFINE(NM_IP_ROUTE_ATTRIBUTE_ADVMSS,
|
||||
G_VARIANT_TYPE_UINT32,
|
||||
.v4 = TRUE,
|
||||
.v6 = TRUE, ),
|
||||
NM_VARIANT_ATTRIBUTE_SPEC_DEFINE(NM_IP_ROUTE_ATTRIBUTE_CWND,
|
||||
G_VARIANT_TYPE_UINT32,
|
||||
.v4 = TRUE,
|
||||
|
|
@ -1213,6 +1217,10 @@ static const NMVariantAttributeSpec *const ip_route_attribute_spec[] = {
|
|||
G_VARIANT_TYPE_UINT32,
|
||||
.v4 = TRUE,
|
||||
.v6 = TRUE, ),
|
||||
NM_VARIANT_ATTRIBUTE_SPEC_DEFINE(NM_IP_ROUTE_ATTRIBUTE_LOCK_ADVMSS,
|
||||
G_VARIANT_TYPE_BOOLEAN,
|
||||
.v4 = TRUE,
|
||||
.v6 = TRUE, ),
|
||||
NM_VARIANT_ATTRIBUTE_SPEC_DEFINE(NM_IP_ROUTE_ATTRIBUTE_LOCK_CWND,
|
||||
G_VARIANT_TYPE_BOOLEAN,
|
||||
.v4 = TRUE,
|
||||
|
|
@ -1241,6 +1249,14 @@ static const NMVariantAttributeSpec *const ip_route_attribute_spec[] = {
|
|||
G_VARIANT_TYPE_BOOLEAN,
|
||||
.v4 = TRUE,
|
||||
.v6 = TRUE, ),
|
||||
NM_VARIANT_ATTRIBUTE_SPEC_DEFINE(NM_IP_ROUTE_ATTRIBUTE_QUICKACK,
|
||||
G_VARIANT_TYPE_BOOLEAN,
|
||||
.v4 = TRUE,
|
||||
.v6 = TRUE, ),
|
||||
NM_VARIANT_ATTRIBUTE_SPEC_DEFINE(NM_IP_ROUTE_ATTRIBUTE_RTO_MIN,
|
||||
G_VARIANT_TYPE_UINT32,
|
||||
.v4 = TRUE,
|
||||
.v6 = TRUE, ),
|
||||
NM_VARIANT_ATTRIBUTE_SPEC_DEFINE(NM_IP_ROUTE_ATTRIBUTE_SCOPE,
|
||||
G_VARIANT_TYPE_BYTE,
|
||||
.v4 = TRUE,
|
||||
|
|
|
|||
|
|
@ -1057,6 +1057,9 @@ nm_setting_ip4_config_class_init(NMSettingIP4ConfigClass *klass)
|
|||
* Various attributes are supported:
|
||||
* <itemizedlist>
|
||||
* <listitem>
|
||||
* <para><literal>"advmss"</literal> - an unsigned 32 bit integer.</para>
|
||||
* </listitem>
|
||||
* <listitem>
|
||||
* <para><literal>"cwnd"</literal> - an unsigned 32 bit integer.</para>
|
||||
* </listitem>
|
||||
* <listitem>
|
||||
|
|
@ -1066,6 +1069,9 @@ nm_setting_ip4_config_class_init(NMSettingIP4ConfigClass *klass)
|
|||
* <para><literal>"initrwnd"</literal> - an unsigned 32 bit integer.</para>
|
||||
* </listitem>
|
||||
* <listitem>
|
||||
* <para><literal>"lock-advmss"</literal> - a boolean value.</para>
|
||||
* </listitem>
|
||||
* <listitem>
|
||||
* <para><literal>"lock-cwnd"</literal> - a boolean value.</para>
|
||||
* </listitem>
|
||||
* <listitem>
|
||||
|
|
@ -1087,6 +1093,13 @@ nm_setting_ip4_config_class_init(NMSettingIP4ConfigClass *klass)
|
|||
* <para><literal>"onlink"</literal> - a boolean value.</para>
|
||||
* </listitem>
|
||||
* <listitem>
|
||||
* <para><literal>"quickack"</literal> - a boolean value.</para>
|
||||
* </listitem>
|
||||
* <listitem>
|
||||
* <para><literal>"rto_min"</literal> - an unsigned 32 bit integer.
|
||||
* The value is in milliseconds.</para>
|
||||
* </listitem>
|
||||
* <listitem>
|
||||
* <para><literal>"scope"</literal> - an unsigned 8 bit integer. IPv4 only.</para>
|
||||
* </listitem>
|
||||
* <listitem>
|
||||
|
|
|
|||
|
|
@ -1043,6 +1043,9 @@ nm_setting_ip6_config_class_init(NMSettingIP6ConfigClass *klass)
|
|||
* Various attributes are supported:
|
||||
* <itemizedlist>
|
||||
* <listitem>
|
||||
* <para><literal>"advmss"</literal> - an unsigned 32 bit integer.</para>
|
||||
* </listitem>
|
||||
* <listitem>
|
||||
* <para><literal>"cwnd"</literal> - an unsigned 32 bit integer.</para>
|
||||
* </listitem>
|
||||
* <listitem>
|
||||
|
|
@ -1055,6 +1058,9 @@ nm_setting_ip6_config_class_init(NMSettingIP6ConfigClass *klass)
|
|||
* <para><literal>"initrwnd"</literal> - an unsigned 32 bit integer.</para>
|
||||
* </listitem>
|
||||
* <listitem>
|
||||
* <para><literal>"lock-advmss"</literal> - a boolean value.</para>
|
||||
* </listitem>
|
||||
* <listitem>
|
||||
* <para><literal>"lock-cwnd"</literal> - a boolean value.</para>
|
||||
* </listitem>
|
||||
* <listitem>
|
||||
|
|
@ -1076,6 +1082,13 @@ nm_setting_ip6_config_class_init(NMSettingIP6ConfigClass *klass)
|
|||
* <para><literal>"onlink"</literal> - a boolean value.</para>
|
||||
* </listitem>
|
||||
* <listitem>
|
||||
* <para><literal>"quickack"</literal> - a boolean value.</para>
|
||||
* </listitem>
|
||||
* <listitem>
|
||||
* <para><literal>"rto_min"</literal> - an unsigned 32 bit integer.
|
||||
* The value is in milliseconds.</para>
|
||||
* </listitem>
|
||||
* <listitem>
|
||||
* <para><literal>"src"</literal> - an IPv6 address.</para>
|
||||
* </listitem>
|
||||
* <listitem>
|
||||
|
|
|
|||
|
|
@ -2381,12 +2381,18 @@ test_setting_ip_route_attributes(void)
|
|||
TEST_ATTR("tos", byte, 127, AF_INET, TRUE, TRUE);
|
||||
TEST_ATTR("tos", string, "0x28", AF_INET, FALSE, TRUE);
|
||||
|
||||
TEST_ATTR("advmss", uint32, 1400, AF_INET, TRUE, TRUE);
|
||||
TEST_ATTR("advmss", string, "1400", AF_INET, FALSE, TRUE);
|
||||
|
||||
TEST_ATTR("cwnd", uint32, 10, AF_INET, TRUE, TRUE);
|
||||
TEST_ATTR("cwnd", string, "11", AF_INET, FALSE, TRUE);
|
||||
|
||||
TEST_ATTR("lock-mtu", boolean, TRUE, AF_INET, TRUE, TRUE);
|
||||
TEST_ATTR("lock-mtu", uint32, 1, AF_INET, FALSE, TRUE);
|
||||
|
||||
TEST_ATTR("lock-advmss", boolean, TRUE, AF_INET, TRUE, TRUE);
|
||||
TEST_ATTR("lock-advmss", boolean, TRUE, AF_INET6, TRUE, TRUE);
|
||||
|
||||
TEST_ATTR("from", string, "fd01::1", AF_INET6, TRUE, TRUE);
|
||||
TEST_ATTR("from", string, "fd01::1/64", AF_INET6, TRUE, TRUE);
|
||||
TEST_ATTR("from", string, "fd01::1/128", AF_INET6, TRUE, TRUE);
|
||||
|
|
@ -2396,6 +2402,12 @@ test_setting_ip_route_attributes(void)
|
|||
TEST_ATTR("from", string, "1.2.3.4", AF_INET, FALSE, TRUE);
|
||||
TEST_ATTR("from", string, "1.2.3.4", AF_INET6, FALSE, TRUE);
|
||||
|
||||
TEST_ATTR("quickack", boolean, TRUE, AF_INET, TRUE, TRUE);
|
||||
TEST_ATTR("quickack", boolean, TRUE, AF_INET6, TRUE, TRUE);
|
||||
|
||||
TEST_ATTR("rto_min", uint32, 1000, AF_INET, TRUE, TRUE);
|
||||
TEST_ATTR("rto_min", uint32, 1000, AF_INET6, TRUE, TRUE);
|
||||
|
||||
TEST_ATTR("src", string, "1.2.3.4", AF_INET, TRUE, TRUE);
|
||||
TEST_ATTR("src", string, "1.2.3.4", AF_INET6, FALSE, TRUE);
|
||||
TEST_ATTR("src", string, "1.2.3.0/24", AF_INET, FALSE, TRUE);
|
||||
|
|
|
|||
|
|
@ -123,10 +123,12 @@ gboolean nm_ip_route_attribute_validate(const char *name,
|
|||
gboolean *known,
|
||||
GError **error);
|
||||
|
||||
#define NM_IP_ROUTE_ATTRIBUTE_ADVMSS "advmss"
|
||||
#define NM_IP_ROUTE_ATTRIBUTE_CWND "cwnd"
|
||||
#define NM_IP_ROUTE_ATTRIBUTE_FROM "from"
|
||||
#define NM_IP_ROUTE_ATTRIBUTE_INITCWND "initcwnd"
|
||||
#define NM_IP_ROUTE_ATTRIBUTE_INITRWND "initrwnd"
|
||||
#define NM_IP_ROUTE_ATTRIBUTE_LOCK_ADVMSS "lock-advmss"
|
||||
#define NM_IP_ROUTE_ATTRIBUTE_LOCK_CWND "lock-cwnd"
|
||||
#define NM_IP_ROUTE_ATTRIBUTE_LOCK_INITCWND "lock-initcwnd"
|
||||
#define NM_IP_ROUTE_ATTRIBUTE_LOCK_INITRWND "lock-initrwnd"
|
||||
|
|
@ -134,6 +136,8 @@ gboolean nm_ip_route_attribute_validate(const char *name,
|
|||
#define NM_IP_ROUTE_ATTRIBUTE_LOCK_WINDOW "lock-window"
|
||||
#define NM_IP_ROUTE_ATTRIBUTE_MTU "mtu"
|
||||
#define NM_IP_ROUTE_ATTRIBUTE_ONLINK "onlink"
|
||||
#define NM_IP_ROUTE_ATTRIBUTE_QUICKACK "quickack"
|
||||
#define NM_IP_ROUTE_ATTRIBUTE_RTO_MIN "rto_min"
|
||||
#define NM_IP_ROUTE_ATTRIBUTE_SCOPE "scope"
|
||||
#define NM_IP_ROUTE_ATTRIBUTE_SRC "src"
|
||||
#define NM_IP_ROUTE_ATTRIBUTE_TABLE "table"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue