summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorwangmenglan <[email protected]>2024-04-23 15:18:50 +0630
committerwangmenglan <[email protected]>2024-04-24 15:22:13 +0630
commit5851c46103f0547fa224b6e0759852785773c14e (patch)
tree5ddbe6c6458fff8da9264b7e66ad2d35fe84766a /common
parent4ca3f5a4a21149825b1d92817d1d94ae0e00ee9a (diff)
bugfix:增加异常处理v4.8.80-20240424
Diffstat (limited to 'common')
-rw-r--r--common/src/tfe_packet_io.cpp31
1 files changed, 30 insertions, 1 deletions
diff --git a/common/src/tfe_packet_io.cpp b/common/src/tfe_packet_io.cpp
index b2d052d..eda7b38 100644
--- a/common/src/tfe_packet_io.cpp
+++ b/common/src/tfe_packet_io.cpp
@@ -923,7 +923,6 @@ static void send_event_log(struct session_ctx *s_ctx, int thread_seq, void *ctx)
// finish writing
if (mpack_writer_destroy(&writer) != mpack_ok)
{
- assert(0);
if (data)
{
free(data);
@@ -936,6 +935,13 @@ static void send_event_log(struct session_ctx *s_ctx, int thread_seq, void *ctx)
int raw_packet_header_len = s_ctx->ctrl_meta->l7offset;
marsio_buff_malloc_global(packet_io->instance, tx_buffs, 1, 0, thread_seq);
char *dst = marsio_buff_append(tx_buffs[0], raw_packet_header_len + size);
+ if (dst == NULL)
+ {
+ TFE_LOG_ERROR(logger, "%s: unable to send log_update packet, get marsio buff is NULL.", LOG_TAG_PKTIO);
+ if (data)
+ free(data);
+ return;
+ }
memcpy(dst, raw_packet_header_data, raw_packet_header_len);
memcpy(dst + raw_packet_header_len, data, size);
@@ -1038,6 +1044,11 @@ static void packet_io_send_fake_pkt(struct packet_io_thread_ctx *thread, struct
{
meta.raw_len = fn[i](info, client_mac, server_mac, buffer, sizeof(buffer));
meta.raw_data = marsio_buff_append(tx_buffs[i], meta.raw_len);
+ if (meta.raw_data == NULL)
+ {
+ TFE_LOG_ERROR(logger, "%s: unable to send fake packet, get marsio buff is NULL.", LOG_TAG_PKTIO);
+ continue;
+ }
memcpy(meta.raw_data, buffer, meta.raw_len);
switch (i)
@@ -1948,6 +1959,12 @@ void handle_decryption_packet_from_tap(const char *data, int len, void *args)
}
char *dst = marsio_buff_append(tx_buffs[0], len);
+ if (dst == NULL)
+ {
+ throughput_metrics_inc(&packet_io_fs->decrypt_rxdrop, 1, len);
+ TFE_LOG_ERROR(logger, "%s: unable to send decryption packet, get marsio buff is NULL.", LOG_TAG_PKTIO);
+ return;
+ }
memcpy(dst, data, len);
struct metadata meta = {0};
@@ -2043,12 +2060,24 @@ void handle_raw_packet_from_tap(const char *data, int len, void *args)
if (header != NULL) {
packet_len = len + header_len - sizeof(struct ethhdr);
dst = marsio_buff_append(tx_buffs[0], packet_len);
+ if (dst == NULL)
+ {
+ throughput_metrics_inc(&packet_io_fs->tap_pkt_rxdrop, 1, len);
+ TFE_LOG_ERROR(logger, "%s: unable to send raw packet, get marsio buff is NULL.", LOG_TAG_PKTIO);
+ return;
+ }
memcpy(dst, header, header_len);
memcpy(dst + header_len, data + sizeof(struct ethhdr), len - sizeof(struct ethhdr));
}
else {
packet_len = len;
dst = marsio_buff_append(tx_buffs[0], len);
+ if (dst == NULL)
+ {
+ throughput_metrics_inc(&packet_io_fs->tap_pkt_rxdrop, 1, len);
+ TFE_LOG_ERROR(logger, "%s: unable to send raw packet, get marsio buff is NULL.", LOG_TAG_PKTIO);
+ return;
+ }
memcpy(dst, data, len);
}