projects
/
openvswitch
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
vswitchd: Make Interface's ofport a persistent column.
[openvswitch]
/
lib
/
ofp-util.c
diff --git
a/lib/ofp-util.c
b/lib/ofp-util.c
index ad3fb369219fe8f666219719be1ef1fa40f4d9a4..4facf0a579b631a876ad85de278f61a8f0ce8c98 100644
(file)
--- a/
lib/ofp-util.c
+++ b/
lib/ofp-util.c
@@
-85,7
+85,7
@@
ofputil_netmask_to_wcbits(ovs_be32 netmask)
void
ofputil_wildcard_from_ofpfw10(uint32_t ofpfw, struct flow_wildcards *wc)
{
void
ofputil_wildcard_from_ofpfw10(uint32_t ofpfw, struct flow_wildcards *wc)
{
- BUILD_ASSERT_DECL(FLOW_WC_SEQ == 1
7
);
+ BUILD_ASSERT_DECL(FLOW_WC_SEQ == 1
8
);
/* Initialize most of wc. */
flow_wildcards_init_catchall(wc);
/* Initialize most of wc. */
flow_wildcards_init_catchall(wc);
@@
-588,6
+588,7
@@
static const struct proto_abbrev proto_abbrevs[] = {
#define N_PROTO_ABBREVS ARRAY_SIZE(proto_abbrevs)
enum ofputil_protocol ofputil_flow_dump_protocols[] = {
#define N_PROTO_ABBREVS ARRAY_SIZE(proto_abbrevs)
enum ofputil_protocol ofputil_flow_dump_protocols[] = {
+ OFPUTIL_P_OF12_OXM,
OFPUTIL_P_OF10_NXM,
OFPUTIL_P_OF10_STD,
};
OFPUTIL_P_OF10_NXM,
OFPUTIL_P_OF10_STD,
};
@@
-847,7
+848,7
@@
ofputil_protocols_from_string(const char *s)
return protocols;
}
return protocols;
}
-static
enum ofp_version
+static
int
ofputil_version_from_string(const char *s)
{
if (!strcasecmp(s, "OpenFlow10")) {
ofputil_version_from_string(const char *s)
{
if (!strcasecmp(s, "OpenFlow10")) {
@@
-859,7
+860,7
@@
ofputil_version_from_string(const char *s)
if (!strcasecmp(s, "OpenFlow12")) {
return OFP12_VERSION;
}
if (!strcasecmp(s, "OpenFlow12")) {
return OFP12_VERSION;
}
-
VLOG_FATAL("Unknown OpenFlow version: \"%s\"", s)
;
+
return 0
;
}
static bool
}
static bool
@@
-876,7
+877,7
@@
ofputil_versions_from_string(const char *s)
while (s[i]) {
size_t j;
while (s[i]) {
size_t j;
-
enum ofp_version
version;
+
int
version;
char *key;
if (is_delimiter(s[i])) {
char *key;
if (is_delimiter(s[i])) {
@@
-889,6
+890,9
@@
ofputil_versions_from_string(const char *s)
}
key = xmemdup0(s + i, j);
version = ofputil_version_from_string(key);
}
key = xmemdup0(s + i, j);
version = ofputil_version_from_string(key);
+ if (!version) {
+ VLOG_FATAL("Unknown OpenFlow version: \"%s\"", key);
+ }
free(key);
bitmap |= 1u << version;
i += j;
free(key);
bitmap |= 1u << version;
i += j;
@@
-897,6
+901,23
@@
ofputil_versions_from_string(const char *s)
return bitmap;
}
return bitmap;
}
+uint32_t
+ofputil_versions_from_strings(char ** const s, size_t count)
+{
+ uint32_t bitmap = 0;
+
+ while (count--) {
+ int version = ofputil_version_from_string(s[count]);
+ if (!version) {
+ VLOG_WARN("Unknown OpenFlow version: \"%s\"", s[count]);
+ } else {
+ bitmap |= 1u << version;
+ }
+ }
+
+ return bitmap;
+}
+
const char *
ofputil_version_to_string(enum ofp_version ofp_version)
{
const char *
ofputil_version_to_string(enum ofp_version ofp_version)
{
@@
-958,6
+979,16
@@
regs_fully_wildcarded(const struct flow_wildcards *wc)
return true;
}
return true;
}
+static bool
+tun_parms_fully_wildcarded(const struct flow_wildcards *wc)
+{
+ return (!wc->masks.tunnel.ip_src &&
+ !wc->masks.tunnel.ip_dst &&
+ !wc->masks.tunnel.ip_ttl &&
+ !wc->masks.tunnel.ip_tos &&
+ !wc->masks.tunnel.flags);
+}
+
/* Returns a bit-mask of ofputil_protocols that can be used for sending 'match'
* to a switch (e.g. to add or remove a flow). Only NXM can handle tunnel IDs,
* registers, or fixing the Ethernet multicast bit. Otherwise, it's better to
/* Returns a bit-mask of ofputil_protocols that can be used for sending 'match'
* to a switch (e.g. to add or remove a flow). Only NXM can handle tunnel IDs,
* registers, or fixing the Ethernet multicast bit. Otherwise, it's better to
@@
-967,7
+998,12
@@
ofputil_usable_protocols(const struct match *match)
{
const struct flow_wildcards *wc = &match->wc;
{
const struct flow_wildcards *wc = &match->wc;
- BUILD_ASSERT_DECL(FLOW_WC_SEQ == 17);
+ BUILD_ASSERT_DECL(FLOW_WC_SEQ == 18);
+
+ /* tunnel params other than tun_id can't be sent in a flow_mod */
+ if (!tun_parms_fully_wildcarded(wc)) {
+ return OFPUTIL_P_NONE;
+ }
/* NXM, OXM, and OF1.1 support bitwise matching on ethernet addresses. */
if (!eth_mask_is_exact(wc->masks.dl_src)
/* NXM, OXM, and OF1.1 support bitwise matching on ethernet addresses. */
if (!eth_mask_is_exact(wc->masks.dl_src)
@@
-1233,7
+1269,9
@@
ofputil_encode_set_protocol(enum ofputil_protocol current,
return ofputil_encode_nx_set_flow_format(NXFF_OPENFLOW10);
case OFPUTIL_P_OF12_OXM:
return ofputil_encode_nx_set_flow_format(NXFF_OPENFLOW10);
case OFPUTIL_P_OF12_OXM:
- return ofputil_encode_nx_set_flow_format(NXFF_OPENFLOW12);
+ /* There's only one OpenFlow 1.2 protocol and we already verified
+ * above that we're not trying to change versions. */
+ NOT_REACHED();
case OFPUTIL_P_OF10_STD_TID:
case OFPUTIL_P_OF10_NXM_TID:
case OFPUTIL_P_OF10_STD_TID:
case OFPUTIL_P_OF10_NXM_TID:
@@
-1283,9
+1321,6
@@
ofputil_nx_flow_format_to_protocol(enum nx_flow_format flow_format)
case NXFF_NXM:
return OFPUTIL_P_OF10_NXM;
case NXFF_NXM:
return OFPUTIL_P_OF10_NXM;
- case NXFF_OPENFLOW12:
- return OFPUTIL_P_OF12_OXM;
-
default:
return 0;
}
default:
return 0;
}
@@
-1308,8
+1343,6
@@
ofputil_nx_flow_format_to_string(enum nx_flow_format flow_format)
return "openflow10";
case NXFF_NXM:
return "nxm";
return "openflow10";
case NXFF_NXM:
return "nxm";
- case NXFF_OPENFLOW12:
- return "openflow12";
default:
NOT_REACHED();
}
default:
NOT_REACHED();
}
@@
-1612,7
+1645,6
@@
ofputil_flow_mod_usable_protocols(const struct ofputil_flow_mod *fms,
usable_protocols &= OFPUTIL_P_OF10_NXM_ANY | OFPUTIL_P_OF12_OXM;
}
}
usable_protocols &= OFPUTIL_P_OF10_NXM_ANY | OFPUTIL_P_OF12_OXM;
}
}
- assert(usable_protocols);
return usable_protocols;
}
return usable_protocols;
}