From da7d1bbdb95903df0ce26b86aaf2867af6a4c9a5 Mon Sep 17 00:00:00 2001 From: Mazdak Nasab Date: Wed, 25 Nov 2026 10:27:51 -0700 Subject: [PATCH] update Change-Id: I118f1f3822ac7a6511b73ec03bb984f8e75ad307 --- feature/conn25/api_test.go | 11 +++++++---- feature/conn25/connector.go | 15 +++++++++++---- feature/conn25/filter.go | 6 +++++- 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/feature/conn25/api_test.go b/feature/conn25/api_test.go index c96946be4..29e127deb 100644 --- a/feature/conn25/api_test.go +++ b/feature/conn25/api_test.go @@ -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")}, }, } diff --git a/feature/conn25/connector.go b/feature/conn25/connector.go index 6f89220d9..43381f7b3 100644 --- a/feature/conn25/connector.go +++ b/feature/conn25/connector.go @@ -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 diff --git a/feature/conn25/filter.go b/feature/conn25/filter.go index fd8a11fc2..4bf241767 100644 --- a/feature/conn25/filter.go +++ b/feature/conn25/filter.go @@ -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