Some deserialization types have been updated on the common routes `ip
route ...` command. Update the filtering function accordingly.

Signed-off-by: Gabriel Goller <[email protected]>
---
 pve-rs/src/sdn/status.rs | 25 +++++++++++++++++--------
 1 file changed, 17 insertions(+), 8 deletions(-)

diff --git a/pve-rs/src/sdn/status.rs b/pve-rs/src/sdn/status.rs
index fc8c19bbcf53..81253732472e 100644
--- a/pve-rs/src/sdn/status.rs
+++ b/pve-rs/src/sdn/status.rs
@@ -150,9 +150,11 @@ pub fn get_routes(routes: RoutesParsed) -> 
Result<Vec<RouteStatus>, anyhow::Erro
             let mut route_belongs_to_fabric = false;
             for route in route_list {
                 for nexthop in &route.nexthops {
-                    if 
interface_names.contains(&nexthop.interface_name.as_str()) {
-                        route_belongs_to_fabric = true;
-                        break;
+                    if let Some(iface_name) = &nexthop.interface_name {
+                        if interface_names.contains(iface_name.as_str()) {
+                            route_belongs_to_fabric = true;
+                            break;
+                        }
                     }
                 }
                 if route_belongs_to_fabric {
@@ -166,8 +168,12 @@ pub fn get_routes(routes: RoutesParsed) -> 
Result<Vec<RouteStatus>, anyhow::Erro
                     for nexthop in &route.nexthops {
                         let via = if let Some(ip) = nexthop.ip {
                             ip.to_string()
+                        } else if let Some(iface_name) = 
&nexthop.interface_name {
+                            iface_name.clone()
+                        } else if let Some(true) = &nexthop.unreachable {
+                            "unreachable".to_string()
                         } else {
-                            nexthop.interface_name.clone()
+                            continue;
                         };
                         via_list.push(via);
                     }
@@ -314,10 +320,13 @@ pub fn get_status(routes: RoutesParsed) -> 
Result<HashMap<FabricId, Status>, any
         // determine status by checking if any routes exist for our interfaces
         let has_routes = all_routes.values().any(|v| {
             v.iter().any(|route| {
-                route
-                    .nexthops
-                    .iter()
-                    .any(|nexthop| 
interface_names.contains(&nexthop.interface_name.as_str()))
+                route.nexthops.iter().any(|nexthop| {
+                    if let Some(iface_name) = &nexthop.interface_name {
+                        interface_names.contains(iface_name.as_str())
+                    } else {
+                        false
+                    }
+                })
             })
         });
 
-- 
2.47.2



_______________________________________________
pve-devel mailing list
[email protected]
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to