29 Commits

Author SHA1 Message Date
M. J. Fromberger
eca10c0c19 appc: check events in TestUpdateRoutesDeadlock
Change-Id: I13a63e0cbb31bc4ffa00ccc47d5434b7d7b019dd
2025-09-19 07:57:08 -07:00
M. J. Fromberger
fde7e17263 appc: check events in TestUpdateWildcardRouteRemoval
Change-Id: I844663f129a91c0fb03aaac9595362553482da4d
2025-09-19 07:57:08 -07:00
M. J. Fromberger
6fee65ce26 appc: check events in TestUpdateDomainRouteRemoval
Change-Id: I013a9673b178e036816458882d589608d7739b18
2025-09-19 07:57:08 -07:00
M. J. Fromberger
896fa3eeb5 appc: check events in TestUpdateRouteRouteRemoval
Change-Id: I31b4541c4c362052e39be5a087fed76bf7c0629f
2025-09-19 07:57:08 -07:00
M. J. Fromberger
1b1c347fc0 appc: check events in TestWildcardDomains
Change-Id: Ic570f49603d83be534a1beec91ba8b98d3c223fd
2025-09-19 07:57:08 -07:00
M. J. Fromberger
b846167f0d appc: check events in TestObserveDNSResponse
Change-Id: I15707a7bcb96ef47b1dbc8febf5e2dca50feef3c
2025-09-19 07:57:08 -07:00
M. J. Fromberger
ae36f9f8b7 appc: check events in TestDomainUpdates
Change-Id: Id223e2cdba129519b987626d4e5fa3c3187288ee
2025-09-19 07:57:08 -07:00
M. J. Fromberger
1dc7a3b414 appc: check events in TestUpdateRoutes
Change-Id: I68b66694a2a3233ff15ddb2dcb84679447f609d4
2025-09-19 07:57:08 -07:00
M. J. Fromberger
3473488e05 appc: remove the store routes callback
Route storage is now handled by the event bus. We also used the presence of the
callback as a flag to determine whether the connector had persisted control
routes for filtering purposes, so separate that out.

Change-Id: I37b78a8499c749c94480593afe981ef189dc299d
2025-09-19 07:57:08 -07:00
M. J. Fromberger
ccbf115875 appc: publish events for route updates and storage
Nothing subscribes to them yet, and we need tests.

Add a Close method to the AppConnector to make sure the client gets cleaned up
when the connector is dropped (we re-create connectors).

Change-Id: I184670ba2fb920e0d2cb2be7c6816259bca77afe
2025-09-19 07:57:08 -07:00
M. J. Fromberger
c563c3a8ef appc: add a required event bus to the AppConnector type
This commit requires the presence of the bus, but does not use it yet.  Check
for required fields and update tests and production use to plumb the necessary
arguments.

Change-Id: I8cefd2fdb314ca9945317d3320bd5ea6a92e8dcb
2025-09-19 07:57:08 -07:00
M. J. Fromberger
b344d3592f appc: factor app connector arguments into a Config type
Replace the positional arguments to NewAppConnector with a Config struct.
Update the existing uses. Other than the API change, there are no functional
changes in this commit.

Change-Id: Ibf37f021372155a4db8aaf738f4b4f2c746bf623
2025-09-19 07:57:08 -07:00
Andrew Lytvynov
ec5f04b274
appc: fix a deadlock in route advertisements (#15031)
`routeAdvertiser` is the `iplocal.LocalBackend`. Calls to
`Advertise/UnadvertiseRoute` end up calling `EditPrefs` which in turn
calls `authReconfig` which finally calls `readvertiseAppConnectorRoutes`
which calls `AppConnector.DomainRoutes` and gets stuck on a mutex that
was already held when `routeAdvertiser` was called.

Make all calls to `routeAdvertiser` in `app.AppConnector` go through the
execqueue instead as a short-term fix.

Updates tailscale/corp#25965

Signed-off-by: Andrew Lytvynov <awly@tailscale.com>
Co-authored-by: Irbe Krumina <irbe@tailscale.com>
2025-02-18 11:31:14 -08:00
Andrew Lytvynov
f1710f4a42
appc,ipn/ipnlocal: log DNS parsing errors in app connectors (#14607)
If we fail to parse the upstream DNS response in an app connector, we
might miss new IPs for the target domain. Log parsing errors to be able
to diagnose that.

Updates #14606

Signed-off-by: Andrew Lytvynov <awly@tailscale.com>
2025-01-23 09:03:56 -08:00
Brad Fitzpatrick
1e2e319e7d util/slicesx: add MapKeys and MapValues from golang.org/x/exp/maps
Importing the ~deprecated golang.org/x/exp/maps as "xmaps" to not
shadow the std "maps" was getting ugly.

And using slices.Collect on an iterator is verbose & allocates more.

So copy (x)maps.Keys+Values into our slicesx package instead.

Updates #cleanup
Updates #12912
Updates #14514 (pulled out of that change)

Change-Id: I5e68d12729934de93cf4a9cd87c367645f86123a
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2025-01-03 10:48:31 -08:00
Fran Bull
380a3a0834 appc: track metrics for route info storing
Track how often we're writing state and how many routes we're writing.

Updates #11008

Signed-off-by: Fran Bull <fran@tailscale.com>
2024-07-12 10:39:48 -07:00
Fran Bull
ba46495e11 appc: log how many routes are being written
So that we can debug customer problems more easily.

Updates #11008

Signed-off-by: Fran Bull <fran@tailscale.com>
2024-06-07 12:04:43 -07:00
Fran Bull
e06862b8d8 appc: log how often routeInfo is stored
So that we have some debugging info if users have trouble with storing
the routeInfo.

Updates #11008

Signed-off-by: Fran Bull <fran@tailscale.com>
2024-06-03 09:03:17 -07:00
Fran Bull
c27dc1ca31 appc: unadvertise routes when reconfiguring app connector
If the controlknob to persist app connector routes is enabled, when
reconfiguring an app connector unadvertise routes that are no longer
relevant.

Updates #11008
Signed-off-by: Fran Bull <fran@tailscale.com>
2024-04-29 11:40:04 -07:00
Fran Bull
1bd1b387b2 appc: add flag shouldStoreRoutes and controlknob for it
When an app connector is reconfigured and domains to route are removed,
we would like to no longer advertise routes that were discovered for
those domains. In order to do this we plan to store which routes were
discovered for which domains.

Add a controlknob so that we can enable/disable the new behavior.

Updates #11008
Signed-off-by: Fran Bull <fran@tailscale.com>
2024-04-29 11:40:04 -07:00
James Tucker
e1a4b89dbe appc,ipn/ipnlocal: add app connector routes if any part of a CNAME chain is routed
If any domain along a CNAME chain matches any of the routed domains, add
routes for the discovered domains.

Fixes tailscale/corp#16928

Signed-off-by: James Tucker <james@tailscale.com>
2024-02-01 11:43:07 -08:00
James Tucker
0e2cb76abe appc: add test to ensure that individual IPs are not removed during route updates
If control advised the connector to advertise a route that had already
been discovered by DNS it would be incorrectly removed. Now those routes
are preserved.

Updates tailscale/corp#16833

Signed-off-by: James Tucker <james@tailscale.com>
2024-01-22 17:50:55 -08:00
Charlotte Brandhorst-Satzkorn
ce4553b988 appc,ipn/ipnlocal: optimize preference adjustments when routes update
This change allows us to perform batch modification for new route
advertisements and route removals. Additionally, we now handle the case
where newly added routes are covered by existing ranges.

This change also introduces a new appctest package that contains some
shared functions used for testing.

Updates tailscale/corp#16833

Signed-off-by: Charlotte Brandhorst-Satzkorn <charlotte@tailscale.com>
2024-01-22 17:37:16 -08:00
James Tucker
8250582fe6 ipn/ipnlocal: make app connector configuration concurrent
If there are routes changes as a side effect of an app connector
configuration update, the connector configuration may want to reenter a
lock, so must be started asynchronously.

Updates tailscale/corp#16833
Signed-off-by: James Tucker <james@tailscale.com>
2024-01-18 12:26:58 -08:00
James Tucker
24df1ef1ee appc,ipn/ipnlocal,types/appctype: implement control provided routes
Control can now send down a set of routes along with the domains, and
the routes will be advertised, with any newly overlapped routes being
removed to reduce the size of the routing table.

Fixes tailscale/corp#16833
Signed-off-by: James Tucker <james@tailscale.com>
2024-01-17 14:40:09 -08:00
James Tucker
245ddb157b appc: fix DomainRoutes copy
The non-referential copy destination doesn't extend the map contents,
but also the read of a non-key is returning a zero value not bound to
the map contents in any way.

Updates tailscale/corp#15657

Signed-off-by: James Tucker <james@tailscale.com>
2023-11-15 12:20:00 -08:00
James Tucker
1a143963ec appc: prevent duplication of wildcard entries on map updates
Updates #15437
Signed-off-by: James Tucker <james@tailscale.com>
2023-11-09 16:47:42 -08:00
James Tucker
73de6a1a95 appc: add support for matching wildcard domains
The app connector matches a configuration of "*.example.com" to mean any
sub-domain of example.com.

Updates #15437

Signed-off-by: James Tucker <james@tailscale.com>
2023-11-09 12:39:30 -08:00
James Tucker
f27b2cf569 appc,cmd/sniproxy,ipn/ipnlocal: split sniproxy configuration code out of appc
The design changed during integration and testing, resulting in the
earlier implementation growing in the appc package to be intended now
only for the sniproxy implementation. That code is moved to it's final
location, and the current App Connector code is now renamed.

Updates tailscale/corp#15437

Signed-off-by: James Tucker <james@tailscale.com>
2023-11-02 12:51:40 -07:00