diff options
author | Alberto Compagno <acompagn+fdio@cisco.com> | 2020-04-07 11:43:39 +0200 |
---|---|---|
committer | Alberto Compagno <acompagn+fdio@cisco.com> | 2020-05-04 11:16:59 +0200 |
commit | c61e2e149421b849888bea0239c50607edce35ac (patch) | |
tree | f1191d338c9e27c77484c0d8bed6118c6d4612b6 /hicn-plugin/src/faces/ip/face_ip_cli.c | |
parent | dee66271e7f84cb756dae31d154982d5b6bb9807 (diff) |
[HICN-590] Removed andjacency type specific face implementation
Changes in the new implementation are:
- the adjacency index is replaced with a dpo that allows the single face node
to dispatch the packet to the right vlib node.
- local and remote address in the face are replaced with a single nat address
which is used to perform the nat operation when rewriting an interest or a
data (in case of tunnels the nat address will be equal to 0)
- the list of next hop in the load balance is no longer a list of dpos but
a list of face id (this makes the code easier and increases the number of
next hop we supports)
Signed-off-by: Alberto Compagno <acompagn+fdio@cisco.com>
Change-Id: I4ac2b4eb09425bfe1b3ca9f82d7d0ff564297b0d
Diffstat (limited to 'hicn-plugin/src/faces/ip/face_ip_cli.c')
-rw-r--r-- | hicn-plugin/src/faces/ip/face_ip_cli.c | 208 |
1 files changed, 0 insertions, 208 deletions
diff --git a/hicn-plugin/src/faces/ip/face_ip_cli.c b/hicn-plugin/src/faces/ip/face_ip_cli.c deleted file mode 100644 index 4c4986f97..000000000 --- a/hicn-plugin/src/faces/ip/face_ip_cli.c +++ /dev/null @@ -1,208 +0,0 @@ -/* - * Copyright (c) 2017-2019 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 <vnet/vnet.h> -#include <vnet/dpo/dpo.h> -#include <vlib/vlib.h> - -#include "face_ip.h" -#include "dpo_ip.h" -#include "../face.h" - -#define HICN_FACE_NONE 0 -#define HICN_FACE_DELETE 1 -#define HICN_FACE_ADD 2 - -static clib_error_t * -hicn_face_ip_cli_set_command_fn (vlib_main_t * vm, - unformat_input_t * main_input, - vlib_cli_command_t * cmd) -{ - vnet_main_t *vnm = vnet_get_main (); - ip46_address_t local_addr; - ip46_address_t remote_addr; - hicn_face_id_t face_id = HICN_FACE_NULL; - int ret = HICN_ERROR_NONE; - int sw_if; - int face_op = HICN_FACE_NONE; - - ip46_address_reset (&local_addr); - /* Get a line of input. */ - unformat_input_t _line_input, *line_input = &_line_input; - if (!unformat_user (main_input, unformat_line_input, line_input)) - { - return (0); - } - - while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) - { - if (unformat (line_input, "del")) - { - if (unformat (line_input, "id %d", &face_id)) - face_op = HICN_FACE_DELETE; - else - { - return clib_error_return (0, "missing face id"); - } - } - else if (unformat (line_input, "add")) - { - face_op = HICN_FACE_ADD; - if (unformat (line_input, "local %U", - unformat_ip46_address, &local_addr, IP46_TYPE_ANY)); - - if (unformat (line_input, "remote %U intfc %U", - unformat_ip46_address, &remote_addr, - IP46_TYPE_ANY, unformat_vnet_sw_interface, vnm, - &sw_if)); - else - { - return clib_error_return (0, "%s '%U'", - get_error_string - (HICN_ERROR_CLI_INVAL), - format_unformat_error, line_input); - } - } - else - { - return clib_error_return (0, "%s '%U'", - get_error_string (HICN_ERROR_CLI_INVAL), - format_unformat_error, line_input); - } - } - - if (face_id != HICN_FACE_NULL) - { - - if (!hicn_dpoi_idx_is_valid (face_id)) - { - return clib_error_return (0, "%s, face_id %d not valid", - get_error_string (ret), face_id); - } - } - - int rv; - switch (face_op) - { - case HICN_FACE_ADD: - - /* Check for presence of next hop address */ - if ((remote_addr.as_u64[0] == (u64) 0) - && (remote_addr.as_u64[1] == (u64) 0)) - { - return clib_error_return (0, "next hop address not specified"); - } - - if (ip46_address_is_zero (&local_addr)) - { - if (!vnet_sw_interface_is_valid (vnm, sw_if)) - return clib_error_return (0, "interface not valid"); - - if (ip46_address_is_ip4 (&remote_addr)) - { - ip_interface_address_t *interface_address; - ip4_address_t *addr = - ip4_interface_address_matching_destination (&ip4_main, - &remote_addr.ip4, - sw_if, - &interface_address); - - if (addr == NULL) - addr = ip4_interface_first_address (&ip4_main, - sw_if, - &interface_address); - - if (addr == NULL) - return clib_error_return (0, - "no valid ip address on interface %d", - sw_if); - - ip46_address_set_ip4 (&local_addr, addr); - } - else - { - ip_interface_address_t *interface_address; - ip6_interface_address_matching_destination (&ip6_main, - &remote_addr.ip6, - sw_if, - &interface_address); - - ip6_address_t *addr = NULL; - if (interface_address != NULL) - addr = - (ip6_address_t *) - ip_interface_address_get_address (&ip6_main.lookup_main, - interface_address); - - if (addr == NULL) - addr = ip6_interface_first_address (&ip6_main, sw_if); - - if (addr == NULL) - return clib_error_return (0, - "no valid ip address on interface %d", - sw_if); - - ip46_address_set_ip6 (&local_addr, addr); - } - } - - rv = hicn_face_ip_add (&local_addr, &remote_addr, sw_if, &face_id, 0); - - if (rv == HICN_ERROR_NONE) - { - vlib_cli_output (vm, "Face id: %d", face_id); - } - else - { - return clib_error_return (0, get_error_string (rv)); - } - break; - case HICN_FACE_DELETE: - rv = hicn_face_ip_del (face_id); - if (rv == HICN_ERROR_NONE) - { - vlib_cli_output (vm, "Face %d deleted", face_id); - } - else - { - return clib_error_return (0, get_error_string (rv)); - } - break; - default: - return clib_error_return (0, "Operation (%d) not implemented", face_op); - break; - } - return (rv == HICN_ERROR_NONE) ? 0 : clib_error_return (0, "%s\n", - get_error_string - (rv)); -} - -/* cli declaration for 'cfg face' */ -/* *INDENT-OFF* */ -VLIB_CLI_COMMAND (hicn_face_ip_cli_set_command, static) = -{ - .path = "hicn face ip", - .short_help = "hicn face ip {add [local <src_address>] remote <dst_address> intfc <sw_if>} | {del id <face_id>}", - .function = hicn_face_ip_cli_set_command_fn, -}; -/* *INDENT-ON* */ - -/* - * fd.io coding-style-patch-verification: ON - * - * Local Variables: - * eval: (c-set-style "gnu") - * End: - */ |