libnm-core: fail verify() for NMSettingVlan for invalid vlan id

Point in case:

    # ip link add link dummy0 name dummy0.vlan type vlan id 4095
    RTNETLINK answers: Numerical result out of range

This potentially causes existing (invalid) connections to disappear
as they now fail verification.

Instead of adjusting the range of the GObject property
NM_SETTING_VLAN_ID, reject it during vlan. This is a bit more
forgiving to an older client that isn't aware of this new restriction,
so he can first set the value without raising a critical warning.
This commit is contained in:
Thomas Haller
2016-01-22 11:23:02 +01:00
parent bd74a9348f
commit 8715d61437
4 changed files with 24 additions and 6 deletions

View File

@@ -2147,10 +2147,9 @@ nm_utils_new_vlan_name (const char *parent_iface, guint32 vlan_id)
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;