diff options
author | Thomas Haller <thaller@redhat.com> | 2019-08-03 09:04:33 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2019-08-05 10:16:10 +0200 |
commit | 66088a09b27450599e9ffb0dbaae01e40ef616bf (patch) | |
tree | a84ea20af5ebee19f136f857d0841dd4f4c53d55 | |
parent | d4fabd728a898b2dfee1cac5592c082bee6b4e5a (diff) | |
download | NetworkManager-66088a09b27450599e9ffb0dbaae01e40ef616bf.tar.gz |
libnm: when stringifying policy routing rule place "not" specifier after "priority"
Otherwise, it just looks odd:
"not priority 31265 from 0.0.0.0/0 fwmark 0xcb87 table 52103"
Better is:
"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.
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/228
-rw-r--r-- | libnm-core/nm-setting-ip-config.c | 9 | ||||
-rw-r--r-- | libnm-core/tests/test-setting.c | 4 |
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"); |