aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorKlement Sekera <ksekera@cisco.com>2021-11-22 21:26:20 +0100
committerOle Tr�an <otroan@employees.org>2021-12-14 09:15:48 +0000
commit9b7e8acf792cced80e6775bc5668d9db415cdb46 (patch)
treeb600764a60f9978017a567390a025d2777b864a1 /src/plugins
parent755042dec0fcc733d456adc2a74042c529eff039 (diff)
api: verify message size on receipt
When a message is received, verify that it's sufficiently large to accomodate any VLAs within message. To do that, we need a way to calculate message size including any VLAs. This patch adds such funcionality to vppapigen and necessary C code to use those to validate message size on receipt. Drop messages which are malformed. Type: improvement Signed-off-by: Klement Sekera <ksekera@cisco.com> Change-Id: I2903aa21dee84be6822b064795ba314de46c18f4
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/hs_apps/sapi/vpp_echo_bapi.c7
-rw-r--r--src/plugins/tracedump/tracedump_test.c6
2 files changed, 11 insertions, 2 deletions
diff --git a/src/plugins/hs_apps/sapi/vpp_echo_bapi.c b/src/plugins/hs_apps/sapi/vpp_echo_bapi.c
index 30f3b78aff3..2e997096f85 100644
--- a/src/plugins/hs_apps/sapi/vpp_echo_bapi.c
+++ b/src/plugins/hs_apps/sapi/vpp_echo_bapi.c
@@ -548,6 +548,10 @@ _(APP_DEL_CERT_KEY_PAIR_REPLY, app_del_cert_key_pair_reply)
#include <vnet/session/session.api.h>
#undef vl_endianfun
+#define vl_calcsizefun
+#include <vnet/session/session.api.h>
+#undef vl_calcsizefun
+
#define vl_printfun
#include <vnet/session/session.api.h>
#undef vl_printfun
@@ -573,7 +577,8 @@ echo_api_hookup (echo_main_t * em)
REPLY_MSG_ID_BASE + VL_API_##N, #n, vl_api_##n##_t_handler, \
vl_noop_handler, vl_api_##n##_t_endian, vl_api_##n##_t_print, \
sizeof (vl_api_##n##_t), 1, vl_api_##n##_t_print_json, \
- vl_api_##n##_t_tojson, vl_api_##n##_t_fromjson);
+ vl_api_##n##_t_tojson, vl_api_##n##_t_fromjson, \
+ vl_api_##n##_t_calc_size);
foreach_quic_echo_msg;
#undef _
}
diff --git a/src/plugins/tracedump/tracedump_test.c b/src/plugins/tracedump/tracedump_test.c
index 05191a49ac4..abb81059199 100644
--- a/src/plugins/tracedump/tracedump_test.c
+++ b/src/plugins/tracedump/tracedump_test.c
@@ -242,6 +242,9 @@ api_trace_clear_capture (vat_main_t * vam)
#define vl_printfun
#include <tracedump/tracedump.api.h>
#undef vl_printfun
+#define vl_calcsizefun
+#include <tracedump/tracedump.api.h>
+#undef vl_calcsizefun
void
manual_setup_message_id_table (vat_main_t * vam)
@@ -251,7 +254,8 @@ manual_setup_message_id_table (vat_main_t * vam)
vl_api_trace_details_t_handler, vl_noop_handler,
vl_api_trace_details_t_endian, vl_api_trace_details_t_print,
sizeof (vl_api_trace_details_t), 1, vl_api_trace_details_t_print_json,
- vl_api_trace_details_t_tojson, vl_api_trace_details_t_fromjson);
+ vl_api_trace_details_t_tojson, vl_api_trace_details_t_fromjson,
+ vl_api_trace_details_t_calc_size);
}
#define VL_API_LOCAL_SETUP_MESSAGE_ID_TABLE manual_setup_message_id_table