summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--tun/tun_openbsd.go11
1 files changed, 7 insertions, 4 deletions
diff --git a/tun/tun_openbsd.go b/tun/tun_openbsd.go
index 1e6191f..bbc0432 100644
--- a/tun/tun_openbsd.go
+++ b/tun/tun_openbsd.go
@@ -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