mirror of
https://github.com/tailscale/tailscale.git
synced 2025-05-02 05:31:01 +00:00
Unadvertise routes when turning an appConnector down, and also only unadvertise routes for a domain when the domain actually have a datedRoutes structure
This commit is contained in:
parent
75ba1c4d45
commit
aeff360f77
@ -144,6 +144,15 @@ func (e *AppConnector) UpdateRouteInfo(ri *routeinfo.RouteInfo) {
|
||||
e.routeInfo = ri
|
||||
}
|
||||
|
||||
func (e *AppConnector) UnadvertiseRemoteRoutes() {
|
||||
e.queue.Add(func() {
|
||||
toRemove := e.RouteInfo().Routes(false, true, true)
|
||||
if err := e.routeAdvertiser.UnadvertiseRoute(toRemove...); err != nil {
|
||||
e.logf("failed to unadvertise routes %v: %v", toRemove, err)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// UpdateDomains asynchronously replaces the current set of configured domains
|
||||
// with the supplied set of domains. Domains must not contain a trailing dot,
|
||||
// and should be lower case. If the domain contains a leading '*' label it
|
||||
@ -216,11 +225,13 @@ func (e *AppConnector) updateDomains(domains []string) {
|
||||
e.UpdateRouteInfo(routeInfo)
|
||||
// everything left in oldDiscovered a) won't be in e.domains and b) can be unadvertised if it's not in local or control
|
||||
for domainName, domainsRoutes := range oldDiscovered {
|
||||
if domainsRoutes != nil {
|
||||
toRemove := domainsRoutes.RoutesSlice()
|
||||
e.logf("unadvertising %d routes for domain: %s", len(toRemove), domainName)
|
||||
e.scheduleUnadvertisement(domainName, toRemove...)
|
||||
}
|
||||
}
|
||||
}
|
||||
e.logf("handling domains: %v and wildcards: %v", xmaps.Keys(e.domains), e.wildcards)
|
||||
}
|
||||
|
||||
|
@ -22,6 +22,8 @@ func TestUpdateDomains(t *testing.T) {
|
||||
for _, shouldStore := range []bool{true, false} {
|
||||
ctx := context.Background()
|
||||
a := NewAppConnector(t.Logf, nil, shouldStore)
|
||||
a.routeAdvertiser = &appctest.RouteCollector{}
|
||||
a.UpdateRouteInfo(routeinfo.NewRouteInfo())
|
||||
a.UpdateDomains([]string{"example.com"})
|
||||
|
||||
a.Wait(ctx)
|
||||
|
@ -3585,7 +3585,7 @@ func (b *LocalBackend) reconfigAppConnectorLocked(nm *netmap.NetworkMap, prefs i
|
||||
|
||||
if !prefs.AppConnector().Advertise {
|
||||
if b.appConnector != nil && shouldAppCStoreRoutes {
|
||||
b.appConnector.UpdateDomainsAndRoutes([]string{}, []netip.Prefix{})
|
||||
b.appConnector.UnadvertiseRemoteRoutes()
|
||||
}
|
||||
b.appConnector = nil
|
||||
return
|
||||
|
Loading…
x
Reference in New Issue
Block a user