u8
session_endpoint_in_ns (session_endpoint_t * sep)
{
- u8 is_zero = ip_is_zero (&sep->ip, sep->is_ip4);
- if (!is_zero && sep->sw_if_index != ENDPOINT_INVALID_INDEX
+ u8 is_lep = session_endpoint_is_local (sep);
+ if (!is_lep && sep->sw_if_index != ENDPOINT_INVALID_INDEX
&& !ip_interface_has_address (sep->sw_if_index, &sep->ip, sep->is_ip4))
{
clib_warning ("sw_if_index %u not configured with ip %U",
sep->is_ip4);
return 0;
}
- return (is_zero || ip_is_local (sep->fib_index, &sep->ip, sep->is_ip4));
+ return (is_lep || ip_is_local (sep->fib_index, &sep->ip, sep->is_ip4));
}
int
* Add session endpoint to local session table. Only binds to "inaddr_any"
* (i.e., zero address) are added to local scope table.
*/
- if (application_has_local_scope (app) && session_endpoint_is_zero (sep))
+ if (application_has_local_scope (app) && session_endpoint_is_local (sep))
{
if ((rv = application_start_local_listen (app, sep, handle)))
return rv;
u64 secret;
int rv;
- app = application_lookup (a->api_client_index);
+ if (a->api_client_index != APP_INVALID_INDEX)
+ app = application_lookup (a->api_client_index);
+ else if (a->name)
+ app = application_lookup_name (a->name);
+ else
+ return clib_error_return_code (0, VNET_API_ERROR_INVALID_VALUE, 0,
+ "api index or name must be provided");
+
if (app)
- return clib_error_return_code (0, VNET_API_ERROR_APP_ALREADY_ATTACHED,
- 0, "app already attached");
+ return clib_error_return_code (0, VNET_API_ERROR_APP_ALREADY_ATTACHED, 0,
+ "app already attached");
secret = a->options[APP_OPTIONS_NAMESPACE_SECRET];
if ((rv = session_validate_namespace (a->namespace_id, secret,
return clib_error_return_code (0, rv, 0, "namespace validation: %d", rv);
a->options[APP_OPTIONS_NAMESPACE] = app_ns_index;
app = application_new ();
- if ((rv = application_init (app, a->api_client_index, a->options,
+ if ((rv = application_init (app, a->api_client_index, a->name, a->options,
a->session_cb_vft)))
return clib_error_return_code (0, rv, 0, "app init: %d", rv);