diff --git a/src/runmodes.c b/src/runmodes.c index d2214baa3b..1418fe0d4c 100644 --- a/src/runmodes.c +++ b/src/runmodes.c @@ -3579,7 +3579,7 @@ int RunModeIdsPfringAutoFp(DetectEngineCtx *de_ctx, char *iface) { int pfring_threads = PfringConfGetThreads(); /* create the threads */ for (thread = 0; thread < pfring_threads; thread++) { - snprintf(tname, sizeof(tname),"RecvPfring%"PRIu16, thread+1); + snprintf(tname, sizeof(tname),"RxPfring%"PRIu16, thread+1); char *thread_name = SCStrdup(tname); ThreadVars *tv_receive = TmThreadCreatePacketHandler(thread_name,"packetpool","packetpool",queues,"flow","varslot"); diff --git a/src/source-pfring.c b/src/source-pfring.c index bd9f2a5d94..016cfa8d5c 100644 --- a/src/source-pfring.c +++ b/src/source-pfring.c @@ -163,7 +163,7 @@ void PfringLoadConfig(void) { } else { if (threadsstr != NULL) { g_pfring_threads = (uint8_t)atoi(threadsstr); - SCLogInfo("Going to use %" PRId32 " PF_RING receive threads", + SCLogInfo("Going to use %" PRId32 " PF_RING receive thread(s)", g_pfring_threads); } } @@ -212,7 +212,6 @@ TmEcode ReceivePfring(ThreadVars *tv, Packet *p, void *data, PacketQueue *pq, Pa PfringThreadVars *ptv = (PfringThreadVars *)data; struct pfring_pkthdr hdr; - int r; if (suricata_ctl_flags & SURICATA_STOP || suricata_ctl_flags & SURICATA_KILL) { @@ -220,7 +219,7 @@ TmEcode ReceivePfring(ThreadVars *tv, Packet *p, void *data, PacketQueue *pq, Pa } /* Depending on what compile time options are used for pfring we either return 0 or -1 on error and always 1 for success */ - r = pfring_recv(ptv->pd, (char *)p->pkt , (u_int)default_packet_size, &hdr, LIBPFRING_WAIT_FOR_INCOMING); + int r = pfring_recv(ptv->pd, (char *)p->pkt , (u_int)(default_packet_size - 1), &hdr, LIBPFRING_WAIT_FOR_INCOMING); if (r == 1) { //printf("RecievePfring src %" PRIu32 " sport %" PRIu32 " dst %" PRIu32 " dstport %" PRIu32 "\n", // hdr.parsed_pkt.ipv4_src,hdr.parsed_pkt.l4_src_port, hdr.parsed_pkt.ipv4_dst,hdr.parsed_pkt.l4_dst_port); @@ -249,7 +248,7 @@ TmEcode ReceivePfring(ThreadVars *tv, Packet *p, void *data, PacketQueue *pq, Pa */ TmEcode ReceivePfringThreadInit(ThreadVars *tv, void *initdata, void **data) { int rc; - u_int32_t version; + u_int32_t version = 0; char *tmpclusterid; char *tmpctype; @@ -275,7 +274,8 @@ TmEcode ReceivePfringThreadInit(ThreadVars *tv, void *initdata, void **data) { ptv->pd = pfring_open(ptv->interface, LIBPFRING_PROMISC, (uint32_t)default_packet_size, LIBPFRING_REENTRANT); if (ptv->pd == NULL) { - SCLogError(SC_ERR_PF_RING_OPEN,"pfring_open error"); + SCLogError(SC_ERR_PF_RING_OPEN,"opening %s failed: pfring_open error", + ptv->interface); return TM_ECODE_FAILED; } else { pfring_set_application_name(ptv->pd, PROG_NAME); diff --git a/src/suricata.c b/src/suricata.c index b7487b0daa..12a6f23214 100644 --- a/src/suricata.c +++ b/src/suricata.c @@ -361,7 +361,8 @@ void usage(const char *progname) printf("\t--pcap-buffer-size : size of the pcap buffer value from 0 - %i\n",INT_MAX); #endif /* HAVE_SET_PCAP_BUFF */ #ifdef HAVE_PFRING - printf("\t--pfring-int : run in pfring mode\n"); + printf("\t--pfring : run in pfring mode, use interface from suricata.yaml\n"); + printf("\t--pfring-int : run in pfring mode, use interface \n"); printf("\t--pfring-cluster-id : pfring cluster id \n"); printf("\t--pfring-cluster-type : pfring cluster type for PF_RING 4.1.2 and later cluster_round_robin|cluster_flow\n"); #endif /* HAVE_PFRING */ @@ -459,9 +460,10 @@ int main(int argc, char **argv) struct option long_opts[] = { {"dump-config", 0, &dump_config, 1}, - {"pfring-int", required_argument, 0, 0}, - {"pfring-cluster-id", required_argument, 0, 0}, - {"pfring-cluster-type", required_argument, 0, 0}, + {"pfring", optional_argument, 0, 0}, + {"pfring-int", required_argument, 0, 0}, + {"pfring-cluster-id", required_argument, 0, 0}, + {"pfring-cluster-type", required_argument, 0, 0}, {"pcap-buffer-size", required_argument, 0, 0}, {"unittest-filter", required_argument, 0, 'U'}, {"list-unittests", 0, &list_unittests, 1}, @@ -490,15 +492,19 @@ int main(int argc, char **argv) while ((opt = getopt_long(argc, argv, short_opts, long_opts, &option_index)) != -1) { switch (opt) { case 0: - if(strcmp((long_opts[option_index]).name , "pfring-int") == 0){ + if (strcmp((long_opts[option_index]).name , "pfring") == 0 || + strcmp((long_opts[option_index]).name , "pfring-int") == 0) { #ifdef HAVE_PFRING run_mode = MODE_PFRING; - if (ConfSet("pfring.interface", optarg, 0) != 1) { - fprintf(stderr, "ERROR: Failed to set pfring interface.\n"); - exit(EXIT_FAILURE); + if (optarg != NULL) { + if (ConfSet("pfring.interface", optarg, 0) != 1) { + fprintf(stderr, "ERROR: Failed to set pfring interface.\n"); + exit(EXIT_FAILURE); + } } #else - SCLogError(SC_ERR_NO_PF_RING,"PF_RING not enabled. Make sure to pass --enable-pfring to configure when building."); + SCLogError(SC_ERR_NO_PF_RING,"PF_RING not enabled. Make sure " + "to pass --enable-pfring to configure when building."); exit(EXIT_FAILURE); #endif /* HAVE_PFRING */ } @@ -509,7 +515,8 @@ int main(int argc, char **argv) exit(EXIT_FAILURE); } #else - SCLogError(SC_ERR_NO_PF_RING,"PF_RING not enabled. Make sure to pass --enable-pfring to configure when building."); + SCLogError(SC_ERR_NO_PF_RING,"PF_RING not enabled. Make sure " + "to pass --enable-pfring to configure when building."); exit(EXIT_FAILURE); #endif /* HAVE_PFRING */ } @@ -520,7 +527,8 @@ int main(int argc, char **argv) exit(EXIT_FAILURE); } #else - SCLogError(SC_ERR_NO_PF_RING,"PF_RING not enabled. Make sure to pass --enable-pfring to configure when building."); + SCLogError(SC_ERR_NO_PF_RING,"PF_RING not enabled. Make sure " + "to pass --enable-pfring to configure when building."); exit(EXIT_FAILURE); #endif /* HAVE_PFRING */ }