summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2019-04-21 11:50:18 +0200
committerThomas Haller <thaller@redhat.com>2019-04-25 07:49:56 +0200
commit2800574221711c702d22fcfbba55230e82c96c34 (patch)
tree932075963d90ad5885da260c03e14913eb4554de
parent2aa81edeaf6a5cfb6925604de7a68315f5815962 (diff)
downloadNetworkManager-2800574221711c702d22fcfbba55230e82c96c34.tar.gz
shared: fix to/from string of vlanid and missed-max values for NMTeamLinkWatcher
The vlanid and missed-max values have non-zero default values. That is what nm_utils_team_link_watcher_from_string() honors. Note that nm_utils_team_link_watcher_to_string() must omit printing the value only if it's the default value too. Otherwise, these values are not preserved during a to string conversion and back. Maybe a better fix would be to always print the values, regardless of the default value. But arguably, that is quite ugly because in most cases we don't want to cluter the string output with values that are left at the default.
-rw-r--r--clients/common/tests/test-libnm-core-aux.c24
-rw-r--r--shared/nm-libnm-core-aux/nm-libnm-core-aux.c9
2 files changed, 19 insertions, 14 deletions
diff --git a/clients/common/tests/test-libnm-core-aux.c b/clients/common/tests/test-libnm-core-aux.c
index e773300bf9..e5679bc43c 100644
--- a/clients/common/tests/test-libnm-core-aux.c
+++ b/clients/common/tests/test-libnm-core-aux.c
@@ -148,7 +148,7 @@ test_team_link_watcher_tofro_string (void)
-1,
NM_TEAM_LINK_WATCHER_ARP_PING_FLAG_NONE);
- w = _team_link_watcher_from_string ("name=nsna_ping missed-max=3 target-host=xxx",
+ w = _team_link_watcher_from_string ("name=nsna_ping target-host=xxx",
"name=nsna_ping target-host=xxx",
"target-host=x1 target-host=xxx name=nsna_ping",
" missed-max=3 target-host=xxx name=nsna_ping ");
@@ -164,8 +164,8 @@ test_team_link_watcher_tofro_string (void)
-1,
NM_TEAM_LINK_WATCHER_ARP_PING_FLAG_NONE);
- w = _team_link_watcher_from_string ("name=arp_ping missed-max=3 target-host=xxx vlanid=-1 source-host=yzd",
- "source-host=yzd name=arp_ping target-host=xxx",
+ w = _team_link_watcher_from_string ("name=arp_ping target-host=xxx source-host=yzd",
+ "source-host=yzd name=arp_ping vlanid=-1 target-host=xxx",
"source-host=yz source-host=yzd target-host=x1 target-host=xxx name=arp_ping",
" source-host=yzd target-host=xxx name=arp_ping ");
_team_link_watcher_cmp (&w,
@@ -180,23 +180,23 @@ test_team_link_watcher_tofro_string (void)
-1,
NM_TEAM_LINK_WATCHER_ARP_PING_FLAG_NONE);
- w = _team_link_watcher_from_string ("name=arp_ping missed-max=1 target-host=xxx vlanid=-1 source-host=yzd");
+ w = _team_link_watcher_from_string ("name=arp_ping missed-max=0 target-host=xxx vlanid=0 source-host=yzd");
_team_link_watcher_cmp (&w,
"arp_ping",
-1,
-1,
0,
0,
- 1,
+ 0,
"xxx",
"yzd",
- -1,
+ 0,
NM_TEAM_LINK_WATCHER_ARP_PING_FLAG_NONE);
- w = _team_link_watcher_from_string ("name=arp_ping missed-max=3 target-host=xxx vlanid=-1 source-host=yzd validate-active=true",
+ w = _team_link_watcher_from_string ("name=arp_ping target-host=xxx source-host=yzd validate-active=true",
"source-host=yzd send-always=false name=arp_ping validate-active=true validate-inactive=false target-host=xxx",
"source-host=yz validate-active=true source-host=yzd target-host=x1 target-host=xxx name=arp_ping",
- " source-host=yzd target-host=xxx validate-active=true name=arp_ping ");
+ " source-host=yzd target-host=xxx vlanid=-1 validate-active=true name=arp_ping ");
_team_link_watcher_cmp (&w,
"arp_ping",
-1,
@@ -209,7 +209,7 @@ test_team_link_watcher_tofro_string (void)
-1,
NM_TEAM_LINK_WATCHER_ARP_PING_FLAG_VALIDATE_ACTIVE);
- w = _team_link_watcher_from_string ("name=arp_ping missed-max=3 target-host=xxx vlanid=-1 source-host=yzd validate-active=true validate-inactive=true send-always=true",
+ w = _team_link_watcher_from_string ("name=arp_ping target-host=xxx source-host=yzd validate-active=true validate-inactive=true send-always=true",
"source-host=yzd send-always=true name=arp_ping validate-active=true validate-inactive=true target-host=xxx",
"source-host=yz validate-active=true source-host=yzd target-host=x1 target-host=xxx name=arp_ping send-always=true validate-inactive=true",
" source-host=yzd target-host=xxx validate-inactive=true send-always=true validate-active=true name=arp_ping ");
@@ -227,17 +227,17 @@ test_team_link_watcher_tofro_string (void)
| NM_TEAM_LINK_WATCHER_ARP_PING_FLAG_VALIDATE_INACTIVE
| NM_TEAM_LINK_WATCHER_ARP_PING_FLAG_SEND_ALWAYS);
- w = _team_link_watcher_from_string ("name=arp_ping missed-max=1 target-host=xxx vlanid=1 source-host=yzd");
+ w = _team_link_watcher_from_string ("name=arp_ping missed-max=0 target-host=xxx vlanid=0 source-host=yzd");
_team_link_watcher_cmp (&w,
"arp_ping",
-1,
-1,
0,
0,
- 1,
+ 0,
"xxx",
"yzd",
- 1,
+ 0,
NM_TEAM_LINK_WATCHER_ARP_PING_FLAG_NONE);
}
diff --git a/shared/nm-libnm-core-aux/nm-libnm-core-aux.c b/shared/nm-libnm-core-aux/nm-libnm-core-aux.c
index 8b443ec204..72f12ddccc 100644
--- a/shared/nm-libnm-core-aux/nm-libnm-core-aux.c
+++ b/shared/nm-libnm-core-aux/nm-libnm-core-aux.c
@@ -54,14 +54,19 @@ nm_utils_team_link_watcher_to_string (NMTeamLinkWatcher *watcher)
/* NM_TEAM_LINK_WATCHER_NSNA_PING and NM_TEAM_LINK_WATCHER_ARP_PING */
DUMP_WATCHER_INT (w_dump, watcher, "init-wait", init_wait);
DUMP_WATCHER_INT (w_dump, watcher, "interval", interval);
- DUMP_WATCHER_INT (w_dump, watcher, "missed-max", missed_max);
+
+ if (nm_team_link_watcher_get_missed_max (watcher) != 3)
+ g_string_append_printf (w_dump, " %s=%d", "missed-max", nm_team_link_watcher_get_missed_max (watcher));
+
g_string_append_printf (w_dump, " target-host=%s",
nm_team_link_watcher_get_target_host (watcher));
if (nm_streq (name, NM_TEAM_LINK_WATCHER_NSNA_PING))
return g_string_free (w_dump, FALSE);
- DUMP_WATCHER_INT (w_dump, watcher, "vlanid", vlanid);
+ if (nm_team_link_watcher_get_vlanid (watcher) != -1)
+ g_string_append_printf (w_dump, " %s=%d", "vlanid", nm_team_link_watcher_get_vlanid (watcher));
+
#undef DUMP_WATCHER_INT
g_string_append_printf (w_dump, " source-host=%s",
nm_team_link_watcher_get_source_host (watcher));