summaryrefslogtreecommitdiffstats
path: root/vnet
diff options
context:
space:
mode:
authorOle Troan <ot@cisco.com>2016-06-15 14:29:08 +0200
committerOle Troan <ot@cisco.com>2016-06-15 16:10:08 +0200
commit3b3688f9d3a640a169e9c7fc858d36ab3aeb147e (patch)
tree5fc72f464da8410e9a838aef62c1bc5a8886a181 /vnet
parentf0f852251c885fc5f73125a4365cf356feeb0cdd (diff)
6rd: Move to plugin
- Change toplevel plugins make target. Now builds all plugins under plugins/. (Apart from sample-plugin). - Move sixrd code to plugins directory and make necessary changes to make it a plugin - Remove 6rd hooks from IP lookup code Change-Id: I447e92e3bee240cd8de01d0abac2e1708e8c27d1 Signed-off-by: Ole Troan <ot@cisco.com>
Diffstat (limited to 'vnet')
-rw-r--r--vnet/Makefile.am6
-rw-r--r--vnet/vnet/ip/lookup.c1
-rw-r--r--vnet/vnet/ip/lookup.h5
-rw-r--r--vnet/vnet/map/ip4_sixrd.c127
-rw-r--r--vnet/vnet/map/ip6_sixrd.c129
-rw-r--r--vnet/vnet/map/sixrd.c355
-rw-r--r--vnet/vnet/map/sixrd.h141
7 files changed, 1 insertions, 763 deletions
diff --git a/vnet/Makefile.am b/vnet/Makefile.am
index 3d9e07dad11..b758c7f1cc9 100644
--- a/vnet/Makefile.am
+++ b/vnet/Makefile.am
@@ -346,15 +346,11 @@ libvnet_la_SOURCES += \
vnet/map/map.c \
vnet/map/ip4_map.c \
vnet/map/ip6_map.c \
- vnet/map/sixrd.c \
- vnet/map/ip4_sixrd.c \
- vnet/map/ip6_sixrd.c \
vnet/map/ip4_map_t.c \
vnet/map/ip6_map_t.c
nobase_include_HEADERS += \
- vnet/map/map.h \
- vnet/map/sixrd.h
+ vnet/map/map.h
########################################
# Tunnel protocol: gre
diff --git a/vnet/vnet/ip/lookup.c b/vnet/vnet/ip/lookup.c
index 5a56870f9b2..2d9e01f24b9 100644
--- a/vnet/vnet/ip/lookup.c
+++ b/vnet/vnet/ip/lookup.c
@@ -947,7 +947,6 @@ u8 * format_ip_lookup_next (u8 * s, va_list * args)
case IP_LOOKUP_NEXT_CLASSIFY: t = "classify"; break;
case IP_LOOKUP_NEXT_MAP: t = "map"; break;
case IP_LOOKUP_NEXT_MAP_T: t = "map-t"; break;
- case IP_LOOKUP_NEXT_SIXRD: t = "sixrd"; break;
case IP_LOOKUP_NEXT_INDIRECT: t="indirect"; break;
case IP_LOOKUP_NEXT_REWRITE:
break;
diff --git a/vnet/vnet/ip/lookup.h b/vnet/vnet/ip/lookup.h
index a7aef9f52a8..35c19a77327 100644
--- a/vnet/vnet/ip/lookup.h
+++ b/vnet/vnet/ip/lookup.h
@@ -76,9 +76,6 @@ typedef enum {
/* This packet needs to go to MAP with Translation - RFC7599 */
IP_LOOKUP_NEXT_MAP_T,
- /* This packets needs to go to 6RD (RFC5969) */
- IP_LOOKUP_NEXT_SIXRD,
-
/* This packets needs to go to indirect next hop */
IP_LOOKUP_NEXT_INDIRECT,
@@ -109,7 +106,6 @@ typedef enum {
[IP_LOOKUP_NEXT_CLASSIFY] = "ip4-classify", \
[IP_LOOKUP_NEXT_MAP] = "ip4-map", \
[IP_LOOKUP_NEXT_MAP_T] = "ip4-map-t", \
- [IP_LOOKUP_NEXT_SIXRD] = "ip4-sixrd", \
[IP_LOOKUP_NEXT_INDIRECT] = "ip4-indirect", \
[IP_LOOKUP_NEXT_ICMP_ERROR] = "ip4-icmp-error", \
}
@@ -124,7 +120,6 @@ typedef enum {
[IP_LOOKUP_NEXT_CLASSIFY] = "ip6-classify", \
[IP_LOOKUP_NEXT_MAP] = "ip6-map", \
[IP_LOOKUP_NEXT_MAP_T] = "ip6-map-t", \
- [IP_LOOKUP_NEXT_SIXRD] = "ip6-sixrd", \
[IP_LOOKUP_NEXT_INDIRECT] = "ip6-indirect", \
[IP_LOOKUP_NEXT_ICMP_ERROR] = "ip6-icmp-error", \
[IP6_LOOKUP_NEXT_HOP_BY_HOP] = "ip6-hop-by-hop", \
diff --git a/vnet/vnet/map/ip4_sixrd.c b/vnet/vnet/map/ip4_sixrd.c
deleted file mode 100644
index 2fb8015d994..00000000000
--- a/vnet/vnet/map/ip4_sixrd.c
+++ /dev/null
@@ -1,127 +0,0 @@
-/*---------------------------------------------------------------------------
- * Copyright (c) 2009-2014 Cisco and/or its affiliates.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *---------------------------------------------------------------------------
- */
-#include "sixrd.h"
-
-static vlib_node_registration_t ip4_sixrd_node;
-
-typedef enum {
- IP4_SIXRD_NEXT_IP6_LOOKUP,
- IP4_SIXRD_NEXT_DROP,
- IP4_SIXRD_N_NEXT,
-} ip4_sixrd_next_t;
-
-/*
- * ip4_sixrd_sec_check
- */
-static_always_inline void
-ip4_sixrd_sec_check (sixrd_domain_t *d, ip4_address_t sa4, ip6_address_t sa6, u8 *error)
-{
- u32 a = sixrd_get_addr(d, sa6.as_u64[0]);
- clib_warning("Security check: %U %U", format_ip4_address, &a, format_ip4_address, &sa4);
- if (PREDICT_FALSE(sixrd_get_addr(d, sa6.as_u64[0]) != sa4.as_u32))
- *error = SIXRD_ERROR_SEC_CHECK;
-}
-
-/*
- * ip4_sixrd
- */
-static uword
-ip4_sixrd (vlib_main_t *vm,
- vlib_node_runtime_t *node,
- vlib_frame_t *frame)
-{
- u32 n_left_from, *from, next_index, *to_next, n_left_to_next;
- vlib_node_runtime_t *error_node = vlib_node_get_runtime(vm, ip4_sixrd_node.index);
- u32 decap = 0;
-
- from = vlib_frame_vector_args(frame);
- n_left_from = frame->n_vectors;
- next_index = node->cached_next_index;
- while (n_left_from > 0) {
- vlib_get_next_frame(vm, node, next_index, to_next, n_left_to_next);
-
- /* Single loop */
- while (n_left_from > 0 && n_left_to_next > 0) {
- u32 pi0;
- vlib_buffer_t *p0;
- u8 error0 = SIXRD_ERROR_NONE;
- sixrd_domain_t *d0 = 0;
- ip4_header_t *ip40;
- ip6_header_t *ip60;
- u32 sixrd_domain_index0 = ~0;
- u32 next0;
-
- pi0 = to_next[0] = from[0];
- from += 1;
- n_left_from -= 1;
- to_next +=1;
- n_left_to_next -= 1;
-
- p0 = vlib_get_buffer(vm, pi0);
- ip40 = vlib_buffer_get_current(p0);
-
- /* Throw away anything that isn't IP in IP. */
- if (PREDICT_TRUE(ip40->protocol == IP_PROTOCOL_IPV6 && clib_net_to_host_u16(ip40->length) >= 60)) {
- vlib_buffer_advance(p0, sizeof(ip4_header_t));
- ip60 = vlib_buffer_get_current(p0);
- d0 = ip4_sixrd_get_domain(vnet_buffer(p0)->ip.adj_index[VLIB_TX], (ip6_address_t *)&ip60->src_address,
- &sixrd_domain_index0, &error0);
- } else {
- error0 = SIXRD_ERROR_BAD_PROTOCOL;
- }
- if (d0) {
- /* SIXRD inbound security check */
- ip4_sixrd_sec_check(d0, ip40->src_address, ip60->src_address, &error0);
- }
-
- next0 = error0 == SIXRD_ERROR_NONE ? IP4_SIXRD_NEXT_IP6_LOOKUP : IP4_SIXRD_NEXT_DROP;
-
- if (PREDICT_FALSE(p0->flags & VLIB_BUFFER_IS_TRACED)) {
- sixrd_trace_t *tr = vlib_add_trace(vm, node, p0, sizeof(*tr));
- tr->sixrd_domain_index = sixrd_domain_index0;
- }
-
- p0->error = error_node->errors[error0];
- if (PREDICT_TRUE(error0 == SIXRD_ERROR_NONE)) decap++;
- vlib_validate_buffer_enqueue_x1(vm, node, next_index, to_next, n_left_to_next, pi0, next0);
-
- }
- vlib_put_next_frame(vm, node, next_index, n_left_to_next);
- }
- vlib_node_increment_counter(vm, ip4_sixrd_node.index, SIXRD_ERROR_DECAPSULATED, decap);
-
- return frame->n_vectors;
-}
-
-static char *sixrd_error_strings[] = {
-#define _(sym,string) string,
- foreach_sixrd_error
-#undef _
-};
-
-VLIB_REGISTER_NODE(ip4_sixrd_node,static) = {
- .function = ip4_sixrd,
- .name = "ip4-sixrd",
- .vector_size = sizeof(u32),
- .format_trace = format_sixrd_trace,
- .n_errors = SIXRD_N_ERROR,
- .error_strings = sixrd_error_strings,
- .n_next_nodes = IP4_SIXRD_N_NEXT,
- .next_nodes = {
- [IP4_SIXRD_NEXT_IP6_LOOKUP] = "ip6-lookup",
- [IP4_SIXRD_NEXT_DROP] = "error-drop",
- },
-};
diff --git a/vnet/vnet/map/ip6_sixrd.c b/vnet/vnet/map/ip6_sixrd.c
deleted file mode 100644
index 36f3fab320b..00000000000
--- a/vnet/vnet/map/ip6_sixrd.c
+++ /dev/null
@@ -1,129 +0,0 @@
-/*---------------------------------------------------------------------------
- * Copyright (c) 2009-2014 Cisco and/or its affiliates.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *---------------------------------------------------------------------------
- */
-/*
- * Defines used for testing various optimisation schemes
- */
-#define SIXRD_ENCAP_DUAL 0
-
-#include "sixrd.h"
-
-static vlib_node_registration_t ip6_sixrd_node;
-
-typedef enum {
- IP6_SIXRD_NEXT_IP4_LOOKUP,
- IP6_SIXRD_NEXT_DROP,
- IP6_SIXRD_N_NEXT,
-} ip6_sixrd_next_t;
-
-/*
- * ip6_sixrd
- */
-static uword
-ip6_sixrd (vlib_main_t *vm,
- vlib_node_runtime_t *node,
- vlib_frame_t *frame)
-{
- u32 n_left_from, *from, next_index, *to_next, n_left_to_next;
- vlib_node_runtime_t *error_node = vlib_node_get_runtime(vm, ip6_sixrd_node.index);
- u32 encap = 0;
- from = vlib_frame_vector_args(frame);
- n_left_from = frame->n_vectors;
- next_index = node->cached_next_index;
-
- while (n_left_from > 0) {
- vlib_get_next_frame(vm, node, next_index, to_next, n_left_to_next);
-
- while (n_left_from > 0 && n_left_to_next > 0) {
- u32 pi0;
- vlib_buffer_t *p0;
- sixrd_domain_t *d0;
- u8 error0 = SIXRD_ERROR_NONE;
- ip6_header_t *ip60;
- ip4_header_t *ip4h0;
- u32 next0 = IP6_SIXRD_NEXT_IP4_LOOKUP;
- u32 sixrd_domain_index0 = ~0;
-
- pi0 = to_next[0] = from[0];
- from += 1;
- n_left_from -= 1;
- to_next +=1;
- n_left_to_next -= 1;
-
- p0 = vlib_get_buffer(vm, pi0);
- ip60 = vlib_buffer_get_current(p0);
- // p0->current_length = clib_net_to_host_u16(ip40->length);
- d0 = ip6_sixrd_get_domain(vnet_buffer(p0)->ip.adj_index[VLIB_TX], &sixrd_domain_index0);
- ASSERT(d0);
-
- /* SIXRD calc */
- u64 dal60 = clib_net_to_host_u64(ip60->dst_address.as_u64[0]);
- u32 da40 = sixrd_get_addr(d0, dal60);
- u16 len = clib_net_to_host_u16(ip60->payload_length) + 60;
- if (da40 == 0) error0 = SIXRD_ERROR_UNKNOWN;
-
- /* construct ipv4 header */
- vlib_buffer_advance(p0, - (sizeof(ip4_header_t)));
- ip4h0 = vlib_buffer_get_current(p0);
- vnet_buffer(p0)->sw_if_index[VLIB_TX] = (u32)~0;
- ip4h0->ip_version_and_header_length = 0x45;
- ip4h0->tos = 0;
- ip4h0->length = clib_host_to_net_u16(len);
- ip4h0->fragment_id = 0;
- ip4h0->flags_and_fragment_offset = 0;
- ip4h0->ttl = 0x40;
- ip4h0->protocol = IP_PROTOCOL_IPV6;
- ip4h0->src_address = d0->ip4_src;
- ip4h0->dst_address.as_u32 = clib_host_to_net_u32(da40);
- ip4h0->checksum = ip4_header_checksum(ip4h0);
-
- next0 = error0 == SIXRD_ERROR_NONE ? IP6_SIXRD_NEXT_IP4_LOOKUP : IP6_SIXRD_NEXT_DROP;
-
- if (PREDICT_FALSE(p0->flags & VLIB_BUFFER_IS_TRACED)) {
- sixrd_trace_t *tr = vlib_add_trace(vm, node, p0, sizeof(*tr));
- tr->sixrd_domain_index = sixrd_domain_index0;
- }
-
- p0->error = error_node->errors[error0];
- if (PREDICT_TRUE(error0 == SIXRD_ERROR_NONE)) encap++;
-
- vlib_validate_buffer_enqueue_x1(vm, node, next_index, to_next, n_left_to_next, pi0, next0);
- }
- vlib_put_next_frame(vm, node, next_index, n_left_to_next);
- }
- vlib_node_increment_counter(vm, ip6_sixrd_node.index, SIXRD_ERROR_ENCAPSULATED, encap);
-
- return frame->n_vectors;
-}
-
-static char *sixrd_error_strings[] = {
-#define _(sym,string) string,
- foreach_sixrd_error
-#undef _
-};
-
-VLIB_REGISTER_NODE(ip6_sixrd_node,static) = {
- .function = ip6_sixrd,
- .name = "ip6-sixrd",
- .vector_size = sizeof(u32),
- .format_trace = format_sixrd_trace,
- .n_errors = SIXRD_N_ERROR,
- .error_strings = sixrd_error_strings,
- .n_next_nodes = IP6_SIXRD_N_NEXT,
- .next_nodes = {
- [IP6_SIXRD_NEXT_IP4_LOOKUP] = "ip4-lookup",
- [IP6_SIXRD_NEXT_DROP] = "error-drop",
- },
-};
diff --git a/vnet/vnet/map/sixrd.c b/vnet/vnet/map/sixrd.c
deleted file mode 100644
index 26b4eea9a86..00000000000
--- a/vnet/vnet/map/sixrd.c
+++ /dev/null
@@ -1,355 +0,0 @@
-/*
- * Copyright (c) 2015 Cisco and/or its affiliates.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "sixrd.h"
-
-/*
- * This code supports the following sixrd modes:
- *
- * 32 EA bits (Complete IPv4 address is embedded):
- * ea_bits_len = 32
- * IPv4 suffix is embedded:
- * ea_bits_len = < 32
- * No embedded address bits (1:1 mode):
- * ea_bits_len = 0
- */
-
-int
-sixrd_create_domain (ip6_address_t *ip6_prefix,
- u8 ip6_prefix_len,
- ip4_address_t *ip4_prefix,
- u8 ip4_prefix_len,
- ip4_address_t *ip4_src,
- u32 *sixrd_domain_index,
- u16 mtu)
-{
- sixrd_main_t *mm = &sixrd_main;
- ip4_main_t *im4 = &ip4_main;
- ip6_main_t *im6 = &ip6_main;
- sixrd_domain_t *d;
- ip_adjacency_t adj;
- ip4_add_del_route_args_t args4;
- ip6_add_del_route_args_t args6;
- u32 *p;
-
- /* Get domain index */
- pool_get_aligned(mm->domains, d, CLIB_CACHE_LINE_BYTES);
- memset(d, 0, sizeof (*d));
- *sixrd_domain_index = d - mm->domains;
-
- /* Init domain struct */
- d->ip4_prefix.as_u32 = ip4_prefix->as_u32;
- d->ip4_prefix_len = ip4_prefix_len;
- d->ip6_prefix = *ip6_prefix;
- d->ip6_prefix_len = ip6_prefix_len;
- d->ip4_src = *ip4_src;
- d->mtu = mtu;
-
- if (ip4_prefix_len < 32)
- d->shift = 64 - ip6_prefix_len + (32 - ip4_prefix_len);
-
- /* Init IP adjacency */
- memset(&adj, 0, sizeof(adj));
- adj.explicit_fib_index = ~0;
- adj.lookup_next_index = IP_LOOKUP_NEXT_SIXRD;
- p = (u32 *)&adj.rewrite_data[0];
- *p = (u32) (*sixrd_domain_index);
-
- /* Create ip6 adjacency */
- memset(&args6, 0, sizeof(args6));
- args6.table_index_or_table_id = 0;
- args6.flags = IP6_ROUTE_FLAG_ADD;
- args6.dst_address.as_u64[0] = ip6_prefix->as_u64[0];
- args6.dst_address.as_u64[1] = ip6_prefix->as_u64[1];
- args6.dst_address_length = ip6_prefix_len;
- args6.adj_index = ~0;
- args6.add_adj = &adj;
- args6.n_add_adj = 1;
- ip6_add_del_route(im6, &args6);
-
- /* Multiple SIXRD domains may share same source IPv4 TEP */
- uword *q = ip4_get_route(im4, 0, 0, (u8 *)ip4_src, 32);
- if (q) {
- u32 ai = q[0];
- ip_lookup_main_t *lm4 = &ip4_main.lookup_main;
- ip_adjacency_t *adj4 = ip_get_adjacency(lm4, ai);
- if (adj4->lookup_next_index != IP_LOOKUP_NEXT_SIXRD) {
- clib_warning("BR source address already assigned: %U", format_ip4_address, ip4_src);
- pool_put(mm->domains, d);
- return -1;
- }
- /* Shared source */
- p = (u32 *)&adj4->rewrite_data[0];
- p[0] = ~0;
-
- /* Add refcount, so we don't accidentially delete the route underneath someone */
- p[1]++;
- } else {
- /* Create ip4 adjacency. */
- memset(&args4, 0, sizeof(args4));
- args4.table_index_or_table_id = 0;
- args4.flags = IP4_ROUTE_FLAG_ADD;
- args4.dst_address.as_u32 = ip4_src->as_u32;
- args4.dst_address_length = 32;
- args4.adj_index = ~0;
- args4.add_adj = &adj;
- args4.n_add_adj = 1;
- ip4_add_del_route(im4, &args4);
- }
-
- return 0;
-}
-
-/*
- * sixrd_delete_domain
- */
-int
-sixrd_delete_domain (u32 sixrd_domain_index)
-{
- sixrd_main_t *mm = &sixrd_main;
- ip4_main_t *im4 = &ip4_main;
- ip6_main_t *im6 = &ip6_main;
- sixrd_domain_t *d;
- ip_adjacency_t adj;
- ip4_add_del_route_args_t args4;
- ip6_add_del_route_args_t args6;
-
- if (pool_is_free_index(mm->domains, sixrd_domain_index)) {
- clib_warning("SIXRD domain delete: domain does not exist: %d", sixrd_domain_index);
- return -1;
- }
-
- d = pool_elt_at_index(mm->domains, sixrd_domain_index);
-
- memset(&adj, 0, sizeof(adj));
- adj.explicit_fib_index = ~0;
- adj.lookup_next_index = IP_LOOKUP_NEXT_SIXRD;
-
- /* Delete ip6 adjacency */
- memset(&args6, 0, sizeof (args6));
- args6.table_index_or_table_id = 0;
- args6.flags = IP6_ROUTE_FLAG_DEL;
- args6.dst_address.as_u64[0] = d->ip6_prefix.as_u64[0];
- args6.dst_address.as_u64[1] = d->ip6_prefix.as_u64[1];
- args6.dst_address_length = d->ip6_prefix_len;
- args6.adj_index = 0;
- args6.add_adj = &adj;
- args6.n_add_adj = 0;
- ip6_add_del_route(im6, &args6);
-
- /* Delete ip4 adjacency */
- uword *q = ip4_get_route(im4, 0, 0, (u8 *)&d->ip4_src, 32);
- if (q) {
- u32 ai = q[0];
- ip_lookup_main_t *lm4 = &ip4_main.lookup_main;
- ip_adjacency_t *adj4 = ip_get_adjacency(lm4, ai);
-
- u32 *p = (u32 *)&adj4->rewrite_data[0];
- /* Delete route when no other domains use this source */
- if (p[1] == 0) {
- memset(&args4, 0, sizeof(args4));
- args4.table_index_or_table_id = 0;
- args4.flags = IP4_ROUTE_FLAG_DEL;
- args4.dst_address.as_u32 = d->ip4_prefix.as_u32;
- args4.dst_address_length = d->ip4_prefix_len;
- args4.adj_index = 0;
- args4.add_adj = &adj;
- args4.n_add_adj = 0;
- ip4_add_del_route(im4, &args4);
- }
- p[1]--;
- }
-
- pool_put(mm->domains, d);
-
- return 0;
-}
-
-static clib_error_t *
-sixrd_add_domain_command_fn (vlib_main_t *vm,
- unformat_input_t *input,
- vlib_cli_command_t *cmd)
-{
- unformat_input_t _line_input, *line_input = &_line_input;
- ip4_address_t ip4_prefix;
- ip6_address_t ip6_prefix;
- ip4_address_t ip4_src;
- u32 ip6_prefix_len, ip4_prefix_len, sixrd_domain_index;
- u32 num_m_args = 0;
- /* Optional arguments */
- u32 mtu = 0;
-
- /* Get a line of input. */
- if (!unformat_user(input, unformat_line_input, line_input))
- return 0;
- while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) {
- if (unformat(line_input, "ip6-pfx %U/%d", unformat_ip6_address, &ip6_prefix, &ip6_prefix_len))
- num_m_args++;
- else if (unformat(line_input, "ip4-pfx %U/%d", unformat_ip4_address, &ip4_prefix, &ip4_prefix_len))
- num_m_args++;
- else if (unformat(line_input, "ip4-src %U", unformat_ip4_address, &ip4_src))
- num_m_args++;
- else if (unformat(line_input, "mtu %d", &mtu))
- num_m_args++;
- else
- return clib_error_return(0, "unknown input `%U'",
- format_unformat_error, input);
- }
- unformat_free(line_input);
-
- if (num_m_args < 3)
- return clib_error_return(0, "mandatory argument(s) missing");
-
- sixrd_create_domain(&ip6_prefix, ip6_prefix_len, &ip4_prefix, ip4_prefix_len,
- &ip4_src, &sixrd_domain_index, mtu);
-
- return 0;
-}
-
-static clib_error_t *
-sixrd_del_domain_command_fn (vlib_main_t *vm,
- unformat_input_t *input,
- vlib_cli_command_t *cmd)
-{
- unformat_input_t _line_input, *line_input = &_line_input;
- u32 num_m_args = 0;
- u32 sixrd_domain_index;
-
- /* Get a line of input. */
- if (! unformat_user(input, unformat_line_input, line_input))
- return 0;
-
- while (unformat_check_input(line_input) != UNFORMAT_END_OF_INPUT) {
- if (unformat(line_input, "index %d", &sixrd_domain_index))
- num_m_args++;
- else
- return clib_error_return(0, "unknown input `%U'",
- format_unformat_error, input);
- }
- unformat_free(line_input);
-
- if (num_m_args != 1)
- return clib_error_return(0, "mandatory argument(s) missing");
-
- sixrd_delete_domain(sixrd_domain_index);
-
- return 0;
-}
-
-static u8 *
-format_sixrd_domain (u8 *s, va_list *args)
-{
- sixrd_domain_t *d = va_arg(*args, sixrd_domain_t *);
- sixrd_main_t *mm = &sixrd_main;
-
- s = format(s,
- "[%d] ip6-pfx %U/%d ip4-pfx %U/%d ip4-src %U mtu %d",
- d - mm->domains,
- format_ip6_address, &d->ip6_prefix, d->ip6_prefix_len,
- format_ip4_address, &d->ip4_prefix, d->ip4_prefix_len,
- format_ip4_address, &d->ip4_src, d->mtu);
-
- return s;
-}
-
-static clib_error_t *
-show_sixrd_domain_command_fn (vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
-{
- sixrd_main_t *mm = &sixrd_main;
- sixrd_domain_t *d;
-
- if (pool_elts(mm->domains) == 0)
- vlib_cli_output(vm, "No SIXRD domains are configured...");
-
- pool_foreach(d, mm->domains, ({vlib_cli_output(vm, "%U", format_sixrd_domain, d);}));
-
- return 0;
-
-}
-
-static clib_error_t *
-show_sixrd_stats_command_fn (vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
-{
- sixrd_main_t *mm = &sixrd_main;
- sixrd_domain_t *d;
- int domains = 0, domaincount = 0;
- if (pool_elts (mm->domains) == 0)
- vlib_cli_output (vm, "No SIXRD domains are configured...");
-
- pool_foreach(d, mm->domains, ({
- domains += sizeof(*d);
- domaincount++;
- }));
-
- vlib_cli_output(vm, "SIXRD domains structure: %d\n", sizeof (sixrd_domain_t));
- vlib_cli_output(vm, "SIXRD domains: %d (%d bytes)\n", domaincount, domains);
-
- return 0;
-}
-
-/*
- * packet trace format function
- */
-u8 *
-format_sixrd_trace (u8 *s, va_list *args)
-{
- CLIB_UNUSED(vlib_main_t *vm) = va_arg (*args, vlib_main_t *);
- CLIB_UNUSED(vlib_node_t *node) = va_arg (*args, vlib_node_t *);
- sixrd_trace_t *t = va_arg (*args, sixrd_trace_t *);
- u32 sixrd_domain_index = t->sixrd_domain_index;
-
- s = format(s, "SIXRD domain index: %d", sixrd_domain_index);
-
- return s;
-}
-
-VLIB_CLI_COMMAND(sixrd_add_domain_command, static) = {
- .path = "sixrd add domain",
- .short_help =
- "sixrd add domain ip6-pfx <ip6-pfx> ip4-pfx <ip4-pfx> ip4-src <ip4-addr>",
- .function = sixrd_add_domain_command_fn,
-};
-
-VLIB_CLI_COMMAND(sixrd_del_command, static) = {
- .path = "sixrd del domain",
- .short_help =
- "sixrd del domain index <domain>",
- .function = sixrd_del_domain_command_fn,
-};
-
-VLIB_CLI_COMMAND(show_sixrd_domain_command, static) = {
- .path = "show sixrd domain",
- .function = show_sixrd_domain_command_fn,
-};
-
-VLIB_CLI_COMMAND(show_sixrd_stats_command, static) = {
- .path = "show sixrd stats",
- .function = show_sixrd_stats_command_fn,
-};
-
-/*
- * sixrd_init
- */
-clib_error_t *sixrd_init (vlib_main_t *vm)
-{
- sixrd_main_t *mm = &sixrd_main;
-
- mm->vnet_main = vnet_get_main();
- mm->vlib_main = vm;
-
- return 0;
-}
-
-VLIB_INIT_FUNCTION(sixrd_init);
diff --git a/vnet/vnet/map/sixrd.h b/vnet/vnet/map/sixrd.h
deleted file mode 100644
index 388ba4d298b..00000000000
--- a/vnet/vnet/map/sixrd.h
+++ /dev/null
@@ -1,141 +0,0 @@
-/*---------------------------------------------------------------------------
- * Copyright (c) 2009-2014 Cisco and/or its affiliates.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *---------------------------------------------------------------------------
- */
-#include <stdbool.h>
-#include <vppinfra/error.h>
-#include <vnet/vnet.h>
-#include <vnet/ip/ip.h>
-
-int sixrd_create_domain(ip6_address_t *ip6_prefix, u8 ip6_prefix_len,
- ip4_address_t *ip4_prefix, u8 ip4_prefix_len,
- ip4_address_t *ip4_src, u32 *sixrd_domain_index, u16 mtu);
-int sixrd_delete_domain(u32 sixrd_domain_index);
-u8 *format_sixrd_trace(u8 *s, va_list *args);
-
-typedef struct {
- ip6_address_t ip6_prefix;
- ip4_address_t ip4_prefix;
- ip4_address_t ip4_src;
- u8 ip6_prefix_len;
- u8 ip4_prefix_len;
-
- /* helpers */
- u8 shift;
-
- u16 mtu;
-} sixrd_domain_t;
-
-typedef struct {
- /* pool of SIXRD domains */
- sixrd_domain_t *domains;
-
- /* convenience */
- vlib_main_t *vlib_main;
- vnet_main_t *vnet_main;
-} sixrd_main_t;
-
-#define foreach_sixrd_error \
- /* Must be first. */ \
- _(NONE, "valid SIXRD packets") \
- _(BAD_PROTOCOL, "bad protocol") \
- _(WRONG_ICMP_TYPE, "wrong icmp type") \
- _(SEC_CHECK, "security check failed") \
- _(ICMP, "unable to translate ICMP") \
- _(UNKNOWN, "unknown") \
- _(NO_DOMAIN, "no domain") \
- _(ENCAPSULATED, "encapsulated") \
- _(DECAPSULATED, "decapsulated") \
- _(TRANSLATED_4TO6, "translated 4 to 6") \
- _(TRANSLATED_6TO4, "translated 6 to 4") \
- _(FRAGMENT, "fragment handling error") \
- _(FRAGMENT_QUEUED, "dropped, missing first fragment") \
- _(FRAGMENTED, "packets requiring fragmentation") \
- _(FRAGMENT_PARTS, "fragment parts") \
- _(MALFORMED, "malformed packet")
-
-typedef enum {
-#define _(sym,str) SIXRD_ERROR_##sym,
- foreach_sixrd_error
-#undef _
- SIXRD_N_ERROR,
- } sixrd_error_t;
-
-typedef struct {
- u32 sixrd_domain_index;
-} sixrd_trace_t;
-
-sixrd_main_t sixrd_main;
-
-/*
- * sixrd_get_addr
- */
-static_always_inline u32
-sixrd_get_addr (sixrd_domain_t *d, u64 dal)
-{
-
- /* 1:1 mode */
- if (d->ip4_prefix_len == 32) return (d->ip4_prefix.as_u32);
-
- /* Grab 32 - ip4_prefix_len bits out of IPv6 address from offset ip6_prefix_len */
- return (d->ip4_prefix.as_u32 | (u32)(dal >> d->shift));
-}
-
-/*
- * Get the SIXRD domain from an IPv6 lookup adjacency.
- */
-static_always_inline sixrd_domain_t *
-ip6_sixrd_get_domain (u32 adj_index, u32 *sixrd_domain_index)
-{
- sixrd_main_t *mm = &sixrd_main;
- ip_lookup_main_t *lm = &ip6_main.lookup_main;
- ip_adjacency_t *adj = ip_get_adjacency(lm, adj_index);
- ASSERT(adj);
- uword *p = (uword *)adj->rewrite_data;
- ASSERT(p);
- *sixrd_domain_index = p[0];
- return pool_elt_at_index(mm->domains, p[0]);
-}
-
-/*
- * Get the SIXRD domain from an IPv4 lookup adjacency.
- * If the IPv4 address is not shared, no lookup is required.
- * The IPv6 address is used otherwise.
- */
-static_always_inline sixrd_domain_t *
-ip4_sixrd_get_domain (u32 adj_index, ip6_address_t *addr,
- u32 *sixrd_domain_index, u8 *error)
-{
- sixrd_main_t *mm = &sixrd_main;
- ip6_main_t *im6 = &ip6_main;
- ip_lookup_main_t *lm4 = &ip4_main.lookup_main;
- ip_lookup_main_t *lm6 = &ip6_main.lookup_main;
- ip_adjacency_t *adj = ip_get_adjacency(lm4, adj_index);
- ASSERT(adj);
- uword *p = (uword *)adj->rewrite_data;
- ASSERT(p);
- *sixrd_domain_index = p[0];
- if (p[0] != ~0)
- return pool_elt_at_index(mm->domains, p[0]);
-
- u32 ai = ip6_fib_lookup_with_table(im6, 0, addr);
- ip_adjacency_t *adj6 = ip_get_adjacency (lm6, ai);
- if (PREDICT_TRUE(adj6->lookup_next_index == IP_LOOKUP_NEXT_SIXRD)) {
- uword *p = (uword *)adj6->rewrite_data;
- *sixrd_domain_index = p[0];
- return pool_elt_at_index(mm->domains, *sixrd_domain_index);
- }
- *error = SIXRD_ERROR_NO_DOMAIN;
- return NULL;
-}