Просмотр исходного кода

fix(agent): adopt the global IPv6 from a PPPoE child (#2305)

Nacho 5 часов назад
Родитель
Сommit
4ef4555f0a
3 измененных файлов с 23 добавлено и 6 удалено
  1. 1 1
      agent/VERSION
  2. 4 1
      agent/probe/probe.go
  3. 18 4
      agent/probe/probe_test.go

+ 1 - 1
agent/VERSION

@@ -1 +1 @@
-3.0.53
+3.0.54

+ 4 - 1
agent/probe/probe.go

@@ -846,7 +846,10 @@ func withChildFacts(parent ifaceStatus, ifaces []ifaceStatus) ifaceStatus {
 		if len(parent.IPV4) == 0 {
 			parent.IPV4 = c.IPV4
 		}
-		if len(parent.IPV6) == 0 {
+		// #2288: un padre PPPoE lleva una link-local, asi que "sin
+		// entradas" no vale como puerta. Se adopta el hijo si no hay una
+		// global usable que publicar.
+		if globalIPv6(parent.IPV6) == "" {
 			parent.IPV6 = c.IPV6
 		}
 		if len(parent.Route) == 0 {

+ 18 - 4
agent/probe/probe_test.go

@@ -1894,11 +1894,25 @@ func TestParseWanStatusIPv6Deprecada(t *testing.T) {
 // El hijo que netifd crea para un modem lleva las direcciones que el padre no
 // tiene: si no se copian, el uplink reporta v4 sin v6.
 func TestWithChildFactsCopiaIPv6(t *testing.T) {
-	parent := ifaceStatus{Interface: "wwan", Dynamic: true, L3Device: "wwan0"}
+	parent := ifaceStatus{Interface: "wwan", L3Device: "wwan0"}
 	child := ifaceStatus{Interface: "wwan_6", Dynamic: true, L3Device: "wwan0",
 		IPV6: []ubusIPv6{{Address: "2a0c:5a80:1234::9", Preferred: []byte("7200")}}}
-	got := withChildFacts(child, []ifaceStatus{parent})
-	if len(got.IPV6) != 1 || got.IPV6[0].Address != "2a0c:5a80:1234::9" {
-		t.Fatalf("ipv6 no copiada del padre: %+v", got.IPV6)
+	got := withChildFacts(parent, []ifaceStatus{child})
+	if globalIPv6(got.IPV6) != "2a0c:5a80:1234::9" {
+		t.Fatalf("ipv6 no copiada del hijo: %+v", got.IPV6)
+	}
+}
+
+// #2288: en PPPoE el padre lleva la link-local y el hijo dhcpv6 la global.
+// La puerta antigua ("sin entradas IPv6") no se abria y la WAN se quedaba sin
+// v6 aunque `ip -6 addr` mostrara la direccion global en el mismo enlace.
+func TestWithChildFactsPPPoEAdoptaGlobalIPv6(t *testing.T) {
+	parent := ifaceStatus{Interface: "wan", Proto: "pppoe", L3Device: "pppoe-wan",
+		IPV6: []ubusIPv6{{Address: "fe80::1/64"}}}
+	child := ifaceStatus{Interface: "wan_6", Dynamic: true, Proto: "dhcpv6", L3Device: "pppoe-wan",
+		IPV6: []ubusIPv6{{Address: "2a0c:5a80:1234::9/64", Preferred: []byte("7200")}}}
+	got := withChildFacts(parent, []ifaceStatus{child})
+	if wan := wanInfoFrom(got); wan.IPv6 != "2a0c:5a80:1234::9" {
+		t.Fatalf("wan.ipv6=%q, esperaba la global del hijo dhcpv6", wan.IPv6)
 	}
 }