- // TODO: Find last common ASN among all paths
- *path_vecs.first().map(|route| route.path.last().unwrap_or(&0)).unwrap_or(&0)
+
+ let primary_route = path_vecs.pop().unwrap();
+ 'asn_candidates: for asn in primary_route.path.iter().rev() {
+ for secondary_route in path_vecs.iter() {
+ if !secondary_route.path.contains(asn) {
+ continue 'asn_candidates;
+ }
+ }
+ return *asn;
+ }
+ *primary_route.path.last().unwrap_or(&0)