Fix handling failed route lookups
authorMatt Corallo <git@bluematt.me>
Fri, 23 Aug 2019 01:14:53 +0000 (21:14 -0400)
committerMatt Corallo <git@bluematt.me>
Fri, 23 Aug 2019 03:42:07 +0000 (23:42 -0400)
src/bgp_client.rs

index cb33305d4e17bde8b2d318fa438fb89775ddf2f4..a890dad9cd72b227c5948461eefab5d2979899c8 100644 (file)
@@ -182,7 +182,7 @@ impl BGPClient {
                                .then(path_b.med.cmp(&path_a.med))
                });
                // TODO: Find last common ASN among all paths
-               *path_vecs[0].path.last().unwrap_or(&0)
+               *path_vecs.first().map(|route| route.path.last().unwrap_or(&0)).unwrap_or(&0)
        }
 
        pub fn disconnect(&self) {