mirror of
https://git.hardenedbsd.org/hardenedbsd/HardenedBSD.git
synced 2024-12-18 05:53:36 +01:00
ifconfig: fix vlan/vlanproto reconfiguration
The setvlantag() and setvlanproto() functions are used in two scenarios: when we create a new vlan interface and when we update an existing interface. These are distinguished by the getvlan() at the end of the functions. If this fails we assume that is because the interface doesn't exist (so we're creating a new one). We only update the 'params' struct, and expect the settings to be applied when we vlan_create(). However, if we're updating an existing interface we do not retrieve the current settings, and can end up invalidating settings. Fix this by using the settings we retrieved while checking which scenario we're in. Note that we do not address this for setvlandev(), because if_vlan does not allow the vlan parent device to be changed without disassociating it first (with ifconfig vlanX -vlandev). Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D35848
This commit is contained in:
parent
663f556b03
commit
b82b8055ad
@ -204,8 +204,11 @@ DECL_CMD_FUNC(setvlantag, val, d)
|
||||
if (params.vlr_tag != ul)
|
||||
errx(1, "value for vlan out of range");
|
||||
|
||||
if (getvlan(s, &ifr, &vreq) != -1)
|
||||
if (getvlan(s, &ifr, &vreq) != -1) {
|
||||
vreq.vlr_tag = params.vlr_tag;
|
||||
memcpy(¶ms, &vreq, sizeof(params));
|
||||
vlan_set(s, &ifr);
|
||||
}
|
||||
}
|
||||
|
||||
static
|
||||
@ -233,8 +236,11 @@ DECL_CMD_FUNC(setvlanproto, val, d)
|
||||
} else
|
||||
errx(1, "invalid value for vlanproto");
|
||||
|
||||
if (getvlan(s, &ifr, &vreq) != -1)
|
||||
if (getvlan(s, &ifr, &vreq) != -1) {
|
||||
vreq.vlr_proto = params.vlr_proto;
|
||||
memcpy(¶ms, &vreq, sizeof(params));
|
||||
vlan_set(s, &ifr);
|
||||
}
|
||||
}
|
||||
|
||||
static
|
||||
|
Loading…
Reference in New Issue
Block a user