diff options
author | Florin Coras <fcoras@cisco.com> | 2019-10-21 16:07:46 -0700 |
---|---|---|
committer | Dave Barach <openvpp@barachs.net> | 2020-04-03 22:10:22 +0000 |
commit | 00e01d3e875bb18397ff81e0f58f9b468477f473 (patch) | |
tree | 277b9ce692a465644de5d3481b42e6cce6394f46 /src/vnet/session/transport.c | |
parent | 39aa7a5202a6a875bd6f5d341cb07f19ab0bf51e (diff) |
session: improve error reporting
Type: improvement
Change-Id: I9dd850a1ce85b0adb5136233f176117e0ee38817
Signed-off-by: Florin Coras <fcoras@cisco.com>
Diffstat (limited to 'src/vnet/session/transport.c')
-rw-r--r-- | src/vnet/session/transport.c | 33 |
1 files changed, 10 insertions, 23 deletions
diff --git a/src/vnet/session/transport.c b/src/vnet/session/transport.c index 69046855c38..29c94f363ff 100644 --- a/src/vnet/session/transport.c +++ b/src/vnet/session/transport.c @@ -480,7 +480,7 @@ transport_alloc_local_port (u8 proto, ip46_address_t * ip) return -1; } -static clib_error_t * +static session_error_t transport_get_interface_ip (u32 sw_if_index, u8 is_ip4, ip46_address_t * addr) { if (is_ip4) @@ -488,9 +488,7 @@ transport_get_interface_ip (u32 sw_if_index, u8 is_ip4, ip46_address_t * addr) ip4_address_t *ip4; ip4 = ip_interface_get_first_ip (sw_if_index, 1); if (!ip4) - return clib_error_return (0, "no routable ip4 address on %U", - format_vnet_sw_if_index_name, - vnet_get_main (), sw_if_index); + return SESSION_E_NOIP; addr->ip4.as_u32 = ip4->as_u32; } else @@ -498,15 +496,13 @@ transport_get_interface_ip (u32 sw_if_index, u8 is_ip4, ip46_address_t * addr) ip6_address_t *ip6; ip6 = ip_interface_get_first_ip (sw_if_index, 0); if (ip6 == 0) - return clib_error_return (0, "no routable ip6 addresses on %U", - format_vnet_sw_if_index_name, - vnet_get_main (), sw_if_index); + return SESSION_E_NOIP; clib_memcpy_fast (&addr->ip6, ip6, sizeof (*ip6)); } return 0; } -static clib_error_t * +static session_error_t transport_find_local_ip_for_remote (u32 sw_if_index, transport_endpoint_t * rmt, ip46_address_t * lcl_addr) @@ -526,14 +522,11 @@ transport_find_local_ip_for_remote (u32 sw_if_index, /* Couldn't find route to destination. Bail out. */ if (fei == FIB_NODE_INDEX_INVALID) - return clib_error_return (0, "no route to %U", format_ip46_address, - &rmt->ip, (rmt->is_ip4 == 0) + 1); + return SESSION_E_NOROUTE; sw_if_index = fib_entry_get_resolving_interface (fei); if (sw_if_index == ENDPOINT_INVALID_INDEX) - return clib_error_return (0, "no resolving interface for %U", - format_ip46_address, &rmt->ip, - (rmt->is_ip4 == 0) + 1); + return SESSION_E_NOINTF; } clib_memset (lcl_addr, 0, sizeof (*lcl_addr)); @@ -545,7 +538,7 @@ transport_alloc_local_endpoint (u8 proto, transport_endpoint_cfg_t * rmt_cfg, ip46_address_t * lcl_addr, u16 * lcl_port) { transport_endpoint_t *rmt = (transport_endpoint_t *) rmt_cfg; - clib_error_t *error; + session_error_t error; int port; u32 tei; @@ -557,10 +550,7 @@ transport_alloc_local_endpoint (u8 proto, transport_endpoint_cfg_t * rmt_cfg, error = transport_find_local_ip_for_remote (rmt_cfg->peer.sw_if_index, rmt, lcl_addr); if (error) - { - clib_error_report (error); - return -1; - } + return error; } else { @@ -576,10 +566,7 @@ transport_alloc_local_endpoint (u8 proto, transport_endpoint_cfg_t * rmt_cfg, { port = transport_alloc_local_port (proto, lcl_addr); if (port < 1) - { - clib_warning ("Failed to allocate src port"); - return -1; - } + return SESSION_E_NOPORT; *lcl_port = port; } else @@ -588,7 +575,7 @@ transport_alloc_local_endpoint (u8 proto, transport_endpoint_cfg_t * rmt_cfg, tei = transport_endpoint_lookup (&local_endpoints_table, proto, lcl_addr, port); if (tei != ENDPOINT_INVALID_INDEX) - return -1; + return SESSION_E_PORTINUSE; transport_endpoint_mark_used (proto, lcl_addr, port); *lcl_port = port; |