diff options
author | arikachen <eaglesora@gmail.com> | 2021-11-12 06:40:55 +0000 |
---|---|---|
committer | Beno�t Ganne <bganne@cisco.com> | 2021-11-18 16:56:22 +0000 |
commit | 57bdb26ba42c3fc6da601d007b27fa5c3f09dd96 (patch) | |
tree | a5f4a9f29bff156a974139416ee75e3a69c867e9 /src/plugins/af_xdp/api.c | |
parent | ef048034be365ba312e37e0fd19c22414f4e6434 (diff) |
af_xdp: introduce to netns api
In some situation, we support to deploy vpp as per host
and handler packet in container, so we use xdp to redirect
the flow.
Type: improvement
Signed-off-by: arikachen <eaglesora@gmail.com>
Change-Id: Iab42d6a0abb2b330a284d519018a90aff2fa4371
Diffstat (limited to 'src/plugins/af_xdp/api.c')
-rw-r--r-- | src/plugins/af_xdp/api.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/plugins/af_xdp/api.c b/src/plugins/af_xdp/api.c index 1864c4c2ee9..45dab284e4c 100644 --- a/src/plugins/af_xdp/api.c +++ b/src/plugins/af_xdp/api.c @@ -87,6 +87,38 @@ vl_api_af_xdp_create_t_handler (vl_api_af_xdp_create_t * mp) } static void +vl_api_af_xdp_create_v2_t_handler (vl_api_af_xdp_create_v2_t *mp) +{ + vlib_main_t *vm = vlib_get_main (); + af_xdp_main_t *rm = &af_xdp_main; + vl_api_af_xdp_create_v2_reply_t *rmp; + af_xdp_create_if_args_t args; + int rv; + + clib_memset (&args, 0, sizeof (af_xdp_create_if_args_t)); + + args.linux_ifname = mp->host_if[0] ? (char *) mp->host_if : 0; + args.name = mp->name[0] ? (char *) mp->name : 0; + args.prog = mp->prog[0] ? (char *) mp->prog : 0; + args.netns = mp->namespace[0] ? (char *) mp->namespace : 0; + args.mode = af_xdp_api_mode (mp->mode); + args.flags = af_xdp_api_flags (mp->flags); + args.rxq_size = ntohs (mp->rxq_size); + args.txq_size = ntohs (mp->txq_size); + args.rxq_num = ntohs (mp->rxq_num); + + af_xdp_create_if (vm, &args); + rv = args.rv; + + /* clang-format off */ + REPLY_MACRO2 (VL_API_AF_XDP_CREATE_V2_REPLY + rm->msg_id_base, + ({ + rmp->sw_if_index = ntohl (args.sw_if_index); + })); + /* clang-format on */ +} + +static void vl_api_af_xdp_delete_t_handler (vl_api_af_xdp_delete_t * mp) { vlib_main_t *vm = vlib_get_main (); |