mirror of
https://github.com/openvswitch/ovs
synced 2025-10-29 15:28:56 +00:00
meta-flow: Add convenience members to union mf_subvalue.
This makes access to the least-significant bits more convenient. This commit simplifies a few existing cases; later commits will make more use of this feature. Signed-off-by: Ben Pfaff <blp@nicira.com> Acked-by: Russell Bryant <rbryant@redhat.com>
This commit is contained in:
@@ -148,8 +148,7 @@ 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)) {
|
||||
ovs_be16 *last_be16 = &value.be16[ARRAY_SIZE(value.be16) - 1];
|
||||
ofp_port_t port = u16_to_ofp(ntohs(*last_be16));
|
||||
ofp_port_t port = u16_to_ofp(ntohll(value.integer));
|
||||
|
||||
if (ofp_to_u16(port) < ofp_to_u16(OFPP_MAX)
|
||||
|| port == OFPP_IN_PORT
|
||||
@@ -211,8 +210,7 @@ learn_parse_load_immediate(const char *s, struct ofpact_learn_spec *spec)
|
||||
}
|
||||
s = arrow;
|
||||
} else {
|
||||
ovs_be64 *last_be64 = &imm.be64[ARRAY_SIZE(imm.be64) - 1];
|
||||
*last_be64 = htonll(strtoull(s, (char **) &s, 0));
|
||||
imm.integer = htonll(strtoull(s, (char **) &s, 0));
|
||||
}
|
||||
|
||||
if (strncmp(s, "->", 2)) {
|
||||
|
||||
@@ -1567,10 +1567,26 @@ struct mf_subfield {
|
||||
* value" contains NXM_OF_VLAN_TCI[0..11], then one could access the
|
||||
* corresponding data in value.be16[7] as the bits in the mask htons(0xfff). */
|
||||
union mf_subvalue {
|
||||
/* Access to full data. */
|
||||
uint8_t u8[16];
|
||||
ovs_be16 be16[8];
|
||||
ovs_be32 be32[4];
|
||||
ovs_be64 be64[2];
|
||||
|
||||
/* Convenient access to just least-significant bits in various forms. */
|
||||
struct {
|
||||
ovs_be64 dummy_integer;
|
||||
ovs_be64 integer;
|
||||
};
|
||||
struct {
|
||||
uint8_t dummy_mac[10];
|
||||
uint8_t mac[6];
|
||||
};
|
||||
struct {
|
||||
ovs_be32 dummy_ipv4[3];
|
||||
ovs_be32 ipv4;
|
||||
};
|
||||
struct in6_addr ipv6;
|
||||
};
|
||||
BUILD_ASSERT_DECL(sizeof(union mf_value) == sizeof (union mf_subvalue));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user