diff options
author | Beniamino Galvani <bgalvani@redhat.com> | 2017-10-09 20:55:38 +0200 |
---|---|---|
committer | Beniamino Galvani <bgalvani@redhat.com> | 2017-10-19 14:31:07 +0200 |
commit | 0a7b08968d313a7dcd55ba8b50365fe20c301aff (patch) | |
tree | ba28ba92bc3e4099b4682da080e9c5af7f0f58be | |
parent | 5c2c7d37c3bf8d789349eb5504da764091865413 (diff) | |
download | NetworkManager-0a7b08968d313a7dcd55ba8b50365fe20c301aff.tar.gz |
libnm-core: normalize "tx_hash" when comparing team config
teamd adds the "tx_hash" property for "lacp" and "loadbalance" runners
when not present. Do the same so that our original configuration
matches with the one reported by teamd.
https://bugzilla.redhat.com/show_bug.cgi?id=1497333
-rw-r--r-- | libnm-core/nm-utils.c | 11 | ||||
-rw-r--r-- | libnm-core/tests/test-general.c | 16 |
2 files changed, 27 insertions, 0 deletions
diff --git a/libnm-core/nm-utils.c b/libnm-core/nm-utils.c index b3c3fc5d68..7e96184340 100644 --- a/libnm-core/nm-utils.c +++ b/libnm-core/nm-utils.c @@ -4355,6 +4355,7 @@ _nm_utils_team_config_equal (const char *conf1, gboolean port_config) { json_t *json1 = NULL, *json2 = NULL, *json; + json_t *array, *name; gs_free char *dump1 = NULL, *dump2 = NULL; json_t *value, *property; json_error_t jerror; @@ -4394,6 +4395,16 @@ _nm_utils_team_config_equal (const char *conf1, property = json_object (); json_object_set_new (property, "name", json_string ("roundrobin")); json_object_set_new (json, "runner", property); + } else if ( (name = json_object_get (property, "name")) + && NM_IN_STRSET (json_string_value (name), "lacp", "loadbalance")) { + /* Add default tx_hash when missing */ + if (!json_object_get (property, "tx_hash")) { + array = json_array (); + json_array_append_new (array, json_string ("eth")); + json_array_append_new (array, json_string ("ipv4")); + json_array_append_new (array, json_string ("ipv6")); + json_object_set_new (property, "tx_hash", array); + } } } } diff --git a/libnm-core/tests/test-general.c b/libnm-core/tests/test-general.c index 8c4d120d11..5f4540c57a 100644 --- a/libnm-core/tests/test-general.c +++ b/libnm-core/tests/test-general.c @@ -5562,10 +5562,26 @@ test_nm_utils_team_config_equal (void) "{ \"runner\" : { \"name\" : \"random\"} }", FALSE, TRUE); + _team_config_equal_check ("{ \"runner\" : { \"name\" : \"loadbalance\"} }", + "{ \"runner\" : { \"name\" : \"loadbalance\"} }", + FALSE, + TRUE); _team_config_equal_check ("{ \"runner\" : { \"name\" : \"random\"}, \"ports\" : { \"eth0\" : {} } }", "{ \"runner\" : { \"name\" : \"random\"}, \"ports\" : { \"eth1\" : {} } }", FALSE, TRUE); + _team_config_equal_check ("{ \"runner\" : { \"name\" : \"lacp\"} }", + "{ \"runner\" : { \"name\" : \"lacp\", \"tx_hash\" : [ \"eth\", \"ipv4\", \"ipv6\" ] } }", + FALSE, + TRUE); + _team_config_equal_check ("{ \"runner\" : { \"name\" : \"roundrobin\"} }", + "{ \"runner\" : { \"name\" : \"roundrobin\", \"tx_hash\" : [ \"eth\", \"ipv4\", \"ipv6\" ] } }", + FALSE, + FALSE); + _team_config_equal_check ("{ \"runner\" : { \"name\" : \"lacp\"} }", + "{ \"runner\" : { \"name\" : \"lacp\", \"tx_hash\" : [ \"eth\" ] } }", + FALSE, + FALSE); /* team port config */ _team_config_equal_check ("{ }", |