Skip to content

Commit

Permalink
ignore linux error: File exists while add same route twice
Browse files Browse the repository at this point in the history
  • Loading branch information
wencaiwulue authored and ginuerzh committed Aug 22, 2021
1 parent a4695ec commit 8f08304
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion tuntap_linux.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package gost

import (
"errors"
"fmt"
"net"
"syscall"

"github.com/docker/libcontainer/netlink"
"github.com/go-log/log"
Expand Down Expand Up @@ -149,7 +151,7 @@ func addTunRoutes(ifName string, routes ...IPRoute) error {
}
cmd := fmt.Sprintf("ip route add %s dev %s", route.Dest.String(), ifName)
log.Logf("[tun] %s", cmd)
if err := netlink.AddRoute(route.Dest.String(), "", "", ifName); err != nil {
if err := netlink.AddRoute(route.Dest.String(), "", "", ifName); err != nil && !errors.Is(err, syscall.EEXIST) {
return fmt.Errorf("%s: %v", cmd, err)
}
}
Expand Down

0 comments on commit 8f08304

Please sign in to comment.