diff options
author | Klement Sekera <ksekera@cisco.com> | 2021-11-22 21:26:20 +0100 |
---|---|---|
committer | Ole Tr�an <otroan@employees.org> | 2021-12-14 09:15:48 +0000 |
commit | 9b7e8acf792cced80e6775bc5668d9db415cdb46 (patch) | |
tree | b600764a60f9978017a567390a025d2777b864a1 /src/vnet/srmpls/sr_mpls_api.c | |
parent | 755042dec0fcc733d456adc2a74042c529eff039 (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/vnet/srmpls/sr_mpls_api.c')
-rw-r--r-- | src/vnet/srmpls/sr_mpls_api.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/vnet/srmpls/sr_mpls_api.c b/src/vnet/srmpls/sr_mpls_api.c index 7d42f1ba451..45107f08ab1 100644 --- a/src/vnet/srmpls/sr_mpls_api.c +++ b/src/vnet/srmpls/sr_mpls_api.c @@ -39,6 +39,10 @@ #include <vnet/srmpls/sr_mpls.api.h> #undef vl_endianfun +#define vl_calcsizefun +#include <vnet/srmpls/sr_mpls.api.h> +#undef vl_calcsizefun + #define vl_printfun #include <vnet/srmpls/sr_mpls.api.h> #undef vl_printfun @@ -194,7 +198,8 @@ sr_mpls_api_hookup (vlib_main_t * vm) 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_vpe_api_msg; #undef _ @@ -207,7 +212,8 @@ sr_mpls_api_hookup (vlib_main_t * vm) vl_api_sr_mpls_policy_add_t_handler, vl_noop_handler, vl_api_sr_mpls_policy_add_t_endian, vl_api_sr_mpls_policy_add_t_print, 256, 1, vl_api_sr_mpls_policy_add_t_print_json, - vl_api_sr_mpls_policy_mod_t_tojson, vl_api_sr_mpls_policy_mod_t_fromjson); + vl_api_sr_mpls_policy_add_t_tojson, vl_api_sr_mpls_policy_add_t_fromjson, + vl_api_sr_mpls_policy_add_t_calc_size); /* * Manually register the sr policy mod msg, so we trace enough bytes @@ -218,7 +224,8 @@ sr_mpls_api_hookup (vlib_main_t * vm) vl_api_sr_mpls_policy_mod_t_handler, vl_noop_handler, vl_api_sr_mpls_policy_mod_t_endian, vl_api_sr_mpls_policy_mod_t_print, 256, 1, vl_api_sr_mpls_policy_mod_t_print_json, - vl_api_sr_mpls_policy_mod_t_tojson, vl_api_sr_mpls_policy_mod_t_fromjson); + vl_api_sr_mpls_policy_mod_t_tojson, vl_api_sr_mpls_policy_mod_t_fromjson, + vl_api_sr_mpls_policy_mod_t_calc_size); /* * Set up the (msg_name, crc, message-id) table |