From: Russell Bryant Date: Mon, 20 Apr 2015 16:56:07 +0000 (-0400) Subject: ovn-northd: Update Bindings for container integration. X-Git-Tag: v2.5.0~1123 X-Git-Url: http://git.cascardo.eti.br/?a=commitdiff_plain;h=48f42f3a9a9efef777894c82ada0c454c81e1435;p=cascardo%2Fovs.git ovn-northd: Update Bindings for container integration. ovn-northd updates the Bindings table of the OVN database when there are updates to the OVN_Northbound database. This update makes ovn-northd copy over the container integration related fields from OVN_Northbound into the Bindings table. Signed-off-by: Russell Bryant Acked-by: Justin Pettit Signed-off-by: Justin Pettit --- diff --git a/ovn/northd/ovn-northd.c b/ovn/northd/ovn-northd.c index 7e2df4364..0a2756ea6 100644 --- a/ovn/northd/ovn-northd.c +++ b/ovn/northd/ovn-northd.c @@ -114,6 +114,35 @@ macs_equal(char **binding_macs_, size_t b_n_macs, return (i == b_n_macs) ? true : false; } +static bool +parents_equal(const struct sbrec_bindings *binding, + const struct nbrec_logical_port *lport) +{ + if (!!binding->parent_port != !!lport->parent_name) { + /* One is set and the other is not. */ + return false; + } + + if (binding->parent_port) { + /* Both are set. */ + return strcmp(binding->parent_port, lport->parent_name) ? false : true; + } + + /* Both are NULL. */ + return true; +} + +static bool +tags_equal(const struct sbrec_bindings *binding, + const struct nbrec_logical_port *lport) +{ + if (binding->n_tag != lport->n_tag) { + return false; + } + + return binding->n_tag ? (binding->tag[0] == lport->tag[0]) : true; +} + /* * When a change has occurred in the OVN_Northbound database, we go through and * make sure that the contents of the Bindings table in the OVN_Southbound @@ -163,8 +192,7 @@ set_bindings(struct northd_context *ctx) if (binding) { /* We found an existing binding for this logical port. Update its - * contents. Right now the only thing we expect that could change - * is the list of MAC addresses. */ + * contents. */ hmap_remove(&bindings_hmap, &hash_node->node); free(hash_node); @@ -175,6 +203,12 @@ set_bindings(struct northd_context *ctx) sbrec_bindings_set_mac(binding, (const char **) lport->macs, lport->n_macs); } + if (!parents_equal(binding, lport)) { + sbrec_bindings_set_parent_port(binding, lport->parent_name); + } + if (!tags_equal(binding, lport)) { + sbrec_bindings_set_tag(binding, lport->tag, lport->n_tag); + } } else { /* There is no binding for this logical port, so create one. */ @@ -182,6 +216,10 @@ set_bindings(struct northd_context *ctx) sbrec_bindings_set_logical_port(binding, lport->name); sbrec_bindings_set_mac(binding, (const char **) lport->macs, lport->n_macs); + if (lport->parent_name && lport->n_tag > 0) { + sbrec_bindings_set_parent_port(binding, lport->parent_name); + sbrec_bindings_set_tag(binding, lport->tag, lport->n_tag); + } } } @@ -377,6 +415,8 @@ main(int argc, char *argv[]) ovsdb_idl_add_column(ovnsb_idl, &sbrec_bindings_col_logical_port); ovsdb_idl_add_column(ovnsb_idl, &sbrec_bindings_col_chassis); ovsdb_idl_add_column(ovnsb_idl, &sbrec_bindings_col_mac); + ovsdb_idl_add_column(ovnsb_idl, &sbrec_bindings_col_tag); + ovsdb_idl_add_column(ovnsb_idl, &sbrec_bindings_col_parent_port); /* * The loop here just runs the IDL in a loop waiting for the seqno to