Skip to content

Commit 688bd53

Browse files
committed
pcap: implement pcap-file-buffer-size option
Allows easy specification of buffer size on the commandline. Ticket: OISF#7155.
1 parent 7b730c2 commit 688bd53

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

doc/userguide/partials/options.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,11 @@
7777
continuously feed files to a directory and have them cleaned up when done. If
7878
this option is not set, pcap files will not be deleted after processing.
7979

80+
.. option:: --pcap-file-buffer-size <value>
81+
82+
Set read buffer size using ``setvbuf`` to speed up pcap reading. Valid values
83+
are 4 KiB to 64 MiB. Default value is 128 KiB. Supported on Linux only.
84+
8085
.. option:: -i <interface>
8186

8287
After the -i option you can enter the interface card you would like

src/suricata.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -631,6 +631,7 @@ static void PrintUsage(const char *progname)
631631
printf("\t--pcap-file-continuous : when running in pcap mode with a directory, continue checking directory for pcaps until interrupted\n");
632632
printf("\t--pcap-file-delete : when running in replay mode (-r with directory or file), will delete pcap files that have been processed when done\n");
633633
printf("\t--pcap-file-recursive : will descend into subdirectories when running in replay mode (-r)\n");
634+
printf("\t--pcap-file-buffer-size : set read buffer size (setvbuf)\n");
634635
#ifdef HAVE_PCAP_SET_BUFF
635636
printf("\t--pcap-buffer-size : size of the pcap buffer value from 0 - %i\n",INT_MAX);
636637
#endif /* HAVE_SET_PCAP_BUFF */
@@ -1351,6 +1352,7 @@ TmEcode SCParseCommandLine(int argc, char **argv)
13511352
{"pcap-file-continuous", 0, 0, 0},
13521353
{"pcap-file-delete", 0, 0, 0},
13531354
{"pcap-file-recursive", 0, 0, 0},
1355+
{"pcap-file-buffer-size", required_argument, 0, 0},
13541356
{"simulate-ips", 0, 0 , 0},
13551357
{"no-random", 0, &g_disable_randomness, 1},
13561358
{"strict-rule-keywords", optional_argument, 0, 0},
@@ -1755,8 +1757,12 @@ TmEcode SCParseCommandLine(int argc, char **argv)
17551757
SCLogError("failed to set pcap-file.recursive");
17561758
return TM_ECODE_FAILED;
17571759
}
1758-
}
1759-
else if (strcmp((long_opts[option_index]).name, "data-dir") == 0) {
1760+
} else if (strcmp((long_opts[option_index]).name, "pcap-file-buffer-size") == 0) {
1761+
if (ConfSetFinal("pcap-file.buffer-size", optarg) != 1) {
1762+
SCLogError("failed to set pcap-file.buffer-size");
1763+
return TM_ECODE_FAILED;
1764+
}
1765+
} else if (strcmp((long_opts[option_index]).name, "data-dir") == 0) {
17601766
if (optarg == NULL) {
17611767
SCLogError("no option argument (optarg) for -d");
17621768
return TM_ECODE_FAILED;
@@ -1774,7 +1780,7 @@ TmEcode SCParseCommandLine(int argc, char **argv)
17741780
return TM_ECODE_FAILED;
17751781
}
17761782
suri->set_datadir = true;
1777-
} else if (strcmp((long_opts[option_index]).name , "strict-rule-keywords") == 0){
1783+
} else if (strcmp((long_opts[option_index]).name, "strict-rule-keywords") == 0) {
17781784
if (optarg == NULL) {
17791785
suri->strict_rule_parsing_string = SCStrdup("all");
17801786
} else {

suricata.yaml.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -860,6 +860,8 @@ pcap-file:
860860
# checksum off-loading is used. (default)
861861
# Warning: 'checksum-validation' must be set to yes to have checksum tested
862862
checksum-checks: auto
863+
# Read buffer size set using setvbuf. Max value is 64 MiB. Linux only.
864+
#buffer-size: 128 KiB
863865

864866
# See "Advanced Capture Options" below for more options, including Netmap
865867
# and PF_RING.

0 commit comments

Comments
 (0)