[ovs-dev] [PATCH 3/3] auto-attach: Add auto-attach support to bridge layer and command set

drflynn at avaya.com drflynn at avaya.com
Fri Nov 14 12:42:09 UTC 2014


From: Dennis Flynn <drflynn at avaya.com>

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, unit tests, and
news and license notice files are also updated.

Signed-off-by: Ludovic Beliveau <ludovic.beliveau at windriver.com>
Signed-off-by: Dennis Flynn <drflynn at avaya.com>

diff --git a/NEWS b/NEWS
index 40a0db0..6a9bf0f 100644
--- a/NEWS
+++ b/NEWS
@@ -51,6 +51,9 @@ Post-v2.3.0
      with Docker, the wrapper script will be retired.
    - Added support for DPDK Tunneling. VXLAN and GRE are supported protocols.
      This is generic tunneling mechanism for userspace datapath.
+   - Initial support for the IETF Auto-Attach SPBM draft standard. This
+     contains rudimentary support for the LLDP protocol as needed for
+     Auto-Attach.
 
 
 v2.3.0 - 14 Aug 2014
diff --git a/NOTICE b/NOTICE
index a213190..dbbb707 100644
--- a/NOTICE
+++ b/NOTICE
@@ -25,3 +25,16 @@ Copyright (C) 2006-2013 Free Software Foundation, Inc.
 
 Rapid Spanning Tree Protocol (RSTP) implementation
 Copyright (c) 2011-2014 M3S, Srl - Italy
+
+LLDP implementation
+Copyright (c) 2008, 2012 Vincent Bernat <bernat at luffy.cx>
+
+LLDP includes code used from the Net::CDP project based on the ISC license
+Copyright (c) 2014 Michael Chapman
+
+LLDP includes code used from the ladvd project based on the ISC license
+Copyright (c) 2008, 2009, 2010 Sten Spans <sten at blinkenlights.nl>
+
+Auto Attach implementation
+Copyright (c) 2014 WindRiver, Inc
+Copyright (c) 2014 Avaya, Inc
diff --git a/debian/copyright.in b/debian/copyright.in
index 811a378..86978cc 100644
--- a/debian/copyright.in
+++ b/debian/copyright.in
@@ -17,6 +17,10 @@ Upstream Copyright Holders:
 	Copyright (C) 2000 The NetBSD Foundation, Inc.
 	Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
 	Copyright (c) 1982, 1986, 1990, 1993 The Regents of the University of California.
+	Copyright (c) 2008, 2012 Vincent Bernat <bernat at luffy.cx>
+	Copyright (c) 2014 Michael Chapman
+	Copyright (c) 2014 WindRiver, Inc.
+	Copyright (c) 2014 Avaya, Inc.
 
 License:
 
@@ -204,6 +208,20 @@ License:
     gives unlimited permission to copy and/or distribute it,
     with or without modifications, as long as this notice is preserved.
 
+* The following files are licensed under the ISC-license
+
+    lib/aa-structs.h
+    lib/lldpd.h
+    lib/lldpd-structs.h
+    lib/lldp-tlv.h
+    lib/ovs-lldp.c
+    lib/lldpd.c
+    lib/lldp.c
+    lib/ovs-lldp.h
+    lib/lldpd-structs.c
+    lib/lldp-const.h
+    lib/marshal.h
+
 * All other components of this package are licensed under
   The Apache License Version 2.0.
 
diff --git a/tests/ovs-vsctl.at b/tests/ovs-vsctl.at
index efe7817..efab274 100644
--- a/tests/ovs-vsctl.at
+++ b/tests/ovs-vsctl.at
@@ -645,6 +645,7 @@ AT_CHECK([${PERL} $srcdir/uuidfilt.pl out1 out2], [0],
 
 
 _uuid               : <0>
+auto_attach         : []
 controller          : []
 datapath_id         : []
 datapath_type       : ""
@@ -1144,6 +1145,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-vsctl.8.in b/utilities/ovs-vsctl.8.in
index 8cf13ae..fa67942 100644
--- a/utilities/ovs-vsctl.8.in
+++ b/utilities/ovs-vsctl.8.in
@@ -446,7 +446,7 @@ Prints the SSL configuration.
 Deletes the current SSL configuration.
 .
 .IP "[\fB\-\-bootstrap\fR] \fBset\-ssl\fR \fIprivate-key\fR \fIcertificate\fR \fIca-cert\fR"
-Sets the SSL configuration.  The \fB\-\-bootstrap\fR option is described 
+Sets the SSL configuration.  The \fB\-\-bootstrap\fR option is described
 below.
 .
 .ST "CA Certificate Bootstrap"
@@ -469,6 +469,26 @@ 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.  Auto Attach
+configuration.  The IETF Auto-Attach SPBM draft standard describes a compact
+method of using IEEE 802.1AB Link Layer Discovery Protocol (LLDP) together with
+a IEEE 802.1aq Shortest Path Bridging (SPB) network to automatically attach
+network devices to individual services in a SPB network.  The intent here is to
+allow network applications and devices using OVS to be able to easily take
+advantage of features offered by industry standard SPB networks.
+.
+.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 +552,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,
@@ -805,7 +827,7 @@ Create a new bridge named br0 and add port eth0 to it:
 .B "ovs\-vsctl add\-port br0 eth0"
 .PP
 Alternatively, perform both operations in a single atomic transaction:
-.IP 
+.IP
 .B "ovs\-vsctl add\-br br0 \-\- add\-port br0 eth0"
 .PP
 Delete bridge \fBbr0\fR, reporting an error if it does not exist:
diff --git a/utilities/ovs-vsctl.c b/utilities/ovs-vsctl.c
index 8ac6d10..0189592 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,7 @@ 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);
+    ovsdb_idl_add_column(ctx->idl, &ovsrec_bridge_col_auto_attach);
 
     ovsdb_idl_add_column(ctx->idl, &ovsrec_port_col_name);
     ovsdb_idl_add_column(ctx->idl, &ovsrec_port_col_fake_bridge);
@@ -1032,6 +1038,8 @@ 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);
+
+    ovsdb_idl_add_column(ctx->idl, &ovsrec_autoattach_col_mappings);
     ovsdb_idl_add_column(ctx->idl, &ovsrec_interface_col_ofport);
 }
 
@@ -1644,6 +1652,7 @@ cmd_add_br(struct vsctl_context *ctx)
 
     if (!parent_name) {
         struct ovsrec_port *port;
+        struct ovsrec_autoattach *aa;
         struct ovsrec_bridge *br;
 
         iface = ovsrec_interface_insert(ctx->txn);
@@ -1654,9 +1663,12 @@ cmd_add_br(struct vsctl_context *ctx)
         ovsrec_port_set_name(port, br_name);
         ovsrec_port_set_interfaces(port, &iface, 1);
 
+        aa = ovsrec_autoattach_insert(ctx->txn);
+
         br = ovsrec_bridge_insert(ctx->txn);
         ovsrec_bridge_set_name(br, br_name);
         ovsrec_bridge_set_ports(br, &port, 1);
+        ovsrec_bridge_set_auto_attach(br, aa);
 
         ovs_insert_bridge(ctx->ovs, br);
     } else {
@@ -2506,6 +2518,175 @@ cmd_set_ssl(struct vsctl_context *ctx)
 
     ovsrec_open_vswitch_set_ssl(ctx->ovs, ssl);
 }
+
+static void
+autoattach_insert_mapping(struct ovsrec_autoattach *aa,
+                          int64_t isid,
+                          int64_t vlan)
+{
+    int64_t *key_mappings, *value_mappings;
+    size_t i;
+
+    key_mappings = xmalloc(sizeof *aa->key_mappings * (aa->n_mappings + 1));
+    value_mappings = xmalloc(sizeof *aa->value_mappings * (aa->n_mappings + 1));
+
+    for (i = 0; i < aa->n_mappings; i++) {
+		key_mappings[i] = aa->key_mappings[i];
+		value_mappings[i] = aa->value_mappings[i];
+    }
+    key_mappings[aa->n_mappings] = isid;
+    value_mappings[aa->n_mappings] = vlan;
+
+	ovsrec_autoattach_set_mappings(aa, key_mappings, value_mappings,
+                                   aa->n_mappings + 1);
+
+    free(key_mappings);
+    free(value_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) {
+		autoattach_insert_mapping(br->br_cfg->auto_attach, isid, vlan);
+	}
+}
+
+static void
+del_aa_mapping(struct ovsrec_autoattach *aa,
+               int64_t isid,
+               int64_t vlan)
+{
+    int64_t *key_mappings, *value_mappings;
+    size_t i, n;
+
+    key_mappings = xmalloc(sizeof *aa->key_mappings * (aa->n_mappings));
+    value_mappings = xmalloc(sizeof *value_mappings * (aa->n_mappings));
+
+    for (i = n = 0; i < aa->n_mappings; i++) {
+        if (aa->key_mappings[i] != isid && aa->value_mappings[i] != vlan) {
+            key_mappings[n] = aa->key_mappings[i];
+            value_mappings[n++] = aa->value_mappings[i];
+        }
+    }
+
+	ovsrec_autoattach_set_mappings(aa, key_mappings, value_mappings, n);
+
+    free(key_mappings);
+    free(value_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->key_mappings &&
+        br->br_cfg->auto_attach->value_mappings) {
+		size_t i;
+
+		for (i = 0; i < br->br_cfg->auto_attach->n_mappings; i++) {
+			if (br->br_cfg->auto_attach->key_mappings[i] == isid &&
+                br->br_cfg->auto_attach->value_mappings[i] == vlan) {
+				del_aa_mapping(br->br_cfg->auto_attach, isid, vlan);
+                break;
+			}
+		}
+	}
+}
+
+static void
+pre_aa_mapping(struct vsctl_context *ctx)
+{
+    pre_get_info(ctx);
+
+    ovsdb_idl_add_column(ctx->idl, &ovsrec_autoattach_col_mappings);
+}
+
+static void
+verify_auto_attach(struct ovsrec_bridge *bridge)
+{
+	if (bridge) {
+		ovsrec_bridge_verify_auto_attach(bridge);
+
+		if (bridge->auto_attach) {
+			ovsrec_autoattach_verify_mappings(bridge->auto_attach);
+		}
+	}
+}
+
+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->key_mappings &&
+        br->br_cfg->auto_attach->value_mappings) {
+		size_t i;
+
+		for (i = 0; i < br->br_cfg->auto_attach->n_mappings; i++) {
+			ds_put_format(&ctx->output, "%ld %ld\n",
+                          (long int) br->br_cfg->auto_attach->key_mappings[i],
+                          (long int) br->br_cfg->auto_attach->value_mappings[i]);
+		}
+	}
+}
+
 
 /* Parameter commands. */
 
@@ -2585,6 +2766,12 @@ static const struct vsctl_table_class tables[] = {
       {&ovsrec_table_flow_sample_collector_set, NULL,
        &ovsrec_flow_sample_collector_set_col_ipfix}}},
 
+    {&ovsrec_table_autoattach,
+     {{&ovsrec_table_bridge,
+       &ovsrec_bridge_col_name,
+       &ovsrec_bridge_col_auto_attach},
+      {NULL, NULL, NULL}}},
+
     {&ovsrec_table_flow_sample_collector_set,
      {{NULL, NULL, NULL},
       {NULL, NULL, NULL}}},
@@ -4294,6 +4481,11 @@ 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},
 
+    /* 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},
+
     /* 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 33d8d6a..09328be 100644
--- a/vswitchd/bridge.c
+++ b/vswitchd/bridge.c
@@ -33,6 +33,7 @@
 #include "jsonrpc.h"
 #include "lacp.h"
 #include "list.h"
+#include "ovs-lldp.h"
 #include "mac-learning.h"
 #include "mcast-snooping.h"
 #include "meta-flow.h"
@@ -127,6 +128,9 @@ struct bridge {
     /* Port mirroring. */
     struct hmap mirrors;        /* "struct mirror" indexed by UUID. */
 
+    /* Auto Attach */
+    struct hmap mappings;       /* "struct" indexed by UUID */
+
     /* Used during reconfiguration. */
     struct shash wanted_ports;
 
@@ -136,6 +140,14 @@ struct bridge {
     struct ovsrec_interface *synth_local_ifacep;
 };
 
+struct aa_mapping {
+    struct hmap_node hmap_node; /* In struct bridge's "mappings" hmap. */
+    struct bridge *bridge;
+    int64_t isid;
+    int64_t vlan;
+    char *br_name;
+};
+
 /* All bridges, indexed by name. */
 static struct hmap all_bridges = HMAP_INITIALIZER(&all_bridges);
 
@@ -194,6 +206,12 @@ static bool status_txn_try_again;
 static int stats_timer_interval;
 static long long int stats_timer = LLONG_MIN;
 
+/* 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;
+
 /* 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
@@ -234,6 +252,9 @@ 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 *);
+static void bridge_configure_aa(struct bridge *);
+static void bridge_aa_refresh_queued(struct bridge *);
+static bool bridge_aa_need_refresh(struct bridge *);
 static void bridge_configure_remotes(struct bridge *,
                                      const struct sockaddr_in *managers,
                                      size_t n_managers);
@@ -394,7 +415,8 @@ bridge_init(const char *remote)
     ovsdb_idl_omit_alert(idl, &ovsrec_port_col_statistics);
     ovsdb_idl_omit_alert(idl, &ovsrec_port_col_bond_active_slave);
     ovsdb_idl_omit(idl, &ovsrec_port_col_external_ids);
-
+    ovsdb_idl_omit_alert(idl, &ovsrec_port_col_trunks);
+    ovsdb_idl_omit_alert(idl, &ovsrec_port_col_vlan_mode);
     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);
@@ -454,6 +476,7 @@ bridge_init(const char *remote)
     cfm_init();
     ovs_numa_init();
     stp_init();
+    lldp_init();
     rstp_init();
 }
 
@@ -633,6 +656,8 @@ 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);
+                ofproto_port_set_lldp(br->ofproto, iface->ofp_port,
+                                      &iface->cfg->lldp);
             }
         }
         bridge_configure_mirrors(br);
@@ -647,6 +672,7 @@ bridge_reconfigure(const struct ovsrec_open_vswitch *ovs_cfg)
         bridge_configure_rstp(br);
         bridge_configure_tables(br);
         bridge_configure_dp_desc(br);
+        bridge_configure_aa(br);
     }
     free(managers);
 
@@ -2747,6 +2773,24 @@ run_status_update(void)
             }
         }
     }
+
+    /* Refresh AA port status if necessary. */
+    if (time_msec() >= aa_refresh_timer) {
+        struct bridge *br;
+
+        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;
+    }
 }
 
 static void
@@ -3083,6 +3127,7 @@ bridge_create(const struct ovsrec_bridge *br_cfg)
     hmap_init(&br->iface_by_name);
     hmap_init(&br->mirrors);
 
+    hmap_init(&br->mappings);
     hmap_insert(&all_bridges, &br->node, hash_string(br->name, 0));
 }
 
@@ -3106,6 +3151,7 @@ bridge_destroy(struct bridge *br)
         hmap_destroy(&br->ports);
         hmap_destroy(&br->iface_by_name);
         hmap_destroy(&br->mirrors);
+        hmap_destroy(&br->mappings);
         free(br->name);
         free(br->type);
         free(br);
@@ -3630,6 +3676,229 @@ bridge_configure_dp_desc(struct bridge *br)
     ofproto_set_dp_desc(br->ofproto,
                         smap_get(&br->cfg->other_config, "dp-desc"));
 }
+
+static struct aa_mapping *
+bridge_aa_mapping_find(struct bridge *br, const int64_t isid)
+{
+    struct aa_mapping *m;
+
+    HMAP_FOR_EACH_IN_BUCKET (m, hmap_node, hash_bytes(&isid, sizeof(isid), 0),
+                             &br->mappings) {
+        if (isid == m->isid) {
+            return m;
+        }
+    }
+    return NULL;
+}
+
+static struct aa_mapping *
+bridge_aa_mapping_create(struct bridge *br,
+                         const int64_t isid,
+                         const int64_t vlan)
+{
+    struct aa_mapping *m;
+
+    m = xzalloc(sizeof *m);
+    m->bridge = br;
+    m->isid = isid;
+    m->vlan = vlan;
+    m->br_name = xstrdup(br->name);
+    hmap_insert(&br->mappings, &m->hmap_node,
+                hash_bytes(&isid, sizeof(isid), 0));
+
+    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 aa_mapping_settings s;
+
+    s.isid = m->isid;
+    s.vlan = m->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.system_description = br->cfg->auto_attach->system_description;
+        aa_s.system_name = br->cfg->auto_attach->system_name;
+        ofproto_set_aa(br->ofproto, NULL, &aa_s);
+
+        mc = ovsrec_autoattach_get_mappings(br->cfg->auto_attach,
+                                            OVSDB_TYPE_INTEGER,
+                                            OVSDB_TYPE_INTEGER);
+        HMAP_FOR_EACH_SAFE (m, next, hmap_node, &br->mappings) {
+            union ovsdb_atom atom;
+
+            atom.integer = m->isid;
+            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 aa_mapping *m =
+                bridge_aa_mapping_find(br,
+                                       br->cfg->auto_attach->key_mappings[i]);
+
+            if (!m) {
+                VLOG_INFO("Adding isid=%ld, vlan=%ld",
+                          br->cfg->auto_attach->key_mappings[i],
+                          br->cfg->auto_attach->value_mappings[i]);
+                m = bridge_aa_mapping_create(br,
+                                             br->cfg->auto_attach->key_mappings[i],
+                                             br->cfg->auto_attach->value_mappings[i]);
+                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);
+}
+
 
 /* Port functions. */
 
diff --git a/vswitchd/vswitch.ovsschema b/vswitchd/vswitch.ovsschema
index 196c33c..4898b16 100644
--- a/vswitchd/vswitch.ovsschema
+++ b/vswitchd/vswitch.ovsschema
@@ -1,6 +1,6 @@
 {"name": "Open_vSwitch",
- "version": "7.11.1",
- "cksum": "1038213587 21518",
+ "version": "7.11.2",
+ "cksum": "320332148 22294",
  "tables": {
    "Open_vSwitch": {
      "columns": {
@@ -118,7 +118,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": {
@@ -274,6 +278,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": {
@@ -580,4 +587,18 @@
        "external_ids": {
          "type": {"key": "string", "value": "string",
                   "min": 0, "max": "unlimited"}}},
-     "maxRows": 1}}}
+     "maxRows": 1},
+   "AutoAttach": {
+     "columns": {
+       "system_name": {
+         "type": "string"},
+       "system_description": {
+         "type": "string"},
+       "mappings": {
+         "type": {"key": {"type": "integer",
+                          "minInteger": 0,
+                          "maxInteger": 16777215},
+                  "value": {"type": "integer",
+                          "minInteger": 0,
+                          "maxInteger": 4095},
+                  "min": 0, "max": "unlimited"}}}}}}
diff --git a/vswitchd/vswitch.xml b/vswitchd/vswitch.xml
index 7101a66..52bc43a 100644
--- a/vswitchd/vswitch.xml
+++ b/vswitchd/vswitch.xml
@@ -506,6 +506,10 @@
           a different type of mirror instead.
         </p>
       </column>
+
+      <column name="auto_attach">
+        Auto Attach configuration.
+      </column>
     </group>
 
     <group title="OpenFlow Configuration">
@@ -2798,6 +2802,17 @@
       </column>
     </group>
 
+    <group title="Auto Attach Configuration">
+	  <p>
+	    Auto Attach configuration for a particular interface.
+	  </p>
+
+	  <column name="lldp" key="enable" type='{"type": "boolean"}'>
+          True to enable LLDP on this <ref table="Interface"/>.  If not
+          specified, LLDP will be disabled by default.
+	  </column>
+    </group>
+
     <group title="Common Columns">
       The overall purpose of these columns is described under <code>Common
       Columns</code> at the beginning of this document.
@@ -4352,4 +4367,53 @@
     </group>
   </table>
 
+  <table name="AutoAttach">
+    <p>Auto Attach configuration within a bridge.  The IETF Auto-Attach SPBM
+       draft standard describes a compact method of using IEEE 802.1AB Link
+       Layer Discovery Protocol (LLDP) together with a IEEE 802.1aq Shortest
+       Path Bridging (SPB) network to automatically attach network devices
+       to individual services in a SPB network.  The intent here is to allow
+       network applications and devices using OVS to be able to easily take
+       advantage of features offered by industry standard SPB networks.</p>
+
+    <p>Auto Attach (AA) uses LLDP to communicate between a directly connected
+       Auto Attach Client (AAC) and Auto Attach Server (AAS). The LLDP protocol
+       is extended to add two new Type-Length-Value tuples (TLVs). The first
+       new TLV supports the ongoing discovery of directly connected AA
+       correspondents. Auto Attach operates by regularly transmitting AA
+       discovery TLVs between the AA client and AA server. By exchanging these
+       discovery messages, both the AAC and AAS learn the system name and
+       system description of their peer. In the OVS context, OVS operates as
+       the AA client and the AA server resides on a switch at the edge of the
+       SPB network.</p>
+
+     <p>Once AA discovery has been completed the AAC then uses the
+       second new TLV to deliver identifier mappings from the AAC to the AAS. A primary
+       feature of Auto Attach is to facilitate the mapping of VLANs defined
+       outside the SPB network onto service ids (ISIDs) defined within the SPM
+       network. By doing so individual external VLANs can be mapped onto
+       specific SPB network services. These VLAN id to ISID mappings can be
+       configured and managed locally using new options added to the ovs-vsctl
+       command.</p>
+
+    <p>The Auto Attach OVS feature does not provide a full implementation of
+       the LLDP protocol. Support for the mandatory TLVs as defined by the LLDP
+       standard and support for the AA TLV extensions is provided. LLDP
+       protocol support in OVS can be enabled or disabled on a port by port
+       basis. LLDP support is disabled by default.</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>
+
+    <column name="mappings">
+      A mapping from SPB network Individual Service Identifier (ISID) to VLAN id.
+    </column>
+  </table>
 </database>
-- 
1.7.12.4




More information about the dev mailing list