BFD: Decreasing minimal transmit and receive interval
[cascardo/ovs.git] / lib / odp-util.c
index 9a4ea5e..8b33ec8 100644 (file)
@@ -399,7 +399,7 @@ format_odp_hash_action(struct ds *ds, const struct ovs_action_hash *hash_act)
     ds_put_format(ds, "hash(");
 
     if (hash_act->hash_alg == OVS_HASH_ALG_L4) {
-        ds_put_format(ds, "hash_l4(%"PRIu32")", hash_act->hash_bias);
+        ds_put_format(ds, "hash_l4(%"PRIu32")", hash_act->hash_basis);
     } else {
         ds_put_format(ds, "Unknown hash algorithm(%"PRIu32")",
                       hash_act->hash_alg);
@@ -1319,7 +1319,7 @@ format_odp_key_attr(const struct nlattr *a, const struct nlattr *ma,
         } else {
             const struct ovs_key_sctp *sctp_key = nl_attr_get(a);
 
-            ds_put_format(ds, "(src=%"PRIu16",dst=%"PRIu16")",
+            ds_put_format(ds, "src=%"PRIu16",dst=%"PRIu16,
                           ntohs(sctp_key->sctp_src), ntohs(sctp_key->sctp_dst));
         }
         break;
@@ -1657,7 +1657,9 @@ parse_odp_key_mask_attr(const char *s, const struct simap *port_names,
 
         if (ovs_scan(s, "recirc_id(%"SCNi32")%n", &recirc_id, &n)) {
             nl_msg_put_u32(key, OVS_KEY_ATTR_RECIRC_ID, recirc_id);
-            nl_msg_put_u32(mask, OVS_KEY_ATTR_RECIRC_ID, UINT32_MAX);
+            if (mask) {
+                nl_msg_put_u32(mask, OVS_KEY_ATTR_RECIRC_ID, UINT32_MAX);
+            }
             return n;
         }
     }
@@ -2967,47 +2969,42 @@ parse_l2_5_onward(const struct nlattr *attrs[OVS_KEY_ATTR_MAX + 1],
     enum ovs_key_attr expected_bit = 0xff;
 
     if (eth_type_mpls(src_flow->dl_type)) {
-        size_t size = nl_attr_get_size(attrs[OVS_KEY_ATTR_MPLS]);
-        const ovs_be32 *mpls_lse = nl_attr_get(attrs[OVS_KEY_ATTR_MPLS]);
-        int n = size / sizeof(ovs_be32);
-        int i;
-
-        if (!size || size % sizeof(ovs_be32)) {
-            return ODP_FIT_ERROR;
-        }
-
-        if (!is_mask) {
+        if (!is_mask || present_attrs & (UINT64_C(1) << OVS_KEY_ATTR_MPLS)) {
             expected_attrs |= (UINT64_C(1) << OVS_KEY_ATTR_MPLS);
+        }
+        if (present_attrs & (UINT64_C(1) << OVS_KEY_ATTR_MPLS)) {
+            size_t size = nl_attr_get_size(attrs[OVS_KEY_ATTR_MPLS]);
+            const ovs_be32 *mpls_lse = nl_attr_get(attrs[OVS_KEY_ATTR_MPLS]);
+            int n = size / sizeof(ovs_be32);
+            int i;
 
-            if (!(present_attrs & (UINT64_C(1) << OVS_KEY_ATTR_MPLS))) {
-                return ODP_FIT_TOO_LITTLE;
+            if (!size || size % sizeof(ovs_be32)) {
+                return ODP_FIT_ERROR;
             }
-        } else if (present_attrs & (UINT64_C(1) << OVS_KEY_ATTR_MPLS)) {
             if (flow->mpls_lse[0] && flow->dl_type != htons(0xffff)) {
                 return ODP_FIT_ERROR;
             }
-            expected_attrs |= (UINT64_C(1) << OVS_KEY_ATTR_MPLS);
-        }
 
-        for (i = 0; i < n && i < FLOW_MAX_MPLS_LABELS; i++) {
-            flow->mpls_lse[i] = mpls_lse[i];
-        }
-        if (n > FLOW_MAX_MPLS_LABELS) {
-            return ODP_FIT_TOO_MUCH;
-        }
+            for (i = 0; i < n && i < FLOW_MAX_MPLS_LABELS; i++) {
+                flow->mpls_lse[i] = mpls_lse[i];
+            }
+            if (n > FLOW_MAX_MPLS_LABELS) {
+                return ODP_FIT_TOO_MUCH;
+            }
 
-        if (!is_mask) {
-            /* BOS may be set only in the innermost label. */
-            for (i = 0; i < n - 1; i++) {
-                if (flow->mpls_lse[i] & htonl(MPLS_BOS_MASK)) {
-                    return ODP_FIT_ERROR;
+            if (!is_mask) {
+                /* BOS may be set only in the innermost label. */
+                for (i = 0; i < n - 1; i++) {
+                    if (flow->mpls_lse[i] & htonl(MPLS_BOS_MASK)) {
+                        return ODP_FIT_ERROR;
+                    }
                 }
-            }
 
-            /* BOS must be set in the innermost label. */
-            if (n < FLOW_MAX_MPLS_LABELS
-                && !(flow->mpls_lse[n - 1] & htonl(MPLS_BOS_MASK))) {
-                return ODP_FIT_TOO_LITTLE;
+                /* BOS must be set in the innermost label. */
+                if (n < FLOW_MAX_MPLS_LABELS
+                    && !(flow->mpls_lse[n - 1] & htonl(MPLS_BOS_MASK))) {
+                    return ODP_FIT_TOO_LITTLE;
+                }
             }
         }
 
@@ -3313,7 +3310,7 @@ odp_flow_key_to_flow__(const struct nlattr *key, size_t key_len,
         flow->recirc_id = nl_attr_get_u32(attrs[OVS_KEY_ATTR_RECIRC_ID]);
         expected_attrs |= UINT64_C(1) << OVS_KEY_ATTR_RECIRC_ID;
     } else if (is_mask) {
-        /* Always exact match recirc_id when datapath does not sepcify it. */
+        /* Always exact match recirc_id if it is not specified. */
         flow->recirc_id = UINT32_MAX;
     }