From 52345a2de49d47bfad23b5cf45435cd84fd971bc Mon Sep 17 00:00:00 2001 From: Fyodor Ustinov Date: Tue, 21 Sep 2021 23:19:25 +0300 Subject: [PATCH 1/2] Check tun.config is not equal to nil before usage (#830) We have to check tun.config is not nil before first use, not after. --- src/tuntap/tun.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/tuntap/tun.go b/src/tuntap/tun.go index 4caefe4a..eddccbcd 100644 --- a/src/tuntap/tun.go +++ b/src/tuntap/tun.go @@ -114,11 +114,11 @@ func (tun *TunAdapter) _start() error { if tun.isOpen { return errors.New("TUN module is already started") } - tun.config.RLock() - defer tun.config.RUnlock() if tun.config == nil { return errors.New("no configuration available to TUN") } + tun.config.RLock() + defer tun.config.RUnlock() tun.addr = tun.rwc.Address() tun.subnet = tun.rwc.Subnet() addr := fmt.Sprintf("%s/%d", net.IP(tun.addr[:]).String(), 8*len(address.GetPrefix())-1) From 1c7deb72db461ee4c1ec96137b9242fb6acd1837 Mon Sep 17 00:00:00 2001 From: Paul Dee <647633+systemcrash@users.noreply.github.com> Date: Tue, 21 Sep 2021 22:19:40 +0200 Subject: [PATCH 2/2] Align struct elements to byte boundaries: reduce memory footprint. (#834) --- cmd/yggdrasil/main.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/yggdrasil/main.go b/cmd/yggdrasil/main.go index 95d40151..58b8230d 100644 --- a/cmd/yggdrasil/main.go +++ b/cmd/yggdrasil/main.go @@ -185,14 +185,14 @@ func setLogLevel(loglevel string, logger *log.Logger) { type yggArgs struct { genconf bool useconf bool - useconffile string normaliseconf bool confjson bool autoconf bool ver bool - logto string getaddr bool getsnet bool + useconffile string + logto string loglevel string }