+
+ return 0;
+}
+
+static void
+send_ifindex_reply(uint32_t seq, struct svec *ifaces)
+{
+ struct ofpbuf *reply;
+ const char *iface;
+ size_t n_indices;
+ int *indices;
+ size_t i;
+
+ /* Make sure that any given interface only occurs once. This shouldn't
+ * happen, but who knows what people put into their configuration files. */
+ svec_sort_unique(ifaces);
+
+ /* Convert 'ifaces' into ifindexes. */
+ n_indices = 0;
+ indices = xmalloc(ifaces->n * sizeof *indices);
+ SVEC_FOR_EACH (i, iface, ifaces) {
+ int ifindex = if_nametoindex(iface);
+ if (ifindex) {
+ indices[n_indices++] = ifindex;
+ }
+ }
+
+ /* Compose and send reply. */
+ reply = compose_reply(seq, 0);
+ nl_msg_put_unspec(reply, BRC_GENL_A_IFINDEXES,
+ indices, n_indices * sizeof *indices);
+ send_reply(reply);
+
+ /* Free memory. */
+ free(indices);
+}
+
+static int
+handle_get_bridges_cmd(const struct ovsrec_open_vswitch *ovs,
+ struct ofpbuf *buffer)
+{
+ struct svec bridges;
+ size_t i, j;
+
+ uint32_t seq;
+
+ int error;
+
+ /* Parse Netlink command.
+ *
+ * The command doesn't actually have any arguments, but we need the
+ * sequence number to send the reply. */
+ error = parse_command(buffer, &seq, NULL, NULL, NULL, NULL);
+ if (error) {
+ return error;
+ }
+
+ /* Get all the real bridges and all the fake ones. */
+ svec_init(&bridges);
+ for (i = 0; i < ovs->n_bridges; i++) {
+ const struct ovsrec_bridge *br = ovs->bridges[i];
+
+ svec_add(&bridges, br->name);
+ for (j = 0; j < br->n_ports; j++) {
+ const struct ovsrec_port *port = br->ports[j];
+
+ if (port->fake_bridge) {
+ svec_add(&bridges, port->name);
+ }
+ }
+ }
+
+ send_ifindex_reply(seq, &bridges);
+ svec_destroy(&bridges);