mirror of
https://github.com/amnezia-vpn/amneziawg-go.git
synced 2025-04-16 14:06:54 +02:00
tun: openbsd: don't change MTU when it's already the expected size
Allows for running wireguard-go as non-root user. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
parent
9ea9a92117
commit
4d5819183e
1 changed files with 7 additions and 4 deletions
|
@ -173,10 +173,13 @@ func CreateTUNFromFile(file *os.File, mtu int) (Device, error) {
|
|||
|
||||
go tun.routineRouteListener(tunIfindex)
|
||||
|
||||
err = tun.setMTU(mtu)
|
||||
if err != nil {
|
||||
tun.Close()
|
||||
return nil, err
|
||||
currentMTU, err := tun.MTU()
|
||||
if err != nil || currentMTU != mtu {
|
||||
err = tun.setMTU(mtu)
|
||||
if err != nil {
|
||||
tun.Close()
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
return tun, nil
|
||||
|
|
Loading…
Add table
Reference in a new issue