aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorElias Rudberg <elias.rudberg@bahnhof.net>2020-04-23 11:17:58 +0200
committerOle Trøan <otroan@employees.org>2020-05-06 09:28:51 +0000
commit8f8212b245ec7a411f98209663f310fe72c28edc (patch)
tree3aaae162128b020e3ff4862bb2fa477b52e0d695 /src
parentc611f36bbc75a7157bbec26a78178872ddc5441f (diff)
nat: ipfix logging vlib_mains[thread_index] bugfix
Use thread-specific vlib_main_t *vm pointers to avoid problems with different threads accessing the same vlib_main_t data structure. This avoids crashing when ipfix logging is enabled and several threads are used. Type: fix Signed-off-by: Elias Rudberg <elias.rudberg@bahnhof.net> Change-Id: Ic1d3d335919d7666ead14be1153eb8c8c07b7356
Diffstat (limited to 'src')
-rwxr-xr-xsrc/plugins/nat/nat_ipfix_logging.c32
1 files changed, 16 insertions, 16 deletions
diff --git a/src/plugins/nat/nat_ipfix_logging.c b/src/plugins/nat/nat_ipfix_logging.c
index 55f516e640c..da8e1f28991 100755
--- a/src/plugins/nat/nat_ipfix_logging.c
+++ b/src/plugins/nat/nat_ipfix_logging.c
@@ -532,7 +532,7 @@ snat_ipfix_header_create (flow_report_main_t * frm,
}
static inline void
-snat_ipfix_send (flow_report_main_t * frm,
+snat_ipfix_send (u32 thread_index, flow_report_main_t * frm,
vlib_frame_t * f, vlib_buffer_t * b0, u16 template_id)
{
ip4_ipfix_template_packet_t *tp;
@@ -540,7 +540,7 @@ snat_ipfix_send (flow_report_main_t * frm,
ipfix_set_header_t *s = 0;
ip4_header_t *ip;
udp_header_t *udp;
- vlib_main_t *vm = frm->vlib_main;
+ vlib_main_t *vm = vlib_mains[thread_index];
tp = vlib_buffer_get_current (b0);
ip = (ip4_header_t *) & tp->ip4;
@@ -584,7 +584,7 @@ snat_ipfix_logging_nat44_ses (u32 thread_index, u8 nat_event, u32 src_ip,
vlib_buffer_t *b0 = 0;
u32 bi0 = ~0;
u32 offset;
- vlib_main_t *vm = frm->vlib_main;
+ vlib_main_t *vm = vlib_mains[thread_index];
u64 now;
u8 proto = ~0;
u16 template_id;
@@ -667,7 +667,7 @@ snat_ipfix_logging_nat44_ses (u32 thread_index, u8 nat_event, u32 src_ip,
template_id = clib_atomic_fetch_or (
&silm->nat44_session_template_id,
0);
- snat_ipfix_send (frm, f, b0, template_id);
+ snat_ipfix_send (thread_index, frm, f, b0, template_id);
sitd->nat44_session_frame = 0;
sitd->nat44_session_buffer = 0;
offset = 0;
@@ -685,7 +685,7 @@ snat_ipfix_logging_addr_exhausted (u32 thread_index, u32 pool_id, int do_flush)
vlib_buffer_t *b0 = 0;
u32 bi0 = ~0;
u32 offset;
- vlib_main_t *vm = frm->vlib_main;
+ vlib_main_t *vm = vlib_mains[thread_index];
u64 now;
u8 nat_event = NAT_ADDRESSES_EXHAUTED;
u16 template_id;
@@ -751,7 +751,7 @@ snat_ipfix_logging_addr_exhausted (u32 thread_index, u32 pool_id, int do_flush)
template_id = clib_atomic_fetch_or (
&silm->addr_exhausted_template_id,
0);
- snat_ipfix_send (frm, f, b0, template_id);
+ snat_ipfix_send (thread_index, frm, f, b0, template_id);
sitd->addr_exhausted_frame = 0;
sitd->addr_exhausted_buffer = 0;
offset = 0;
@@ -770,7 +770,7 @@ snat_ipfix_logging_max_entries_per_usr (u32 thread_index,
vlib_buffer_t *b0 = 0;
u32 bi0 = ~0;
u32 offset;
- vlib_main_t *vm = frm->vlib_main;
+ vlib_main_t *vm = vlib_mains[thread_index];
u64 now;
u8 nat_event = QUOTA_EXCEEDED;
u32 quota_event = MAX_ENTRIES_PER_USER;
@@ -843,7 +843,7 @@ snat_ipfix_logging_max_entries_per_usr (u32 thread_index,
template_id = clib_atomic_fetch_or (
&silm->max_entries_per_user_template_id,
0);
- snat_ipfix_send (frm, f, b0, template_id);
+ snat_ipfix_send (thread_index, frm, f, b0, template_id);
sitd->max_entries_per_user_frame = 0;
sitd->max_entries_per_user_buffer = 0;
offset = 0;
@@ -861,7 +861,7 @@ nat_ipfix_logging_max_ses (u32 thread_index, u32 limit, int do_flush)
vlib_buffer_t *b0 = 0;
u32 bi0 = ~0;
u32 offset;
- vlib_main_t *vm = frm->vlib_main;
+ vlib_main_t *vm = vlib_mains[thread_index];
u64 now;
u8 nat_event = QUOTA_EXCEEDED;
u32 quota_event = MAX_SESSION_ENTRIES;
@@ -931,7 +931,7 @@ nat_ipfix_logging_max_ses (u32 thread_index, u32 limit, int do_flush)
template_id = clib_atomic_fetch_or (
&silm->max_sessions_template_id,
0);
- snat_ipfix_send (frm, f, b0, template_id);
+ snat_ipfix_send (thread_index, frm, f, b0, template_id);
sitd->max_sessions_frame = 0;
sitd->max_sessions_buffer = 0;
offset = 0;
@@ -949,7 +949,7 @@ nat_ipfix_logging_max_bib (u32 thread_index, u32 limit, int do_flush)
vlib_buffer_t *b0 = 0;
u32 bi0 = ~0;
u32 offset;
- vlib_main_t *vm = frm->vlib_main;
+ vlib_main_t *vm = vlib_mains[thread_index];
u64 now;
u8 nat_event = QUOTA_EXCEEDED;
u32 quota_event = MAX_BIB_ENTRIES;
@@ -1019,7 +1019,7 @@ nat_ipfix_logging_max_bib (u32 thread_index, u32 limit, int do_flush)
template_id = clib_atomic_fetch_or (
&silm->max_bibs_template_id,
0);
- snat_ipfix_send (frm, f, b0, template_id);
+ snat_ipfix_send (thread_index, frm, f, b0, template_id);
sitd->max_bibs_frame = 0;
sitd->max_bibs_buffer = 0;
offset = 0;
@@ -1040,7 +1040,7 @@ nat_ipfix_logging_nat64_bibe (u32 thread_index, u8 nat_event,
vlib_buffer_t *b0 = 0;
u32 bi0 = ~0;
u32 offset;
- vlib_main_t *vm = frm->vlib_main;
+ vlib_main_t *vm = vlib_mains[thread_index];
u64 now;
u16 template_id;
@@ -1120,7 +1120,7 @@ nat_ipfix_logging_nat64_bibe (u32 thread_index, u8 nat_event,
template_id = clib_atomic_fetch_or (
&silm->nat64_bib_template_id,
0);
- snat_ipfix_send (frm, f, b0, template_id);
+ snat_ipfix_send (thread_index, frm, f, b0, template_id);
sitd->nat64_bib_frame = 0;
sitd->nat64_bib_buffer = 0;
offset = 0;
@@ -1143,7 +1143,7 @@ nat_ipfix_logging_nat64_ses (u32 thread_index, u8 nat_event,
vlib_buffer_t *b0 = 0;
u32 bi0 = ~0;
u32 offset;
- vlib_main_t *vm = frm->vlib_main;
+ vlib_main_t *vm = vlib_mains[thread_index];
u64 now;
u16 template_id;
@@ -1235,7 +1235,7 @@ nat_ipfix_logging_nat64_ses (u32 thread_index, u8 nat_event,
template_id = clib_atomic_fetch_or (
&silm->nat64_ses_template_id,
0);
- snat_ipfix_send (frm, f, b0, template_id);
+ snat_ipfix_send (thread_index, frm, f, b0, template_id);
sitd->nat64_ses_frame = 0;
sitd->nat64_ses_buffer = 0;
offset = 0;