> On Feb 11, 2016, at 5:18 PM, Ramu Ramamurthy <[email protected]>
> wrote:
>
> @@ -65,6 +66,8 @@ get_local_iface_ids(const struct ovsrec_bridge *br_int,
> struct shash *lports)
>
> for (j = 0; j < port_rec->n_interfaces; j++) {
> const struct ovsrec_interface *iface_rec;
> + const char *zone;
> + int zone_id;
>
> iface_rec = port_rec->interfaces[j];
> iface_id = smap_get(&iface_rec->external_ids, "iface-id");
> @@ -72,13 +75,65 @@ get_local_iface_ids(const struct ovsrec_bridge *br_int,
> struct shash *lports)
> continue;
> }
> shash_add(lports, iface_id, iface_rec);
> + zone = smap_get(&iface_rec->external_ids, "ovn-zone-id");
It would be good to document "ovn-zone-id" in the "OPEN VSWITCH DATABASE USAGE"
section of the ovn-controller man page.
> +static void
> +update_local_zone_ids(const struct ovsrec_bridge *br_int, struct simap
> *ct_zones,
> + struct controller_ctx *ctx)
> +{
> + int i;
> +
> + if (!ctx->ovs_idl_txn || !br_int) {
> + return;
> + }
> +
> + for (i = 0; i < br_int->n_ports; i++) {
> + const struct ovsrec_port *port_rec = br_int->ports[i];
> + int j;
> +
> + if (!strcmp(port_rec->name, br_int->name)) {
> + continue;
> + }
> +
> + for (j = 0; j < port_rec->n_interfaces; j++) {
> + const struct ovsrec_interface *iface_rec;
> + const char *iface_id;
> + struct smap new;
> + int zone_id;
> + char zone[12];
> +
> + iface_rec = port_rec->interfaces[j];
> + iface_id = smap_get(&iface_rec->external_ids, "iface-id");
> +
> + if (!iface_id ||
> + smap_get(&iface_rec->external_ids, "ovn-zone-id") ||
> + !simap_contains(ct_zones, iface_id)) {
> + continue;
> + }
> +
> + zone_id = simap_get(ct_zones, iface_id);
> + snprintf(zone, sizeof zone, "%d", zone_id);
> + smap_clone(&new, &iface_rec->external_ids);
> + smap_replace(&new, "ovn-zone-id", zone);
> + ovsrec_interface_verify_external_ids(iface_rec);
> + ovsrec_interface_set_external_ids(iface_rec, &new);
> + smap_destroy(&new);
> }
> }
> }
>
> static void
> update_ct_zones(struct sset *lports, struct simap *ct_zones,
> - unsigned long *ct_zone_bitmap)
> + unsigned long *ct_zone_bitmap,
> + const struct ovsrec_bridge *br_int,
> + struct controller_ctx *ctx)
> {
> struct simap_node *ct_zone, *ct_zone_next;
> const char *iface_id;
> @@ -119,6 +174,7 @@ update_ct_zones(struct sset *lports, struct simap
> *ct_zones,
> * xxx zone, but we need a generic interface to the conntrack
> * xxx table. */
> }
> + update_local_zone_ids(br_int, ct_zones, ctx);
Is it possible to remove update_local_zone_ids()? It gets run every time
through binding_run() and it just goes through all the interfaces on the system
to see if any don't have "ovn-zone-id" and then sets them. There's a call to
get_local_iface_ids() in binding_run() that should retrieve all the existing
zone ids from the interface records. The only additions I can think of are
coming from update_ct_zones() which is allocating and assigning the zone ids.
Couldn't we just set "ovn-zone-id" there?
This will be a nice addition. Don't forget to add yourself to AUTHORS, also.
--Justin
_______________________________________________
dev mailing list
[email protected]
http://openvswitch.org/mailman/listinfo/dev