Skip to content

IPv6 NAT table missing in nftables mode (regression in 1.64) #12008

Closed

Description

@irbekrm

What is the issue?

IPv6 NAT table no longer gets created for Linux hosts that support IPv6 running in tun mode with netfilter in nftables mode since 1.64.

One possible side effect (user reported) is that routing to IPv6 targets via exit nodes in tun mode is broken.

Steps to reproduce

Set up a Tailscale client (in the example, running in a container so no pre-existing tables) with firewall in nftables mode, observe that the nat table for ip6 is missing altogether:

Details / # nft list ruleset table ip filter { chain FORWARD { type filter hook forward priority filter; policy accept; counter packets 0 bytes 0 jump ts-forward }
    chain INPUT {
            type filter hook input priority filter; policy accept;
            counter packets 99 bytes 23734 jump ts-input
    }

    chain ts-forward {
            iifname "tailscale0*" counter packets 0 bytes 0 meta mark set meta mark & 0xffff04ff | 0x00000400
            meta mark & 0x0000ff00 == 0x00000400 counter packets 0 bytes 0 accept
            oifname "tailscale0*" ip saddr 100.64.0.0/10 counter packets 0 bytes 0 drop
            oifname "tailscale0*" counter packets 0 bytes 0 accept
    }

    chain ts-input {
            iifname "lo*" ip saddr 100.110.115.23 counter packets 0 bytes 0 accept
            iifname != "tailscale0*" ip saddr 100.115.92.0/23 counter packets 0 bytes 0 return
            iifname != "tailscale0*" ip saddr 100.64.0.0/10 counter packets 0 bytes 0 drop
            iifname "tailscale0*" counter packets 0 bytes 0 accept
            udp dport 41943 counter packets 46 bytes 3312 accept
    }

}
table ip6 filter {
chain FORWARD {
type filter hook forward priority filter; policy accept;
counter packets 0 bytes 0 jump ts-forward
}

    chain INPUT {
            type filter hook input priority filter; policy accept;
            counter packets 215 bytes 2784089 jump ts-input
    }

    chain ts-forward {
            iifname "tailscale0*" counter packets 0 bytes 0 meta mark set meta mark & 0xffff04ff | 0x00000400
            meta mark & 0x0000ff00 == 0x00000400 counter packets 0 bytes 0 accept
            oifname "tailscale0*" counter packets 0 bytes 0 accept
    }

    chain ts-input {
            iifname "lo*" ip6 saddr fd7a:115c:a1e0::df01:7317 counter packets 0 bytes 0 accept
            iifname "tailscale0*" counter packets 0 bytes 0 accept
            udp dport 49489 counter packets 43 bytes 3956 accept
    }

}
table ip nat {
chain POSTROUTING {
type nat hook postrouting priority srcnat; policy accept;
counter packets 58 bytes 7426 jump ts-postrouting
}

    chain ts-postrouting {
            meta mark & 0x0000ff00 == 0x00000400 counter packets 0 bytes 0 masquerade
    }

}

For comparison, on a 1.62 Linux node:
Details / # nft list ruleset table ip filter { chain FORWARD { type filter hook forward priority filter; policy accept; counter packets 0 bytes 0 jump ts-forward }
    chain INPUT {
            type filter hook input priority filter; policy accept;
            counter packets 89 bytes 22796 jump ts-input
    }

    chain ts-forward {
            iifname "tailscale0*" counter packets 0 bytes 0 meta mark set meta mark & 0xffff04ff | 0x00000400
            meta mark & 0x0000ff00 == 0x00000400 counter packets 0 bytes 0 accept
            oifname "tailscale0*" ip saddr 100.64.0.0/10 counter packets 0 bytes 0 drop
            oifname "tailscale0*" counter packets 0 bytes 0 accept
    }

    chain ts-input {
            iifname "lo*" ip saddr 100.110.115.23 counter packets 0 bytes 0 accept
            iifname != "tailscale0*" ip saddr 100.115.92.0/23 counter packets 0 bytes 0 return
            iifname != "tailscale0*" ip saddr 100.64.0.0/10 counter packets 0 bytes 0 drop
            iifname "tailscale0*" counter packets 0 bytes 0 accept
            udp dport 35163 counter packets 43 bytes 3096 accept
    }

}
table ip6 filter {
chain FORWARD {
type filter hook forward priority filter; policy accept;
counter packets 0 bytes 0 jump ts-forward
}

    chain INPUT {
            type filter hook input priority filter; policy accept;
            counter packets 199 bytes 2782509 jump ts-input
    }

    chain ts-forward {
            iifname "tailscale0*" counter packets 0 bytes 0 meta mark set meta mark & 0xffff04ff | 0x00000400
            meta mark & 0x0000ff00 == 0x00000400 counter packets 0 bytes 0 accept
            oifname "tailscale0*" counter packets 0 bytes 0 accept
    }

    chain ts-input {
            iifname "lo*" ip6 saddr fd7a:115c:a1e0::df01:7317 counter packets 0 bytes 0 accept
            iifname "tailscale0*" counter packets 0 bytes 0 accept
            udp dport 56475 counter packets 40 bytes 3680 accept
    }

}
table ip nat {
chain POSTROUTING {
type nat hook postrouting priority srcnat; policy accept;
counter packets 53 bytes 7021 jump ts-postrouting
}

    chain ts-postrouting {
            meta mark & 0x0000ff00 == 0x00000400 counter packets 0 bytes 0 masquerade
    }

}
table ip6 nat {
chain POSTROUTING {
type nat hook postrouting priority srcnat; policy accept;
counter packets 23 bytes 2023 jump ts-postrouting
}

    chain ts-postrouting {
            meta mark & 0x0000ff00 == 0x00000400 counter packets 0 bytes 0 masquerade
    }

}

Are there any recent changes that introduced the issue?

This will have been introduced in #11546, specifically here - I removed setting of nftables.v6NatAvailable field in favour of a new method (that was introduced to fix another issue), but we actually still use it in some places directly, i.e here

We should remove the field and the direct references altogether (see #11353 where we remove logic for the separate IPv6 NAT availability check for nftables)

We should also add tests that can catch issues like this.

Tailscale version

1.64.0

Activity

  1. self-assigned this
    on May 5, 2024
  2. gitlankford commented on May 11, 2024

    @gitlankford

    at first read I was wondering if they just moved to INET family instead of IP family, but I guess not.

  3. irbekrm commented on May 11, 2024

    @irbekrm
    ContributorAuthor

    No, for nftables we need to explicitly create tables, it's missing because we skipped creating it.
    Should be fixed in #12009

  4. irbekrm commented on May 16, 2024

    @irbekrm
    ContributorAuthor

    Fixed in #12009

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions