mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-04-22 10:30:43 +02:00
l3cfg: various fixes and improvments (e.g. add pre-commit hook)
- add "pre-commit" signal. - fix assertion in nm_l3_config_data_get_ip6_privacy(). - set IPv6 privacy in _init_from_connection_ip() from profile. - fix leaking "os_zombie_lst" in _obj_state_data_free(). - remove wrong assertion about VRF. - fix _routes_temporary_not_available_update() to honor only the requested object type. Otherwise, we always prune unrelated objects too.
This commit is contained in:
parent
8b575f7553
commit
07d570766f
4 changed files with 41 additions and 14 deletions
|
|
@ -1792,7 +1792,7 @@ nm_l3_config_data_set_ip6_mtu(NML3ConfigData *self, guint32 ip6_mtu)
|
|||
NMSettingIP6ConfigPrivacy
|
||||
nm_l3_config_data_get_ip6_privacy(const NML3ConfigData *self)
|
||||
{
|
||||
nm_assert(_NM_IS_L3_CONFIG_DATA(self, FALSE));
|
||||
nm_assert(_NM_IS_L3_CONFIG_DATA(self, TRUE));
|
||||
|
||||
return self->ip6_privacy;
|
||||
}
|
||||
|
|
@ -2642,6 +2642,12 @@ _init_from_connection_ip(NML3ConfigData *self, int addr_family, NMConnection *co
|
|||
nm_l3_config_data_set_dns_priority(self,
|
||||
addr_family,
|
||||
nm_setting_ip_config_get_dns_priority(s_ip));
|
||||
|
||||
if (!IS_IPv4) {
|
||||
nm_l3_config_data_set_ip6_privacy(
|
||||
self,
|
||||
nm_setting_ip6_config_get_ip6_privacy(NM_SETTING_IP6_CONFIG(s_ip)));
|
||||
}
|
||||
}
|
||||
|
||||
NML3ConfigData *
|
||||
|
|
|
|||
|
|
@ -345,6 +345,7 @@ static NM_UTILS_ENUM2STR_DEFINE(
|
|||
NM_UTILS_ENUM2STR(NM_L3_CONFIG_NOTIFY_TYPE_L3CD_CHANGED, "l3cd-changed"),
|
||||
NM_UTILS_ENUM2STR(NM_L3_CONFIG_NOTIFY_TYPE_PLATFORM_CHANGE, "platform-change"),
|
||||
NM_UTILS_ENUM2STR(NM_L3_CONFIG_NOTIFY_TYPE_PLATFORM_CHANGE_ON_IDLE, "platform-change-on-idle"),
|
||||
NM_UTILS_ENUM2STR(NM_L3_CONFIG_NOTIFY_TYPE_PRE_COMMIT, "pre-commit"),
|
||||
NM_UTILS_ENUM2STR(NM_L3_CONFIG_NOTIFY_TYPE_POST_COMMIT, "post-commit"),
|
||||
NM_UTILS_ENUM2STR(NM_L3_CONFIG_NOTIFY_TYPE_ROUTES_TEMPORARY_NOT_AVAILABLE_EXPIRED,
|
||||
"routes-temporary-not-available-expired"),
|
||||
|
|
@ -683,6 +684,7 @@ _obj_state_data_free(gpointer data)
|
|||
ObjStateData *obj_state = data;
|
||||
|
||||
c_list_unlink_stale(&obj_state->os_lst);
|
||||
c_list_unlink_stale(&obj_state->os_zombie_lst);
|
||||
c_list_unlink_stale(&obj_state->os_temporary_not_available_lst);
|
||||
nmp_object_unref(obj_state->obj);
|
||||
nmp_object_unref(obj_state->os_plobj);
|
||||
|
|
@ -3409,9 +3411,6 @@ _l3cfg_update_combined_config(NML3Cfg * self,
|
|||
continue;
|
||||
|
||||
for (IS_IPv4 = 1; IS_IPv4 >= 0; IS_IPv4--) {
|
||||
/* FIXME(l3cfg): VRF needs to be treated specially. */
|
||||
nm_assert(!nm_l3cfg_is_vrf(self));
|
||||
|
||||
nm_l3_config_data_add_dependent_device_routes(
|
||||
l3cd,
|
||||
IS_IPv4 ? AF_INET : AF_INET6,
|
||||
|
|
@ -3536,13 +3535,15 @@ _routes_temporary_not_available_update(NML3Cfg * self,
|
|||
int addr_family,
|
||||
GPtrArray *routes_temporary_not_available_arr)
|
||||
{
|
||||
ObjStateData *obj_state;
|
||||
ObjStateData *obj_state_safe;
|
||||
gint64 now_msec;
|
||||
gboolean prune_all = FALSE;
|
||||
gboolean success = TRUE;
|
||||
guint i;
|
||||
ObjStateData * obj_state;
|
||||
ObjStateData * obj_state_safe;
|
||||
gint64 now_msec;
|
||||
gboolean prune_all = FALSE;
|
||||
gboolean success = TRUE;
|
||||
guint i;
|
||||
const NMPClass *klass;
|
||||
|
||||
klass = nmp_class_from_type(NMP_OBJECT_TYPE_IP_ROUTE(NM_IS_IPv4(addr_family)));
|
||||
now_msec = nm_utils_get_monotonic_timestamp_msec();
|
||||
|
||||
if (nm_g_ptr_array_len(routes_temporary_not_available_arr) <= 0) {
|
||||
|
|
@ -3553,8 +3554,10 @@ _routes_temporary_not_available_update(NML3Cfg * self,
|
|||
c_list_for_each_entry (obj_state,
|
||||
&self->priv.p->obj_state_temporary_not_available_lst_head,
|
||||
os_temporary_not_available_lst) {
|
||||
nm_assert(obj_state->os_temporary_not_available_timestamp_msec > 0);
|
||||
obj_state->os_tna_dirty = TRUE;
|
||||
if (NMP_OBJECT_GET_CLASS(obj_state->obj) == klass) {
|
||||
nm_assert(obj_state->os_temporary_not_available_timestamp_msec > 0);
|
||||
obj_state->os_tna_dirty = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < routes_temporary_not_available_arr->len; i++) {
|
||||
|
|
@ -3614,8 +3617,10 @@ out_prune:
|
|||
&self->priv.p->obj_state_temporary_not_available_lst_head,
|
||||
os_temporary_not_available_lst) {
|
||||
if (prune_all || obj_state->os_tna_dirty) {
|
||||
obj_state->os_temporary_not_available_timestamp_msec = 0;
|
||||
c_list_unlink(&obj_state->os_temporary_not_available_lst);
|
||||
if (NMP_OBJECT_GET_CLASS(obj_state->obj) == klass) {
|
||||
obj_state->os_temporary_not_available_timestamp_msec = 0;
|
||||
c_list_unlink(&obj_state->os_temporary_not_available_lst);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -3804,6 +3809,8 @@ _l3_commit(NML3Cfg *self, NML3CfgCommitType commit_type, gboolean is_idle)
|
|||
&l3cd_old,
|
||||
&changed_combined_l3cd);
|
||||
|
||||
_nm_l3cfg_emit_signal_notify_simple(self, NM_L3_CONFIG_NOTIFY_TYPE_PRE_COMMIT);
|
||||
|
||||
_l3_commit_one(self, AF_INET, commit_type, changed_combined_l3cd, l3cd_old);
|
||||
_l3_commit_one(self, AF_INET6, commit_type, changed_combined_l3cd, l3cd_old);
|
||||
|
||||
|
|
|
|||
|
|
@ -130,6 +130,12 @@ typedef enum {
|
|||
|
||||
NM_L3_CONFIG_NOTIFY_TYPE_ACD_EVENT,
|
||||
|
||||
/* emitted before the merged l3cd is committed to platform.
|
||||
*
|
||||
* This event also gets emitted "under unsafe circumstances".
|
||||
* See NM_L3_CONFIG_NOTIFY_TYPE_L3CD_CHANGED. */
|
||||
NM_L3_CONFIG_NOTIFY_TYPE_PRE_COMMIT,
|
||||
|
||||
/* emitted at the end of nm_l3cfg_platform_commit(). This signals also that
|
||||
* nm_l3cfg_is_ready() might have switched to TRUE. */
|
||||
NM_L3_CONFIG_NOTIFY_TYPE_POST_COMMIT,
|
||||
|
|
|
|||
|
|
@ -135,6 +135,7 @@ typedef struct {
|
|||
NML3AcdDefendType acd_defend_type_a;
|
||||
|
||||
TestL3cfgNotifyType notify_type;
|
||||
guint pre_commit_event_count;
|
||||
guint post_commit_event_count;
|
||||
guint general_event_count;
|
||||
guint general_event_flags;
|
||||
|
|
@ -154,6 +155,7 @@ _test_l3cfg_data_set_notify_type(TestL3cfgData *tdata, TestL3cfgNotifyType notif
|
|||
g_assert(tdata);
|
||||
|
||||
tdata->notify_type = notify_type;
|
||||
tdata->pre_commit_event_count = 0;
|
||||
tdata->post_commit_event_count = 0;
|
||||
tdata->general_event_count = 0;
|
||||
tdata->general_event_flags = 0;
|
||||
|
|
@ -212,6 +214,10 @@ _test_l3cfg_signal_notify(NML3Cfg * l3cfg,
|
|||
case TEST_L3CFG_NOTIFY_TYPE_COMMIT_1:
|
||||
g_assert_cmpint(tdata->post_commit_event_count, ==, 0);
|
||||
switch (notify_data->notify_type) {
|
||||
case NM_L3_CONFIG_NOTIFY_TYPE_PRE_COMMIT:
|
||||
g_assert_cmpint(tdata->pre_commit_event_count, ==, 0);
|
||||
tdata->pre_commit_event_count++;
|
||||
return;
|
||||
case NM_L3_CONFIG_NOTIFY_TYPE_POST_COMMIT:
|
||||
tdata->post_commit_event_count++;
|
||||
return;
|
||||
|
|
@ -258,6 +264,7 @@ _test_l3cfg_signal_notify(NML3Cfg * l3cfg,
|
|||
1 + 2 + (tdata->add_addr4_101 ? (tdata->has_addr4_101 ? 1 : 3) : 0);
|
||||
|
||||
if (NM_IN_SET(notify_data->notify_type,
|
||||
NM_L3_CONFIG_NOTIFY_TYPE_PRE_COMMIT,
|
||||
NM_L3_CONFIG_NOTIFY_TYPE_PLATFORM_CHANGE,
|
||||
NM_L3_CONFIG_NOTIFY_TYPE_PLATFORM_CHANGE_ON_IDLE))
|
||||
return;
|
||||
|
|
@ -453,6 +460,7 @@ test_l3cfg(gconstpointer test_data)
|
|||
|
||||
_test_l3cfg_data_set_notify_type(tdata, TEST_L3CFG_NOTIFY_TYPE_COMMIT_1);
|
||||
nm_l3cfg_commit(l3cfg0, NM_L3_CFG_COMMIT_TYPE_REAPPLY);
|
||||
g_assert_cmpint(tdata->pre_commit_event_count, ==, 1);
|
||||
g_assert_cmpint(tdata->post_commit_event_count, ==, 1);
|
||||
_test_l3cfg_data_set_notify_type(tdata, TEST_L3CFG_NOTIFY_TYPE_NONE);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue