aboutsummaryrefslogtreecommitdiffstats
path: root/vnet/vnet/ip/udp.h
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2016-02-18 22:20:01 +0100
committerGerrit Code Review <gerrit@fd.io>2016-04-02 17:20:44 +0000
commite127a7e4528472a320bf1cc343d3656dcdd4b108 (patch)
tree0a577faa62d883d0c8a2f223f216ed9c5df69882 /vnet/vnet/ip/udp.h
parent28e3db9dd617324a3196f369788d62cc72b5903b (diff)
LISP GPE: initial CP commit and DP improvements
Control Plane ------------- In essence, this introduces basic support for map-request/reply processing, the logic to generate and consume such messages, including SMRs, a control-plane backend, consisting of an eid-table, locator and locator-set tables, and CLI to interact with it. Naturally, we can now serialize/deserialize LISP specific types: addresses, locators, mappings, messages. An important caveat is that IPv6 support is not complete, both for EIDs and RLOCs. Functionally, the DP forwards all packets it can't handle to the CP (lisp_cp_lookup node) which takes care of obtaining a mapping for the packet's destination from a pre-configured map-resolver using the LISP protocol. The CP then caches this information and programs the DP such that all new packets with the same destination (or within the covering prefix) are encapsulated to one of the locators retrieved in the mapping. Ingress traffic-engineering is not yet supported. Data Plane ---------- First of all, to enable punting to the CP, when LISP GPE is turned on a default route that points to lisp_cp_lookup is now inserted. The DP also exposes an API the CP can use to program forwarding for a given mapping. This mainly consists in allocating a tunnel and programming the FIB such that all packets destined to the mapping's prefix are forwarded to a lisp-gpe encapsulating node. Another important change done for lisp forwarding is that both source and destination IP addresses are considered when encapsulating a packet. To this end, a new FIB/mtrie is introduced as a second stage, src lookup, post dst lookup. The latter is still done in the IP FIB but for source-dest entries, in the dest adjacency the lookup_next_index points to a lisp lookup node and the rewrite_header.sw_if_index points to the src FIB. This is read by the lisp lookup node which then walks the src mtrie, finds the associated adjacency, marks the buffer with the index and forwards the packet to the appropriate next node (typically, lisp-gpe-encap). Change-Id: Ibdf52fdc1f89311854621403ccdd66f90e2522fd Signed-off-by: Florin Coras <fcoras@cisco.com>
Diffstat (limited to 'vnet/vnet/ip/udp.h')
-rw-r--r--vnet/vnet/ip/udp.h99
1 files changed, 98 insertions, 1 deletions
diff --git a/vnet/vnet/ip/udp.h b/vnet/vnet/ip/udp.h
index 65eef29cb10..e9ee1e32faa 100644
--- a/vnet/vnet/ip/udp.h
+++ b/vnet/vnet/ip/udp.h
@@ -38,6 +38,7 @@ _ (67, dhcp_to_server) \
_ (68, dhcp_to_client) \
_ (500, ikev2) \
_ (4341, lisp_gpe) \
+_ (4342, lisp_cp) \
_ (4739, ipfix) \
_ (4789, vxlan) \
_ (4790, vxlan_gpe) \
@@ -47,6 +48,7 @@ _ (6633, vpath_3)
#define foreach_udp6_dst_port \
_ (547, dhcpv6_to_server) \
_ (546, dhcpv6_to_client) \
+_ (4342, lisp_cp6) \
_ (6633, vpath6_3)
typedef enum {
@@ -109,5 +111,100 @@ void udp_register_dst_port (vlib_main_t * vm,
udp_dst_port_t dst_port,
u32 node_index, u8 is_ip4);
-#endif /* included_udp_h */
+always_inline void
+ip4_udp_encap_one (vlib_main_t * vm, vlib_buffer_t * b0, u8 * ec0, u32 ec_len)
+{
+ ip4_header_t * ip0;
+ ip_csum_t sum0;
+ u16 old_l0 = 0;
+ u16 new_l0;
+ udp_header_t * udp0;
+
+ vlib_buffer_advance (b0, - ec_len);
+ ip0 = vlib_buffer_get_current(b0);
+
+ /* Apply the encap string. */
+#if DPDK
+ rte_memcpy(ip0, ec0, ec_len);
+#else
+ memcpy(ip0, ec0, ec_len);
+#endif
+
+ /* fix the <bleep>ing outer-IP checksum */
+ sum0 = ip0->checksum;
+ /* old_l0 always 0, see the rewrite setup */
+ new_l0 = clib_host_to_net_u16 (vlib_buffer_length_in_chain (vm, b0));
+
+ sum0 = ip_csum_update(sum0, old_l0, new_l0, ip4_header_t,
+ length /* changed member */);
+ ip0->checksum = ip_csum_fold (sum0);
+ ip0->length = new_l0;
+
+ /* Fix UDP length */
+ udp0 = (udp_header_t *)(ip0+1);
+ new_l0 = clib_host_to_net_u16 (vlib_buffer_length_in_chain (vm, b0)
+ - sizeof (*ip0));
+
+ udp0->length = new_l0;
+}
+always_inline void
+ip4_udp_encap_two (vlib_main_t * vm, vlib_buffer_t * b0, vlib_buffer_t * b1,
+ u8 * ec0, u8 * ec1, u32 ec_len)
+{
+ ip4_header_t * ip0, *ip1;
+ ip_csum_t sum0, sum1;
+ u16 old_l0 = 0, old_l1 = 0;
+ u16 new_l0, new_l1;
+ udp_header_t * udp0, *udp1;
+
+ ASSERT(_vec_len(ec0) == _vec_len(ec1));
+
+ vlib_buffer_advance (b0, -ec_len);
+ vlib_buffer_advance (b1, -ec_len);
+
+ ip0 = vlib_buffer_get_current (b0);
+ ip1 = vlib_buffer_get_current (b1);
+
+ /* Apply the encap string */
+#ifdef DPDK
+ rte_memcpy (ip0, ec0, ec_len);
+ rte_memcpy (ip1, ec1, ec_len);
+#else
+ memcpy (ip0, ec0, ec_len);
+ memcpy (ip1, ec1, ec_len);
+#endif
+
+ /* fix the <bleep>ing outer-IP checksum */
+ sum0 = ip0->checksum;
+ sum1 = ip1->checksum;
+
+ /* old_l0 always 0, see the rewrite setup */
+ new_l0 = clib_host_to_net_u16 (vlib_buffer_length_in_chain (vm, b0));
+ new_l1 = clib_host_to_net_u16 (vlib_buffer_length_in_chain (vm, b1));
+
+ sum0 = ip_csum_update(sum0, old_l0, new_l0, ip4_header_t,
+ length /* changed member */);
+ sum1 = ip_csum_update(sum1, old_l1, new_l1, ip4_header_t,
+ length /* changed member */);
+
+ ip0->checksum = ip_csum_fold (sum0);
+ ip1->checksum = ip_csum_fold (sum1);
+
+ ip0->length = new_l0;
+ ip1->length = new_l1;
+
+ /* Fix UDP length */
+ udp0 = (udp_header_t *) (ip0 + 1);
+ udp1 = (udp_header_t *) (ip1 + 1);
+
+ new_l0 = clib_host_to_net_u16 (
+ vlib_buffer_length_in_chain (vm, b0) - sizeof(*ip0));
+ new_l1 = clib_host_to_net_u16 (
+ vlib_buffer_length_in_chain (vm, b1) - sizeof(*ip1));
+ udp0->length = new_l0;
+ udp1->length = new_l1;
+ return;
+}
+
+#endif /* included_udp_h */