Repository navigation
wgengine/router,util/linuxfw: don't attempt to configure IPv6 firewall rules with ip6tables that don't support filter table - #11546
Merged
Merged
Conversation
irbekrm
marked this pull request as draft
March 28, 2024 14:58
irbekrm
force-pushed
the
irbekrm/router
branch
3 times, most recently
from
March 28, 2024 18:02
aa59e43 to
b2501b2
Compare
irbekrm
marked this pull request as ready for review
March 28, 2024 18:45
raggi
reviewed
Mar 28, 2024
| ipt6 := newFakeIPTables() | ||
|
|
||
| iptr := &iptablesRunner{ipt4, ipt6, true, true} | ||
| iptr := &iptablesRunner{ipt4, ipt6, true, true, true} |
Member
There was a problem hiding this comment.
could you add field labels to this constructor? it probably needed them before but 3 bools is definitely getting to a lot
raggi
reviewed
Mar 28, 2024
| for cidr := range r.addrs { | ||
| if err := r.addLoopbackRule(cidr.Addr()); err != nil { | ||
| return err | ||
| return fmt.Errorf("error adding loopback rule: %v", err) |
Member
There was a problem hiding this comment.
%w rather than %v when wrapping, then errors.Is and friends work
…tial iptables mode We have hosts that support IPv6, but not IPv6 firewall configuration in iptables mode. We also have hosts that have some support for IPv6 firewall configuration in iptables mode, but do not have iptables filter table. We should: - configure ip rules for all hosts that support IPv6 - only configure firewall rules in iptables mode if the host has iptables filter table. Updates #11540 Signed-off-by: Irbe Krumina <[email protected]>
raggi
approved these changes
Mar 28, 2024
This was referenced Mar 29, 2024
chen8945
pushed a commit
to Ckid-Home/tailscale
that referenced
this pull request
Jul 31, 2024
…tial iptables mode (tailscale#11546) We have hosts that support IPv6, but not IPv6 firewall configuration in iptables mode. We also have hosts that have some support for IPv6 firewall configuration in iptables mode, but do not have iptables filter table. We should: - configure ip rules for all hosts that support IPv6 - only configure firewall rules in iptables mode if the host has iptables filter table. Updates tailscale#11540 Signed-off-by: Irbe Krumina <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
However, netfilter can also be off during a regular Linux client router setup, so this resulted in a buggy sequence:
UpdateMagicSockPortruns with port for IPv6 and because netfilter is off + our changed logic, it determines thatlinuxRouter.magicsockPortv6needs to be set (here)linuxRouter.setNetfilterModeruns with a netfilter mode change false -> true, so we hit this path and becauselinuxRouter.magicsockPortv6is still set and we use the current netfilter mode (off) in the IPv6 availability check, we end up attempting to set the IPv6 firewall rules, error out and the rest of the router config remains unset, resulting in a broken clientThis PR attempts to ensure that:
I have tested this with an IPv4 host (container) with no IPv6 filter table support:
Details
/ # env | grep TS_DEBUG_FIREWALL TS_DEBUG_FIREWALL_MODE=iptables / # ip -6 rule list 0: from all lookup local 5210: from all fwmark 0x80000/0xff0000 lookup main 5230: from all fwmark 0x80000/0xff0000 lookup default 5250: from all fwmark 0x80000/0xff0000 unreachable 5270: from all lookup 52 32766: from all lookup main / # ip6tables -t filter -L modprobe: can't change directory to '/lib/modules': No such file or directory ip6tables v1.8.9 (legacy): can't initialize ip6tables table `filter': Table does not exist (do you need to insmod?) Perhaps ip6tables or your kernel needs to be upgraded.Details
... boot: 2024/03/28 19:09:27 [v1] kernel supports IPv6 policy routing (found 6 rules) boot: 2024/03/28 19:09:27 ip6tables filtering is not supported on this host: running [/sbin/ip6tables -t filter -S --wait]: exit status 3: modprobe: can't change directory to '/lib/modules': No such file or directory ip6tables v1.8.9 (legacy): can't initialize ip6tables table `filter': Table does not exist (do you need to insmod?) Perhaps ip6tables or your kernel needs to be upgraded. boot: 2024/03/28 19:09:27 v6 = true, v6filter = false, v6nat = false ...I have also tested it on an IPv6 host (container) with firewall in iptables mode:
Details
# env | grep TS_DEBUG_FIRE TS_DEBUG_FIREWALL_MODE=iptables / # ip -6 rule list 0: from all lookup local 5210: from all fwmark 0x80000/0xff0000 lookup main 5230: from all fwmark 0x80000/0xff0000 lookup default 5250: from all fwmark 0x80000/0xff0000 unreachable 5270: from all lookup 52 32766: from all lookup main / # ip6tables -t filter -L Chain INPUT (policy ACCEPT) target prot opt source destination ts-input all -- anywhere anywhereChain FORWARD (policy ACCEPT)
target prot opt source destination
ts-forward all -- anywhere anywhere
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
Chain ts-forward (1 references)
target prot opt source destination
MARK all -- anywhere anywhere MARK xset 0x40000/0xff0000
ACCEPT all -- anywhere anywhere mark match 0x40000/0xff0000
ACCEPT all -- anywhere anywhere
Chain ts-input (1 references)
target prot opt source destination
ACCEPT all -- fd7a:115c:a1e0::8f01:5e37 anywhere
ACCEPT all -- anywhere anywhere
ACCEPT udp -- anywhere anywhere udp dpt:53101
Details
... boot: 2024/03/28 19:51:09 [v1] kernel supports IPv6 policy routing (found 6 rules) 2024/03/28 19:51:09 magicsock: derp-8 connected; connGen=1 2024/03/28 19:51:09 health("overall"): ok boot: 2024/03/28 19:51:09 v6 = true, v6filter = true, v6nat = true ...When/if it merges, we'd still have to test with Synology.
Updates #11540