diff options
author | John Lo <loj@cisco.com> | 2020-06-11 00:20:45 -0400 |
---|---|---|
committer | Florin Coras <florin.coras@gmail.com> | 2020-06-16 07:25:30 +0000 |
commit | 9ebbb5c41620066d45915020569db9e4316450a5 (patch) | |
tree | 8529b395f4063e7b20064e4d2cb89fc9a39395e4 /src/plugins/gtpu/gtpu_api.c | |
parent | a0e8d9669e980c673f5302e7bff0c06b31d46b56 (diff) |
gtpu: support separate rx-decap and encap-tx teid values
Support separate local and remote TEIDs, with local (or RX) one used
for GTPU tunnel RX/decap and remote (or TX) one used encap/TX.
Updated current gtpu API to support seperate RX/TX TEIDs and added new
gtpu_tunnel_update_tteid API to allow changing TX-TEID of an existing
GTPU tunnel. The current tunnel field "teid" is used for RX-TEID and
a new field "tteid" is used for TX-TEID.
Type: improvement
Signed-off-by: John Lo <loj@cisco.com>
Change-Id: I549d79750a34bb965036da298c0ca894d15c2c20
Diffstat (limited to 'src/plugins/gtpu/gtpu_api.c')
-rw-r--r-- | src/plugins/gtpu/gtpu_api.c | 55 |
1 files changed, 43 insertions, 12 deletions
diff --git a/src/plugins/gtpu/gtpu_api.c b/src/plugins/gtpu/gtpu_api.c index 24fb8e2eae2..1100a7f90c1 100644 --- a/src/plugins/gtpu/gtpu_api.c +++ b/src/plugins/gtpu/gtpu_api.c @@ -116,26 +116,27 @@ static void vl_api_gtpu_add_del_tunnel_t_handler { vl_api_gtpu_add_del_tunnel_reply_t *rmp; int rv = 0; - ip4_main_t *im = &ip4_main; gtpu_main_t *gtm = >pu_main; - uword *p = hash_get (im->fib_index_by_table_id, ntohl (mp->encap_vrf_id)); - if (!p) - { - rv = VNET_API_ERROR_NO_SUCH_FIB; - goto out; - } - - vnet_gtpu_add_del_tunnel_args_t a = { - .is_add = mp->is_add, + vnet_gtpu_add_mod_del_tunnel_args_t a = { + .opn = mp->is_add ? GTPU_ADD_TUNNEL : GTPU_DEL_TUNNEL, .mcast_sw_if_index = ntohl (mp->mcast_sw_if_index), - .encap_fib_index = p[0], .decap_next_index = ntohl (mp->decap_next_index), .teid = ntohl (mp->teid), + .tteid = ntohl (mp->tteid), }; ip_address_decode (&mp->dst_address, &a.dst); ip_address_decode (&mp->src_address, &a.src); + u8 is_ipv6 = !ip46_address_is_ip4 (&a.dst); + a.encap_fib_index = fib_table_find (fib_ip_proto (is_ipv6), + ntohl (mp->encap_vrf_id)); + if (a.encap_fib_index == ~0) + { + rv = VNET_API_ERROR_NO_SUCH_FIB; + goto out; + } + /* Check src & dst are different */ if (ip46_address_cmp (&a.dst, &a.src) == 0) { @@ -150,7 +151,7 @@ static void vl_api_gtpu_add_del_tunnel_t_handler } u32 sw_if_index = ~0; - rv = vnet_gtpu_add_del_tunnel (&a, &sw_if_index); + rv = vnet_gtpu_add_mod_del_tunnel (&a, &sw_if_index); out: /* *INDENT-OFF* */ @@ -161,6 +162,35 @@ out: /* *INDENT-ON* */ } +static void vl_api_gtpu_tunnel_update_tteid_t_handler + (vl_api_gtpu_tunnel_update_tteid_t * mp) +{ + vl_api_gtpu_tunnel_update_tteid_reply_t *rmp; + int rv = 0; + gtpu_main_t *gtm = >pu_main; + + vnet_gtpu_add_mod_del_tunnel_args_t a = { + .opn = GTPU_UPD_TTEID, + .teid = ntohl (mp->teid), + .tteid = ntohl (mp->tteid), + }; + ip_address_decode (&mp->dst_address, &a.dst); + + u8 is_ipv6 = !ip46_address_is_ip4 (&a.dst); + a.encap_fib_index = fib_table_find (fib_ip_proto (is_ipv6), + ntohl (mp->encap_vrf_id)); + if (a.encap_fib_index == ~0) + { + rv = VNET_API_ERROR_NO_SUCH_FIB; + goto out; + } + + rv = vnet_gtpu_add_mod_del_tunnel (&a, 0); + +out: + REPLY_MACRO (VL_API_GTPU_TUNNEL_UPDATE_TTEID_REPLY); +} + static void send_gtpu_tunnel_details (gtpu_tunnel_t * t, vl_api_registration_t * reg, u32 context) { @@ -184,6 +214,7 @@ static void send_gtpu_tunnel_details htonl (im4->fibs[t->encap_fib_index].ft_table_id); rmp->mcast_sw_if_index = htonl (t->mcast_sw_if_index); rmp->teid = htonl (t->teid); + rmp->tteid = htonl (t->tteid); rmp->decap_next_index = htonl (t->decap_next_index); rmp->sw_if_index = htonl (t->sw_if_index); rmp->context = context; |