From d149ba688fb16b4c602034f337916eae2781ea26 Mon Sep 17 00:00:00 2001 From: gVisor bot Date: Wed, 4 May 2022 01:03:41 +0800 Subject: [PATCH] fix: wrong parameters --- listener/tun/ipstack/commons/router_linux.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/listener/tun/ipstack/commons/router_linux.go b/listener/tun/ipstack/commons/router_linux.go index 39f4dca7..4a11f99f 100644 --- a/listener/tun/ipstack/commons/router_linux.go +++ b/listener/tun/ipstack/commons/router_linux.go @@ -17,23 +17,24 @@ func ConfigInterfaceAddress(dev device.Device, addr netip.Prefix, forceMTU int, var ( interfaceName = dev.Name() ip = addr.Masked().Addr().Next() - err error ) - if _, err = cmd.ExecCmd(fmt.Sprintf("ip addr add %s dev %s", ip.String(), interfaceName)); err != nil { + if _, err := cmd.ExecCmd(fmt.Sprintf("ip addr add %s dev %s", ip.String(), interfaceName)); err != nil { return err } - if _, err = cmd.ExecCmd(fmt.Sprintf("ip link set %s up", interfaceName)); err != nil { + if _, err := cmd.ExecCmd(fmt.Sprintf("ip link set %s up", interfaceName)); err != nil { return err } - execRouterCmd("add", addr.Masked().String(), interfaceName, ip.String(), "main") + if err := execRouterCmd("add", addr.Masked().String(), interfaceName, ip.String(), "main"); err != nil { + return err + } if autoRoute { - err = configInterfaceRouting(interfaceName, addr, autoDetectInterface) + _ = configInterfaceRouting(interfaceName, addr, autoDetectInterface) } - return err + return nil } func configInterfaceRouting(interfaceName string, addr netip.Prefix, autoDetectInterface bool) error {