ip4-config: keep track of ifindex
No functional change, a cosmetic thing for now. We want it set before any routes are added and ensure routes have a valid ifindex before we pass it to the platform. In a future NMRouteManager will need to look up the route for a device in its cache thus we'll need to make sure routes passed to the it have an appropriate ifindex set.
This commit is contained in:
@@ -498,8 +498,10 @@ modem_ip4_config_result (NMModem *modem,
|
|||||||
error->code, error->message ? error->message : "(unknown)");
|
error->code, error->message ? error->message : "(unknown)");
|
||||||
|
|
||||||
nm_device_state_changed (device, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE);
|
nm_device_state_changed (device, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE);
|
||||||
} else
|
} else {
|
||||||
|
nm_ip4_config_set_ifindex (config, nm_device_get_ifindex (device));
|
||||||
nm_device_activate_schedule_ip4_config_result (device, config);
|
nm_device_activate_schedule_ip4_config_result (device, config);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@@ -2614,6 +2614,7 @@ aipd_get_ip4_config (NMDevice *self, guint32 lla)
|
|||||||
NMPlatformIP4Route route;
|
NMPlatformIP4Route route;
|
||||||
|
|
||||||
config = nm_ip4_config_new ();
|
config = nm_ip4_config_new ();
|
||||||
|
nm_ip4_config_set_ifindex (config, nm_device_get_ifindex (self));
|
||||||
g_assert (config);
|
g_assert (config);
|
||||||
|
|
||||||
memset (&address, 0, sizeof (address));
|
memset (&address, 0, sizeof (address));
|
||||||
@@ -2875,6 +2876,8 @@ ensure_con_ipx_config (NMDevice *self)
|
|||||||
priv->con_ip4_config = nm_ip4_config_new ();
|
priv->con_ip4_config = nm_ip4_config_new ();
|
||||||
priv->con_ip6_config = nm_ip6_config_new ();
|
priv->con_ip6_config = nm_ip6_config_new ();
|
||||||
|
|
||||||
|
nm_ip4_config_set_ifindex (priv->con_ip4_config, nm_device_get_ifindex (self));
|
||||||
|
|
||||||
nm_ip4_config_merge_setting (priv->con_ip4_config,
|
nm_ip4_config_merge_setting (priv->con_ip4_config,
|
||||||
nm_connection_get_setting_ip4_config (connection),
|
nm_connection_get_setting_ip4_config (connection),
|
||||||
nm_device_get_ip4_route_metric (self));
|
nm_device_get_ip4_route_metric (self));
|
||||||
@@ -2942,6 +2945,7 @@ ip4_config_merge_and_apply (NMDevice *self,
|
|||||||
}
|
}
|
||||||
|
|
||||||
composite = nm_ip4_config_new ();
|
composite = nm_ip4_config_new ();
|
||||||
|
nm_ip4_config_set_ifindex (composite, nm_device_get_ifindex (self));
|
||||||
|
|
||||||
ensure_con_ipx_config (self);
|
ensure_con_ipx_config (self);
|
||||||
|
|
||||||
@@ -3296,6 +3300,7 @@ shared4_new_config (NMDevice *self, NMConnection *connection, NMDeviceStateReaso
|
|||||||
}
|
}
|
||||||
|
|
||||||
config = nm_ip4_config_new ();
|
config = nm_ip4_config_new ();
|
||||||
|
nm_ip4_config_set_ifindex (config, nm_device_get_ifindex (self));
|
||||||
address.source = NM_IP_CONFIG_SOURCE_SHARED;
|
address.source = NM_IP_CONFIG_SOURCE_SHARED;
|
||||||
nm_ip4_config_add_address (config, &address);
|
nm_ip4_config_add_address (config, &address);
|
||||||
|
|
||||||
@@ -3456,6 +3461,7 @@ act_stage3_ip4_config_start (NMDevice *self,
|
|||||||
else if (strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_MANUAL) == 0) {
|
else if (strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_MANUAL) == 0) {
|
||||||
/* Use only IPv4 config from the connection data */
|
/* Use only IPv4 config from the connection data */
|
||||||
*out_config = nm_ip4_config_new ();
|
*out_config = nm_ip4_config_new ();
|
||||||
|
nm_ip4_config_set_ifindex (*out_config, nm_device_get_ifindex (self));
|
||||||
g_assert (*out_config);
|
g_assert (*out_config);
|
||||||
ret = NM_ACT_STAGE_RETURN_SUCCESS;
|
ret = NM_ACT_STAGE_RETURN_SUCCESS;
|
||||||
} else if (strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_SHARED) == 0) {
|
} else if (strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_SHARED) == 0) {
|
||||||
@@ -6565,6 +6571,7 @@ find_ip4_lease_config (NMDevice *self,
|
|||||||
NMIP4Config *ext_ip4_config)
|
NMIP4Config *ext_ip4_config)
|
||||||
{
|
{
|
||||||
const char *ip_iface = nm_device_get_ip_iface (self);
|
const char *ip_iface = nm_device_get_ip_iface (self);
|
||||||
|
int ifindex = nm_device_get_ifindex (self);
|
||||||
GSList *leases, *liter;
|
GSList *leases, *liter;
|
||||||
NMIP4Config *found = NULL;
|
NMIP4Config *found = NULL;
|
||||||
|
|
||||||
@@ -6587,6 +6594,7 @@ find_ip4_lease_config (NMDevice *self,
|
|||||||
if (gateway != nm_ip4_config_get_gateway (ext_ip4_config))
|
if (gateway != nm_ip4_config_get_gateway (ext_ip4_config))
|
||||||
continue;
|
continue;
|
||||||
found = g_object_ref (lease_config);
|
found = g_object_ref (lease_config);
|
||||||
|
nm_ip4_config_set_ifindex (found, ifindex);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_slist_free_full (leases, g_object_unref);
|
g_slist_free_full (leases, g_object_unref);
|
||||||
|
@@ -165,6 +165,7 @@ modem_ip4_config_result (NMModem *modem,
|
|||||||
|
|
||||||
nm_device_state_changed (device, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE);
|
nm_device_state_changed (device, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE);
|
||||||
} else {
|
} else {
|
||||||
|
nm_ip4_config_set_ifindex (config, nm_device_get_ifindex (device));
|
||||||
nm_device_set_wwan_ip4_config (device, config);
|
nm_device_set_wwan_ip4_config (device, config);
|
||||||
nm_device_activate_schedule_ip4_config_result (device, NULL);
|
nm_device_activate_schedule_ip4_config_result (device, NULL);
|
||||||
}
|
}
|
||||||
|
@@ -763,7 +763,8 @@ nm_dhcp_client_handle_event (gpointer unused,
|
|||||||
priv->priority,
|
priv->priority,
|
||||||
priv->info_only);
|
priv->info_only);
|
||||||
} else {
|
} else {
|
||||||
ip_config = (GObject *) nm_dhcp_utils_ip4_config_from_options (priv->iface,
|
ip_config = (GObject *) nm_dhcp_utils_ip4_config_from_options (priv->ifindex,
|
||||||
|
priv->iface,
|
||||||
str_options,
|
str_options,
|
||||||
priv->priority);
|
priv->priority);
|
||||||
}
|
}
|
||||||
|
@@ -206,7 +206,8 @@ G_STMT_START { \
|
|||||||
} G_STMT_END
|
} G_STMT_END
|
||||||
|
|
||||||
static NMIP4Config *
|
static NMIP4Config *
|
||||||
lease_to_ip4_config (sd_dhcp_lease *lease,
|
lease_to_ip4_config (const char *iface,
|
||||||
|
sd_dhcp_lease *lease,
|
||||||
GHashTable *options,
|
GHashTable *options,
|
||||||
guint32 default_priority,
|
guint32 default_priority,
|
||||||
gboolean log_lease,
|
gboolean log_lease,
|
||||||
@@ -387,7 +388,7 @@ nm_dhcp_systemd_get_lease_ip_configs (const char *iface,
|
|||||||
path = get_leasefile_path (iface, uuid, FALSE);
|
path = get_leasefile_path (iface, uuid, FALSE);
|
||||||
r = sd_dhcp_lease_load (&lease, path);
|
r = sd_dhcp_lease_load (&lease, path);
|
||||||
if (r == 0 && lease) {
|
if (r == 0 && lease) {
|
||||||
ip4_config = lease_to_ip4_config (lease, NULL, default_route_metric, FALSE, NULL);
|
ip4_config = lease_to_ip4_config (iface, lease, NULL, default_route_metric, FALSE, NULL);
|
||||||
if (ip4_config)
|
if (ip4_config)
|
||||||
leases = g_slist_append (leases, ip4_config);
|
leases = g_slist_append (leases, ip4_config);
|
||||||
}
|
}
|
||||||
@@ -440,7 +441,8 @@ bound4_handle (NMDhcpSystemd *self)
|
|||||||
}
|
}
|
||||||
|
|
||||||
options = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, g_free);
|
options = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, g_free);
|
||||||
ip4_config = lease_to_ip4_config (lease,
|
ip4_config = lease_to_ip4_config (iface,
|
||||||
|
lease,
|
||||||
options,
|
options,
|
||||||
nm_dhcp_client_get_priority (NM_DHCP_CLIENT (self)),
|
nm_dhcp_client_get_priority (NM_DHCP_CLIENT (self)),
|
||||||
TRUE,
|
TRUE,
|
||||||
|
@@ -374,7 +374,8 @@ ip4_add_domain_search (gpointer data, gpointer user_data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
NMIP4Config *
|
NMIP4Config *
|
||||||
nm_dhcp_utils_ip4_config_from_options (const char *iface,
|
nm_dhcp_utils_ip4_config_from_options (int ifindex,
|
||||||
|
const char *iface,
|
||||||
GHashTable *options,
|
GHashTable *options,
|
||||||
guint32 priority)
|
guint32 priority)
|
||||||
{
|
{
|
||||||
@@ -387,6 +388,7 @@ nm_dhcp_utils_ip4_config_from_options (const char *iface,
|
|||||||
g_return_val_if_fail (options != NULL, NULL);
|
g_return_val_if_fail (options != NULL, NULL);
|
||||||
|
|
||||||
ip4_config = nm_ip4_config_new ();
|
ip4_config = nm_ip4_config_new ();
|
||||||
|
nm_ip4_config_set_ifindex (ip4_config, ifindex);
|
||||||
memset (&address, 0, sizeof (address));
|
memset (&address, 0, sizeof (address));
|
||||||
address.timestamp = nm_utils_get_monotonic_timestamp_s ();
|
address.timestamp = nm_utils_get_monotonic_timestamp_s ();
|
||||||
|
|
||||||
|
@@ -24,7 +24,8 @@
|
|||||||
#include <nm-ip4-config.h>
|
#include <nm-ip4-config.h>
|
||||||
#include <nm-ip6-config.h>
|
#include <nm-ip6-config.h>
|
||||||
|
|
||||||
NMIP4Config *nm_dhcp_utils_ip4_config_from_options (const char *iface,
|
NMIP4Config *nm_dhcp_utils_ip4_config_from_options (int ifindex,
|
||||||
|
const char *iface,
|
||||||
GHashTable *options,
|
GHashTable *options,
|
||||||
guint priority);
|
guint priority);
|
||||||
|
|
||||||
|
@@ -88,7 +88,7 @@ test_generic_options (void)
|
|||||||
const char *expected_route2_gw = "10.1.1.1";
|
const char *expected_route2_gw = "10.1.1.1";
|
||||||
|
|
||||||
options = fill_table (generic_options, NULL);
|
options = fill_table (generic_options, NULL);
|
||||||
ip4_config = nm_dhcp_utils_ip4_config_from_options ("eth0", options, 0);
|
ip4_config = nm_dhcp_utils_ip4_config_from_options (1, "eth0", options, 0);
|
||||||
g_assert (ip4_config);
|
g_assert (ip4_config);
|
||||||
|
|
||||||
/* IP4 address */
|
/* IP4 address */
|
||||||
@@ -159,7 +159,7 @@ test_wins_options (void)
|
|||||||
|
|
||||||
options = fill_table (generic_options, NULL);
|
options = fill_table (generic_options, NULL);
|
||||||
options = fill_table (data, options);
|
options = fill_table (data, options);
|
||||||
ip4_config = nm_dhcp_utils_ip4_config_from_options ("eth0", options, 0);
|
ip4_config = nm_dhcp_utils_ip4_config_from_options (1, "eth0", options, 0);
|
||||||
g_assert (ip4_config);
|
g_assert (ip4_config);
|
||||||
|
|
||||||
/* IP4 address */
|
/* IP4 address */
|
||||||
@@ -221,7 +221,7 @@ test_classless_static_routes_1 (void)
|
|||||||
|
|
||||||
options = fill_table (generic_options, NULL);
|
options = fill_table (generic_options, NULL);
|
||||||
options = fill_table (data, options);
|
options = fill_table (data, options);
|
||||||
ip4_config = nm_dhcp_utils_ip4_config_from_options ("eth0", options, 0);
|
ip4_config = nm_dhcp_utils_ip4_config_from_options (1, "eth0", options, 0);
|
||||||
g_assert (ip4_config);
|
g_assert (ip4_config);
|
||||||
|
|
||||||
/* IP4 routes */
|
/* IP4 routes */
|
||||||
@@ -249,7 +249,7 @@ test_classless_static_routes_2 (void)
|
|||||||
|
|
||||||
options = fill_table (generic_options, NULL);
|
options = fill_table (generic_options, NULL);
|
||||||
options = fill_table (data, options);
|
options = fill_table (data, options);
|
||||||
ip4_config = nm_dhcp_utils_ip4_config_from_options ("eth0", options, 0);
|
ip4_config = nm_dhcp_utils_ip4_config_from_options (1, "eth0", options, 0);
|
||||||
g_assert (ip4_config);
|
g_assert (ip4_config);
|
||||||
|
|
||||||
/* IP4 routes */
|
/* IP4 routes */
|
||||||
@@ -278,7 +278,7 @@ test_fedora_dhclient_classless_static_routes (void)
|
|||||||
|
|
||||||
options = fill_table (generic_options, NULL);
|
options = fill_table (generic_options, NULL);
|
||||||
options = fill_table (data, options);
|
options = fill_table (data, options);
|
||||||
ip4_config = nm_dhcp_utils_ip4_config_from_options ("eth0", options, 0);
|
ip4_config = nm_dhcp_utils_ip4_config_from_options (1, "eth0", options, 0);
|
||||||
g_assert (ip4_config);
|
g_assert (ip4_config);
|
||||||
|
|
||||||
/* IP4 routes */
|
/* IP4 routes */
|
||||||
@@ -310,7 +310,7 @@ test_dhclient_invalid_classless_routes_1 (void)
|
|||||||
|
|
||||||
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING,
|
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING,
|
||||||
"*ignoring invalid classless static routes*");
|
"*ignoring invalid classless static routes*");
|
||||||
ip4_config = nm_dhcp_utils_ip4_config_from_options ("eth0", options, 0);
|
ip4_config = nm_dhcp_utils_ip4_config_from_options (1, "eth0", options, 0);
|
||||||
g_assert (ip4_config);
|
g_assert (ip4_config);
|
||||||
g_test_assert_expected_messages ();
|
g_test_assert_expected_messages ();
|
||||||
|
|
||||||
@@ -341,7 +341,7 @@ test_dhcpcd_invalid_classless_routes_1 (void)
|
|||||||
|
|
||||||
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING,
|
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING,
|
||||||
"*ignoring invalid classless static routes*");
|
"*ignoring invalid classless static routes*");
|
||||||
ip4_config = nm_dhcp_utils_ip4_config_from_options ("eth0", options, 0);
|
ip4_config = nm_dhcp_utils_ip4_config_from_options (1, "eth0", options, 0);
|
||||||
g_assert (ip4_config);
|
g_assert (ip4_config);
|
||||||
g_test_assert_expected_messages ();
|
g_test_assert_expected_messages ();
|
||||||
|
|
||||||
@@ -374,7 +374,7 @@ test_dhclient_invalid_classless_routes_2 (void)
|
|||||||
|
|
||||||
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING,
|
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING,
|
||||||
"*ignoring invalid classless static routes*");
|
"*ignoring invalid classless static routes*");
|
||||||
ip4_config = nm_dhcp_utils_ip4_config_from_options ("eth0", options, 0);
|
ip4_config = nm_dhcp_utils_ip4_config_from_options (1, "eth0", options, 0);
|
||||||
g_assert (ip4_config);
|
g_assert (ip4_config);
|
||||||
g_test_assert_expected_messages ();
|
g_test_assert_expected_messages ();
|
||||||
|
|
||||||
@@ -407,7 +407,7 @@ test_dhcpcd_invalid_classless_routes_2 (void)
|
|||||||
|
|
||||||
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING,
|
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING,
|
||||||
"*ignoring invalid classless static routes*");
|
"*ignoring invalid classless static routes*");
|
||||||
ip4_config = nm_dhcp_utils_ip4_config_from_options ("eth0", options, 0);
|
ip4_config = nm_dhcp_utils_ip4_config_from_options (1, "eth0", options, 0);
|
||||||
g_assert (ip4_config);
|
g_assert (ip4_config);
|
||||||
g_test_assert_expected_messages ();
|
g_test_assert_expected_messages ();
|
||||||
|
|
||||||
@@ -440,7 +440,7 @@ test_dhclient_invalid_classless_routes_3 (void)
|
|||||||
|
|
||||||
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING,
|
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING,
|
||||||
"*ignoring invalid classless static routes*");
|
"*ignoring invalid classless static routes*");
|
||||||
ip4_config = nm_dhcp_utils_ip4_config_from_options ("eth0", options, 0);
|
ip4_config = nm_dhcp_utils_ip4_config_from_options (1, "eth0", options, 0);
|
||||||
g_assert (ip4_config);
|
g_assert (ip4_config);
|
||||||
g_test_assert_expected_messages ();
|
g_test_assert_expected_messages ();
|
||||||
|
|
||||||
@@ -468,7 +468,7 @@ test_dhcpcd_invalid_classless_routes_3 (void)
|
|||||||
|
|
||||||
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING,
|
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING,
|
||||||
"*DHCP provided invalid classless static route*");
|
"*DHCP provided invalid classless static route*");
|
||||||
ip4_config = nm_dhcp_utils_ip4_config_from_options ("eth0", options, 0);
|
ip4_config = nm_dhcp_utils_ip4_config_from_options (1, "eth0", options, 0);
|
||||||
g_assert (ip4_config);
|
g_assert (ip4_config);
|
||||||
g_test_assert_expected_messages ();
|
g_test_assert_expected_messages ();
|
||||||
|
|
||||||
@@ -494,7 +494,7 @@ test_dhclient_gw_in_classless_routes (void)
|
|||||||
|
|
||||||
options = fill_table (generic_options, NULL);
|
options = fill_table (generic_options, NULL);
|
||||||
options = fill_table (data, options);
|
options = fill_table (data, options);
|
||||||
ip4_config = nm_dhcp_utils_ip4_config_from_options ("eth0", options, 0);
|
ip4_config = nm_dhcp_utils_ip4_config_from_options (1, "eth0", options, 0);
|
||||||
g_assert (ip4_config);
|
g_assert (ip4_config);
|
||||||
|
|
||||||
/* IP4 routes */
|
/* IP4 routes */
|
||||||
@@ -522,7 +522,7 @@ test_dhcpcd_gw_in_classless_routes (void)
|
|||||||
|
|
||||||
options = fill_table (generic_options, NULL);
|
options = fill_table (generic_options, NULL);
|
||||||
options = fill_table (data, options);
|
options = fill_table (data, options);
|
||||||
ip4_config = nm_dhcp_utils_ip4_config_from_options ("eth0", options, 0);
|
ip4_config = nm_dhcp_utils_ip4_config_from_options (1, "eth0", options, 0);
|
||||||
g_assert (ip4_config);
|
g_assert (ip4_config);
|
||||||
|
|
||||||
/* IP4 routes */
|
/* IP4 routes */
|
||||||
@@ -550,7 +550,7 @@ test_escaped_domain_searches (void)
|
|||||||
|
|
||||||
options = fill_table (generic_options, NULL);
|
options = fill_table (generic_options, NULL);
|
||||||
options = fill_table (data, options);
|
options = fill_table (data, options);
|
||||||
ip4_config = nm_dhcp_utils_ip4_config_from_options ("eth0", options, 0);
|
ip4_config = nm_dhcp_utils_ip4_config_from_options (1, "eth0", options, 0);
|
||||||
g_assert (ip4_config);
|
g_assert (ip4_config);
|
||||||
|
|
||||||
/* domain searches */
|
/* domain searches */
|
||||||
@@ -577,7 +577,7 @@ test_invalid_escaped_domain_searches (void)
|
|||||||
|
|
||||||
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING,
|
g_test_expect_message ("NetworkManager", G_LOG_LEVEL_WARNING,
|
||||||
"*invalid domain search*");
|
"*invalid domain search*");
|
||||||
ip4_config = nm_dhcp_utils_ip4_config_from_options ("eth0", options, 0);
|
ip4_config = nm_dhcp_utils_ip4_config_from_options (1, "eth0", options, 0);
|
||||||
g_assert (ip4_config);
|
g_assert (ip4_config);
|
||||||
g_test_assert_expected_messages ();
|
g_test_assert_expected_messages ();
|
||||||
|
|
||||||
@@ -598,7 +598,7 @@ test_ip4_missing_prefix (const char *ip, guint32 expected_prefix)
|
|||||||
g_hash_table_insert (options, "ip_address", (gpointer) ip);
|
g_hash_table_insert (options, "ip_address", (gpointer) ip);
|
||||||
g_hash_table_remove (options, "subnet_mask");
|
g_hash_table_remove (options, "subnet_mask");
|
||||||
|
|
||||||
ip4_config = nm_dhcp_utils_ip4_config_from_options ("eth0", options, 0);
|
ip4_config = nm_dhcp_utils_ip4_config_from_options (1, "eth0", options, 0);
|
||||||
g_assert (ip4_config);
|
g_assert (ip4_config);
|
||||||
|
|
||||||
g_assert_cmpint (nm_ip4_config_get_num_addresses (ip4_config), ==, 1);
|
g_assert_cmpint (nm_ip4_config_get_num_addresses (ip4_config), ==, 1);
|
||||||
@@ -643,7 +643,7 @@ test_ip4_prefix_classless (void)
|
|||||||
g_hash_table_insert (options, "ip_address", "172.16.54.22");
|
g_hash_table_insert (options, "ip_address", "172.16.54.22");
|
||||||
g_hash_table_insert (options, "subnet_mask", "255.255.252.0");
|
g_hash_table_insert (options, "subnet_mask", "255.255.252.0");
|
||||||
|
|
||||||
ip4_config = nm_dhcp_utils_ip4_config_from_options ("eth0", options, 0);
|
ip4_config = nm_dhcp_utils_ip4_config_from_options (1, "eth0", options, 0);
|
||||||
g_assert (ip4_config);
|
g_assert (ip4_config);
|
||||||
|
|
||||||
g_assert_cmpint (nm_ip4_config_get_num_addresses (ip4_config), ==, 1);
|
g_assert_cmpint (nm_ip4_config_get_num_addresses (ip4_config), ==, 1);
|
||||||
|
@@ -87,6 +87,7 @@ dhcp4_state_changed (NMDhcpClient *client,
|
|||||||
if (last_config) {
|
if (last_config) {
|
||||||
g_object_unref (last_config);
|
g_object_unref (last_config);
|
||||||
last_config = nm_ip4_config_new ();
|
last_config = nm_ip4_config_new ();
|
||||||
|
nm_ip4_config_set_ifindex (last_config, nm_dhcp_client_get_ifindex (client));
|
||||||
nm_ip4_config_replace (last_config, ip4_config, NULL);
|
nm_ip4_config_replace (last_config, ip4_config, NULL);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@@ -55,6 +55,7 @@ typedef struct {
|
|||||||
GArray *wins;
|
GArray *wins;
|
||||||
guint32 mtu;
|
guint32 mtu;
|
||||||
NMIPConfigSource mtu_source;
|
NMIPConfigSource mtu_source;
|
||||||
|
int ifindex;
|
||||||
} NMIP4ConfigPrivate;
|
} NMIP4ConfigPrivate;
|
||||||
|
|
||||||
/* internal guint32 are assigned to gobject properties of type uint. Ensure, that uint is large enough */
|
/* internal guint32 are assigned to gobject properties of type uint. Ensure, that uint is large enough */
|
||||||
@@ -78,13 +79,22 @@ enum {
|
|||||||
static GParamSpec *obj_properties[LAST_PROP] = { NULL, };
|
static GParamSpec *obj_properties[LAST_PROP] = { NULL, };
|
||||||
#define _NOTIFY(config, prop) G_STMT_START { g_object_notify_by_pspec (G_OBJECT (config), obj_properties[prop]); } G_STMT_END
|
#define _NOTIFY(config, prop) G_STMT_START { g_object_notify_by_pspec (G_OBJECT (config), obj_properties[prop]); } G_STMT_END
|
||||||
|
|
||||||
|
|
||||||
NMIP4Config *
|
NMIP4Config *
|
||||||
nm_ip4_config_new (void)
|
nm_ip4_config_new ()
|
||||||
{
|
{
|
||||||
return (NMIP4Config *) g_object_new (NM_TYPE_IP4_CONFIG, NULL);
|
return (NMIP4Config *) g_object_new (NM_TYPE_IP4_CONFIG, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
nm_ip4_config_set_ifindex (NMIP4Config *config, int ifindex)
|
||||||
|
{
|
||||||
|
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
|
||||||
|
|
||||||
|
g_return_if_fail (priv->ifindex == 0);
|
||||||
|
g_assert (priv->routes->len == 0);
|
||||||
|
|
||||||
|
priv->ifindex = ifindex;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
nm_ip4_config_export (NMIP4Config *config)
|
nm_ip4_config_export (NMIP4Config *config)
|
||||||
@@ -191,6 +201,7 @@ nm_ip4_config_capture (int ifindex, gboolean capture_resolv_conf)
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
config = nm_ip4_config_new ();
|
config = nm_ip4_config_new ();
|
||||||
|
nm_ip4_config_set_ifindex (config, ifindex);
|
||||||
priv = NM_IP4_CONFIG_GET_PRIVATE (config);
|
priv = NM_IP4_CONFIG_GET_PRIVATE (config);
|
||||||
|
|
||||||
g_array_unref (priv->addresses);
|
g_array_unref (priv->addresses);
|
||||||
@@ -825,6 +836,12 @@ nm_ip4_config_replace (NMIP4Config *dst, const NMIP4Config *src, gboolean *relev
|
|||||||
|
|
||||||
g_object_freeze_notify (G_OBJECT (dst));
|
g_object_freeze_notify (G_OBJECT (dst));
|
||||||
|
|
||||||
|
/* ifindex */
|
||||||
|
if (src_priv->ifindex != dst_priv->ifindex) {
|
||||||
|
nm_ip4_config_set_ifindex (dst, src_priv->ifindex);
|
||||||
|
has_minor_changes = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
/* never_default */
|
/* never_default */
|
||||||
if (src_priv->never_default != dst_priv->never_default) {
|
if (src_priv->never_default != dst_priv->never_default) {
|
||||||
dst_priv->never_default = src_priv->never_default;
|
dst_priv->never_default = src_priv->never_default;
|
||||||
@@ -1266,6 +1283,7 @@ nm_ip4_config_add_route (NMIP4Config *config, const NMPlatformIP4Route *new)
|
|||||||
|
|
||||||
g_return_if_fail (new != NULL);
|
g_return_if_fail (new != NULL);
|
||||||
g_return_if_fail (new->plen > 0);
|
g_return_if_fail (new->plen > 0);
|
||||||
|
g_assert (priv->ifindex);
|
||||||
|
|
||||||
for (i = 0; i < priv->routes->len; i++ ) {
|
for (i = 0; i < priv->routes->len; i++ ) {
|
||||||
NMPlatformIP4Route *item = &g_array_index (priv->routes, NMPlatformIP4Route, i);
|
NMPlatformIP4Route *item = &g_array_index (priv->routes, NMPlatformIP4Route, i);
|
||||||
@@ -1282,6 +1300,7 @@ nm_ip4_config_add_route (NMIP4Config *config, const NMPlatformIP4Route *new)
|
|||||||
}
|
}
|
||||||
|
|
||||||
g_array_append_val (priv->routes, *new);
|
g_array_append_val (priv->routes, *new);
|
||||||
|
g_array_index (priv->routes, NMPlatformIP4Route, priv->routes->len - 1).ifindex = priv->ifindex;
|
||||||
NOTIFY:
|
NOTIFY:
|
||||||
_NOTIFY (config, PROP_ROUTE_DATA);
|
_NOTIFY (config, PROP_ROUTE_DATA);
|
||||||
_NOTIFY (config, PROP_ROUTES);
|
_NOTIFY (config, PROP_ROUTES);
|
||||||
|
@@ -57,6 +57,7 @@ GType nm_ip4_config_get_type (void);
|
|||||||
|
|
||||||
|
|
||||||
NMIP4Config * nm_ip4_config_new (void);
|
NMIP4Config * nm_ip4_config_new (void);
|
||||||
|
void nm_ip4_config_set_ifindex (NMIP4Config *config, int ifindex);
|
||||||
|
|
||||||
/* D-Bus integration */
|
/* D-Bus integration */
|
||||||
void nm_ip4_config_export (NMIP4Config *config);
|
void nm_ip4_config_export (NMIP4Config *config);
|
||||||
|
@@ -547,6 +547,7 @@ impl_ppp_manager_set_ip4_config (NMPPPManager *manager,
|
|||||||
remove_timeout_handler (manager);
|
remove_timeout_handler (manager);
|
||||||
|
|
||||||
config = nm_ip4_config_new ();
|
config = nm_ip4_config_new ();
|
||||||
|
nm_ip4_config_set_ifindex (config, nm_platform_link_get_ifindex (priv->ip_iface));
|
||||||
memset (&address, 0, sizeof (address));
|
memset (&address, 0, sizeof (address));
|
||||||
address.plen = 32;
|
address.plen = 32;
|
||||||
|
|
||||||
|
@@ -72,6 +72,7 @@ build_test_config (void)
|
|||||||
|
|
||||||
/* Build up the config to subtract */
|
/* Build up the config to subtract */
|
||||||
config = nm_ip4_config_new ();
|
config = nm_ip4_config_new ();
|
||||||
|
nm_ip4_config_set_ifindex (config, 1);
|
||||||
|
|
||||||
addr_init (&addr, "192.168.1.10", "1.2.3.4", 24);
|
addr_init (&addr, "192.168.1.10", "1.2.3.4", 24);
|
||||||
nm_ip4_config_add_address (config, &addr);
|
nm_ip4_config_add_address (config, &addr);
|
||||||
@@ -192,7 +193,9 @@ test_compare_with_source (void)
|
|||||||
NMPlatformIP4Route route;
|
NMPlatformIP4Route route;
|
||||||
|
|
||||||
a = nm_ip4_config_new ();
|
a = nm_ip4_config_new ();
|
||||||
|
nm_ip4_config_set_ifindex (a, 1);
|
||||||
b = nm_ip4_config_new ();
|
b = nm_ip4_config_new ();
|
||||||
|
nm_ip4_config_set_ifindex (b, 2);
|
||||||
|
|
||||||
/* Address */
|
/* Address */
|
||||||
addr_init (&addr, "1.2.3.4", NULL, 24);
|
addr_init (&addr, "1.2.3.4", NULL, 24);
|
||||||
@@ -225,6 +228,7 @@ test_add_address_with_source (void)
|
|||||||
const NMPlatformIP4Address *test_addr;
|
const NMPlatformIP4Address *test_addr;
|
||||||
|
|
||||||
a = nm_ip4_config_new ();
|
a = nm_ip4_config_new ();
|
||||||
|
nm_ip4_config_set_ifindex (a, 1);
|
||||||
|
|
||||||
/* Test that a higher priority source is not overwritten */
|
/* Test that a higher priority source is not overwritten */
|
||||||
addr_init (&addr, "1.2.3.4", NULL, 24);
|
addr_init (&addr, "1.2.3.4", NULL, 24);
|
||||||
@@ -265,6 +269,7 @@ test_add_route_with_source (void)
|
|||||||
const NMPlatformIP4Route *test_route;
|
const NMPlatformIP4Route *test_route;
|
||||||
|
|
||||||
a = nm_ip4_config_new ();
|
a = nm_ip4_config_new ();
|
||||||
|
nm_ip4_config_set_ifindex (a, 1);
|
||||||
|
|
||||||
/* Test that a higher priority source is not overwritten */
|
/* Test that a higher priority source is not overwritten */
|
||||||
route_new (&route, "1.2.3.4", 24, "1.2.3.1");
|
route_new (&route, "1.2.3.4", 24, "1.2.3.1");
|
||||||
|
@@ -893,8 +893,10 @@ apply_parent_device_config (NMVpnConnection *connection)
|
|||||||
NMIP4Config *vpn4_parent_config = NULL;
|
NMIP4Config *vpn4_parent_config = NULL;
|
||||||
NMIP6Config *vpn6_parent_config = NULL;
|
NMIP6Config *vpn6_parent_config = NULL;
|
||||||
|
|
||||||
if (priv->ip4_config)
|
if (priv->ip4_config) {
|
||||||
vpn4_parent_config = nm_ip4_config_new ();
|
vpn4_parent_config = nm_ip4_config_new ();
|
||||||
|
nm_ip4_config_set_ifindex (vpn4_parent_config, priv->ip_ifindex);
|
||||||
|
}
|
||||||
if (priv->ip6_config)
|
if (priv->ip6_config)
|
||||||
vpn6_parent_config = nm_ip6_config_new ();
|
vpn6_parent_config = nm_ip6_config_new ();
|
||||||
|
|
||||||
@@ -1191,6 +1193,7 @@ nm_vpn_connection_ip4_config_get (DBusGProxy *proxy,
|
|||||||
}
|
}
|
||||||
|
|
||||||
config = nm_ip4_config_new ();
|
config = nm_ip4_config_new ();
|
||||||
|
nm_ip4_config_set_ifindex (config, priv->ip_ifindex);
|
||||||
|
|
||||||
memset (&address, 0, sizeof (address));
|
memset (&address, 0, sizeof (address));
|
||||||
address.plen = 24;
|
address.plen = 24;
|
||||||
|
Reference in New Issue
Block a user