mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-05 13:28:02 +02:00
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.
This commit is contained in:
parent
2aa81edeaf
commit
2800574221
2 changed files with 19 additions and 14 deletions
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue