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
This commit is contained in:
@@ -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
|
||||
|
@@ -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");
|
||||
|
Reference in New Issue
Block a user