summaryrefslogtreecommitdiffstats
path: root/src/vnet
diff options
context:
space:
mode:
authorDmitry Valter <d-valter@yandex-team.ru>2022-12-12 11:43:33 +0000
committerDave Wallace <dwallacelf@gmail.com>2022-12-16 17:25:27 +0000
commit415b6a7c75d003b90d8a7f02563ab41f1b036c21 (patch)
tree3a4405e674912df40f557c3c2ea95ec9b637c284 /src/vnet
parent4117b24acb4241d7f2ef38248bc254f6a4a7b422 (diff)
bfd: fix bfd udp error enum incompatibility
New BFD UDP errors were no longer compatible with BFD errors. This was causing out-of-bound reads and ASAN test crashes. Fix this issue by statically checking if these enums are compatible. Type: fix Signed-off-by: Dmitry Valter <d-valter@yandex-team.ru> Change-Id: I92fddd26270f946bc16ade840c94e5496e2cb88a
Diffstat (limited to 'src/vnet')
-rw-r--r--src/vnet/bfd/bfd.api51
-rw-r--r--src/vnet/bfd/bfd_udp.c8
2 files changed, 55 insertions, 4 deletions
diff --git a/src/vnet/bfd/bfd.api b/src/vnet/bfd/bfd.api
index f573bc5309a..d3b3ed21a26 100644
--- a/src/vnet/bfd/bfd.api
+++ b/src/vnet/bfd/bfd.api
@@ -359,6 +359,7 @@ autoreply define bfd_udp_auth_deactivate
bool is_delayed;
};
+/* must be compatible with bfd_error_t */
counters bfd_udp {
none {
severity info;
@@ -366,17 +367,23 @@ counters bfd_udp {
units "packets";
description "OK";
};
- no_session {
+ bad {
severity error;
type counter64;
units "packets";
- description "no-session";
+ description "bad packet";
};
- bad {
+ disabled {
severity error;
type counter64;
units "packets";
- description "bad packet";
+ description "bfd packets received on disabled interfaces";
+ };
+ version {
+ severity error;
+ type counter64;
+ units "packets";
+ description "version";
};
length {
severity error;
@@ -384,6 +391,42 @@ counters bfd_udp {
units "packets";
description "too short";
};
+ detect_multi {
+ severity error;
+ type counter64;
+ units "packets";
+ description "detect-multi";
+ };
+ multi_point {
+ severity error;
+ type counter64;
+ units "packets";
+ description "multi-point";
+ };
+ my_disc {
+ severity error;
+ type counter64;
+ units "packets";
+ description "my-disc";
+ };
+ your_disc {
+ severity error;
+ type counter64;
+ units "packets";
+ description "your-disc";
+ };
+ admin_down {
+ severity error;
+ type counter64;
+ units "packets";
+ description "session admin-down";
+ };
+ no_session {
+ severity error;
+ type counter64;
+ units "packets";
+ description "no-session";
+ };
failed_verification {
severity error;
type counter64;
diff --git a/src/vnet/bfd/bfd_udp.c b/src/vnet/bfd/bfd_udp.c
index 37bb102d2d9..2ba43a309d1 100644
--- a/src/vnet/bfd/bfd_udp.c
+++ b/src/vnet/bfd/bfd_udp.c
@@ -42,6 +42,14 @@
#include <vnet/bfd/bfd_api.h>
#include <vnet/bfd/bfd.api_enum.h>
+#define F(sym, str) \
+ STATIC_ASSERT ((int) BFD_ERROR_##sym == (int) BFD_UDP_ERROR_##sym, \
+ "BFD error enums mismatch");
+foreach_bfd_error (F)
+#undef F
+ STATIC_ASSERT ((int) BFD_N_ERROR <= (int) BFD_UDP_N_ERROR,
+ "BFD error enum sizes mismatch");
+
typedef struct
{
bfd_main_t *bfd_main;