GBP: redirect contracts
[vpp.git] / src / plugins / gbp / gbp_learn.c
index 9239779..762b463 100644 (file)
@@ -110,11 +110,14 @@ gbp_learn_l2_cp (const gbp_learn_l2_t * gl2)
    * flip the source and dst, since that's how it was received, this API
    * takes how it's sent
    */
-  gbp_endpoint_update (gl2->sw_if_index, ips,
-                      &gl2->mac, gl2->epg,
-                      (GBP_ENDPOINT_FLAG_LEARNT |
-                       GBP_ENDPOINT_FLAG_REMOTE),
-                      &gl2->outer_dst, &gl2->outer_src, NULL);
+  gbp_endpoint_update_and_lock (GBP_ENDPOINT_SRC_DP,
+                               gl2->sw_if_index, ips,
+                               &gl2->mac, INDEX_INVALID,
+                               INDEX_INVALID, gl2->epg,
+                               (GBP_ENDPOINT_FLAG_LEARNT |
+                                GBP_ENDPOINT_FLAG_REMOTE),
+                               &gl2->outer_dst, &gl2->outer_src, NULL);
+  vec_free (ips);
 }
 
 static void
@@ -236,6 +239,7 @@ gbp_learn_l2 (vlib_main_t * vm,
          ip4_address_t outer_src, outer_dst;
          u32 bi0, sw_if_index0, t0, epg0;
          const ethernet_header_t *eh0;
+         gbp_bridge_domain_t *gb0;
          gbp_learn_next_t next0;
          gbp_endpoint_t *ge0;
          vlib_buffer_t *b0;
@@ -259,10 +263,12 @@ gbp_learn_l2 (vlib_main_t * vm,
 
          ge0 = gbp_endpoint_find_mac (eh0->src_address,
                                       vnet_buffer (b0)->l2.bd_index);
+         gb0 =
+           gbp_bridge_domain_get_by_bd_index (vnet_buffer (b0)->l2.bd_index);
 
-         if (vnet_buffer2 (b0)->gbp.flags & VXLAN_GBP_GPFLAGS_D)
+         if ((vnet_buffer2 (b0)->gbp.flags & VXLAN_GBP_GPFLAGS_D) ||
+             (gb0->gb_flags & GBP_BD_FLAG_DO_NOT_LEARN))
            {
-             ge0 = NULL;
              t0 = 1;
              goto trace;
            }
@@ -270,7 +276,7 @@ gbp_learn_l2 (vlib_main_t * vm,
          /*
           * check for new EP or a moved EP
           */
-         if (NULL == ge0 || ge0->ge_sw_if_index != sw_if_index0)
+         if (NULL == ge0 || ge0->ge_fwd.gef_itf != sw_if_index0)
 
            {
              /*
@@ -335,7 +341,7 @@ gbp_learn_l2 (vlib_main_t * vm,
            {
              gbp_learn_l2_trace_t *t =
                vlib_add_trace (vm, node, b0, sizeof (*t));
-             clib_memcpy (t->mac.bytes, eh0->src_address, 6);
+             clib_memcpy_fast (t->mac.bytes, eh0->src_address, 6);
              t->new = (NULL == ge0);
              t->throttled = t0;
              t->sw_if_index = sw_if_index0;
@@ -412,10 +418,13 @@ gbp_learn_l3_cp (const gbp_learn_l3_t * gl3)
 
   vec_add1 (ips, gl3->ip);
 
-  gbp_endpoint_update (gl3->sw_if_index, ips, NULL, gl3->epg,
-                      (GBP_ENDPOINT_FLAG_REMOTE |
-                       GBP_ENDPOINT_FLAG_LEARNT),
-                      &gl3->outer_dst, &gl3->outer_src, NULL);
+  gbp_endpoint_update_and_lock (GBP_ENDPOINT_SRC_DP,
+                               gl3->sw_if_index, ips, NULL,
+                               INDEX_INVALID, INDEX_INVALID, gl3->epg,
+                               (GBP_ENDPOINT_FLAG_REMOTE |
+                                GBP_ENDPOINT_FLAG_LEARNT),
+                               &gl3->outer_dst, &gl3->outer_src, NULL);
+  vec_free (ips);
 }
 
 static void