diff options
author | Neale Ranns <neale@graphiant.com> | 2021-06-07 09:34:07 +0000 |
---|---|---|
committer | Ole Tr�an <otroan@employees.org> | 2021-06-14 13:13:13 +0000 |
commit | 89d939e52c999edec66194c60bc5afb2397a2842 (patch) | |
tree | 00e8ec98863ead022c30e8619b45a7585fc7a5de /src/vnet | |
parent | 6197cb730e1571ca69859489c0ae7ea90a5c5fd4 (diff) |
linux-cp: Add tests for tun devices
Type: test
Signed-off-by: Neale Ranns <neale@graphiant.com>
Change-Id: Iec69d8624b15766ed65e7d09777819d2242dee17
Diffstat (limited to 'src/vnet')
-rw-r--r-- | src/vnet/ipsec/ipsec_api.c | 31 | ||||
-rw-r--r-- | src/vnet/ipsec/ipsec_itf.c | 12 | ||||
-rw-r--r-- | src/vnet/ipsec/ipsec_itf.h | 3 |
3 files changed, 46 insertions, 0 deletions
diff --git a/src/vnet/ipsec/ipsec_api.c b/src/vnet/ipsec/ipsec_api.c index b954a6eae9f..0eb51b5727f 100644 --- a/src/vnet/ipsec/ipsec_api.c +++ b/src/vnet/ipsec/ipsec_api.c @@ -696,9 +696,40 @@ vl_api_ipsec_itf_delete_t_handler (vl_api_ipsec_itf_delete_t * mp) REPLY_MACRO (VL_API_IPSEC_ITF_DELETE_REPLY); } +static walk_rc_t +send_ipsec_itf_details (ipsec_itf_t *itf, void *arg) +{ + ipsec_dump_walk_ctx_t *ctx = arg; + vl_api_ipsec_itf_details_t *mp; + + mp = vl_msg_api_alloc (sizeof (*mp)); + clib_memset (mp, 0, sizeof (*mp)); + mp->_vl_msg_id = ntohs (VL_API_IPSEC_ITF_DETAILS); + mp->context = ctx->context; + + mp->itf.mode = tunnel_mode_encode (itf->ii_mode); + mp->itf.user_instance = htonl (itf->ii_user_instance); + mp->itf.sw_if_index = htonl (itf->ii_sw_if_index); + vl_api_send_msg (ctx->reg, (u8 *) mp); + + return (WALK_CONTINUE); +} + static void vl_api_ipsec_itf_dump_t_handler (vl_api_ipsec_itf_dump_t * mp) { + vl_api_registration_t *reg; + + reg = vl_api_client_index_to_registration (mp->client_index); + if (!reg) + return; + + ipsec_dump_walk_ctx_t ctx = { + .reg = reg, + .context = mp->context, + }; + + ipsec_itf_walk (send_ipsec_itf_details, &ctx); } typedef struct ipsec_sa_dump_match_ctx_t_ diff --git a/src/vnet/ipsec/ipsec_itf.c b/src/vnet/ipsec/ipsec_itf.c index ae8e3427b12..532d5be4c07 100644 --- a/src/vnet/ipsec/ipsec_itf.c +++ b/src/vnet/ipsec/ipsec_itf.c @@ -342,6 +342,18 @@ ipsec_itf_delete (u32 sw_if_index) return 0; } +void +ipsec_itf_walk (ipsec_itf_walk_cb_t cb, void *ctx) +{ + ipsec_itf_t *itf; + + pool_foreach (itf, ipsec_itf_pool) + { + if (WALK_CONTINUE != cb (itf, ctx)) + break; + } +} + static clib_error_t * ipsec_itf_create_cli (vlib_main_t * vm, unformat_input_t * input, vlib_cli_command_t * cmd) diff --git a/src/vnet/ipsec/ipsec_itf.h b/src/vnet/ipsec/ipsec_itf.h index ab317e10332..4958d102b65 100644 --- a/src/vnet/ipsec/ipsec_itf.h +++ b/src/vnet/ipsec/ipsec_itf.h @@ -110,6 +110,9 @@ extern u8 *format_ipsec_itf (u8 * s, va_list * a); extern ipsec_itf_t *ipsec_itf_get (index_t ii); +typedef walk_rc_t (*ipsec_itf_walk_cb_t) (ipsec_itf_t *itf, void *ctx); +extern void ipsec_itf_walk (ipsec_itf_walk_cb_t cd, void *ctx); + /* * fd.io coding-style-patch-verification: ON * |