Change-Id: I118f1f3822ac7a6511b73ec03bb984f8e75ad307
This commit is contained in:
Mazdak Nasab committed 2026-11-25 10:27:51 -07:00
1 parent eb74770fec
commit da7d1bbdb9
3 files changed
+23 -9

No files matched your search

+7 -4
View File
@@ -67,10 +67,13 @@ func TestGetActiveState(t *testing.T) {
netip.MustParseAddr("11.0.0.1"): {
// A mapping whose grant restricts the protocols and ports it
// may carry; the others were granted nothing and carry none.
netip.MustParseAddr("169.254.0.5"): {app: "zapp", addr: netip.MustParseAddr("10.0.0.5"), ports: views.SliceOf([]tailcfg.ProtoPortRange{
{Proto: int(ipproto.TCP), Ports: tailcfg.PortRange{First: 443, Last: 443}},
{Ports: tailcfg.PortRangeAny},
})},
netip.MustParseAddr("169.254.0.5"): {
app: "zapp", addr: netip.MustParseAddr("10.0.0.5"),
ports: views.SliceOf([]tailcfg.ProtoPortRange{
{Proto: int(ipproto.TCP), Ports: tailcfg.PortRange{First: 443, Last: 443}},
{Ports: tailcfg.PortRangeAny},
}),
},
netip.MustParseAddr("169.254.0.6"): {app: "app1", addr: netip.MustParseAddr("10.0.0.6")},
},
}
+11 -4
View File
@@ -22,14 +22,18 @@ type appAddr struct {
app string
addr netip.Addr
// ports are the protocol and port combinations the peer was permitted to
// reach through app at the moment it registered this mapping. See
// [appProtoPortRanges] for where they come from, and
// [connector.ingressAllow] for how they are enforced.
// reach through app at the moment it registered this mapping.
ports views.Slice[tailcfg.ProtoPortRange]
expiryEntry *list.Element
}
func (c *connector) handleTransitIPRequest(n tailcfg.NodeView, peerV4 netip.Addr, peerV6 netip.Addr, tipr TransitIPRequest, ports views.Slice[tailcfg.ProtoPortRange]) TransitIPResponse {
func (c *connector) handleTransitIPRequest(
n tailcfg.NodeView,
peerV4 netip.Addr,
peerV6 netip.Addr,
tipr TransitIPRequest,
ports views.Slice[tailcfg.ProtoPortRange],
) TransitIPResponse {
if tipr.TransitIP.Is4() != tipr.DestinationIP.Is4() {
c.logf("[Unexpected] peer attempt to map a transit IP to dest IP did not have matching families: node: %s, tIPv4: %v dIPv4: %v",
n.StableID(), tipr.TransitIP.Is4(), tipr.DestinationIP.Is4())
@@ -161,6 +165,9 @@ func (c *connector) destinationInPools(dst netip.Addr) bool {
// conn25 allocates transit IPs out of link-local space, so a packet addressed
// to one has to get past that check; whether the peer may actually reach it is
// decided by [connector.ingressAllow].
// linkLocalAllow returns true if the provided packet has a Dst that is in
// the configured transit IP range for this connector, false otherwise.
func (c *connector) linkLocalAllow(p packet.Parsed) (bool, string) {
if c.transitIPInPool(p.Dst.Addr()) {
return true, connectorTransitIPReason
+5 -1
View File
@@ -47,7 +47,11 @@ const (
// comes back as an empty slice with hasCap true: the app stays resolvable and
// registrable, which keeps the misconfiguration diagnosable, but
// [connector.ingressAllow] lets nothing through.
func appProtoPortRanges(peerCaps tailcfg.PeerCapMap, app string) (ranges views.Slice[tailcfg.ProtoPortRange], hasCap bool, err error) {
func appProtoPortRanges(peerCaps tailcfg.PeerCapMap, app string) (
ranges views.Slice[tailcfg.ProtoPortRange],
hasCap bool,
err error,
) {
cap := peercap.Conn25Prefix.ToAttribute(app)
if !peerCaps.HasCapability(cap) {
return ranges, false, nil