[ovs-dev] [PATCH v5 09/13] lib/odp-util: Fix mapping to Netlink frag mask.
Jarno Rajahalme
jrajahalme at nicira.com
Fri Sep 5 23:05:16 UTC 2014
The frag member in the Netlink interface is an uint8_t enumeration
type, not a bitrfield, so it should always be either fully masked or
not masked at all.
Signed-off-by: Jarno Rajahalme <jrajahalme at nicira.com>
---
lib/odp-util.c | 19 ++++++++++---------
1 file changed, 10 insertions(+), 9 deletions(-)
diff --git a/lib/odp-util.c b/lib/odp-util.c
index 8ac43c5..3c398ce 100644
--- a/lib/odp-util.c
+++ b/lib/odp-util.c
@@ -2485,20 +2485,20 @@ odp_flow_from_string(const char *s, const struct simap *port_names,
static uint8_t
ovs_to_odp_frag(uint8_t nw_frag)
{
- return (nw_frag == 0 ? OVS_FRAG_TYPE_NONE
- : nw_frag == FLOW_NW_FRAG_ANY ? OVS_FRAG_TYPE_FIRST
- : OVS_FRAG_TYPE_LATER);
+ return !(nw_frag & FLOW_NW_FRAG_ANY) ? OVS_FRAG_TYPE_NONE
+ : nw_frag & FLOW_NW_FRAG_LATER ? OVS_FRAG_TYPE_LATER
+ : OVS_FRAG_TYPE_FIRST;
}
+/*
+ * Netlink interface 'enum ovs_frag_type' is an 8-bit enumeration type, not a
+ * set of flags or bitfields. Hence, if the struct flow nw_frag mask, which is
+ * a set of bits, has the FLOW_NW_FRAG_ANY as zero, we must use a zero mask for
+ * the netlink frag field, and all ones mask otherwise. */
static uint8_t
ovs_to_odp_frag_mask(uint8_t nw_frag_mask)
{
- uint8_t frag_mask = ~(OVS_FRAG_TYPE_FIRST | OVS_FRAG_TYPE_LATER);
-
- frag_mask |= (nw_frag_mask & FLOW_NW_FRAG_ANY) ? OVS_FRAG_TYPE_FIRST : 0;
- frag_mask |= (nw_frag_mask & FLOW_NW_FRAG_LATER) ? OVS_FRAG_TYPE_LATER : 0;
-
- return frag_mask;
+ return (nw_frag_mask & FLOW_NW_FRAG_ANY) ? UINT8_MAX : 0;
}
static void
@@ -2858,6 +2858,7 @@ odp_to_ovs_frag(uint8_t odp_frag, struct flow *flow)
return false;
}
+ flow->nw_frag = 0;
if (odp_frag != OVS_FRAG_TYPE_NONE) {
flow->nw_frag |= FLOW_NW_FRAG_ANY;
if (odp_frag == OVS_FRAG_TYPE_LATER) {
--
1.7.10.4
More information about the dev
mailing list