summaryrefslogtreecommitdiffstats
path: root/src/plugins/nat/lib/ipfix_logging.c
diff options
context:
space:
mode:
authorMatthew Smith <mgsmith@netgate.com>2020-11-04 11:18:10 -0600
committerMatthew Smith <mgsmith@netgate.com>2020-12-11 20:03:32 +0000
commitbfba2d555331ce67f707e608877e96dbd2aacd80 (patch)
treebbba7d8a489b19fb5e664a550ed5997d2e157dc3 /src/plugins/nat/lib/ipfix_logging.c
parenta8ebb518445a3ee82e7d18858ea6d2f24c780abc (diff)
nat: fix byte order on ipfix message fields
Type: fix The code for quota exceeded events is a u32 and was being copied into ipfix packets in host byte order. Same for the limit field. Swap the order before copying into packet buffer. Change-Id: I881766e1c52acc9bebde38d85228fa492214ee21 Signed-off-by: Matthew Smith <mgsmith@netgate.com>
Diffstat (limited to 'src/plugins/nat/lib/ipfix_logging.c')
-rw-r--r--src/plugins/nat/lib/ipfix_logging.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/plugins/nat/lib/ipfix_logging.c b/src/plugins/nat/lib/ipfix_logging.c
index 2fb8912226d..872d11bdfb5 100644
--- a/src/plugins/nat/lib/ipfix_logging.c
+++ b/src/plugins/nat/lib/ipfix_logging.c
@@ -780,7 +780,7 @@ nat_ipfix_logging_max_entries_per_usr (u32 thread_index,
vlib_main_t *vm = vlib_get_main ();
u64 now;
u8 nat_event = QUOTA_EXCEEDED;
- u32 quota_event = MAX_ENTRIES_PER_USER;
+ u32 quota_event = clib_host_to_net_u32 (MAX_ENTRIES_PER_USER);
u16 template_id;
now = (u64) ((vlib_time_now (vm) - silm->vlib_time_0) * 1e3);
@@ -835,6 +835,7 @@ nat_ipfix_logging_max_entries_per_usr (u32 thread_index,
clib_memcpy_fast (b0->data + offset, &quota_event, sizeof (quota_event));
offset += sizeof (quota_event);
+ limit = clib_host_to_net_u32 (limit);
clib_memcpy_fast (b0->data + offset, &limit, sizeof (limit));
offset += sizeof (limit);
@@ -871,7 +872,7 @@ nat_ipfix_logging_max_ses (u32 thread_index, u32 limit, int do_flush)
vlib_main_t *vm = vlib_get_main ();
u64 now;
u8 nat_event = QUOTA_EXCEEDED;
- u32 quota_event = MAX_SESSION_ENTRIES;
+ u32 quota_event = clib_host_to_net_u32 (MAX_SESSION_ENTRIES);
u16 template_id;
now = (u64) ((vlib_time_now (vm) - silm->vlib_time_0) * 1e3);
@@ -926,6 +927,7 @@ nat_ipfix_logging_max_ses (u32 thread_index, u32 limit, int do_flush)
clib_memcpy_fast (b0->data + offset, &quota_event, sizeof (quota_event));
offset += sizeof (quota_event);
+ limit = clib_host_to_net_u32 (limit);
clib_memcpy_fast (b0->data + offset, &limit, sizeof (limit));
offset += sizeof (limit);
@@ -959,7 +961,7 @@ nat_ipfix_logging_max_bib (u32 thread_index, u32 limit, int do_flush)
vlib_main_t *vm = vlib_get_main ();
u64 now;
u8 nat_event = QUOTA_EXCEEDED;
- u32 quota_event = MAX_BIB_ENTRIES;
+ u32 quota_event = clib_host_to_net_u32 (MAX_BIB_ENTRIES);
u16 template_id;
now = (u64) ((vlib_time_now (vm) - silm->vlib_time_0) * 1e3);
@@ -1014,6 +1016,7 @@ nat_ipfix_logging_max_bib (u32 thread_index, u32 limit, int do_flush)
clib_memcpy_fast (b0->data + offset, &quota_event, sizeof (quota_event));
offset += sizeof (quota_event);
+ limit = clib_host_to_net_u32 (limit);
clib_memcpy_fast (b0->data + offset, &limit, sizeof (limit));
offset += sizeof (limit);