@@ -65,7 +65,7 @@ struct ctx {
65
65
unsigned long kpull , dump_interval , tx_bytes , tx_packets ;
66
66
size_t reserve_size ;
67
67
bool randomize , promiscuous , enforce , jumbo , dump_bpf , hwtimestamp , verbose ,
68
- ui ;
68
+ ui , nolock ;
69
69
enum pcap_ops_groups pcap ; enum dump_mode dump_mode ;
70
70
uid_t uid ; gid_t gid ; uint32_t link_type , magic ;
71
71
struct dnsctxt dns_ctxt ;
@@ -74,7 +74,7 @@ struct ctx {
74
74
static volatile sig_atomic_t sigint = 0 ;
75
75
static volatile bool next_dump = false;
76
76
77
- static const char * short_options = "d:i:o:rf:MNJt:S:k:n:b:HQmcZYsqXlvhF :GAP:Vu:g:T:DBUL:W:C:a:" ;
77
+ static const char * short_options = "d:i:o:rf:MNJt:S:k:n:b:HQmcZYsqXxlvhF :GAP:Vu:g:T:DBUL:W:C:a:" ;
78
78
static const struct option long_options [] = {
79
79
{"dev" , required_argument , NULL , 'd' },
80
80
{"in" , required_argument , NULL , 'i' },
@@ -89,6 +89,7 @@ static const struct option long_options[] = {
89
89
{"prefix" , required_argument , NULL , 'P' },
90
90
{"user" , required_argument , NULL , 'u' },
91
91
{"group" , required_argument , NULL , 'g' },
92
+ {"nomemlock" , no_argument , NULL , 'x' },
92
93
{"magic" , required_argument , NULL , 'T' },
93
94
{"rand" , no_argument , NULL , 'r' },
94
95
// {"rfraw", no_argument, NULL, 'R'},
@@ -1156,21 +1157,21 @@ static void init_ctx(struct ctx *ctx)
1156
1157
ctx -> uid = getgid ();
1157
1158
1158
1159
ctx -> cpu = -1 ;
1159
- ctx -> packet_type = -1 ;
1160
- ctx -> local_prefix = -1 ;
1160
+ ctx -> packet_type = -1 ;
1161
+ ctx -> local_prefix = -1 ;
1161
1162
1162
1163
ctx -> magic = ORIGINAL_TCPDUMP_MAGIC ;
1163
- ctx -> print_mode = PRINT_NONE ;
1164
+ ctx -> print_mode = PRINT_NONE ;
1164
1165
ctx -> pcap = PCAP_OPS_SG ;
1165
1166
1166
1167
ctx -> dump_mode = DUMP_INTERVAL_TIME ;
1167
1168
ctx -> dump_interval = 60 ;
1168
1169
1169
1170
ctx -> promiscuous = true;
1170
1171
ctx -> randomize = false;
1171
- ctx -> hwtimestamp = true ;
1172
- ctx -> ui = false ;
1173
-
1172
+ ctx -> nolock = false ;
1173
+ ctx -> hwtimestamp = true ;
1174
+ ctx -> ui = false;
1174
1175
}
1175
1176
1176
1177
static void destroy_ctx (struct ctx * ctx )
@@ -1214,6 +1215,7 @@ static void __noreturn help(void)
1214
1215
" -b|--bind-cpu <cpu> Bind to specific CPU\n"
1215
1216
" -u|--user <userid> Drop privileges and change to userid\n"
1216
1217
" -g|--group <groupid> Drop privileges and change to groupid\n"
1218
+ " -x|--nolock Don't lock memory\n"
1217
1219
" -H|--prio-high Make this high priority process\n"
1218
1220
" -Q|--notouch-irq Do not touch IRQ CPU affinity of NIC\n"
1219
1221
" -s|--silent Do not print captured packets\n"
@@ -1324,6 +1326,9 @@ int main(int argc, char **argv)
1324
1326
ctx .gid = strtoul (optarg , NULL , 0 );
1325
1327
ctx .enforce = true;
1326
1328
break ;
1329
+ case 'x' :
1330
+ ctx .nolock = true;
1331
+ break ;
1327
1332
case 't' :
1328
1333
if (!strncmp (optarg , "host" , strlen ("host" )))
1329
1334
ctx .packet_type = PACKET_HOST ;
@@ -1581,7 +1586,7 @@ int main(int argc, char **argv)
1581
1586
init_geoip (ctx .geoip_loc , ctx .geoip_asn );
1582
1587
if (setsockmem )
1583
1588
set_system_socket_memory (vals , array_size (vals ));
1584
- if (!ctx .enforce )
1589
+ if (!ctx .enforce && ! ctx . nolock )
1585
1590
xlockme ();
1586
1591
1587
1592
if (ctx .verbose )
@@ -1595,7 +1600,7 @@ int main(int argc, char **argv)
1595
1600
if (ctx .ui )
1596
1601
pktvisor_ui_shutdown ();
1597
1602
1598
- if (!ctx .enforce )
1603
+ if (!ctx .enforce && ! ctx . nolock )
1599
1604
xunlockme ();
1600
1605
if (setsockmem )
1601
1606
reset_system_socket_memory (vals , array_size (vals ));
0 commit comments