summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2014-11-14 14:44:37 +0100
committerThomas Haller <thaller@redhat.com>2014-11-22 01:07:03 +0100
commit02712f77f6b79e9aca7ceaf18117fe367aa43991 (patch)
treed4ed91d09238bbf20662e68fbe2075331a3cb8da
parentf1fe9f089dd22a1a792e8ddbc66c6260da6cf426 (diff)
downloadNetworkManager-02712f77f6b79e9aca7ceaf18117fe367aa43991.tar.gz
iface-helper: make priority variable guint32th/bgo723178_device_route_metric
Also read the command line argument as G_OPTION_ARG_INT64 type. Otherwise, on 32-bit integers, you could not enter any number larger then G_MAXINT32. Signed-off-by: Thomas Haller <thaller@redhat.com>
-rw-r--r--src/nm-iface-helper.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/nm-iface-helper.c b/src/nm-iface-helper.c
index 61093a023b..4d62c9c0ec 100644
--- a/src/nm-iface-helper.c
+++ b/src/nm-iface-helper.c
@@ -56,7 +56,7 @@ static int ifindex = -1;
static gboolean slaac_required = FALSE;
static gboolean dhcp4_required = FALSE;
static int tempaddr = NM_SETTING_IP6_CONFIG_PRIVACY_UNKNOWN;
-static int priority = -1;
+static guint32 priority;
static void
dhcp4_state_changed (NMDhcpClient *client,
@@ -287,6 +287,7 @@ main (int argc, char *argv[])
size_t hwaddr_len = 0;
gconstpointer tmp;
gs_free NMUtilsIPv6IfaceId *iid = NULL;
+ gint64 priority64 = -1;
GOptionEntry options[] = {
/* Interface/IP config */
@@ -299,7 +300,7 @@ main (int argc, char *argv[])
{ "dhcp4-required", '4', 0, G_OPTION_ARG_NONE, &dhcp4_required, N_("Whether DHCPv4 must be successful"), NULL },
{ "dhcp4-clientid", 'c', 0, G_OPTION_ARG_STRING, &dhcp4_clientid, N_("Hex-encoded DHCPv4 client ID"), NULL },
{ "dhcp4-hostname", 'h', 0, G_OPTION_ARG_STRING, &dhcp4_hostname, N_("Hostname to send to DHCP server"), N_("barbar") },
- { "priority", 'p', 0, G_OPTION_ARG_INT, &priority, N_("Route priority"), N_("10") },
+ { "priority", 'p', 0, G_OPTION_ARG_INT64, &priority64, N_("Route priority"), N_("10") },
{ "iid", 'e', 0, G_OPTION_ARG_STRING, &iid_str, N_("Hex-encoded Interface Identifier"), N_("") },
/* Logging/debugging */
@@ -417,7 +418,7 @@ main (int argc, char *argv[])
iid = g_bytes_unref_to_data (bytes, &ignored);
}
- priority = MAX (0, priority);
+ priority = (guint32) CLAMP (priority64, 0, G_MAXUINT32);
if (dhcp4_address) {
nm_platform_sysctl_set (nm_utils_ip4_property_path (ifname, "promote_secondaries"), "1");