[ovs-dev] [PATCH 6/6] rstp: Add the 'ovs-appctl rstp/show' command.

2017-03-31 Thread nickcooper-zhangtonghao
The rstp/show command will help users and developers to
get more details about rstp. This patch works together with
the previous patches.

Signed-off-by: nickcooper-zhangtonghao 
---
 NEWS   |   4 +-
 lib/rstp.c | 113 +++--
 lib/rstp.h |   2 +-
 vswitchd/ovs-vswitchd.8.in |  11 -
 4 files changed, 123 insertions(+), 7 deletions(-)

diff --git a/NEWS b/NEWS
index 00c9106..a28b8da 100644
--- a/NEWS
+++ b/NEWS
@@ -15,7 +15,9 @@ Post-v2.7.0
  "dot1q-tunnel" port VLAN mode.
- OVN:
  * Make the DHCPv4 router setting optional.
-   - Add the command 'ovs-appctl stp/show' (see ovs-vswitchd(8)).
+   - STP/RSTP
+ * Add the command 'ovs-appctl stp/show' and 'ovs-appctl rstp/show'
+   (see ovs-vswitchd(8)).
 
 v2.7.0 - 21 Feb 2017
 -
diff --git a/lib/rstp.c b/lib/rstp.c
index b942f6e..7a4f1ea 100644
--- a/lib/rstp.c
+++ b/lib/rstp.c
@@ -120,6 +120,10 @@ static void rstp_port_set_mcheck__(struct rstp_port *, 
bool mcheck)
 OVS_REQUIRES(rstp_mutex);
 static void reinitialize_port__(struct rstp_port *p)
 OVS_REQUIRES(rstp_mutex);
+static void rstp_unixctl_tcn(struct unixctl_conn *, int argc,
+ const char *argv[], void *aux);
+static void rstp_unixctl_show(struct unixctl_conn *, int argc,
+  const char *argv[], void *aux);
 
 const char *
 rstp_state_name(enum rstp_state state)
@@ -208,9 +212,6 @@ rstp_port_get_number(const struct rstp_port *p)
 return number;
 }
 
-static void rstp_unixctl_tcn(struct unixctl_conn *, int argc,
- const char *argv[], void *aux);
-
 /* Decrements the State Machines' timers. */
 void
 rstp_tick_timers(struct rstp *rstp)
@@ -246,6 +247,8 @@ rstp_init(void)
 
 unixctl_command_register("rstp/tcn", "[bridge]", 0, 1, 
rstp_unixctl_tcn,
  NULL);
+unixctl_command_register("rstp/show", "[bridge]", 0, 1,
+ rstp_unixctl_show, NULL);
 ovsthread_once_done(&once);
 }
 }
@@ -1398,7 +1401,7 @@ rstp_get_designated_root(const struct rstp *rstp)
  * there is no such port.
  */
 struct rstp_port *
-rstp_get_root_port(struct rstp *rstp)
+rstp_get_root_port(const struct rstp *rstp)
 OVS_EXCLUDED(rstp_mutex)
 {
 struct rstp_port *p;
@@ -1545,3 +1548,105 @@ rstp_unixctl_tcn(struct unixctl_conn *conn, int argc,
 out:
 ovs_mutex_unlock(&rstp_mutex);
 }
+
+static void
+rstp_bridge_id_details(struct ds *ds, const rstp_identifier bridge_id,
+   const uint16_t hello_time, const uint16_t max_age,
+   const uint16_t forward_delay)
+OVS_REQUIRES(rstp_mutex)
+{
+uint16_t priority = bridge_id >> 48;
+ds_put_format(ds, "\tstp-priority\t%"PRIu16"\n", priority);
+
+struct eth_addr mac;
+const uint64_t mac_bits = (UINT64_C(1) << 48) - 1;
+eth_addr_from_uint64(bridge_id & mac_bits, &mac);
+ds_put_format(ds, "\tstp-system-id\t"ETH_ADDR_FMT"\n", ETH_ADDR_ARGS(mac));
+ds_put_format(ds, "\tstp-hello-time\t%"PRIu16"s\n", hello_time);
+ds_put_format(ds, "\tstp-max-age\t%"PRIu16"s\n", max_age);
+ds_put_format(ds, "\tstp-fwd-delay\t%"PRIu16"s\n", forward_delay);
+}
+
+static void
+rstp_print_details(struct ds *ds, const struct rstp *rstp)
+OVS_REQUIRES(rstp_mutex)
+{
+ds_put_format(ds, " %s \n", rstp->name);
+ds_put_cstr(ds, "Root ID:\n");
+
+bool is_root = rstp_is_root_bridge(rstp);
+struct rstp_port *p = rstp_get_root_port(rstp);
+
+rstp_identifier bridge_id =
+is_root ? rstp->bridge_identifier : rstp_get_root_id(rstp);
+uint16_t hello_time =
+is_root ? rstp->bridge_hello_time : p->designated_times.hello_time;
+uint16_t max_age =
+is_root ? rstp->bridge_max_age : p->designated_times.max_age;
+uint16_t forward_delay =
+is_root ? rstp->bridge_forward_delay : 
p->designated_times.forward_delay;
+
+rstp_bridge_id_details(ds, bridge_id, hello_time, max_age, forward_delay);
+if (is_root) {
+ds_put_cstr(ds, "\tThis bridge is the root\n");
+} else {
+ds_put_format(ds, "\troot-port\t%s\n", p->port_name);
+ds_put_format(ds, "\troot-path-cost\t%u\n",
+  rstp_get_root_path_cost(rstp));
+}
+ds_put_cstr(ds, "\n");
+
+ds_put_cstr(ds, "Bridge ID:\n");
+rstp_bridge_id_details(ds, rstp->bridge_identifier,
+   rstp->bridge_hello_time,
+   rstp->bridge_max_age,
+   rstp->bridge_forward_delay);
+ds_put_cstr(ds, "\n");
+
+ds_put_format(ds, "\t%-11.10s%-11.10s%-11.10s%-9.8s%-8.7s\n",
+  "Interface", "Role", "State", "Cost", "Pri.Nbr");
+ds_put_cstr(ds, "\t-- -- --  ---\n");
+HMAP_FOR_EACH (p, node, &rstp->ports) {
+if (p->rstp_state != RSTP_DISABLED) {
+

[ovs-dev] [PATCH 3/6] stp: Add link-state checking support for stp ports.

2017-03-31 Thread nickcooper-zhangtonghao
When bridge stp enabled, we enable the stp ports despite
ports are down. When initializing, this patch checks
link-state of ports and enable or disable them according
to their link-state. This patch also allow user to enable
and disable a port when bridge stp is running.

Signed-off-by: nickcooper-zhangtonghao 
---
 ofproto/ofproto-dpif.c | 41 +++-
 tests/stp.at   | 73 ++
 2 files changed, 113 insertions(+), 1 deletion(-)

diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c
index 4beacda..f015131 100644
--- a/ofproto/ofproto-dpif.c
+++ b/ofproto/ofproto-dpif.c
@@ -2488,6 +2488,37 @@ update_stp_port_state(struct ofport_dpif *ofport)
 }
 }
 
+static void
+stp_check_and_update_link_state(struct ofproto_dpif *ofproto)
+{
+struct ofport *ofport_;
+struct ofport_dpif *ofport;
+bool up;
+
+HMAP_FOR_EACH (ofport_, hmap_node, &ofproto->up.ports) {
+ofport = ofport_dpif_cast(ofport_);
+up = netdev_get_carrier(ofport_->netdev);
+
+if (ofport->stp_port &&
+up != (stp_port_get_state(ofport->stp_port) != STP_DISABLED)) {
+
+VLOG_DBG("bridge: %s, port: %s is %s, %s it", ofproto->up.name,
+ netdev_get_name(ofport->up.netdev),
+ up ? "up" : "down",
+ up ? "enabling" : "disabling");
+
+if (up) {
+stp_port_enable(ofport->stp_port);
+stp_port_set_aux(ofport->stp_port, ofport);
+} else {
+stp_port_disable(ofport->stp_port);
+}
+
+update_stp_port_state(ofport);
+}
+}
+}
+
 /* Configures STP on 'ofport_' using the settings defined in 's'.  The
  * caller is responsible for assigning STP port numbers and ensuring
  * there are no duplicates. */
@@ -2518,7 +2549,12 @@ set_stp_port(struct ofport *ofport_,
 /* Set name before enabling the port so that debugging messages can print
  * the name. */
 stp_port_set_name(sp, netdev_get_name(ofport->up.netdev));
-stp_port_enable(sp);
+
+if (netdev_get_carrier(ofport_->netdev)) {
+stp_port_enable(sp);
+} else {
+stp_port_disable(sp);
+}
 
 stp_port_set_aux(sp, ofport);
 stp_port_set_priority(sp, s->priority);
@@ -2580,6 +2616,9 @@ stp_run(struct ofproto_dpif *ofproto)
 stp_tick(ofproto->stp, MIN(INT_MAX, elapsed));
 ofproto->stp_last_tick = now;
 }
+
+stp_check_and_update_link_state(ofproto);
+
 while (stp_get_changed_port(ofproto->stp, &sp)) {
 struct ofport_dpif *ofport = stp_port_get_aux(sp);
 
diff --git a/tests/stp.at b/tests/stp.at
index 98632a8..de8f971 100644
--- a/tests/stp.at
+++ b/tests/stp.at
@@ -420,6 +420,8 @@ AT_CHECK([ovs-vsctl add-port br1 p8 -- \
set port p8 other_config:stp-enable=false -- \
 ])
 
+ovs-appctl netdev-dummy/set-admin-state up
+
 ovs-appctl time/stop
 
 AT_CHECK([ovs-ofctl add-flow br0 "in_port=7 icmp actions=1"])
@@ -519,6 +521,7 @@ AT_CHECK([
 set interface p6 type=dummy options:pstream=punix:$OVS_RUNDIR/p6.sock 
ofport_request=6
 ], [0])
 
+ovs-appctl netdev-dummy/set-admin-state up
 
 ovs-appctl time/stop
 
@@ -633,6 +636,8 @@ AT_CHECK([
 set interface p2 type=dummy ofport_request=2
 ], [0])
 
+ovs-appctl netdev-dummy/set-admin-state up
+
 ovs-appctl time/stop
 
 # give time for STP to move initially
@@ -653,6 +658,8 @@ AT_CHECK([
 set interface p3 type=dummy ofport_request=3
 ], [0])
 
+ovs-appctl netdev-dummy/set-admin-state p3 up
+
 # The new stp port should be a listening state and other
 # stp ports keep forwarding.
 AT_CHECK([ovs-appctl stp/show br0 | grep p1], [0], [dnl
@@ -676,5 +683,71 @@ AT_CHECK([ovs-appctl stp/show br0 | grep p3], [0], [dnl
p3 designated listening  19128.3
 ])
 
+AT_CLEANUP
+
+AT_SETUP([STP - check link-state when stp is running])
+OVS_VSWITCHD_START([])
+
+AT_CHECK([
+ovs-vsctl -- \
+set port br0 other_config:stp-enable=false -- \
+set bridge br0 datapath-type=dummy stp_enable=true \
+other-config:hwaddr=aa:66:aa:66:00:00
+], [0])
+
+AT_CHECK([
+ovs-vsctl add-port br0 p1 -- \
+set interface p1 type=dummy ofport_request=1
+ovs-vsctl add-port br0 p2 -- \
+set interface p2 type=dummy ofport_request=2
+], [0])
+
+ovs-appctl netdev-dummy/set-admin-state up
+
+ovs-appctl time/stop
+
+# give time for STP to move initially
+for i in $(seq 0 30); do
+ovs-appctl time/warp 1000
+done
+
+AT_CHECK([ovs-appctl stp/show br0 | grep p1], [0], [dnl
+   p1 designated forwarding 19128.1
+])
+AT_CHECK([ovs-appctl stp/show br0 | grep p2], [0], [dnl
+   p2 designated forwarding 19128.2
+])
+
+# add a stp port
+AT_CHECK([
+ovs-vsctl add-port br0 p3 -- \
+set interface p3 type=dummy ofport_request=3
+], [0])
+
+ovs-appctl netdev-dummy/set-admin-state p3 down
+
+# We should not show the p

[ovs-dev] [PATCH 5/6] rstp: Add rstp port name for human reading.

2017-03-31 Thread nickcooper-zhangtonghao
This patch is useful to debug rstp subsystem and log the
port name instead of port number. This patch will also
be used to display rstp info for next patches.

Signed-off-by: nickcooper-zhangtonghao 
---
 lib/rstp-common.h  |  1 +
 lib/rstp.c | 14 +-
 lib/rstp.h |  3 ++-
 ofproto/ofproto-dpif.c |  2 +-
 4 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/lib/rstp-common.h b/lib/rstp-common.h
index 27e8079..c108232 100644
--- a/lib/rstp-common.h
+++ b/lib/rstp-common.h
@@ -262,6 +262,7 @@ struct rstp_port {
 struct rstp *rstp OVS_GUARDED_BY(rstp_mutex);
 struct hmap_node node OVS_GUARDED_BY(rstp_mutex); /* In rstp->ports. */
 void *aux OVS_GUARDED_BY(rstp_mutex);
+char *port_name;
 struct rstp_bpdu received_bpdu_buffer OVS_GUARDED_BY(rstp_mutex);
 /*
  * MAC status parameters
diff --git a/lib/rstp.c b/lib/rstp.c
index 6f1c1e3..b942f6e 100644
--- a/lib/rstp.c
+++ b/lib/rstp.c
@@ -760,6 +760,14 @@ rstp_port_set_port_number__(struct rstp_port *port, 
uint16_t port_number)
 }
 }
 
+static void
+rstp_port_set_port_name__(struct rstp_port *port, const char *name)
+OVS_REQUIRES(rstp_mutex)
+{
+free(port->port_name);
+port->port_name = xstrdup(name);
+}
+
 /* Converts the link speed to a port path cost [Table 17-3]. */
 uint32_t
 rstp_convert_speed_to_cost(unsigned int speed)
@@ -1173,6 +1181,7 @@ rstp_add_port(struct rstp *rstp)
 rstp_port_set_priority__(p, RSTP_DEFAULT_PORT_PRIORITY);
 rstp_port_set_port_number__(p, 0);
 p->aux = NULL;
+p->port_name = NULL;
 rstp_initialize_port_defaults__(p);
 VLOG_DBG("%s: RSTP port "RSTP_PORT_ID_FMT" initialized.", rstp->name,
  p->port_id);
@@ -1210,6 +1219,7 @@ rstp_port_unref(struct rstp_port *rp)
 ovs_mutex_lock(&rstp_mutex);
 rstp = rp->rstp;
 rstp_port_set_state__(rp, RSTP_DISABLED);
+free(rp->port_name);
 hmap_remove(&rstp->ports, &rp->node);
 VLOG_DBG("%s: removed port "RSTP_PORT_ID_FMT"", rstp->name,
  rp->port_id);
@@ -1448,13 +1458,15 @@ void
 rstp_port_set(struct rstp_port *port, uint16_t port_num, int priority,
   uint32_t path_cost, bool is_admin_edge, bool is_auto_edge,
   enum rstp_admin_point_to_point_mac_state admin_p2p_mac_state,
-  bool admin_port_state, bool do_mcheck, void *aux)
+  bool admin_port_state, bool do_mcheck, void *aux,
+  const char *name)
 OVS_EXCLUDED(rstp_mutex)
 {
 ovs_mutex_lock(&rstp_mutex);
 port->aux = aux;
 rstp_port_set_priority__(port, priority);
 rstp_port_set_port_number__(port, port_num);
+rstp_port_set_port_name__(port, name);
 rstp_port_set_path_cost__(port, path_cost);
 rstp_port_set_admin_edge__(port, is_admin_edge);
 rstp_port_set_auto_edge__(port, is_auto_edge);
diff --git a/lib/rstp.h b/lib/rstp.h
index 78e07fb..fa67e3c 100644
--- a/lib/rstp.h
+++ b/lib/rstp.h
@@ -221,7 +221,8 @@ uint32_t rstp_convert_speed_to_cost(unsigned int speed);
 void rstp_port_set(struct rstp_port *, uint16_t port_num, int priority,
uint32_t path_cost, bool is_admin_edge, bool is_auto_edge,
enum rstp_admin_point_to_point_mac_state 
admin_p2p_mac_state,
-   bool admin_port_state, bool do_mcheck, void *aux)
+   bool admin_port_state, bool do_mcheck, void *aux,
+   const char *name)
 OVS_EXCLUDED(rstp_mutex);
 
 enum rstp_state rstp_port_get_state(const struct rstp_port *)
diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c
index f015131..d41d90f 100644
--- a/ofproto/ofproto-dpif.c
+++ b/ofproto/ofproto-dpif.c
@@ -2675,7 +2675,7 @@ set_rstp_port(struct ofport *ofport_,
 rstp_port_set(rp, s->port_num, s->priority, s->path_cost,
   s->admin_edge_port, s->auto_edge,
   s->admin_p2p_mac_state, s->admin_port_state, s->mcheck,
-  ofport);
+  ofport, netdev_get_name(ofport->up.netdev));
 update_rstp_port_state(ofport);
 /* Synchronize operational status. */
 rstp_port_set_mac_operational(rp, ofport->may_enable);
-- 
1.8.3.1



___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH 4/6] rstp: Init a recursive mutex for rstp.

2017-03-31 Thread nickcooper-zhangtonghao
This patch will be used for next patch.

Signed-off-by: nickcooper-zhangtonghao 
---
 lib/rstp.c | 15 ---
 lib/rstp.h |  6 --
 2 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/lib/rstp.c b/lib/rstp.c
index 907a907..6f1c1e3 100644
--- a/lib/rstp.c
+++ b/lib/rstp.c
@@ -50,7 +50,7 @@
 
 VLOG_DEFINE_THIS_MODULE(rstp);
 
-struct ovs_mutex rstp_mutex = OVS_MUTEX_INITIALIZER;
+static struct ovs_mutex rstp_mutex;
 
 static struct ovs_list all_rstps__ = OVS_LIST_INITIALIZER(&all_rstps__);
 static struct ovs_list *const all_rstps OVS_GUARDED_BY(rstp_mutex) = 
&all_rstps__;
@@ -239,8 +239,15 @@ void
 rstp_init(void)
 OVS_EXCLUDED(rstp_mutex)
 {
-unixctl_command_register("rstp/tcn", "[bridge]", 0, 1, rstp_unixctl_tcn,
- NULL);
+static struct ovsthread_once once = OVSTHREAD_ONCE_INITIALIZER;
+
+if (ovsthread_once_start(&once)) {
+ovs_mutex_init_recursive(&rstp_mutex);
+
+unixctl_command_register("rstp/tcn", "[bridge]", 0, 1, 
rstp_unixctl_tcn,
+ NULL);
+ovsthread_once_done(&once);
+}
 }
 
 /* Creates and returns a new RSTP instance that initially has no ports. */
@@ -255,6 +262,8 @@ rstp_create(const char *name, rstp_identifier 
bridge_address,
 
 VLOG_DBG("Creating RSTP instance");
 
+rstp_init();
+
 rstp = xzalloc(sizeof *rstp);
 rstp->name = xstrdup(name);
 
diff --git a/lib/rstp.h b/lib/rstp.h
index 4942d59..78e07fb 100644
--- a/lib/rstp.h
+++ b/lib/rstp.h
@@ -36,12 +36,6 @@
 #include "compiler.h"
 #include "util.h"
 
-/* Thread Safety: Callers passing in RSTP and RSTP port object
- * pointers must hold a reference to the passed object to ensure that
- * the object does not become stale while it is being accessed. */
-
-extern struct ovs_mutex rstp_mutex;
-
 #define RSTP_MAX_PORTS 4095
 
 struct dp_packet;
-- 
1.8.3.1



___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH 2/6] stp: Use OpenFlow port number for stp ports.

2017-03-31 Thread nickcooper-zhangtonghao
When a bridge stp enabled, we assign sequentially element
of stp_port array (in stp struct) to bridge ports. That is
ok when no ports are added to bridge. When adding a port
to bridge which stp enabled, the ovs-vswitchd will assign
stp_port sequentially again. Then the stp_port belonging
to one port may belong to other one. This patch uses the
OpenFlow port numbers instead of sequence numbers to avoid
it.

Signed-off-by: nickcooper-zhangtonghao 
---
 tests/stp.at  | 90 ++-
 vswitchd/bridge.c | 10 +--
 2 files changed, 77 insertions(+), 23 deletions(-)

diff --git a/tests/stp.at b/tests/stp.at
index bd5d208..98632a8 100644
--- a/tests/stp.at
+++ b/tests/stp.at
@@ -570,11 +570,6 @@ for i in $(seq 0 35); do
 done
 
 # root bridge sends query packet
-# we don't want to lose that message, so send it twice
-AT_CHECK([ovs-appctl netdev-dummy/receive br0 \
-
'01005E010101000C29A027D181010800451C00014002CBCBAC102201E0010104EEEB'])
-
-ovs-appctl time/warp 1000
 AT_CHECK([ovs-appctl netdev-dummy/receive br0 \
 
'01005E010101000C29A027D181010800451C00014002CBCBAC102201E0010104EEEB'])
 
@@ -589,21 +584,14 @@ OVS_WAIT_UNTIL([ovs-appctl mdb/show br2 | grep 'querier'])
 # del p2 on the br0, the topology will be changed
 AT_CHECK([ovs-vsctl del-port br0 p2])
 
-# give time for STP to synchronize
-ovs-appctl time/warp 3000
-ovs-appctl time/warp 3000
-ovs-appctl time/warp 3000
-ovs-appctl time/warp 3000
-ovs-appctl time/warp 3000
-
-ovs-appctl time/warp 3000
-ovs-appctl time/warp 3000
-ovs-appctl time/warp 3000
-ovs-appctl time/warp 3000
-ovs-appctl time/warp 3000
-
-ovs-appctl time/warp 3000
-ovs-appctl time/warp 3000
+# We give time for STP to synchronize. The message age of
+# p6 port will time out after 20s. The p5 will left blocked
+# state to forwarding after 30s and then br2 bridge will
+# detect the topology change, flush the fdb and sent tcn BPDU.
+# br1 and br0 will also flush fdb when receiving tcn BPDU.
+for i in $(seq 0 52); do
+ovs-appctl time/warp 1000
+done
 
 # check fdb and mdb
 AT_CHECK([ovs-appctl fdb/show br0], [0], [dnl
@@ -626,5 +614,67 @@ AT_CHECK([ovs-appctl mdb/show br2], [0], [dnl
  port  VLAN  GROUPAge
 ])
 
+AT_CLEANUP
+
+AT_SETUP([STP - check the stp ports num])
+OVS_VSWITCHD_START([])
+
+AT_CHECK([
+ovs-vsctl -- \
+set port br0 other_config:stp-enable=false -- \
+set bridge br0 datapath-type=dummy stp_enable=true \
+other-config:hwaddr=aa:66:aa:66:00:00
+], [0])
+
+AT_CHECK([
+ovs-vsctl add-port br0 p1 -- \
+set interface p1 type=dummy ofport_request=1
+ovs-vsctl add-port br0 p2 -- \
+set interface p2 type=dummy ofport_request=2
+], [0])
+
+ovs-appctl time/stop
+
+# give time for STP to move initially
+for i in $(seq 0 30); do
+ovs-appctl time/warp 1000
+done
+
+AT_CHECK([ovs-appctl stp/show br0 | grep p1], [0], [dnl
+   p1 designated forwarding 19128.1
+])
+AT_CHECK([ovs-appctl stp/show br0 | grep p2], [0], [dnl
+   p2 designated forwarding 19128.2
+])
+
+# add a stp port
+AT_CHECK([
+ovs-vsctl add-port br0 p3 -- \
+set interface p3 type=dummy ofport_request=3
+], [0])
+
+# The new stp port should be a listening state and other
+# stp ports keep forwarding.
+AT_CHECK([ovs-appctl stp/show br0 | grep p1], [0], [dnl
+   p1 designated forwarding 19128.1
+])
+AT_CHECK([ovs-appctl stp/show br0 | grep p2], [0], [dnl
+   p2 designated forwarding 19128.2
+])
+AT_CHECK([ovs-appctl stp/show br0 | grep p3], [0], [dnl
+   p3 designated listening  19128.3
+])
+
+# delete p1 stp port
+AT_CHECK([ovs-vsctl del-port br0 p1])
+
+# The other stp ports keep original state.
+AT_CHECK([ovs-appctl stp/show br0 | grep p2], [0], [dnl
+   p2 designated forwarding 19128.2
+])
+AT_CHECK([ovs-appctl stp/show br0 | grep p3], [0], [dnl
+   p3 designated listening  19128.3
+])
+
 OVS_VSWITCHD_STOP
 AT_CLEANUP
diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c
index 867a26d..d683000 100644
--- a/vswitchd/bridge.c
+++ b/vswitchd/bridge.c
@@ -1396,13 +1396,17 @@ port_configure_stp(const struct ofproto *ofproto, 
struct port *port,
 bitmap_set1(port_num_bitmap, port_idx);
 port_s->port_num = port_idx;
 } else {
-if (*port_num_counter >= STP_MAX_PORTS) {
-VLOG_ERR("port %s: too many STP ports, disabling", port->name);
+if (iface->ofp_port > STP_MAX_PORTS) {
+VLOG_ERR("port %s: too many STP ports or OpenFlow port number "
+ "(%d) > STP_MAX_PORTS (%d), disabling", port->name,
+ iface->ofp_port, STP_MAX_PORTS);
+
 port_s->enable = false;
 return;
 }
 
-port_s->port_num = (*port_num_counter)++;
+port_s->port_num = iface->ofp_port -1;
+(*port_num_counter)++;
 }
 
 conf

[ovs-dev] [PATCH 1/6] rstp/stp: Unref the rstp/stp when bridges destroyed.

2017-03-31 Thread nickcooper-zhangtonghao
When bridges destroyed, which stp enabled, you can
still get stp info via the command 'ovs-appctl stp/show'.
And the rstp is also in the same case. We should unref
them. The rstp/stp ports have been unregistered via
'ofproto_port_unregister' function when ports destroyed.
We will unref rstp/stp struct in the 'destruct' of
ofproto-dpif provider.

Signed-off-by: nickcooper-zhangtonghao 
---
 ofproto/ofproto-dpif.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c
index 523adad..4beacda 100644
--- a/ofproto/ofproto-dpif.c
+++ b/ofproto/ofproto-dpif.c
@@ -1494,6 +1494,8 @@ destruct(struct ofproto *ofproto_)
 hmap_destroy(&ofproto->bundles);
 mac_learning_unref(ofproto->ml);
 mcast_snooping_unref(ofproto->ms);
+stp_unref(ofproto->stp);
+rstp_unref(ofproto->rstp);
 
 sset_destroy(&ofproto->ports);
 sset_destroy(&ofproto->ghost_ports);
-- 
1.8.3.1




___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


Re: [ovs-dev] [PATCH 2/3] ofproto: Store meters into imap

2017-03-31 Thread Ben Pfaff
On Fri, Mar 31, 2017 at 01:42:02PM -0700, Andy Zhou wrote:
> Currently, meters are stored in a fixed pointer array. It is not
> very efficient since the controller, at least in theory, can
> pick any meter id (up to the limits to uint32_t), not necessarily
> within the lower end of a region, or in close range to each other.
> In particular, OFPM_SLOWPATH and OFPM_CONTROLLER meters are specified
> at the high region.
> 
> Switching to use imap, so that ofproto layer does not restrict
> the number of meters that controller can add, nor does it care
> about the value of meter_id. Only datapth actually limits the
> number of meters ofproto layer can support.
> 
> Signed-off-by: Andy Zhou 

Instead of using a new integer-to-pointer map data structure, did you
consider adding an hmap_node to struct meter?  That's the first approach
that comes to mind, so I'm curious to know whether it's a poor approach
for some reason.
___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


Re: [ovs-dev] Fwd: In OVS2.6 userspace datapath, ARP handling for non-tunnel packet?

2017-03-31 Thread Joo Kim
While static MAC binding addon is good in the sense that we can avoid
expense ARP resolution,  but still in the usecase of running OVS switch
alone without controller,  ARP resolution is needed for forwarding
non-tunnel traffic to nexthop, isn't it?

On Fri, Mar 31, 2017 at 11:12 AM, Darrell Ball  wrote:

>
>
>
>
> *From: *Joo Kim 
> *Date: *Thursday, March 30, 2017 at 5:09 PM
> *To: *Darrell Ball 
> *Cc: *"ovs-dev@openvswitch.org" 
> *Subject: *Re: [ovs-dev] Fwd: In OVS2.6 userspace datapath, ARP handling
> for non-tunnel packet?
>
>
>
> Thanks for reply Darrell.
>
> BTW, why we don't try to send ARP request for the non-tunnel traffic by
> default?  If the mechanism(ARP handling via controller) you are describing
> is not installed,  then in current OVS-2.6 userspace datapath, non-tunnel
> traffic is just dropped?
>
>
>
> In general, an Openflow switch supports routing with added rule
> configuration.
>
> MAC binding rules must be specifically added. This can be done statically
> as well, where
>
> the controller knows the MAC binding, from a CMS, which is statically
> configured and distributes
>
> this information -> controller -> switch.
>
> BTW, in the case of tunnels, there is both overlay and underlay mac
> bindings.
>
> Applications sitting on top of OVS, like OVN (for NFV), should provide
> support
>
> for mac bindings.
>
> Take a look at OVN (tests in ovn.at and system-ovn.at).
>
>
>
>
>
> On Mon, Mar 27, 2017 at 6:14 PM, Darrell Ball  wrote:
>
>
>
> On 3/23/17, 2:59 PM, "ovs-dev-boun...@openvswitch.org on behalf of Joo
> Kim" 
> wrote:
>
> Folks,
>
> Anybody knows  about this ARP behavior in ovs2.6?   -thanks-
>
>
> -- Forwarded message --
> From: Joo Kim 
> Date: Wed, Mar 22, 2017 at 3:58 AM
> Subject: In OVS2.6 userspace datapath, ARP handling for non-tunnel
> packet?
> To: ovs-dev@openvswitch.org
>
>
> Hello,
>
> Looks like build_tunnel_send() (which, I understand, is for tunnel
> packet)   sends ARP request on the fly (using tnl_send_arp_request() )
> when there is no ARP cache.
>
> Then,  how about  ARP handling for NON-tunnel packet (=> which does not
> call build_tunnel_send () )?Does it send arp request?
>
> Not by default
>
>  (In the code, I
> don't find that kind of code)
>
> I think you are referring to resolving the hop b/w HVs, without using
> tunnels
> to connect said HVs, while using routing forwarding.
>
> In this case, the expected use is for there to be a rule installed to send
> the original
> packet to a controller, which would construct the arp request, send it
> back down to the switch,
> have the arp reply (another rule) sent to it and later installing the
> binding rule.
> This involves packet-ins/outs.
>
>
>
>
> #0  build_tunnel_send (xport=0xdbab10, tunnel_odp_port=3,
> flow=0x7fffb778, ctx=0x7fff9ac0)
>  at ofproto/ofproto-dpif-xlate.c:2946
>  #1  compose_output_action__ (ctx=ctx@entry=0x7fffa160,
> ofp_port=2,
> xr=xr@entry=0x0,
>  check_stp=check_stp@entry=true) at
> ofproto/ofproto-dpif-xlate.c:
> 3243
>  #2  0x005d7bb2 in compose_output_action (xr=0x0,
> ofp_port=,
>  ctx=0x7fffa160) at ofproto/ofproto-dpif-xlate.c:3308
>  #3  output_normal (ctx=ctx@entry=0x7fffa160,
> out_xbundle=out_xbundle@entry=0xd96200,
>  vlan=vlan@entry=0) at ofproto/ofproto-dpif-xlate.c:1958
>  #4  0x005d81f6 in xlate_normal_flood (ctx=ctx@entry
> =0x7fffa160,
>  in_xbundle=in_xbundle@entry=0xd9b3e0, vlan=vlan@entry=0) at
> ofproto/ofproto-dpif-xlate.c:2401
>  #5  0x005d89ad in xlate_normal (ctx=0x7fffa160) at
> ofproto/ofproto-dpif-xlate.c:2604
>  #6  xlate_output_action (ctx=ctx@entry=0x7fffa160,
> port= out>,
>  max_len=, may_packet_in=may_packet_in@
> entry=true)
>  at ofproto/ofproto-dpif-xlate.c:3981
>  #7  0x005d51ee in do_xlate_actions (ofpacts=ofpacts@entry
> =
> 0xd99ae8,
>  ofpacts_len=ofpacts_len@entry=16, ctx=ctx@entry
> =0x7fffa160)
>  at ofproto/ofproto-dpif-xlate.c:4781
>  #8  0x005da384 in xlate_actions (xin=xin@entry
> =0x7fffb770,
>  xout=xout@entry=0x7fffbb00) at
> ofproto/ofproto-dpif-xlate.c:
> 5618
>  #9  0x005cec3c in upcall_xlate (wc=0x7fffce58,
> odp_actions=0x7fffc680,
>  upcall=0x7fffbaa0, udpif=0xd479b0) at
> ofproto/ofproto-dpif-upcall.c:1102
>  #10 process_upcall (udpif=udpif@entry=0xd479b0,
> upcall=upcall@entry=
> 0x7fffbaa0,
>  odp_actions=odp_actions@entry=0x7fffc680, wc=wc@entry
> =0x7fffce58)
>
> ___
> dev mailing list
> d...@openvswitch.org
> https://urldefense.proofpoint.com/v2/url?u=https-3A__mail.
> openvswitch.org_mail

[ovs-dev] [PATCH] ovn-sbctl: fix lflow-list when uuid has leading 0s.

2017-03-31 Thread Han Zhou
When uuid starts with 0s, lflow-list will fail if leading 0s are
not included in command argument. This leads to unexpected results
considering that leading 0s are usually not shown up in cookies
of OpenFlow outputs of tools such as ovs-ofctl dump-flows
and ovs-appctl ofproto/trace. E.g.

lflow uuid: 0c16ceb4-0409-484b-8297-a6e7f264ac2d
$ ovn-nbctl lflow-list 0c16ceb4 # works fine
$ ovn-nbctl lflow-list c16ceb4 # doesn't work

This patch fixes the problem.

Signed-off-by: Han Zhou 
---
 ovn/utilities/ovn-sbctl.c | 13 -
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/ovn/utilities/ovn-sbctl.c b/ovn/utilities/ovn-sbctl.c
index 4e3cbad..612456a 100644
--- a/ovn/utilities/ovn-sbctl.c
+++ b/ovn/utilities/ovn-sbctl.c
@@ -714,13 +714,24 @@ parse_partial_uuid(char *s)
 return NULL;
 }
 
+static const char *
+strip_leading_zero(const char *s)
+{
+size_t i = 0;
+while (s[i++] == '0');
+return s + i;
+}
+
 static bool
 is_partial_uuid_match(const struct uuid *uuid, const char *match)
 {
 char uuid_s[UUID_LEN + 1];
 snprintf(uuid_s, sizeof uuid_s, UUID_FMT, UUID_ARGS(uuid));
 
-return !strncmp(uuid_s, match, strlen(match));
+const char *s1 = strip_leading_zero(uuid_s);
+const char *s2 = strip_leading_zero(match);
+
+return !strncmp(s1, s2, strlen(s2));
 }
 
 static const struct sbrec_datapath_binding *
-- 
2.1.0

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] ovs-dev@openvswitch.org邮件系统升级验证提醒!

2017-03-31 Thread postmaster
这是一封 HTML 格式的邮件,请以网页方式查看邮件。
___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH 3/3] ofproto-dpif: Add 'meter_ids' to backer

2017-03-31 Thread Andy Zhou
Add 'meter_ids', an id-pool object to manage datapath meter id, i.e.
provider_meter_id.

Currently, only userspace datapath supports meter, and it implements
the provider_meter_id management. Moving this function to 'backer'
allows other datapath implementation to share the same logic.

Signed-off-by: Andy Zhou 
---
 lib/dpif-netdev.c  | 24 
 ofproto/ofproto-dpif.c | 22 ++
 ofproto/ofproto-dpif.h |  4 
 3 files changed, 26 insertions(+), 24 deletions(-)

diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
index a14a2ebb5b2a..d5417162b7af 100644
--- a/lib/dpif-netdev.c
+++ b/lib/dpif-netdev.c
@@ -260,7 +260,6 @@ struct dp_netdev {
 /* Meters. */
 struct ovs_mutex meter_locks[N_METER_LOCKS];
 struct dp_meter *meters[MAX_METERS]; /* Meter bands. */
-uint32_t meter_free; /* Next free meter. */
 
 /* Protects access to ofproto-dpif-upcall interface during revalidator
  * thread synchronization. */
@@ -3896,9 +3895,6 @@ dpif_netdev_meter_set(struct dpif *dpif, ofproto_meter_id 
*meter_id,
 struct dp_meter *meter;
 int i;
 
-if (mid == UINT32_MAX) {
-mid = dp->meter_free;
-}
 if (mid >= MAX_METERS) {
 return EFBIG; /* Meter_id out of range. */
 }
@@ -3958,21 +3954,6 @@ dpif_netdev_meter_set(struct dpif *dpif, 
ofproto_meter_id *meter_id,
 dp->meters[mid] = meter;
 meter_unlock(dp, mid);
 
-meter_id->uint32 = mid; /* Store on success. */
-
-/* Find next free meter */
-if (dp->meter_free == mid) { /* Now taken. */
-do {
-if (++mid >= MAX_METERS) { /* Wrap around */
-mid = 0;
-}
-if (mid == dp->meter_free) { /* Full circle */
-mid = MAX_METERS;
-break;
-}
-} while (dp->meters[mid]);
-dp->meter_free = mid; /* Next free meter or MAX_METERS */
-}
 return 0;
 }
 return ENOMEM;
@@ -4027,11 +4008,6 @@ dpif_netdev_meter_del(struct dpif *dpif,
 meter_lock(dp, meter_id);
 dp_delete_meter(dp, meter_id);
 meter_unlock(dp, meter_id);
-
-/* Keep free meter index as low as possible */
-if (meter_id < dp->meter_free) {
-dp->meter_free = meter_id;
-}
 }
 return error;
 }
diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c
index 523adad6fa52..0d37efbea9ac 100644
--- a/ofproto/ofproto-dpif.c
+++ b/ofproto/ofproto-dpif.c
@@ -662,6 +662,7 @@ close_dpif_backer(struct dpif_backer *backer)
 free(backer->type);
 free(backer->dp_version_string);
 dpif_close(backer->dpif);
+id_pool_destroy(backer->meter_ids);
 free(backer);
 }
 
@@ -787,6 +788,15 @@ open_dpif_backer(const char *type, struct dpif_backer 
**backerp)
 = check_variable_length_userdata(backer);
 backer->dp_version_string = dpif_get_dp_version(backer->dpif);
 
+/* Manage Datpath meter IDs if supported. */
+struct ofputil_meter_features features;
+dpif_meter_get_features(backer->dpif, &features);
+if (features.max_meters) {
+backer->meter_ids = id_pool_create(0, features.max_meters);
+} else {
+backer->meter_ids = NULL;
+}
+
 return error;
 }
 
@@ -5391,6 +5401,17 @@ meter_set(struct ofproto *ofproto_, ofproto_meter_id 
*meter_id,
 {
 struct ofproto_dpif *ofproto = ofproto_dpif_cast(ofproto_);
 
+/* Provider ID unknown. Use backer to allocate a new DP meter */
+if (meter_id->uint32 == UINT32_MAX) {
+if (!ofproto->backer->meter_ids) {
+return EFBIG; /* Datapath does not support meter.  */
+}
+
+if(!id_pool_alloc_id(ofproto->backer->meter_ids, &meter_id->uint32)) {
+return ENOMEM; /* Can't allocate a DP meter. */
+}
+}
+
 switch (dpif_meter_set(ofproto->backer->dpif, meter_id, config)) {
 case 0:
 return 0;
@@ -5426,6 +5447,7 @@ meter_del(struct ofproto *ofproto_, ofproto_meter_id 
meter_id)
 struct ofproto_dpif *ofproto = ofproto_dpif_cast(ofproto_);
 
 dpif_meter_del(ofproto->backer->dpif, meter_id, NULL, 0);
+id_pool_free_id(ofproto->backer->meter_ids, meter_id.uint32);
 }
 
 const struct ofproto_class ofproto_dpif_class = {
diff --git a/ofproto/ofproto-dpif.h b/ofproto/ofproto-dpif.h
index cc514d245a90..4aabb35bc30b 100644
--- a/ofproto/ofproto-dpif.h
+++ b/ofproto/ofproto-dpif.h
@@ -51,6 +51,7 @@
 #include "hmapx.h"
 #include "odp-util.h"
 #include "openvswitch/ofp-util.h"
+#include "id-pool.h"
 #include "ovs-thread.h"
 #include "ofproto-provider.h"
 #include "util.h"
@@ -208,6 +209,9 @@ struct dpif_backer {
 
 bool recv_set_enable; /* Enables or disables receiving packets. */
 
+/* Meter. */
+struct id_pool *meter_ids; /* Datapath meter allocation. */
+
 /* Version string of the datapath stored in OVSDB. */
 char *dp_version_string;
 
-- 
1.8.3.1

__

[ovs-dev] [PATCH 2/3] ofproto: Store meters into imap

2017-03-31 Thread Andy Zhou
Currently, meters are stored in a fixed pointer array. It is not
very efficient since the controller, at least in theory, can
pick any meter id (up to the limits to uint32_t), not necessarily
within the lower end of a region, or in close range to each other.
In particular, OFPM_SLOWPATH and OFPM_CONTROLLER meters are specified
at the high region.

Switching to use imap, so that ofproto layer does not restrict
the number of meters that controller can add, nor does it care
about the value of meter_id. Only datapth actually limits the
number of meters ofproto layer can support.

Signed-off-by: Andy Zhou 
---
 ofproto/ofproto-provider.h |   8 ++-
 ofproto/ofproto.c  | 125 +++--
 2 files changed, 79 insertions(+), 54 deletions(-)

diff --git a/ofproto/ofproto-provider.h b/ofproto/ofproto-provider.h
index b7b12cdfd5f4..ccd574284f5d 100644
--- a/ofproto/ofproto-provider.h
+++ b/ofproto/ofproto-provider.h
@@ -38,6 +38,7 @@
 #include "guarded-list.h"
 #include "heap.h"
 #include "hindex.h"
+#include "imap.h"
 #include "object-collection.h"
 #include "ofproto/ofproto.h"
 #include "openvswitch/list.h"
@@ -109,12 +110,9 @@ struct ofproto {
 /* List of expirable flows, in all flow tables. */
 struct ovs_list expirable OVS_GUARDED_BY(ofproto_mutex);
 
-/* Meter table.
- * OpenFlow meters start at 1.  To avoid confusion we leave the first
- * pointer in the array un-used, and index directly with the OpenFlow
- * meter_id. */
+/* Meter table.  */
 struct ofputil_meter_features meter_features;
-struct meter **meters; /* 'meter_features.max_meter' + 1 pointers. */
+struct imap meters; /* uint32_t indexed 'struct meter *'.  */
 
 /* OpenFlow connections. */
 struct connmgr *connmgr;
diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c
index 84ea95b0c2a2..e6d605549b07 100644
--- a/ofproto/ofproto.c
+++ b/ofproto/ofproto.c
@@ -281,7 +281,8 @@ static uint64_t pick_fallback_dpid(void);
 static void ofproto_destroy__(struct ofproto *);
 static void update_mtu(struct ofproto *, struct ofport *);
 static void update_mtu_ofproto(struct ofproto *);
-static void meter_delete(struct ofproto *, uint32_t first, uint32_t last);
+static void meter_delete(struct ofproto *, uint32_t);
+static void meter_delete_all(struct ofproto *);
 static void meter_insert_rule(struct rule *);
 
 /* unixctl. */
@@ -566,8 +567,7 @@ ofproto_create(const char *datapath_name, const char 
*datapath_type,
 } else {
 memset(&ofproto->meter_features, 0, sizeof ofproto->meter_features);
 }
-ofproto->meters = xzalloc((ofproto->meter_features.max_meters + 1)
-  * sizeof(struct meter *));
+imap_init(&ofproto->meters);
 
 /* Set the initial tables version. */
 ofproto_bump_tables_version(ofproto);
@@ -1635,11 +1635,9 @@ ofproto_destroy(struct ofproto *p, bool del)
 return;
 }
 
-if (p->meters) {
-meter_delete(p, 1, p->meter_features.max_meters);
-p->meter_features.max_meters = 0;
-free(p->meters);
-p->meters = NULL;
+if (!imap_is_empty(&p->meters)) {
+meter_delete_all(p);
+imap_destroy(&p->meters);
 }
 
 ofproto_flush__(p);
@@ -6215,6 +6213,19 @@ struct meter {
 struct ofputil_meter_band *bands;
 };
 
+static struct meter *
+ofproto_get_meter(const struct ofproto *ofproto, uint32_t index)
+{
+return imap_get(&ofproto->meters, index);
+}
+
+static void
+ofproto_add_meter(struct ofproto *ofproto, uint32_t index,
+  struct meter *meter)
+{
+imap_add(&ofproto->meters, index, meter);
+}
+
 /*
  * This is used in instruction validation at flow set-up time, to map
  * the OpenFlow meter ID to the corresponding datapath provider meter
@@ -6226,7 +6237,7 @@ ofproto_fix_meter_action(const struct ofproto *ofproto,
  struct ofpact_meter *ma)
 {
 if (ma->meter_id && ma->meter_id <= ofproto->meter_features.max_meters) {
-const struct meter *meter = ofproto->meters[ma->meter_id];
+const struct meter *meter = ofproto_get_meter(ofproto, ma->meter_id);
 
 if (meter && meter->provider_meter_id.uint32 != UINT32_MAX) {
 /* Update the action with the provider's meter ID, so that we
@@ -6246,7 +6257,7 @@ meter_insert_rule(struct rule *rule)
 {
 const struct rule_actions *a = rule_get_actions(rule);
 uint32_t meter_id = ofpacts_get_meter(a->ofpacts, a->ofpacts_len);
-struct meter *meter = rule->ofproto->meters[meter_id];
+struct meter *meter = ofproto_get_meter(rule->ofproto, meter_id);
 
 ovs_list_insert(&meter->rules, &rule->meter_list_node);
 }
@@ -6279,31 +6290,50 @@ meter_create(const struct ofputil_meter_config *config,
 }
 
 static void
-meter_delete(struct ofproto *ofproto, uint32_t first, uint32_t last)
+meter_destroy(struct ofproto *ofproto, struct meter *meter)
 OVS_REQUIRES(ofproto_mutex)
 {
-for (uint32_t mid = first; mid <= las

[ovs-dev] [PATCH 1/3] lib: Add imap

2017-03-31 Thread Andy Zhou
'imap' implements a sparse array that maps a uint32_t value to
a pointer of arbitrary object. Future patches will make use
of this library.

Signed-off-by: Andy Zhou 
---
 lib/automake.mk |   2 +
 lib/imap.c  | 129 
 lib/imap.h  |  63 +++
 3 files changed, 194 insertions(+)
 create mode 100644 lib/imap.c
 create mode 100644 lib/imap.h

diff --git a/lib/automake.mk b/lib/automake.mk
index b266af13e4c7..5056c923827c 100644
--- a/lib/automake.mk
+++ b/lib/automake.mk
@@ -105,6 +105,8 @@ lib_libopenvswitch_la_SOURCES = \
lib/hmapx.h \
lib/id-pool.c \
lib/id-pool.h \
+   lib/imap.h \
+   lib/imap.c \
lib/jhash.c \
lib/jhash.h \
lib/json.c \
diff --git a/lib/imap.c b/lib/imap.c
new file mode 100644
index ..556ed6200105
--- /dev/null
+++ b/lib/imap.c
@@ -0,0 +1,129 @@
+/* Copyright (c) 2017 Nicira, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. */
+
+#include 
+#include "imap.h"
+
+
+/* Public Functions. */
+void
+imap_init(struct imap *imap)
+{
+hmap_init(&imap->map);
+}
+
+void
+imap_destroy(struct imap *imap)
+{
+if (imap) {
+imap_clear(imap);
+hmap_destroy(&imap->map);
+}
+}
+
+/* Adds 'index' paired with 'data' to 'imap'.  It is the caller's
+ * responsibility to avoid duplicate keys if desirable.  */
+struct imap_node *
+imap_add(struct imap *imap, uint32_t index, void *data)
+{
+struct imap_node *node = xmalloc(sizeof *node);
+node->index = index;
+node->data = data;
+hmap_insert(&imap->map, &node->node, hash_int(index, 0));
+return node;
+}
+
+/* Attempts to add 'index' to 'imap' associated with 'data'.  If 'index'
+ * already exists in 'imap', does nothing and returns false.  Otherwise,
+ * performs the addition and returns true. */
+bool
+imap_add_once(struct imap *imap, uint32_t index, void *data)
+{
+if (imap_get(imap, index)) {
+return false;
+}
+
+imap_add(imap, index, data);
+return true;
+}
+
+/* If 'index' is in 'imap', removes it.  Otherwise does nothing. */
+void
+imap_remove(struct imap *imap, uint32_t index)
+{
+struct imap_node *node = imap_get_node(imap, index);
+
+if (node) {
+imap_remove_node(imap, node);
+}
+}
+
+/* Removes 'node' from 'imap'. */
+void
+imap_remove_node(struct imap *imap, struct imap_node *node)
+{
+hmap_remove(&imap->map, &node->node);
+free(node->data);
+free(node);
+}
+
+/* Removes all indexes from 'imap'. */
+void
+imap_clear(struct imap *imap)
+{
+struct imap_node *node, *next;
+
+IMAP_FOR_EACH_SAFE (node, next, imap) {
+imap_remove_node(imap, node);
+}
+}
+
+/* Returns the data associated with 'index' in 'imap'.
+ * If 'imap' does not contain 'index', returns NULL. */
+void *
+imap_get(const struct imap *imap, uint32_t index)
+{
+struct imap_node *node = imap_get_node(imap, index);
+return node ? node->data : NULL;
+}
+
+/* Returns the node associated with 'index' in 'imap', or NULL. */
+struct imap_node *
+imap_get_node(const struct imap *imap, uint32_t index)
+{
+struct imap_node *node;
+uint32_t hash = hash_int(index, 0);
+
+HMAP_FOR_EACH_WITH_HASH (node, node, hash, &imap->map) {
+if (node->index == index) {
+return node;
+}
+}
+
+return NULL;
+}
+
+/* Returns true of there are no elements in 'imap'. */
+bool
+imap_is_empty(const struct imap *imap)
+{
+return hmap_is_empty(&imap->map);
+}
+
+/* Returns the number of elements in 'imap'. */
+size_t
+imap_count(const struct imap *imap)
+{
+return hmap_count(&imap->map);
+}
diff --git a/lib/imap.h b/lib/imap.h
new file mode 100644
index ..c90d02351ff8
--- /dev/null
+++ b/lib/imap.h
@@ -0,0 +1,63 @@
+/* Copyright (c) 2017 Nicira, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.  */
+
+#ifndef IMAP_H
+#define IMAP_H 1
+
+#include 

Re: [ovs-dev] Fwd: In OVS2.6 userspace datapath, ARP handling for non-tunnel packet?

2017-03-31 Thread Darrell Ball


From: Joo Kim 
Date: Thursday, March 30, 2017 at 5:09 PM
To: Darrell Ball 
Cc: "ovs-dev@openvswitch.org" 
Subject: Re: [ovs-dev] Fwd: In OVS2.6 userspace datapath, ARP handling for 
non-tunnel packet?

Thanks for reply Darrell.
BTW, why we don't try to send ARP request for the non-tunnel traffic by 
default?  If the mechanism(ARP handling via controller) you are describing is 
not installed,  then in current OVS-2.6 userspace datapath, non-tunnel traffic 
is just dropped?

In general, an Openflow switch supports routing with added rule configuration.
MAC binding rules must be specifically added. This can be done statically as 
well, where
the controller knows the MAC binding, from a CMS, which is statically 
configured and distributes
this information -> controller -> switch.
BTW, in the case of tunnels, there is both overlay and underlay mac bindings.
Applications sitting on top of OVS, like OVN (for NFV), should provide support
for mac bindings.
Take a look at OVN (tests in ovn.at and system-ovn.at).


On Mon, Mar 27, 2017 at 6:14 PM, Darrell Ball 
mailto:db...@vmware.com>> wrote:


On 3/23/17, 2:59 PM, 
"ovs-dev-boun...@openvswitch.org on 
behalf of Joo Kim" 
mailto:ovs-dev-boun...@openvswitch.org> on 
behalf of itsolut...@gmail.com> wrote:

Folks,

Anybody knows  about this ARP behavior in ovs2.6?   -thanks-


-- Forwarded message --
From: Joo Kim mailto:itsolut...@gmail.com>>
Date: Wed, Mar 22, 2017 at 3:58 AM
Subject: In OVS2.6 userspace datapath, ARP handling for non-tunnel packet?
To: ovs-dev@openvswitch.org


Hello,

Looks like build_tunnel_send() (which, I understand, is for tunnel
packet)   sends ARP request on the fly (using tnl_send_arp_request() )
when there is no ARP cache.

Then,  how about  ARP handling for NON-tunnel packet (=> which does not
call build_tunnel_send () )?Does it send arp request?

Not by default

 (In the code, I
don't find that kind of code)

I think you are referring to resolving the hop b/w HVs, without using tunnels
to connect said HVs, while using routing forwarding.

In this case, the expected use is for there to be a rule installed to send the 
original
packet to a controller, which would construct the arp request, send it back 
down to the switch,
have the arp reply (another rule) sent to it and later installing the binding 
rule.
This involves packet-ins/outs.



#0  build_tunnel_send (xport=0xdbab10, tunnel_odp_port=3,
flow=0x7fffb778, ctx=0x7fff9ac0)
 at ofproto/ofproto-dpif-xlate.c:2946
 #1  compose_output_action__ (ctx=ctx@entry=0x7fffa160, ofp_port=2,
xr=xr@entry=0x0,
 check_stp=check_stp@entry=true) at ofproto/ofproto-dpif-xlate.c:
3243
 #2  0x005d7bb2 in compose_output_action (xr=0x0,
ofp_port=,
 ctx=0x7fffa160) at ofproto/ofproto-dpif-xlate.c:3308
 #3  output_normal (ctx=ctx@entry=0x7fffa160,
out_xbundle=out_xbundle@entry=0xd96200,
 vlan=vlan@entry=0) at ofproto/ofproto-dpif-xlate.c:1958
 #4  0x005d81f6 in xlate_normal_flood (ctx=ctx@entry
=0x7fffa160,
 in_xbundle=in_xbundle@entry=0xd9b3e0, vlan=vlan@entry=0) at
ofproto/ofproto-dpif-xlate.c:2401
 #5  0x005d89ad in xlate_normal (ctx=0x7fffa160) at
ofproto/ofproto-dpif-xlate.c:2604
 #6  xlate_output_action (ctx=ctx@entry=0x7fffa160, port=,
 max_len=, may_packet_in=may_packet_in@entry=true)
 at ofproto/ofproto-dpif-xlate.c:3981
 #7  0x005d51ee in do_xlate_actions (ofpacts=ofpacts@entry=
0xd99ae8,
 ofpacts_len=ofpacts_len@entry=16, ctx=ctx@entry=0x7fffa160)
 at ofproto/ofproto-dpif-xlate.c:4781
 #8  0x005da384 in xlate_actions (xin=xin@entry=0x7fffb770,
 xout=xout@entry=0x7fffbb00) at ofproto/ofproto-dpif-xlate.c:
5618
 #9  0x005cec3c in upcall_xlate (wc=0x7fffce58,
odp_actions=0x7fffc680,
 upcall=0x7fffbaa0, udpif=0xd479b0) at
ofproto/ofproto-dpif-upcall.c:1102
 #10 process_upcall (udpif=udpif@entry=0xd479b0, upcall=upcall@entry=
0x7fffbaa0,
 odp_actions=odp_actions@entry=0x7fffc680, wc=wc@entry
=0x7fffce58)
___
dev mailing list
d...@openvswitch.org

https://urldefense.proofpoint.com/v2/url?u=https-3A__mail.openvswitch.org_mailman_listinfo_ovs-2Ddev&d=DwICAg&c=uilaK90D4TOVoH58JNXRgQ&r=BVhFA09CGX7JQ5Ih-uZnsw&m=grsVZ3eXMxJ9_ta4SIIRRhFhYcRMDJ0x3XzWaI7xSV8&s=DP1FHEMujvEevhithC2uOnBMI0o8ph5_C1xrAoKJQ2E&e=






___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH] table: provide table formatting option help at runtime

2017-03-31 Thread Lance Richardson
Show table formatting options with help output from
ovn-nbctl, obn-sbctl, ovs-vsctl, and vtep-ctl commands.
Include "--data" option in ovsdb-client help output.

Signed-off-by: Lance Richardson 
---
 lib/table.c   | 16 
 lib/table.h   |  1 +
 ovn/utilities/ovn-nbctl.c |  1 +
 ovn/utilities/ovn-sbctl.c |  1 +
 ovsdb/ovsdb-client.c  |  9 ++---
 utilities/ovs-vsctl.c |  1 +
 vtep/vtep-ctl.c   |  1 +
 7 files changed, 23 insertions(+), 7 deletions(-)

diff --git a/lib/table.c b/lib/table.c
index 9158499..6136beb 100644
--- a/lib/table.c
+++ b/lib/table.c
@@ -594,3 +594,19 @@ table_print(const struct table *table, const struct 
table_style *style)
 break;
 }
 }
+
+void
+table_usage(void)
+{
+printf("\nOutput formatting options:\n"
+   "  -f, --format=FORMAT set output formatting to FORMAT\n"
+   "  (\"table\", \"html\", \"csv\", "
+   "or \"json\")\n"
+   "  -d, --data=FORMAT   set table cell output formatting 
to\n"
+   "  FORMAT (\"string\", \"bare\", "
+   "or \"json\")\n"
+   "  --no-headings   omit table heading row\n"
+   "  --prettypretty-print JSON in output\n"
+   "  --bare  equivalent to "
+   "\"--format=list --data=bare --no-headings\"\n");
+}
diff --git a/lib/table.h b/lib/table.h
index 7330a33..fee3689 100644
--- a/lib/table.h
+++ b/lib/table.h
@@ -121,5 +121,6 @@ void table_parse_format(struct table_style *, const char 
*format);
 void table_parse_cell_format(struct table_style *, const char *format);
 
 void table_print(const struct table *, const struct table_style *);
+void table_usage(void);
 
 #endif /* table.h */
diff --git a/ovn/utilities/ovn-nbctl.c b/ovn/utilities/ovn-nbctl.c
index ebb9349..598f502 100644
--- a/ovn/utilities/ovn-nbctl.c
+++ b/ovn/utilities/ovn-nbctl.c
@@ -448,6 +448,7 @@ Options:\n\
   --oneline   print exactly one line of output per command\n",
program_name, program_name, ctl_get_db_cmd_usage(),
default_nb_db());
+table_usage();
 vlog_usage();
 printf("\
   --no-syslog equivalent to --verbose=nbctl:syslog:warn\n");
diff --git a/ovn/utilities/ovn-sbctl.c b/ovn/utilities/ovn-sbctl.c
index 4e3cbad..ffa931a 100644
--- a/ovn/utilities/ovn-sbctl.c
+++ b/ovn/utilities/ovn-sbctl.c
@@ -327,6 +327,7 @@ Options:\n\
   --oneline   print exactly one line of output per command\n",
program_name, program_name, ctl_get_db_cmd_usage(),
default_sb_db());
+table_usage();
 vlog_usage();
 printf("\
   --no-syslog equivalent to --verbose=sbctl:syslog:warn\n");
diff --git a/ovsdb/ovsdb-client.c b/ovsdb/ovsdb-client.c
index ba232fc..1df4fb4 100644
--- a/ovsdb/ovsdb-client.c
+++ b/ovsdb/ovsdb-client.c
@@ -282,13 +282,8 @@ usage(void)
"The default DATABASE is Open_vSwitch.\n",
program_name, program_name, ovs_rundir());
 stream_usage("SERVER", true, true, true);
-printf("\nOutput formatting options:\n"
-   "  -f, --format=FORMAT set output formatting to FORMAT\n"
-   "  (\"table\", \"html\", \"csv\", "
-   "or \"json\")\n"
-   "  --no-headings   omit table heading row\n"
-   "  --prettypretty-print JSON in output\n"
-   "  --timestamp timestamp \"monitor\" output");
+table_usage();
+printf("  --timestamp timestamp \"monitor\" output");
 daemon_usage();
 vlog_usage();
 printf("\nOther options:\n"
diff --git a/utilities/ovs-vsctl.c b/utilities/ovs-vsctl.c
index 4d9845e..84176de 100644
--- a/utilities/ovs-vsctl.c
+++ b/utilities/ovs-vsctl.c
@@ -421,6 +421,7 @@ Options:\n\
   --dry-run   do not commit changes to database\n\
   --oneline   print exactly one line of output per command\n",
program_name, program_name, ctl_get_db_cmd_usage(), 
ctl_default_db());
+table_usage();
 vlog_usage();
 printf("\
   --no-syslog equivalent to --verbose=vsctl:syslog:warn\n");
diff --git a/vtep/vtep-ctl.c b/vtep/vtep-ctl.c
index e23c987..7dc3cc7 100644
--- a/vtep/vtep-ctl.c
+++ b/vtep/vtep-ctl.c
@@ -366,6 +366,7 @@ Options:\n\
   --dry-run   do not commit changes to database\n\
   --oneline   print exactly one line of output per command\n",
program_name, program_name, ctl_get_db_cmd_usage(), 
ctl_default_db());
+table_usage();
 vlog_usage();
 printf("\
   --no-syslog equivalent to --verbose=vtep_ctl:syslog:warn\n");
-- 
2.7.4

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH 2/2] ovn-nbctl: include table formatting options in man page

2017-03-31 Thread Lance Richardson
Include descriptions of table formatting optiosn in ovn-nbctl
man page.

Signed-off-by: Lance Richardson 
---
 ovn/utilities/ovn-nbctl.8.xml | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/ovn/utilities/ovn-nbctl.8.xml b/ovn/utilities/ovn-nbctl.8.xml
index 10793ce..70afc10 100644
--- a/ovn/utilities/ovn-nbctl.8.xml
+++ b/ovn/utilities/ovn-nbctl.8.xml
@@ -847,6 +847,12 @@
 
 Logging options
 http://www.w3.org/2003/XInclude"/>
+
+Table Formatting Options
+These options control the format of output from the list and
+find commands.
+http://www.w3.org/2003/XInclude"/>
+
 PKI Options
 
   PKI configuration is required to use SSL for the connection to the
-- 
2.7.4

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH 1/2] table: add xml version of lib/table.man

2017-03-31 Thread Lance Richardson
Add lib/table.xml, translated from lib/table.man for inclusion
in XML man pages (such as ovn-nbctl.8.xml).

Signed-off-by: Lance Richardson 
---
 lib/automake.mk |   1 +
 lib/table.xml   | 114 
 2 files changed, 115 insertions(+)
 create mode 100644 lib/table.xml

diff --git a/lib/automake.mk b/lib/automake.mk
index b266af1..62b2f38 100644
--- a/lib/automake.mk
+++ b/lib/automake.mk
@@ -443,6 +443,7 @@ EXTRA_DIST += \
lib/db-ctl-base.xml \
lib/ssl.xml \
lib/ssl-bootstrap.xml \
+   lib/table.xml \
lib/vlog.xml
 
 MAN_FRAGMENTS += \
diff --git a/lib/table.xml b/lib/table.xml
new file mode 100644
index 000..e233eff
--- /dev/null
+++ b/lib/table.xml
@@ -0,0 +1,114 @@
+
+
+  -f format
+  --format=format
+  
+
+  Sets the type of table formatting.  The following types of
+  format are available:
+  
+   table
+
+  2-D text tables with aligned columns.
+
+
+list (default)
+
+  A list with one column per line and rows separated by a blank line.
+
+
+html
+
+  HTML tables.
+
+csv
+
+  Comma-separated values as defined in RFC 4180.
+
+
+json
+
+  JSON format as defined in RFC 4627.  The output
+  is a sequence of JSON objects, each of which corresponds to one
+  table.  Each JSON object has the following members with the noted
+  values:
+  
+caption
+
+  The table's caption.  This member is omitted if the table has
+  no caption.
+
+headings
+
+  An array with one element per table column.  Each array element
+  is a string giving the corresponding column's heading.
+
+data
+
+  An array with one element per table row.  Each element is also
+  an array with one element per table column.  The elements of
+  this second-level array are the cells that constitute the table.
+  Cells that represent OVSDB data or data types are expressed in
+  the format described in the OVSDB specification; other cells are
+  simply expressed as text strings.
+
+  
+
+  
+
+  
+  -d format
+  --data=format
+  
+
+  Sets the formatting for cells within output tables.  The following
+  types of format are available:
+  
+string (default)
+
+  The simple format described in the Database Values
+  section of ovs-vsctl(8).
+
+
+bare
+
+  The simple format with punctuation stripped off:
+  [] and {} are omitted around sets, maps,
+  and empty columns, items within sets and maps are space-separated,
+  and strings are never quoted.  This format may be easier for scripts
+  to parse.
+
+
+json
+
+  The json output format always outputs cells in JSON
+  format, ignoring this option.
+
+  
+
+  
+  --no-heading
+  
+This option suppresses the heading row that otherwise appears in the
+first row of table output.
+  
+  --pretty
+  
+
+  This option suppresses the heading row that otherwise appears in the
+  first row of table output.
+  By default, JSON in output is printed as compactly as possible.  This
+  option causes JSON in output to be printed in a more readable
+  fashion.  Members of objects and elements of arrays are printed one
+  per line, with indentation.
+
+
+  This option does not affect JSON in tables, which is always printed
+  compactly.
+
+  
+  --bare
+  
+Equivalent to --format=list --data=bare --no-headings.
+  
+
-- 
2.7.4

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH 0/2] add table formatting options to ovn-nbctl man page

2017-03-31 Thread Lance Richardson
Add missing descriptions of table formatting options to the
ovn-nbctl(8) man page.

Lance Richardson (2):
  table: add xml version of lib/table.man
  ovn-nbctl: include table formatting options in man page

 lib/automake.mk   |   1 +
 lib/table.xml | 114 ++
 ovn/utilities/ovn-nbctl.8.xml |   6 +++
 3 files changed, 121 insertions(+)
 create mode 100644 lib/table.xml

-- 
2.7.4

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH] build: Don't run tests in rpm makefile targets.

2017-03-31 Thread Russell Bryant
The RPM build makefile targets are helpful during development and testing,
but I personally almost never want the tests to run when I use them.
Leave tests on by default in the spec file for when the package is built by
distro build systems, but disable it by default in the Makefile targets and
update the documentation accordingly.

Signed-off-by: Russell Bryant 
---
 Documentation/intro/install/fedora.rst | 9 -
 rhel/automake.mk   | 1 +
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/Documentation/intro/install/fedora.rst 
b/Documentation/intro/install/fedora.rst
index ffc77a4..b5617dc 100644
--- a/Documentation/intro/install/fedora.rst
+++ b/Documentation/intro/install/fedora.rst
@@ -87,15 +87,14 @@ can be added:
 
 ::
 
-$ make rpm-fedora RPMBUILD_OPT="--with dpdk"
+$ make rpm-fedora RPMBUILD_OPT="--with dpdk --without check"
 
-The above commands automatically run the Open vSwitch unit tests, which can
-take several minutes.  To reduce the build time by disabling the execution of
-these tests, the ``--without check`` option can be added:
+You can also have the above commands automatically run the Open vSwitch unit
+tests.  This can take several minutes.
 
 ::
 
-$ make rpm-fedora RPMBUILD_OPT="--without check"
+$ make rpm-fedora RPMBUILD_OPT="--with check"
 
 Kernel OVS Tree Datapath RPM
 
diff --git a/rhel/automake.mk b/rhel/automake.mk
index c4f043a..1265fa7 100644
--- a/rhel/automake.mk
+++ b/rhel/automake.mk
@@ -55,6 +55,7 @@ $(srcdir)/rhel/openvswitch-fedora.spec: 
rhel/openvswitch-fedora.spec.in $(top_bu
$(update_rhel_spec)
 
 RPMBUILD_TOP := $(abs_top_builddir)/rpm/rpmbuild
+RPMBUILD_OPT ?= --without check
 
 # Build user-space RPMs
 rpm-fedora: dist $(srcdir)/rhel/openvswitch-fedora.spec
-- 
2.9.3

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


Re: [ovs-dev] [PATCH v1] ofproto-dpif-mirror: Fix issue of reseting snaplen in mirroring

2017-03-31 Thread William Tu
Looks good to me, thanks for the fix.

Acked-by: William Tu 

On Sun, Mar 26, 2017 at 8:16 PM, Zhenyu Gao  wrote:
> Currently, the mirror code doesn't check new value of snaplen when try
> to reconfigure snaplen.
> This patch fix this issue and add testings to reconfigure snaplen.
>
> Signed-off-by: Zhenyu Gao 
> ---
>  ofproto/ofproto-dpif-mirror.c |  3 ++-
>  tests/ofproto-dpif.at | 40 
>  2 files changed, 42 insertions(+), 1 deletion(-)
>
> diff --git a/ofproto/ofproto-dpif-mirror.c b/ofproto/ofproto-dpif-mirror.c
> index 675adf3..62dcc45 100644
> --- a/ofproto/ofproto-dpif-mirror.c
> +++ b/ofproto/ofproto-dpif-mirror.c
> @@ -252,7 +252,8 @@ mirror_set(struct mbridge *mbridge, void *aux, const char 
> *name,
>  && hmapx_equals(&dsts_map, &mirror->dsts)
>  && vlan_bitmap_equal(mirror->vlans, src_vlans)
>  && mirror->out == out
> -&& mirror->out_vlan == out_vlan)
> +&& mirror->out_vlan == out_vlan
> +&& mirror->snaplen == snaplen)
>  {
>  hmapx_destroy(&srcs_map);
>  hmapx_destroy(&dsts_map);
> diff --git a/tests/ofproto-dpif.at b/tests/ofproto-dpif.at
> index e3d79bd..0c2ea38 100644
> --- a/tests/ofproto-dpif.at
> +++ b/tests/ofproto-dpif.at
> @@ -4458,6 +4458,46 @@ AT_CHECK_UNQUOTED([tail -1 stdout], [0],
>  OVS_VSWITCHD_STOP
>  AT_CLEANUP
>
> +AT_SETUP([ofproto-dpif - mirroring, select_all with snaplen and reset 
> snaplen])
> +AT_KEYWORDS([mirror mirrors mirroring])
> +OVS_VSWITCHD_START
> +add_of_ports br0 1 2 3
> +ovs-vsctl \
> +set Bridge br0 mirrors=@m --\
> +--id=@p3 get Port p3 --\
> +--id=@m create Mirror name=mymirror select_all=true output_port=@p3 
> snaplen=100
> +
> +AT_DATA([flows.txt], [dnl
> +in_port=1 actions=output:2
> +in_port=2 actions=output:1
> +])
> +AT_CHECK([ovs-ofctl add-flows br0 flows.txt])
> +
> +flow="in_port(1),eth(src=50:54:00:00:00:05,dst=50:54:00:00:00:07),eth_type(0x0800),ipv4(src=192.168.0.1,dst=192.168.0.2,proto=1,tos=0,ttl=128,frag=no),icmp(type=8,code=0)"
> +AT_CHECK([ovs-appctl ofproto/trace ovs-dummy "$flow"], [0], [stdout])
> +AT_CHECK_UNQUOTED([tail -1 stdout], [0],
> +  [Datapath actions: trunc(100),3,2
> +])
> +
> +ovs-vsctl set mirror mymirror snaplen=77
> +
> +flow="in_port(2),eth(src=50:54:00:00:00:05,dst=50:54:00:00:00:07),eth_type(0x0800),ipv4(src=192.168.0.1,dst=192.168.0.2,proto=1,tos=0,ttl=128,frag=no),icmp(type=8,code=0)"
> +AT_CHECK([ovs-appctl ofproto/trace ovs-dummy "$flow"], [0], [stdout])
> +AT_CHECK_UNQUOTED([tail -1 stdout], [0],
> +  [Datapath actions: trunc(77),3,1
> +])
> +
> +ovs-vsctl set mirror mymirror snaplen=65535
> +
> +flow="in_port(2),eth(src=50:54:00:00:00:05,dst=50:54:00:00:00:07),eth_type(0x0800),ipv4(src=192.168.0.1,dst=192.168.0.2,proto=1,tos=0,ttl=128,frag=no),icmp(type=8,code=0)"
> +AT_CHECK([ovs-appctl ofproto/trace ovs-dummy "$flow"], [0], [stdout])
> +AT_CHECK_UNQUOTED([tail -1 stdout], [0],
> +  [Datapath actions: 3,1
> +])
> +
> +OVS_VSWITCHD_STOP
> +AT_CLEANUP
> +
>  AT_SETUP([ofproto-dpif - mirroring, select_src with snaplen])
>  AT_KEYWORDS([mirror mirrors mirroring])
>  OVS_VSWITCHD_START
> --
> 1.9.1
>
___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev