From 970e2c5aeb952447aab1c991082112f5ceb1eabb Mon Sep 17 00:00:00 2001 From: Alfredo Cardigliano Date: Tue, 3 Sep 2024 17:59:29 +0200 Subject: [PATCH] Add -f to ftflow. Update FT libs. --- userland/examples_ft/ftflow.c | 17 +++++++++++++++-- userland/lib/libs/libpfring_ft_x86_64.a | Bin 142564 -> 142564 bytes userland/lib/libs/libpfring_ft_x86_64.so | Bin 126184 -> 126184 bytes .../lib/libs/libpfring_ft_x86_64_core-avx2.a | Bin 143060 -> 143060 bytes .../libs/libpfring_ft_x86_64_core-avx2_dl.a | Bin 146326 -> 146326 bytes .../lib/libs/libpfring_ft_x86_64_corei7-avx.a | Bin 141836 -> 141836 bytes .../libs/libpfring_ft_x86_64_corei7-avx_dl.a | Bin 145102 -> 145102 bytes .../lib/libs/libpfring_ft_x86_64_corei7.a | Bin 141892 -> 141892 bytes .../lib/libs/libpfring_ft_x86_64_corei7_dl.a | Bin 145158 -> 145158 bytes userland/lib/libs/libpfring_ft_x86_64_dl.a | Bin 145830 -> 145830 bytes userland/lib/libs/libpfring_ft_x86_64_dl.so | Bin 117008 -> 117008 bytes userland/lib/pfring_ft.h | 2 +- 12 files changed, 16 insertions(+), 3 deletions(-) diff --git a/userland/examples_ft/ftflow.c b/userland/examples_ft/ftflow.c index 9e20fa2eb..26a4cd477 100644 --- a/userland/examples_ft/ftflow.c +++ b/userland/examples_ft/ftflow.c @@ -387,6 +387,7 @@ void print_help(void) { printf("-h Print this help\n"); printf("-i Device name\n"); printf("-7 Enable L7 protocol detection (nDPI)\n"); + printf("-f Capture filter (BPF)\n"); printf("-F Load filtering/shunting rules from file\n"); printf("-p Load nDPI custom protocols from file\n"); printf("-c Load nDPI categories by host from file\n"); @@ -419,8 +420,9 @@ int main(int argc, char* argv[]) { packet_direction direction = rx_and_tx_direction; pthread_t time_thread; u_int8_t ignore_hw_hash = 0; + char *filter = NULL; - while ((c = getopt(argc,argv,"c:dEg:hHi:p:qvF:s:S:tV7")) != '?') { + while ((c = getopt(argc,argv,"c:dEf:g:hHi:p:qvF:s:S:tV7")) != '?') { if ((c == 255) || (c == -1)) break; switch(c) { @@ -437,6 +439,9 @@ int main(int argc, char* argv[]) { enable_l7_extra = 1; break; #endif + case 'f': + filter = strdup(optarg); + break; case 'g': bind_core = atoi(optarg); break; @@ -556,7 +561,7 @@ int main(int argc, char* argv[]) { promisc = 1; - if (promisc) flags |= PF_RING_PROMISC; + if (promisc) flags |= PF_RING_PROMISC; if (!time_pulse) flags |= PF_RING_TIMESTAMP; /* needed for flow processing */ pd = pfring_open(device, snaplen, flags); @@ -584,6 +589,14 @@ int main(int argc, char* argv[]) { if ((rc = pfring_set_socket_mode(pd, recv_only_mode)) != 0) fprintf(stderr, "pfring_set_socket_mode returned [rc=%d]\n", rc); + if (filter != NULL) { + rc = pfring_set_bpf_filter(pd, filter); + if (rc != 0) + fprintf(stderr, "pfring_set_bpf_filter(%s) returned %d\n", filter, rc); + else if (!quiet) + printf("Successfully set BPF filter '%s'\n", filter); + } + signal(SIGINT, sigproc); signal(SIGTERM, sigproc); diff --git a/userland/lib/libs/libpfring_ft_x86_64.a b/userland/lib/libs/libpfring_ft_x86_64.a index 13338f27749044e3eb570c63a98bbb0f71489bdd..0c53c4037c45849dc4635c6980c35ecb3b3998fa 100644 GIT binary patch delta 33 rcmV++0N(%P*$Cv>2(U$B0l1S!Vxa-Jv*=<0DgiTt>WsJQi~;(e6Lk2(U$B0k4xrVxa-Av*=<0DgiQs>WsJQi~;(e5(5x9 diff --git a/userland/lib/libs/libpfring_ft_x86_64.so b/userland/lib/libs/libpfring_ft_x86_64.so index effa63577146ba8541bf24975d02acaf5e186d21..09a09d99aba56cd10c3379f8f6ba8e3aeafcbdeb 100755 GIT binary patch delta 56 zcmV-80LTC6*$3#^2e8-z6ip?Y(U*~?U)Xx~c($~81TQDhAG7QN(UbwWlfIXs0l2eZ On3%W$Gq?Fr0q>hXQ5@j_ delta 56 zcmV-80LTC6*$3#^2e8-z6dsDIrnp4xBLNeftCN9@Ham9E%(LtQ(UbwNlfIXs0k5-Q On3%W$GPn6q0q>h4_8eFM diff --git a/userland/lib/libs/libpfring_ft_x86_64_core-avx2.a b/userland/lib/libs/libpfring_ft_x86_64_core-avx2.a index 58c806418eda887ed9a7bceb8ac1fe50efa8530d..b9b3a87de474a4ee997dd0a67148ed32f867b5bf 100644 GIT binary patch delta 33 pcmca|m*dJ^jt!+rj5{WmC9P!Ku~{Mcr6!|sGgt3+u3pAd3jq#54$uGq delta 33 pcmca|m*dJ^jt!+rjO!LcvmRxwGyyY%%$c{$nE}e73LTvmRxwGyyV$%$c{$nE}e73X%`k diff --git a/userland/lib/libs/libpfring_ft_x86_64_corei7-avx.a b/userland/lib/libs/libpfring_ft_x86_64_corei7-avx.a index 0a352ae69066309b2d4995336cf6ab9997e9e9eb..14a54b9921a242567973347792a8393b9ce6dccb 100644 GIT binary patch delta 33 pcmeCV!qIbuV?%2aMNh=xGZ#GDNsmW;6EY-VRs+aN8902{@4vqi- diff --git a/userland/lib/libs/libpfring_ft_x86_64_corei7-avx_dl.a b/userland/lib/libs/libpfring_ft_x86_64_corei7-avx_dl.a index ea80cd15c29a11cedf20273630daf4d7498f2412..7fdf30800c10df671e9257fda7836fbc4dd13d04 100644 GIT binary patch delta 33 rcmV++0N(%3?Fi282(Wr&0l1TUWU>Lcvo2+=GyyY%+?luBnE~>g9Ayx> delta 33 rcmV++0N(%3?Fi282(Wr&0k4yLWU>LTvo2+=GyyV$+?luBnE~>g8uJjQ diff --git a/userland/lib/libs/libpfring_ft_x86_64_corei7.a b/userland/lib/libs/libpfring_ft_x86_64_corei7.a index 3023e1ea4d4e1b6a965cbd976e91a1bfa688e013..deabbeda9c867c1ecba8b285211a3d57d631279a 100644 GIT binary patch delta 33 rcmV++0N($^)Ck1X2(VRR0l1S^Vxa-Jv-o21DFHKs>WsJQi~(Am872^a delta 33 rcmV++0N($^)Ck1X2(VRR0k4x*Vxa-Av-o21DFHHr>WsJQi~(Am7qk#; diff --git a/userland/lib/libs/libpfring_ft_x86_64_corei7_dl.a b/userland/lib/libs/libpfring_ft_x86_64_corei7_dl.a index de66ce5ca64dabd45410ef9b2d79cc8f69a2e981..7b598047ad79303c6902f307605f0e285bc03a4f 100644 GIT binary patch delta 33 rcmV++0N($G?g)nN2(U_I0l1S(WU>Lcv;JhQGyyY%teLm0nE_gz3Y`z5 delta 33 rcmV++0N($G?g)nN2(U_I0k4xwWU>LTv;JhQGyyV$teLm0nE_gz2`dkf diff --git a/userland/lib/libs/libpfring_ft_x86_64_dl.a b/userland/lib/libs/libpfring_ft_x86_64_dl.a index 40831e5b212eff8d500f1e54f21466ea0f0727b0..e99dadfb68e203eaa70400e172e892ab2ed8a102 100644 GIT binary patch delta 33 rcmV++0N($m^9ZK%2(UV20l1SpWU>Lcv+iWQGyyY%teLm0nF0Er5#SJS delta 33 rcmV++0N($m^9ZK%2(UV20k4xgWU>LTv+iWQGyyV$teLm0nF0Er5N;4$ diff --git a/userland/lib/libs/libpfring_ft_x86_64_dl.so b/userland/lib/libs/libpfring_ft_x86_64_dl.so index 96b7c0ca8944de9a0884705608d50407a60b00d7..77d0a14f531dee5c4d415ae50bcc02c857807475 100755 GIT binary patch delta 56 zcmV-80LTB3k_V8I2e8-z6bac9=Kj3@;Dvm(>GDvoHzX8{3A5}1^nwAnli`K30l2f2 OhBL1LGq=b!0Z5Z5og1G3 delta 56 zcmV-80LTB3k_V8I2e8-z6d@Vz*W)*;SbK7G5(Q!XonADWTeIu}^nwAeli`K30k5-^ OhBL1LGPlSz0Z5b8X&IUT diff --git a/userland/lib/pfring_ft.h b/userland/lib/pfring_ft.h index 5389768ae..96501ba87 100644 --- a/userland/lib/pfring_ft.h +++ b/userland/lib/pfring_ft.h @@ -24,7 +24,7 @@ extern "C" { #endif -#define FT_API_VERSION 77 +#define FT_API_VERSION 83 typedef void pfring_ft_table; typedef void pfring_ft_list;