From: Ben Pfaff Date: Wed, 15 Jul 2009 18:05:37 +0000 (-0700) Subject: vswitchd: New unixctl command "fdb/show" to print the MAC learing table. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8c4c1387fdebb4b650a093340842ce2226e118af;p=openvswitch vswitchd: New unixctl command "fdb/show" to print the MAC learing table. To implement "brctl showmacs" for bridge compatibility, brcompatd needs to be able to extract the MAC learning table from ovs-vswitchd. This provides a way, and it may be directly useful to switch administrators also. --- diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c index 5d8a5b06..b0b2a8f1 100644 --- a/vswitchd/bridge.c +++ b/vswitchd/bridge.c @@ -206,6 +206,8 @@ static uint64_t bridge_pick_datapath_id(struct bridge *, const char *devname); static uint64_t dpid_from_hash(const void *, size_t nbytes); +static void bridge_unixctl_fdb_show(struct unixctl_conn *, const char *args); + static void bond_init(void); static void bond_run(struct bridge *); static void bond_wait(struct bridge *); @@ -280,6 +282,8 @@ bridge_init(void) bond_init(); + unixctl_command_register("fdb/show", bridge_unixctl_fdb_show); + for (i = 0; i < DP_MAX; i++) { struct dpif dpif; char devname[16]; @@ -788,6 +792,32 @@ bridge_flush(struct bridge *br) } } +/* Bridge unixctl user interface functions. */ +static void +bridge_unixctl_fdb_show(struct unixctl_conn *conn, const char *args) +{ + struct ds ds = DS_EMPTY_INITIALIZER; + const struct bridge *br; + + br = bridge_lookup(args); + if (!br) { + unixctl_command_reply(conn, 501, "no such bridge"); + return; + } + + ds_put_cstr(&ds, " port VLAN MAC Age\n"); + if (br->ml) { + const struct mac_entry *e; + LIST_FOR_EACH (e, struct mac_entry, lru_node, &br->ml->lrus) { + ds_put_format(&ds, "%5d %4d "ETH_ADDR_FMT" %3d\n", + e->port, e->vlan, ETH_ADDR_ARGS(e->mac), + mac_entry_age(e)); + } + } + unixctl_command_reply(conn, 200, ds_cstr(&ds)); + ds_destroy(&ds); +} + /* Bridge reconfiguration functions. */ static struct bridge *