From 9a56fa0b3f1cdb109dc9db571f8d076ef4715fa6 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Fri, 22 Jan 2016 11:11:59 +0100 Subject: [PATCH] core: allow VLAN ids between 1 and 4095 nm_utils_new_vlan_name() should reject the reserved VLAN id 4095, and the test case should not test reserved values 0 and 4095. Fixes: 778207f23eb2ac022b2ee47968a484fdb94626fe --- src/NetworkManagerUtils.c | 2 +- src/tests/test-general-with-expect.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/NetworkManagerUtils.c b/src/NetworkManagerUtils.c index 14ed35e139..dd7467c14d 100644 --- a/src/NetworkManagerUtils.c +++ b/src/NetworkManagerUtils.c @@ -2155,7 +2155,7 @@ nm_utils_new_vlan_name (const char *parent_iface, guint32 vlan_id) else if (vlan_id < 1000) id_len = 4; else { - g_return_val_if_fail (vlan_id < 4096, NULL); + g_return_val_if_fail (vlan_id < 4095, NULL); id_len = 5; } diff --git a/src/tests/test-general-with-expect.c b/src/tests/test-general-with-expect.c index 3ec9df41a1..31afd62d2a 100644 --- a/src/tests/test-general-with-expect.c +++ b/src/tests/test-general-with-expect.c @@ -879,7 +879,8 @@ test_nm_utils_new_vlan_name (void) gs_free char *vlan_id_s = NULL; guint vlan_id; - vlan_id = nmtst_get_rand_int () % 4096; + /* Create a random VLAN id between 1 and 4094 */ + vlan_id = 1 + nmtst_get_rand_int () % 4094; vlan_id_s = g_strdup_printf (".%d", vlan_id);