summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Barach <dave@barachs.net>2016-06-26 10:29:03 -0400
committerDave Barach <dave@barachs.net>2016-06-26 10:37:14 -0400
commit203c632d29fc5f5d820251e4e58ea724e1002a91 (patch)
tree3b464fc1b11c8b39ccc87767a51c688ade26de20
parent63617fc8e456f5803cec9b967a4a880f57755d0b (diff)
Misc. janitorial work:
Remove private / name-colliding "give me the first ip address on an interface" routine from proxy_node.c Return a proper error from ip4_lookup_init / ip6_lookup_init. Change-Id: Idd3c574424ba2ea77c263af16b02cd4ad0cb4605 Signed-off-by: Dave Barach <dave@barachs.net>
-rw-r--r--vnet/vnet/dhcp/proxy_node.c24
-rw-r--r--vnet/vnet/ip/ip4.h4
-rw-r--r--vnet/vnet/ip/ip4_forward.c5
-rw-r--r--vnet/vnet/ip/ip6_forward.c5
-rw-r--r--vnet/vnet/ip/ip_feature_registration.c6
5 files changed, 19 insertions, 25 deletions
diff --git a/vnet/vnet/dhcp/proxy_node.c b/vnet/vnet/dhcp/proxy_node.c
index 69edae7e3d0..2073b3f7bf6 100644
--- a/vnet/vnet/dhcp/proxy_node.c
+++ b/vnet/vnet/dhcp/proxy_node.c
@@ -93,24 +93,6 @@ u8 * format_dhcp_proxy_header_with_length (u8 * s, va_list * args)
return s;
}
-/* get first interface address */
-static ip4_address_t *
-ip4_interface_first_address (ip4_main_t * im, u32 sw_if_index)
-{
- ip_lookup_main_t * lm = &im->lookup_main;
- ip_interface_address_t * ia = 0;
- ip4_address_t * result = 0;
-
- foreach_ip_interface_address (lm, ia, sw_if_index,
- 1 /* honor unnumbered */,
- ({
- ip4_address_t * a = ip_interface_address_get_address (lm, ia);
- result = a;
- break;
- }));
- return result;
-}
-
static uword
dhcp_proxy_to_server_input (vlib_main_t * vm,
vlib_node_runtime_t * node,
@@ -290,7 +272,7 @@ dhcp_proxy_to_server_input (vlib_main_t * vm,
* RX interface, if not unnumbered. otherwise use
* the loopback interface's ip address.
*/
- ia0 = ip4_interface_first_address(&ip4_main, sw_if_index);
+ ia0 = ip4_interface_first_address(&ip4_main, sw_if_index, 0);
if (ia0 == 0)
{
@@ -597,7 +579,7 @@ dhcp_proxy_to_client_input (vlib_main_t * vm,
if (swif->flags & VNET_SW_INTERFACE_FLAG_UNNUMBERED)
sw_if_index = swif->unnumbered_sw_if_index;
- ia0 = ip4_interface_first_address (&ip4_main, sw_if_index);
+ ia0 = ip4_interface_first_address (&ip4_main, sw_if_index, 0);
if (ia0 == 0)
{
error0 = DHCP_PROXY_ERROR_NO_INTERFACE_ADDRESS;
@@ -1113,7 +1095,7 @@ dhcp_option_82_address_show_command_fn (vlib_main_t * vm,
swif = vnet_get_sw_interface (vnm, sw_if_index0);
sw_if_index = (swif->flags & VNET_SW_INTERFACE_FLAG_UNNUMBERED) ?
swif->unnumbered_sw_if_index : sw_if_index0;
- ia0 = ip4_interface_first_address(&ip4_main, sw_if_index);
+ ia0 = ip4_interface_first_address(&ip4_main, sw_if_index, 0);
if (ia0)
{
vlib_cli_output (vm, "%=20s%=20s", "interface",
diff --git a/vnet/vnet/ip/ip4.h b/vnet/vnet/ip/ip4.h
index b24f18d03e7..7ed5bf5e9a9 100644
--- a/vnet/vnet/ip/ip4.h
+++ b/vnet/vnet/ip/ip4.h
@@ -386,6 +386,10 @@ void ip4_adjacency_set_interface_route (vnet_main_t * vnm,
u32 sw_if_index,
u32 if_address_index);
+ip4_address_t *
+ip4_interface_first_address (ip4_main_t * im, u32 sw_if_index,
+ ip_interface_address_t ** result_ia);
+
/* Send an ARP request to see if given destination is reachable on given interface. */
clib_error_t *
ip4_probe_neighbor (vlib_main_t * vm, ip4_address_t * dst, u32 sw_if_index);
diff --git a/vnet/vnet/ip/ip4_forward.c b/vnet/vnet/ip/ip4_forward.c
index 08a1785aaa5..96036dc0ec6 100644
--- a/vnet/vnet/ip/ip4_forward.c
+++ b/vnet/vnet/ip/ip4_forward.c
@@ -1451,6 +1451,7 @@ clib_error_t *
ip4_lookup_init (vlib_main_t * vm)
{
ip4_main_t * im = &ip4_main;
+ clib_error_t * error;
uword i;
for (i = 0; i < ARRAY_LEN (im->fib_masks); i++)
@@ -1501,9 +1502,9 @@ ip4_lookup_init (vlib_main_t * vm)
"ip4 arp");
}
- ip4_feature_init (vm, im);
+ error = ip4_feature_init (vm, im);
- return 0;
+ return error;
}
VLIB_INIT_FUNCTION (ip4_lookup_init);
diff --git a/vnet/vnet/ip/ip6_forward.c b/vnet/vnet/ip/ip6_forward.c
index b558787c45c..afb23f1bf6c 100644
--- a/vnet/vnet/ip/ip6_forward.c
+++ b/vnet/vnet/ip/ip6_forward.c
@@ -2858,6 +2858,7 @@ static clib_error_t *
ip6_lookup_init (vlib_main_t * vm)
{
ip6_main_t * im = &ip6_main;
+ clib_error_t * error;
uword i;
for (i = 0; i < ARRAY_LEN (im->fib_masks); i++)
@@ -2924,9 +2925,9 @@ ip6_lookup_init (vlib_main_t * vm)
"ip6 neighbor discovery");
}
- ip6_feature_init (vm, im);
+ error = ip6_feature_init (vm, im);
- return 0;
+ return error;
}
VLIB_INIT_FUNCTION (ip6_lookup_init);
diff --git a/vnet/vnet/ip/ip_feature_registration.c b/vnet/vnet/ip/ip_feature_registration.c
index e100b1e19a3..5f0d58ea25d 100644
--- a/vnet/vnet/ip/ip_feature_registration.c
+++ b/vnet/vnet/ip/ip_feature_registration.c
@@ -119,6 +119,12 @@ ip_feature_init_cast (vlib_main_t * vm,
return clib_error_return (0, "comma_split failed!");
p = hash_get_mem (index_by_name, a_name);
+ /*
+ * Note: the next two errors mean that the xxx_FEATURE_INIT macros are
+ * b0rked. As in: if you code "A depends on B," and you forget
+ * to define a FEATURE_INIT macro for B, you lose.
+ * Nonexistent graph nodes are tolerated.
+ */
if (p == 0)
return clib_error_return (0, "feature node '%s' not found", a_name);
a_index = p[0];