From eeba8e4fd3b9ae3c69fbf3ae9ef28a55184ac12a Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Fri, 6 May 2011 12:38:20 -0700 Subject: [PATCH] Fix up usage of flow_wildcards_t. The flow_wildcards_t type is defined as a distinct type from sparse's perspective (with __attribute__((bitwise))) so that we don't accidentally mix it with only-partially-compatible OFPFW_* flags. But we were weren't using it quite right in a few plces. This fixes it up. --- lib/nx-match.c | 2 +- lib/ofp-util.c | 13 ++++++------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/lib/nx-match.c b/lib/nx-match.c index 4d2e590e5..7c2aa7a04 100644 --- a/lib/nx-match.c +++ b/lib/nx-match.c @@ -680,7 +680,7 @@ nxm_put_eth(struct ofpbuf *b, uint32_t header, static void nxm_put_eth_dst(struct ofpbuf *b, - uint32_t wc, const uint8_t value[ETH_ADDR_LEN]) + flow_wildcards_t wc, const uint8_t value[ETH_ADDR_LEN]) { switch (wc & (FWW_DL_DST | FWW_ETH_MCAST)) { case FWW_DL_DST | FWW_ETH_MCAST: diff --git a/lib/ofp-util.c b/lib/ofp-util.c index 7b167257b..8a8a7b5cb 100644 --- a/lib/ofp-util.c +++ b/lib/ofp-util.c @@ -96,12 +96,11 @@ ofputil_netmask_to_wcbits(ovs_be32 netmask) /* WC_INVARIANTS is the invariant bits (as defined on WC_INVARIANT_LIST) all * OR'd together. */ -enum { - WC_INVARIANTS = 0 +static const flow_wildcards_t WC_INVARIANTS = 0 #define WC_INVARIANT_BIT(NAME) | FWW_##NAME WC_INVARIANT_LIST #undef WC_INVARIANT_BIT -}; +; /* Converts the ofp_match in 'match' into a cls_rule in 'rule', with the given * 'priority'. */ @@ -110,7 +109,7 @@ ofputil_cls_rule_from_match(const struct ofp_match *match, unsigned int priority, struct cls_rule *rule) { struct flow_wildcards *wc = &rule->wc; - unsigned int ofpfw; + uint32_t ofpfw; ovs_be16 vid, pcp; /* Initialize rule->priority. */ @@ -119,7 +118,7 @@ ofputil_cls_rule_from_match(const struct ofp_match *match, /* Initialize most of rule->wc. */ flow_wildcards_init_catchall(wc); - wc->wildcards = ofpfw & WC_INVARIANTS; + wc->wildcards = (OVS_FORCE flow_wildcards_t) 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); @@ -202,10 +201,10 @@ void ofputil_cls_rule_to_match(const struct cls_rule *rule, struct ofp_match *match) { const struct flow_wildcards *wc = &rule->wc; - unsigned int ofpfw; + uint32_t ofpfw; /* Figure out most OpenFlow wildcards. */ - ofpfw = wc->wildcards & WC_INVARIANTS; + ofpfw = (OVS_FORCE uint32_t) (wc->wildcards & WC_INVARIANTS); ofpfw |= ofputil_netmask_to_wcbits(wc->nw_src_mask) << OFPFW_NW_SRC_SHIFT; ofpfw |= ofputil_netmask_to_wcbits(wc->nw_dst_mask) << OFPFW_NW_DST_SHIFT; if (wc->wildcards & FWW_NW_TOS) { -- 2.20.1