summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2019-08-03 09:04:33 +0200
committerThomas Haller <thaller@redhat.com>2019-08-03 09:47:51 +0200
commit827a3c14322ee5ade6d469f12f23f03ae7acdf7c (patch)
tree41db4ec1923ce30b814884918830084fca2339e4
parent377a775a2ab449555bf3d4e0f29ea90879ee0f1e (diff)
downloadNetworkManager-th/policy-route-to-string-not-attribute.tar.gz
libnm: when stringifying policy routing rule place "not" specifier after "priority"th/policy-route-to-string-not-attribute
Otherwise, it just looks odd: "not priority 31265 from 0.0.0.0/0 fwmark 0xcb87 table 52103" better would be "priority 31265 not from 0.0.0.0/0 fwmark 0xcb87 table 52103" The "not" specifier should come after the priority. It makes more sense to read it that way. As far as parsing the string is concerned, the order does not matter. So this change in behavior is no problem.
-rw-r--r--libnm-core/nm-setting-ip-config.c9
-rw-r--r--libnm-core/tests/test-setting.c4
2 files changed, 8 insertions, 5 deletions
diff --git a/libnm-core/nm-setting-ip-config.c b/libnm-core/nm-setting-ip-config.c
index 458d93b30d..56b16d414a 100644
--- a/libnm-core/nm-setting-ip-config.c
+++ b/libnm-core/nm-setting-ip-config.c
@@ -3110,7 +3110,8 @@ nm_ip_routing_rule_from_string (const char *str,
goto next_words_consumed;
}
if (NM_IN_STRSET (word0, "not")) {
- /* we accept multiple "not" specifiers. */
+ /* we accept multiple "not" specifiers. "not not" still means
+ * not. */
val_invert = TRUE;
goto next_words_consumed;
}
@@ -3460,15 +3461,15 @@ nm_ip_routing_rule_to_string (const NMIPRoutingRule *self,
str = g_string_sized_new (30);
- if (self->invert)
- g_string_append (str, "not");
-
if (self->priority_has) {
g_string_append_printf (nm_gstring_add_space_delimiter (str),
"priority %u",
(guint) self->priority);
}
+ if (self->invert)
+ g_string_append (nm_gstring_add_space_delimiter (str), "not");
+
_rr_string_append_inet_addr (str,
TRUE,
( !self->to_has
diff --git a/libnm-core/tests/test-setting.c b/libnm-core/tests/test-setting.c
index aa9de5a03d..3438aea99d 100644
--- a/libnm-core/tests/test-setting.c
+++ b/libnm-core/tests/test-setting.c
@@ -3168,7 +3168,9 @@ test_routing_rule (gconstpointer test_data)
_rr_from_str ("priority 5 from :: iif a\\\\303b table 25");
_rr_from_str ("priority 5 to 0.0.0.0 sport 10 table 6",
"priority 5 to 0.0.0.0 sport 10-10 table 6");
- _rr_from_str ("not priority 5 to 0.0.0.0 dport 10-133 table 6",
+ _rr_from_str ("priority 5 not to 0.0.0.0 dport 10-133 table 6",
+ "not priority 5 to 0.0.0.0 dport 10-133 table 6",
+ "not priority 5 not to 0.0.0.0 dport 10-133 table 6",
"priority 5 to 0.0.0.0 not dport 10-133 not table 6",
"priority 5 to 0.0.0.0 not dport 10-\\ 133 not table 6");
_rr_from_str ("priority 5 to 0.0.0.0 ipproto 10 sport 10 table 6");