2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-31 06:15:47 +00:00

flow: Adds support for arbitrary ethernet masking

Arbitrary ethernet mask support is one step on the way to support for OpenFlow
1.1+. This patch set seeks to add this capability without breaking current
protocol support.

Signed-off-by: Joe Stringer <joe@wand.net.nz>
[blp@nicira.com made some updates, see
 http://openvswitch.org/pipermail/dev/2012-May/017585.html]
Signed-off-by: Ben Pfaff <blp@nicira.com>
This commit is contained in:
Joe Stringer
2012-05-29 00:38:21 +12:00
committed by Ben Pfaff
parent 623e1caf2f
commit 73c0ce349b
16 changed files with 176 additions and 213 deletions

View File

@@ -76,8 +76,6 @@ ofputil_netmask_to_wcbits(ovs_be32 netmask)
* name. */
#define WC_INVARIANT_LIST \
WC_INVARIANT_BIT(IN_PORT) \
WC_INVARIANT_BIT(DL_SRC) \
WC_INVARIANT_BIT(DL_DST) \
WC_INVARIANT_BIT(DL_TYPE) \
WC_INVARIANT_BIT(NW_PROTO)
@@ -101,7 +99,7 @@ static const flow_wildcards_t WC_INVARIANTS = 0
void
ofputil_wildcard_from_openflow(uint32_t ofpfw, struct flow_wildcards *wc)
{
BUILD_ASSERT_DECL(FLOW_WC_SEQ == 10);
BUILD_ASSERT_DECL(FLOW_WC_SEQ == 11);
/* Initialize most of rule->wc. */
flow_wildcards_init_catchall(wc);
@@ -127,11 +125,11 @@ ofputil_wildcard_from_openflow(uint32_t ofpfw, struct flow_wildcards *wc)
wc->tp_dst_mask = htons(UINT16_MAX);
}
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;
if (!(ofpfw & OFPFW_DL_SRC)) {
memset(wc->dl_src_mask, 0xff, ETH_ADDR_LEN);
}
if (!(ofpfw & OFPFW_DL_DST)) {
memset(wc->dl_dst_mask, 0xff, ETH_ADDR_LEN);
}
/* VLAN TCI mask. */
@@ -212,6 +210,12 @@ ofputil_cls_rule_to_match(const struct cls_rule *rule, struct ofp_match *match)
if (!wc->tp_dst_mask) {
ofpfw |= OFPFW_TP_DST;
}
if (eth_addr_is_zero(wc->dl_src_mask)) {
ofpfw |= OFPFW_DL_SRC;
}
if (eth_addr_is_zero(wc->dl_dst_mask)) {
ofpfw |= OFPFW_DL_DST;
}
/* Translate VLANs. */
match->dl_vlan = htons(0);
@@ -1174,10 +1178,15 @@ ofputil_usable_protocols(const struct cls_rule *rule)
{
const struct flow_wildcards *wc = &rule->wc;
BUILD_ASSERT_DECL(FLOW_WC_SEQ == 10);
BUILD_ASSERT_DECL(FLOW_WC_SEQ == 11);
/* Only NXM supports separately wildcards the Ethernet multicast bit. */
if (!(wc->wildcards & FWW_DL_DST) != !(wc->wildcards & FWW_ETH_MCAST)) {
/* NXM and OF1.1+ supports bitwise matching on ethernet addresses. */
if (!eth_mask_is_exact(wc->dl_src_mask)
&& !eth_addr_is_zero(wc->dl_src_mask)) {
return OFPUTIL_P_NXM_ANY;
}
if (!eth_mask_is_exact(wc->dl_dst_mask)
&& !eth_addr_is_zero(wc->dl_dst_mask)) {
return OFPUTIL_P_NXM_ANY;
}