mirror of
https://git.proxmox.com/git/pve-common
synced 2025-04-28 12:10:17 +00:00
fix #5454: net: check names for vlan bridge slave interfaces
Adds a check for the name of VLAN bridge slave interfaces, which are created on non VLAN-aware bridges. These checks mimics what is done when parsing an interface name in iproute2 [0], which includes a name size check, an empty string check and checking for invalid characters. Without this check, creating a VLAN bridge slave interface, where the length of the string "<iface>.<vlanid>" will be greater than or equal to 16 characters, resulted in the following error message from `ip` itself: > Error: argument "<iface>.<vlanid>" is wrong: "name" not a valid ifname [0] https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/tree/lib/utils.c?h=v6.1.0#n825 Signed-off-by: Daniel Kral <d.kral@proxmox.com>
This commit is contained in:
parent
0219596da2
commit
d67d5b26c3
@ -165,6 +165,22 @@ my $compute_fwbr_names = sub {
|
||||
return ($fwbr, $vethfw, $vethfwpeer, $ovsintport);
|
||||
};
|
||||
|
||||
sub check_iface_name : prototype($) {
|
||||
my ($name) = @_;
|
||||
|
||||
my $name_len = length($name);
|
||||
|
||||
# iproute2 / kernel have a strict interface name size limit
|
||||
die "the interface name $name is too long"
|
||||
if $name_len >= PVE::ProcFSTools::IFNAMSIZ;
|
||||
|
||||
# iproute2 checks with isspace(3), which includes vertical tabs (not catched with perl's '\s')
|
||||
die "the interface name $name is empty or contains invalid characters"
|
||||
if $name_len == 0 || $name =~ /\s|\v|\//;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
sub iface_delete :prototype($) {
|
||||
my ($iface) = @_;
|
||||
run_command(['/sbin/ip', 'link', 'delete', 'dev', $iface], noerr => 1)
|
||||
@ -561,6 +577,8 @@ sub activate_bridge_vlan_slave {
|
||||
# create vlan on $iface is not already exist
|
||||
if (! -d "/sys/class/net/$ifacevlan") {
|
||||
eval {
|
||||
check_iface_name($ifacevlan);
|
||||
|
||||
my $cmd = ['/sbin/ip', 'link', 'add'];
|
||||
push @$cmd, 'link', $iface;
|
||||
push @$cmd, 'name', $ifacevlan;
|
||||
|
Loading…
Reference in New Issue
Block a user