wgengine/router: allow loopback traffic from our own IP(s).

Signed-off-by: David Anderson <danderson@tailscale.com>
reviewable/pr373/r3
David Anderson 5 years ago committed by Dave Anderson
parent 64f6104e63
commit cd01bcc395

@ -318,18 +318,30 @@ func (r *linuxRouter) restoreResolvConf() error {
return nil return nil
} }
// addAddress adds an IP/mask to the tunnel interface. Fails if the // addAddress adds an IP/mask to the tunnel interface, and firewall
// address is already assigned to the interface, or if the addition // rules to permit loopback traffic. Fails if the address is already
// fails. // assigned to the interface, or if the addition fails.
func (r *linuxRouter) addAddress(addr netaddr.IPPrefix) error { func (r *linuxRouter) addAddress(addr netaddr.IPPrefix) error {
return cmd("ip", "addr", "add", addr.String(), "dev", r.tunname) if err := cmd("ip", "addr", "add", addr.String(), "dev", r.tunname); err != nil {
return err
}
if err := r.ipt4.Insert("filter", "ts-input", 1, "-i", "lo", "-s", addr.IP.String(), "-j", "ACCEPT"); err != nil {
return err
}
return nil
} }
// delAddress removes an IP/mask from the tunnel interface. Fails if // delAddress removes an IP/mask from the tunnel interface, and
// the address is not assigned to the interface, or if the removal // firewall rules permitting loopback traffic. Fails if the address is
// fails. // not assigned to the interface, or if the removal fails.
func (r *linuxRouter) delAddress(addr netaddr.IPPrefix) error { func (r *linuxRouter) delAddress(addr netaddr.IPPrefix) error {
return cmd("ip", "addr", "del", addr.String(), "dev", r.tunname) if err := r.ipt4.Delete("filter", "ts-input", "-i", "lo", "-s", addr.IP.String(), "-j", "ACCEPT"); err != nil {
return err
}
if err := cmd("ip", "addr", "del", addr.String(), "dev", r.tunname); err != nil {
return err
}
return nil
} }
// normalizeCIDR returns cidr as an ip/mask string, with the host bits // normalizeCIDR returns cidr as an ip/mask string, with the host bits

Loading…
Cancel
Save