From: Justin Pettit Date: Tue, 4 Oct 2011 18:49:22 +0000 (-0700) Subject: nicira-ext: Fix build problems on 64-bit systems. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dc56021df437b866c372085c195b8bdd12bd87b2;p=openvswitch nicira-ext: Fix build problems on 64-bit systems. Commit d2c0fe (nicira-ext: Bump number of registers to five from four.) broke the build on 64-bit systems. This commit fixes the problems it introduced. --- diff --git a/lib/classifier.c b/lib/classifier.c index 02011e0c..1f58860b 100644 --- a/lib/classifier.c +++ b/lib/classifier.c @@ -450,7 +450,7 @@ cls_rule_format(const struct cls_rule *rule, struct ds *s) int i; - BUILD_ASSERT_DECL(FLOW_WC_SEQ == 1); + BUILD_ASSERT_DECL(FLOW_WC_SEQ == 2); if (rule->priority != OFP_DEFAULT_PRIORITY) { ds_put_format(s, "priority=%d,", rule->priority); @@ -1123,7 +1123,7 @@ flow_equal_except(const struct flow *a, const struct flow *b, const flow_wildcards_t wc = wildcards->wildcards; int i; - BUILD_ASSERT_DECL(FLOW_WC_SEQ == 1); + BUILD_ASSERT_DECL(FLOW_WC_SEQ == 2); for (i = 0; i < FLOW_N_REGS; i++) { if ((a->regs[i] ^ b->regs[i]) & wildcards->reg_masks[i]) { diff --git a/lib/flow.c b/lib/flow.c index 2d62a12d..1e5f2e5f 100644 --- a/lib/flow.c +++ b/lib/flow.c @@ -431,7 +431,7 @@ flow_zero_wildcards(struct flow *flow, const struct flow_wildcards *wildcards) const flow_wildcards_t wc = wildcards->wildcards; int i; - BUILD_ASSERT_DECL(FLOW_WC_SEQ == 1); + BUILD_ASSERT_DECL(FLOW_WC_SEQ == 2); for (i = 0; i < FLOW_N_REGS; i++) { flow->regs[i] &= wildcards->reg_masks[i]; @@ -558,7 +558,7 @@ flow_wildcards_init_catchall(struct flow_wildcards *wc) wc->ipv6_dst_mask = in6addr_any; memset(wc->reg_masks, 0, sizeof wc->reg_masks); wc->vlan_tci_mask = htons(0); - wc->zero = 0; + memset(wc->zeros, 0, sizeof wc->zeros); } /* Initializes 'wc' as an exact-match set of wildcards; that is, 'wc' does not @@ -574,7 +574,7 @@ flow_wildcards_init_exact(struct flow_wildcards *wc) wc->ipv6_dst_mask = in6addr_exact; memset(wc->reg_masks, 0xff, sizeof wc->reg_masks); wc->vlan_tci_mask = htons(UINT16_MAX); - wc->zero = 0; + memset(wc->zeros, 0, sizeof wc->zeros); } /* Returns true if 'wc' is exact-match, false if 'wc' wildcards any bits or @@ -584,7 +584,7 @@ flow_wildcards_is_exact(const struct flow_wildcards *wc) { int i; - BUILD_ASSERT_DECL(FLOW_WC_SEQ == 1); + BUILD_ASSERT_DECL(FLOW_WC_SEQ == 2); if (wc->wildcards || wc->tun_id_mask != htonll(UINT64_MAX) @@ -612,7 +612,7 @@ flow_wildcards_is_catchall(const struct flow_wildcards *wc) { int i; - BUILD_ASSERT_DECL(FLOW_WC_SEQ == 1); + BUILD_ASSERT_DECL(FLOW_WC_SEQ == 2); if (wc->wildcards != FWW_ALL || wc->tun_id_mask != htonll(0) @@ -664,7 +664,7 @@ flow_wildcards_hash(const struct flow_wildcards *wc, uint32_t basis) /* If you change struct flow_wildcards and thereby trigger this * assertion, please check that the new struct flow_wildcards has no holes * in it before you update the assertion. */ - BUILD_ASSERT_DECL(sizeof *wc == 56 + FLOW_N_REGS * 4); + BUILD_ASSERT_DECL(sizeof *wc == 60 + FLOW_N_REGS * 4); return hash_bytes(wc, sizeof *wc, basis); } diff --git a/lib/flow.h b/lib/flow.h index 5cbfca58..736890a3 100644 --- a/lib/flow.h +++ b/lib/flow.h @@ -35,7 +35,7 @@ struct ofpbuf; /* This sequence number should be incremented whenever anything involving flows * or the wildcarding of flows changes. This will cause build assertion * failures in places which likely need to be updated. */ -#define FLOW_WC_SEQ 1 +#define FLOW_WC_SEQ 2 #define FLOW_N_REGS 5 BUILD_ASSERT_DECL(FLOW_N_REGS <= NXM_NX_MAX_REGS); @@ -63,19 +63,18 @@ struct flow { struct in6_addr ipv6_src; /* IPv6 source address. */ struct in6_addr ipv6_dst; /* IPv6 destination address. */ struct in6_addr nd_target; /* IPv6 neighbor discovery (ND) target. */ - uint32_t reserved; /* Reserved for 64-bit packing. */ }; /* Assert that there are FLOW_SIG_SIZE bytes of significant data in "struct * flow", followed by FLOW_PAD_SIZE bytes of padding. */ #define FLOW_SIG_SIZE (100 + FLOW_N_REGS * 4) -#define FLOW_PAD_SIZE 4 +#define FLOW_PAD_SIZE 0 BUILD_ASSERT_DECL(offsetof(struct flow, nd_target) == FLOW_SIG_SIZE - 16); BUILD_ASSERT_DECL(sizeof(((struct flow *)0)->nd_target) == 16); BUILD_ASSERT_DECL(sizeof(struct flow) == FLOW_SIG_SIZE + FLOW_PAD_SIZE); /* Remember to update FLOW_WC_SEQ when changing 'struct flow'. */ -BUILD_ASSERT_DECL(FLOW_SIG_SIZE == 120 && FLOW_WC_SEQ == 1); +BUILD_ASSERT_DECL(FLOW_SIG_SIZE == 120 && FLOW_WC_SEQ == 2); int flow_extract(struct ofpbuf *, ovs_be64 tun_id, uint16_t in_port, struct flow *); @@ -136,7 +135,7 @@ typedef unsigned int OVS_BITWISE flow_wildcards_t; #define FWW_ALL ((OVS_FORCE flow_wildcards_t) (((1 << 12)) - 1)) /* Remember to update FLOW_WC_SEQ when adding or removing FWW_*. */ -BUILD_ASSERT_DECL(FWW_ALL == ((1 << 12) - 1) && FLOW_WC_SEQ == 1); +BUILD_ASSERT_DECL(FWW_ALL == ((1 << 12) - 1) && FLOW_WC_SEQ == 2); /* Information on wildcards for a flow, as a supplement to "struct flow". * @@ -151,11 +150,11 @@ struct flow_wildcards { struct in6_addr ipv6_src_mask; /* 1-bit in each signficant ipv6_src bit. */ struct in6_addr ipv6_dst_mask; /* 1-bit in each signficant ipv6_dst bit. */ ovs_be16 vlan_tci_mask; /* 1-bit in each significant vlan_tci bit. */ - uint16_t zero; /* Padding field set to zero. */ + uint8_t zeros[6]; /* Padding field set to zero. */ }; /* Remember to update FLOW_WC_SEQ when updating struct flow_wildcards. */ -BUILD_ASSERT_DECL(sizeof(struct flow_wildcards) == 76 && FLOW_WC_SEQ == 1); +BUILD_ASSERT_DECL(sizeof(struct flow_wildcards) == 80 && FLOW_WC_SEQ == 2); void flow_wildcards_init_catchall(struct flow_wildcards *); void flow_wildcards_init_exact(struct flow_wildcards *); diff --git a/lib/nx-match.c b/lib/nx-match.c index 0b9072b0..beaed3da 100644 --- a/lib/nx-match.c +++ b/lib/nx-match.c @@ -419,7 +419,7 @@ nx_put_match(struct ofpbuf *b, const struct cls_rule *cr) int match_len; int i; - BUILD_ASSERT_DECL(FLOW_WC_SEQ == 1); + BUILD_ASSERT_DECL(FLOW_WC_SEQ == 2); /* Metadata. */ if (!(wc & FWW_IN_PORT)) { diff --git a/lib/ofp-util.c b/lib/ofp-util.c index 52a996a5..b46219a7 100644 --- a/lib/ofp-util.c +++ b/lib/ofp-util.c @@ -99,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 == 1); + BUILD_ASSERT_DECL(FLOW_WC_SEQ == 2); /* Initialize most of rule->wc. */ flow_wildcards_init_catchall(wc); @@ -790,7 +790,7 @@ ofputil_min_flow_format(const struct cls_rule *rule) { const struct flow_wildcards *wc = &rule->wc; - BUILD_ASSERT_DECL(FLOW_WC_SEQ == 1); + BUILD_ASSERT_DECL(FLOW_WC_SEQ == 2); /* Only NXM supports separately wildcards the Ethernet multicast bit. */ if (!(wc->wildcards & FWW_DL_DST) != !(wc->wildcards & FWW_ETH_MCAST)) {