diff options
author | Thomas Haller <thaller@redhat.com> | 2017-09-28 14:51:14 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2017-10-06 11:13:43 +0200 |
commit | 5afdf6f1de76a6563914ae47eeddf51ea21de203 (patch) | |
tree | 3d65f79988b2f831267ab29d0660f720b7bc0e5b /src/dhcp | |
parent | a4e506ead5215ee736de9f53720a61aaf716a320 (diff) | |
download | NetworkManager-5afdf6f1de76a6563914ae47eeddf51ea21de203.tar.gz |
dhcp/trivial: rename "priority" variables to "route_metric" in DHCP code
The name "priority" is well established for routes (e.g. kernel's
RTA_PRIORITY netlink attribute).
However, we call it at most places "metric" or "route_metric".
Rename it, not to use two different names for the same thing.
Diffstat (limited to 'src/dhcp')
-rw-r--r-- | src/dhcp/nm-dhcp-client.c | 23 | ||||
-rw-r--r-- | src/dhcp/nm-dhcp-client.h | 6 | ||||
-rw-r--r-- | src/dhcp/nm-dhcp-dhclient.c | 2 | ||||
-rw-r--r-- | src/dhcp/nm-dhcp-manager.c | 16 | ||||
-rw-r--r-- | src/dhcp/nm-dhcp-manager.h | 6 | ||||
-rw-r--r-- | src/dhcp/nm-dhcp-systemd.c | 10 | ||||
-rw-r--r-- | src/dhcp/nm-dhcp-utils.c | 25 | ||||
-rw-r--r-- | src/dhcp/nm-dhcp-utils.h | 3 | ||||
-rw-r--r-- | src/dhcp/tests/test-dhcp-utils.c | 4 |
9 files changed, 46 insertions, 49 deletions
diff --git a/src/dhcp/nm-dhcp-client.c b/src/dhcp/nm-dhcp-client.c index afa6b6a731..307108e1c2 100644 --- a/src/dhcp/nm-dhcp-client.c +++ b/src/dhcp/nm-dhcp-client.c @@ -56,7 +56,7 @@ NM_GOBJECT_PROPERTIES_DEFINE_BASE ( PROP_IFINDEX, PROP_HWADDR, PROP_UUID, - PROP_PRIORITY, + PROP_ROUTE_METRIC, PROP_TIMEOUT, ); @@ -73,7 +73,7 @@ typedef struct _NMDhcpClientPrivate { guint watch_id; int addr_family; int ifindex; - guint32 priority; + guint32 route_metric; guint32 timeout; NMDhcpState state; bool info_only:1; @@ -151,11 +151,11 @@ nm_dhcp_client_get_hw_addr (NMDhcpClient *self) } guint32 -nm_dhcp_client_get_priority (NMDhcpClient *self) +nm_dhcp_client_get_route_metric (NMDhcpClient *self) { g_return_val_if_fail (NM_IS_DHCP_CLIENT (self), G_MAXUINT32); - return NM_DHCP_CLIENT_GET_PRIVATE (self)->priority; + return NM_DHCP_CLIENT_GET_PRIVATE (self)->route_metric; } guint32 @@ -789,14 +789,13 @@ nm_dhcp_client_handle_event (gpointer unused, priv->ifindex, priv->iface, str_options, - priv->priority); + priv->route_metric); } else { prefix = nm_dhcp_utils_ip6_prefix_from_options (str_options); ip_config = (GObject *) nm_dhcp_utils_ip6_config_from_options (nm_dhcp_client_get_multi_idx (self), priv->ifindex, priv->iface, str_options, - priv->priority, priv->info_only); } } @@ -851,8 +850,8 @@ get_property (GObject *object, guint prop_id, case PROP_UUID: g_value_set_string (value, priv->uuid); break; - case PROP_PRIORITY: - g_value_set_uint (value, priv->priority); + case PROP_ROUTE_METRIC: + g_value_set_uint (value, priv->route_metric); break; case PROP_TIMEOUT: g_value_set_uint (value, priv->timeout); @@ -900,9 +899,9 @@ set_property (GObject *object, guint prop_id, /* construct-only */ priv->uuid = g_value_dup_string (value); break; - case PROP_PRIORITY: + case PROP_ROUTE_METRIC: /* construct-only */ - priv->priority = g_value_get_uint (value); + priv->route_metric = g_value_get_uint (value); break; case PROP_TIMEOUT: /* construct-only */ @@ -1011,8 +1010,8 @@ nm_dhcp_client_class_init (NMDhcpClientClass *client_class) G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS); - obj_properties[PROP_PRIORITY] = - g_param_spec_uint (NM_DHCP_CLIENT_PRIORITY, "", "", + obj_properties[PROP_ROUTE_METRIC] = + g_param_spec_uint (NM_DHCP_CLIENT_ROUTE_METRIC, "", "", 0, G_MAXUINT32, 0, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS); diff --git a/src/dhcp/nm-dhcp-client.h b/src/dhcp/nm-dhcp-client.h index 91dc2299bd..98f7e4ab5b 100644 --- a/src/dhcp/nm-dhcp-client.h +++ b/src/dhcp/nm-dhcp-client.h @@ -39,7 +39,7 @@ #define NM_DHCP_CLIENT_IFINDEX "ifindex" #define NM_DHCP_CLIENT_HWADDR "hwaddr" #define NM_DHCP_CLIENT_UUID "uuid" -#define NM_DHCP_CLIENT_PRIORITY "priority" +#define NM_DHCP_CLIENT_ROUTE_METRIC "route-metric" #define NM_DHCP_CLIENT_TIMEOUT "timeout" #define NM_DHCP_CLIENT_MULTI_IDX "multi-idx" @@ -122,7 +122,7 @@ const GByteArray *nm_dhcp_client_get_duid (NMDhcpClient *self); const GByteArray *nm_dhcp_client_get_hw_addr (NMDhcpClient *self); -guint32 nm_dhcp_client_get_priority (NMDhcpClient *self); +guint32 nm_dhcp_client_get_route_metric (NMDhcpClient *self); guint32 nm_dhcp_client_get_timeout (NMDhcpClient *self); @@ -185,7 +185,7 @@ typedef struct { const char *iface, int ifindex, const char *uuid, - guint32 default_route_metric); + guint32 route_metric); } NMDhcpClientFactory; extern const NMDhcpClientFactory _nm_dhcp_client_factory_dhclient; diff --git a/src/dhcp/nm-dhcp-dhclient.c b/src/dhcp/nm-dhcp-dhclient.c index f04c1862b7..2143067c1f 100644 --- a/src/dhcp/nm-dhcp-dhclient.c +++ b/src/dhcp/nm-dhcp-dhclient.c @@ -164,7 +164,7 @@ nm_dhcp_dhclient_get_lease_ip_configs (NMDedupMultiIndex *multi_idx, const char *iface, int ifindex, const char *uuid, - guint32 default_route_metric) + guint32 route_metric) { char *contents = NULL; char *leasefile; diff --git a/src/dhcp/nm-dhcp-manager.c b/src/dhcp/nm-dhcp-manager.c index 0ee064285f..9614fb021c 100644 --- a/src/dhcp/nm-dhcp-manager.c +++ b/src/dhcp/nm-dhcp-manager.c @@ -158,7 +158,7 @@ client_start (NMDhcpManager *self, int ifindex, const GByteArray *hwaddr, const char *uuid, - guint32 priority, + guint32 route_metric, const struct in6_addr *ipv6_ll_addr, const char *dhcp_client_id, guint32 timeout, @@ -202,7 +202,7 @@ client_start (NMDhcpManager *self, NM_DHCP_CLIENT_IFINDEX, ifindex, NM_DHCP_CLIENT_HWADDR, hwaddr, NM_DHCP_CLIENT_UUID, uuid, - NM_DHCP_CLIENT_PRIORITY, priority, + NM_DHCP_CLIENT_ROUTE_METRIC, route_metric, NM_DHCP_CLIENT_TIMEOUT, (guint) timeout, NULL); g_hash_table_insert (NM_DHCP_MANAGER_GET_PRIVATE (self)->clients, client, g_object_ref (client)); @@ -229,7 +229,7 @@ nm_dhcp_manager_start_ip4 (NMDhcpManager *self, int ifindex, const GByteArray *hwaddr, const char *uuid, - guint32 priority, + guint32 route_metric, gboolean send_hostname, const char *dhcp_hostname, const char *dhcp_fqdn, @@ -270,7 +270,7 @@ nm_dhcp_manager_start_ip4 (NMDhcpManager *self, } } - return client_start (self, AF_INET, multi_idx, iface, ifindex, hwaddr, uuid, priority, NULL, + return client_start (self, AF_INET, multi_idx, iface, ifindex, hwaddr, uuid, route_metric, NULL, dhcp_client_id, timeout, dhcp_anycast_addr, hostname, use_fqdn, FALSE, 0, last_ip_address, 0); } @@ -284,7 +284,7 @@ nm_dhcp_manager_start_ip6 (NMDhcpManager *self, const GByteArray *hwaddr, const struct in6_addr *ll_addr, const char *uuid, - guint32 priority, + guint32 route_metric, gboolean send_hostname, const char *dhcp_hostname, guint32 timeout, @@ -303,7 +303,7 @@ nm_dhcp_manager_start_ip6 (NMDhcpManager *self, /* Always prefer the explicit dhcp-hostname if given */ hostname = dhcp_hostname ? dhcp_hostname : priv->default_hostname; } - return client_start (self, AF_INET6, multi_idx, iface, ifindex, hwaddr, uuid, priority, + return client_start (self, AF_INET6, multi_idx, iface, ifindex, hwaddr, uuid, route_metric, ll_addr, NULL, timeout, dhcp_anycast_addr, hostname, TRUE, info_only, privacy, NULL, needed_prefixes); } @@ -329,7 +329,7 @@ nm_dhcp_manager_get_lease_ip_configs (NMDhcpManager *self, const char *iface, int ifindex, const char *uuid, - guint32 default_route_metric) + guint32 route_metric) { NMDhcpManagerPrivate *priv; @@ -342,7 +342,7 @@ nm_dhcp_manager_get_lease_ip_configs (NMDhcpManager *self, priv = NM_DHCP_MANAGER_GET_PRIVATE (self); if ( priv->client_factory && priv->client_factory->get_lease_ip_configs) - return priv->client_factory->get_lease_ip_configs (multi_idx, addr_family, iface, ifindex, uuid, default_route_metric); + return priv->client_factory->get_lease_ip_configs (multi_idx, addr_family, iface, ifindex, uuid, route_metric); return NULL; } diff --git a/src/dhcp/nm-dhcp-manager.h b/src/dhcp/nm-dhcp-manager.h index f73ca6892f..57fbd4a7e5 100644 --- a/src/dhcp/nm-dhcp-manager.h +++ b/src/dhcp/nm-dhcp-manager.h @@ -51,7 +51,7 @@ NMDhcpClient * nm_dhcp_manager_start_ip4 (NMDhcpManager *manager, int ifindex, const GByteArray *hwaddr, const char *uuid, - guint32 priority, + guint32 route_metric, gboolean send_hostname, const char *dhcp_hostname, const char *dhcp_fqdn, @@ -67,7 +67,7 @@ NMDhcpClient * nm_dhcp_manager_start_ip6 (NMDhcpManager *manager, const GByteArray *hwaddr, const struct in6_addr *ll_addr, const char *uuid, - guint32 priority, + guint32 route_metric, gboolean send_hostname, const char *dhcp_hostname, guint32 timeout, @@ -82,7 +82,7 @@ GSList * nm_dhcp_manager_get_lease_ip_configs (NMDhcpManager *self, const char *iface, int ifindex, const char *uuid, - guint32 default_route_metric); + guint32 route_metric); /* For testing only */ extern const char* nm_dhcp_helper_path; diff --git a/src/dhcp/nm-dhcp-systemd.c b/src/dhcp/nm-dhcp-systemd.c index 53d4241300..3cf95cec54 100644 --- a/src/dhcp/nm-dhcp-systemd.c +++ b/src/dhcp/nm-dhcp-systemd.c @@ -221,7 +221,7 @@ lease_to_ip4_config (NMDedupMultiIndex *multi_idx, int ifindex, sd_dhcp_lease *lease, GHashTable *options, - guint32 default_priority, + guint32 route_metric, gboolean log_lease, GError **error) { @@ -356,7 +356,7 @@ lease_to_ip4_config (NMDedupMultiIndex *multi_idx, if (route.plen) { route.rt_source = NM_IP_CONFIG_SOURCE_DHCP; - route.metric = default_priority; + route.metric = route_metric; nm_ip4_config_add_route (ip4_config, &route, NULL); s = nm_utils_inet4_ntop (route.network, buf); @@ -440,7 +440,7 @@ nm_dhcp_systemd_get_lease_ip_configs (NMDedupMultiIndex *multi_idx, const char *iface, int ifindex, const char *uuid, - guint32 default_route_metric) + guint32 route_metric) { GSList *leases = NULL; gs_free char *path = NULL; @@ -454,7 +454,7 @@ nm_dhcp_systemd_get_lease_ip_configs (NMDedupMultiIndex *multi_idx, path = get_leasefile_path (addr_family, iface, uuid); r = dhcp_lease_load (&lease, path); if (r == 0 && lease) { - ip4_config = lease_to_ip4_config (multi_idx, iface, ifindex, lease, NULL, default_route_metric, FALSE, NULL); + ip4_config = lease_to_ip4_config (multi_idx, iface, ifindex, lease, NULL, route_metric, FALSE, NULL); if (ip4_config) leases = g_slist_append (leases, ip4_config); sd_dhcp_lease_unref (lease); @@ -513,7 +513,7 @@ bound4_handle (NMDhcpSystemd *self) nm_dhcp_client_get_ifindex (NM_DHCP_CLIENT (self)), lease, options, - nm_dhcp_client_get_priority (NM_DHCP_CLIENT (self)), + nm_dhcp_client_get_route_metric (NM_DHCP_CLIENT (self)), TRUE, &error); if (ip4_config) { diff --git a/src/dhcp/nm-dhcp-utils.c b/src/dhcp/nm-dhcp-utils.c index 8eb980c4b9..7c5f1b9784 100644 --- a/src/dhcp/nm-dhcp-utils.c +++ b/src/dhcp/nm-dhcp-utils.c @@ -38,7 +38,7 @@ static gboolean ip4_process_dhcpcd_rfc3442_routes (const char *iface, const char *str, - guint32 priority, + guint32 route_metric, NMIP4Config *ip4_config, guint32 *gwaddr) { @@ -90,7 +90,7 @@ ip4_process_dhcpcd_rfc3442_routes (const char *iface, route.plen = rt_cidr; route.gateway = rt_route; route.rt_source = NM_IP_CONFIG_SOURCE_DHCP; - route.metric = priority; + route.metric = route_metric; nm_ip4_config_add_route (ip4_config, &route, NULL); } } @@ -166,7 +166,7 @@ error: static gboolean ip4_process_dhclient_rfc3442_routes (const char *iface, const char *str, - guint32 priority, + guint32 route_metric, NMIP4Config *ip4_config, guint32 *gwaddr) { @@ -198,7 +198,7 @@ ip4_process_dhclient_rfc3442_routes (const char *iface, /* normal route */ route.rt_source = NM_IP_CONFIG_SOURCE_DHCP; - route.metric = priority; + route.metric = route_metric; nm_ip4_config_add_route (ip4_config, &route, NULL); _LOG2I (LOGD_DHCP4, iface, " classless static route %s/%d gw %s", @@ -215,7 +215,7 @@ out: static gboolean ip4_process_classless_routes (const char *iface, GHashTable *options, - guint32 priority, + guint32 route_metric, NMIP4Config *ip4_config, guint32 *gwaddr) { @@ -271,16 +271,16 @@ ip4_process_classless_routes (const char *iface, if (strchr (str, '/')) { /* dhcpcd format */ - return ip4_process_dhcpcd_rfc3442_routes (iface, str, priority, ip4_config, gwaddr); + return ip4_process_dhcpcd_rfc3442_routes (iface, str, route_metric, ip4_config, gwaddr); } - return ip4_process_dhclient_rfc3442_routes (iface, str, priority, ip4_config, gwaddr); + return ip4_process_dhclient_rfc3442_routes (iface, str, route_metric, ip4_config, gwaddr); } static void process_classful_routes (const char *iface, GHashTable *options, - guint32 priority, + guint32 route_metric, NMIP4Config *ip4_config) { const char *str; @@ -324,7 +324,7 @@ process_classful_routes (const char *iface, } route.gateway = rt_route; route.rt_source = NM_IP_CONFIG_SOURCE_DHCP; - route.metric = priority; + route.metric = route_metric; route.network = nm_utils_ip4_address_clear_host_address (route.network, route.plen); @@ -390,7 +390,7 @@ nm_dhcp_utils_ip4_config_from_options (NMDedupMultiIndex *multi_idx, int ifindex, const char *iface, GHashTable *options, - guint32 priority) + guint32 route_metric) { NMIP4Config *ip4_config = NULL; guint32 tmp_addr; @@ -426,8 +426,8 @@ nm_dhcp_utils_ip4_config_from_options (NMDedupMultiIndex *multi_idx, /* Routes: if the server returns classless static routes, we MUST ignore * the 'static_routes' option. */ - if (!ip4_process_classless_routes (iface, options, priority, ip4_config, &gwaddr)) - process_classful_routes (iface, options, priority, ip4_config); + if (!ip4_process_classless_routes (iface, options, route_metric, ip4_config, &gwaddr)) + process_classful_routes (iface, options, route_metric, ip4_config); if (gwaddr) { _LOG2I (LOGD_DHCP4, iface, " gateway %s", nm_utils_inet4_ntop (gwaddr, NULL)); @@ -624,7 +624,6 @@ nm_dhcp_utils_ip6_config_from_options (NMDedupMultiIndex *multi_idx, int ifindex, const char *iface, GHashTable *options, - guint32 priority, gboolean info_only) { NMIP6Config *ip6_config = NULL; diff --git a/src/dhcp/nm-dhcp-utils.h b/src/dhcp/nm-dhcp-utils.h index 3cd0dbc405..b2757ed27c 100644 --- a/src/dhcp/nm-dhcp-utils.h +++ b/src/dhcp/nm-dhcp-utils.h @@ -28,13 +28,12 @@ NMIP4Config *nm_dhcp_utils_ip4_config_from_options (struct _NMDedupMultiIndex *m int ifindex, const char *iface, GHashTable *options, - guint priority); + guint32 route_metric); NMIP6Config *nm_dhcp_utils_ip6_config_from_options (struct _NMDedupMultiIndex *multi_idx, int ifindex, const char *iface, GHashTable *options, - guint priority, gboolean info_only); NMPlatformIP6Address nm_dhcp_utils_ip6_prefix_from_options (GHashTable *options); diff --git a/src/dhcp/tests/test-dhcp-utils.c b/src/dhcp/tests/test-dhcp-utils.c index a03c684fa2..907fb5d892 100644 --- a/src/dhcp/tests/test-dhcp-utils.c +++ b/src/dhcp/tests/test-dhcp-utils.c @@ -35,12 +35,12 @@ static NMIP4Config * _ip4_config_from_options (int ifindex, const char *iface, GHashTable *options, - guint32 priority) + guint32 route_metric) { nm_auto_unref_dedup_multi_index NMDedupMultiIndex *multi_idx = nm_dedup_multi_index_new (); NMIP4Config *config; - config = nm_dhcp_utils_ip4_config_from_options (multi_idx, ifindex, iface, options, priority); + config = nm_dhcp_utils_ip4_config_from_options (multi_idx, ifindex, iface, options, route_metric); g_assert (config); return config; } |