On Fri, May 27, 2011 at 09:12:38AM -0700, Ben Pfaff wrote:
> On Wed, May 25, 2011 at 02:19:07PM -0700, Jean Tourrilhes wrote:
> > I tried to use ovs-controller in the 1.1.0 branch, and the
> > support for was broken. I fixed it and I also improved it so that you
> > an specify any wildcard you want from the command line.
>
> Would you mind adding an update to the ovs-controller documentation
> also? And then send it to [email protected]? Thanks.
>
> I'll take time to review this in detail next week.
Here it is...
Note that I forgot to mention that the current wildcard you
picked generate normalisation warnings, and my patch fixes that.
Have fun...
Jean
diff -u -p -r openvswitch-1.1.0-clean//lib/learning-switch.c openvswitch-1.1.0-jean1//lib/learning-switch.c
--- openvswitch-1.1.0-clean//lib/learning-switch.c 2011-04-07 08:41:17.000000000 -0700
+++ openvswitch-1.1.0-jean1//lib/learning-switch.c 2011-05-25 14:12:05.000000000 -0700
@@ -101,13 +101,27 @@ lswitch_create(struct rconn *rconn, cons
flow_wildcards_init_exact(&sw->wc);
if (!cfg->exact_flows) {
- /* We cannot wildcard all fields.
- * We need in_port to detect moves.
- * We need both SA and DA to do learning. */
- sw->wc.wildcards = (FWW_DL_TYPE | FWW_NW_PROTO
- | FWW_TP_SRC | FWW_TP_DST);
- sw->wc.nw_src_mask = htonl(0);
- sw->wc.nw_dst_mask = htonl(0);
+ uint32_t wildcards = cfg->wildcards;
+
+ /* Check if a wildcard was provided */
+ if (wildcards == 0) {
+ /* No wildcard defined, try to wildcard as many fields
+ * as possible, however we cannot wildcard all fields.
+ * We need in_port to detect moves.
+ * We need both MAC SA and DA to do L2 learning. Jean II */
+ wildcards = (OFPFW_DL_TYPE | OFPFW_NW_SRC_ALL | OFPFW_NW_DST_ALL
+ | OFPFW_NW_TOS | OFPFW_NW_PROTO
+ | OFPFW_TP_SRC | OFPFW_TP_DST);
+ /* Note : this L2 only wildcard is 0x2820F0
+ * For a L3 only wildcard, use --wildcards=0x2000EC. Jean II. */
+ }
+ VLOG_DBG("%016llx: using OpenFlow wildcards 0x%X",
+ sw->datapath_id, wildcards);
+
+ /* Translate supplied OpenFlow wildcard to internal format */
+ ofputil_wildcard_from_openflow(wildcards, &sw->wc);
+ /* Assume VLAN is always exact match for segregation. */
+ sw->wc.vlan_tci_mask = htons(0);
}
sw->default_queue = cfg->default_queue;
diff -u -p -r openvswitch-1.1.0-clean//lib/learning-switch.h openvswitch-1.1.0-jean1//lib/learning-switch.h
--- openvswitch-1.1.0-clean//lib/learning-switch.h 2011-04-07 08:41:17.000000000 -0700
+++ openvswitch-1.1.0-jean1//lib/learning-switch.h 2011-05-23 17:54:27.000000000 -0700
@@ -35,6 +35,7 @@ struct lswitch_config {
/* Set up only exact-match flows? */
bool exact_flows;
+ uint32_t wildcards; /* Wildcard fields when not exact. */
/* <0: Process every packet at the controller.
* >=0: Expire flows after they are unused for 'max_idle' seconds.
diff -u -p -r openvswitch-1.1.0-clean//lib/ofp-util.c openvswitch-1.1.0-jean1//lib/ofp-util.c
--- openvswitch-1.1.0-clean//lib/ofp-util.c 2011-04-07 08:41:17.000000000 -0700
+++ openvswitch-1.1.0-jean1//lib/ofp-util.c 2011-05-24 18:18:25.000000000 -0700
@@ -100,6 +100,34 @@ enum {
#undef WC_INVARIANT_BIT
};
+/* Converts the wildcard in 'ofpfw' into a flow_wildcards in 'wc' for use
+ * in struct cls_rule.
+ * Don't process VLAN bits, it's too messy. */
+void
+ofputil_wildcard_from_openflow(uint32_t ofpfw,
+ struct flow_wildcards *wc)
+{
+ /* Initialize most of rule->wc. */
+ flow_wildcards_init_catchall(wc);
+ wc->wildcards = ofpfw & WC_INVARIANTS;
+
+ /* Wildcard fields that aren't defined by ofp_match or tun_id. */
+ wc->wildcards |= (FWW_ARP_SHA | FWW_ARP_THA | FWW_ND_TARGET);
+
+ if (ofpfw & OFPFW_NW_TOS) {
+ wc->wildcards |= FWW_NW_TOS;
+ }
+ wc->nw_src_mask = ofputil_wcbits_to_netmask(ofpfw >> OFPFW_NW_SRC_SHIFT);
+ wc->nw_dst_mask = ofputil_wcbits_to_netmask(ofpfw >> OFPFW_NW_DST_SHIFT);
+
+ if (ofpfw & OFPFW_DL_DST) {
+ /* OpenFlow 1.0 OFPFW_DL_DST covers the whole Ethernet destination, but
+ * Open vSwitch breaks the Ethernet destination into bits as FWW_DL_DST
+ * and FWW_ETH_MCAST. */
+ wc->wildcards |= FWW_ETH_MCAST;
+ }
+}
+
/* Converts the ofp_match in 'match' into a cls_rule in 'rule', with the given
* 'priority'.
*
@@ -122,30 +150,12 @@ ofputil_cls_rule_from_match(const struct
ofpfw &= flow_format == NXFF_TUN_ID_FROM_COOKIE ? OVSFW_ALL : OFPFW_ALL;
rule->priority = !ofpfw ? UINT16_MAX : priority;
- /* Initialize most of rule->wc. */
- flow_wildcards_init_catchall(wc);
- wc->wildcards = ofpfw & WC_INVARIANTS;
-
- /* Wildcard fields that aren't defined by ofp_match or tun_id. */
- wc->wildcards |= (FWW_ARP_SHA | FWW_ARP_THA | FWW_ND_TARGET);
-
- if (ofpfw & OFPFW_NW_TOS) {
- wc->wildcards |= FWW_NW_TOS;
- }
- wc->nw_src_mask = ofputil_wcbits_to_netmask(ofpfw >> OFPFW_NW_SRC_SHIFT);
- wc->nw_dst_mask = ofputil_wcbits_to_netmask(ofpfw >> OFPFW_NW_DST_SHIFT);
+ ofputil_wildcard_from_openflow(ofpfw, wc);
if (flow_format == NXFF_TUN_ID_FROM_COOKIE && !(ofpfw & NXFW_TUN_ID)) {
rule->flow.tun_id = htonll(ntohll(cookie) >> 32);
}
- if (ofpfw & OFPFW_DL_DST) {
- /* OpenFlow 1.0 OFPFW_DL_DST covers the whole Ethernet destination, but
- * Open vSwitch breaks the Ethernet destination into bits as FWW_DL_DST
- * and FWW_ETH_MCAST. */
- wc->wildcards |= FWW_ETH_MCAST;
- }
-
/* Initialize most of rule->flow. */
rule->flow.nw_src = match->nw_src;
rule->flow.nw_dst = match->nw_dst;
diff -u -p -r openvswitch-1.1.0-clean//lib/ofp-util.h openvswitch-1.1.0-jean1//lib/ofp-util.h
--- openvswitch-1.1.0-clean//lib/ofp-util.h 2011-04-07 08:41:17.000000000 -0700
+++ openvswitch-1.1.0-jean1//lib/ofp-util.h 2011-05-24 10:01:29.000000000 -0700
@@ -98,6 +98,10 @@ const char *ofputil_msg_type_name(const
ovs_be32 ofputil_wcbits_to_netmask(int wcbits);
int ofputil_netmask_to_wcbits(ovs_be32 netmask);
+/* wildcard translation between OpenFlow and 'struct cls_rule' format. */
+void ofputil_wildcard_from_openflow(uint32_t ofpfw,
+ struct flow_wildcards *wc);
+
/* Work with OpenFlow 1.0 ofp_match. */
void ofputil_cls_rule_from_match(const struct ofp_match *,
unsigned int priority, enum nx_flow_format,
diff -u -p -r openvswitch-1.1.0-clean//Makefile.in openvswitch-1.1.0-jean1//Makefile.in
--- openvswitch-1.1.0-clean//Makefile.in 2011-04-07 10:19:10.000000000 -0700
+++ openvswitch-1.1.0-jean1//Makefile.in 2011-05-20 17:38:34.000000000 -0700
@@ -635,6 +635,8 @@ PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
PERL = @PERL@
PKG_CONFIG = @PKG_CONFIG@
+PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
+PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
PKIDIR = @PKIDIR@
PYTHON = @PYTHON@
PYUIC4 = @PYUIC4@
diff -u -p -r openvswitch-1.1.0-clean//utilities/ovs-controller.8.in openvswitch-1.1.0-jean1//utilities/ovs-controller.8.in
--- openvswitch-1.1.0-clean//utilities/ovs-controller.8.in 2011-04-07 08:41:17.000000000 -0700
+++ openvswitch-1.1.0-jean1//utilities/ovs-controller.8.in 2011-05-27 10:18:53.000000000 -0700
@@ -66,12 +66,28 @@ This option is most useful for debugging
performance, so it should not be used in production.
.
.IP "\fB\-w\fR"
-.IQ "\fB\-\-wildcard\fR"
+.IQ "\fB\-\-wildcards\fR[\fB=\fIwildcard_mask\fR]\fR"
By default, \fBovs\-controller\fR sets up exact-match flows. This
option allows it to set up wildcarded flows, which may reduce
flow-setup latency by causing less traffic to be sent up to the
controller.
.IP
+The optional \fIwildcard_mask\fR is an OpenFlow wildcard bitmask in
+hexadecimal and specify the type of wildcarding to perform. If no
+\fIwildcard_bits\fR is specified, the default value 0x2820F0 is used
+which specifies L2 only switching and wildcards L3 and L4
+fields. Another interesting value is 0x2000EC which specifies L3 only
+switching and wildcards L2 and L4 fields.
+.IP
+This option has no effect when \fB\-n\fR (or \fB\-\-noflow\fR) is in use
+(because the controller does not set up flows in that case).
+.
+.IP "\fB\-e\fR"
+.IQ "\fB\-\-exact\-match"
+Force \fBovs\-controller\fR sets up exact-match flows, which is the
+default. Every flow is fully specified which give the most visibility
+to the controller, but also the highest overhead.
+.IP
This option has no effect when \fB\-n\fR (or \fB\-\-noflow\fR) is in use
(because the controller does not set up flows in that case).
.
diff -u -p -r openvswitch-1.1.0-clean//utilities/ovs-controller.c openvswitch-1.1.0-jean1//utilities/ovs-controller.c
--- openvswitch-1.1.0-clean//utilities/ovs-controller.c 2011-04-07 08:41:17.000000000 -0700
+++ openvswitch-1.1.0-jean1//utilities/ovs-controller.c 2011-05-27 10:18:35.000000000 -0700
@@ -63,6 +63,7 @@ static bool action_normal = false;
/* -w, --wildcard: Set up exact match or wildcard flow entries? */
static bool exact_flows = true;
+static uint32_t wildcards = 0;
/* --max-idle: Maximum idle time, in seconds, before flows expire. */
static int max_idle = 60;
@@ -228,6 +229,8 @@ new_switch(struct switch_ *sw, struct vc
cfg.mode = (action_normal ? LSW_NORMAL
: learn_macs ? LSW_LEARN
: LSW_FLOOD);
+ cfg.exact_flows = exact_flows;
+ cfg.wildcards = wildcards;
cfg.max_idle = set_up_flows ? max_idle : -1;
cfg.default_flows = &default_flows;
cfg.default_queue = default_queue;
@@ -314,7 +317,8 @@ parse_options(int argc, char *argv[])
{"hub", no_argument, 0, 'H'},
{"noflow", no_argument, 0, 'n'},
{"normal", no_argument, 0, 'N'},
- {"wildcard", no_argument, 0, 'w'},
+ {"wildcards", optional_argument, 0, 'w'},
+ {"exact-match", no_argument, 0, 'e'},
{"max-idle", required_argument, 0, OPT_MAX_IDLE},
{"mute", no_argument, 0, OPT_MUTE},
{"queue", required_argument, 0, 'q'},
@@ -361,6 +365,14 @@ parse_options(int argc, char *argv[])
case 'w':
exact_flows = false;
+ if (optarg) {
+ /* Expect HEX value */
+ wildcards = strtol(optarg, NULL, 16);
+ }
+ break;
+
+ case 'e':
+ exact_flows = true;
break;
case OPT_MAX_IDLE:
_______________________________________________
dev mailing list
[email protected]
http://openvswitch.org/mailman/listinfo/dev