6RD: Rewritten 6RD RFC5969 support.

Change-Id: Ic30fbcb2630f39e45345d7215babf5d7ed4b33a0
Signed-off-by: Ole Troan <ot@cisco.com>
diff --git a/src/vnet/adj/adj_delegate.h b/src/vnet/adj/adj_delegate.h
index c473800..13bf911 100644
--- a/src/vnet/adj/adj_delegate.h
+++ b/src/vnet/adj/adj_delegate.h
@@ -99,7 +99,6 @@
                             adj_delegate_type_t fdt,
                             index_t adi);
 
-
 /**
  * @brief Get a delegate from an adjacency
  *
diff --git a/src/vnet/adj/adj_glean.c b/src/vnet/adj/adj_glean.c
index 82d0a46..7de8e39 100644
--- a/src/vnet/adj/adj_glean.c
+++ b/src/vnet/adj/adj_glean.c
@@ -48,6 +48,7 @@
  */
 adj_index_t
 adj_glean_add_or_lock (fib_protocol_t proto,
+                       vnet_link_t linkt,
 		       u32 sw_if_index,
 		       const ip46_address_t *nh_addr)
 {
@@ -61,15 +62,23 @@
 
 	adj->lookup_next_index = IP_LOOKUP_NEXT_GLEAN;
 	adj->ia_nh_proto = proto;
+        adj->ia_link = linkt;
 	adj_gleans[proto][sw_if_index] = adj_get_index(adj);
 
 	if (NULL != nh_addr)
 	{
 	    adj->sub_type.glean.receive_addr = *nh_addr;
 	}
+        else
+        {
+            adj->sub_type.glean.receive_addr = zero_addr;
+        }
 
 	adj->rewrite_header.sw_if_index = sw_if_index;
 	adj->rewrite_header.data_bytes = 0;
+        adj->rewrite_header.max_l3_packet_bytes =
+            vnet_sw_interface_get_mtu(vnet_get_main(), sw_if_index, VLIB_TX);
+
         adj_lock(adj_get_index(adj));
 
 	vnet_update_adjacency_for_sw_interface(vnet_get_main(),
diff --git a/src/vnet/adj/adj_glean.h b/src/vnet/adj/adj_glean.h
index 47cddfb..3ffbe36 100644
--- a/src/vnet/adj/adj_glean.h
+++ b/src/vnet/adj/adj_glean.h
@@ -44,6 +44,7 @@
  *  as the source address in packets when the ARP/ND packet is sent
  */
 extern adj_index_t adj_glean_add_or_lock(fib_protocol_t proto,
+                                         vnet_link_t linkt,
 					 u32 sw_if_index,
 					 const ip46_address_t *nh_addr);
 
diff --git a/src/vnet/adj/rewrite.c b/src/vnet/adj/rewrite.c
index c21495a..f4b26a9 100644
--- a/src/vnet/adj/rewrite.c
+++ b/src/vnet/adj/rewrite.c
@@ -82,6 +82,8 @@
 	s = format (s, "DELETED:%d", rw->sw_if_index);
     }
 
+  s = format (s, " mtu:%d", rw->max_l3_packet_bytes);
+
   /* Format rewrite string. */
   if (rw->data_bytes > 0)
     s = format (s, " %U",
diff --git a/src/vnet/fib/fib_entry.h b/src/vnet/fib/fib_entry.h
index 273a5e6..d905a83 100644
--- a/src/vnet/fib/fib_entry.h
+++ b/src/vnet/fib/fib_entry.h
@@ -81,10 +81,6 @@
      */
     FIB_SOURCE_MAP,
     /**
-     * SIXRD
-     */
-    FIB_SOURCE_SIXRD,
-    /**
      * DHCP
      */
     FIB_SOURCE_DHCP,
@@ -151,7 +147,6 @@
     [FIB_SOURCE_ADJ] = "adjacency",			\
     [FIB_SOURCE_MAP] = "MAP",			        \
     [FIB_SOURCE_SR] = "SR",			        \
-    [FIB_SOURCE_SIXRD] = "SixRD",			\
     [FIB_SOURCE_LISP] = "LISP", 			\
     [FIB_SOURCE_CLASSIFY] = "classify",			\
     [FIB_SOURCE_DHCP] = "DHCP",   			\
diff --git a/src/vnet/fib/fib_entry_src_special.c b/src/vnet/fib/fib_entry_src_special.c
index a2493bb..a289916 100644
--- a/src/vnet/fib/fib_entry_src_special.c
+++ b/src/vnet/fib/fib_entry_src_special.c
@@ -64,7 +64,6 @@
 {
     fib_entry_src_register(FIB_SOURCE_SPECIAL, &special_src_vft);
     fib_entry_src_register(FIB_SOURCE_MAP, &special_src_vft);
-    fib_entry_src_register(FIB_SOURCE_SIXRD, &special_src_vft);
     fib_entry_src_register(FIB_SOURCE_CLASSIFY, &special_src_vft);
     fib_entry_src_register(FIB_SOURCE_AE, &special_src_vft);
     fib_entry_src_register(FIB_SOURCE_PROXY, &special_src_vft);
diff --git a/src/vnet/fib/fib_path.c b/src/vnet/fib/fib_path.c
index ffb7ad2..b4f9971 100644
--- a/src/vnet/fib/fib_path.c
+++ b/src/vnet/fib/fib_path.c
@@ -707,6 +707,7 @@
     else
     {
         return (adj_glean_add_or_lock(dpo_proto_to_fib(path->fp_nh_proto),
+                                      link,
                                       path->attached.fp_interface,
                                       NULL));
     }
diff --git a/src/vnet/ip/ip4_forward.c b/src/vnet/ip/ip4_forward.c
index b9875d7..6b7eb9c 100644
--- a/src/vnet/ip/ip4_forward.c
+++ b/src/vnet/ip/ip4_forward.c
@@ -1923,7 +1923,8 @@
   if (adj->lookup_next_index == IP_LOOKUP_NEXT_REWRITE)
     {
       adj_unlock (ai);
-      ai = adj_glean_add_or_lock (FIB_PROTOCOL_IP4, sw_if_index, &nh);
+      ai = adj_glean_add_or_lock (FIB_PROTOCOL_IP4,
+				  VNET_LINK_IP4, sw_if_index, &nh);
       adj = adj_get (ai);
     }
 
diff --git a/src/vnet/ip/ip6_forward.c b/src/vnet/ip/ip6_forward.c
index 4fd7129..30b717f 100644
--- a/src/vnet/ip/ip6_forward.c
+++ b/src/vnet/ip/ip6_forward.c
@@ -1744,7 +1744,8 @@
   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);
     }