mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-27 07:00:09 +01:00
l3cfg: fix nm_l3cfg_commit_type_register() to set commit_type and add debug logging
Co-authored-by: Thomas Haller <thaller@redhat.com>
This commit is contained in:
parent
f3def63fed
commit
8a06d66d0e
5 changed files with 37 additions and 14 deletions
|
|
@ -601,7 +601,8 @@ _l3cd_config_add(NML3IPv4LL *self)
|
|||
|
||||
self->l3cfg_commit_handle = nm_l3cfg_commit_type_register(self->l3cfg,
|
||||
NM_L3_CFG_COMMIT_TYPE_ASSUME,
|
||||
self->l3cfg_commit_handle);
|
||||
self->l3cfg_commit_handle,
|
||||
"ipv4ll");
|
||||
nm_l3cfg_commit_on_idle_schedule(self->l3cfg, NM_L3_CFG_COMMIT_TYPE_AUTO);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -430,7 +430,8 @@ _lladdr_handle_changed(NML3IPv6LL *self)
|
|||
self->l3cfg_commit_handle = nm_l3cfg_commit_type_register(self->l3cfg,
|
||||
l3cd ? NM_L3_CFG_COMMIT_TYPE_ASSUME
|
||||
: NM_L3_CFG_COMMIT_TYPE_NONE,
|
||||
self->l3cfg_commit_handle);
|
||||
self->l3cfg_commit_handle,
|
||||
"ipv6ll");
|
||||
|
||||
if (changed)
|
||||
nm_l3cfg_commit_on_idle_schedule(self->l3cfg, NM_L3_CFG_COMMIT_TYPE_AUTO);
|
||||
|
|
|
|||
|
|
@ -3811,6 +3811,7 @@ nm_l3cfg_commit_type_get(NML3Cfg *self)
|
|||
* @commit_type: the commit type to register
|
||||
* @existing_handle: instead of being a new registration, update an existing handle.
|
||||
* This may be %NULL, which is like having no previous registration.
|
||||
* @source: the source of the commit type, for logging.
|
||||
*
|
||||
* NML3Cfg needs to know whether it is in charge of an interface (and how "much").
|
||||
* By default, it is not in charge, but various users can register themself with
|
||||
|
|
@ -3823,11 +3824,14 @@ nm_l3cfg_commit_type_get(NML3Cfg *self)
|
|||
NML3CfgCommitTypeHandle *
|
||||
nm_l3cfg_commit_type_register(NML3Cfg * self,
|
||||
NML3CfgCommitType commit_type,
|
||||
NML3CfgCommitTypeHandle *existing_handle)
|
||||
NML3CfgCommitTypeHandle *existing_handle,
|
||||
const char * source)
|
||||
{
|
||||
NML3CfgCommitTypeHandle *handle;
|
||||
NML3CfgCommitTypeHandle *h;
|
||||
gboolean linked;
|
||||
NML3CfgCommitTypeHandle *ret = NULL;
|
||||
char buf[64];
|
||||
|
||||
nm_assert(NM_IS_L3CFG(self));
|
||||
nm_assert(NM_IN_SET(commit_type,
|
||||
|
|
@ -3841,21 +3845,24 @@ nm_l3cfg_commit_type_register(NML3Cfg * self,
|
|||
if (existing_handle) {
|
||||
if (commit_type == NM_L3_CFG_COMMIT_TYPE_NONE) {
|
||||
nm_l3cfg_commit_type_unregister(self, existing_handle);
|
||||
return NULL;
|
||||
goto out;
|
||||
}
|
||||
if (existing_handle->commit_type == commit_type) {
|
||||
ret = existing_handle;
|
||||
goto out;
|
||||
}
|
||||
if (existing_handle->commit_type == commit_type)
|
||||
return existing_handle;
|
||||
c_list_unlink_stale(&existing_handle->commit_type_lst);
|
||||
handle = existing_handle;
|
||||
} else {
|
||||
if (commit_type == NM_L3_CFG_COMMIT_TYPE_NONE)
|
||||
return NULL;
|
||||
handle = g_slice_new(NML3CfgCommitTypeHandle);
|
||||
handle->commit_type = commit_type;
|
||||
goto out;
|
||||
handle = g_slice_new(NML3CfgCommitTypeHandle);
|
||||
if (c_list_is_empty(&self->priv.p->commit_type_lst_head))
|
||||
g_object_ref(self);
|
||||
}
|
||||
|
||||
handle->commit_type = commit_type;
|
||||
|
||||
linked = FALSE;
|
||||
c_list_for_each_entry (h, &self->priv.p->commit_type_lst_head, commit_type_lst) {
|
||||
if (handle->commit_type >= h->commit_type) {
|
||||
|
|
@ -3867,7 +3874,15 @@ nm_l3cfg_commit_type_register(NML3Cfg * self,
|
|||
if (!linked)
|
||||
c_list_link_tail(&self->priv.p->commit_type_lst_head, &handle->commit_type_lst);
|
||||
|
||||
return handle;
|
||||
ret = handle;
|
||||
out:
|
||||
_LOGT("commit type register (type \"%s\", source \"%s\", existing " NM_HASH_OBFUSCATE_PTR_FMT
|
||||
") -> " NM_HASH_OBFUSCATE_PTR_FMT "",
|
||||
_l3_cfg_commit_type_to_string(commit_type, buf, sizeof(buf)),
|
||||
source,
|
||||
NM_HASH_OBFUSCATE_PTR(existing_handle),
|
||||
NM_HASH_OBFUSCATE_PTR(ret));
|
||||
return ret;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -3880,6 +3895,8 @@ nm_l3cfg_commit_type_unregister(NML3Cfg *self, NML3CfgCommitTypeHandle *handle)
|
|||
|
||||
nm_assert(c_list_contains(&self->priv.p->commit_type_lst_head, &handle->commit_type_lst));
|
||||
|
||||
_LOGT("commit type unregister " NM_HASH_OBFUSCATE_PTR_FMT "", NM_HASH_OBFUSCATE_PTR(handle));
|
||||
|
||||
c_list_unlink_stale(&handle->commit_type_lst);
|
||||
if (c_list_is_empty(&self->priv.p->commit_type_lst_head))
|
||||
g_object_unref(self);
|
||||
|
|
|
|||
|
|
@ -384,7 +384,8 @@ typedef struct _NML3CfgCommitTypeHandle NML3CfgCommitTypeHandle;
|
|||
|
||||
NML3CfgCommitTypeHandle *nm_l3cfg_commit_type_register(NML3Cfg * self,
|
||||
NML3CfgCommitType commit_type,
|
||||
NML3CfgCommitTypeHandle *existing_handle);
|
||||
NML3CfgCommitTypeHandle *existing_handle,
|
||||
const char * source);
|
||||
|
||||
void nm_l3cfg_commit_type_unregister(NML3Cfg *self, NML3CfgCommitTypeHandle *handle);
|
||||
|
||||
|
|
|
|||
|
|
@ -371,7 +371,8 @@ test_l3cfg(gconstpointer test_data)
|
|||
|
||||
g_signal_connect(l3cfg0, NM_L3CFG_SIGNAL_NOTIFY, G_CALLBACK(_test_l3cfg_signal_notify), tdata);
|
||||
|
||||
commit_type_1 = nm_l3cfg_commit_type_register(l3cfg0, NM_L3_CFG_COMMIT_TYPE_UPDATE, NULL);
|
||||
commit_type_1 =
|
||||
nm_l3cfg_commit_type_register(l3cfg0, NM_L3_CFG_COMMIT_TYPE_UPDATE, NULL, "test1");
|
||||
|
||||
if (!nmtst_get_rand_one_case_in(4)) {
|
||||
commit_type_2 =
|
||||
|
|
@ -379,7 +380,8 @@ test_l3cfg(gconstpointer test_data)
|
|||
nmtst_rand_select(NM_L3_CFG_COMMIT_TYPE_NONE,
|
||||
NM_L3_CFG_COMMIT_TYPE_ASSUME,
|
||||
NM_L3_CFG_COMMIT_TYPE_UPDATE),
|
||||
NULL);
|
||||
NULL,
|
||||
"test2");
|
||||
} else
|
||||
commit_type_2 = NULL;
|
||||
|
||||
|
|
@ -612,7 +614,8 @@ _test_l3_ipv4ll_signal_notify(NML3Cfg * l3cfg,
|
|||
tdata->l3cfg_commit_type_1 =
|
||||
nm_l3cfg_commit_type_register(nm_l3_ipv4ll_get_l3cfg(tdata->l3ipv4ll),
|
||||
NM_L3_CFG_COMMIT_TYPE_UPDATE,
|
||||
tdata->l3cfg_commit_type_1);
|
||||
tdata->l3cfg_commit_type_1,
|
||||
"test");
|
||||
}
|
||||
} else if (nm_l3_ipv4ll_get_state(tdata->l3ipv4ll) != NM_L3_IPV4LL_STATE_DEFENDING
|
||||
&& tdata->ready_seen > 0) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue