Label stack size exceeded fix 39/9739/2
authorNeale Ranns <nranns@cisco.com>
Wed, 6 Dec 2017 08:45:33 +0000 (00:45 -0800)
committerDamjan Marion <dmarion.lists@gmail.com>
Wed, 6 Dec 2017 19:40:06 +0000 (19:40 +0000)
Change-Id: Ibe2041d83e9b5be16801dc316bd472ae4f6e8c31
Signed-off-by: Neale Ranns <nranns@cisco.com>
src/vnet/dpo/mpls_label_dpo.c
src/vnet/dpo/mpls_label_dpo.h

index c6e8dcc..fa5177a 100644 (file)
@@ -16,6 +16,7 @@
 #include <vnet/ip/ip.h>
 #include <vnet/dpo/mpls_label_dpo.h>
 #include <vnet/mpls/mpls.h>
+#include <vnet/dpo/drop_dpo.h>
 
 /*
  * pool of all MPLS Label DPOs
@@ -53,6 +54,17 @@ mpls_label_dpo_create (mpls_label_t *label_stack,
     u32 ii;
 
     mld = mpls_label_dpo_alloc();
+
+    if (MPLS_LABEL_DPO_MAX_N_LABELS < vec_len(label_stack))
+    {
+        clib_warning("Label stack size exceeded");
+        dpo_stack(DPO_MPLS_LABEL,
+                  mld->mld_payload_proto,
+                  &mld->mld_dpo,
+                  drop_dpo_get(DPO_PROTO_MPLS));
+        return (mpls_label_dpo_get_index(mld));
+    }
+
     mld->mld_n_labels = vec_len(label_stack);
     mld->mld_n_hdr_bytes = mld->mld_n_labels * sizeof(mld->mld_hdr[0]);
     mld->mld_payload_proto = payload_proto;
index e23f3d2..8494d26 100644 (file)
 #include <vnet/mpls/packet.h>
 #include <vnet/dpo/dpo.h>
 
+
+/**
+ * Maximum number of labels in one DPO
+ */
+#define MPLS_LABEL_DPO_MAX_N_LABELS 12
 /**
  * A representation of an MPLS label for imposition in the data-path
  */
@@ -27,8 +32,9 @@ typedef struct mpls_label_dpo_t
 {
     /**
      * The MPLS label header to impose. Outer most label first.
+     * Each DPO will occupy one cache line, stuff that many labels in.
      */
-    mpls_unicast_header_t mld_hdr[8];
+    mpls_unicast_header_t mld_hdr[MPLS_LABEL_DPO_MAX_N_LABELS];
 
     /**
      * Next DPO in the graph