vswitchd: Make "fdb/show" output more meaningful port numbers.
authorBen Pfaff <blp@nicira.com>
Thu, 16 Jul 2009 22:15:02 +0000 (15:15 -0700)
committerBen Pfaff <blp@nicira.com>
Thu, 16 Jul 2009 22:15:02 +0000 (15:15 -0700)
The "fdb/show" unixctl command was showing vswitch-internal port indexes,
which cannot be meaningfully interpreted by software outside vswitchd.
Also, they potentially change every time the vswitchd configuration file
changes.  This commit changes it to use a datapath port index instead,
which are both more meaningful and more stable.

vswitchd/bridge.c

index b0b2a8f11ab755dac8e669b3c3b45b6e8b3bbf74..6a82a031e138747c44d73a69d3c190b770cb9ba4 100644 (file)
@@ -809,9 +809,12 @@ bridge_unixctl_fdb_show(struct unixctl_conn *conn, const char *args)
     if (br->ml) {
         const struct mac_entry *e;
         LIST_FOR_EACH (e, struct mac_entry, lru_node, &br->ml->lrus) {
+            if (e->port < 0 || e->port >= br->n_ports) {
+                continue;
+            }
             ds_put_format(&ds, "%5d  %4d  "ETH_ADDR_FMT"  %3d\n",
-                          e->port, e->vlan, ETH_ADDR_ARGS(e->mac),
-                          mac_entry_age(e));
+                          br->ports[e->port]->ifaces[0]->dp_ifidx,
+                          e->vlan, ETH_ADDR_ARGS(e->mac), mac_entry_age(e));
         }
     }
     unixctl_command_reply(conn, 200, ds_cstr(&ds));