This is the final commit in the series of commits that deliver initial support for Auto-Attach. Specifically this commit delivers auto-attach support to the OVS bridge layer as well as the new auto-attach commands. The OVSDB schema is modified to define the new auto-attach entries. The man pages and unit tests are also updated.
diff --git a/tests/ovs-vsctl.at b/tests/ovs-vsctl.at index 864c382..6aed078 100644 --- a/tests/ovs-vsctl.at +++ b/tests/ovs-vsctl.at @@ -643,6 +643,7 @@ AT_CHECK([${PERL} $srcdir/uuidfilt.pl out1 out2], [0], [[<0> _uuid : <0> +auto_attach : [] controller : [] datapath_id : [] datapath_type : "" @@ -1141,6 +1142,7 @@ AT_CHECK([RUN_OVS_VSCTL([--id=@br0 create Bridge name=br0 -- add Open_vSwitch . AT_CHECK([${PERL} $srcdir/uuidfilt.pl stdout], [0], [[<0> _uuid : <1> +auto_attach : [] controller : [] datapath_id : [] datapath_type : "" diff --git a/utilities/ovs-ctl.in b/utilities/ovs-ctl.in index 6d2e938..2dc4fad 100755 --- a/utilities/ovs-ctl.in +++ b/utilities/ovs-ctl.in @@ -71,6 +71,10 @@ create_db () { action "Creating empty database $DB_FILE" ovsdb_tool create "$DB_FILE" "$DB_SCHEMA" } +remove_db () { + action "Removing database $DB_FILE" rm "$DB_FILE" +} + upgrade_db () { schemaver=`ovsdb_tool schema-version "$DB_SCHEMA"` if test ! -e "$DB_FILE"; then @@ -458,6 +462,10 @@ restart () { restore_interfaces || true } +reset () { + remove_db +} + ## --------------- ## ## enable-protocol ## ## --------------- ## @@ -708,6 +716,9 @@ case $command in restart) restart ;; + reset) + reset + ;; status) rc=0 for daemon in `daemons`; do diff --git a/utilities/ovs-vsctl.8.in b/utilities/ovs-vsctl.8.in index 8cf13ae..a377863 100644 --- a/utilities/ovs-vsctl.8.in +++ b/utilities/ovs-vsctl.8.in @@ -469,6 +469,20 @@ This option is only useful if the controller sends its CA certificate as part of the SSL certificate chain. The SSL protocol does not require the controller to send the CA certificate. . +.SS "Auto Attach Commands" +. +These commands manage the Auto Attach I-SID/VLAN mappings. +. +.IP "\fBadd\-aa\-mapping \fIbridge i-sid vlan\fR" +Creates a new Auto Attach mapping on \fIbridge\fR for \fIi-sid\fR +and \fIvlan\fR. +. +.IP "\fBdel\-aa\-mapping \fIbridge i-sid vlan\fR" +Deletes an Auto Attach mapping on \fIbridge\fR for \fIi-sid\fR +and \fIvlan\fR. +.IP "\fBget\-aa\-mapping \fIbridge\fR" +Lists all of the Auto Attach mappings within \fIbridge\fR on standard output. +. .SS "Database Commands" . These commands query and modify the contents of \fBovsdb\fR tables. @@ -532,6 +546,8 @@ identified by bridge name. .IP "\fBFlow_Sample_Collector_Set\fR" An IPFIX exporter configuration attached to a bridge for sampling packets on a per-flow basis using OpenFlow \fBsample\fR actions. +.IP "\fBAutoAttach\fR" +Configuration for Auto Attach within a bridge. .PP Record names must be specified in full and with correct capitalization. Names of tables and columns are not case-sensitive, diff --git a/utilities/ovs-vsctl.c b/utilities/ovs-vsctl.c index 5cf12cf..4f3f36e 100644 --- a/utilities/ovs-vsctl.c +++ b/utilities/ovs-vsctl.c @@ -693,6 +693,11 @@ SSL commands:\n\ del-ssl delete the SSL configuration\n\ set-ssl PRIV-KEY CERT CA-CERT set the SSL configuration\n\ \n\ +Auto Attach commands:\n\ + add-aa-mapping BRIDGE I-SID VLAN add Auto Attach mapping to BRIDGE\n\ + del-aa-mapping BRIDGE I-SID VLAN delete Auto Attach mapping VLAN from BRIDGE\n\ + get-aa-mapping BRIDGE get Auto Attach mappings from BRIDGE\n\ +\n\ Switch commands:\n\ emer-reset reset switch to known good state\n\ \n\ @@ -1025,6 +1030,9 @@ pre_get_info(struct vsctl_context *ctx) ovsdb_idl_add_column(ctx->idl, &ovsrec_bridge_col_controller); ovsdb_idl_add_column(ctx->idl, &ovsrec_bridge_col_fail_mode); ovsdb_idl_add_column(ctx->idl, &ovsrec_bridge_col_ports); +#ifdef ENABLE_AUTO_ATTACH + ovsdb_idl_add_column(ctx->idl, &ovsrec_bridge_col_auto_attach); +#endif ovsdb_idl_add_column(ctx->idl, &ovsrec_port_col_name); ovsdb_idl_add_column(ctx->idl, &ovsrec_port_col_fake_bridge); @@ -1032,6 +1040,10 @@ pre_get_info(struct vsctl_context *ctx) ovsdb_idl_add_column(ctx->idl, &ovsrec_port_col_interfaces); ovsdb_idl_add_column(ctx->idl, &ovsrec_interface_col_name); + +#ifdef ENABLE_AUTO_ATTACH + ovsdb_idl_add_column(ctx->idl, &ovsrec_autoattach_col_mappings); +#endif ovsdb_idl_add_column(ctx->idl, &ovsrec_interface_col_ofport); } @@ -1644,6 +1656,10 @@ cmd_add_br(struct vsctl_context *ctx) if (!parent_name) { struct ovsrec_port *port; + struct ovsrec_interface *iface; +#ifdef ENABLE_AUTO_ATTACH + struct ovsrec_autoattach *aa; +#endif struct ovsrec_bridge *br; iface = ovsrec_interface_insert(ctx->txn); @@ -1654,9 +1670,17 @@ cmd_add_br(struct vsctl_context *ctx) ovsrec_port_set_name(port, br_name); ovsrec_port_set_interfaces(port, &iface, 1); +#ifdef ENABLE_AUTO_ATTACH + aa = ovsrec_autoattach_insert(ctx->txn); + ovsrec_autoattach_set_enabled(aa, false); +#endif + br = ovsrec_bridge_insert(ctx->txn); ovsrec_bridge_set_name(br, br_name); ovsrec_bridge_set_ports(br, &port, 1); +#ifdef ENABLE_AUTO_ATTACH + ovsrec_bridge_set_auto_attach(br, aa); +#endif ovs_insert_bridge(ctx->ovs, br); } else { @@ -2506,6 +2530,208 @@ cmd_set_ssl(struct vsctl_context *ctx) ovsrec_open_vswitch_set_ssl(ctx->ovs, ssl); } + +#ifdef ENABLE_AUTO_ATTACH +static void +autoattach_insert_mapping(struct ovsrec_autoattach *aa, + struct ovsrec_autoattachmapping *mapping) +{ + struct ovsrec_autoattachmapping **mappings = 0; + size_t i = 0; + + mappings = xmalloc(sizeof *aa->mappings * (aa->n_mappings + 1)); + for (i = 0; i < aa->n_mappings; i++) { + mappings[i] = aa->mappings[i]; + } + mappings[aa->n_mappings] = mapping; + ovsrec_autoattach_set_mappings(aa, mappings, aa->n_mappings + 1); + free(mappings); +} + +static void +cmd_add_aa_mapping(struct vsctl_context *ctx) +{ + struct vsctl_bridge *br; + int64_t isid, vlan; + char *nptr = NULL; + + isid = strtoull(ctx->argv[2], &nptr, 10); + if (nptr == ctx->argv[2] || nptr == NULL) { + vsctl_fatal("Invalid argument %s", ctx->argv[2]); + return; + } + + vlan = strtoull(ctx->argv[3], &nptr, 10); + if (nptr == ctx->argv[3] || nptr == NULL) { + vsctl_fatal("Invalid argument %s", ctx->argv[3]); + return; + } + + vsctl_context_populate_cache(ctx); + + br = find_bridge(ctx, ctx->argv[1], true); + if (br->parent) { + br = br->parent; + } + + if (br && br->br_cfg) { + struct ovsrec_autoattachmapping *aamapping; + + aamapping = ovsrec_autoattachmapping_insert(ctx->txn); + ovsrec_autoattachmapping_set_isid(aamapping, &isid, 1); + ovsrec_autoattachmapping_set_vlan(aamapping, &vlan, 1); + + autoattach_insert_mapping(br->br_cfg->auto_attach, aamapping); + } +} + +static void +del_aa_mapping(struct ovsrec_bridge *br, + struct ovsrec_autoattachmapping *mapping) +{ + struct ovsrec_autoattachmapping **mappings; + size_t i, n; + + mappings = xmalloc(sizeof *br->auto_attach->mappings * + br->auto_attach->n_mappings); + for (i = n = 0; i < br->auto_attach->n_mappings; i++) { + if (br->auto_attach->mappings[i] != mapping) { + mappings[n++] = br->auto_attach->mappings[i]; + } + } + ovsrec_autoattach_set_mappings(br->auto_attach, mappings, n); + free(mappings); +} + +static void +cmd_del_aa_mapping(struct vsctl_context *ctx) +{ + struct vsctl_bridge *br; + int64_t isid, vlan; + char *nptr = NULL; + + isid = strtoull(ctx->argv[2], &nptr, 10); + if (nptr == ctx->argv[2] || nptr == NULL) { + vsctl_fatal("Invalid argument %s", ctx->argv[2]); + return; + } + + vlan = strtoull(ctx->argv[3], &nptr, 10); + if (nptr == ctx->argv[3] || nptr == NULL) { + vsctl_fatal("Invalid argument %s", ctx->argv[3]); + return; + } + + vsctl_context_populate_cache(ctx); + + br = find_bridge(ctx, ctx->argv[1], true); + if (br->parent) { + br = br->parent; + } + + if (br && br->br_cfg && br->br_cfg->auto_attach && + br->br_cfg->auto_attach->mappings) { + size_t i; + + for (i = 0; i < br->br_cfg->auto_attach->n_mappings; i++) { + struct ovsrec_autoattachmapping *mapping = + br->br_cfg->auto_attach->mappings[i]; + + if (*mapping->isid == isid && *mapping->vlan == vlan) { + del_aa_mapping(br->br_cfg, mapping); + + ovsrec_autoattachmapping_delete(mapping); + /* Freeing mapping can reesult in segmentation fault */ + /* free(mapping); */ + } + } + } +} + +static void +pre_aa_mapping(struct vsctl_context *ctx) +{ + pre_get_info(ctx); + + ovsdb_idl_add_column(ctx->idl, &ovsrec_autoattach_col_mappings); + ovsdb_idl_add_column(ctx->idl, &ovsrec_autoattachmapping_col_isid); + ovsdb_idl_add_column(ctx->idl, &ovsrec_autoattachmapping_col_vlan); +} + +static void +verify_auto_attach(struct ovsrec_bridge *bridge) +{ + if (bridge) { + size_t i; + + ovsrec_bridge_verify_auto_attach(bridge); + + if (bridge->auto_attach) { + ovsrec_autoattach_verify_mappings(bridge->auto_attach); + } + + for (i = 0; i < bridge->auto_attach->n_mappings; i++) { + struct ovsrec_autoattachmapping *mapping = + bridge->auto_attach->mappings[i]; + ovsrec_autoattachmapping_verify_isid(mapping); + ovsrec_autoattachmapping_verify_vlan(mapping); + } + } +} + +/* qsort comparison function. */ +static int +compare_mapping(const void *a_, const void *b_) +{ + const struct ovsrec_autoattachmapping *const *ap = a_; + const struct ovsrec_autoattachmapping *const *bp = b_; + const struct ovsrec_autoattachmapping *a = *ap; + const struct ovsrec_autoattachmapping *b = *bp; + + return *a->isid > *b->isid; +} + +static void +cmd_get_aa_mapping(struct vsctl_context *ctx) +{ + struct vsctl_bridge *br; + + vsctl_context_populate_cache(ctx); + + br = find_bridge(ctx, ctx->argv[1], true); + if (br->parent) { + br = br->parent; + } + + verify_auto_attach(br->br_cfg); + + if (br && br->br_cfg && br->br_cfg->auto_attach && + br->br_cfg->auto_attach->mappings) { + struct ovsrec_autoattachmapping **mappings; + size_t i; + + mappings = xmalloc(br->br_cfg->auto_attach->n_mappings * + sizeof *mappings); + + /* It might be safer to copy the original structure before the sort */ + for (i = 0; i < br->br_cfg->auto_attach->n_mappings; i++) { + mappings[i] = br->br_cfg->auto_attach->mappings[i]; + } + + qsort(mappings, br->br_cfg->auto_attach->n_mappings, sizeof *mappings, + compare_mapping); + + for (i = 0; i < br->br_cfg->auto_attach->n_mappings; i++) { + struct ovsrec_autoattachmapping *mapping = mappings[i]; + ds_put_format(&ctx->output, "%ld %ld\n", (long int) *mapping->isid, + (long int) *mapping->vlan); + } + + free(mappings); + } +} +#endif + /* Parameter commands. */ @@ -2585,6 +2811,14 @@ static const struct vsctl_table_class tables[] = { {&ovsrec_table_flow_sample_collector_set, NULL, &ovsrec_flow_sample_collector_set_col_ipfix}}}, +#ifdef ENABLE_AUTO_ATTACH + {&ovsrec_table_autoattach, + {{&ovsrec_table_bridge, + &ovsrec_bridge_col_name, + &ovsrec_bridge_col_auto_attach}, + {NULL, NULL, NULL}}}, +#endif + {&ovsrec_table_flow_sample_collector_set, {{NULL, NULL, NULL}, {NULL, NULL, NULL}}}, @@ -4294,6 +4528,13 @@ static const struct vsctl_command_syntax all_commands[] = { {"del-ssl", 0, 0, pre_cmd_del_ssl, cmd_del_ssl, NULL, "", RW}, {"set-ssl", 3, 3, pre_cmd_set_ssl, cmd_set_ssl, NULL, "--bootstrap", RW}, +#ifdef ENABLE_AUTO_ATTACH + /* Auto Attach commands. */ + {"add-aa-mapping", 3, 3, pre_get_info, cmd_add_aa_mapping, NULL, "", RW}, + {"del-aa-mapping", 3, 3, pre_aa_mapping, cmd_del_aa_mapping, NULL, "", RW}, + {"get-aa-mapping", 1, 1, pre_aa_mapping, cmd_get_aa_mapping, NULL, "", RO}, +#endif + /* Switch commands. */ {"emer-reset", 0, 0, pre_cmd_emer_reset, cmd_emer_reset, NULL, "", RW}, diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c index 1060719..0178561 100644 --- a/vswitchd/bridge.c +++ b/vswitchd/bridge.c @@ -33,6 +33,9 @@ #include "jsonrpc.h" #include "lacp.h" #include "list.h" +#ifdef ENABLE_AUTO_ATTACH +#include "ovs-lldp.h" +#endif #include "mac-learning.h" #include "mcast-snooping.h" #include "meta-flow.h" @@ -125,6 +128,10 @@ struct bridge { /* Port mirroring. */ struct hmap mirrors; /* "struct mirror" indexed by UUID. */ +#ifdef ENABLE_AUTO_ATTACH + /* Auto Attach */ + struct hmap mappings; /* "struct" indexed by UUID */ +#endif /* Used during reconfiguration. */ struct shash wanted_ports; @@ -134,6 +141,18 @@ struct bridge { struct ovsrec_interface *synth_local_ifacep; }; +#ifdef ENABLE_AUTO_ATTACH +struct aa_mapping { + struct uuid uuid; + struct hmap_node hmap_node; /* In struct bridge's "mappings" hmap. */ + struct bridge *bridge; + int64_t isid; + int64_t vlan; + char *br_name; + struct ovsrec_autoattachmapping *cfg; +}; +#endif + /* All bridges, indexed by name. */ static struct hmap all_bridges = HMAP_INITIALIZER(&all_bridges); @@ -192,6 +211,14 @@ static bool status_txn_try_again; static int stats_timer_interval; static long long int stats_timer = LLONG_MIN; +#ifdef ENABLE_AUTO_ATTACH +/* Each time this timer expires, the bridge fetches the list of port/VLAN + * membership that has been modified by the AA. + */ +#define AA_REFRESH_INTERVAL (1000) /* In milliseconds. */ +static long long int aa_refresh_timer = LLONG_MIN; +#endif + /* In some datapaths, creating and destroying OpenFlow ports can be extremely * expensive. This can cause bridge_reconfigure() to take a long time during * which no other work can be done. To deal with this problem, we limit port @@ -232,6 +259,11 @@ static void bridge_configure_stp(struct bridge *); static void bridge_configure_rstp(struct bridge *); static void bridge_configure_tables(struct bridge *); static void bridge_configure_dp_desc(struct bridge *); +#ifdef ENABLE_AUTO_ATTACH +static void bridge_configure_aa(struct bridge *); +static void bridge_aa_refresh_queued(struct bridge *); +static bool bridge_aa_need_refresh(struct bridge *); +#endif static void bridge_configure_remotes(struct bridge *, const struct sockaddr_in *managers, size_t n_managers); @@ -390,7 +422,10 @@ bridge_init(const char *remote) ovsdb_idl_omit_alert(idl, &ovsrec_port_col_rstp_statistics); ovsdb_idl_omit_alert(idl, &ovsrec_port_col_statistics); ovsdb_idl_omit(idl, &ovsrec_port_col_external_ids); - +#ifdef ENABLE_AUTO_ATTACH + ovsdb_idl_omit_alert(idl, &ovsrec_port_col_trunks); + ovsdb_idl_omit_alert(idl, &ovsrec_port_col_vlan_mode); +#endif ovsdb_idl_omit_alert(idl, &ovsrec_interface_col_admin_state); ovsdb_idl_omit_alert(idl, &ovsrec_interface_col_duplex); ovsdb_idl_omit_alert(idl, &ovsrec_interface_col_link_speed); @@ -450,6 +485,9 @@ bridge_init(const char *remote) cfm_init(); ovs_numa_init(); stp_init(); +#ifdef ENABLE_AUTO_ATTACH + lldp_init(); +#endif rstp_init(); } @@ -623,6 +661,10 @@ bridge_reconfigure(const struct ovsrec_open_vswitch *ovs_cfg) iface_set_mac(br, port, iface); ofproto_port_set_bfd(br->ofproto, iface->ofp_port, &iface->cfg->bfd); +#ifdef ENABLE_AUTO_ATTACH + ofproto_port_set_lldp(br->ofproto, iface->ofp_port, + &iface->cfg->lldp); +#endif } } bridge_configure_mirrors(br); @@ -637,6 +679,9 @@ bridge_reconfigure(const struct ovsrec_open_vswitch *ovs_cfg) bridge_configure_rstp(br); bridge_configure_tables(br); bridge_configure_dp_desc(br); +#ifdef ENABLE_AUTO_ATTACH + bridge_configure_aa(br); +#endif } free(managers); @@ -2821,6 +2866,26 @@ bridge_run(void) } } +#ifdef ENABLE_AUTO_ATTACH + /* Refresh AA port status if necessary. */ + if (time_msec() >= aa_refresh_timer) { + if (cfg) { + HMAP_FOR_EACH (br, node, &all_bridges) { + if (bridge_aa_need_refresh(br)) { + struct ovsdb_idl_txn *txn; + + txn = ovsdb_idl_txn_create(idl); + bridge_aa_refresh_queued(br); + ovsdb_idl_txn_commit(txn); + ovsdb_idl_txn_destroy(txn); + } + } + } + + aa_refresh_timer = time_msec() + AA_REFRESH_INTERVAL; + } +#endif + run_system_stats(); } @@ -3004,6 +3069,9 @@ bridge_create(const struct ovsrec_bridge *br_cfg) hmap_init(&br->iface_by_name); hmap_init(&br->mirrors); +#ifdef ENABLE_AUTO_ATTACH + hmap_init(&br->mappings); +#endif hmap_insert(&all_bridges, &br->node, hash_string(br->name, 0)); } @@ -3027,6 +3095,9 @@ bridge_destroy(struct bridge *br) hmap_destroy(&br->ports); hmap_destroy(&br->iface_by_name); hmap_destroy(&br->mirrors); +#ifdef ENABLE_AUTO_ATTACH + hmap_destroy(&br->mappings); +#endif free(br->name); free(br->type); free(br); @@ -3551,6 +3622,230 @@ bridge_configure_dp_desc(struct bridge *br) ofproto_set_dp_desc(br->ofproto, smap_get(&br->cfg->other_config, "dp-desc")); } + +#ifdef ENABLE_AUTO_ATTACH +static struct aa_mapping * +bridge_aa_mapping_find_by_uuid(struct bridge *br, const struct uuid *uuid) +{ + struct aa_mapping *m; + + HMAP_FOR_EACH_IN_BUCKET (m, hmap_node, uuid_hash(uuid), &br->mappings) { + if (uuid_equals(uuid, &m->uuid)) { + return m; + } + } + return NULL; +} + +static struct aa_mapping * +bridge_aa_mapping_create(struct bridge *br, + const struct ovsrec_autoattachmapping *cfg) +{ + struct aa_mapping *m; + + m = xzalloc(sizeof *m); + m->uuid = cfg->header_.uuid; + m->bridge = br; + /* cfg pointer is valid once it's returned from reconfigure. */ + m->isid = *cfg->isid; + m->vlan = *cfg->vlan; + m->br_name = xstrdup(br->name); + hmap_insert(&br->mappings, &m->hmap_node, uuid_hash(&m->uuid)); + + return m; +} + +static void +bridge_aa_mapping_destroy(struct aa_mapping *m) +{ + if (m) { + struct bridge *br = m->bridge; + + if (br->ofproto) { + ofproto_aa_mapping_unregister(br->ofproto, m); + } + + hmap_remove(&br->mappings, &m->hmap_node); + if (m->br_name) { + free(m->br_name); + } + free(m); + } +} + +static bool +bridge_aa_mapping_configure(struct aa_mapping *m) +{ + struct ovsrec_autoattachmapping *cfg = m->cfg; + struct aa_mapping_settings s; + + s.isid = *cfg->isid; + s.vlan = *cfg->vlan; + + /* Configure. */ + ofproto_aa_mapping_register(m->bridge->ofproto, m, &s); + + return true; +} + +static void +bridge_configure_aa(struct bridge *br) +{ + if (!br->cfg->auto_attach) { + ofproto_set_aa(br->ofproto, NULL, NULL); + return; + } + + if (br->cfg->auto_attach) { + const struct ovsdb_datum *mc; + struct aa_settings aa_s; + struct aa_mapping *m, *next; + size_t i; + + memset(&aa_s, 0, sizeof aa_s); + aa_s.enabled = br->cfg->auto_attach->enabled; + aa_s.system_description = br->cfg->auto_attach->system_description; + aa_s.system_name = br->cfg->auto_attach->system_name; + aa_s.authentication_key = br->cfg->auto_attach->authentication_key; + ofproto_set_aa(br->ofproto, NULL, &aa_s); + + mc = ovsrec_autoattach_get_mappings(br->cfg->auto_attach, + OVSDB_TYPE_UUID); + HMAP_FOR_EACH_SAFE (m, next, hmap_node, &br->mappings) { + union ovsdb_atom atom; + + atom.uuid = m->uuid; + if (ovsdb_datum_find_key(mc, &atom, OVSDB_TYPE_UUID) == UINT_MAX) { + VLOG_INFO("Deleting isid=%ld, vlan=%ld", m->isid, m->vlan); + bridge_aa_mapping_destroy(m); + } + } + + /* Add new mappings and reconfigure existing ones. */ + for (i = 0; i < br->cfg->auto_attach->n_mappings; ++i) { + struct ovsrec_autoattachmapping *cfg = + br->cfg->auto_attach->mappings[i]; + struct aa_mapping *m = + bridge_aa_mapping_find_by_uuid(br, &cfg->header_.uuid); + + if (!m) { + VLOG_INFO("Adding isid=%ld, vlan=%ld", *cfg->isid, *cfg->vlan); + m = bridge_aa_mapping_create(br, cfg); + m->cfg = cfg; + if (!bridge_aa_mapping_configure(m)) { + bridge_aa_mapping_destroy(m); + } + } + } + } +} + +static bool +bridge_aa_need_refresh(struct bridge *br) +{ + return ofproto_aa_vlan_get_queue_size(br->ofproto) > 0; +} + +static void +bridge_aa_update_trunks(struct port *port, struct bridge_aa_vlan *m) +{ + int64_t *trunks = 0; + unsigned int i = 0; + bool found = false, reconfigure = false; + + for (i = 0; i < port->cfg->n_trunks; i++) { + if (port->cfg->trunks[i] == m->vlan) { + found = true; + break; + } + } + + switch (m->oper) { + case BRIDGE_AA_VLAN_OPER_ADD: + if (!found) { + trunks = xmalloc(sizeof(*trunks) * (port->cfg->n_trunks + 1)); + + for (i = 0; i < port->cfg->n_trunks; i++) { + trunks[i] = port->cfg->trunks[i]; + } + trunks[i++] = m->vlan; + reconfigure = true; + } + + break; + + case BRIDGE_AA_VLAN_OPER_REMOVE: + if (found) { + unsigned int j = 0; + + trunks = xmalloc(sizeof(*trunks) * (port->cfg->n_trunks - 1)); + + for (i = 0; i < port->cfg->n_trunks; i++) { + if (port->cfg->trunks[i] != m->vlan) { + trunks[j++] = port->cfg->trunks[i]; + } + } + i = j; + reconfigure = true; + } + + break; + + case BRIDGE_AA_VLAN_OPER_UNDEF: + default: + VLOG_WARN("unrecognized operation %u", m->oper); + break; + } + + if (reconfigure) { + /* VLAN switching under trunk mode cause the trunk port to switch all + * VLANs, see ovs-vswitchd.conf.db + */ + if (i == 0) { + static char *vlan_mode_access = "access"; + ovsrec_port_set_vlan_mode(port->cfg, vlan_mode_access); + } + + if (i == 1) { + static char *vlan_mode_trunk = "trunk"; + ovsrec_port_set_vlan_mode(port->cfg, vlan_mode_trunk); + } + + ovsrec_port_set_trunks(port->cfg, trunks, i); + + /* Force reconfigure of the port. */ + port_configure(port); + } +} + +static void +bridge_aa_refresh_queued(struct bridge *br) +{ + struct list *list; + struct bridge_aa_vlan *node; + + ofproto_aa_vlan_get_queued(br->ofproto, &list); + + LIST_FOR_EACH(node, list_node, list) { + struct port *port; + + VLOG_INFO("ifname=%s, vlan=%u, oper=%u", node->port_name, node->vlan, + node->oper); + + port = port_lookup(br, node->port_name); + if (port) { + bridge_aa_update_trunks(port, node); + } + + list_remove(&node->list_node); + free(node->port_name); + free(node); + } + + free(list); +} +#endif + /* Port functions. */ diff --git a/vswitchd/vswitch.ovsschema b/vswitchd/vswitch.ovsschema index 3d78f1d..1bc9094 100644 --- a/vswitchd/vswitch.ovsschema +++ b/vswitchd/vswitch.ovsschema @@ -1,6 +1,6 @@ {"name": "Open_vSwitch", - "version": "7.9.0", - "cksum": "2301439325 21345", + "version": "7.9.1", + "cksum": "3263898173 22517", "tables": { "Open_vSwitch": { "columns": { @@ -116,7 +116,11 @@ "maxInteger": 254}, "value": {"type": "uuid", "refTable": "Flow_Table"}, - "min": 0, "max": "unlimited"}}}, + "min": 0, "max": "unlimited"}}, + "auto_attach": { + "type": {"key": {"type": "uuid", + "refTable": "AutoAttach"}, + "min": 0, "max": 1}}}, "indexes": [["name"]]}, "Port": { "columns": { @@ -269,6 +273,9 @@ "type": {"key": {"type": "boolean"}, "min": 0, "max": 1}, "ephemeral": true}, + "lldp": { + "type": {"key": "string", "value": "string", + "min": 0, "max": "unlimited"}}, "other_config": { "type": {"key": "string", "value": "string", "min": 0, "max": "unlimited"}}, "statistics": { @@ -575,4 +582,31 @@ "external_ids": { "type": {"key": "string", "value": "string", "min": 0, "max": "unlimited"}}}, - "maxRows": 1}}} + "maxRows": 1}, + "AutoAttach": { + "columns": { + "enabled": { + "type": "boolean"}, + "system_name": { + "type": "string"}, + "system_description": { + "type": "string"}, + "authentication_key": { + "type": "string"}, + "mappings": { + "type": {"key": {"type": "uuid", + "refTable": "AutoAttachMapping"}, + "min": 0, "max": "unlimited"}}}}, + "AutoAttachMapping": { + "columns": { + "isid": { + "type": {"key": {"type": "integer", + "minInteger": 0, + "maxInteger": 16777215}, + "min": 0, "max": 1}}, + "vlan": { + "type": {"key": {"type": "integer", + "minInteger": 0, + "maxInteger": 4095}, + "min": 0, "max": 1}}}, + "indexes": [["isid"]]}}} diff --git a/vswitchd/vswitch.xml b/vswitchd/vswitch.xml index d07d54f..678e4bf 100644 --- a/vswitchd/vswitch.xml +++ b/vswitchd/vswitch.xml @@ -478,6 +478,10 @@ a different type of mirror instead. </p> </column> + + <column name="auto_attach"> + Auto Attach configuration. + </column> </group> <group title="OpenFlow Configuration"> @@ -4225,4 +4229,30 @@ </group> </table> + <table name="AutoAttach"> + <p>Auto Attach configuration within a bridge.</p> + + <column name="system_name"> + The system_name string is exported in LLDP messages. It should uniquely + identify the bridge in the network. + </column> + + <column name="system_description"> + The system_description string is exported in LLDP messages. It should + describe the type of software and hardware. + </column> + </table> + + <table name="AutoAttachMapping"> + <p>Auto Attach Mapping configuration within a bridge. This table contains + all the i-sid/vlan mappings.</p> + + <column name="isid"> + The isid that is associated to a particular vlan. + </column> + + <column name="vlan"> + The vlan used to encapsulated traffic for a particular isid. + </column> + </table> </database> -- 1.7.12.4 _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev