Kaynağa Gözat

Roaming: feed the 802.11r view from agent payloads (#1451)

* feat(agent): send raw uci wireless config for the 802.11r view

Agent-only fleets have no SSH key on the server, so the 802.11r view
(`GET /api/dot11r`) always answered 503: its only data source was
`uci show wireless` over SSH. The agent now ships that dump inside the
payload, following the surveyRaw precedent (#1214): the server keeps
parsing it with its own parseUciWireless, so no parser is duplicated in
the agent.

- probe.CmdUciWireless: `uci -q show wireless`, 3 s timeout, best effort
  (empty output = could not read).
- Secret fields (key/PSK/SAE/password/RADIUS) are filtered out before
  sending: unlike the SSH path, this dump travels on every push and is
  persisted in kv agent.state.<slug>, and the 802.11r parser never reads
  them.
- WirelessData.uciWirelessRaw (omitempty, a few KB against a 2 MB ingest
  cap).
- Read on full polls at most every 5 minutes, emitted from cache on every
  push including wireless-only event pushes, so the last payload of a
  router never loses the section.
- Not counted as wireless presence: a unit with the config file but no
  live wifi does not start reporting a wireless section.
- Older agents do not send the field; nothing else changes for them.

Tests: the raw text is filled from a fake runner, the event path reuses
the cache without a second uci call, a failing command leaves the field
empty, the secrets filter drops key/SAE/RADIUS lines and keeps the rest,
and the JSON key is present when set and omitted when empty.

Also gofmt-aligns OwnBSSID tags, which were already off in this file.

Refs #1450

* feat(roaming): feed the 802.11r view from agent payloads

`GetDot11r` only knew how to run `uci show wireless` over SSH and skipped
agent-only routers, so a whole agent-only fleet got 503 on the tab even
with 802.11r configured everywhere.

- New dot11rIfacesFromPayload parses wireless.uciWirelessRaw with the
  same parseUciWireless the SSH path uses. No second parser.
- GetDot11r feeds agent-only routers from the fresh payload of their
  agent (AgentRegistry.MatchRouter, the same accessor and freshness rule
  as the usteer view in #1431); SSH routers keep the SSH path and SNMP
  units stay listed with no data.
- Older agents without the field, and units where `uci` is missing, keep
  Available=false: no error and no invented data.
- The overview is available whenever a wireless config could be read,
  even if no SSID has 802.11r: the panel then shows the inactive state
  instead of a read error (that case also answered 503 before, which is
  what made the error text look like a failure to read).
- Front: new key roaming.dot11r.error (es/en) for the 802.11r tab, which
  no longer reuses roaming.error (that one blamed usteer). The matrix tab
  keeps roaming.error.
- Manual (es/en): on agent-only fleets the config arrives in the agent
  push, SSH elsewhere.

Tests: an agent-only fleet of two routers yields the SSID with
enabledEverywhere, the mobility domain, FT over DS and the per-router
interfaces; no payload, an old agent without the field and a stale
payload yield no data; a mixed fleet keeps the SNMP unit empty; a
readable config without 11r is available with the SSID off; the helper
is nil-safe.

Closes #1450
Nacho 1 ay önce
ebeveyn
işleme
b2572b3ee0

+ 52 - 0
agent/probe/local.go

@@ -106,11 +106,26 @@ type Prober struct {
 	surveyMu     sync.Mutex
 	surveyForced bool
 	surveyAt     time.Time
+
+	// Config wireless cruda (#1450): `uci show wireless` para que el server
+	// pinte 802.11r en flotas agent-only. Se refresca cada uciWirelessTTL
+	// (la config cambia a mano, no sola) y el valor cacheado se emite en
+	// TODOS los pushes: un push de evento (BuildWireless) no debe dejar al
+	// server sin la sección mientras llega el siguiente sondeo completo.
+	uciWirelessMu  sync.Mutex
+	uciWirelessRaw string
+	uciWirelessAt  time.Time
 }
 
 // surveyInterval: mínimo entre `iw survey dump` si no hay force (#1214).
 const surveyInterval = 5 * time.Minute
 
+// uciWirelessTTL: mínimo entre lecturas de `uci show wireless` (#1450).
+// Leer /etc/config/wireless es barato, pero la configuración solo cambia
+// cuando alguien la edita: con 5 min el panel sigue fresco y el push no
+// engorda en cada ciclo.
+const uciWirelessTTL = 5 * time.Minute
+
 const radiosTTL = 5 * time.Minute
 
 const (
@@ -178,6 +193,33 @@ func (p *Prober) surveyDue() bool {
 	return false
 }
 
+// refreshUciWireless lee `uci show wireless` si toca (#1450) y lo deja en
+// caché para el resto de pushes. Marca el intento aunque falle: un equipo sin
+// uci (o un switch sin sección wireless) no reintenta en cada sondeo.
+func (p *Prober) refreshUciWireless(ctx context.Context) {
+	p.uciWirelessMu.Lock()
+	due := p.uciWirelessAt.IsZero() || time.Since(p.uciWirelessAt) >= uciWirelessTTL
+	p.uciWirelessMu.Unlock()
+	if !due {
+		return
+	}
+	out := p.runBest(ctx, CmdUciWireless, 3*time.Second)
+	p.uciWirelessMu.Lock()
+	p.uciWirelessAt = time.Now()
+	if out != "" {
+		p.uciWirelessRaw = out
+	}
+	p.uciWirelessMu.Unlock()
+}
+
+// uciWirelessCached devuelve el último volcado bueno de la config wireless
+// ("" si nunca se pudo leer).
+func (p *Prober) uciWirelessCached() string {
+	p.uciWirelessMu.Lock()
+	defer p.uciWirelessMu.Unlock()
+	return p.uciWirelessRaw
+}
+
 // scanDue decide si toca lanzar CmdScan en este sondeo completo: true si hay
 // un force pendiente (refresh del server) o si pasó scanInterval desde el
 // último intento. Con ScanDisabled los periódicos no corren nunca (solo
@@ -497,6 +539,16 @@ func (p *Prober) probeWireless(ctx context.Context, full bool) *WirelessData {
 	if !any && (len(wd.Radios) > 0 || len(wd.OwnBssids) > 0) {
 		any = true
 	}
+	// Config wireless cruda (#1450): alimenta la vista 802.11r del server en
+	// flotas agent-only. Se refresca solo en el sondeo completo y se emite
+	// SIEMPRE desde la caché (también en el path de eventos, para que el
+	// último payload no pierda la sección). No cuenta para `any`: una unidad
+	// con la config presente pero sin wifi operativa no debe aparecer como
+	// wireless vivo.
+	if full {
+		p.refreshUciWireless(ctx)
+	}
+	wd.UciWirelessRaw = p.uciWirelessCached()
 	if !any {
 		return nil
 	}

+ 11 - 3
agent/probe/payload.go

@@ -123,13 +123,21 @@ type WirelessData struct {
 	// parser (adapters.ParseIwSurvey) para la lente "Ahora" en unidades
 	// agent-only sin SSH. Vacío = sin survey fresco (throttle 5 min).
 	SurveyRaw string `json:"surveyRaw,omitempty"`
+	// UciWirelessRaw (#1450): salida cruda de `uci show wireless`. El server
+	// la parsea con su parseUciWireless (misma función que el camino SSH)
+	// para la vista 802.11r en flotas agent-only, donde no hay llave SSH.
+	// Se refresca cada uciWirelessTTL pero va en TODOS los pushes (también
+	// los de evento), para que el último payload del router nunca la pierda.
+	// Vacío = no se pudo leer, o agente antiguo que no manda el campo: en
+	// ambos casos el server degrada a "802.11r no disponible" sin error.
+	UciWirelessRaw string `json:"uciWirelessRaw,omitempty"`
 }
 
 // OwnBSSID: una interfaz AP local con su BSSID y SSID (#1087).
 type OwnBSSID struct {
-	Iface  string `json:"iface"`
-	BSSID  string `json:"bssid"` // MAC en mayúsculas
-	SSID   string `json:"ssid"`  // puede estar vacío
+	Iface string `json:"iface"`
+	BSSID string `json:"bssid"` // MAC en mayúsculas
+	SSID  string `json:"ssid"`  // puede estar vacío
 }
 
 // ScanResult es un AP vecino detectado por un scan pasivo.

+ 15 - 0
agent/probe/probe.go

@@ -124,6 +124,21 @@ const (
 	// CmdRadioSections (#500): secciones wifi-device de UCI con su banda, para
 	// resolver "2.4 GHz" → radio0 (la relación iface→sección no sale de iwinfo).
 	CmdRadioSections = `uci -q show wireless 2>/dev/null | grep -E "=wifi-device$|\.band=|\.hwmode="`
+	// CmdUciWireless (#1450): volcado crudo de la configuración wireless, tal
+	// cual lo emite `uci show wireless`. El server lo parsea con su
+	// parseUciWireless (vista 802.11r) en unidades agent-only sin SSH: el
+	// parser NO se duplica en el agente, igual que con CmdSurvey (#1214).
+	// Solo lectura de /etc/config/wireless, barato (unos pocos KB).
+	//
+	// Los campos de SECRETO se descartan antes de enviarlo: a diferencia del
+	// camino SSH (que los lee y los tira en el server), este volcado viaja en
+	// cada push y queda persistido en kv agent.state.<slug>. El parser 802.11r
+	// no usa la PSK, así que filtrarla no quita información a la vista.
+	CmdUciWireless = `uci -q show wireless 2>/dev/null | ` + uciWirelessSecretsFilter
+	// uciWirelessSecretsFilter: líneas `option` con secretos fuera del push
+	// (key/PSK/SAE/contraseñas/RADIUS). Se conserva el resto del volcado tal
+	// cual. Busybox grep -E soporta la alternancia.
+	uciWirelessSecretsFilter = `grep -v -E '\.(key|sae_key|wpa_psk|psk|password|secret|radius_secret)='`
 	// CmdPortStates: "<name> <operstate> <speed> <dsa> <type> <conduit>" por
 	// interfaz.
 	//   - dsa: "dsa" cuando la interfaz es un conduit DSA (tiene el directorio

+ 6 - 0
agent/probe/scan_throttle_test.go

@@ -18,12 +18,18 @@ import (
 type countingRunner struct {
 	fakeRunner
 	scanCalls int
+	// calls cuenta por comando exacto (#1450: comprobar que el volcado de
+	// `uci show wireless` se cachea y no se relanza). nil = no se cuenta.
+	calls map[string]int
 }
 
 func (r *countingRunner) Run(ctx context.Context, cmd string, timeout time.Duration) (string, error) {
 	if strings.HasPrefix(cmd, `iw dev "`) && strings.HasSuffix(cmd, `" scan 2>/dev/null`) {
 		r.scanCalls++
 	}
+	if r.calls != nil {
+		r.calls[cmd]++
+	}
 	return r.fakeRunner.Run(ctx, cmd, timeout)
 }
 

+ 152 - 0
agent/probe/uciwireless_1450_test.go

@@ -0,0 +1,152 @@
+package probe
+
+import (
+	"context"
+	"encoding/json"
+	"os/exec"
+	"runtime"
+	"strings"
+	"testing"
+)
+
+// uciWirelessFixture es un `uci show wireless` reducido: un wifi-device y un
+// wifi-iface con 802.11r, el mínimo que el server necesita para pintar la
+// vista (#1450).
+const uciWirelessFixture = `wireless.radio0=wifi-device
+wireless.radio0.band='2g'
+wireless.radio0.channel='6'
+wireless.wifi2g=wifi-iface
+wireless.wifi2g.device='radio0'
+wireless.wifi2g.ssid='temiscira'
+wireless.wifi2g.ieee80211r='1'
+wireless.wifi2g.mobility_domain='2025'
+wireless.wifi2g.ft_over_ds='1'
+`
+
+// hostapdUnoOut: un AP con un cliente, suficiente para que probeWireless
+// marque la sección como presente (any=true) sin depender de iwinfo.
+const hostapdUnoOut = `==AP==hostapd.phy0-ap0
+{
+	"freq": 2437,
+	"clients": {
+		"AA:BB:CC:DD:EE:FF": { "auth": true, "assoc": true, "authorized": true, "signal": -60 }
+	}
+}`
+
+// TestProberWirelessUciWirelessRaw: el sondeo completo rellena el campo con la
+// salida cruda de `uci show wireless` y el path de eventos la reutiliza desde
+// caché (sin un segundo uci), para que ningún push deje al server sin la
+// sección.
+func TestProberWirelessUciWirelessRaw(t *testing.T) {
+	run := &countingRunner{
+		fakeRunner: fakeRunner{outs: map[string]string{
+			CmdHostapdClients: hostapdUnoOut,
+			CmdUciWireless:    uciWirelessFixture,
+		}},
+		calls: map[string]int{},
+	}
+	p := NewProber(run, Options{})
+
+	wd := p.probeWireless(context.Background(), true)
+	if wd == nil {
+		t.Fatal("wireless nil en el sondeo completo")
+	}
+	if wd.UciWirelessRaw != uciWirelessFixture {
+		t.Fatalf("uciWirelessRaw inesperado: %q", wd.UciWirelessRaw)
+	}
+	if n := run.calls[CmdUciWireless]; n != 1 {
+		t.Fatalf("uci show wireless ejecutado %d veces en el sondeo completo, want 1", n)
+	}
+
+	// Path de eventos: misma sección, sin volver a lanzar uci.
+	wd2 := p.probeWireless(context.Background(), false)
+	if wd2 == nil {
+		t.Fatal("wireless nil en el path de eventos")
+	}
+	if wd2.UciWirelessRaw != uciWirelessFixture {
+		t.Fatalf("el path de eventos perdió uciWirelessRaw: %q", wd2.UciWirelessRaw)
+	}
+	if n := run.calls[CmdUciWireless]; n != 1 {
+		t.Fatalf("uci show wireless se repitió en el path de eventos: %d llamadas", n)
+	}
+}
+
+// TestProberWirelessUciWirelessFallo: sin uci (o si el comando falla) el
+// campo queda vacío y la sección wireless sigue existiendo. Es la degradación
+// que el server interpreta como "802.11r no disponible", sin error.
+func TestProberWirelessUciWirelessFallo(t *testing.T) {
+	run := fakeRunner{outs: map[string]string{
+		CmdHostapdClients: hostapdUnoOut,
+	}}
+	p := NewProber(run, Options{})
+
+	wd := p.probeWireless(context.Background(), true)
+	if wd == nil {
+		t.Fatal("wireless nil: un fallo de uci no debe vaciar la sección")
+	}
+	if wd.UciWirelessRaw != "" {
+		t.Fatalf("uciWirelessRaw = %q, want vacío", wd.UciWirelessRaw)
+	}
+}
+
+// TestUciWirelessSecretsFilter: el volcado que sale del router lleva la config
+// pero NO los secretos (PSK/SAE/RADIUS): viaja en cada push y queda guardado
+// en kv agent.state.<slug>. El parser 802.11r no los necesita.
+func TestUciWirelessSecretsFilter(t *testing.T) {
+	if runtime.GOOS == "windows" {
+		t.Skip("necesita /bin/sh")
+	}
+	in := strings.Join([]string{
+		`wireless.wifi2g=wifi-iface`,
+		`wireless.wifi2g.ssid='temiscira'`,
+		`wireless.wifi2g.key='super-secreta'`,
+		`wireless.wifi2g.sae_key='sae-secreta'`,
+		`wireless.wifi2g.radius_secret='radius-secreto'`,
+		`wireless.wifi2g.ieee80211r='1'`,
+		`wireless.wifi2g.ft_psk_generate_local='1'`,
+		"",
+	}, "\n")
+	cmd := exec.Command("/bin/sh", "-c", uciWirelessSecretsFilter)
+	cmd.Stdin = strings.NewReader(in)
+	out, err := cmd.Output()
+	if err != nil {
+		t.Fatalf("filtro: %v", err)
+	}
+	got := string(out)
+	for _, leaked := range []string{"super-secreta", "sae-secreta", "radius-secreto", "sae_key", "radius_secret"} {
+		if strings.Contains(got, leaked) {
+			t.Fatalf("secreto %q en el volcado: %s", leaked, got)
+		}
+	}
+	for _, kept := range []string{"wireless.wifi2g=wifi-iface", `ssid='temiscira'`, `ieee80211r='1'`, `ft_psk_generate_local='1'`} {
+		if !strings.Contains(got, kept) {
+			t.Fatalf("el filtro se llevó %q: %s", kept, got)
+		}
+	}
+	if !strings.Contains(CmdUciWireless, uciWirelessSecretsFilter) {
+		t.Fatalf("CmdUciWireless no aplica el filtro de secretos: %q", CmdUciWireless)
+	}
+}
+
+// TestUciWirelessRawJSON fija el contrato con el server: la clave
+// `uciWirelessRaw` viaja en el payload y se omite cuando está vacía (agentes
+// antiguos y equipos sin uci no mandan la clave).
+func TestUciWirelessRawJSON(t *testing.T) {
+	wd := WirelessData{Clients: map[string]WirelessClient{}, UciWirelessRaw: uciWirelessFixture}
+	raw, err := json.Marshal(wd)
+	if err != nil {
+		t.Fatal(err)
+	}
+	if !strings.Contains(string(raw), `"uciWirelessRaw":"wireless.radio0=wifi-device\n`) {
+		t.Fatalf("uciWirelessRaw no serializado: %s", raw)
+	}
+
+	vacio := WirelessData{Clients: map[string]WirelessClient{}}
+	raw, err = json.Marshal(vacio)
+	if err != nil {
+		t.Fatal(err)
+	}
+	if strings.Contains(string(raw), "uciWirelessRaw") {
+		t.Fatalf("campo vacío debe omitirse: %s", raw)
+	}
+}

+ 1 - 0
app/public/locales/en/translation.json

@@ -720,6 +720,7 @@
     "dot11r": {
       "title": "802.11r status",
       "description": "Fast BSS Transition (fast roaming) read from `uci show wireless`. Without it the client fully re-authenticates when jumping APs (1-2 s hiccup).",
+      "error": "Could not read the 802.11r configuration: no router reported its wireless config. An updated agent is required (older ones don't send it); units without an agent are read over SSH.",
       "empty": "No router has 802.11r enabled on any SSID.",
       "allOn": "802.11r active on all {{n}} SSIDs",
       "partial": "Partial: active on {{on}} of {{total}} SSIDs",

+ 1 - 0
app/public/locales/es/translation.json

@@ -720,6 +720,7 @@
     "dot11r": {
       "title": "Estado 802.11r",
       "description": "Fast BSS Transition (itinerancia rápida) leído de `uci show wireless`. Sin él, el cliente se re-autentica completo al saltar de AP (corte de 1-2 s).",
+      "error": "No se pudo leer la configuración 802.11r: ningún router ha reportado su configuración wifi. Hace falta un agente actualizado (los anteriores no la envían); en los equipos sin agente se lee por SSH.",
       "empty": "Ningún router tiene 802.11r habilitado en ningún SSID.",
       "allOn": "802.11r activo en los {{n}} SSIDs",
       "partial": "Parcial: activo en {{on}} de {{total}} SSIDs",

+ 1 - 1
app/src/pages/Roaming.tsx

@@ -800,7 +800,7 @@ function Dot11rPanel({
   if (error) {
     return (
       <div className="rounded-2xl border border-border bg-surface p-8 text-center text-caption text-text-muted">
-        {t('roaming.error')}
+        {t('roaming.dot11r.error')}
       </div>
     )
   }

+ 1 - 1
docs/manual.en.md

@@ -327,7 +327,7 @@ Five tabs:
 ### What data it needs
 
 - **Matrix** and **Re-anchor** depend on **usteer** (or DAWN, which is deprecated and shows a notice). Without an active roaming daemon on the routers, these tabs have no data.
-- **802.11r** reads `uci show wireless` from each router with WiFi (one SSH per router).
+- **802.11r** reads `uci show wireless` from each router with WiFi. On units with an agent (agent-only fleets) the configuration arrives in the agent push; everywhere else it is read over SSH (one SSH per router).
 - **Survey** uses `iw survey dump` (one SSH per WiFi router).
 - **Events** arrive via continuous agent ingestion into the SQLite database (30 days).
 

+ 1 - 1
docs/manual.es.md

@@ -327,7 +327,7 @@ Cinco pestañas:
 ### Qué datos necesita
 
 - La **Matriz** y **Reanclar** dependen de **usteer** (o de DAWN, que está en desuso y muestra un aviso). Sin un daemon de itinerancia activo en los routers, estas pestañas no tienen datos.
-- **802.11r** lee `uci show wireless` de cada router con WiFi (un SSH por router).
+- **802.11r** lee `uci show wireless` de cada router con WiFi. En las unidades con agente (flotas agent-only) la configuración llega en el push del agente; en el resto se lee por SSH (un SSH por router).
 - **Survey** usa `iw survey dump` (un SSH por router con WiFi).
 - **Eventos** llegan por ingesta continua del agente a la base SQLite (30 días).
 

+ 28 - 0
server-go/internal/adapters/dot11r_agent.go

@@ -0,0 +1,28 @@
+// dot11r_agent.go - vista 802.11r alimentada por el payload del agente
+// (#1450). En flotas agent-only (router.AgentOnly, el patrón NetGrip con el
+// agente embebido) no hay sondeo SSH y la pestaña 802.11r respondía 503
+// aunque la config estuviera puesta: el único camino leía `uci show wireless`
+// por SSH. El agente manda ese volcado crudo en wireless.uciWirelessRaw y
+// aquí se parsea con la MISMA función que el camino SSH (parseUciWireless):
+// no hay segundo parser, ni en el agente ni en este fichero.
+package adapters
+
+import (
+	"github.com/gnacho/netpulse/agent/probe"
+)
+
+// dot11rIfacesFromPayload devuelve las wifi-iface del último payload del
+// agente (nil si no hay payload, no trae sección wireless o el agente es
+// anterior al campo). Un campo vacío es el caso normal de un agente antiguo
+// y de un equipo donde `uci` no está: se degrada a "802.11r no disponible",
+// nunca a error.
+func dot11rIfacesFromPayload(p *probe.Payload) []Dot11rIface {
+	if p == nil || p.Data.Wireless == nil {
+		return nil
+	}
+	raw := p.Data.Wireless.UciWirelessRaw
+	if raw == "" {
+		return nil
+	}
+	return parseUciWireless(raw)
+}

+ 271 - 0
server-go/internal/adapters/dot11r_agent_test.go

@@ -0,0 +1,271 @@
+package adapters
+
+import (
+	"context"
+	"testing"
+	"time"
+
+	"github.com/gnacho/netpulse/agent/probe"
+)
+
+// uciWireless11rFixture: `uci show wireless` de un AP con dos radios y el
+// mismo SSID en ambas, con 802.11r activo (el caso real de la flota de
+// oficina del issue #1450: ieee80211r=1, mobility_domain=2025, ft_over_ds=1).
+const uciWireless11rFixture = `wireless.radio0=wifi-device
+wireless.radio0.band='2g'
+wireless.radio0.channel='1'
+wireless.wifi2g=wifi-iface
+wireless.wifi2g.device='radio0'
+wireless.wifi2g.network='lan'
+wireless.wifi2g.mode='ap'
+wireless.wifi2g.ssid='temiscira'
+wireless.wifi2g.ieee80211k='1'
+wireless.wifi2g.ieee80211r='1'
+wireless.wifi2g.mobility_domain='2025'
+wireless.wifi2g.ft_over_ds='1'
+wireless.wifi2g.ft_psk_generate_local='1'
+wireless.wifi2g.ifname='wlan0'
+wireless.radio1=wifi-device
+wireless.radio1.band='5g'
+wireless.radio1.channel='36'
+wireless.wifi5g=wifi-iface
+wireless.wifi5g.device='radio1'
+wireless.wifi5g.network='lan'
+wireless.wifi5g.mode='ap'
+wireless.wifi5g.ssid='temiscira'
+wireless.wifi5g.ieee80211r='1'
+wireless.wifi5g.mobility_domain='2025'
+wireless.wifi5g.ft_over_ds='1'
+wireless.wifi5g.ft_psk_generate_local='1'
+wireless.wifi5g.ifname='wlan1'
+`
+
+// TestGetDot11rAgentOnlyFromPayload (#1450): en una flota agent-only la vista
+// 802.11r se alimenta del payload del agente, sin SSH. Pool nil como
+// tripwire: si la guarda agent-only se rompe y se intenta SSH, paniquea.
+func TestGetDot11rAgentOnlyFromPayload(t *testing.T) {
+	l := NewLive(nil, nil, []RouterConfig{
+		{ID: "flint2", Name: "flint2", Host: "192.168.1.1", AgentOnly: true},
+		{ID: "rt2", Name: "rt2", Host: "192.168.1.2", AgentOnly: true},
+	}, nil)
+	reg := NewAgentRegistry(time.Hour)
+	for _, slug := range []string{"flint2", "rt2"} {
+		reg.Ingest(&probe.Payload{
+			Router:  slug,
+			Version: "3.0.20",
+			Data: probe.PayloadData{Wireless: &probe.WirelessData{
+				Clients:        map[string]probe.WirelessClient{},
+				UciWirelessRaw: uciWireless11rFixture,
+			}},
+		})
+	}
+	l.SetAgents(reg)
+
+	d, err := l.GetDot11r(context.Background())
+	if err != nil {
+		t.Fatalf("unexpected error: %v", err)
+	}
+	if d == nil || !d.Available {
+		t.Fatalf("esperaba overview disponible, got %+v", d)
+	}
+	if len(d.Routers) != 2 {
+		t.Fatalf("esperaba 2 routers, got %d: %+v", len(d.Routers), d.Routers)
+	}
+	for _, r := range d.Routers {
+		if !r.Available || len(r.Ifaces) != 2 {
+			t.Fatalf("router %s sin datos del agente: %+v", r.RouterID, r)
+		}
+	}
+
+	if len(d.SSIDs) != 1 {
+		t.Fatalf("esperaba 1 SSID, got %+v", d.SSIDs)
+	}
+	s := d.SSIDs[0]
+	if s.SSID != "temiscira" {
+		t.Errorf("SSID = %q, want temiscira", s.SSID)
+	}
+	if s.EnabledCount != 4 || s.TotalCount != 4 || !s.EnabledEverywhere {
+		t.Errorf("cobertura 11r = %d/%d everywhere=%v, want 4/4 true",
+			s.EnabledCount, s.TotalCount, s.EnabledEverywhere)
+	}
+	if s.MobilityDomain != "2025" {
+		t.Errorf("mobility domain = %q, want 2025", s.MobilityDomain)
+	}
+	if !s.FTOverDS {
+		t.Errorf("ft_over_ds = false, want true")
+	}
+	if !s.FTPSKGenerateLocal {
+		t.Errorf("ft_psk_generate_local = false, want true")
+	}
+	if len(s.RouterIDs) != 2 || s.RouterIDs[0] != "flint2" || s.RouterIDs[1] != "rt2" {
+		t.Errorf("routerIDs = %v, want [flint2 rt2]", s.RouterIDs)
+	}
+}
+
+// TestGetDot11rAgentOnlyNoPayload: un router agent-only cuyo agente todavía
+// no ha empujado (o que es de un tipo sin sección wireless) queda como antes:
+// sin datos y sin error. Igual que el test SNMP, pool nil es el tripwire.
+func TestGetDot11rAgentOnlyNoPayload(t *testing.T) {
+	l := NewLive(nil, nil, []RouterConfig{
+		{ID: "rt2", Name: "rt2", Host: "192.168.1.2", AgentOnly: true},
+	}, nil)
+	l.SetAgents(NewAgentRegistry(time.Hour))
+
+	d, err := l.GetDot11r(context.Background())
+	if err != nil {
+		t.Fatalf("unexpected error: %v", err)
+	}
+	if d != nil {
+		t.Fatalf("expected nil Dot11rOverview sin payload, got %+v", d)
+	}
+}
+
+// TestGetDot11rAgentOldWithoutField: un agente anterior a #1450 no manda
+// uciWirelessRaw. Debe degradar (sin datos), no romper ni inventar.
+func TestGetDot11rAgentOldWithoutField(t *testing.T) {
+	l := NewLive(nil, nil, []RouterConfig{
+		{ID: "rt2", Name: "rt2", Host: "192.168.1.2", AgentOnly: true},
+	}, nil)
+	reg := NewAgentRegistry(time.Hour)
+	reg.Ingest(&probe.Payload{
+		Router:  "rt2",
+		Version: "3.0.18",
+		Data: probe.PayloadData{Wireless: &probe.WirelessData{
+			Clients: map[string]probe.WirelessClient{"AA:BB:CC:DD:EE:FF": {SignalDbm: -55, Band: "2.4 GHz"}},
+		}},
+	})
+	l.SetAgents(reg)
+
+	d, err := l.GetDot11r(context.Background())
+	if err != nil {
+		t.Fatalf("unexpected error: %v", err)
+	}
+	if d != nil {
+		t.Fatalf("agente viejo: esperaba nil, got %+v", d)
+	}
+}
+
+// TestGetDot11rMixedFleet: agent-only con payload + unidad SNMP. La SNMP se
+// lista sin datos y el resto de la vista sigue disponible.
+func TestGetDot11rMixedFleet(t *testing.T) {
+	l := NewLive(nil, nil, []RouterConfig{
+		{ID: "rt2", Name: "rt2", Host: "192.168.1.2", AgentOnly: true},
+		{ID: "sw1", Name: "Switch 1", Host: "192.168.1.10", SnmpEnabled: true},
+	}, nil)
+	reg := NewAgentRegistry(time.Hour)
+	reg.Ingest(&probe.Payload{
+		Router:  "rt2",
+		Version: "3.0.20",
+		Data: probe.PayloadData{Wireless: &probe.WirelessData{
+			Clients:        map[string]probe.WirelessClient{},
+			UciWirelessRaw: uciWireless11rFixture,
+		}},
+	})
+	l.SetAgents(reg)
+
+	d, err := l.GetDot11r(context.Background())
+	if err != nil {
+		t.Fatalf("unexpected error: %v", err)
+	}
+	if d == nil || !d.Available {
+		t.Fatalf("esperaba overview disponible, got %+v", d)
+	}
+	var sw *Dot11rRouter
+	for i := range d.Routers {
+		if d.Routers[i].RouterID == "sw1" {
+			sw = &d.Routers[i]
+		}
+	}
+	if sw == nil || sw.Available || len(sw.Ifaces) != 0 {
+		t.Fatalf("la unidad SNMP debe seguir sin datos: %+v", sw)
+	}
+}
+
+// TestGetDot11rAgentOnlyStalePayload: un payload fuera del TTL no pinta la
+// config como actual (mismo criterio que /api/usteer, #1431).
+func TestGetDot11rAgentOnlyStalePayload(t *testing.T) {
+	l := NewLive(nil, nil, []RouterConfig{
+		{ID: "rt2", Name: "rt2", Host: "192.168.1.2", AgentOnly: true},
+	}, nil)
+	reg := NewAgentRegistry(time.Minute)
+	now := time.Now()
+	reg.SetClock(func() time.Time { return now })
+	reg.Ingest(&probe.Payload{
+		Router:  "rt2",
+		Version: "3.0.20",
+		Data: probe.PayloadData{Wireless: &probe.WirelessData{
+			Clients:        map[string]probe.WirelessClient{},
+			UciWirelessRaw: uciWireless11rFixture,
+		}},
+	})
+	reg.SetClock(func() time.Time { return now.Add(10 * time.Minute) })
+	l.SetAgents(reg)
+
+	d, err := l.GetDot11r(context.Background())
+	if err != nil {
+		t.Fatalf("unexpected error: %v", err)
+	}
+	if d != nil {
+		t.Fatalf("payload caducado: esperaba nil, got %+v", d)
+	}
+}
+
+// TestGetDot11rNo11rEnabledIsAvailable: si la config se leyó pero ningún SSID
+// tiene 802.11r, la vista está disponible con el estado "inactivo" en vez de
+// devolver 503 (que la UI mostraba como error de lectura).
+func TestGetDot11rNo11rEnabledIsAvailable(t *testing.T) {
+	sin11r := `wireless.radio0=wifi-device
+wireless.radio0.band='2g'
+wireless.radio0.channel='6'
+wireless.wifi2g=wifi-iface
+wireless.wifi2g.device='radio0'
+wireless.wifi2g.network='lan'
+wireless.wifi2g.ssid='temiscira'
+wireless.wifi2g.ieee80211r='0'
+`
+	l := NewLive(nil, nil, []RouterConfig{
+		{ID: "rt2", Name: "rt2", Host: "192.168.1.2", AgentOnly: true},
+	}, nil)
+	reg := NewAgentRegistry(time.Hour)
+	reg.Ingest(&probe.Payload{
+		Router:  "rt2",
+		Version: "3.0.20",
+		Data: probe.PayloadData{Wireless: &probe.WirelessData{
+			Clients:        map[string]probe.WirelessClient{},
+			UciWirelessRaw: sin11r,
+		}},
+	})
+	l.SetAgents(reg)
+
+	d, err := l.GetDot11r(context.Background())
+	if err != nil {
+		t.Fatalf("unexpected error: %v", err)
+	}
+	if d == nil || !d.Available {
+		t.Fatalf("esperaba overview disponible (11r inactivo), got %+v", d)
+	}
+	if len(d.SSIDs) != 1 || d.SSIDs[0].EnabledCount != 0 || d.SSIDs[0].EnabledEverywhere {
+		t.Fatalf("SSIDs = %+v, want temiscira con 11r inactivo", d.SSIDs)
+	}
+}
+
+// TestDot11rIfacesFromPayloadDegenerados: el helper nunca paniquea y devuelve
+// nil para payload/sección/campo ausentes.
+func TestDot11rIfacesFromPayloadDegenerados(t *testing.T) {
+	cases := map[string]*probe.Payload{
+		"nil":            nil,
+		"sin-wireless":   {Router: "rt2"},
+		"sin-campo":      {Router: "rt2", Data: probe.PayloadData{Wireless: &probe.WirelessData{}}},
+		"raw-sin-ifaces": {Router: "rt2", Data: probe.PayloadData{Wireless: &probe.WirelessData{UciWirelessRaw: "wireless.radio0=wifi-device\n"}}},
+	}
+	for name, p := range cases {
+		t.Run(name, func(t *testing.T) {
+			if got := dot11rIfacesFromPayload(p); len(got) != 0 {
+				t.Fatalf("esperaba 0 ifaces, got %+v", got)
+			}
+		})
+	}
+	if got := dot11rIfacesFromPayload(&probe.Payload{Data: probe.PayloadData{Wireless: &probe.WirelessData{UciWirelessRaw: uciWireless11rFixture}}}); len(got) != 2 {
+		t.Fatalf("esperaba 2 ifaces del fixture, got %d", len(got))
+	}
+}

+ 44 - 9
server-go/internal/adapters/live.go

@@ -4522,6 +4522,11 @@ type dot11rIfaceRef struct {
 func (l *Live) GetDot11r(ctx context.Context) (*Dot11rOverview, error) {
 	l.mu.Lock()
 	routers := append([]RouterConfig(nil), l.routers...)
+	reg := l.agents
+	macs := make(map[string]string, len(l.routerMacs))
+	for k, v := range l.routerMacs {
+		macs[k] = v
+	}
 	l.mu.Unlock()
 
 	out := Dot11rOverview{Routers: []Dot11rRouter{}, SSIDs: []Dot11rSSID{}}
@@ -4533,18 +4538,36 @@ func (l *Live) GetDot11r(ctx context.Context) (*Dot11rOverview, error) {
 			name = cfg.ID
 		}
 		r := Dot11rRouter{RouterID: cfg.ID, Name: name, Ifaces: []Dot11rIface{}}
-		// Agent-only (switches sin SSH ni wifi) y los sondeados por SNMP (sin
-		// SSH en absoluto, #1026) se listan como Available=false.
-		if cfg.AgentOnly || cfg.SnmpEnabled {
-			out.Routers = append(out.Routers, r)
-			continue
-		}
-		uciOut, err := l.pool.Run(cfg.SSHAddr(), "uci show wireless", 0)
-		if err != nil {
+		// #1450: en flotas agent-only no hay llave SSH. La config sale del
+		// último payload del agente (uciWirelessRaw), parseado con la MISMA
+		// parseUciWireless del camino SSH. Solo payload fresco (mismo
+		// criterio que la vista usteer, #1431): un router que dejó de
+		// empujar no debe seguir pintando su config como actual.
+		// SNMP (sin SSH en absoluto, #1026) y agentes antiguos sin el campo
+		// se listan con Available=false, como antes.
+		var ifaces []Dot11rIface
+		switch {
+		case cfg.AgentOnly:
+			if reg != nil {
+				if _, p, fresh := reg.MatchRouter(cfg, macs); fresh && p != nil {
+					ifaces = dot11rIfacesFromPayload(p)
+				}
+			}
+			if len(ifaces) == 0 {
+				out.Routers = append(out.Routers, r)
+				continue
+			}
+		case cfg.SnmpEnabled:
 			out.Routers = append(out.Routers, r)
 			continue
+		default:
+			uciOut, err := l.pool.Run(cfg.SSHAddr(), "uci show wireless", 0)
+			if err != nil {
+				out.Routers = append(out.Routers, r)
+				continue
+			}
+			ifaces = parseUciWireless(uciOut)
 		}
-		ifaces := parseUciWireless(uciOut)
 		r.Available = true
 		r.Ifaces = ifaces
 		out.Routers = append(out.Routers, r)
@@ -4601,6 +4624,18 @@ func (l *Live) GetDot11r(ctx context.Context) (*Dot11rOverview, error) {
 			break
 		}
 	}
+	// #1450: si la configuración wifi SÍ se pudo leer pero ningún SSID tiene
+	// 802.11r, la vista está disponible (el panel pinta el estado "inactivo"
+	// en vez de un error de lectura). Antes este caso devolvía (nil, nil) y el
+	// handler respondía 503, que la UI mostraba como "no se pudo leer".
+	if !out.Available {
+		for _, r := range out.Routers {
+			if r.Available {
+				out.Available = true
+				break
+			}
+		}
+	}
 	if !out.Available {
 		return nil, nil
 	}