Disallow I/O Output for Distributors with all buffers in use/full
Some checks failed
RPM Build / build (push) Has been cancelled
Build / macOS-14 cc (push) Has been cancelled
Build / ubuntu-latest clang (push) Has been cancelled
Build / ubuntu-latest clang-1 (push) Has been cancelled
Build / ubuntu-22.04 clang-12 (push) Has been cancelled
ArchLinux PKGBUILD / build (push) Has been cancelled
Docker Build / docker (push) Has been cancelled
FreeBSD Build / Build and Test (push) Has been cancelled
Build OpenWrt Packages / build (malta-be) (push) Has been cancelled
Build OpenWrt Packages / build (armsr-armv8) (push) Has been cancelled
Build OpenWrt Packages / build (ramips-mt7621) (push) Has been cancelled
Build / ubuntu-latest gcc (push) Has been cancelled
Build / ubuntu-latest gcc-1 (push) Has been cancelled
Build / ubuntu-22.04 gcc-9 (push) Has been cancelled
Build OpenWrt Packages / build (x86-64) (push) Has been cancelled
Build / ubuntu-latest gcc-2 (push) Has been cancelled
Build / ubuntu-22.04 gcc-10 (push) Has been cancelled
SonarQube Scan / Build and analyze (push) Has been cancelled

Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
This commit is contained in:
Toni Uhlig 2026-10-07 14:03:10 +02:00
parent 5d5c6c732c
commit 65fb7c2185
No known key found for this signature in database
GPG key ID: 22C5333D922537D2
2 changed files with 16 additions and 13 deletions

View file

@ -149,9 +149,9 @@ static int pcap_open_or_append(int packet_datalink,
return 0;
}
static void decode_base64(pcap_dumper_t * const pd,
struct packet_data * const pd_elt,
struct flow_packet_data * const fd_elt)
static int decode_base64(pcap_dumper_t * const pd,
struct packet_data * const pd_elt,
struct flow_packet_data * const fd_elt)
{
char const * base64_packet;
size_t base64_packet_size;
@ -176,7 +176,7 @@ static void decode_base64(pcap_dumper_t * const pd,
else
{
logger(1, "%s", "BUG: Can not decode base64 packet.");
return;
return 1;
}
if (nDPIsrvd_base64decode(base64_packet, base64_packet_size, pkt_buf, &pkt_buf_len) != 0 || pkt_buf_len == 0)
@ -186,6 +186,7 @@ static void decode_base64(pcap_dumper_t * const pd,
} else {
logger(1, "Packet event Base64 decode failed (%zu bytes)", base64_packet_size);
}
return 1;
}
else
{
@ -195,6 +196,7 @@ static void decode_base64(pcap_dumper_t * const pd,
phdr.caplen = pkt_buf_len;
phdr.len = pkt_buf_len;
pcap_dump((unsigned char *)pd, &phdr, pkt_buf);
return 0;
}
}
@ -735,7 +737,7 @@ static enum nDPIsrvd_callback_return captured_json_callback(struct nDPIsrvd_sock
if (TOKEN_GET_SZ(sock, "error_event_name") != NULL)
{
logger(1, "Received an error event for packet id %llu.", packet_id);
//logger(1, "Received an error event for packet id %llu.", packet_id);
if (TOKEN_GET_SZ(sock, "error_event_id") == NULL)
{
@ -754,7 +756,7 @@ static enum nDPIsrvd_callback_return captured_json_callback(struct nDPIsrvd_sock
}
else if (TOKEN_VALUE_EQUALS_SZ(sock, TOKEN_GET_SZ(sock, "packet_event_name"), "packet") != 0)
{
logger(1, "Received an packet event for packet id %llu.", packet_id);
//logger(1, "Received an packet event for packet id %llu.", packet_id);
if (capture_mode != 0)
{
@ -804,7 +806,7 @@ static enum nDPIsrvd_callback_return captured_json_callback(struct nDPIsrvd_sock
if (packet_write_pcap_file(global_user) != 0)
{
logger(1, "%s", "Could not dump non-flow packet data");
//logger(1, "%s", "Could not dump non-flow packet data");
return CALLBACK_OK;
}
}
@ -977,7 +979,7 @@ static enum nDPIsrvd_callback_return captured_json_callback(struct nDPIsrvd_sock
errno = 0;
if (flow_write_pcap_file(flow_user, pcap_filename) != 0)
{
logger(1, "Could not dump packet data to pcap file %s: %s", pcap_filename, strerror(errno));
//logger(1, "Could not dump packet data to pcap file %s", pcap_filename);
return CALLBACK_OK;
}
}

View file

@ -336,7 +336,7 @@ static UT_array * get_additional_write_buffers(struct remote_desc * const remote
return NULL;
}
static int add_to_additional_write_buffers(struct nio * const io, int index,
static int add_to_additional_write_buffers(struct nio * const io,
struct remote_desc * const remote,
uint8_t * const buf,
nDPIsrvd_ull json_message_length)
@ -349,9 +349,6 @@ static int add_to_additional_write_buffers(struct nio * const io, int index,
return -1;
}
if (nio_can_output(io, index) == NIO_SUCCESS) {
return 0;
}
if (utarray_len(additional_write_buffers) >= GET_CMDARG_ULL(nDPIsrvd_options.max_write_buffers))
{
logger_nDPIsrvd(remote,
@ -1807,10 +1804,14 @@ static int handle_incoming_data(struct nio * const io, int index, struct remote_
continue;
}
if (nio_can_output(io, index) == NIO_SUCCESS) {
continue;
}
if (json_bytes == NULL || *json_bytes > write_buffer->buf.max - write_buffer->buf.used ||
utarray_len(additional_write_buffers) > 0)
{
if (add_to_additional_write_buffers(io, index,
if (add_to_additional_write_buffers(io,
&remotes.desc[i],
json_read_buffer->buf.ptr.raw,
*json_bytes) != 0)