Skip to content

Commit

Permalink
meta-flow: Make it simpler to expand mf_values in the future
Browse files Browse the repository at this point in the history
Remove hard coded array index and make it dependent on the array size.

Signed-off-by: Madhu Challa <challa@noironetworks.com>
Co-authored-by: Ben Pfaff <blp@nicira.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
  • Loading branch information
mchalla and blp committed Nov 6, 2014
1 parent fb39399 commit f98e6e5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/learn.c
Expand Up @@ -147,7 +147,8 @@ learn_execute(const struct ofpact_learn *learn, const struct flow *flow,
case NX_LEARN_DST_OUTPUT:
if (spec->n_bits <= 16
|| is_all_zeros(value.u8, sizeof value - 2)) {
ofp_port_t port = u16_to_ofp(ntohs(value.be16[7]));
ovs_be16 *last_be16 = &value.be16[ARRAY_SIZE(value.be16) - 1];
ofp_port_t port = u16_to_ofp(ntohs(*last_be16));

if (ofp_to_u16(port) < ofp_to_u16(OFPP_MAX)
|| port == OFPP_IN_PORT
Expand Down Expand Up @@ -209,7 +210,8 @@ learn_parse_load_immediate(const char *s, struct ofpact_learn_spec *spec)
}
s = arrow;
} else {
imm.be64[1] = htonll(strtoull(s, (char **) &s, 0));
ovs_be64 *last_be64 = &imm.be64[ARRAY_SIZE(imm.be64) - 1];
*last_be64 = htonll(strtoull(s, (char **) &s, 0));
}

if (strncmp(s, "->", 2)) {
Expand Down
2 changes: 2 additions & 0 deletions lib/meta-flow.h
Expand Up @@ -1503,7 +1503,9 @@ union mf_value {
};
BUILD_ASSERT_DECL(sizeof(union mf_value) == 16);

/* An all-1-bits mf_value. Needs to be updated if struct mf_value grows.*/
#define MF_EXACT_MASK_INITIALIZER { IN6ADDR_EXACT_INIT }
BUILD_ASSERT_DECL(sizeof(union mf_value) == sizeof(struct in6_addr));

/* Part of a field. */
struct mf_subfield {
Expand Down

0 comments on commit f98e6e5

Please sign in to comment.