Mcast rewrite optimisations
[vpp.git] / src / vnet / ip / ip6_forward.c
index 4fd7129..f4e45a4 100644 (file)
@@ -432,8 +432,9 @@ ip6_sw_interface_add_del (vnet_main_t * vnm, u32 sw_if_index, u32 is_add)
       vlib_main_t *vm = vlib_get_main ();
 
       ip6_neighbor_sw_interface_add_del (vnm, sw_if_index, 0 /* is_add */ );
+      vnet_sw_interface_update_unnumbered (sw_if_index, ~0, 0);
       /* *INDENT-OFF* */
-      foreach_ip_interface_address (lm6, ia, sw_if_index, 1 /* honor unnumbered */,
+      foreach_ip_interface_address (lm6, ia, sw_if_index, 0,
       ({
         address = ip_interface_address_get_address (lm6, ia);
         ip6_add_del_interface_address(vm, sw_if_index, address, ia->address_length, 1);
@@ -974,12 +975,15 @@ ip6_urpf_loose_check (ip6_main_t * im, vlib_buffer_t * b, ip6_header_t * i)
 {
   const load_balance_t *lb0;
   index_t lbi;
+  u32 fib_index;
 
-  lbi = ip6_fib_table_fwding_lookup_with_if_index (im,
-                                                  vnet_buffer
-                                                  (b)->sw_if_index[VLIB_RX],
-                                                  &i->src_address);
+  fib_index = vec_elt (im->fib_index_by_sw_if_index,
+                      vnet_buffer (b)->sw_if_index[VLIB_RX]);
+  fib_index =
+    (vnet_buffer (b)->sw_if_index[VLIB_TX] == (u32) ~ 0) ?
+    fib_index : vnet_buffer (b)->sw_if_index[VLIB_TX];
 
+  lbi = ip6_fib_table_fwding_lookup (im, fib_index, &i->src_address);
   lb0 = load_balance_get (lbi);
 
   return (fib_urpf_check_size (lb0->lb_urpf));
@@ -1351,7 +1355,6 @@ VLIB_REGISTER_NODE (ip6_local_node, static) =
     [IP_LOCAL_NEXT_PUNT] = "ip6-punt",
     [IP_LOCAL_NEXT_UDP_LOOKUP] = "ip6-udp-lookup",
     [IP_LOCAL_NEXT_ICMP] = "ip6-icmp-input",
-    [IP_LOCAL_NEXT_REASSEMBLY] = "ip6-reassembly",
   },
 };
 /* *INDENT-ON* */
@@ -1548,9 +1551,10 @@ ip6_discover_neighbor_inline (vlib_main_t * vm,
             * Choose source address based on destination lookup
             * adjacency.
             */
-           if (ip6_src_address_for_packet (lm,
-                                           sw_if_index0,
-                                           &h0->ip.src_address))
+           if (!ip6_src_address_for_packet (lm,
+                                            sw_if_index0,
+                                            &ip0->dst_address,
+                                            &h0->ip.src_address))
              {
                /* There is no address on the interface */
                p0->error =
@@ -1744,7 +1748,8 @@ ip6_probe_neighbor (vlib_main_t * vm, ip6_address_t * dst, u32 sw_if_index)
   if (adj->lookup_next_index == IP_LOOKUP_NEXT_REWRITE)
     {
       adj_unlock (ai);
-      ai = adj_glean_add_or_lock (FIB_PROTOCOL_IP6, sw_if_index, &nh);
+      ai = adj_glean_add_or_lock (FIB_PROTOCOL_IP6,
+                                 VNET_LINK_IP6, sw_if_index, &nh);
       adj = adj_get (ai);
     }
 
@@ -1769,6 +1774,12 @@ typedef enum
   IP6_REWRITE_NEXT_ICMP_ERROR,
 } ip6_rewrite_next_t;
 
+/**
+ * This bits of an IPv6 address to mask to construct a multicast
+ * MAC address
+ */
+#define IP6_MCAST_ADDR_MASK 0xffffffff
+
 always_inline uword
 ip6_rewrite_inline (vlib_main_t * vm,
                    vlib_node_runtime_t * node,
@@ -1972,8 +1983,16 @@ ip6_rewrite_inline (vlib_main_t * vm,
              /*
               * copy bytes from the IP address into the MAC rewrite
               */
-             vnet_fixup_one_header (adj0[0], &ip0->dst_address, ip0);
-             vnet_fixup_one_header (adj1[0], &ip1->dst_address, ip1);
+             vnet_ip_mcast_fixup_header (IP6_MCAST_ADDR_MASK,
+                                         adj0->
+                                         rewrite_header.dst_mcast_offset,
+                                         &ip0->dst_address.as_u32[3],
+                                         (u8 *) ip0);
+             vnet_ip_mcast_fixup_header (IP6_MCAST_ADDR_MASK,
+                                         adj1->
+                                         rewrite_header.dst_mcast_offset,
+                                         &ip1->dst_address.as_u32[3],
+                                         (u8 *) ip1);
            }
 
          vlib_validate_buffer_enqueue_x2 (vm, node, next_index,
@@ -2080,7 +2099,11 @@ ip6_rewrite_inline (vlib_main_t * vm,
            }
          if (is_mcast)
            {
-             vnet_fixup_one_header (adj0[0], &ip0->dst_address, ip0);
+             vnet_ip_mcast_fixup_header (IP6_MCAST_ADDR_MASK,
+                                         adj0->
+                                         rewrite_header.dst_mcast_offset,
+                                         &ip0->dst_address.as_u32[3],
+                                         (u8 *) ip0);
            }
 
          p0->error = error_node->errors[error0];
@@ -2694,7 +2717,7 @@ ip6_hbh_register_option (u8 option,
   ip6_main_t *im = &ip6_main;
   ip6_hop_by_hop_main_t *hm = &ip6_hop_by_hop_main;
 
-  ASSERT (option < ARRAY_LEN (hm->options));
+  ASSERT ((u32) option < ARRAY_LEN (hm->options));
 
   /* Already registered */
   if (hm->options[option])
@@ -2715,7 +2738,7 @@ ip6_hbh_unregister_option (u8 option)
   ip6_main_t *im = &ip6_main;
   ip6_hop_by_hop_main_t *hm = &ip6_hop_by_hop_main;
 
-  ASSERT (option < ARRAY_LEN (hm->options));
+  ASSERT ((u32) option < ARRAY_LEN (hm->options));
 
   /* Not registered */
   if (!hm->options[option])