aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlberto Compagno <acompagn+fdio@cisco.com>2019-03-20 11:50:29 +0100
committerAlberto Compagno <acompagn+fdio@cisco.com>2019-03-20 13:28:49 +0100
commit8ede92527fac95d4f4bd5f686189a5d35f996193 (patch)
tree6b7d5c16441a445dcdec047575d1ee8f6596969b
parentb52e00ea9b64e9718bd348915c692a95e346d831 (diff)
[HICN-132] Prevent to show interface details if the interface does not exist
Change-Id: Id87483597b0259ed1b940948f2de7e2138ca97f9 Signed-off-by: Alberto Compagno <acompagn+fdio@cisco.com>
-rw-r--r--hicn-plugin/src/faces/ip/face_ip.c61
-rw-r--r--hicn-plugin/src/faces/udp/face_udp.c83
2 files changed, 81 insertions, 63 deletions
diff --git a/hicn-plugin/src/faces/ip/face_ip.c b/hicn-plugin/src/faces/ip/face_ip.c
index a70cb1011..a7ec95417 100644
--- a/hicn-plugin/src/faces/ip/face_ip.c
+++ b/hicn-plugin/src/faces/ip/face_ip.c
@@ -1,16 +1,16 @@
/*
- * 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:
+ * 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
+ * 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.
+ * 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 "face_ip.h"
@@ -40,24 +40,20 @@ hicn_face_ip_init (vlib_main_t * vm)
/* Default Strategy has index 0 and it always exists */
strategy_face_ip4_vlib_edge = vlib_node_add_next (vm,
hicn_dpo_get_strategy_vft
- (default_dpo.
- hicn_dpo_get_type ())->
- get_strategy_node_index
+ (default_dpo.hicn_dpo_get_type
+ ())->get_strategy_node_index
(),
- hicn_face_ip4_output_node.
- index);
+ hicn_face_ip4_output_node.index);
strategy_face_ip6_vlib_edge = vlib_node_add_next (vm,
hicn_dpo_get_strategy_vft
- (default_dpo.
- hicn_dpo_get_type ())->
- get_strategy_node_index
+ (default_dpo.hicn_dpo_get_type
+ ())->get_strategy_node_index
(),
- hicn_face_ip6_output_node.
- index);
+ hicn_face_ip6_output_node.index);
/*
- * Create and edge between al the other strategy nodes
- * and the ip_encap nodes.
+ * Create and edge between al the other strategy nodes and the
+ * ip_encap nodes.
*/
for (int i = 1; i < strategy_nodes_n; i++)
{
@@ -120,8 +116,8 @@ hicn_face_ip_del (hicn_face_id_t face_id)
/*
- * Utility that adds a new face cache entry. For the moment we assume that the
- * ip_adjacency has already been set up.
+ * Utility that adds a new face cache entry. For the moment we assume that
+ * the ip_adjacency has already been set up.
*/
int
hicn_face_ip_add (const ip46_address_t * local_addr,
@@ -234,8 +230,7 @@ hicn_face_ip_add (const ip46_address_t * local_addr,
}
retx_t *retx = vlib_process_signal_event_data (vlib_get_main (),
- hicn_mapme_eventmgr_process_node.
- index,
+ hicn_mapme_eventmgr_process_node.index,
HICN_MAPME_EVENT_FACE_ADD, 1,
sizeof (retx_t));
*retx = (retx_t)
@@ -275,8 +270,12 @@ format_hicn_face_ip (u8 * s, va_list * args)
format (s, "remote %U ", format_ip46_address, &ip_face->remote_addr,
IP46_TYPE_ANY);
s = format (s, "%U", format_vnet_link, adj->ia_link);
- s = format (s, " dev %U", format_vnet_sw_interface_name, vnm,
- vnet_get_sw_interface (vnm, face->shared.sw_if));
+
+ vnet_sw_interface_t *sw_int =
+ vnet_get_sw_interface_safe (vnm, face->shared.sw_if);
+ if (sw_int != NULL)
+ s = format (s, " dev %U", format_vnet_sw_interface_name, vnm, sw_int);
+
if ((face->shared.flags & HICN_FACE_FLAGS_APPFACE_PROD))
s = format (s, " %U", format_hicn_face_prod, face_id, 0);
@@ -293,9 +292,11 @@ format_hicn_face_ip (u8 * s, va_list * args)
s = format (s, "type IP local %U remote %U",
format_ip46_address, &ip_face->local_addr, IP46_TYPE_ANY,
format_ip46_address, &ip_face->remote_addr, IP46_TYPE_ANY);
- s =
- format (s, " dev %U", format_vnet_sw_interface_name, vnm,
- vnet_get_sw_interface (vnm, face->shared.sw_if));
+
+ vnet_sw_interface_t *sw_int =
+ vnet_get_sw_interface_safe (vnm, face->shared.sw_if);
+ if (sw_int != NULL)
+ s = format (s, " dev %U", format_vnet_sw_interface_name, vnm, sw_int);
if ((face->shared.flags & HICN_FACE_FLAGS_APPFACE_PROD))
s = format (s, " %U", format_hicn_face_prod, face_id, 0);
diff --git a/hicn-plugin/src/faces/udp/face_udp.c b/hicn-plugin/src/faces/udp/face_udp.c
index 924c79a91..6f345925b 100644
--- a/hicn-plugin/src/faces/udp/face_udp.c
+++ b/hicn-plugin/src/faces/udp/face_udp.c
@@ -1,16 +1,16 @@
/*
- * 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:
+ * 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
+ * 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.
+ * 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 <vlib/vlib.h>
@@ -62,8 +62,10 @@ ip6_header_t ip6_header_skl = {
u32 strategy_face_udp4_vlib_edge;
u32 strategy_face_udp6_vlib_edge;
-/* Separated from the hicn_face_udp_init because it cannot be called by the
- init macro due to dependencies with other modules not yet initialied */
+/*
+ * Separated from the hicn_face_udp_init because it cannot be called by the
+ * init macro due to dependencies with other modules not yet initialied
+ */
void
hicn_face_udp_init_internal ()
{
@@ -79,22 +81,20 @@ hicn_face_udp_init (vlib_main_t * vm)
/* Default Strategy has index 0 and it always exists */
strategy_face_udp4_vlib_edge = vlib_node_add_next (vm,
hicn_dpo_get_strategy_vft
- (default_dpo.
- hicn_dpo_get_type ())->
- get_strategy_node_index
+ (default_dpo.hicn_dpo_get_type
+ ())->get_strategy_node_index
(),
- hicn_face_udp4_output_node.
- index);
+ hicn_face_udp4_output_node.index);
strategy_face_udp6_vlib_edge =
vlib_node_add_next (vm,
- hicn_dpo_get_strategy_vft (default_dpo.
- hicn_dpo_get_type ())->
- get_strategy_node_index (),
+ hicn_dpo_get_strategy_vft
+ (default_dpo.hicn_dpo_get_type
+ ())->get_strategy_node_index (),
hicn_face_udp6_output_node.index);
/*
- * Create and edge between al the other strategy nodes
- * and the udp_output nodes.
+ * Create and edge between al the other strategy nodes and the
+ * udp_output nodes.
*/
for (int i = 1; i < strategy_nodes_n; i++)
{
@@ -266,8 +266,7 @@ hicn_face_udp_add (const ip46_address_t * local_addr,
}
retx_t *retx = vlib_process_signal_event_data (vlib_get_main (),
- hicn_mapme_eventmgr_process_node.
- index,
+ hicn_mapme_eventmgr_process_node.index,
HICN_MAPME_EVENT_FACE_ADD, 1,
sizeof (retx_t));
*retx = (retx_t)
@@ -318,8 +317,13 @@ format_hicn_face_udp (u8 * s, va_list * args)
&udp_face->hdrs.ip4.ip.dst_address,
clib_net_to_host_u16 (udp_face->hdrs.ip4.udp.dst_port));
s = format (s, "%U", format_vnet_link, adj->ia_link);
- s = format (s, " dev %U", format_vnet_sw_interface_name, vnm,
- vnet_get_sw_interface (vnm, face->shared.sw_if));
+
+ vnet_sw_interface_t *sw_int =
+ vnet_get_sw_interface_safe (vnm, face->shared.sw_if);
+ if (sw_int != NULL)
+ s = format (s, " dev %U", format_vnet_sw_interface_name, vnm,
+ sw_int);
+
if ((face->shared.flags & HICN_FACE_FLAGS_DELETED))
s = format (s, " (deleted)");
}
@@ -333,8 +337,13 @@ format_hicn_face_udp (u8 * s, va_list * args)
&udp_face->hdrs.ip6.ip.dst_address,
clib_net_to_host_u16 (udp_face->hdrs.ip6.udp.dst_port));
s = format (s, "%U", format_vnet_link, adj->ia_link);
- s = format (s, " dev %U", format_vnet_sw_interface_name, vnm,
- vnet_get_sw_interface (vnm, face->shared.sw_if));
+
+ vnet_sw_interface_t *sw_int =
+ vnet_get_sw_interface_safe (vnm, face->shared.sw_if);
+ if (sw_int != NULL)
+ s = format (s, " dev %U", format_vnet_sw_interface_name, vnm,
+ sw_int);
+
if ((face->shared.flags & HICN_FACE_FLAGS_DELETED))
s = format (s, " (deleted)");
}
@@ -351,9 +360,13 @@ format_hicn_face_udp (u8 * s, va_list * args)
format (s, " local %U|%u", format_ip4_address,
&udp_face->hdrs.ip4.ip.dst_address,
clib_net_to_host_u16 (udp_face->hdrs.ip4.udp.dst_port));
- s =
- format (s, " dev %U", format_vnet_sw_interface_name, vnm,
- vnet_get_sw_interface (vnm, face->shared.sw_if));
+
+ vnet_sw_interface_t *sw_int =
+ vnet_get_sw_interface_safe (vnm, face->shared.sw_if);
+ if (sw_int != NULL)
+ s = format (s, " dev %U", format_vnet_sw_interface_name, vnm,
+ sw_int);
+
if ((face->shared.flags & HICN_FACE_FLAGS_DELETED))
s = format (s, " (deleted)");
}
@@ -366,9 +379,13 @@ format_hicn_face_udp (u8 * s, va_list * args)
format (s, " remote %U|%u", format_ip6_address,
&udp_face->hdrs.ip6.ip.dst_address,
clib_net_to_host_u16 (udp_face->hdrs.ip6.udp.dst_port));
- s =
- format (s, " dev %U", format_vnet_sw_interface_name, vnm,
- vnet_get_sw_interface (vnm, face->shared.sw_if));
+
+ vnet_sw_interface_t *sw_int =
+ vnet_get_sw_interface_safe (vnm, face->shared.sw_if);
+ if (sw_int != NULL)
+ s = format (s, " dev %U", format_vnet_sw_interface_name, vnm,
+ sw_int);
+
if ((face->shared.flags & HICN_FACE_FLAGS_DELETED))
s = format (s, " (deleted)");
}