}
}
+ if (priv->id >= 4095) {
+ g_set_error (error,
+ NM_CONNECTION_ERROR,
+ NM_CONNECTION_ERROR_INVALID_PROPERTY,
+ _("the vlan id must be in range 0-4094 but is %u"),
+ priv->id);
+ g_prefix_error (error, "%s.%s: ", NM_SETTING_VLAN_SETTING_NAME, NM_SETTING_VLAN_ID);
+ }
+
if (priv->flags & ~NM_VLAN_FLAGS_ALL) {
g_set_error_literal (error,
NM_CONNECTION_ERROR,
* NMSettingVlan:id:
*
* The VLAN identifier that the interface created by this connection should
- * be assigned.
+ * be assigned. The valid range is from 0 to 4094, without the reserved id 4095.
**/
/* ---ifcfg-rh---
* property: id
return FALSE;
}
+ if (priv->id >= 4095) {
+ g_set_error (error,
+ NM_SETTING_VLAN_ERROR,
+ NM_SETTING_VLAN_ERROR_INVALID_PROPERTY,
+ _("the vlan id must be in range 0-4094 but is %u"),
+ priv->id);
+ g_prefix_error (error, "%s.%s: ", NM_SETTING_VLAN_SETTING_NAME, NM_SETTING_VLAN_ID);
+ return FALSE;
+ }
+
/* If interface_name is specified, it must be a valid interface name. We
* don't check that it matches parent and/or id, because we allow
* renaming vlans to arbitrary names.
g_return_val_if_fail (parent_iface && *parent_iface, NULL);
- if (vlan_id < 10) {
- g_return_val_if_fail (vlan_id > 0, NULL);
+ if (vlan_id < 10)
id_len = 2;
- } else if (vlan_id < 100)
+ else if (vlan_id < 100)
id_len = 3;
else if (vlan_id < 1000)
id_len = 4;
gs_free char *vlan_id_s = NULL;
guint vlan_id;
- /* Create a random VLAN id between 1 and 4094 */
- vlan_id = 1 + nmtst_get_rand_int () % 4094;
+ /* Create a random VLAN id between 0 and 4094 */
+ vlan_id = nmtst_get_rand_int () % 4095;
vlan_id_s = g_strdup_printf (".%d", vlan_id);