[ovs-dev] [mpls 2/2] odp-util: Fix BOS checks in parse_l2_5_onward().

Ben Pfaff blp at nicira.com
Mon Feb 3 20:57:56 UTC 2014


The check for the innermost BOS should only happen for flows, not for
masks.  This fixes a test failure.

Also, check that BOS=0 in labels other than the innermost.

Signed-off-by: Ben Pfaff <blp at nicira.com>
---
 lib/odp-util.c |   19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)

diff --git a/lib/odp-util.c b/lib/odp-util.c
index 97e681d..d9b4d53 100644
--- a/lib/odp-util.c
+++ b/lib/odp-util.c
@@ -2908,10 +2908,23 @@ parse_l2_5_onward(const struct nlattr *attrs[OVS_KEY_ATTR_MAX + 1],
         }
         if (n > ARRAY_SIZE(flow->mpls_lse)) {
             return ODP_FIT_TOO_MUCH;
-        } else if (n < ARRAY_SIZE(flow->mpls_lse)
-                   && !(flow->mpls_lse[n - 1] & htonl(MPLS_BOS_MASK))) {
-            return ODP_FIT_TOO_LITTLE;
         }
+
+        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 < ARRAY_SIZE(flow->mpls_lse)
+                && !(flow->mpls_lse[n - 1] & htonl(MPLS_BOS_MASK))) {
+                return ODP_FIT_TOO_LITTLE;
+            }
+        }
+
         goto done;
     } else if (src_flow->dl_type == htons(ETH_TYPE_IP)) {
         if (!is_mask) {
-- 
1.7.10.4




More information about the dev mailing list