]> mj.ucw.cz Git - jablonka.git/commitdiff
show-switch: Better error handling
authorMartin Mareš <mj@ucw.cz>
Fri, 21 Nov 2025 21:06:41 +0000 (22:06 +0100)
committerMartin Mareš <mj@ucw.cz>
Fri, 21 Nov 2025 21:06:41 +0000 (22:06 +0100)
show-switch

index 9dab19c7317dc074e0c2db19c9adf85d630a7b80..1079000896b1caf29f77b72d4875f1ad919148bf 100755 (executable)
@@ -155,7 +155,12 @@ my $port_table = my_get_table({
 print "# Switch ports:\n", Dumper($port_table) if $debug;
 
 for my $port (keys %$port_table) {
-       my $if = $if_table->{$port_table->{$port}->{ifindex}} or die "Port table refers to unknown iface";
+       my $ifi = $port_table->{$port}->{ifindex};
+       my $if = $if_table->{$ifi};
+       if (!$if) {
+               print STDERR "WARNING: Port $port refers to unknown ifindex $ifi\n";
+               next;
+       }
        $if->{switch_port} = $port;
 }