systemd-resolved: the guard applies the uplink's names every round (issue 960)

Each round it finds the link carrying the default route (the lowest-metric
kernel default route that is neither one route routed nor the private
network's interface), gives it the names from uplink-names's file plus
its own search and routing domains, and takes them off the link they were
on before when that differs. What it applied is kept in
uplink-names.applied, read at its own start so a restart never infers
which link to take them off, and a resolved refusal is journalled once
per change, not every round. The guard's own names are left out of
whether a link is judged `route` routed, so the fallback still gives a
link holding only them its default route back while the mesh's resolvers
are silent (ADR 0688 stands).

Builds: design 08 sign-in-page §7, §8
This commit is contained in:
jochen
2026-11-24 21:23:06 +01:00
parent a40d7fb1c4
commit b694c5e2a5
4 changed files with 260 additions and 3 deletions
@@ -258,8 +258,20 @@ func (r *Resolver) Routes(ctx context.Context) (*Routes, error) {
}
}
sort.Strings(names)
// The guard's own uplink names (design 08 sign-in-page §7, DMC-2) are left out of whether a link is
// judged `route` routed: a link holding only those names is still the fallback's to give a default
// route back while the mesh's resolvers are silent, never one the fallback takes for a VPN's.
applied := ReadUplinkApplied(r.UplinkNamesAppliedFile)
marked := map[string]bool{}
for _, n := range applied.Names {
marked["~"+n] = true
}
for _, name := range names {
s := Scope{Link: name, Servers: lServers[name], Domains: orEmpty(unrouted(lDomains[name])), routed: onlyRouting(lDomains[name])}
judge := lDomains[name]
if name == applied.Link && len(marked) > 0 {
judge = withoutMarked(judge, marked)
}
s := Scope{Link: name, Servers: lServers[name], Domains: orEmpty(unrouted(lDomains[name])), routed: onlyRouting(judge)}
if d, ok := lDefault[name]; ok && len(d) > 0 {
yes := d[0] == "yes"
s.DefaultRoute = &yes
@@ -269,6 +281,17 @@ func (r *Resolver) Routes(ctx context.Context) (*Routes, error) {
return out, nil
}
// withoutMarked is domains without those marked (design 08 sign-in-page DMC-2).
func withoutMarked(domains []string, marked map[string]bool) []string {
out := make([]string, 0, len(domains))
for _, d := range domains {
if !marked[d] {
out = append(out, d)
}
}
return out
}
func orEmpty(s []string) []string {
if s == nil {
return []string{}