wgengine: properly clean up freebsd routes and interfaces on close

Signed-off-by: wardn <wardn@users.noreply.github.com>
pull/106/head
wardn 5 years ago committed by David Crawshaw
parent 7a3be96199
commit 9390a3ef55

@ -35,6 +35,7 @@ func (t *fakeTun) File() *os.File {
func (t *fakeTun) Close() error {
close(t.closechan)
close(t.datachan)
close(t.evchan)
return nil
}

@ -55,6 +55,10 @@ func (r *freebsdRouter) Up() error {
}
func (r *freebsdRouter) SetRoutes(rs RouteSettings) error {
if rs.LocalAddr == (wgcfg.CIDR{}) {
return nil
}
var errq error
// Update the address.
@ -139,15 +143,6 @@ func (r *freebsdRouter) SetRoutes(rs RouteSettings) error {
}
func (r *freebsdRouter) Close() error {
out, err := cmd("ifconfig", r.tunname, "down").CombinedOutput()
if err != nil {
r.logf("running ifconfig failed: %v\n%s", err, out)
}
if err := r.restoreResolvConf(); err != nil {
r.logf("failed to restore system resolv.conf: %v", err)
}
return nil
}

@ -564,6 +564,7 @@ func (e *userspaceEngine) Close() {
e.wgdev.IpcSetOperation(r)
e.linkMon.Close()
e.router.Close()
e.wgdev.Close()
e.magicConn.Close()
close(e.waitCh)
}

Loading…
Cancel
Save