summaryrefslogtreecommitdiffstats
path: root/src/vnet/udp/udp_api.c
diff options
context:
space:
mode:
authorNeale Ranns <nranns@cisco.com>2018-09-07 08:57:41 -0700
committerDamjan Marion <dmarion@me.com>2018-09-20 10:57:25 +0000
commit9c0a3c423ee0b9326f600a00c1bd46fef45d4975 (patch)
tree6415119b2e341cd340f2b2cbbb44e8ce0c689451 /src/vnet/udp/udp_api.c
parentda8e1802625bd5d6e9901d5a96106e6de4f3d71f (diff)
UDP-Encap: name counters for the stats segment
change the ADD api so that is returns the 'ID' that can be used by the client to read the stats from the stats segment and to delete the object. Previously a similar value used required to be chosen by the client, now VPP allocates one (like it does e.g. for interfaces) Change-Id: I563cf6092276eb990c52d5457c86e72546bcf69e Signed-off-by: Neale Ranns <nranns@cisco.com>
Diffstat (limited to 'src/vnet/udp/udp_api.c')
-rw-r--r--src/vnet/udp/udp_api.c24
1 files changed, 15 insertions, 9 deletions
diff --git a/src/vnet/udp/udp_api.c b/src/vnet/udp/udp_api.c
index 43a39b82ef0..d00d74e27d5 100644
--- a/src/vnet/udp/udp_api.c
+++ b/src/vnet/udp/udp_api.c
@@ -86,7 +86,7 @@ send_udp_encap_details (const udp_encap_t * ue, vl_api_registration_t * reg,
mp->udp_encap.table_id =
htonl (fib_table_get_table_id (ue->ue_fib_index, ue->ue_ip_proto));
- mp->udp_encap.id = htonl (ue->ue_id);
+ mp->udp_encap.id = htonl (ue - udp_encap_pool);
vl_api_send_msg (reg, (u8 *) mp);
}
@@ -115,12 +115,12 @@ vl_api_udp_encap_add_t_handler (vl_api_udp_encap_add_t * mp, vlib_main_t * vm)
{
vl_api_udp_encap_add_reply_t *rmp;
ip46_address_t src_ip, dst_ip;
- u32 fib_index, table_id, ue_id;
+ u32 fib_index, table_id;
fib_protocol_t fproto;
ip46_type_t itype;
+ index_t uei;
int rv = 0;
- ue_id = ntohl (mp->udp_encap.id);
table_id = ntohl (mp->udp_encap.table_id);
itype = ip_address_decode (&mp->udp_encap.src_ip, &src_ip);
@@ -134,14 +134,20 @@ vl_api_udp_encap_add_t_handler (vl_api_udp_encap_add_t * mp, vlib_main_t * vm)
goto done;
}
- udp_encap_add_and_lock (ue_id, fproto, fib_index,
- &src_ip, &dst_ip,
- ntohs (mp->udp_encap.src_port),
- ntohs (mp->udp_encap.dst_port),
- UDP_ENCAP_FIXUP_NONE);
+ uei = udp_encap_add_and_lock (fproto, fib_index,
+ &src_ip, &dst_ip,
+ ntohs (mp->udp_encap.src_port),
+ ntohs (mp->udp_encap.dst_port),
+ UDP_ENCAP_FIXUP_NONE);
done:
- REPLY_MACRO (VL_API_UDP_ENCAP_ADD_REPLY);
+ /* *INDENT-OFF* */
+ REPLY_MACRO2 (VL_API_UDP_ENCAP_ADD_REPLY,
+ ({
+ rmp->id = ntohl (uei);
+ }));
+ /* *INDENT-ON* */
+
}
static void