l3cfg: add nm_l3cfg_remove_config_all_dirty() for removing dirty configs

The "only_dirty" parameter to a remove-all() function is odd.

For one, the function is called remove-all, but depending on a parameter
it does not remove all.

Also, setting remove-all(only_dirty=TRUE) means it will remove not
everything, so passing TRUE will remove only parts. That logic seems
confusing.

Avoid that, by removing the parameter from nm_l3cfg_remove_config_all()
and add nm_l3cfg_remove_config_all_dirty().
This commit is contained in:
Thomas Haller 2021-08-05 11:42:29 +02:00
parent a3b7030d74
commit 320a1b5a79
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728
3 changed files with 13 additions and 9 deletions

View file

@ -2885,9 +2885,15 @@ nm_l3cfg_remove_config(NML3Cfg *self, gconstpointer tag, const NML3ConfigData *i
}
gboolean
nm_l3cfg_remove_config_all(NML3Cfg *self, gconstpointer tag, gboolean only_dirty)
nm_l3cfg_remove_config_all(NML3Cfg *self, gconstpointer tag)
{
return _l3cfg_remove_config(self, tag, only_dirty, NULL);
return _l3cfg_remove_config(self, tag, FALSE, NULL);
}
gboolean
nm_l3cfg_remove_config_all_dirty(NML3Cfg *self, gconstpointer tag)
{
return _l3cfg_remove_config(self, tag, TRUE, NULL);
}
/*****************************************************************************/

View file

@ -295,7 +295,8 @@ gboolean nm_l3cfg_add_config(NML3Cfg * self,
gboolean nm_l3cfg_remove_config(NML3Cfg *self, gconstpointer tag, const NML3ConfigData *ifcfg);
gboolean nm_l3cfg_remove_config_all(NML3Cfg *self, gconstpointer tag, gboolean only_dirty);
gboolean nm_l3cfg_remove_config_all(NML3Cfg *self, gconstpointer tag);
gboolean nm_l3cfg_remove_config_all_dirty(NML3Cfg *self, gconstpointer tag);
/*****************************************************************************/

View file

@ -490,7 +490,7 @@ test_l3cfg(gconstpointer test_data)
if (nmtst_get_rand_one_case_in(3))
_test_fixture_1_teardown(&test_fixture);
nm_l3cfg_remove_config_all(l3cfg0, GINT_TO_POINTER('a'), FALSE);
nm_l3cfg_remove_config_all(l3cfg0, GINT_TO_POINTER('a'));
if (nmtst_get_rand_one_case_in(3))
_test_fixture_1_teardown(&test_fixture);
@ -615,8 +615,7 @@ _test_l3_ipv4ll_signal_notify(NML3Cfg * l3cfg,
_LOGT("remove address %s that previously passed ACD",
_nm_utils_inet4_ntop(tdata->addr_commit_addr, sbuf_addr));
if (!nm_l3cfg_remove_config_all(nm_l3_ipv4ll_get_l3cfg(tdata->l3ipv4ll),
TEST_L3_IPV4LL_TAG(tdata, 1),
FALSE))
TEST_L3_IPV4LL_TAG(tdata, 1)))
g_assert_not_reached();
nm_l3cfg_commit_on_idle_schedule(nm_l3_ipv4ll_get_l3cfg(tdata->l3ipv4ll));
nm_l3cfg_commit_type_unregister(nm_l3_ipv4ll_get_l3cfg(tdata->l3ipv4ll),
@ -766,9 +765,7 @@ test_l3_ipv4ll(gconstpointer test_data)
_LOGT("poll 1 end");
if (tdata->addr_commit || nmtst_get_rand_bool()) {
nm_l3cfg_remove_config_all(nm_l3_ipv4ll_get_l3cfg(l3ipv4ll),
TEST_L3_IPV4LL_TAG(tdata, 1),
FALSE);
nm_l3cfg_remove_config_all(nm_l3_ipv4ll_get_l3cfg(l3ipv4ll), TEST_L3_IPV4LL_TAG(tdata, 1));
}
nmtstp_acd_defender_destroy(g_steal_pointer(&acd_defender_1));