mirror of
https://github.com/netblue30/firejail.git
synced 2026-05-15 14:16:14 -06:00
increase socket buffer size for firemon, bug #2700
This commit is contained in:
parent
0fa479a8ad
commit
bef5d86a10
5 changed files with 35 additions and 7 deletions
|
|
@ -26,6 +26,7 @@
|
|||
#include <sys/stat.h>
|
||||
|
||||
pid_t skip_process = 0;
|
||||
int arg_debug = 0;
|
||||
static int arg_route = 0;
|
||||
static int arg_arp = 0;
|
||||
static int arg_tree = 0;
|
||||
|
|
@ -142,7 +143,8 @@ int main(int argc, char **argv) {
|
|||
printf("firemon version %s\n\n", VERSION);
|
||||
return 0;
|
||||
}
|
||||
|
||||
else if (strcmp(argv[i], "--debug") == 0)
|
||||
arg_debug = 1;
|
||||
// options without a pid argument
|
||||
else if (strcmp(argv[i], "--top") == 0)
|
||||
arg_top = 1;
|
||||
|
|
|
|||
|
|
@ -29,6 +29,9 @@
|
|||
#include "../include/pid.h"
|
||||
#include "../include/common.h"
|
||||
|
||||
// main.c
|
||||
extern int arg_debug;
|
||||
|
||||
// clear screen
|
||||
static inline void firemon_clrscr(void) {
|
||||
printf("\033[2J\033[1;1H");
|
||||
|
|
|
|||
|
|
@ -173,6 +173,20 @@ static int procevent_netlink_setup(void) {
|
|||
if (bind(sock, (struct sockaddr *)&addr, sizeof(addr)) < 0)
|
||||
goto errexit;
|
||||
|
||||
// set a large socket rx buffer
|
||||
// the regular default value as set in /proc/sys/net/core/rmem_default will fill the
|
||||
// buffer much quicker than we can process it
|
||||
int bsize = 1024 * 1024; // 1MB
|
||||
socklen_t blen = sizeof(int);
|
||||
if (setsockopt(sock, SOL_SOCKET, SO_RCVBUFFORCE, &bsize, blen) == -1)
|
||||
fprintf(stderr, "Warning: cannot set rx buffer size, using default system value\n");
|
||||
else if (arg_debug) {
|
||||
if (getsockopt(sock, SOL_SOCKET, SO_RCVBUF, &bsize, &blen) == -1)
|
||||
fprintf(stderr, "Error: cannot read rx buffer size\n");
|
||||
else
|
||||
printf("rx buffer size %d\n", bsize / 2); // the value returned is duble the real one, see man 7 socket
|
||||
}
|
||||
|
||||
// send monitoring message
|
||||
struct nlmsghdr nlmsghdr;
|
||||
memset(&nlmsghdr, 0, sizeof(nlmsghdr));
|
||||
|
|
@ -244,14 +258,19 @@ static int procevent_monitor(const int sock, pid_t mypid) {
|
|||
}
|
||||
|
||||
|
||||
if ((len = recv(sock, buf, sizeof(buf), 0)) == 0) {
|
||||
if ((len = recv(sock, buf, sizeof(buf), 0)) == 0)
|
||||
return 0;
|
||||
}
|
||||
if (len == -1) {
|
||||
if (errno == EINTR) {
|
||||
return 0;
|
||||
} else {
|
||||
fprintf(stderr,"recv: %s\n", strerror(errno));
|
||||
if (errno == EINTR)
|
||||
continue;
|
||||
else if (errno == ENOBUFS) {
|
||||
// rx buffer is full, the kernel started dropping messages
|
||||
printf("*** Waning *** - message burst received, not all events are printed\n");
|
||||
//return -1;
|
||||
continue;
|
||||
}
|
||||
else {
|
||||
fprintf(stderr,"Error: rx socket recv call, errno %d, %s\n", errno, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ static char *help_str =
|
|||
"\t--caps - print capabilities configuration for each sandbox.\n\n"
|
||||
"\t--cgroup - print control group information for each sandbox.\n\n"
|
||||
"\t--cpu - print CPU affinity for each sandbox.\n\n"
|
||||
"\t--debug - print debug messages.\n\n"
|
||||
"\t--help, -? - this help screen.\n\n"
|
||||
"\t--interface - print network interface information for each sandbox.\n\n"
|
||||
"\t--list - list all sandboxes.\n\n"
|
||||
|
|
|
|||
|
|
@ -25,6 +25,9 @@ Print control group information for each sandbox.
|
|||
\fB\-\-cpu
|
||||
Print CPU affinity for each sandbox.
|
||||
.TP
|
||||
\fB\-\-debug
|
||||
Print debug messages
|
||||
.TP
|
||||
\fB\-?\fR, \fB\-\-help\fR
|
||||
Print options end exit.
|
||||
.TP
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue