Page MenuHomeVyOS Platform

wireguard checks if port already binding
Open, Requires assessmentPublicBUG

Description

As I understand there are should be checks if the port is already used by any process.
To reproduce in 1.3:

set interfaces wireguard wg0 address 10.77.77.1/24
set interfaces wireguard wg0 description 'VPN-to-wg-PEER01-192.168.122.11'
set interfaces wireguard wg0 peer PEER01 allowed-ips 10.22.1.0/24
set interfaces wireguard wg0 peer PEER01 address 192.168.122.11
set interfaces wireguard wg0 peer PEER01 port 54321
set interfaces wireguard wg0 peer PEER01 pubkey 'l+U1Rz38RW11ClMYYtXqEneRNu3oLn2yvI5B+jBESyY='
set interfaces wireguard wg0 port 12345

set interfaces wireguard wg1 address 10.88.88.1/24
set interfaces wireguard wg1 description 'VPN-to-wg-PEER02-192.168.122.12'
set interfaces wireguard wg1 peer PEER02 allowed-ips 10.33.3.0/24
set interfaces wireguard wg1 peer PEER02 address 192.168.122.12
set interfaces wireguard wg1 peer PEER02 port 55555
set interfaces wireguard wg1 peer PEER02 pubkey 'l+U1Rz38RW11ClMYYtXqEneRNu3oLn2yvI5B+jBESyY='
set interfaces wireguard wg1 port 12345

Commit

vyos@r4-1.3# commit
[ interfaces wireguard wg1 ]
VyOS had an issue completing a command.

Report Time:      2021-08-18 13:02:15
Image Version:    VyOS 1.3-beta-202108151336
Release Train:    equuleus

Built by:         autobuild@vyos.net
Built on:         Mon 16 Aug 2021 03:42 UTC
Build UUID:       9b63bb49-29c8-421e-ba25-72b83600d513
Build Commit ID:  bc4c54605b5c2c

Architecture:     x86_64
Boot via:         installed image
System type:      KVM guest

Hardware vendor:  QEMU
Hardware model:   Standard PC (Q35 + ICH9, 2009)
Hardware S/N:     
Hardware UUID:    710e3d5f-968a-4d51-a408-5167c8cdd1f6

Traceback (most recent call last):
  File "/usr/libexec/vyos/conf_mode/interfaces-wireguard.py", line 108, in <module>
    apply(c)
  File "/usr/libexec/vyos/conf_mode/interfaces-wireguard.py", line 100, in apply
    tmp.update(wireguard)
  File "/usr/lib/python3/dist-packages/vyos/ifconfig/wireguard.py", line 253, in update
    super().update(config)
  File "/usr/lib/python3/dist-packages/vyos/ifconfig/interface.py", line 1263, in update
    self.set_admin_state(state)
  File "/usr/lib/python3/dist-packages/vyos/ifconfig/interface.py", line 670, in set_admin_state
    return self.set_interface('admin_state', state)
  File "/usr/lib/python3/dist-packages/vyos/ifconfig/control.py", line 184, in set_interface
    return self._set_command(self.config, name, value)
  File "/usr/lib/python3/dist-packages/vyos/ifconfig/control.py", line 109, in _set_command
    return self._command_set[name].get('format', lambda _: _)(self._cmd(cmd))
  File "/usr/lib/python3/dist-packages/vyos/ifconfig/control.py", line 51, in _cmd
    return cmd(command, self.debug)
  File "/usr/lib/python3/dist-packages/vyos/util.py", line 161, in cmd
    raise OSError(code, feedback)
FileNotFoundError: [Errno 2] failed to run command: ip link set dev wg1 up
returned: 
exit code: 2

noteworthy:
cmd 'ip link set dev wg1 up'
returned (out):

returned (err):
RTNETLINK answers: Address already in use

[[interfaces wireguard wg1]] failed
Commit failed
[edit]
vyos@r4-1.3#

To reproduce in 1.4:

set interfaces wireguard wg0 address 10.77.77.1/24
set interfaces wireguard wg0 description 'VPN-to-wg-PEER01-192.168.122.11'
set interfaces wireguard wg0 peer PEER01 allowed-ips 10.22.1.0/24
set interfaces wireguard wg0 peer PEER01 address 192.168.122.11
set interfaces wireguard wg0 peer PEER01 port 54321
set interfaces wireguard wg0 peer PEER01 public-key 'l+U1Rz38RW11ClMYYtXqEneRNu3oLn2yvI5B+jBESyY='
set interfaces wireguard wg0 private-key 'IMAGzmcQOHDTN70fyJ04uiWx0+wc/BKPj4aNKYAZRXA='
set interfaces wireguard wg0 port 12345

set interfaces wireguard wg1 address 10.88.88.1/24
set interfaces wireguard wg1 description 'VPN-to-wg-PEER02-192.168.122.12'
set interfaces wireguard wg1 peer PEER02 allowed-ips 10.33.3.0/24
set interfaces wireguard wg1 peer PEER02 address 192.168.122.12
set interfaces wireguard wg1 peer PEER02 port 55555
set interfaces wireguard wg1 peer PEER02 public-key 'l+U1Rz38RW11ClMYYtXqEneRNu3oLn2yvI5B+jBESyY='
set interfaces wireguard wg1 private-key 'IMAGzmcQOHDTN70fyJ04uiWx0+wc/BKPj4aNKYAZRXA='
set interfaces wireguard wg1 port 12345

Commit 1.4:

vyos@r1-roll# commit
[ interfaces wireguard wg1 ]
VyOS had an issue completing a command.

Report Time:      2021-08-18 13:12:53
Image Version:    VyOS 1.4-rolling-202108130117
Release Train:    sagitta

Built by:         autobuild@vyos.net
Built on:         Fri 13 Aug 2021 10:41 UTC
Build UUID:       d80d691e-95b0-4835-be37-d4167b8b1cbf
Build Commit ID:  0f8a2d5e61c739

Architecture:     x86_64
Boot via:         installed image
System type:      KVM guest

Hardware vendor:  QEMU
Hardware model:   Standard PC (Q35 + ICH9, 2009)
Hardware S/N:     
Hardware UUID:    08227416-e73c-46f1-984b-937def82b485

Traceback (most recent call last):
  File "/usr/libexec/vyos/conf_mode/interfaces-wireguard.py", line 104, in <module>
    apply(c)
  File "/usr/libexec/vyos/conf_mode/interfaces-wireguard.py", line 96, in apply
    tmp.update(wireguard)
  File "/usr/lib/python3/dist-packages/vyos/ifconfig/wireguard.py", line 253, in update
    super().update(config)
  File "/usr/lib/python3/dist-packages/vyos/ifconfig/interface.py", line 1316, in update
    self.set_admin_state(state)
  File "/usr/lib/python3/dist-packages/vyos/ifconfig/interface.py", line 693, in set_admin_state
    return self.set_interface('admin_state', state)
  File "/usr/lib/python3/dist-packages/vyos/ifconfig/control.py", line 184, in set_interface
    return self._set_command(self.config, name, value)
  File "/usr/lib/python3/dist-packages/vyos/ifconfig/control.py", line 109, in _set_command
    return self._command_set[name].get('format', lambda _: _)(self._cmd(cmd))
  File "/usr/lib/python3/dist-packages/vyos/ifconfig/control.py", line 51, in _cmd
    return cmd(command, self.debug)
  File "/usr/lib/python3/dist-packages/vyos/util.py", line 161, in cmd
    raise OSError(code, feedback)
FileNotFoundError: [Errno 2] failed to run command: ip link set dev wg1 up
returned: 
exit code: 2

noteworthy:
cmd 'nft -c delete element inet vrf_zones ct_iface_map { "wg1" }'
returned (out):

returned (err):
Error: No such file or directory
delete element inet vrf_zones ct_iface_map { wg1 }
                    ^^^^^^^^^
cmd 'ip link set dev wg1 up'
returned (out):

returned (err):
RTNETLINK answers: Address already in use

[[interfaces wireguard wg1]] failed
Commit failed
[edit]
vyos@r1-roll#

Details

Difficulty level
Normal (likely a few hours)
Version
1.3-beta-202108151336
Why the issue appeared?
Will be filled on close
Is it a breaking change?
Unspecified (possibly destroys the router)