diff options
author | Dan Williams <dcbw@redhat.com> | 2015-02-20 16:31:10 -0600 |
---|---|---|
committer | Lubomir Rintel <lkundrak@v3.sk> | 2015-02-27 16:50:09 +0100 |
commit | 84f54f0a5f5cc90887aec3357289fe9429da738a (patch) | |
tree | 3893b7fa7f8846a680a05019aece42fab9427342 | |
parent | 0659a67c8fb2a8f13f12fd05967bc92670dd4410 (diff) | |
download | NetworkManager-84f54f0a5f5cc90887aec3357289fe9429da738a.tar.gz |
core: pass ifindex as parameter to nm_ip4_config_new()
-rw-r--r-- | include/nm-test-utils.h | 2 | ||||
-rw-r--r-- | src/devices/bluetooth/nm-device-bt.c | 4 | ||||
-rw-r--r-- | src/devices/nm-device.c | 28 | ||||
-rw-r--r-- | src/devices/wwan/nm-device-modem.c | 1 | ||||
-rw-r--r-- | src/devices/wwan/nm-modem-broadband.c | 6 | ||||
-rw-r--r-- | src/dhcp-manager/nm-dhcp-client.h | 1 | ||||
-rw-r--r-- | src/dhcp-manager/nm-dhcp-dhclient-utils.c | 4 | ||||
-rw-r--r-- | src/dhcp-manager/nm-dhcp-dhclient-utils.h | 1 | ||||
-rw-r--r-- | src/dhcp-manager/nm-dhcp-dhclient.c | 3 | ||||
-rw-r--r-- | src/dhcp-manager/nm-dhcp-manager.c | 4 | ||||
-rw-r--r-- | src/dhcp-manager/nm-dhcp-manager.h | 1 | ||||
-rw-r--r-- | src/dhcp-manager/nm-dhcp-systemd.c | 7 | ||||
-rw-r--r-- | src/dhcp-manager/nm-dhcp-utils.c | 3 | ||||
-rw-r--r-- | src/dhcp-manager/tests/test-dhcp-dhclient.c | 6 | ||||
-rw-r--r-- | src/nm-iface-helper.c | 3 | ||||
-rw-r--r-- | src/nm-ip4-config.c | 51 | ||||
-rw-r--r-- | src/nm-ip4-config.h | 4 | ||||
-rw-r--r-- | src/ppp-manager/nm-ppp-manager.c | 3 | ||||
-rw-r--r-- | src/tests/test-ip4-config.c | 15 | ||||
-rw-r--r-- | src/vpn-manager/nm-vpn-connection.c | 9 |
20 files changed, 89 insertions, 67 deletions
diff --git a/include/nm-test-utils.h b/include/nm-test-utils.h index 24523abdad..996f6654dd 100644 --- a/include/nm-test-utils.h +++ b/include/nm-test-utils.h @@ -686,7 +686,7 @@ nmtst_platform_ip6_routes_equal (const NMPlatformIP6Route *a, const NMPlatformIP inline static NMIP4Config * nmtst_ip4_config_clone (NMIP4Config *config) { - NMIP4Config *copy = nm_ip4_config_new (); + NMIP4Config *copy = nm_ip4_config_new (-1); g_assert (copy); g_assert (config); diff --git a/src/devices/bluetooth/nm-device-bt.c b/src/devices/bluetooth/nm-device-bt.c index af466e5347..61371dddec 100644 --- a/src/devices/bluetooth/nm-device-bt.c +++ b/src/devices/bluetooth/nm-device-bt.c @@ -498,10 +498,8 @@ modem_ip4_config_result (NMModem *modem, error->code, error->message ? error->message : "(unknown)"); nm_device_state_changed (device, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE); - } else { - nm_ip4_config_set_ifindex (config, nm_device_get_ifindex (device)); + } else nm_device_activate_schedule_ip4_config_result (device, config); - } } static void diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index 204840df09..e43db8f351 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -2613,8 +2613,7 @@ aipd_get_ip4_config (NMDevice *self, guint32 lla) NMPlatformIP4Address address; NMPlatformIP4Route route; - config = nm_ip4_config_new (); - nm_ip4_config_set_ifindex (config, nm_device_get_ifindex (self)); + config = nm_ip4_config_new (nm_device_get_ip_ifindex (self)); g_assert (config); memset (&address, 0, sizeof (address)); @@ -2862,6 +2861,7 @@ static void ensure_con_ipx_config (NMDevice *self) { NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self); + int ip_ifindex = nm_device_get_ip_ifindex (self); NMConnection *connection; g_assert (!!priv->con_ip4_config == !!priv->con_ip6_config); @@ -2873,10 +2873,9 @@ ensure_con_ipx_config (NMDevice *self) if (!connection) return; - priv->con_ip4_config = nm_ip4_config_new (); + priv->con_ip4_config = nm_ip4_config_new (ip_ifindex); priv->con_ip6_config = nm_ip6_config_new (); - nm_ip4_config_set_ifindex (priv->con_ip4_config, nm_device_get_ifindex (self)); nm_ip6_config_set_ifindex (priv->con_ip6_config, nm_device_get_ifindex (self)); nm_ip4_config_merge_setting (priv->con_ip4_config, @@ -2945,8 +2944,7 @@ ip4_config_merge_and_apply (NMDevice *self, priv->dev_ip4_config = g_object_ref (config); } - composite = nm_ip4_config_new (); - nm_ip4_config_set_ifindex (composite, nm_device_get_ifindex (self)); + composite = nm_ip4_config_new (nm_device_get_ip_ifindex (self)); ensure_con_ipx_config (self); @@ -3300,8 +3298,7 @@ shared4_new_config (NMDevice *self, NMConnection *connection, NMDeviceStateReaso return NULL; } - config = nm_ip4_config_new (); - nm_ip4_config_set_ifindex (config, nm_device_get_ifindex (self)); + config = nm_ip4_config_new (nm_device_get_ip_ifindex (self)); address.source = NM_IP_CONFIG_SOURCE_SHARED; nm_ip4_config_add_address (config, &address); @@ -3461,8 +3458,7 @@ act_stage3_ip4_config_start (NMDevice *self, ret = aipd_start (self, reason); else if (strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_MANUAL) == 0) { /* Use only IPv4 config from the connection data */ - *out_config = nm_ip4_config_new (); - nm_ip4_config_set_ifindex (*out_config, nm_device_get_ifindex (self)); + *out_config = nm_ip4_config_new (nm_device_get_ip_ifindex (self)); g_assert (*out_config); ret = NM_ACT_STAGE_RETURN_SUCCESS; } else if (strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_SHARED) == 0) { @@ -5910,7 +5906,7 @@ nm_device_set_ip4_config (NMDevice *self, gboolean has_changes = FALSE; gboolean success = TRUE; NMDeviceStateReason reason_local = NM_DEVICE_STATE_REASON_NONE; - int ip_ifindex; + int ip_ifindex, config_ifindex; g_return_val_if_fail (NM_IS_DEVICE (self), FALSE); @@ -5918,6 +5914,12 @@ nm_device_set_ip4_config (NMDevice *self, ip_iface = nm_device_get_ip_iface (self); ip_ifindex = nm_device_get_ip_ifindex (self); + if (new_config) { + config_ifindex = nm_ip4_config_get_ifindex (new_config); + if (config_ifindex > 0) + g_return_val_if_fail (ip_ifindex == config_ifindex, FALSE); + } + old_config = priv->ip4_config; /* Always commit to nm-platform to update lifetimes */ @@ -6578,7 +6580,7 @@ find_ip4_lease_config (NMDevice *self, NMIP4Config *ext_ip4_config) { const char *ip_iface = nm_device_get_ip_iface (self); - int ifindex = nm_device_get_ifindex (self); + int ip_ifindex = nm_device_get_ip_ifindex (self); GSList *leases, *liter; NMIP4Config *found = NULL; @@ -6587,6 +6589,7 @@ find_ip4_lease_config (NMDevice *self, leases = nm_dhcp_manager_get_lease_ip_configs (nm_dhcp_manager_get (), ip_iface, + ip_ifindex, nm_connection_get_uuid (connection), FALSE, nm_device_get_ip4_route_metric (self)); @@ -6601,7 +6604,6 @@ find_ip4_lease_config (NMDevice *self, if (gateway != nm_ip4_config_get_gateway (ext_ip4_config)) continue; found = g_object_ref (lease_config); - nm_ip4_config_set_ifindex (found, ifindex); } g_slist_free_full (leases, g_object_unref); diff --git a/src/devices/wwan/nm-device-modem.c b/src/devices/wwan/nm-device-modem.c index f8c90837e6..9102f5db89 100644 --- a/src/devices/wwan/nm-device-modem.c +++ b/src/devices/wwan/nm-device-modem.c @@ -165,7 +165,6 @@ modem_ip4_config_result (NMModem *modem, nm_device_state_changed (device, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE); } else { - nm_ip4_config_set_ifindex (config, nm_device_get_ifindex (device)); nm_device_set_wwan_ip4_config (device, config); nm_device_activate_schedule_ip4_config_result (device, NULL); } diff --git a/src/devices/wwan/nm-modem-broadband.c b/src/devices/wwan/nm-modem-broadband.c index 4bb72fd190..ebd849485f 100644 --- a/src/devices/wwan/nm-modem-broadband.c +++ b/src/devices/wwan/nm-modem-broadband.c @@ -715,6 +715,7 @@ static_stage3_ip4_done (NMModemBroadband *self) { GError *error = NULL; NMIP4Config *config = NULL; + const char *data_port; const gchar *address_string; const gchar *gw_string; guint32 address_network; @@ -724,6 +725,7 @@ static_stage3_ip4_done (NMModemBroadband *self) guint i; g_assert (self->priv->ipv4_config); + g_assert (self->priv->bearer); nm_log_info (LOGD_MB, "(%s): IPv4 static configuration:", nm_modem_get_uid (NM_MODEM (self))); @@ -743,7 +745,9 @@ static_stage3_ip4_done (NMModemBroadband *self) gw_string = mm_bearer_ip_config_get_gateway (self->priv->ipv4_config); ip4_string_to_num (gw_string, &gw); - config = nm_ip4_config_new (); + data_port = mm_bearer_get_interface (self->priv->bearer); + g_assert (data_port); + config = nm_ip4_config_new (nm_platform_link_get_ifindex (data_port)); memset (&address, 0, sizeof (address)); address.address = address_network; diff --git a/src/dhcp-manager/nm-dhcp-client.h b/src/dhcp-manager/nm-dhcp-client.h index 971c9dc04e..0cbd2001bb 100644 --- a/src/dhcp-manager/nm-dhcp-client.h +++ b/src/dhcp-manager/nm-dhcp-client.h @@ -101,6 +101,7 @@ GType nm_dhcp_client_get_type (void); typedef const char *(*NMDhcpClientGetPathFunc) (void); typedef GSList * (*NMDhcpClientGetLeaseConfigsFunc) (const char *iface, + int ifindex, const char *uuid, gboolean ipv6, guint32 default_route_metric); diff --git a/src/dhcp-manager/nm-dhcp-dhclient-utils.c b/src/dhcp-manager/nm-dhcp-dhclient-utils.c index 46e8e0b8dc..13ec7a32a3 100644 --- a/src/dhcp-manager/nm-dhcp-dhclient-utils.c +++ b/src/dhcp-manager/nm-dhcp-dhclient-utils.c @@ -571,6 +571,7 @@ lease_validity_span (const char *str_expire, GDateTime *now) /** * nm_dhcp_dhclient_read_lease_ip_configs: * @iface: the interface name to match leases with + * @ifindex: interface index of @iface * @contents: the contents of a dhclient leasefile * @ipv6: whether to read IPv4 or IPv6 leases * @now: the current UTC date/time; pass %NULL to automatically use current @@ -584,6 +585,7 @@ lease_validity_span (const char *str_expire, GDateTime *now) */ GSList * nm_dhcp_dhclient_read_lease_ip_configs (const char *iface, + int ifindex, const char *contents, gboolean ipv6, GDateTime *now) @@ -691,7 +693,7 @@ nm_dhcp_dhclient_read_lease_ip_configs (const char *iface, address.lifetime = address.preferred = expiry; address.source = NM_IP_CONFIG_SOURCE_DHCP; - ip4 = nm_ip4_config_new (); + ip4 = nm_ip4_config_new (ifindex); nm_ip4_config_add_address (ip4, &address); nm_ip4_config_set_gateway (ip4, gw); diff --git a/src/dhcp-manager/nm-dhcp-dhclient-utils.h b/src/dhcp-manager/nm-dhcp-dhclient-utils.h index a1828add4a..3cd0f8b832 100644 --- a/src/dhcp-manager/nm-dhcp-dhclient-utils.h +++ b/src/dhcp-manager/nm-dhcp-dhclient-utils.h @@ -45,6 +45,7 @@ gboolean nm_dhcp_dhclient_save_duid (const char *leasefile, GError **error); GSList *nm_dhcp_dhclient_read_lease_ip_configs (const char *iface, + int ifindex, const char *contents, gboolean ipv6, GDateTime *now); diff --git a/src/dhcp-manager/nm-dhcp-dhclient.c b/src/dhcp-manager/nm-dhcp-dhclient.c index 91515ddac1..60cddbd30d 100644 --- a/src/dhcp-manager/nm-dhcp-dhclient.c +++ b/src/dhcp-manager/nm-dhcp-dhclient.c @@ -125,6 +125,7 @@ get_dhclient_leasefile (const char *iface, static GSList * nm_dhcp_dhclient_get_lease_ip_configs (const char *iface, + int ifindex, const char *uuid, gboolean ipv6, guint32 default_route_metric) @@ -141,7 +142,7 @@ nm_dhcp_dhclient_get_lease_ip_configs (const char *iface, && g_file_get_contents (leasefile, &contents, NULL, NULL) && contents && contents[0]) - leases = nm_dhcp_dhclient_read_lease_ip_configs (iface, contents, ipv6, NULL); + leases = nm_dhcp_dhclient_read_lease_ip_configs (iface, ifindex, contents, ipv6, NULL); g_free (leasefile); g_free (contents); diff --git a/src/dhcp-manager/nm-dhcp-manager.c b/src/dhcp-manager/nm-dhcp-manager.c index c547af10cd..fa562e6cf1 100644 --- a/src/dhcp-manager/nm-dhcp-manager.c +++ b/src/dhcp-manager/nm-dhcp-manager.c @@ -353,6 +353,7 @@ nm_dhcp_manager_set_default_hostname (NMDhcpManager *manager, const char *hostna GSList * nm_dhcp_manager_get_lease_ip_configs (NMDhcpManager *self, const char *iface, + int ifindex, const char *uuid, gboolean ipv6, guint32 default_route_metric) @@ -361,11 +362,12 @@ nm_dhcp_manager_get_lease_ip_configs (NMDhcpManager *self, g_return_val_if_fail (NM_IS_DHCP_MANAGER (self), NULL); g_return_val_if_fail (iface != NULL, NULL); + g_return_val_if_fail (ifindex >= -1, NULL); g_return_val_if_fail (uuid != NULL, NULL); desc = find_client_desc (NULL, NM_DHCP_MANAGER_GET_PRIVATE (self)->client_type); if (desc && desc->get_lease_configs_func) - return desc->get_lease_configs_func (iface, uuid, ipv6, default_route_metric); + return desc->get_lease_configs_func (iface, ifindex, uuid, ipv6, default_route_metric); return NULL; } diff --git a/src/dhcp-manager/nm-dhcp-manager.h b/src/dhcp-manager/nm-dhcp-manager.h index bf6cc7786a..4c9e45de96 100644 --- a/src/dhcp-manager/nm-dhcp-manager.h +++ b/src/dhcp-manager/nm-dhcp-manager.h @@ -79,6 +79,7 @@ NMDhcpClient * nm_dhcp_manager_start_ip6 (NMDhcpManager *manager, GSList * nm_dhcp_manager_get_lease_ip_configs (NMDhcpManager *self, const char *iface, + int ifindex, const char *uuid, gboolean ipv6, guint32 default_route_metric); diff --git a/src/dhcp-manager/nm-dhcp-systemd.c b/src/dhcp-manager/nm-dhcp-systemd.c index f3669bf8d4..1ea836e586 100644 --- a/src/dhcp-manager/nm-dhcp-systemd.c +++ b/src/dhcp-manager/nm-dhcp-systemd.c @@ -207,6 +207,7 @@ G_STMT_START { \ static NMIP4Config * lease_to_ip4_config (const char *iface, + int ifindex, sd_dhcp_lease *lease, GHashTable *options, guint32 default_priority, @@ -228,7 +229,7 @@ lease_to_ip4_config (const char *iface, g_return_val_if_fail (lease != NULL, NULL); - ip4_config = nm_ip4_config_new (); + ip4_config = nm_ip4_config_new (ifindex); /* Address */ sd_dhcp_lease_get_address (lease, &tmp_addr); @@ -372,6 +373,7 @@ get_leasefile_path (const char *iface, const char *uuid, gboolean ipv6) static GSList * nm_dhcp_systemd_get_lease_ip_configs (const char *iface, + int ifindex, const char *uuid, gboolean ipv6, guint32 default_route_metric) @@ -388,7 +390,7 @@ nm_dhcp_systemd_get_lease_ip_configs (const char *iface, path = get_leasefile_path (iface, uuid, FALSE); r = sd_dhcp_lease_load (&lease, path); if (r == 0 && lease) { - ip4_config = lease_to_ip4_config (iface, lease, NULL, default_route_metric, FALSE, NULL); + ip4_config = lease_to_ip4_config (iface, ifindex, lease, NULL, default_route_metric, FALSE, NULL); if (ip4_config) leases = g_slist_append (leases, ip4_config); } @@ -442,6 +444,7 @@ bound4_handle (NMDhcpSystemd *self) options = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, g_free); ip4_config = lease_to_ip4_config (iface, + nm_dhcp_client_get_ifindex (NM_DHCP_CLIENT (self)), lease, options, nm_dhcp_client_get_priority (NM_DHCP_CLIENT (self)), diff --git a/src/dhcp-manager/nm-dhcp-utils.c b/src/dhcp-manager/nm-dhcp-utils.c index 91c6e78284..2808f0d89e 100644 --- a/src/dhcp-manager/nm-dhcp-utils.c +++ b/src/dhcp-manager/nm-dhcp-utils.c @@ -387,8 +387,7 @@ nm_dhcp_utils_ip4_config_from_options (int ifindex, g_return_val_if_fail (options != NULL, NULL); - ip4_config = nm_ip4_config_new (); - nm_ip4_config_set_ifindex (ip4_config, ifindex); + ip4_config = nm_ip4_config_new (ifindex); memset (&address, 0, sizeof (address)); address.timestamp = nm_utils_get_monotonic_timestamp_s (); diff --git a/src/dhcp-manager/tests/test-dhcp-dhclient.c b/src/dhcp-manager/tests/test-dhcp-dhclient.c index 848584aadf..40f4f9e7ea 100644 --- a/src/dhcp-manager/tests/test-dhcp-dhclient.c +++ b/src/dhcp-manager/tests/test-dhcp-dhclient.c @@ -601,7 +601,7 @@ test_read_lease_ip4_config_basic (void) /* Date from before the least expiration */ now = g_date_time_new_utc (2013, 11, 1, 19, 55, 32); - leases = nm_dhcp_dhclient_read_lease_ip_configs ("wlan0", contents, FALSE, now); + leases = nm_dhcp_dhclient_read_lease_ip_configs ("wlan0", -1, contents, FALSE, now); g_assert_cmpint (g_slist_length (leases), ==, 2); /* IP4Config #1 */ @@ -673,7 +673,7 @@ test_read_lease_ip4_config_expired (void) /* Date from *after* the lease expiration */ now = g_date_time_new_utc (2013, 12, 1, 19, 55, 32); - leases = nm_dhcp_dhclient_read_lease_ip_configs ("wlan0", contents, FALSE, now); + leases = nm_dhcp_dhclient_read_lease_ip_configs ("wlan0", -1, contents, FALSE, now); g_assert (leases == NULL); g_date_time_unref (now); @@ -695,7 +695,7 @@ test_read_lease_ip4_config_expect_failure (gconstpointer user_data) /* Date from before the least expiration */ now = g_date_time_new_utc (2013, 11, 1, 1, 1, 1); - leases = nm_dhcp_dhclient_read_lease_ip_configs ("wlan0", contents, FALSE, now); + leases = nm_dhcp_dhclient_read_lease_ip_configs ("wlan0", -1, contents, FALSE, now); g_assert (leases == NULL); g_date_time_unref (now); diff --git a/src/nm-iface-helper.c b/src/nm-iface-helper.c index 859967d3c2..cc5a0a6806 100644 --- a/src/nm-iface-helper.c +++ b/src/nm-iface-helper.c @@ -86,8 +86,7 @@ dhcp4_state_changed (NMDhcpClient *client, if (last_config) { g_object_unref (last_config); - last_config = nm_ip4_config_new (); - nm_ip4_config_set_ifindex (last_config, nm_dhcp_client_get_ifindex (client)); + last_config = nm_ip4_config_new (nm_dhcp_client_get_ifindex (client)); nm_ip4_config_replace (last_config, ip4_config, NULL); } break; diff --git a/src/nm-ip4-config.c b/src/nm-ip4-config.c index 77bbe223e8..cc705287e3 100644 --- a/src/nm-ip4-config.c +++ b/src/nm-ip4-config.c @@ -64,6 +64,7 @@ G_STATIC_ASSERT (G_MAXUINT >= 0xFFFFFFFF); enum { PROP_0, + PROP_IFINDEX, PROP_ADDRESS_DATA, PROP_ADDRESSES, PROP_ROUTE_DATA, @@ -80,20 +81,11 @@ 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 NMIP4Config * -nm_ip4_config_new () +nm_ip4_config_new (int ifindex) { - 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; + return (NMIP4Config *) g_object_new (NM_TYPE_IP4_CONFIG, + NM_IP4_CONFIG_IFINDEX, ifindex, + NULL); } void @@ -200,8 +192,7 @@ nm_ip4_config_capture (int ifindex, gboolean capture_resolv_conf) if (nm_platform_link_get_master (ifindex) > 0) return NULL; - config = nm_ip4_config_new (); - nm_ip4_config_set_ifindex (config, ifindex); + config = nm_ip4_config_new (ifindex); priv = NM_IP4_CONFIG_GET_PRIVATE (config); g_array_unref (priv->addresses); @@ -838,7 +829,7 @@ nm_ip4_config_replace (NMIP4Config *dst, const NMIP4Config *src, gboolean *relev /* ifindex */ if (src_priv->ifindex != dst_priv->ifindex) { - nm_ip4_config_set_ifindex (dst, src_priv->ifindex); + dst_priv->ifindex = src_priv->ifindex; has_minor_changes = TRUE; } @@ -1878,6 +1869,9 @@ get_property (GObject *object, guint prop_id, NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (object); switch (prop_id) { + case PROP_IFINDEX: + g_value_set_int (value, priv->ifindex); + break; case PROP_ADDRESS_DATA: { GPtrArray *addresses = g_ptr_array_new (); @@ -2028,6 +2022,24 @@ get_property (GObject *object, guint prop_id, } static void +set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) +{ + NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (object); + + switch (prop_id) { + case PROP_IFINDEX: + priv->ifindex = g_value_get_int (value); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void nm_ip4_config_class_init (NMIP4ConfigClass *config_class) { GObjectClass *object_class = G_OBJECT_CLASS (config_class); @@ -2035,8 +2047,15 @@ nm_ip4_config_class_init (NMIP4ConfigClass *config_class) g_type_class_add_private (config_class, sizeof (NMIP4ConfigPrivate)); object_class->get_property = get_property; + object_class->set_property = set_property; object_class->finalize = finalize; + obj_properties[PROP_IFINDEX] = + g_param_spec_int (NM_IP4_CONFIG_IFINDEX, "", "", + -1, G_MAXINT, -1, + G_PARAM_READWRITE | + G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_STRINGS); obj_properties[PROP_ADDRESS_DATA] = g_param_spec_boxed (NM_IP4_CONFIG_ADDRESS_DATA, "", "", DBUS_TYPE_NM_IP_ADDRESSES, diff --git a/src/nm-ip4-config.h b/src/nm-ip4-config.h index d2a1c1ffca..b7443ae61c 100644 --- a/src/nm-ip4-config.h +++ b/src/nm-ip4-config.h @@ -41,6 +41,7 @@ typedef struct { GObjectClass parent; } NMIP4ConfigClass; +#define NM_IP4_CONFIG_IFINDEX "ifindex" #define NM_IP4_CONFIG_ADDRESS_DATA "address-data" #define NM_IP4_CONFIG_ROUTE_DATA "route-data" #define NM_IP4_CONFIG_GATEWAY "gateway" @@ -56,8 +57,7 @@ typedef struct { GType nm_ip4_config_get_type (void); -NMIP4Config * nm_ip4_config_new (void); -void nm_ip4_config_set_ifindex (NMIP4Config *config, int ifindex); +NMIP4Config * nm_ip4_config_new (int ifindex); /* D-Bus integration */ void nm_ip4_config_export (NMIP4Config *config); diff --git a/src/ppp-manager/nm-ppp-manager.c b/src/ppp-manager/nm-ppp-manager.c index c42eeee75a..d5893338fa 100644 --- a/src/ppp-manager/nm-ppp-manager.c +++ b/src/ppp-manager/nm-ppp-manager.c @@ -546,8 +546,7 @@ impl_ppp_manager_set_ip4_config (NMPPPManager *manager, remove_timeout_handler (manager); - config = nm_ip4_config_new (); - nm_ip4_config_set_ifindex (config, nm_platform_link_get_ifindex (priv->ip_iface)); + config = nm_ip4_config_new (nm_platform_link_get_ifindex (priv->ip_iface)); memset (&address, 0, sizeof (address)); address.plen = 32; diff --git a/src/tests/test-ip4-config.c b/src/tests/test-ip4-config.c index be13422063..f355115dbd 100644 --- a/src/tests/test-ip4-config.c +++ b/src/tests/test-ip4-config.c @@ -71,8 +71,7 @@ build_test_config (void) NMPlatformIP4Route route; /* Build up the config to subtract */ - config = nm_ip4_config_new (); - nm_ip4_config_set_ifindex (config, 1); + config = nm_ip4_config_new (1); addr_init (&addr, "192.168.1.10", "1.2.3.4", 24); nm_ip4_config_add_address (config, &addr); @@ -192,10 +191,8 @@ test_compare_with_source (void) NMPlatformIP4Address addr; NMPlatformIP4Route route; - a = nm_ip4_config_new (); - nm_ip4_config_set_ifindex (a, 1); - b = nm_ip4_config_new (); - nm_ip4_config_set_ifindex (b, 2); + a = nm_ip4_config_new (1); + b = nm_ip4_config_new (2); /* Address */ addr_init (&addr, "1.2.3.4", NULL, 24); @@ -227,8 +224,7 @@ test_add_address_with_source (void) NMPlatformIP4Address addr; const NMPlatformIP4Address *test_addr; - a = nm_ip4_config_new (); - nm_ip4_config_set_ifindex (a, 1); + a = nm_ip4_config_new (1); /* Test that a higher priority source is not overwritten */ addr_init (&addr, "1.2.3.4", NULL, 24); @@ -268,8 +264,7 @@ test_add_route_with_source (void) NMPlatformIP4Route route; const NMPlatformIP4Route *test_route; - a = nm_ip4_config_new (); - nm_ip4_config_set_ifindex (a, 1); + a = nm_ip4_config_new (1); /* Test that a higher priority source is not overwritten */ route_new (&route, "1.2.3.4", 24, "1.2.3.1"); diff --git a/src/vpn-manager/nm-vpn-connection.c b/src/vpn-manager/nm-vpn-connection.c index 073527122d..8163644ef3 100644 --- a/src/vpn-manager/nm-vpn-connection.c +++ b/src/vpn-manager/nm-vpn-connection.c @@ -893,10 +893,8 @@ apply_parent_device_config (NMVpnConnection *connection) NMIP4Config *vpn4_parent_config = NULL; NMIP6Config *vpn6_parent_config = NULL; - if (priv->ip4_config) { - vpn4_parent_config = nm_ip4_config_new (); - nm_ip4_config_set_ifindex (vpn4_parent_config, priv->ip_ifindex); - } + if (priv->ip4_config) + vpn4_parent_config = nm_ip4_config_new (priv->ip_ifindex); if (priv->ip6_config) { vpn6_parent_config = nm_ip6_config_new (); nm_ip6_config_set_ifindex (vpn6_parent_config, priv->ip_ifindex); @@ -1194,8 +1192,7 @@ nm_vpn_connection_ip4_config_get (DBusGProxy *proxy, priv->has_ip6 = FALSE; } - config = nm_ip4_config_new (); - nm_ip4_config_set_ifindex (config, priv->ip_ifindex); + config = nm_ip4_config_new (priv->ip_ifindex); memset (&address, 0, sizeof (address)); address.plen = 24; |