[-]
[+]
|
Changed |
ixgbe.changes
|
|
[-]
[+]
|
Changed |
libpfring.changes
^
|
|
[-]
[+]
|
Changed |
pf_ring-kmp.changes
^
|
|
[-]
[+]
|
Changed |
pf_ring-ixgbe-kmp.spec
^
|
|
[-]
[+]
|
Changed |
pf_ring-kmp.spec
^
|
|
[-]
[+]
|
Changed |
pf_ring.spec
^
|
|
[-]
[+]
|
Deleted |
pf_ring-4.7.1-makefile.patch
^
|
@@ -1,28 +0,0 @@
---- userland/lib/Makefile.in.orig 2011-07-24 13:59:43.673544590 +0200
-+++ userland/lib/Makefile.in 2011-07-24 14:01:45.743464767 +0200
-@@ -6,7 +6,7 @@
- #
- # Installation directory
- #
--INSTDIR = @INSTALL_PREFIX@
-+INSTDIR = ${DESTDIR}@INSTALL_PREFIX@
-
- #
- # Search directories
-@@ -77,12 +77,12 @@
- ar x @VIRTUAL_LIB@
-
- install: ${STATICLIB} ${DYNAMICLIB}
-- mkdir -p ${INSTDIR}/lib
-+ mkdir -p ${INSTDIR}/${LIB}
- mkdir -p ${INSTDIR}/include
-- cp ${STATICLIB} ${INSTDIR}/lib/
-- cp ${DYNAMICLIB} ${INSTDIR}/lib/
-+ cp ${STATICLIB} ${INSTDIR}/${LIB}/
-+ cp ${DYNAMICLIB} ${INSTDIR}/${LIB}/
- cp pfring.h ${INSTDIR}/include/
-- ldconfig
-+ #ldconfig
-
- clean:
- @rm -f ${TARGETS} *.o *~
|
[-]
[+]
|
Added |
pf_ring-4.7.2-makefile.patch
^
|
@@ -0,0 +1,28 @@
+--- userland/lib/Makefile.in.orig 2011-07-24 13:59:43.673544590 +0200
++++ userland/lib/Makefile.in 2011-07-24 14:01:45.743464767 +0200
+@@ -6,7 +6,7 @@
+ #
+ # Installation directory
+ #
+-INSTDIR = @INSTALL_PREFIX@
++INSTDIR = ${DESTDIR}@INSTALL_PREFIX@
+
+ #
+ # Search directories
+@@ -77,12 +77,12 @@
+ ar x @VIRTUAL_LIB@
+
+ install: ${STATICLIB} ${DYNAMICLIB}
+- mkdir -p ${INSTDIR}/lib
++ mkdir -p ${INSTDIR}/${LIB}
+ mkdir -p ${INSTDIR}/include
+- cp ${STATICLIB} ${INSTDIR}/lib/
+- cp ${DYNAMICLIB} ${INSTDIR}/lib/
++ cp ${STATICLIB} ${INSTDIR}/${LIB}/
++ cp ${DYNAMICLIB} ${INSTDIR}/${LIB}/
+ cp pfring.h ${INSTDIR}/include/
+- ldconfig
++ #ldconfig
+
+ clean:
+ @rm -f ${TARGETS} *.o *~
|
[-]
[+]
|
Deleted |
pf_ring-makefile.patch
^
|
@@ -1,27 +0,0 @@
---- userland/lib/Makefile.orig 2010-11-03 17:05:32.288634758 +0100
-+++ userland/lib/Makefile 2010-11-03 17:09:19.487790799 +0100
-@@ -8,7 +8,7 @@
- #
- # Installation directory
- #
--INSTDIR = ${DESTDIR}/usr/local
-+INSTDIR = ${DESTDIR}${PREFIX}
-
- #
- # Search directories
-@@ -63,10 +63,12 @@
- ${CC} ${LDFLAGS} ${OBJS} ${SYSLIBS} -o $@
-
- install: ${STATICLIB} ${DYNAMICLIB}
-- cp ${STATICLIB} ${INSTDIR}/lib/
-- cp ${DYNAMICLIB} ${INSTDIR}/lib/
-+ mkdir -p ${INSTDIR}/${LIB}
-+ mkdir -p ${INSTDIR}/include
-+ cp ${STATICLIB} ${INSTDIR}/${LIB}
-+ cp ${DYNAMICLIB} ${INSTDIR}/${LIB}
- cp pfring_e1000e_dna.h pfring.h ${INSTDIR}/include/
-- ldconfig
-+ #ldconfig
-
- clean:
- @rm -f ${TARGETS} *.o *~
|
[-]
[+]
|
Deleted |
PF_RING-4.7.1.tar.bz2/userland/examples/Makefile
^
|
@@ -1,146 +0,0 @@
-#
-# Makefile for the PF_RING API example programs
-#
-# Try to make both programs written on top of the
-# PF_RING library and programs originally written
-# on top of PCAP library and linked now to use
-# the version with PF_RING aware functionalities.
-#
-
-
-
-#
-# PF_RING
-#
-PFRINGDIR = ../lib
-LIBPFRING = ${PFRINGDIR}/libpfring.a
-
-#
-# DNA Support
-DNA_DEFINE = #-DENABLE_DNA_SUPPORT
-
-#
-# PF_RING aware libpcap
-#
-O_FLAG = #-O2
-EXTRA_LIBS = #-ldag
-PCAPDIR = ../libpcap-1.1.1-ring
-LIBPCAP = ${PCAPDIR}/libpcap.a ${EXTRA_LIBS}
-
-#
-# Search directories
-#
-PFRING_KERNEL=../../kernel
-INCLUDE = -I${PFRING_KERNEL} -I${PFRING_KERNEL}/plugins -I${PFRINGDIR} -I${PCAPDIR}
-
-#
-# C compiler and flags
-#
-#
-# CROSS_COMPILE=arm-mv5sft-linux-gnueabi-
-#
-CC = ${CROSS_COMPILE}gcc #--platform=native
-CFLAGS = -g ${O_FLAG} -Wall ${INCLUDE} ${DNA_DEFINE} #-O
-# LDFLAGS =
-
-#
-# User and System libraries
-#
-LIBS = ${LIBPFRING} -lpthread #-ldag
-
-# How to make an object file
-%.o: %.c
-# @echo "=*= making object $@ =*="
- ${CC} ${CFLAGS} -c $< -o $@
-
-#
-# Main targets
-#
-PFPROGS = ringc rings ringm pcaps pfcount pfcount_multichannel pftwin ptwin preflect pfbounce pfmap \
- forwarder alldevs dummy_plugin_pfcount pcap2nspcap pfcount_dummy_plugin pffilter_test \
- pfcount_bundle pfcount_82599 vdevice_simulator pfsystest pfsend
-
-PCAPPROGS = pcount pwrite
-TARGETS = ${PFPROGS} ${PCAPPROGS}
-
-RCOBJS = ringc.o interval.o
-RSOBJS = rings.o interval.o
-RMOBJS = ringm.o interval.o
-RPOBJS = pcaps.o interval.o
-
-all: ${TARGETS}
-
-ringc: ${RCOBJS} ${LIBPFRING}
- ${CC} ${RCOBJS} ${LIBS} -o $@
-
-rings: ${RSOBJS} ${LIBPFRING}
- ${CC} ${RSOBJS} ${LIBS} -o $@
-
-ringm: ${RMOBJS} ${LIBPFRING}
- ${CC} ${RMOBJS} ${LIBS} -o $@
-
-pcaps: ${RPOBJS}
- ${CC} ${RPOBJS} ${LIBPCAP} ${LIBS} -o $@
-
-pfcount: pfcount.o ${LIBPFRING}
- ${CC} pfcount.o ${LIBS} -o $@
-
-dummy_plugin_pfcount: dummy_plugin_pfcount.o ${LIBPFRING}
- ${CC} dummy_plugin_pfcount.o ${LIBS} -o $@
-
-pffilter_test: pffilter_test.o ${LIBPFRING}
- ${CC} pffilter_test.o ${LIBS} -o $@
-
-pcap2nspcap: pcap2nspcap.o ${LIBPFRING}
- ${CC} pcap2nspcap.o ${LIBPCAP} ${LIBS} -o $@
-
-pfcount_multichannel: pfcount_multichannel.o ${LIBPFRING}
- ${CC} pfcount_multichannel.o ${LIBS} -o $@
-
-pfcount_82599: pfcount_82599.o ${LIBPFRING}
- ${CC} pfcount_82599.o ${LIBS} -o $@
-
-pfcount_bundle: pfcount_bundle.o ${LIBPFRING}
- ${CC} pfcount_bundle.o ${LIBS} -o $@
-
-pfcount_dummy_plugin: pfcount_dummy_plugin.o ${LIBPFRING}
- ${CC} pfcount_dummy_plugin.o ${LIBS} -o $@
-
-preflect: preflect.o ${LIBPFRING}
- ${CC} preflect.o ${LIBPCAP} ${LIBS} -o $@
-
-pfbounce: pfbounce.o ${LIBPFRING}
- ${CC} pfbounce.o ${LIBPCAP} ${LIBS} -o $@
-
-pfsend: pfsend.o ${LIBPFRING}
- ${CC} pfsend.o ${LIBPCAP} ${LIBS} -o $@
-
-pftwin: pftwin.o ${LIBPFRING}
- ${CC} pftwin.o ${LIBS} -o $@
-
-ptwin: ptwin.o ${LIBPFRING}
- ${CC} ptwin.o ${LIBPCAP} ${LIBS} -o $@
-
-pfmap: pfmap.o ${LIBPFRING}
- ${CC} pfmap.o ${LIBS} -o $@
-
-forwarder: forwarder.o ${LIBPFRING}
- ${CC} forwarder.o ${LIBS} -o $@
-
-pcount: pcount.o ${LIBPCAP} ${LIBPFRING}
- ${CC} pcount.o ${LIBPCAP} ${LIBS} -o $@
-
-alldevs: alldevs.o ${LIBPCAP} ${LIBPFRING}
- ${CC} alldevs.o ${LIBPCAP} ${LIBS} -o $@
-
-pwrite: pwrite.o ${LIBPCAP} ${LIBPFRING}
- ${CC} pwrite.o ${LIBPCAP} ${LIBS} -o $@
-
-vdevice_simulator: vdevice_simulator.o ${LIBPCAP} ${LIBPFRING}
- ${CC} vdevice_simulator.o ${LIBPCAP} ${LIBS} -o $@
-
-pfsystest: pfsystest.o ${LIBPFRING}
- ${CC} pfsystest.o ${LIBS} -o $@
-
-clean:
- @rm -f ${TARGETS} *.o *~
|
[-]
[+]
|
Deleted |
PF_RING-4.7.1.tar.bz2/userland/examples/pcaps.c
^
|
@@ -1,310 +0,0 @@
-/*
- * -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- * pcaps.c - single-process, multi-handle packet sniffer
- * for PCAP aware interfaces (see rings.c)
- *
- * 2Q 2008 Rocco Carbone <rocco /at/ ntop /dot/ org>
- *
- * -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- *
- * It simply opens several pcap-handles (default 1) and uses
- * them in round-robin to count packets received
- * from the interface, until the maximum # of packets
- * has been reached (default 100000).
- *
- * At given intervals (a percentage of packets received
- * which defaults to 10) it also prints out statistics
- * information about the value of pkts/sec calculated
- *
- * rocco@ring.netikos.com 455> sudo ./ringp
- * ringp: requested to open #1 pcap-handle
- * ringp: listening from eth0 using libpcap version 0.9.8
- *
- * ringp: starting to capture #100000 pckts using #1 pcap-handle...
- * ringp: pkts rcvd #10000 of #100000 (10.00%)
- * ringp: pkts rcvd #20000 of #100000 (20.00%) [10683.76 pkts/sec => +10000 pkts in 936 msecs]
- * ringp: pkts rcvd #30000 of #100000 (30.00%) [10548.52 pkts/sec => +10000 pkts in 948 msecs]
- * ringp: pkts rcvd #40000 of #100000 (40.00%) [10493.18 pkts/sec => +10000 pkts in 953 msecs]
- * ringp: pkts rcvd #50000 of #100000 (50.00%) [10040.16 pkts/sec => +10000 pkts in 996 msecs]
- * ringp: pkts rcvd #60000 of #100000 (60.00%) [10537.41 pkts/sec => +10000 pkts in 949 msecs]
- * ringp: pkts rcvd #70000 of #100000 (70.00%) [10526.32 pkts/sec => +10000 pkts in 950 msecs]
- * ringp: pkts rcvd #80000 of #100000 (80.00%) [10638.30 pkts/sec => +10000 pkts in 940 msecs]
- * ringp: pkts rcvd #90000 of #100000 (90.00%) [10526.32 pkts/sec => +10000 pkts in 950 msecs]
- * ringp: pkts rcvd #100000 of #100000 (100%) [10537.41 pkts/sec => +10000 pkts in 949 msecs]
- *
- * Time:
- * =====
- * Started: Thu Jun 5 19:25:53 2008
- * Finished: Thu Jun 5 19:26:03 2008
- * Elapsed Time: 9.550 secs
- *
- * Great Totals:
- * =============
- * pkts rcvd #100000 pckts of #100000 => 10471.20 pkts/sec
- *
- * -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- */
-
-
-/* Package info */
-static char __author__ [] = "R. Carbone <rocco /at/ ntop /dot/ org>";
-static char __version__ [] = "version 0.0.1";
-static char __released__ [] = "Jun 2008";
-static char __copyright__ [] = "Copyright (c) 2008";
-
-
-/* Operating System header file(s) */
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-#include <signal.h>
-#include <getopt.h>
-
-/* Packet Capture Library */
-#include <pcap.h>
-
-
-#define DEFAULT_INTERFACE "eth0" /* default interface */
-#define DEFAULT_SNAPSHOT 1500 /* default snapshot length */
-#define DEFAULT_HANDLES 1 /* default # of pcap-handle(s) to use */
-#define DEFAULT_PACKETS 100000 /* default # of packets to capture per pcap-handle */
-#define DEFAULT_HB 10 /* default heartbeat */
-
-
-/* Public funtions in file time.c */
-time_t delta_time_in_milliseconds (struct timeval * t2, struct timeval * t1);
-void print_time_in_secs (struct timeval * t, char * label);
-char * elapsed_time (struct timeval * start, struct timeval * stop);
-char * percentage (unsigned long partial, unsigned long total);
-void showbar (unsigned long partial);
-
-
-/* What should be done on interrupt */
-static void on_ctrl_c (int sig)
-{
- printf ("\nCaught signal %d: terminating...\n", sig);
- exit (0);
-}
-
-
-/* Display version information */
-static void version (char * progname)
-{
- printf ("This is %s %s of %s\n", progname, __version__, __released__);
- printf ("%s %s\n", __copyright__, __author__);
-
- exit (0);
-}
-
-
-/* How to use this program */
-static void usage (char * progname)
-{
- printf ("Usage: %s [options]\n", progname);
-
- printf (" -h show usage and exit\n");
- printf (" -v show version and exit\n");
-
- printf (" -i interface use 'interface' for packet capture. default '%s'\n", DEFAULT_INTERFACE);
- printf (" -s len snapshot length. default %d\n", DEFAULT_SNAPSHOT);
-
- printf (" -n count # of pcap-handle(s) to open. default %d\n", DEFAULT_HANDLES);
- printf (" -c count # of packets to capture per pcap-handle. default %d - 0 means unlimited\n", DEFAULT_PACKETS);
-
- printf (" -b count heartbeat in seconds to show intermediate results. default %d\n", DEFAULT_HB);
-}
-
-
-/*
- * 1. Open 'p' pcap-handle(s)
- * 2. Capture 'n' packets per pcap-handle using a round-robin algorithm
- * 3. Print global statistics information
- */
-int main (int argc, char * argv [])
-{
- int option;
-
- char * interface = DEFAULT_INTERFACE; /* interface name */
- int promiscuous = 1;
- int snapshot = DEFAULT_SNAPSHOT;
-
- /* How many pcap-handles */
- int handles = DEFAULT_HANDLES;
- pcap_t ** table = NULL;
- int p;
- char ebuf [PCAP_ERRBUF_SIZE];
- const unsigned char * packet;
- struct pcap_pkthdr header;
-
- /* How many packets */
- unsigned long maxcount = DEFAULT_PACKETS;
- unsigned long partial = 0;
- unsigned long errors = 0;
-
- int hb = -1; /* heartbeat */
- int quiet = 0;
-
- struct timeval started;
- struct timeval stopped;
- double delta;
-
- /* Notice the program name */
- char * progname = strrchr (argv [0], '/');
- progname = ! progname ? * argv : progname + 1;
-
-#define OPTSTRING "hvi:s:n:c:b:q"
- while ((option = getopt (argc, argv, OPTSTRING)) != EOF)
- {
- switch (option)
- {
- default: return -1;
-
- case 'h': usage (progname); return 0;
- case 'v': version (progname); return 0;
-
- case 'i': interface = optarg; break;
- case 's': snapshot = atoi (optarg); break;
-
- case 'n': handles = atoi (optarg);
- if (! handles)
- handles = 1;
- break;
-
- case 'c': maxcount = atoi (optarg); break;
-
- case 'b': hb = atoi (optarg); break;
- case 'q': quiet = 1; break;
- }
- }
-
- /* =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- */
-
- /* Set unbuffered stdout */
- setvbuf (stdout, NULL, _IONBF, 0);
-
- if ((getuid () && geteuid ()) || setuid (0))
- {
- printf ("%s: sorry, you must be root in order to run this program\n", progname);
- return -1;
- }
-
- /* Find a suitable interface, if you don't have one */
- if (! interface && ! (interface = pcap_lookupdev (ebuf)))
- {
- printf ("%s: no suitable interface found, please specify one with -d\n", progname);
- return -1;
- }
-
- signal (SIGINT, on_ctrl_c);
-
- /* Announce */
- printf ("%s: requested to open #%d pcap-handle%s\n", progname, handles, handles > 1 ? "s" : "");
-
- /* Allocate enough memory to keep the pointers to the pcap-handle(s) */
- table = calloc ((handles + 1) * sizeof (pcap_t *), 1);
- for (p = 0; p < handles; p ++)
- table [p] = NULL;
- table [p] = NULL;
-
- /* Open the interface for packet capturing */
- for (p = 0; p < handles; p ++)
- if (! (table [p] = pcap_open_live (interface, snapshot, promiscuous, 1000, ebuf)))
- {
- printf ("%s: cannot open interface '%s' due to '%s'\n", progname, interface, ebuf);
- return -1;
- }
-
- printf ("%s: listening from %s using %s\n\n", progname, interface, pcap_lib_version ());
-
- /* =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- */
-
- if (hb == -1)
- hb = maxcount / DEFAULT_HB;
- if (! hb)
- hb = 1;
-
- printf ("%s: starting to capture #%lu pckts using #%d pcap-handle%s...\n", progname, maxcount, handles, handles > 1 ? "s" : "");
-
- gettimeofday (& started, NULL);
-
- p = 0;
- while (! maxcount || (partial + errors) < maxcount)
- {
- /* Please give me just a packet at once from the interface */
- if ((packet = pcap_next (table [p], & header)))
- {
- partial ++;
- if (! quiet)
- {
- if (! (partial % hb))
- {
- static unsigned long previous = 0;
- static struct timeval latest;
-
- struct timeval now;
-
- /* Show pkts/secs in the latest period */
- gettimeofday (& now, NULL);
- delta = delta_time_in_milliseconds (& now, & latest);
-
- printf ("%s: pkts rcvd #%lu of #%lu %s", progname, partial, maxcount, percentage (partial, maxcount));
- if (previous && delta)
- printf (" [%8.2f pkts/sec => +%lu pkts in %s]",
- (double) (partial - previous) * 1000 / delta,
- partial - previous, elapsed_time (& latest, & now));
- printf ("\n");
-
- previous = partial;
- latest = now;
- }
- else
- showbar (partial);
- }
- }
- else
- errors ++;
-
- /* Round-robin to choose the pcap-handle candidate for the packet capture */
- p = (p + 1) % handles;
- }
-
- /* Close the pcap-handle(s) */
- for (p = 0; p < handles; p ++)
- pcap_close (table [p]);
- free (table);
-
- gettimeofday (& stopped, NULL);
- delta = (double) delta_time_in_milliseconds (& stopped, & started);
-
- printf (" \n");
-
- printf ("Time:\n");
- printf ("=====\n");
- print_time_in_secs (& started, "Started: ");
- print_time_in_secs (& stopped, "Finished: ");
- printf ("Elapsed Time: %s\n", elapsed_time (& started, & stopped));
- printf ("\n");
-
- /* Print out test results */
- printf ("Great Totals:\n");
- printf ("=============\n");
- printf ("pkts rcvd #%lu pckts of #%lu => %7.2f pkts/sec\n", partial, maxcount, (double) partial * 1000 / delta);
-
- return 0;
-}
|
[-]
[+]
|
Deleted |
PF_RING-4.7.1.tar.bz2/userland/examples/pftwin.c
^
|
@@ -1,524 +0,0 @@
-/*
- *
- * (C) 2005-10 - Luca Deri <deri@ntop.org>
- *
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- *
- */
-
-#define _GNU_SOURCE
-#include <signal.h>
-#include <sched.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <string.h>
-#include <unistd.h>
-#include <sys/mman.h>
-#include <errno.h>
-#include <sys/poll.h>
-#include <netinet/in_systm.h>
-#include <netinet/in.h>
-#include <netinet/ip.h>
-#include <net/ethernet.h> /* the L2 protocols */
-#include <sys/time.h>
-#include <time.h>
-#include <sys/socket.h>
-#include <arpa/inet.h>
-
-#include "pfring.h"
-
-#define ALARM_SLEEP 1
-#define DEFAULT_SNAPLEN 128
-int verbose = 0;
-pfring_stat pfringStats;
-
-static struct timeval startTime;
-unsigned long long numPkts = 0, numBytes = 0;
-u_int8_t do_shutdown = 0;
-
-#define DEFAULT_DEVICE "eth0"
-
-pfring *pd, *a_pd, *b_pd;
-
-/* *************************************** */
-/*
- * The time difference in millisecond
- */
-double delta_time (struct timeval * now,
- struct timeval * before) {
- time_t delta_seconds;
- time_t delta_microseconds;
-
- /*
- * compute delta in second, 1/10's and 1/1000's second units
- */
- delta_seconds = now -> tv_sec - before -> tv_sec;
- delta_microseconds = now -> tv_usec - before -> tv_usec;
-
- if(delta_microseconds < 0) {
- /* manually carry a one from the seconds field */
- delta_microseconds += 1000000; /* 1e6 */
- -- delta_seconds;
- }
- return((double)(delta_seconds * 1000) + (double)delta_microseconds/1000);
-}
-
-/* ******************************** */
-
-void print_stats() {
- pfring_stat pfringStat;
- struct timeval endTime;
- double deltaMillisec;
- static u_int64_t lastPkts = 0;
- u_int64_t diff;
- static struct timeval lastTime;
-
- if(startTime.tv_sec == 0) {
- gettimeofday(&startTime, NULL);
- return;
- }
-
- gettimeofday(&endTime, NULL);
- deltaMillisec = delta_time(&endTime, &startTime);
-
- if(pfring_stats(pd, &pfringStat) >= 0) {
- double thpt = ((double)8*numBytes)/(deltaMillisec*1000);
-
- fprintf(stderr, "=========================\n"
- "Absolute Stats: [%u pkts rcvd][%u pkts dropped]\n"
- "Total Pkts=%u/Dropped=%.1f %%\n",
- (unsigned int)pfringStat.recv, (unsigned int)pfringStat.drop,
- (unsigned int)(pfringStat.recv+pfringStat.drop),
- pfringStat.recv == 0 ? 0 :
- (double)(pfringStat.drop*100)/(double)(pfringStat.recv+pfringStat.drop));
- fprintf(stderr, "%llu pkts - %llu bytes", numPkts, numBytes);
- fprintf(stderr, " [%.1f pkt/sec - %.2f Mbit/sec]\n",
- (double)(numPkts*1000)/deltaMillisec, thpt);
-
- if(lastTime.tv_sec > 0) {
- deltaMillisec = delta_time(&endTime, &lastTime);
- diff = pfringStat.recv-lastPkts;
- fprintf(stderr, "=========================\n"
- "Actual Stats: %llu pkts [%.1f ms][%.1f pkt/sec]\n",
- (long long unsigned int)diff, deltaMillisec,
- ((double)diff/(double)(deltaMillisec/1000)));
- }
-
- lastPkts = pfringStat.recv;
- }
-
- lastTime.tv_sec = endTime.tv_sec, lastTime.tv_usec = endTime.tv_usec;
-
- fprintf(stderr, "=========================\n\n");
-}
-
-/* ******************************** */
-
-void sigproc(int sig) {
- static int called = 0;
-
- fprintf(stderr, "Leaving...\n");
- if(called) return; else called = 1;
- do_shutdown = 1;
- print_stats();
- pfring_close(pd);
-
- exit(0);
-}
-
-/* ******************************** */
-
-void my_sigalarm(int sig) {
- print_stats();
- alarm(ALARM_SLEEP);
- signal(SIGALRM, my_sigalarm);
-}
-
-/* ****************************************************** */
-
-static char hex[] = "0123456789ABCDEF";
-
-char* etheraddr_string(const u_char *ep, char *buf) {
- u_int i, j;
- char *cp;
-
- cp = buf;
- if ((j = *ep >> 4) != 0)
- *cp++ = hex[j];
- else
- *cp++ = '0';
-
- *cp++ = hex[*ep++ & 0xf];
-
- for(i = 5; (int)--i >= 0;) {
- *cp++ = ':';
- if ((j = *ep >> 4) != 0)
- *cp++ = hex[j];
- else
- *cp++ = '0';
-
- *cp++ = hex[*ep++ & 0xf];
- }
-
- *cp = '\0';
- return (buf);
-}
-
-/* ****************************************************** */
-
-/*
- * A faster replacement for inet_ntoa().
- */
-char* _intoa(unsigned int addr, char* buf, u_short bufLen) {
- char *cp, *retStr;
- u_int byte;
- int n;
-
- cp = &buf[bufLen];
- *--cp = '\0';
-
- n = 4;
- do {
- byte = addr & 0xff;
- *--cp = byte % 10 + '0';
- byte /= 10;
- if (byte > 0) {
- *--cp = byte % 10 + '0';
- byte /= 10;
- if (byte > 0)
- *--cp = byte + '0';
- }
- *--cp = '.';
- addr >>= 8;
- } while (--n > 0);
-
- /* Convert the string to lowercase */
- retStr = (char*)(cp+1);
-
- return(retStr);
-}
-
-/* ************************************ */
-
-char* intoa(unsigned int addr) {
- static char buf[sizeof "ff:ff:ff:ff:ff:ff:255.255.255.255"];
-
- return(_intoa(addr, buf, sizeof(buf)));
-}
-
-/* ****************************************************** */
-
-char* proto2str(u_short proto) {
- static char protoName[8];
-
- switch(proto) {
- case IPPROTO_TCP: return("TCP");
- case IPPROTO_UDP: return("UDP");
- case IPPROTO_ICMP: return("ICMP");
- default:
- snprintf(protoName, sizeof(protoName), "%d", proto);
- return(protoName);
- }
-}
-
-/* ****************************************************** */
-
-static int32_t thiszone;
-
-void dummyProcesssPacket(const struct pfring_pkthdr *h, const u_char *p) {
- if(verbose) {
- struct ether_header ehdr;
- u_short eth_type, vlan_id;
- char buf1[32], buf2[32];
- struct ip ip;
- int s = (h->ts.tv_sec + thiszone) % 86400;
-
- printf("%02d:%02d:%02d.%06u ",
- s / 3600, (s % 3600) / 60, s % 60,
- (unsigned)h->ts.tv_usec);
- printf("[eth_type=0x%04X]", h->extended_hdr.parsed_pkt.eth_type);
- printf("[l3_proto=%u]", (unsigned int)h->extended_hdr.parsed_pkt.l3_proto);
- printf("[%s:%d -> ", intoa(h->extended_hdr.parsed_pkt.ipv4_src), h->extended_hdr.parsed_pkt.l4_src_port);
- printf("%s:%d] ", intoa(h->extended_hdr.parsed_pkt.ipv4_dst), h->extended_hdr.parsed_pkt.l4_dst_port);
- memcpy(&ehdr, p+h->extended_hdr.parsed_header_len, sizeof(struct ether_header));
- eth_type = ntohs(ehdr.ether_type);
- printf("[%s -> %s] ",
- etheraddr_string(h->extended_hdr.parsed_pkt.smac, buf1),
- etheraddr_string(h->extended_hdr.parsed_pkt.dmac, buf2));
-
- if(eth_type == 0x8100) {
- vlan_id = (p[14] & 15)*256 + p[15];
- eth_type = (p[16])*256 + p[17];
- printf("[vlan %u] ", vlan_id);
- p+=4;
- }
- if(eth_type == 0x0800) {
- memcpy(&ip, p+h->extended_hdr.parsed_header_len+sizeof(ehdr), sizeof(struct ip));
- printf("[%s:%d ", intoa(ntohl(ip.ip_src.s_addr)), h->extended_hdr.parsed_pkt.l4_src_port);
- printf("-> %s:%d] ", intoa(ntohl(ip.ip_dst.s_addr)), h->extended_hdr.parsed_pkt.l4_dst_port);
- } else if(eth_type == 0x0806)
- printf("[ARP]");
- else
- printf("[eth_type=0x%04X]", eth_type);
-
- printf("[tos=%d][tcp_flags=%d][caplen=%d][len=%d][parsed_header_len=%d]"
- "[eth_offset=%d][l3_offset=%d][l4_offset=%d][payload_offset=%d]\n",
- h->extended_hdr.parsed_pkt.ipv4_tos, h->extended_hdr.parsed_pkt.tcp.flags,
- h->caplen, h->len, h->extended_hdr.parsed_header_len,
- h->extended_hdr.parsed_pkt.offset.eth_offset,
- h->extended_hdr.parsed_pkt.offset.l3_offset,
- h->extended_hdr.parsed_pkt.offset.l4_offset,
- h->extended_hdr.parsed_pkt.offset.payload_offset);
- }
-
- numPkts++, numBytes += h->len;
-}
-
-/* *************************************** */
-
-int32_t gmt2local(time_t t) {
- int dt, dir;
- struct tm *gmt, *loc;
- struct tm sgmt;
-
- if (t == 0)
- t = time(NULL);
- gmt = &sgmt;
- *gmt = *gmtime(&t);
- loc = localtime(&t);
- dt = (loc->tm_hour - gmt->tm_hour) * 60 * 60 +
- (loc->tm_min - gmt->tm_min) * 60;
-
- /*
- * If the year or julian day is different, we span 00:00 GMT
- * and must add or subtract a day. Check the year first to
- * avoid problems when the julian day wraps.
- */
- dir = loc->tm_year - gmt->tm_year;
- if (dir == 0)
- dir = loc->tm_yday - gmt->tm_yday;
- dt += dir * 24 * 60 * 60;
-
- return (dt);
-}
-
-/* *************************************** */
-
-void help(void) {
- printf("pftwin\n(C) 2005-10 Deri Luca <deri@ntop.org>\n\n");
-
- printf("Usage: pftwin -a <dev> -b <dev>\n"
- "Simultaneously sniff from two devices using on single socket\n");
-
- printf("-h Print this help\n");
- printf("-a <device> First device name (on which to sniff)\n");
- printf("-b <device> Second device name (on which to sniff)\n");
-
- printf("-e <direction> 0=RX+TX, 1=RX only, 2=TX only\n");
- printf("-s <string> String to search on packets\n");
- printf("-l <len> Capture length\n");
-
- printf("-v Verbose\n");
- exit(0);
-}
-
-/* *************************************** */
-
-void* packet_consumer_thread() {
- while(1) {
- struct simple_stats {
- u_int64_t num_pkts, num_bytes;
- };
-
- u_char *buffer;
- struct simple_stats stats;
- struct pfring_pkthdr hdr;
- int rc;
- u_int len;
-
- if(do_shutdown) break;
-
- if(pfring_recv(pd, &buffer, 0, &hdr, 1) > 0) {
- if(do_shutdown) break;
- dummyProcesssPacket(&hdr, buffer);
- }
-
- if(0) {
- len = sizeof(stats);
- rc = pfring_get_filtering_rule_stats(pd, 5, (char*)&stats, &len);
- if(rc < 0)
- printf("pfring_get_filtering_rule_stats() failed [rc=%d]\n", rc);
- else {
- printf("[Pkts=%u][Bytes=%u]\n",
- (unsigned int)stats.num_pkts,
- (unsigned int)stats.num_bytes);
- }
- }
- }
-
- return(NULL);
-}
-
-/* *************************************** */
-
-int main(int argc, char* argv[]) {
- char *a_device = NULL, *b_device = NULL, c;
- int promisc, snaplen = DEFAULT_SNAPLEN;
- packet_direction direction = rx_and_tx_direction;
-
-#if 0
- struct sched_param schedparam;
-
- schedparam.sched_priority = 99;
- if(sched_setscheduler(0, SCHED_FIFO, &schedparam) == -1) {
- printf("error while setting the scheduler, errno=%i\n",errno);
- exit(1);
- }
-
- mlockall(MCL_CURRENT|MCL_FUTURE);
-
-#undef TEST_PROCESSOR_AFFINITY
-#ifdef TEST_PROCESSOR_AFFINITY
- {
- unsigned long new_mask = 1;
- unsigned int len = sizeof(new_mask);
- unsigned long cur_mask;
- pid_t p = 0; /* current process */
- int ret;
-
- ret = sched_getaffinity(p, len, NULL);
- printf(" sched_getaffinity = %d, len = %u\n", ret, len);
-
- ret = sched_getaffinity(p, len, &cur_mask);
- printf(" sched_getaffinity = %d, cur_mask = %08lx\n", ret, cur_mask);
-
- ret = sched_setaffinity(p, len, &new_mask);
- printf(" sched_setaffinity = %d, new_mask = %08lx\n", ret, new_mask);
-
- ret = sched_getaffinity(p, len, &cur_mask);
- printf(" sched_getaffinity = %d, cur_mask = %08lx\n", ret, cur_mask);
- }
-#endif
-#endif
-
- startTime.tv_sec = 0;
- thiszone = gmt2local(0);
-
- while((c = getopt(argc,argv,"a:b:hl:ve:")) != -1) {
- switch(c) {
- case 'h':
- help();
- return(0);
- break;
- case 'e':
- switch(atoi(optarg)) {
- case rx_and_tx_direction:
- case rx_only_direction:
- case tx_only_direction:
- direction = atoi(optarg);
- break;
- }
- break;
- case 'l':
- snaplen = atoi(optarg);
- break;
- case 'a':
- a_device = strdup(optarg);
- break;
- case 'b':
- b_device = strdup(optarg);
- break;
- case 'v':
- verbose = 1;
- break;
- /*
- case 'f':
- bpfFilter = strdup(optarg);
- break;
- */
- }
- }
-
- // if((a_device == NULL) || (b_device == NULL)) help();
-
- /* hardcode: promisc=1, to_ms=500 */
- promisc = 1;
-
- if((pd = pfring_open("none", promisc, snaplen, 0)) == NULL) {
- printf("pfring_open error\n");
- return(-1);
- }
-
- if(a_device) {
- if((a_pd = pfring_open(a_device, promisc, snaplen, 0)) == NULL) {
- printf("pfring_open(%s) error\n", a_device);
- return(-1);
- } else {
- printf("Capturing from %s\n", a_device);
-
- if(pfring_set_master(a_pd, pd) != 0)
- printf("pfring_set_master(a) failed\n");
- else
- printf("pfring_set_master(a) succeeded\n");
- }
- } else
- a_pd = NULL;
-
- if(b_device) {
- if((b_pd = pfring_open(b_device, promisc, snaplen, 0)) == NULL) {
- printf("pfring_open(%s) error\n", b_device);
- return(-1);
- } else {
- printf("Capturing from %s\n", b_device);
-
- if(pfring_set_master(b_pd, pd) != 0)
- printf("pfring_set_master(b) failed\n");
- else
- printf("pfring_set_master(b) succeeded\n");
- }
- } else
- b_pd = NULL;
-
- {
- u_int32_t version;
-
- pfring_set_application_name(pd, "pftwin");
- pfring_version(pd, &version);
-
- printf("Using PF_RING v.%d.%d.%d\n",
- (version & 0xFFFF0000) >> 16,
- (version & 0x0000FF00) >> 8,
- version & 0x000000FF);
- }
-
- signal(SIGINT, sigproc);
- signal(SIGTERM, sigproc);
- signal(SIGINT, sigproc);
-
- if(!verbose) {
- signal(SIGALRM, my_sigalarm);
- alarm(ALARM_SLEEP);
- }
-
- pfring_enable_ring(pd);
- packet_consumer_thread();
-
- pfring_close(pd);
-
- return(0);
-}
|
[-]
[+]
|
Deleted |
PF_RING-4.7.1.tar.bz2/userland/examples/ptwin.c
^
|
@@ -1,451 +0,0 @@
-/*
- *
- * (C) 2005-10 - Luca Deri <deri@ntop.org>
- *
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- *
- */
-
-#define _GNU_SOURCE
-#include <signal.h>
-#include <sched.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <string.h>
-#include <unistd.h>
-#include <sys/mman.h>
-#include <errno.h>
-#include <sys/poll.h>
-#include <netinet/in_systm.h>
-#include <netinet/in.h>
-#include <netinet/ip.h>
-#include <net/ethernet.h> /* the L2 protocols */
-#include <sys/time.h>
-#include <time.h>
-#include <sys/socket.h>
-#include <arpa/inet.h>
-
-#define HAVE_PF_RING
-#include <pcap/pcap.h>
-
-#include "pfring.h"
-
-#define ALARM_SLEEP 1
-#define DEFAULT_SNAPLEN 128
-int verbose = 0;
-pfring_stat pfringStats;
-
-static struct timeval startTime;
-unsigned long long numPkts = 0, numBytes = 0;
-u_int8_t do_shutdown = 0;
-
-#define DEFAULT_DEVICE "eth0"
-
-pcap_t *pd, *a_pd, *b_pd;
-
-/* *************************************** */
-/*
- * The time difference in microseconds
- */
-long delta_time (struct timeval * now,
- struct timeval * before) {
- time_t delta_seconds;
- time_t delta_microseconds;
-
- /*
- * compute delta in second, 1/10's and 1/1000's second units
- */
- delta_seconds = now -> tv_sec - before -> tv_sec;
- delta_microseconds = now -> tv_usec - before -> tv_usec;
-
- if(delta_microseconds < 0) {
- /* manually carry a one from the seconds field */
- delta_microseconds += 1000000; /* 1e6 */
- -- delta_seconds;
- }
- return((delta_seconds * 1000000) + delta_microseconds);
-}
-
-/* ******************************** */
-
-void print_stats() {
- struct pcap_stat pcapStat;
- struct timeval endTime;
- float deltaSec;
- static u_int64_t lastPkts = 0;
- u_int64_t diff;
- static struct timeval lastTime;
-
- if(startTime.tv_sec == 0) {
- lastTime.tv_sec = 0;
- gettimeofday(&startTime, NULL);
- return;
- }
-
- gettimeofday(&endTime, NULL);
- deltaSec = (double)delta_time(&endTime, &startTime)/1000000;
-
- if(pcap_stats(pd, &pcapStat) >= 0) {
- fprintf(stderr, "=========================\n"
- "Absolute Stats: [%u pkts rcvd][%u pkts dropped]\n"
- "Total Pkts=%d/Dropped=%.1f %%\n",
- pcapStat.ps_recv, pcapStat.ps_drop, pcapStat.ps_recv-pcapStat.ps_drop,
- pcapStat.ps_recv == 0 ? 0 : (double)(pcapStat.ps_drop*100)/(double)pcapStat.ps_recv);
- fprintf(stderr, "%llu pkts [%.1f pkt/sec] - %llu bytes [%.2f Mbit/sec]\n",
- numPkts, (double)numPkts/deltaSec,
- numBytes, (double)8*numBytes/(double)(deltaSec*1000000));
-
- if(lastTime.tv_sec > 0) {
- deltaSec = (double)delta_time(&endTime, &lastTime)/1000000;
- diff = pcapStat.ps_recv-lastPkts;
- fprintf(stderr, "=========================\n"
- "Actual Stats: %llu pkts [%.1f ms][%.1f pkt/sec]\n",
- (long long unsigned int)diff, deltaSec*1000, ((double)diff/(double)(deltaSec)));
- lastPkts = pcapStat.ps_recv;
- }
-
- fprintf(stderr, "=========================\n");
- }
-
- lastTime.tv_sec = endTime.tv_sec, lastTime.tv_usec = endTime.tv_usec;
-}
-
-/* ******************************** */
-
-void sigproc(int sig) {
- static int called = 0;
-
- fprintf(stderr, "Leaving...\n");
- if(called) return; else called = 1;
- do_shutdown = 1;
- print_stats();
- pcap_close(pd);
-
- exit(0);
-}
-
-/* ******************************** */
-
-void my_sigalarm(int sig) {
- print_stats();
- alarm(ALARM_SLEEP);
- signal(SIGALRM, my_sigalarm);
-}
-
-/* ****************************************************** */
-
-static char hex[] = "0123456789ABCDEF";
-
-char* etheraddr_string(const u_char *ep, char *buf) {
- u_int i, j;
- char *cp;
-
- cp = buf;
- if ((j = *ep >> 4) != 0)
- *cp++ = hex[j];
- else
- *cp++ = '0';
-
- *cp++ = hex[*ep++ & 0xf];
-
- for(i = 5; (int)--i >= 0;) {
- *cp++ = ':';
- if ((j = *ep >> 4) != 0)
- *cp++ = hex[j];
- else
- *cp++ = '0';
-
- *cp++ = hex[*ep++ & 0xf];
- }
-
- *cp = '\0';
- return (buf);
-}
-
-/* ****************************************************** */
-
-/*
- * A faster replacement for inet_ntoa().
- */
-char* _intoa(unsigned int addr, char* buf, u_short bufLen) {
- char *cp, *retStr;
- u_int byte;
- int n;
-
- cp = &buf[bufLen];
- *--cp = '\0';
-
- n = 4;
- do {
- byte = addr & 0xff;
- *--cp = byte % 10 + '0';
- byte /= 10;
- if (byte > 0) {
- *--cp = byte % 10 + '0';
- byte /= 10;
- if (byte > 0)
- *--cp = byte + '0';
- }
- *--cp = '.';
- addr >>= 8;
- } while (--n > 0);
-
- /* Convert the string to lowercase */
- retStr = (char*)(cp+1);
-
- return(retStr);
-}
-
-/* ************************************ */
-
-char* intoa(unsigned int addr) {
- static char buf[sizeof "ff:ff:ff:ff:ff:ff:255.255.255.255"];
-
- return(_intoa(addr, buf, sizeof(buf)));
-}
-
-/* ****************************************************** */
-
-char* proto2str(u_short proto) {
- static char protoName[8];
-
- switch(proto) {
- case IPPROTO_TCP: return("TCP");
- case IPPROTO_UDP: return("UDP");
- case IPPROTO_ICMP: return("ICMP");
- default:
- snprintf(protoName, sizeof(protoName), "%d", proto);
- return(protoName);
- }
-}
-
-/* ****************************************************** */
-
-static int32_t thiszone;
-
-void dummyProcesssPacket(u_char *_deviceId,
- const struct pcap_pkthdr *h,
- const u_char *p) {
- if(verbose) {
- struct ether_header ehdr;
- u_short eth_type, vlan_id;
- char buf1[32], buf2[32];
- struct ip ip;
- int s = (h->ts.tv_sec + thiszone) % 86400;
-
- printf("%02d:%02d:%02d.%06u ",
- s / 3600, (s % 3600) / 60, s % 60,
- (unsigned)h->ts.tv_usec);
-
- memcpy(&ehdr, p, sizeof(struct ether_header));
- eth_type = ntohs(ehdr.ether_type);
- printf("[%s -> %s] ",
- etheraddr_string(ehdr.ether_shost, buf1),
- etheraddr_string(ehdr.ether_dhost, buf2));
-
- if(eth_type == 0x8100) {
- vlan_id = (p[14] & 15)*256 + p[15];
- eth_type = (p[16])*256 + p[17];
- printf("[vlan %u] ", vlan_id);
- p+=4;
- }
- if(eth_type == 0x0800) {
- memcpy(&ip, p+sizeof(ehdr), sizeof(struct ip));
- printf("[%s ", intoa(ntohl(ip.ip_src.s_addr)));
- printf("-> %s] ", intoa(ntohl(ip.ip_dst.s_addr)));
- } else if(eth_type == 0x0806)
- printf("[ARP]");
- else
- printf("[eth_type=0x%04X]", eth_type);
-
- printf("[caplen=%d][len=%d]\n", h->caplen, h->len);
- }
-
- if(numPkts == 0) gettimeofday(&startTime, NULL);
- numPkts++, numBytes += h->len;
- }
-
-/* *************************************** */
-
-int32_t gmt2local(time_t t) {
- int dt, dir;
- struct tm *gmt, *loc;
- struct tm sgmt;
-
- if (t == 0)
- t = time(NULL);
- gmt = &sgmt;
- *gmt = *gmtime(&t);
- loc = localtime(&t);
- dt = (loc->tm_hour - gmt->tm_hour) * 60 * 60 +
- (loc->tm_min - gmt->tm_min) * 60;
-
- /*
- * If the year or julian day is different, we span 00:00 GMT
- * and must add or subtract a day. Check the year first to
- * avoid problems when the julian day wraps.
- */
- dir = loc->tm_year - gmt->tm_year;
- if (dir == 0)
- dir = loc->tm_yday - gmt->tm_yday;
- dt += dir * 24 * 60 * 60;
-
- return (dt);
-}
-
-/* *************************************** */
-
-void help(void) {
- printf("pftwin\n(C) 2005-10 Deri Luca <deri@ntop.org>\n\n");
-
- printf("Usage: pftwin -a <dev> -b <dev>\n"
- "Simultaneously sniff from two devices using on single socket\n");
-
- printf("-h Print this help\n");
- printf("-a <device> First device name (on which to sniff)\n");
- printf("-b <device> Second device name (on which to sniff)\n");
-
- printf("-c <BPF Filter> Filter for the first device\n");
- printf("-d <BPF Filter> Filter for the second device\n");
-
- printf("-s <string> String to search on packets\n");
- printf("-l <len> Capture length\n");
-
- printf("-v Verbose\n");
-
- exit(0);
-}
-
-/* *************************************** */
-
-int main(int argc, char* argv[]) {
- char *a_device = NULL, *b_device = NULL, c;
- char *a_filter = NULL, *b_filter = NULL;
- int promisc, snaplen = DEFAULT_SNAPLEN;
- char errbuf[PCAP_ERRBUF_SIZE];
-
- startTime.tv_sec = 0;
- thiszone = gmt2local(0);
-
- while((c = getopt(argc,argv,"a:b:hl:vc:d:")) != -1) {
- switch(c) {
- case 'h':
- help();
- return(0);
- break;
- case 'l':
- snaplen = atoi(optarg);
- break;
- case 'a':
- a_device = strdup(optarg);
- break;
- case 'b':
- b_device = strdup(optarg);
- break;
- case 'c':
- a_filter = strdup(optarg);
- break;
- case 'd':
- b_filter = strdup(optarg);
- break;
- case 'v':
- verbose = 1;
- break;
- }
- }
-
- if((a_device == NULL) || (b_device == NULL)) help();
-
- /* hardcode: promisc=1, to_ms=500 */
- promisc = 1;
-
- if((pd = pcap_open_live("none", snaplen, promisc, 500, errbuf)) == NULL) {
- printf("pcap_open_live error\n");
- return(-1);
- }
-
- if(a_device) {
- if((a_pd = pcap_open_live(a_device, snaplen, promisc, 500, errbuf)) == NULL) {
- printf("pcap_open_live(%s) error\n", a_device);
- return(-1);
- } else {
- printf("Capturing from %s\n", a_device);
-
- if(a_filter) {
- struct bpf_program fcode;
-
- if(pcap_compile(a_pd, &fcode, a_filter, 1, 0xFFFFFF00) < 0) {
- printf("pcap_compile 'a' error: '%s'\n", pcap_geterr(a_pd));
- } else {
- if(pcap_setfilter(a_pd, &fcode) < 0) {
- printf("pcap_setfilter 'a' error: '%s'\n", pcap_geterr(pd));
- } else
- printf("Successfully set filter '%s' on 'a'\n", a_filter);
- }
- }
-
- if(pcap_set_master(a_pd, pd) != 0)
- printf("pcap_set_master(a) failed\n");
- else
- printf("pcap_set_master(a) succeeded\n");
- }
- } else
- a_pd = NULL;
-
- if(b_device) {
- if((b_pd = pcap_open_live(b_device, snaplen, promisc, 500, errbuf)) == NULL) {
- printf("pcap_open_live(%s) error\n", b_device);
- return(-1);
- } else {
- printf("Capturing from %s\n", b_device);
-
- if(b_filter) {
- struct bpf_program fcode;
-
- if(pcap_compile(b_pd, &fcode, b_filter, 1, 0xFFFFFF00) < 0) {
- printf("pcap_compile 'b' error: '%s'\n", pcap_geterr(b_pd));
- } else {
- if(pcap_setfilter(b_pd, &fcode) < 0) {
- printf("pcap_setfilter 'b' error: '%s'\n", pcap_geterr(pd));
- } else
- printf("Successfully set filter '%s' on 'b'\n", a_filter);
- }
- }
-
- if(pcap_set_master_id(b_pd, pcap_get_pfring_id(pd)) != 0)
- printf("pcap_set_master(b) failed\n");
- else
- printf("pcap_set_master(b) succeeded\n");
- }
- } else
- b_pd = NULL;
-
- signal(SIGINT, sigproc);
- signal(SIGTERM, sigproc);
- signal(SIGINT, sigproc);
-
- if(!verbose) {
- signal(SIGALRM, my_sigalarm);
- alarm(ALARM_SLEEP);
- }
-
- pcap_loop(pd, -1, dummyProcesssPacket, NULL);
- pcap_close(pd);
-
- return(0);
-}
|
[-]
[+]
|
Deleted |
PF_RING-4.7.1.tar.bz2/userland/examples/ringc.c
^
|
@@ -1,291 +0,0 @@
-/*
- * -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- * ringc.c - a simple program to count packets and bytes
- * from a PF_RING aware interface and print out
- * at given heartbeat seconds (default 3) statistics
- * information about the value of pkts/sec calculated
- *
- * 2Q 2008 Rocco Carbone <rocco /at/ ntop /dot/ org>
- *
- * -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- *
- * rocco@ring 454> sudo ./ringc
- * ringc: listening from eth0 using PF_RING driver ver 3.8.0
- *
- * ringc: starting to capture (partial reports will be available every 3 secs)
- * [use ^C to interrupt]
- *
- * [ 1] pkts rcvd #35310 => 11770.00 pkts/sec in 3.000 secs
- * [ 2] pkts rcvd #69690 => 11615.00 pkts/sec in 6.000 secs [+34380 => 11460.00 pkts/sec in 3.000 secs]
- * [ 3] pkts rcvd #108640 => 12071.11 pkts/sec in 9.000 secs [+38950 => 12983.33 pkts/sec in 3.000 secs]
- * [ 4] pkts rcvd #142784 => 11898.67 pkts/sec in 12.000 secs [+34144 => 11381.33 pkts/sec in 3.000 secs]
- * [ 5] pkts rcvd #176988 => 11799.20 pkts/sec in 15.000 secs [+34204 => 11401.33 pkts/sec in 3.000 secs]
- * ^C
- * Caught signal 2: terminating...
- * Time:
- * =====
- * Started: Thu Jun 5 19:14:21 2008
- * Finished: Thu Jun 5 19:14:37 2008
- * Elapsed Time: 16.142 secs
- *
- * Great Totals:
- * =============
- * pkts rcvd #189801 pckts => 11758.21 pkts/sec => #20529143 bytes [10174.27 Mbits/sec]
- *
- * -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
-
-/* Package info */
-static char __author__ [] = "R. Carbone <rocco /at/ ntop /dot/ org>";
-static char __version__ [] = "version 0.0.1";
-static char __released__ [] = "Jun 2008";
-static char __copyright__ [] = "Copyright (c) 2008";
-
-
-/* Operating System header file(s) */
-#include <stdio.h>
-#include <signal.h>
-
-/* Private header file(s) */
-#include "pfring.h"
-
-
-#define DEFAULT_INTERFACE "eth0" /* default interface */
-#define DEFAULT_SNAPSHOT 1500 /* default snapshot length */
-#define DEFAULT_PACKETS 0 /* default # of packets to capture */
-#define DEFAULT_HB 3 /* default heartbeat */
-
-/* Public funtions in file time.c */
-time_t delta_time_in_milliseconds (struct timeval * t2, struct timeval * t1);
-void print_time_in_secs (struct timeval * t, char * label);
-char * elapsed_time (struct timeval * start, struct timeval * stop);
-
-
-/* Local variables */
-static int done = 0;
-static pfring * ring = NULL;
-static int heartbeat = DEFAULT_HB;
-
-static struct timeval started; /* time the application started to receive packets */
-static unsigned long long partial = 0; /* # of packets so far received */
-static unsigned long long bytes = 0; /* # of bytes so far received */
-
-
-/* Print out warning information in the event packet counter
- * maintained by the driver differ from those counted by the application,
- * then print out pkts/secs from the start of the program and in the latest time interval
- */
-static void statistics (void)
-{
- static unsigned hits = 0;
- static u_int64_t previous = 0; /* # of packets received during last period */
- static struct timeval latest;
-
- struct timeval now;
- double delta;
-
- pfring_stat pstat;
-
- /* Print statistics information from PF_RING only they differ from those currently maintained by the application */
- if (pfring_stats (ring, & pstat) >= 0 && partial != pstat.recv)
- {
- if (pstat.drop)
- printf ("Warning: received by PF_RING #%llu received by the application #%llu [dropped #%llu (diff #%llu) (%%%.1f)]\n",
- (long long unsigned int)pstat.recv, partial,
- (long long unsigned int)pstat.drop,
- (long long unsigned int)(pstat.recv - pstat.drop),
- (!pstat.recv) ? 0 : (double) (pstat.drop * 100 / pstat.recv));
- else
- printf ("Warning: counted by PF_RING #%llu differ from those received by the application #%llu\n",
- (long long unsigned int)pstat.recv, partial);
- }
-
- /* Calculate the time interval from the start of the capture */
- gettimeofday (& now, NULL);
- delta = delta_time_in_milliseconds (& now, & started);
-
- /* Show pkts/secs in the latest period */
- printf ("[%3u] pkts rcvd #%5llu => %.2f pkts/sec in %s ",
- ++ hits, partial, (double) (partial * 1000 / delta), elapsed_time (& started, & now));
-
- if (previous)
- delta = delta_time_in_milliseconds (& now, & latest),
- printf ("[+%llu => %.2f pkts/sec in %s]",
- partial - previous, (double) ((partial - previous) * 1000 / delta), elapsed_time (& latest, & now));
- printf ("\n");
-
- previous = partial;
- latest = now;
-}
-
-
-/* What has to be done at given timeout */
-static void on_alarm (int sig)
-{
- /* Print out statistics information */
- statistics ();
-
- signal (SIGALRM, on_alarm);
- alarm (heartbeat);
-}
-
-
-/* What has to be done on interrupt */
-static void on_ctrl_c (int sig)
-{
- printf ("\nCaught signal %d: terminating...\n", sig);
-
- done = 1;
-}
-
-
-/* Display version information */
-static void version (char * progname)
-{
- printf ("This is %s %s of %s\n", progname, __version__, __released__);
- printf ("%s %s\n", __copyright__, __author__);
-}
-
-
-/* How to use this program */
-static void usage (char * progname)
-{
- printf ("Usage: %s [options]\n", progname);
-
- printf (" -h show usage and exit\n");
- printf (" -v show version and exit\n");
-
- printf (" -i interface use 'interface' for packet capture. default '%s'\n", DEFAULT_INTERFACE);
- printf (" -s len snapshot length. default %d\n", DEFAULT_SNAPSHOT);
-
- printf (" -c count # of packets to capture. default %d that means unlimited\n", DEFAULT_PACKETS);
-
- printf (" -b count heartbeat in seconds to show intermediate results. default %d\n", DEFAULT_HB);
-}
-
-
-int main (int argc, char * argv [])
-{
- int option;
-
- char * interface = DEFAULT_INTERFACE; /* interface name */
- int promiscuous = 1;
- int snapshot = DEFAULT_SNAPSHOT;
-
- u_int32_t ringdriver;
- u_char *packet;
- struct pfring_pkthdr header;
-
- /* How many packets */
- unsigned long maxcount = DEFAULT_PACKETS; /* total # of packets to capture */
-
- struct timeval stopped; /* time the application was interrupted */
- double delta;
-
- /* Notice the program name */
- char * progname = strrchr (argv [0], '/');
- progname = ! progname ? * argv : progname + 1;
-
-#define OPTSTRING "hvi:s:c:b:"
- while ((option = getopt (argc, argv, OPTSTRING)) != -1)
- {
- switch (option)
- {
- default: return -1;
-
- case 'h': usage (progname); return 0;
- case 'v': version (progname); return 0;
-
- case 'i': interface = optarg; break;
- case 's': snapshot = atoi (optarg); break;
-
- case 'c': maxcount = atoi (optarg); break;
-
- case 'b': heartbeat = atoi (optarg); break;
- }
- }
-
- if (! heartbeat)
- heartbeat = 1;
-
- /* Set unbuffered stdout */
- setvbuf (stdout, NULL, _IONBF, 0);
-
- if ((getuid () && geteuid ()) || setuid (0))
- {
- printf ("%s: sorry, you must be root in order to run this program\n", progname);
- return -1;
- }
-
- if (! (ring = pfring_open (interface, promiscuous, snapshot, 0)))
- {
- printf ("%s: cannot open interface '%s'\n", progname, interface);
- return -1;
- } else
- pfring_set_application_name(ring, "ringc");
-
- /* Print PF_RING driver version */
- pfring_version (ring, & ringdriver);
- printf ("%s: listening from %s using PF_RING driver ver %d.%d.%d\n\n", progname, interface,
- (ringdriver & 0xFFFF0000) >> 16, (ringdriver & 0x0000FF00) >> 8, ringdriver & 0x000000FF);
-
- signal (SIGINT, on_ctrl_c);
- signal (SIGALRM, on_alarm);
- alarm (heartbeat);
-
- /* Set time the application started to capture packets */
- gettimeofday (& started, NULL);
-
- /* Announce */
- printf ("%s: starting to capture (partial reports will be available every %d secs)\n", progname, heartbeat);
- printf (" [use ^C to interrupt]\n\n");
-
- pfring_enable_ring(ring);
-
- while (! done && (! maxcount || partial < maxcount))
- /* Please give me just a packet at once from the ring */
- if (pfring_recv (ring, &packet, sizeof (packet), & header, 1) > 0)
- partial ++,
- bytes += header.caplen,
- printf ("\r");
-
- /* Set time the application was interrupted */
- gettimeofday (& stopped, NULL);
- delta = (double) delta_time_in_milliseconds (& stopped, & started);
-
- printf ("Time:\n");
- printf ("=====\n");
- print_time_in_secs (& started, "Started: ");
- print_time_in_secs (& stopped, "Finished: ");
- printf ("Elapsed Time: %s\n", elapsed_time (& started, & stopped));
- printf ("\n");
-
- /* Print out test results */
- printf ("Great Totals:\n");
- printf ("=============\n");
- printf ("pkts rcvd #%llu pckts => %.2f pkts/sec => #%llu bytes [%.2f Mbits/sec]\n",
- partial, (double) partial * 1000 / delta,
- bytes, (double) 8 * bytes / delta);
-
-#if defined(ROCCO)
- /* Close the ring */
- pfring_close (ring);
-#endif /* ROCCO */
-
- return 0;
-}
|
[-]
[+]
|
Deleted |
PF_RING-4.7.1.tar.bz2/userland/examples/ringm.c
^
|
@@ -1,398 +0,0 @@
-/*
- * -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- * ringm.c - multi-threads, single-ring packet sniffer
- * for PF_RING aware interfaces
- *
- * 2Q 2008 Rocco Carbone <rocco /at/ ntop /dot/ org>
- * -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- *
- * This is the multi-thread version of 'rings'.
- *
- * It simply opens just a single ring and starts
- * the requested number of threads to count packets
- * received from the interface, until the maximum
- * # of packets has been reached (default 100000).
- *
- * When all the threads have finished to receive its
- * own # of packets the program prints out statistics
- * information per thread and the value of pkts/sec calculated
- *
- * rocco@ring 453> sudo ./rings
- * ringm: requested to start #23 threads
- * ringm: listening from eth0 using PF_RING driver ver 3.8.0
- *
- * ringm: starting to capture #434 packets per thread (please be patient)...
- *
- * \ maxcount received elapsed time
- * +========================================
- * |
- * 1 | 435 435 176 msecs
- * 2 | 435 435 1.955 secs
- * 3 | 435 435 2.025 secs
- * 4 | 435 435 1.908 secs
- * 5 | 435 435 2.052 secs
- * 6 | 435 435 2.090 secs
- * 7 | 435 435 1.935 secs
- * 8 | 435 435 2.101 secs
- * 9 | 435 435 2.030 secs
- * 10 | 435 435 2.071 secs
- * 11 | 435 435 1.996 secs
- * 12 | 435 435 2.068 secs
- * 13 | 435 435 2.064 secs
- * 14 | 435 435 2.070 secs
- * 15 | 435 435 2.092 secs
- * 16 | 435 435 2.075 secs
- * 17 | 435 435 1.693 secs
- * 18 | 435 435 2.025 secs
- * 19 | 434 434 2.049 secs
- * 20 | 434 434 2.056 secs
- * 21 | 434 434 1.950 secs
- * 22 | 434 434 2.048 secs
- * 23 | 434 434 2.042 secs
- * |
- * +========================================
- *
- * Test results:
- * =============
- * ringm: min/avg/max => 176.095 / 1937.992 / 2101.423 ms
- *
- * Total:
- * ======
- * Started: Thu Jun 12 16:56:26 2008
- * Finished: Thu Jun 12 16:56:28 2008
- * Elapsed Time: 2.170 secs
- *
- * ringm: received #10000 of expected #10000 packets => 4608.29 pkts/sec
- *
- * -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
-
-/* Package info */
-static char __author__ [] = "R. Carbone <rocco /at/ ntop /dot/ org>";
-static char __version__ [] = "version 0.0.1";
-static char __released__ [] = "Jun 2008";
-static char __copyright__ [] = "Copyright (c) 2008";
-
-
-/* Operating System header file(s) */
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <values.h>
-#include <signal.h>
-#include <pthread.h>
-
-/* Private header file(s) */
-#include "pfring.h"
-
-
-#define DEFAULT_INTERFACE "eth0" /* default interface */
-#define DEFAULT_SNAPSHOT 1500 /* default snapshot length */
-#define DEFAULT_THREADS 1 /* default # of thread(s) to start */
-#define DEFAULT_PACKETS 100000 /* default # of packets to capture per thread */
-
-
-typedef struct
-{
- pthread_t tid;
- pfring * ring;
- unsigned long maxcount;
- unsigned long partial;
- unsigned long errors;
- int snapshot;
- int bar;
-
- /* Timers for statistics */
- struct timeval started;
- struct timeval stopped;
- double elapsed;
-
-} my_thread_t;
-
-
-/* Public funtions in file time.c */
-time_t delta_time_in_milliseconds (struct timeval * t2, struct timeval * t1);
-time_t delta_time_in_microseconds (struct timeval * t2, struct timeval * t1);
-void print_time_in_secs (struct timeval * t, char * label);
-char * elapsed_time (struct timeval * start, struct timeval * stop);
-void showbar (unsigned long partial);
-
-
-/* Thread main loop */
-static void * sniffer (void * _thread)
-{
- my_thread_t * t = _thread;
-
- struct pfring_pkthdr header;
- u_char * packet; /* pointer to the packet */
-
- /* Get memory for packet capturing */
- packet = calloc (t -> snapshot, 1);
-
- gettimeofday (& t -> started, NULL);
-
- t -> partial = 0;
- while (t -> partial < t -> maxcount)
- {
- /* Please give me just a packet from the ring */
- if (pfring_recv (t -> ring, &packet, t -> snapshot, & header, 1) > 0)
- {
- t -> partial ++;
- if (t -> bar)
- showbar (t -> partial);
- }
- else
- t -> errors ++;
- }
-
- gettimeofday (& t -> stopped, NULL);
-
- t -> elapsed = delta_time_in_microseconds (& t -> stopped, & t -> started);
-
- free (packet);
-
- return NULL;
-}
-
-
-/* What should be done on interrupt */
-static void on_ctrl_c (int sig)
-{
- printf ("\nCaught signal %d: terminating...\n", sig);
- exit (0);
-}
-
-
-/* Display version information */
-static void version (char * progname)
-{
- printf ("This is %s %s of %s\n", progname, __version__, __released__);
- printf ("%s %s\n", __copyright__, __author__);
-}
-
-
-/* How to use this program */
-static void usage (char * progname)
-{
- printf ("Usage: %s [options]\n", progname);
-
- printf (" -h show usage and exit\n");
- printf (" -v show version and exit\n");
-
- printf (" -i interface use 'interface' for packet capture. default '%s'\n", DEFAULT_INTERFACE);
- printf (" -s len snapshot length. default %d\n", DEFAULT_SNAPSHOT);
-
- printf (" -t count # of thread(s) to start. default %d\n", DEFAULT_THREADS);
- printf (" -c count # of packets to capture per thread. default %d - 0 means unlimited\n", DEFAULT_PACKETS);
-
- printf (" -b disable the showbar\n");
-}
-
-
-/*
- * 1. Open 1 ring
- * 2. Start 't' thread(s)
- * 3. Capture 'n' packets per thread
- * 4. Print global statistics information
- */
-int main (int argc, char * argv [])
-{
- int option;
-
- char * interface = DEFAULT_INTERFACE; /* interface name */
- int promiscuous = 1;
- int snapshot = DEFAULT_SNAPSHOT;
-
- /* How many threads */
- int threadsno = DEFAULT_THREADS;
- my_thread_t ** threads = NULL; /* table of pointers to the threads */
- int t;
-
- /* How many rings */
- pfring * ring = NULL; /* pointer to the ring */
- u_int32_t ringdriver;
-
- /* How many packets */
- unsigned long maxcount = DEFAULT_PACKETS;
- unsigned long partial = 0;
- unsigned long errors = 0;
- int rest;
-
- int bar = 1; /* boolean to show progress bar */
-
- struct timeval started;
- struct timeval stopped;
- double delta;
-
- /* Counters for statistics */
- double min = MAXDOUBLE;
- double max = 0;
- double avg = 0;
-
- /* Notice the program name */
- char * progname = strrchr (argv [0], '/');
- progname = ! progname ? * argv : progname + 1;
-
-#define OPTSTRING "hvi:s:t:c:b"
- while ((option = getopt (argc, argv, OPTSTRING)) != EOF)
- {
- switch (option)
- {
- default: return -1;
-
- case 'h': usage (progname); return 0;
- case 'v': version (progname); return 0;
-
- case 'i': interface = optarg; break;
- case 's': snapshot = atoi (optarg); break;
-
- case 't': threadsno = atoi (optarg);
- if (! threadsno)
- threadsno = 1;
- break;
-
- case 'c': maxcount = atoi (optarg); break;
-
- case 'b': bar = 0; break;
- }
- }
-
- /* =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- */
-
- /* Set unbuffered stdout */
- setvbuf (stdout, NULL, _IONBF, 0);
-
- if ((getuid () && geteuid ()) || setuid (0))
- {
- printf ("%s: sorry, you must be root in order to run this program\n", progname);
- return -1;
- }
-
- signal (SIGINT, on_ctrl_c);
-
- /* Announce */
- printf ("%s: requested to start #%d thread%s\n", progname, threadsno, threadsno > 1 ? "s" : "");
-
- /* Open the interface for packet capturing */
- if (! (ring = pfring_open (interface, promiscuous, snapshot, 0)))
- {
- printf ("%s: cannot open interface '%s'\n", progname, interface);
- return -1;
- } else
- pfring_set_application_name(ring, "ringm");
-
- /* Allocate enough memory to keep the pointers to the threads */
- threads = calloc ((threadsno + 1) * sizeof (my_thread_t *), 1);
- for (t = 0; t < threadsno; t ++)
- threads [t] = NULL;
- threads [t] = NULL;
-
- /* Print PF_RING driver version */
- pfring_set_application_name(ring, argv[0]);
- pfring_version (ring, & ringdriver);
- printf ("%s: listening from %s using PF_RING driver ver %d.%d.%d\n\n", progname, interface,
- (ringdriver & 0xFFFF0000) >> 16, (ringdriver & 0x0000FF00) >> 8, ringdriver & 0x000000FF);
-
- pfring_enable_ring(ring);
-
- /* Announce */
- printf ("%s: starting to capture #%lu packets per thread (please be patient)...\n", progname, maxcount / threadsno);
-
- /* Set time the application started to capture packets */
- gettimeofday (& started, NULL);
-
- rest = maxcount % threadsno;
-
- /* Create threads to capture packets */
- for (t = 0; t < threadsno; t ++)
- {
- int error;
- threads [t] = calloc (sizeof (my_thread_t), 1);
-
- threads [t] -> ring = ring;
- threads [t] -> maxcount = maxcount / threadsno;
- threads [t] -> partial = 0;
- threads [t] -> errors = 0;
- threads [t] -> snapshot = snapshot;
- threads [t] -> bar = bar;
- if (rest)
- threads [t] -> maxcount ++,
- rest --;
-
- /* Start a new thread */
- if ((error = pthread_create (& threads [t] -> tid, NULL, sniffer, (void *) threads [t])))
- {
- printf ("%s: cannot create a new thread (%d already spawned) [error %d - %s]\n",
- progname, t, error, strerror (error));
- return 0;
- }
- }
-
- /* Wait for thread completions */
- for (t = 0; t < threadsno; t ++)
- pthread_join (threads [t] -> tid, NULL);
-
- /* Done! */
- gettimeofday (& stopped, NULL);
- delta = (double) delta_time_in_milliseconds (& stopped, & started);
-
- /* Print out test results */
- printf (" \n");
- printf (" \\ maxcount received elapsed time\n");
- printf (" +========================================\n");
- printf (" |\n");
-
- /* Print out per thread results */
- for (t = 0; t < threadsno; t ++)
- {
- partial += threads [t] -> partial;
- errors += threads [t] -> errors;
- if (threads [t] -> elapsed)
- printf ("%3d | %7lu %7lu %s\n", t + 1, threads [t] -> maxcount,
- threads [t] -> partial, elapsed_time (& threads [t] -> started, & threads [t] -> stopped)),
- min = threads [t] -> elapsed > min ? min : threads [t] -> elapsed,
- max = threads [t] -> elapsed < max ? max : threads [t] -> elapsed,
- avg += threads [t] -> elapsed;
- }
-
- printf (" |\n");
- printf (" +========================================\n");
-
- /* Print out test results */
- printf ("\n");
- printf ("Test results:\n");
- printf ("=============\n");
- printf ("%s: min/avg/max => %.3f / %.3f / %.3f ms\n\n", progname, min / 1000.0, avg / threadsno / 1000, max / 1000.0);
-
- printf ("Total:\n");
- printf ("======\n");
- print_time_in_secs (& started, "Started: ");
- print_time_in_secs (& stopped, "Finished: ");
- printf ("Elapsed Time: %s\n", elapsed_time (& started, & stopped));
- printf ("\n");
-
- printf ("%s: received #%lu of expected #%lu packets => %7.2f pkts/sec\n", progname, partial, maxcount, (double) 1000 * partial / delta);
-
- /* Threads clean up */
- for (t = 0; t < threadsno; t ++)
- free (threads [t]);
- free (threads);
-
- return 0;
-}
-
|
[-]
[+]
|
Deleted |
PF_RING-4.7.1.tar.bz2/userland/examples/rings.c
^
|
@@ -1,308 +0,0 @@
-/*
- * -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- * rings.c - single-process, multi-rings packet sniffer
- * for PF_RING aware interfaces
- *
- * 2Q 2008 Rocco Carbone <rocco /at/ ntop /dot/ org>
- * -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- *
- * It simply opens several rings (default 1) and uses
- * them in round-robin to count packets received
- * from the interface, until the maximum # of packets
- * has been reached (default 100000).
- *
- * At given intervals (a percentage of packets received
- * which defaults to 10) it also prints out statistics
- * information about the value of pkts/sec calculated
- *
- * rocco@ring 453> sudo ./rings
- * rings: requested to open #1 ring
- * rings: listening from eth0 using PF_RING driver ver 3.8.0
- *
- * rings: starting to capture #100000 pckts using #1 ring...
- * rings: pkts rcvd #10000 of #100000 (10.00%)
- * rings: pkts rcvd #20000 of #100000 (20.00%) [11037.53 pkts/sec => +10000 pkts in 906 msecs]
- * rings: pkts rcvd #30000 of #100000 (30.00%) [11049.72 pkts/sec => +10000 pkts in 905 msecs]
- * rings: pkts rcvd #40000 of #100000 (40.00%) [10917.03 pkts/sec => +10000 pkts in 916 msecs]
- * rings: pkts rcvd #50000 of #100000 (50.00%) [11123.47 pkts/sec => +10000 pkts in 899 msecs]
- * rings: pkts rcvd #60000 of #100000 (60.00%) [10989.01 pkts/sec => +10000 pkts in 910 msecs]
- * rings: pkts rcvd #70000 of #100000 (70.00%) [10917.03 pkts/sec => +10000 pkts in 916 msecs]
- * rings: pkts rcvd #80000 of #100000 (80.00%) [11074.20 pkts/sec => +10000 pkts in 903 msecs]
- * rings: pkts rcvd #90000 of #100000 (90.00%) [11086.47 pkts/sec => +10000 pkts in 902 msecs]
- * rings: pkts rcvd #100000 of #100000 (100%) [10928.96 pkts/sec => +10000 pkts in 915 msecs]
- *
- * Time:
- * =====
- * Started: Thu Jun 5 18:54:29 2008
- * Finished: Thu Jun 5 18:54:38 2008
- * Elapsed Time: 9.089 secs
- *
- * Great Totals:
- * =============
- * pkts rcvd #100000 pckts of #100000 => 11002.31 pkts/sec
- *
- * -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
-
-/* Package info */
-static char __author__ [] = "R. Carbone <rocco /at/ ntop /dot/ org>";
-static char __version__ [] = "version 0.0.1";
-static char __released__ [] = "Jun 2008";
-static char __copyright__ [] = "Copyright (c) 2008";
-
-
-/* Operating System header file(s) */
-#include <stdio.h>
-#include <signal.h>
-
-/* Private header file(s) */
-#include "pfring.h"
-
-
-#define DEFAULT_INTERFACE "eth0" /* default interface */
-#define DEFAULT_SNAPSHOT 1500 /* default snapshot length */
-#define DEFAULT_RINGS 1 /* default # of ring(s) to use */
-#define DEFAULT_PACKETS 100000 /* default # of packets to capture per ring */
-#define DEFAULT_HB 10 /* default heartbeat */
-
-
-/* Public funtions in file time.c */
-time_t delta_time_in_milliseconds (struct timeval * t2, struct timeval * t1);
-void print_time_in_secs (struct timeval * t, char * label);
-char * elapsed_time (struct timeval * start, struct timeval * stop);
-char * percentage (unsigned long partial, unsigned long total);
-void showbar (unsigned long partial);
-
-
-/* What should be done on interrupt */
-static void on_ctrl_c (int sig)
-{
- printf ("\nCaught signal %d: terminating...\n", sig);
- exit (0);
-}
-
-
-/* Display version information */
-static void version (char * progname)
-{
- printf ("This is %s %s of %s\n", progname, __version__, __released__);
- printf ("%s %s\n", __copyright__, __author__);
-}
-
-
-/* How to use this program */
-static void usage (char * progname)
-{
- printf ("Usage: %s [options]\n", progname);
-
- printf (" -h show usage and exit\n");
- printf (" -v show version and exit\n");
-
- printf (" -i interface use 'interface' for packet capture. default '%s'\n", DEFAULT_INTERFACE);
- printf (" -s len snapshot length. default %d\n", DEFAULT_SNAPSHOT);
-
- printf (" -n count # of ring(s) to open. default %d\n", DEFAULT_RINGS);
- printf (" -c count # of packets to capture per ring. default %d - 0 means unlimited\n", DEFAULT_PACKETS);
-
- printf (" -b count heartbeat in seconds to show intermediate results. default %d\n", DEFAULT_HB);
-}
-
-
-/*
- * 1. Open 'r' ring(s)
- * 2. Capture 'n' packets per ring using a round-robin algorithm
- * 3. Print global statistics information
- */
-int main (int argc, char * argv [])
-{
- int option;
-
- char * interface = DEFAULT_INTERFACE; /* interface name */
- int promiscuous = 1;
- int snapshot = DEFAULT_SNAPSHOT;
-
- /* How many rings */
- int rings = DEFAULT_RINGS;
- pfring ** ringtable = NULL;
- int r;
- u_int32_t ringdriver;
- u_char * packet;
- struct pfring_pkthdr header;
-
- /* How many packets */
- unsigned long maxcount = DEFAULT_PACKETS;
- unsigned long partial = 0;
- unsigned long errors = 0;
-
- int hb = -1; /* heartbeat */
- int quiet = 0;
-
- struct timeval started;
- struct timeval stopped;
- double delta;
-
- /* Notice the program name */
- char * progname = strrchr (argv [0], '/');
- progname = ! progname ? * argv : progname + 1;
-
-#define OPTSTRING "hvi:s:n:c:b:q"
- while ((option = getopt (argc, argv, OPTSTRING)) != EOF)
- {
- switch (option)
- {
- default: return -1;
-
- case 'h': usage (progname); return 0;
- case 'v': version (progname); return 0;
-
- case 'i': interface = optarg; break;
- case 's': snapshot = atoi (optarg); break;
-
- case 'n': rings = atoi (optarg);
- if (! rings)
- rings = 1;
- break;
-
- case 'c': maxcount = atoi (optarg); break;
-
- case 'b': hb = atoi (optarg); break;
- case 'q': quiet = 1; break;
- }
- }
-
- /* =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- */
-
- /* Set unbuffered stdout */
- setvbuf (stdout, NULL, _IONBF, 0);
-
- if ((getuid () && geteuid ()) || setuid (0))
- {
- printf ("%s: sorry, you must be root in order to run this program\n", progname);
- return -1;
- }
-
- signal (SIGINT, on_ctrl_c);
-
- /* Announce */
- printf ("%s: requested to open #%d ring%s\n", progname, rings, rings > 1 ? "s" : "");
-
- /* Allocate enough memory to keep the pointers to the ring(s) */
- ringtable = calloc ((rings + 1) * sizeof (pfring *), 1);
- for (r = 0; r < rings; r ++)
- ringtable [r] = NULL;
- ringtable [r] = NULL;
-
- /* Open the interface for packet capturing */
- for (r = 0; r < rings; r ++)
- if (! (ringtable [r] = pfring_open (interface, promiscuous, snapshot, 0)))
- {
- printf ("%s: cannot open interface '%s'\n", progname, interface);
- return -1;
- } else
- pfring_set_application_name(ringtable [r], "rings");
-
- pfring_enable_ring(ringtable [r]);
-
- /* Get memory for packet capturing */
- packet = calloc (snapshot, 1);
-
- /* Print PF_RING driver version */
- pfring_set_application_name(ringtable[0], argv[0]);
- pfring_version (ringtable [0], & ringdriver);
- printf ("%s: listening from %s using PF_RING driver ver %d.%d.%d\n\n", progname, interface,
- (ringdriver & 0xFFFF0000) >> 16, (ringdriver & 0x0000FF00) >> 8, ringdriver & 0x000000FF);
-
- if (hb == -1)
- hb = maxcount / DEFAULT_HB;
- if (! hb)
- hb = 1;
-
- /* Announce */
- printf ("%s: starting to capture #%lu pckts using #%d ring%s...\n", progname, maxcount, rings, rings > 1 ? "s" : "");
-
- /* Set time the application started to capture packets */
- gettimeofday (& started, NULL);
-
- r = 0;
- while (! maxcount || (partial + errors) < maxcount)
- {
- /* Please give me just a packet at once from the ring */
- if (pfring_recv (ringtable [r], &packet, snapshot, & header, 1) > 0)
- {
- partial ++;
- if (! quiet)
- {
- if (! (partial % hb))
- {
- static unsigned long previous = 0;
- static struct timeval latest;
-
- struct timeval now;
-
- /* Show pkts/secs in the latest period */
- gettimeofday (& now, NULL);
- delta = delta_time_in_milliseconds (& now, & latest);
-
- printf ("%s: pkts rcvd #%lu of #%lu %s", progname, partial, maxcount, percentage (partial, maxcount));
- if (previous && delta)
- printf (" [%8.2f pkts/sec => +%lu pkts in %s]",
- (double) (partial - previous) * 1000 / delta,
- partial - previous, elapsed_time (& latest, & now));
- printf ("\n");
-
- previous = partial;
- latest = now;
- }
- else
- showbar (partial);
- }
- }
- else
- errors ++;
-
- /* Round-robin to choose the ring candidate for the packet capture */
- r = (r + 1) % rings;
- }
-
- /* Close the ring(s) */
- for (r = 0; r < rings; r ++)
- pfring_close (ringtable [r]);
- free (ringtable);
-
- /* Done! */
- free (packet);
-
- gettimeofday (& stopped, NULL);
- delta = (double) delta_time_in_milliseconds (& stopped, & started);
-
- printf (" \n");
-
- printf ("Time:\n");
- printf ("=====\n");
- print_time_in_secs (& started, "Started: ");
- print_time_in_secs (& stopped, "Finished: ");
- printf ("Elapsed Time: %s\n", elapsed_time (& started, & stopped));
- printf ("\n");
-
- /* Print out test results */
- printf ("Great Totals:\n");
- printf ("=============\n");
- printf ("pkts rcvd #%lu pckts of #%lu => %7.2f pkts/sec\n", partial, maxcount, (double) partial * 1000 / delta);
-
- return 0;
-}
|
|
Changed |
PF_RING-4.7.2.tar.bz2/doc/PF_RING-UsersGuide.pages
^
|
|
Changed |
PF_RING-4.7.2.tar.bz2/doc/UsersGuide.pdf
^
|
[-]
[+]
|
Changed |
PF_RING-4.7.2.tar.bz2/drivers/intel/ixgbe/ixgbe-3.1.15-FlowDirector-NoTNAPI/src/ixgbe_ethtool.c
^
|
@@ -962,7 +962,7 @@
We just want to check if this interface
supports hardware filtering
*/
- return(0);
+ return(RING_MAGIC_VALUE);
}
if(bytes != NULL) {
|
[-]
[+]
|
Changed |
PF_RING-4.7.2.tar.bz2/drivers/intel/ixgbe/ixgbe-3.3.9-DNA/src/ixgbe_dna.c
^
|
@@ -219,6 +219,11 @@
/* Very important: update the value from the register set from userland */
if(++i == rx_ring->count)
i = 0;
+ /* here i is the last I've read (zero-copy implementation) */
+
+ if(++i == rx_ring->count)
+ i = 0;
+ /* here i is the next I have to read */
rx_ring->next_to_clean = i;
@@ -251,6 +256,8 @@
/* Refresh the value */
staterr = le32_to_cpu(rx_desc->wb.upper.status_error);
+ } else {
+ rx_ring->dna.rx_tx.rx.interrupt_received = 1;
}
if(unlikely(dna_debug))
@@ -361,6 +368,7 @@
u16 cache_line_size;
struct ixgbe_ring *tx_ring = adapter->tx_ring[rx_ring->queue_index];
struct pfring_hooks *hook = (struct pfring_hooks*)rx_ring->netdev->pfring_ptr;
+ dna_device_model model;
/* Check if the memory has been already allocated */
if(rx_ring->dna.rx_tx.rx.packet_memory != 0) return;
@@ -474,6 +482,17 @@
tx_ring->dna.mem_order = rx_ring->dna.mem_order;
dna_ixgbe_alloc_tx_buffers(tx_ring, hook);
+ switch (hw->mac.type) {
+ case ixgbe_mac_82598EB:
+ model = intel_ixgbe_82598;
+ break;
+ case ixgbe_mac_82599EB:
+ model = intel_ixgbe_82599;
+ break;
+ default:
+ model = intel_ixgbe;
+ }
+
hook->ring_dna_device_handler(add_device_mapping,
/* RX */
rx_ring->dna.rx_tx.rx.packet_memory,
@@ -492,7 +511,7 @@
(void*)rx_ring->netdev->mem_start,
rx_ring->netdev->mem_end - rx_ring->netdev->mem_start,
rx_ring->netdev,
- intel_ixgbe,
+ model,
rx_ring->netdev->dev_addr, /* 6 bytes MAC address */
&rx_ring->dna.rx_tx.rx.packet_waitqueue,
&rx_ring->dna.rx_tx.rx.interrupt_received,
|
[-]
[+]
|
Changed |
PF_RING-4.7.2.tar.bz2/drivers/intel/ixgbe/ixgbe-3.3.9-DNA/src/load.sh
^
|
@@ -14,6 +14,7 @@
# Set <id> as many times as the number of processors
#insmod ./ixgbe.ko
insmod ./ixgbe.ko MQ=0,0,0,0
+#insmod ./ixgbe.ko MQ=1,1 RSS=8,8 FdirMode=0,0
sleep 1
killall irqbalance
@@ -25,6 +26,7 @@
fi
printf "Configuring %s\n" "${IF[index]}"
ifconfig ${IF[index]} up
+ sleep 1
bash ../scripts/set_irq_affinity.sh ${IF[index]}
ethtool -A ${IF[index]} autoneg off
ethtool -A ${IF[index]} rx off
|
[-]
[+]
|
Changed |
PF_RING-4.7.2.tar.bz2/kernel/linux/pf_ring.h
^
|
@@ -37,8 +37,8 @@
#define pfring_ptr ec_ptr
/* Versioning */
-#define RING_VERSION "4.7.1"
-#define RING_VERSION_NUM 0x040701
+#define RING_VERSION "4.7.2"
+#define RING_VERSION_NUM 0x040702
/* Set */
#define SO_ADD_TO_CLUSTER 99
@@ -180,6 +180,7 @@
hardware timestamp, this is the place to read timestamp from */
int if_index; /* index of the interface on which the packet has been received.
It can be also used to report other information */
+ u_int32_t pkt_hash; /* Hash based on the packet header */
u_int16_t parsed_header_len; /* Extra parsing data before packet */
/* NOTE: leave it as last field of the memset on parse_pkt() will fail */
@@ -516,25 +517,31 @@
typedef enum {
intel_e1000e = 0,
intel_igb,
- intel_ixgbe
+ intel_ixgbe,
+ intel_ixgbe_82598,
+ intel_ixgbe_82599
} dna_device_model;
typedef struct {
+ u_int32_t packet_memory_num_slots;
+ u_int32_t packet_memory_slot_len;
+ u_int32_t packet_memory_tot_len;
+ u_int32_t descr_packet_memory_num_slots;
+ u_int32_t descr_packet_memory_slot_len;
+ u_int32_t descr_packet_memory_tot_len;
+ u_int32_t phys_card_memory_len;
+ dna_device_model device_model;
+} dna_memory_slots;
+
+typedef struct {
+ dna_memory_slots mem_info;
+ u_int16_t channel_id;
unsigned long rx_packet_memory; /* Invalid in userland */
void *rx_descr_packet_memory; /* Invalid in userland */
unsigned long tx_packet_memory; /* Invalid in userland */
void *tx_descr_packet_memory; /* Invalid in userland */
- u_int packet_memory_num_slots;
- u_int packet_memory_slot_len;
- u_int packet_memory_tot_len;
- u_int descr_packet_memory_num_slots;
- u_int descr_packet_memory_slot_len;
- u_int descr_packet_memory_tot_len;
- u_int channel_id;
char *phys_card_memory; /* Invalid in userland */
- u_int phys_card_memory_len;
struct net_device *netdev; /* Invalid in userland */
- dna_device_model device_model;
u_char device_address[6];
#ifdef __KERNEL__
wait_queue_head_t *packet_waitqueue;
|
[-]
[+]
|
Changed |
PF_RING-4.7.2.tar.bz2/kernel/pf_ring.c
^
|
@@ -156,7 +156,13 @@
/* List of virtual filtering devices */
static struct list_head virtual_filtering_devices_list;
-static rwlock_t virtual_filtering_lock = RW_LOCK_UNLOCKED;
+static rwlock_t virtual_filtering_lock =
+#if(LINUX_VERSION_CODE < KERNEL_VERSION(2,6,39))
+ RW_LOCK_UNLOCKED
+#else
+ __RW_LOCK_UNLOCKED(virtual_filtering_lock)
+#endif
+;
/* List of all clusters */
static struct list_head ring_cluster_list;
@@ -208,7 +214,13 @@
static rwlock_t ring_mgmt_lock;
-inline void init_ring_readers(void) { ring_mgmt_lock = RW_LOCK_UNLOCKED; }
+inline void init_ring_readers(void) { ring_mgmt_lock =
+#if(LINUX_VERSION_CODE < KERNEL_VERSION(2,6,39))
+ RW_LOCK_UNLOCKED
+#else
+ __RW_LOCK_UNLOCKED(ring_mgmt_lock)
+#endif
+; }
inline void ring_write_lock(void) { write_lock_bh(&ring_mgmt_lock); }
inline void ring_write_unlock(void) { write_unlock_bh(&ring_mgmt_lock); }
/* use ring_read_lock/ring_read_unlock in process context (a bottom half may use write_lock) */
@@ -367,6 +379,7 @@
return(dev->real_num_rx_queues);
#else
return(dev->real_num_tx_queues);
+ // return(1);
#endif
#endif
}
@@ -585,8 +598,10 @@
ring_proc_dir,
ring_proc_get_info, pfr);
- printk("[PF_RING] Added /proc/net/pf_ring/%s\n",
- pfr->sock_proc_name);
+ if(enable_debug)
+ printk("[PF_RING] Added /proc/net/pf_ring/%s\n", pfr->sock_proc_name);
+
+ ring_table_size++;
}
}
@@ -596,7 +611,8 @@
{
if((ring_proc_dir != NULL)
&& (pfr->sock_proc_name[0] != '\0')) {
- printk("[PF_RING] Removing /proc/net/pf_ring/%s\n", pfr->sock_proc_name);
+ if(enable_debug)
+ printk("[PF_RING] Removing /proc/net/pf_ring/%s\n", pfr->sock_proc_name);
remove_proc_entry(pfr->sock_proc_name, ring_proc_dir);
@@ -604,6 +620,7 @@
printk("[PF_RING] Removed /proc/net/pf_ring/%s\n", pfr->sock_proc_name);
pfr->sock_proc_name[0] = '\0';
+ ring_table_size--;
}
}
@@ -629,6 +646,12 @@
case intel_ixgbe:
dev_family = "Intel ixgbe"; break;
break;
+ case intel_ixgbe_82598:
+ dev_family = "Intel ixgbe 82598"; break;
+ break;
+ case intel_ixgbe_82599:
+ dev_family = "Intel ixgbe 82599"; break;
+ break;
}
} else {
switch(dev_ptr->device_type) {
@@ -1052,11 +1075,10 @@
{
if(ring_proc != NULL) {
remove_proc_entry(PROC_INFO, ring_proc_dir);
- printk("[PF_RING] removed /proc/net/pf_ring/%s\n", PROC_INFO);
+ if(enable_debug) printk("[PF_RING] removed /proc/net/pf_ring/%s\n", PROC_INFO);
remove_proc_entry(PROC_PLUGINS_INFO, ring_proc_dir);
- printk("[PF_RING] removed /proc/net/pf_ring/%s\n",
- PROC_PLUGINS_INFO);
+ if(enable_debug) printk("[PF_RING] removed /proc/net/pf_ring/%s\n", PROC_PLUGINS_INFO);
remove_proc_entry(PROC_DEV, ring_proc_dir);
@@ -1066,7 +1088,7 @@
init_net.
#endif
proc_net);
- printk("[PF_RING] deregistered /proc/net/pf_ring\n");
+ if(enable_debug) printk("[PF_RING] deregistered /proc/net/pf_ring\n");
}
}
}
@@ -1189,8 +1211,6 @@
printk("[PF_RING] net_ratelimit() failure\n");
}
- ring_table_size++;
-
pfr = (struct pf_ring_socket *)ring_sk(sk);
pfr->ring_pid = current->pid;
}
@@ -1234,7 +1254,7 @@
list_del(ptr);
to_delete = entry;
- ring_table_size--, socket_found = 1;
+ socket_found = 1;
}
if(master_found && socket_found) break;
@@ -1246,6 +1266,35 @@
printk("[PF_RING] leaving ring_remove()\n");
}
+/* ********************************** */
+
+inline u_int32_t hash_pkt(u_int16_t vlan_id, u_int8_t proto,
+ ip_addr host_peer_a, ip_addr host_peer_b,
+ u_int16_t port_peer_a, u_int16_t port_peer_b)
+{
+ return(vlan_id+proto+
+ host_peer_a.v6.s6_addr32[0]+host_peer_a.v6.s6_addr32[1]+
+ host_peer_a.v6.s6_addr32[2]+host_peer_a.v6.s6_addr32[3]+
+ host_peer_b.v6.s6_addr32[0]+host_peer_b.v6.s6_addr32[1]+
+ host_peer_b.v6.s6_addr32[2]+host_peer_b.v6.s6_addr32[3]+
+ port_peer_a+port_peer_b);
+}
+
+/* ********************************** */
+
+inline u_int32_t hash_pkt_header(struct pfring_pkthdr * hdr, u_char mask_src, u_char mask_dst)
+{
+ if(hdr->extended_hdr.pkt_hash == 0)
+ hdr->extended_hdr.pkt_hash = hash_pkt(hdr->extended_hdr.parsed_pkt.vlan_id,
+ hdr->extended_hdr.parsed_pkt.l3_proto,
+ mask_src ? ip_zero : hdr->extended_hdr.parsed_pkt.ip_src,
+ mask_dst ? ip_zero : hdr->extended_hdr.parsed_pkt.ip_dst,
+ mask_src ? 0 : hdr->extended_hdr.parsed_pkt.l4_src_port,
+ mask_dst ? 0 : hdr->extended_hdr.parsed_pkt.l4_dst_port);
+
+ return(hdr->extended_hdr.pkt_hash);
+}
+
/* ******************************************************* */
static int parse_raw_pkt(char *data, u_int data_len,
@@ -1398,6 +1447,8 @@
} else
hdr->extended_hdr.parsed_pkt.l4_src_port = hdr->extended_hdr.parsed_pkt.l4_dst_port = 0;
+ hash_pkt_header(hdr, 0, 0);
+
return(1); /* IP */
}
@@ -1424,33 +1475,6 @@
/* ********************************** */
-inline u_int32_t hash_pkt(u_int16_t vlan_id, u_int8_t proto,
- ip_addr host_peer_a, ip_addr host_peer_b,
- u_int16_t port_peer_a, u_int16_t port_peer_b)
-{
- return(vlan_id+proto+
- host_peer_a.v6.s6_addr32[0]+host_peer_a.v6.s6_addr32[1]+
- host_peer_a.v6.s6_addr32[2]+host_peer_a.v6.s6_addr32[3]+
- host_peer_b.v6.s6_addr32[0]+host_peer_b.v6.s6_addr32[1]+
- host_peer_b.v6.s6_addr32[2]+host_peer_b.v6.s6_addr32[3]+
- port_peer_a+port_peer_b);
-}
-
-/* ********************************** */
-
-inline u_int32_t hash_pkt_header(struct pfring_pkthdr * hdr, u_char mask_src,
- u_char mask_dst)
-{
- return(hash_pkt(hdr->extended_hdr.parsed_pkt.vlan_id,
- hdr->extended_hdr.parsed_pkt.l3_proto,
- mask_src ? ip_zero : hdr->extended_hdr.parsed_pkt.ip_src,
- mask_dst ? ip_zero : hdr->extended_hdr.parsed_pkt.ip_dst,
- mask_src ? 0 : hdr->extended_hdr.parsed_pkt.l4_src_port,
- mask_dst ? 0 : hdr->extended_hdr.parsed_pkt.l4_dst_port));
-}
-
-/* ********************************** */
-
static int hash_bucket_match(sw_filtering_hash_bucket * hash_bucket,
struct pfring_pkthdr *hdr,
u_char mask_src, u_char mask_dst)
@@ -1677,8 +1701,8 @@
}
if(rule->rule.balance_pool > 0) {
- u_int32_t balance_hash =
- hash_pkt_header(hdr, 0, 0) % rule->rule.balance_pool;
+ u_int32_t balance_hash = hash_pkt_header(hdr, 0, 0) % rule->rule.balance_pool;
+
if(balance_hash != rule->rule.balance_id)
return(0);
}
@@ -2389,7 +2413,7 @@
u_int8_t hash_found = 0;
if(pfr && pfr->rehash_rss && skb->dev)
- channel_id = hash_pkt_header(hdr, 0, 0) % get_num_rx_queues(skb->dev);
+ channel_id = hash_pkt_header(hdr, 0, 0) % get_num_rx_queues(skb->dev);
/* This is a memory holder for storing parsed packet information
that will then be freed when the packet has been handled
@@ -2400,9 +2424,21 @@
hdr->len, channel_id, num_rx_channels,
pfr->ring_active, pfr->ring_netdev->dev->name);
+ {
+ static int once = 0;
+
+ while(once < 25) {
+ printk("[PF_RING] add_skb_to_ring on device index %d [active=%d]\n",
+ skb->dev->ifindex, pfr->ring_active);
+ once++;
+ }
+ }
+
if((!pfring_enabled) || ((!pfr->ring_active) && (pfr->master_ring == NULL)))
return(-1);
+
+
pfr->num_rx_channels = num_rx_channels; /* Constantly updated */
hdr->extended_hdr.parsed_pkt.last_matched_rule_id = (u_int16_t)-1;
@@ -2837,6 +2873,15 @@
skb->dev->name, num_rings_per_device[skb->dev->ifindex], num_any_rings);
}
+ if(skb->dev->ifindex != 10) {
+ static int once = 0;
+
+ while(once < 25) {
+ printk("[PF_RING] Received pkt on device index %d\n", skb->dev->ifindex);
+ once++;
+ }
+ }
+
if((num_any_rings == 0)
&& (skb->dev
&& (skb->dev->ifindex < MAX_NUM_IFIDX)
@@ -2890,6 +2935,7 @@
if(pfr && pfr->rehash_rss && skb->dev) {
parse_pkt(skb, displ, &hdr, 1);
+
channel_id = hash_pkt_header(&hdr, 0, 0) % get_num_rx_queues(skb->dev);
}
@@ -2904,7 +2950,6 @@
room_available |= copy_data_to_ring(skb, pfr, &hdr, displ, 0, NULL, NULL, 0);
}
} else {
-
is_ip_pkt = parse_pkt(skb, displ, &hdr, 1);
if(enable_ip_defrag) {
@@ -2923,6 +2968,7 @@
else
hdr.extended_hdr.if_index = UNKNOWN_INTERFACE;
+
/* Avoid the ring to be manipulated while playing with it */
ring_read_lock();
@@ -2947,6 +2993,7 @@
) {
/* We've found the ring where the packet can be stored */
int old_caplen = hdr.caplen; /* Keep old lenght */
+
hdr.caplen = min_val(hdr.caplen, pfr->bucket_len);
room_available |= add_skb_to_ring(skb, pfr, &hdr, is_ip_pkt,
displ, channel_id, num_rx_channels);
@@ -4168,16 +4215,12 @@
if(enable_debug)
printk("[PF_RING] wait_packet_function_ptr(0) returned %d\n", rc);
- //*pfr->dna_device->interrupt_received = rc;
- if(rc == 0)
- rc = *pfr->dna_device->interrupt_received;
-
if(enable_debug)
printk("[PF_RING] poll %s return [%d]\n",
pfr->ring_netdev->dev->name,
*pfr->dna_device->interrupt_received);
- if(rc) {
+ if(*pfr->dna_device->interrupt_received) {
return(POLLIN | POLLRDNORM);
} else {
return(0);
@@ -4449,8 +4492,9 @@
}
}
- printk("[PF_RING] ring_map_dna_device(%s, %u): mapping failed\n",
- mapping->device_name, mapping->channel_id);
+ if(enable_debug)
+ printk("[PF_RING] ring_map_dna_device(%s, %u): mapping failed or not a dna device\n",
+ mapping->device_name, mapping->channel_id);
return(-1);
}
@@ -5210,7 +5254,8 @@
case SO_SET_MASTER_RING:
/* Avoid using master sockets with bound rings */
- if(pfr->ring_netdev == &none_device_element) return -EFAULT;
+ if(pfr->ring_netdev == &none_device_element)
+ return -EFAULT;
if(optlen != sizeof(ring_id))
return -EINVAL;
@@ -5610,10 +5655,10 @@
case SO_GET_MAPPED_DNA_DEVICE:
{
- if((pfr->dna_device == NULL) || (len < sizeof(dna_device)))
+ if((pfr->dna_device == NULL) || (len < sizeof(dna_memory_slots)))
return -EFAULT;
- if(copy_to_user(optval, pfr->dna_device, sizeof(dna_device)))
+ if(copy_to_user(optval, &pfr->dna_device->mem_info, sizeof(dna_memory_slots)))
return -EFAULT;
break;
@@ -5779,21 +5824,22 @@
next->in_use = 0;
next->dev.rx_packet_memory = rx_packet_memory;
- next->dev.packet_memory_num_slots = packet_memory_num_slots;
- next->dev.packet_memory_slot_len = packet_memory_slot_len;
- next->dev.packet_memory_tot_len = packet_memory_tot_len;
+ next->dev.mem_info.packet_memory_num_slots = packet_memory_num_slots;
+ next->dev.mem_info.packet_memory_slot_len = packet_memory_slot_len;
+ next->dev.mem_info.packet_memory_tot_len = packet_memory_tot_len;
+ next->dev.mem_info.device_model = device_model;
next->dev.rx_descr_packet_memory = descr_packet_memory;
- next->dev.descr_packet_memory_num_slots = descr_packet_memory_num_slots;
- next->dev.descr_packet_memory_slot_len = descr_packet_memory_slot_len;
- next->dev.descr_packet_memory_tot_len = descr_packet_memory_tot_len;
+ next->dev.mem_info.descr_packet_memory_num_slots = descr_packet_memory_num_slots;
+ next->dev.mem_info.descr_packet_memory_slot_len = descr_packet_memory_slot_len;
+ next->dev.mem_info.descr_packet_memory_tot_len = descr_packet_memory_tot_len;
next->dev.phys_card_memory = phys_card_memory;
- next->dev.phys_card_memory_len = phys_card_memory_len;
+ next->dev.mem_info.phys_card_memory_len = phys_card_memory_len;
/* TX */
next->dev.tx_packet_memory = tx_packet_memory;
next->dev.tx_descr_packet_memory = tx_descr_packet_memory;
next->dev.channel_id = channel_id;
next->dev.netdev = netdev;
- next->dev.device_model = device_model;
+ next->dev.mem_info.device_model = device_model;
memcpy(next->dev.device_address, device_address, 6);
next->dev.packet_waitqueue = packet_waitqueue;
next->dev.interrupt_received = interrupt_received;
@@ -6013,7 +6059,7 @@
if(enable_debug)
printk("[PF_RING] set_eeprom returned %d\n", rc);
- if(rc == 0) {
+ if(rc == RING_MAGIC_VALUE) {
/* This device supports hardware filtering */
dev_ptr->device_type = intel_82599_family;
@@ -6027,14 +6073,17 @@
ring_proc_dev_rule_read, dev_ptr);
if(entry) {
entry->write_proc = ring_proc_dev_rule_write;
- printk("[PF_RING] Device %s (Intel 82599) DOES support hardware packet filtering\n", dev->name);
- } else
- printk("[PF_RING] Error while creating /proc entry 'rules' for device %s\n", dev->name);
+ if(enable_debug) printk("[PF_RING] Device %s (Intel 82599) DOES support hardware packet filtering\n", dev->name);
+ } else {
+ if(enable_debug) printk("[PF_RING] Error while creating /proc entry 'rules' for device %s\n", dev->name);
+ }
#endif
- } else
- printk("[PF_RING] Device %s does NOT support hardware packet filtering [1]\n", dev->name);
- } else
- printk("[PF_RING] Device %s does NOT support hardware packet filtering [2]\n", dev->name);
+ } else {
+ if(enable_debug) printk("[PF_RING] Device %s does NOT support hardware packet filtering [1]\n", dev->name);
+ }
+ } else {
+ if(enable_debug) printk("[PF_RING] Device %s does NOT support hardware packet filtering [2]\n", dev->name);
+ }
#endif
list_add(&dev_ptr->device_list, &ring_aware_device_list);
@@ -6189,6 +6238,7 @@
kfree(entry);
}
+ list_del(&any_device_element.device_list);
list_for_each_safe(ptr, tmp_ptr, &ring_aware_device_list) {
ring_device_element *dev_ptr;
@@ -6205,7 +6255,7 @@
remove_proc_entry(dev_ptr->dev->name, ring_proc_dev_dir);
if(hook->magic == PF_RING) {
- printk("[PF_RING] Unregister hook for %s\n", dev_ptr->dev->name);
+ if(enable_debug) printk("[PF_RING] Unregister hook for %s\n", dev_ptr->dev->name);
dev_ptr->dev->pfring_ptr = NULL; /* Unhook PF_RING */
}
@@ -6280,6 +6330,9 @@
memset(&any_device_element, 0, sizeof(any_device_element));
any_device_element.dev = &any_dev, any_device_element.device_type = standard_nic_family;
+ INIT_LIST_HEAD(&any_device_element.device_list);
+ list_add(&any_device_element.device_list, &ring_aware_device_list);
+
memset(&none_dev, 0, sizeof(none_dev));
strcpy(none_dev.name, "none");
none_dev.ifindex = MAX_NUM_IFIDX-2;
|
[-]
[+]
|
Added |
PF_RING-4.7.2.tar.bz2/userland/examples/Makefile.in
^
|
@@ -0,0 +1,146 @@
+#
+# Makefile for the PF_RING API example programs
+#
+# Try to make both programs written on top of the
+# PF_RING library and programs originally written
+# on top of PCAP library and linked now to use
+# the version with PF_RING aware functionalities.
+#
+
+
+
+#
+# PF_RING
+#
+PFRINGDIR = ../lib
+LIBPFRING = ${PFRINGDIR}/libpfring.a
+
+#
+# DNA Support
+DNA_DEFINE = #-DENABLE_DNA_SUPPORT
+
+#
+# PF_RING aware libpcap
+#
+O_FLAG = #-O2
+EXTRA_LIBS =
+PCAPDIR = ../libpcap-1.1.1-ring
+LIBPCAP = ${PCAPDIR}/libpcap.a ${EXTRA_LIBS}
+
+#
+# Search directories
+#
+PFRING_KERNEL=../../kernel
+INCLUDE = -I${PFRING_KERNEL} -I${PFRING_KERNEL}/plugins -I${PFRINGDIR} -I${PCAPDIR}
+
+#
+# C compiler and flags
+#
+#
+# CROSS_COMPILE=arm-mv5sft-linux-gnueabi-
+#
+CC = ${CROSS_COMPILE}gcc #--platform=native
+CFLAGS = -g ${O_FLAG} -Wall ${INCLUDE} ${DNA_DEFINE} #-O
+# LDFLAGS =
+
+#
+# User and System libraries
+#
+LIBS = ${LIBPFRING} @DAG_LIB@ -lpthread
+
+# How to make an object file
+%.o: %.c
+# @echo "=*= making object $@ =*="
+ ${CC} ${CFLAGS} -c $< -o $@
+
+#
+# Main targets
+#
+PFPROGS = pfcount pfcount_multichannel preflect pfbounce pfmap \
+ forwarder alldevs dummy_plugin_pfcount pcap2nspcap pfcount_dummy_plugin pffilter_test \
+ pfcount_bundle pfcount_82599 vdevice_simulator pfsystest pfsend
+
+PCAPPROGS = pcount pwrite
+TARGETS = ${PFPROGS} ${PCAPPROGS}
+
+RCOBJS = ringc.o interval.o
+RSOBJS = rings.o interval.o
+RMOBJS = ringm.o interval.o
+RPOBJS = pcaps.o interval.o
+
+all: ${TARGETS}
+
+ringc: ${RCOBJS} ${LIBPFRING}
+ ${CC} ${RCOBJS} ${LIBS} -o $@
+
+rings: ${RSOBJS} ${LIBPFRING}
+ ${CC} ${RSOBJS} ${LIBS} -o $@
+
+ringm: ${RMOBJS} ${LIBPFRING}
+ ${CC} ${RMOBJS} ${LIBS} -o $@
+
+pcaps: ${RPOBJS}
+ ${CC} ${RPOBJS} ${LIBPCAP} ${LIBS} -o $@
+
+pfcount: pfcount.o ${LIBPFRING}
+ ${CC} pfcount.o ${LIBS} -o $@
+
+dummy_plugin_pfcount: dummy_plugin_pfcount.o ${LIBPFRING}
+ ${CC} dummy_plugin_pfcount.o ${LIBS} -o $@
+
+pffilter_test: pffilter_test.o ${LIBPFRING}
+ ${CC} pffilter_test.o ${LIBS} -o $@
+
+pcap2nspcap: pcap2nspcap.o ${LIBPFRING}
+ ${CC} pcap2nspcap.o ${LIBPCAP} ${LIBS} -o $@
+
+pfcount_multichannel: pfcount_multichannel.o ${LIBPFRING}
+ ${CC} pfcount_multichannel.o ${LIBS} -o $@
+
+pfcount_82599: pfcount_82599.o ${LIBPFRING}
+ ${CC} pfcount_82599.o ${LIBS} -o $@
+
+pfcount_bundle: pfcount_bundle.o ${LIBPFRING}
+ ${CC} pfcount_bundle.o ${LIBS} -o $@
+
+pfcount_dummy_plugin: pfcount_dummy_plugin.o ${LIBPFRING}
+ ${CC} pfcount_dummy_plugin.o ${LIBS} -o $@
+
+preflect: preflect.o ${LIBPFRING}
+ ${CC} preflect.o ${LIBPCAP} ${LIBS} -o $@
+
+pfbounce: pfbounce.o ${LIBPFRING}
+ ${CC} pfbounce.o ${LIBPCAP} ${LIBS} -o $@
+
+pfsend: pfsend.o ${LIBPFRING}
+ ${CC} pfsend.o ${LIBPCAP} ${LIBS} -o $@
+
+pftwin: pftwin.o ${LIBPFRING}
+ ${CC} pftwin.o ${LIBS} -o $@
+
+ptwin: ptwin.o ${LIBPFRING}
+ ${CC} ptwin.o ${LIBPCAP} ${LIBS} -o $@
+
+pfmap: pfmap.o ${LIBPFRING}
+ ${CC} pfmap.o ${LIBS} -o $@
+
+forwarder: forwarder.o ${LIBPFRING}
+ ${CC} forwarder.o ${LIBS} -o $@
+
+pcount: pcount.o ${LIBPCAP} ${LIBPFRING}
+ ${CC} pcount.o ${LIBPCAP} ${LIBS} -o $@
+
+alldevs: alldevs.o ${LIBPCAP} ${LIBPFRING}
+ ${CC} alldevs.o ${LIBPCAP} ${LIBS} -o $@
+
+pwrite: pwrite.o ${LIBPCAP} ${LIBPFRING}
+ ${CC} pwrite.o ${LIBPCAP} ${LIBS} -o $@
+
+vdevice_simulator: vdevice_simulator.o ${LIBPCAP} ${LIBPFRING}
+ ${CC} vdevice_simulator.o ${LIBPCAP} ${LIBS} -o $@
+
+pfsystest: pfsystest.o ${LIBPFRING}
+ ${CC} pfsystest.o ${LIBS} -o $@
+
+clean:
+ @rm -f ${TARGETS} *.o *~
|
[-]
[+]
|
Changed |
PF_RING-4.7.2.tar.bz2/userland/examples/pfcount.c
^
|
@@ -398,8 +398,9 @@
printf("[%s:%d ", intoa(ntohl(ip.ip_src.s_addr)), h->extended_hdr.parsed_pkt.l4_src_port);
printf("-> %s:%d] ", intoa(ntohl(ip.ip_dst.s_addr)), h->extended_hdr.parsed_pkt.l4_dst_port);
- printf("[tos=%d][tcp_seq_num=%u][caplen=%d][len=%d][parsed_header_len=%d]"
+ printf("[hash=%u][tos=%d][tcp_seq_num=%u][caplen=%d][len=%d][parsed_header_len=%d]"
"[eth_offset=%d][l3_offset=%d][l4_offset=%d][payload_offset=%d]\n",
+ h->extended_hdr.pkt_hash,
h->extended_hdr.parsed_pkt.ipv4_tos, h->extended_hdr.parsed_pkt.tcp.seq_num,
h->caplen, h->len, h->extended_hdr.parsed_header_len,
h->extended_hdr.parsed_pkt.offset.eth_offset,
@@ -459,7 +460,7 @@
void printHelp(void) {
printf("pfcount\n(C) 2005-11 Deri Luca <deri@ntop.org>\n\n");
printf("-h Print this help\n");
- printf("-i <device> Device name. Use device@channel for channels, and dna:ethX for DNA\n");
+ printf("-i <device> Device name. Use ethX@Y for channels, dna:ethX for DNA, dag:dagX:Y for DAG cards\n");
printf("-n <threads> Number of polling threads (default %d)\n", num_threads);
/* printf("-f <filter> [pfring filter]\n"); */
@@ -837,7 +838,7 @@
bind2core(bind_core);
if(1) {
- pfring_loop(pd, dummyProcesssPacket, (u_char*)NULL);
+ pfring_loop(pd, dummyProcesssPacket, (u_char*)NULL, wait_for_packet);
} else
packet_consumer_thread(0);
|
[-]
[+]
|
Changed |
PF_RING-4.7.2.tar.bz2/userland/lib/Makefile.in
^
|
@@ -32,7 +32,7 @@
#
# Object files
#
-OBJS = pfring.o pfring_mod.o pfring_utils.o ${DNA_OBJS} ${VIRTUAL_OBJS} ${DAG_OBJS}
+OBJS = pfring.o pfring_mod_multi.o pfring_mod.o pfring_utils.o ${DNA_OBJS} ${VIRTUAL_OBJS} ${DAG_OBJS}
#
# C compiler and flags
|
[-]
[+]
|
Changed |
PF_RING-4.7.2.tar.bz2/userland/lib/configure
^
|
@@ -1,11 +1,11 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.65 for pfring.c 1.0.
+# Generated by GNU Autoconf 2.67 for pfring.c 1.0.
#
#
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
-# 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
-# Inc.
+# 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software
+# Foundation, Inc.
#
#
# This configure script is free software; the Free Software Foundation
@@ -316,7 +316,7 @@
test -d "$as_dir" && break
done
test -z "$as_dirs" || eval "mkdir $as_dirs"
- } || test -d "$as_dir" || as_fn_error "cannot create directory $as_dir"
+ } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir"
} # as_fn_mkdir_p
@@ -356,19 +356,19 @@
fi # as_fn_arith
-# as_fn_error ERROR [LINENO LOG_FD]
-# ---------------------------------
+# as_fn_error STATUS ERROR [LINENO LOG_FD]
+# ----------------------------------------
# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are
# provided, also output the error to LOG_FD, referencing LINENO. Then exit the
-# script with status $?, using 1 if that was 0.
+# script with STATUS, using 1 if that was 0.
as_fn_error ()
{
- as_status=$?; test $as_status -eq 0 && as_status=1
- if test "$3"; then
- as_lineno=${as_lineno-"$2"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
- $as_echo "$as_me:${as_lineno-$LINENO}: error: $1" >&$3
+ as_status=$1; test $as_status -eq 0 && as_status=1
+ if test "$4"; then
+ as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+ $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4
fi
- $as_echo "$as_me: error: $1" >&2
+ $as_echo "$as_me: error: $2" >&2
as_fn_exit $as_status
} # as_fn_error
@@ -530,7 +530,7 @@
exec 6>&1
# Name of the host.
-# hostname on some systems (SVR3.2, Linux) returns a bogus exit status,
+# hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status,
# so uname gets run too.
ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q`
@@ -599,6 +599,7 @@
VIRTUAL_OBJS
VIRTUAL_LIB
HAVE_VIRTUAL
+DAG_LIB
DNA_DEP
DNA_OBJS
DNA_LIB
@@ -726,8 +727,9 @@
fi
case $ac_option in
- *=*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;;
- *) ac_optarg=yes ;;
+ *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;;
+ *=) ac_optarg= ;;
+ *) ac_optarg=yes ;;
esac
# Accept the important Cygnus configure options, so we can diagnose typos.
@@ -772,7 +774,7 @@
ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'`
# Reject names that are not valid shell variable names.
expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
- as_fn_error "invalid feature name: $ac_useropt"
+ as_fn_error $? "invalid feature name: $ac_useropt"
ac_useropt_orig=$ac_useropt
ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
case $ac_user_opts in
@@ -798,7 +800,7 @@
ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'`
# Reject names that are not valid shell variable names.
expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
- as_fn_error "invalid feature name: $ac_useropt"
+ as_fn_error $? "invalid feature name: $ac_useropt"
ac_useropt_orig=$ac_useropt
ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
case $ac_user_opts in
@@ -1002,7 +1004,7 @@
ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'`
# Reject names that are not valid shell variable names.
expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
- as_fn_error "invalid package name: $ac_useropt"
+ as_fn_error $? "invalid package name: $ac_useropt"
ac_useropt_orig=$ac_useropt
ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
case $ac_user_opts in
@@ -1018,7 +1020,7 @@
ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'`
# Reject names that are not valid shell variable names.
expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
- as_fn_error "invalid package name: $ac_useropt"
+ as_fn_error $? "invalid package name: $ac_useropt"
ac_useropt_orig=$ac_useropt
ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
case $ac_user_opts in
@@ -1048,8 +1050,8 @@
| --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)
x_libraries=$ac_optarg ;;
- -*) as_fn_error "unrecognized option: \`$ac_option'
-Try \`$0 --help' for more information."
+ -*) as_fn_error $? "unrecognized option: \`$ac_option'
+Try \`$0 --help' for more information"
;;
*=*)
@@ -1057,7 +1059,7 @@
# Reject names that are not valid shell variable names.
case $ac_envvar in #(
'' | [0-9]* | *[!_$as_cr_alnum]* )
- as_fn_error "invalid variable name: \`$ac_envvar'" ;;
+ as_fn_error $? "invalid variable name: \`$ac_envvar'" ;;
esac
eval $ac_envvar=\$ac_optarg
export $ac_envvar ;;
@@ -1075,13 +1077,13 @@
if test -n "$ac_prev"; then
ac_option=--`echo $ac_prev | sed 's/_/-/g'`
- as_fn_error "missing argument to $ac_option"
+ as_fn_error $? "missing argument to $ac_option"
fi
if test -n "$ac_unrecognized_opts"; then
case $enable_option_checking in
no) ;;
- fatal) as_fn_error "unrecognized options: $ac_unrecognized_opts" ;;
+ fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;;
*) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;;
esac
fi
@@ -1104,7 +1106,7 @@
[\\/$]* | ?:[\\/]* ) continue;;
NONE | '' ) case $ac_var in *prefix ) continue;; esac;;
esac
- as_fn_error "expected an absolute directory name for --$ac_var: $ac_val"
+ as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val"
done
# There might be people who depend on the old broken behavior: `$host'
@@ -1118,8 +1120,8 @@
if test "x$host_alias" != x; then
if test "x$build_alias" = x; then
cross_compiling=maybe
- $as_echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host.
- If a cross compiler is detected then cross compile mode will be used." >&2
+ $as_echo "$as_me: WARNING: if you wanted to set the --build type, don't use --host.
+ If a cross compiler is detected then cross compile mode will be used" >&2
elif test "x$build_alias" != "x$host_alias"; then
cross_compiling=yes
fi
@@ -1134,9 +1136,9 @@
ac_pwd=`pwd` && test -n "$ac_pwd" &&
ac_ls_di=`ls -di .` &&
ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` ||
- as_fn_error "working directory cannot be determined"
+ as_fn_error $? "working directory cannot be determined"
test "X$ac_ls_di" = "X$ac_pwd_ls_di" ||
- as_fn_error "pwd does not report name of working directory"
+ as_fn_error $? "pwd does not report name of working directory"
# Find the source files, if location was not specified.
@@ -1175,11 +1177,11 @@
fi
if test ! -r "$srcdir/$ac_unique_file"; then
test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .."
- as_fn_error "cannot find sources ($ac_unique_file) in $srcdir"
+ as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir"
fi
ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work"
ac_abs_confdir=`(
- cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error "$ac_msg"
+ cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg"
pwd)`
# When building in place, set srcdir=.
if test "$ac_abs_confdir" = "$ac_pwd"; then
@@ -1219,7 +1221,7 @@
--help=short display options specific to this package
--help=recursive display the short help of all the included packages
-V, --version display version information and exit
- -q, --quiet, --silent do not print \`checking...' messages
+ -q, --quiet, --silent do not print \`checking ...' messages
--cache-file=FILE cache test results in FILE [disabled]
-C, --config-cache alias for \`--cache-file=config.cache'
-n, --no-create do not create output files
@@ -1347,9 +1349,9 @@
if $ac_init_version; then
cat <<\_ACEOF
pfring.c configure 1.0
-generated by GNU Autoconf 2.65
+generated by GNU Autoconf 2.67
-Copyright (C) 2009 Free Software Foundation, Inc.
+Copyright (C) 2010 Free Software Foundation, Inc.
This configure script is free software; the Free Software Foundation
gives unlimited permission to copy, distribute and modify it.
_ACEOF
@@ -1419,7 +1421,7 @@
mv -f conftest.er1 conftest.err
fi
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
- test $ac_status = 0; } >/dev/null && {
+ test $ac_status = 0; } > conftest.i && {
test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
test ! -s conftest.err
}; then :
@@ -1443,10 +1445,10 @@
ac_fn_c_check_header_mongrel ()
{
as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
- if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
+ if eval "test \"\${$3+set}\"" = set; then :
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
$as_echo_n "checking for $2... " >&6; }
-if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
+if eval "test \"\${$3+set}\"" = set; then :
$as_echo_n "(cached) " >&6
fi
eval ac_res=\$$3
@@ -1482,7 +1484,7 @@
else
ac_header_preproc=no
fi
-rm -f conftest.err conftest.$ac_ext
+rm -f conftest.err conftest.i conftest.$ac_ext
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5
$as_echo "$ac_header_preproc" >&6; }
@@ -1509,7 +1511,7 @@
esac
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
$as_echo_n "checking for $2... " >&6; }
-if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
+if eval "test \"\${$3+set}\"" = set; then :
$as_echo_n "(cached) " >&6
else
eval "$3=\$ac_header_compiler"
@@ -1573,7 +1575,7 @@
as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
$as_echo_n "checking for $2... " >&6; }
-if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
+if eval "test \"\${$3+set}\"" = set; then :
$as_echo_n "(cached) " >&6
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -1645,7 +1647,7 @@
running configure, to aid debugging if configure makes a mistake.
It was created by pfring.c $as_me 1.0, which was
-generated by GNU Autoconf 2.65. Invocation command line was
+generated by GNU Autoconf 2.67. Invocation command line was
$ $0 $@
@@ -1755,11 +1757,9 @@
{
echo
- cat <<\_ASBOX
-## ---------------- ##
+ $as_echo "## ---------------- ##
## Cache variables. ##
-## ---------------- ##
-_ASBOX
+## ---------------- ##"
echo
# The following way of writing the cache mishandles newlines in values,
(
@@ -1793,11 +1793,9 @@
)
echo
- cat <<\_ASBOX
-## ----------------- ##
+ $as_echo "## ----------------- ##
## Output variables. ##
-## ----------------- ##
-_ASBOX
+## ----------------- ##"
echo
for ac_var in $ac_subst_vars
do
@@ -1810,11 +1808,9 @@
echo
if test -n "$ac_subst_files"; then
- cat <<\_ASBOX
-## ------------------- ##
+ $as_echo "## ------------------- ##
## File substitutions. ##
-## ------------------- ##
-_ASBOX
+## ------------------- ##"
echo
for ac_var in $ac_subst_files
do
@@ -1828,11 +1824,9 @@
fi
if test -s confdefs.h; then
- cat <<\_ASBOX
-## ----------- ##
+ $as_echo "## ----------- ##
## confdefs.h. ##
-## ----------- ##
-_ASBOX
+## ----------- ##"
echo
cat confdefs.h
echo
@@ -1887,7 +1881,12 @@
ac_site_file1=NONE
ac_site_file2=NONE
if test -n "$CONFIG_SITE"; then
- ac_site_file1=$CONFIG_SITE
+ # We do not want a PATH search for config.site.
+ case $CONFIG_SITE in #((
+ -*) ac_site_file1=./$CONFIG_SITE;;
+ */*) ac_site_file1=$CONFIG_SITE;;
+ *) ac_site_file1=./$CONFIG_SITE;;
+ esac
elif test "x$prefix" != xNONE; then
ac_site_file1=$prefix/share/config.site
ac_site_file2=$prefix/etc/config.site
@@ -1902,7 +1901,11 @@
{ $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5
$as_echo "$as_me: loading site script $ac_site_file" >&6;}
sed 's/^/| /' "$ac_site_file" >&5
- . "$ac_site_file"
+ . "$ac_site_file" \
+ || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "failed to load site script $ac_site_file
+See \`config.log' for more details" "$LINENO" 5 ; }
fi
done
@@ -1978,7 +1981,7 @@
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
{ $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5
$as_echo "$as_me: error: changes in the environment can compromise the build" >&2;}
- as_fn_error "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5
+ as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5
fi
## -------------------- ##
## Main body of script. ##
@@ -2292,8 +2295,8 @@
test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error "no acceptable C compiler found in \$PATH
-See \`config.log' for more details." "$LINENO" 5; }
+as_fn_error $? "no acceptable C compiler found in \$PATH
+See \`config.log' for more details" "$LINENO" 5 ; }
# Provide some information about the compiler.
$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5
@@ -2407,9 +2410,8 @@
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-{ as_fn_set_status 77
-as_fn_error "C compiler cannot create executables
-See \`config.log' for more details." "$LINENO" 5; }; }
+as_fn_error 77 "C compiler cannot create executables
+See \`config.log' for more details" "$LINENO" 5 ; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
@@ -2451,8 +2453,8 @@
else
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error "cannot compute suffix of executables: cannot compile and link
-See \`config.log' for more details." "$LINENO" 5; }
+as_fn_error $? "cannot compute suffix of executables: cannot compile and link
+See \`config.log' for more details" "$LINENO" 5 ; }
fi
rm -f conftest conftest$ac_cv_exeext
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5
@@ -2509,9 +2511,9 @@
else
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error "cannot run C compiled programs.
+as_fn_error $? "cannot run C compiled programs.
If you meant to cross compile, use \`--host'.
-See \`config.log' for more details." "$LINENO" 5; }
+See \`config.log' for more details" "$LINENO" 5 ; }
fi
fi
fi
@@ -2562,8 +2564,8 @@
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error "cannot compute suffix of object files: cannot compile
-See \`config.log' for more details." "$LINENO" 5; }
+as_fn_error $? "cannot compute suffix of object files: cannot compile
+See \`config.log' for more details" "$LINENO" 5 ; }
fi
rm -f conftest.$ac_cv_objext conftest.$ac_ext
fi
@@ -2830,7 +2832,7 @@
# Broken: fails on valid input.
continue
fi
-rm -f conftest.err conftest.$ac_ext
+rm -f conftest.err conftest.i conftest.$ac_ext
# OK, works on sane cases. Now check whether nonexistent headers
# can be detected and how.
@@ -2846,11 +2848,11 @@
ac_preproc_ok=:
break
fi
-rm -f conftest.err conftest.$ac_ext
+rm -f conftest.err conftest.i conftest.$ac_ext
done
# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
-rm -f conftest.err conftest.$ac_ext
+rm -f conftest.i conftest.err conftest.$ac_ext
if $ac_preproc_ok; then :
break
fi
@@ -2889,7 +2891,7 @@
# Broken: fails on valid input.
continue
fi
-rm -f conftest.err conftest.$ac_ext
+rm -f conftest.err conftest.i conftest.$ac_ext
# OK, works on sane cases. Now check whether nonexistent headers
# can be detected and how.
@@ -2905,18 +2907,18 @@
ac_preproc_ok=:
break
fi
-rm -f conftest.err conftest.$ac_ext
+rm -f conftest.err conftest.i conftest.$ac_ext
done
# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
-rm -f conftest.err conftest.$ac_ext
+rm -f conftest.i conftest.err conftest.$ac_ext
if $ac_preproc_ok; then :
else
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error "C preprocessor \"$CPP\" fails sanity check
-See \`config.log' for more details." "$LINENO" 5; }
+as_fn_error $? "C preprocessor \"$CPP\" fails sanity check
+See \`config.log' for more details" "$LINENO" 5 ; }
fi
ac_ext=c
@@ -2977,7 +2979,7 @@
done
IFS=$as_save_IFS
if test -z "$ac_cv_path_GREP"; then
- as_fn_error "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
+ as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
fi
else
ac_cv_path_GREP=$GREP
@@ -3043,7 +3045,7 @@
done
IFS=$as_save_IFS
if test -z "$ac_cv_path_EGREP"; then
- as_fn_error "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
+ as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
fi
else
ac_cv_path_EGREP=$EGREP
@@ -3175,8 +3177,7 @@
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default
"
-eval as_val=\$$as_ac_Header
- if test "x$as_val" = x""yes; then :
+if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
cat >>confdefs.h <<_ACEOF
#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
_ACEOF
@@ -3272,7 +3273,7 @@
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dag_dag_get_stream_erf_types" >&5
$as_echo "$ac_cv_lib_dag_dag_get_stream_erf_types" >&6; }
if test "x$ac_cv_lib_dag_dag_get_stream_erf_types" = x""yes; then :
- HAVE_DAG="-D HAVE_DAG"; DAG_OBJS="pfring_mod_dag.o"
+ HAVE_DAG="-D HAVE_DAG"; DAG_OBJS="pfring_mod_dag.o"; DAG_LIB="-L/usr/local/lib -ldag"
fi
@@ -3299,6 +3300,10 @@
+
+ac_config_files="$ac_config_files ../examples/Makefile"
+
+
cat >confcache <<\_ACEOF
# This file is a shell script that caches the results of configure
# tests run on this system so they can be shared between configure
@@ -3418,6 +3423,7 @@
ac_libobjs=
ac_ltlibobjs=
+U=
for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue
# 1. Remove the extension, and $U if already installed.
ac_script='s/\$U\././;s/\.o$//;s/\.obj$//'
@@ -3579,19 +3585,19 @@
(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
-# as_fn_error ERROR [LINENO LOG_FD]
-# ---------------------------------
+# as_fn_error STATUS ERROR [LINENO LOG_FD]
+# ----------------------------------------
# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are
# provided, also output the error to LOG_FD, referencing LINENO. Then exit the
-# script with status $?, using 1 if that was 0.
+# script with STATUS, using 1 if that was 0.
as_fn_error ()
{
- as_status=$?; test $as_status -eq 0 && as_status=1
- if test "$3"; then
- as_lineno=${as_lineno-"$2"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
- $as_echo "$as_me:${as_lineno-$LINENO}: error: $1" >&$3
+ as_status=$1; test $as_status -eq 0 && as_status=1
+ if test "$4"; then
+ as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+ $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4
fi
- $as_echo "$as_me: error: $1" >&2
+ $as_echo "$as_me: error: $2" >&2
as_fn_exit $as_status
} # as_fn_error
@@ -3787,7 +3793,7 @@
test -d "$as_dir" && break
done
test -z "$as_dirs" || eval "mkdir $as_dirs"
- } || test -d "$as_dir" || as_fn_error "cannot create directory $as_dir"
+ } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir"
} # as_fn_mkdir_p
@@ -3841,7 +3847,7 @@
# values after options handling.
ac_log="
This file was extended by pfring.c $as_me 1.0, which was
-generated by GNU Autoconf 2.65. Invocation command line was
+generated by GNU Autoconf 2.67. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
CONFIG_HEADERS = $CONFIG_HEADERS
@@ -3894,10 +3900,10 @@
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
pfring.c config.status 1.0
-configured by $0, generated by GNU Autoconf 2.65,
+configured by $0, generated by GNU Autoconf 2.67,
with options \\"\$ac_cs_config\\"
-Copyright (C) 2009 Free Software Foundation, Inc.
+Copyright (C) 2010 Free Software Foundation, Inc.
This config.status script is free software; the Free Software Foundation
gives unlimited permission to copy, distribute and modify it."
@@ -3912,11 +3918,16 @@
while test $# != 0
do
case $1 in
- --*=*)
+ --*=?*)
ac_option=`expr "X$1" : 'X\([^=]*\)='`
ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'`
ac_shift=:
;;
+ --*=)
+ ac_option=`expr "X$1" : 'X\([^=]*\)='`
+ ac_optarg=
+ ac_shift=:
+ ;;
*)
ac_option=$1
ac_optarg=$2
@@ -3938,6 +3949,7 @@
$ac_shift
case $ac_optarg in
*\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;;
+ '') as_fn_error $? "missing file argument" ;;
esac
as_fn_append CONFIG_FILES " '$ac_optarg'"
ac_need_defaults=false;;
@@ -3948,7 +3960,7 @@
ac_cs_silent=: ;;
# This is an error.
- -*) as_fn_error "unrecognized option: \`$1'
+ -*) as_fn_error $? "unrecognized option: \`$1'
Try \`$0 --help' for more information." ;;
*) as_fn_append ac_config_targets " $1"
@@ -3998,8 +4010,9 @@
do
case $ac_config_target in
"Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
+ "../examples/Makefile") CONFIG_FILES="$CONFIG_FILES ../examples/Makefile" ;;
- *) as_fn_error "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
+ *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5 ;;
esac
done
@@ -4035,7 +4048,7 @@
{
tmp=./conf$$-$RANDOM
(umask 077 && mkdir "$tmp")
-} || as_fn_error "cannot create a temporary directory in ." "$LINENO" 5
+} || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5
# Set up the scripts for CONFIG_FILES section.
# No need to generate them if there are no CONFIG_FILES.
@@ -4052,7 +4065,7 @@
fi
ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' </dev/null 2>/dev/null`
if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then
- ac_cs_awk_cr='\r'
+ ac_cs_awk_cr='\\r'
else
ac_cs_awk_cr=$ac_cr
fi
@@ -4066,18 +4079,18 @@
echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' &&
echo "_ACEOF"
} >conf$$subs.sh ||
- as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5
-ac_delim_num=`echo "$ac_subst_vars" | grep -c '$'`
+ as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5
+ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'`
ac_delim='%!_!# '
for ac_last_try in false false false false false :; do
. ./conf$$subs.sh ||
- as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5
+ as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5
ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X`
if test $ac_delim_n = $ac_delim_num; then
break
elif $ac_last_try; then
- as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5
+ as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5
else
ac_delim="$ac_delim!$ac_delim _$ac_delim!! "
fi
@@ -4166,20 +4179,28 @@
else
cat
fi < "$tmp/subs1.awk" > "$tmp/subs.awk" \
- || as_fn_error "could not setup config files machinery" "$LINENO" 5
+ || as_fn_error $? "could not setup config files machinery" "$LINENO" 5
_ACEOF
-# VPATH may cause trouble with some makes, so we remove $(srcdir),
-# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and
+# VPATH may cause trouble with some makes, so we remove sole $(srcdir),
+# ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and
# trailing colons and then remove the whole line if VPATH becomes empty
# (actually we leave an empty line to preserve line numbers).
if test "x$srcdir" = x.; then
- ac_vpsub='/^[ ]*VPATH[ ]*=/{
-s/:*\$(srcdir):*/:/
-s/:*\${srcdir}:*/:/
-s/:*@srcdir@:*/:/
-s/^\([^=]*=[ ]*\):*/\1/
+ ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{
+h
+s///
+s/^/:/
+s/[ ]*$/:/
+s/:\$(srcdir):/:/g
+s/:\${srcdir}:/:/g
+s/:@srcdir@:/:/g
+s/^:*//
s/:*$//
+x
+s/\(=[ ]*\).*/\1/
+G
+s/\n//
s/^[^=]*=[ ]*$//
}'
fi
@@ -4197,7 +4218,7 @@
esac
case $ac_mode$ac_tag in
:[FHL]*:*);;
- :L* | :C*:*) as_fn_error "invalid tag \`$ac_tag'" "$LINENO" 5;;
+ :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5 ;;
:[FH]-) ac_tag=-:-;;
:[FH]*) ac_tag=$ac_tag:$ac_tag.in;;
esac
@@ -4225,7 +4246,7 @@
[\\/$]*) false;;
*) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";;
esac ||
- as_fn_error "cannot find input file: \`$ac_f'" "$LINENO" 5;;
+ as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5 ;;
esac
case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac
as_fn_append ac_file_inputs " '$ac_f'"
@@ -4252,7 +4273,7 @@
case $ac_tag in
*:-:* | *:-) cat >"$tmp/stdin" \
- || as_fn_error "could not create $ac_file" "$LINENO" 5 ;;
+ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;;
esac
;;
esac
@@ -4378,22 +4399,22 @@
$ac_datarootdir_hack
"
eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$tmp/subs.awk" >$tmp/out \
- || as_fn_error "could not create $ac_file" "$LINENO" 5
+ || as_fn_error $? "could not create $ac_file" "$LINENO" 5
test -z "$ac_datarootdir_hack$ac_datarootdir_seen" &&
{ ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } &&
{ ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } &&
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir'
-which seems to be undefined. Please make sure it is defined." >&5
+which seems to be undefined. Please make sure it is defined" >&5
$as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir'
-which seems to be undefined. Please make sure it is defined." >&2;}
+which seems to be undefined. Please make sure it is defined" >&2;}
rm -f "$tmp/stdin"
case $ac_file in
-) cat "$tmp/out" && rm -f "$tmp/out";;
*) rm -f "$ac_file" && mv "$tmp/out" "$ac_file";;
esac \
- || as_fn_error "could not create $ac_file" "$LINENO" 5
+ || as_fn_error $? "could not create $ac_file" "$LINENO" 5
;;
@@ -4408,7 +4429,7 @@
ac_clean_files=$ac_clean_files_save
test $ac_write_fail = 0 ||
- as_fn_error "write failure creating $CONFIG_STATUS" "$LINENO" 5
+ as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5
# configure is writing to config.log, and then calls config.status.
@@ -4429,7 +4450,7 @@
exec 5>>config.log
# Use ||, not &&, to avoid exiting from the if with $? = 1, which
# would make configure fail if this is the last instruction.
- $ac_cs_success || as_fn_exit $?
+ $ac_cs_success || as_fn_exit 1
fi
if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5
|
[-]
[+]
|
Changed |
PF_RING-4.7.2.tar.bz2/userland/lib/configure.in
^
|
@@ -38,7 +38,7 @@
AC_CHECK_LIB( [dag],
[dag_get_stream_erf_types],
- [HAVE_DAG="-D HAVE_DAG"; DAG_OBJS="pfring_mod_dag.o"],
+ [HAVE_DAG="-D HAVE_DAG"; DAG_OBJS="pfring_mod_dag.o"; DAG_LIB="-L/usr/local/lib -ldag"],
[], [] )
if test "x$ac_cv_header_linux_net_tstamp_h" = x""yes; then :
@@ -56,6 +56,7 @@
AC_SUBST(DNA_LIB)
AC_SUBST(DNA_OBJS)
AC_SUBST(DNA_DEP)
+AC_SUBST(DAG_LIB)
AC_SUBST(HAVE_VIRTUAL)
AC_SUBST(VIRTUAL_LIB)
AC_SUBST(VIRTUAL_OBJS)
@@ -64,4 +65,7 @@
AC_SUBST(DAG_OBJS)
AC_SUBST(INSTALL_PREFIX)
+dnl>AC_CONFIG_FILES([Makefile])
+AC_CONFIG_FILES([../examples/Makefile])
+
AC_OUTPUT
|
|
Changed |
PF_RING-4.7.2.tar.bz2/userland/lib/libs/libpfring_dna_i686.a
^
|
|
Changed |
PF_RING-4.7.2.tar.bz2/userland/lib/libs/libpfring_dna_x86_64.a
^
|
[-]
[+]
|
Changed |
PF_RING-4.7.2.tar.bz2/userland/lib/pfring.c
^
|
@@ -25,6 +25,7 @@
/* ********************************* */
#include "pfring_mod.h"
+#include "pfring_mod_multi.h"
#ifdef HAVE_DAG
#include "pfring_mod_dag.h"
@@ -39,6 +40,10 @@
#endif
static pfring_module_info pfring_module_list[] = {
+ { /* usually you don't need to specify this */
+ .name = "default",
+ .open = pfring_mod_open,
+ },
#ifdef HAVE_VIRTUAL
{ /* vPF_RING (guest-side) */
.name = "host",
@@ -57,6 +62,10 @@
.open = pfring_dna_open,
},
#endif
+ {
+ .name = "multi",
+ .open = pfring_mod_multi_open,
+ },
{0}
};
@@ -268,7 +277,8 @@
/* **************************************************** */
-int pfring_loop(pfring *ring, pfringProcesssPacket looper, const u_char *user_bytes) {
+int pfring_loop(pfring *ring, pfringProcesssPacket looper,
+ const u_char *user_bytes, u_int8_t wait_for_packet) {
u_char *buffer = NULL;
struct pfring_pkthdr hdr;
int rc = 0;
@@ -279,11 +289,14 @@
ring->break_recv_loop = 0;
while(!ring->break_recv_loop) {
- rc = pfring_recv(ring, &buffer, 0, &hdr, 1);
+ rc = pfring_recv(ring, &buffer, 0, &hdr, wait_for_packet);
if(rc < 0)
break;
else if(rc > 0)
looper(&hdr, buffer, user_bytes);
+ else {
+ if(!wait_for_packet) usleep(1);
+ }
}
return(rc);
@@ -671,3 +684,13 @@
/* **************************************************** */
+int pfring_is_pkt_available(pfring *ring){
+ if(ring && ring->is_pkt_available) {
+ return ring->is_pkt_available(ring);
+ }
+
+ return -1;
+}
+
+
+
|
[-]
[+]
|
Changed |
PF_RING-4.7.2.tar.bz2/userland/lib/pfring.h
^
|
@@ -127,9 +127,10 @@
/* DNA (Direct NIC Access) */
u_char dna_mapped_device;
u_int16_t num_rx_pkts_before_dns_sync, num_tx_pkts_before_dns_sync, dna_sync_watermark;
- u_int32_t tot_dna_read_pkts, rx_reg, tx_reg, last_rx_slot_read;
+ u_int64_t tot_dna_read_pkts, tot_dna_lost_pkts;
+ u_int32_t rx_reg, tx_reg, last_rx_slot_read;
dna_device dna_dev;
- u_int32_t *rx_reg_ptr, *tx_reg_ptr, *mpc_reg_ptr;
+ u_int32_t *rx_reg_ptr, *tx_reg_ptr, *mpc_reg_ptr, *qprdc_reg_ptr, *rnbc_reg_ptr;
dna_device_operation last_dna_operation;
void *priv_data; /* module private data */
@@ -166,6 +167,7 @@
int (*toggle_filtering_policy) (pfring *, u_int8_t);
int (*enable_rss_rehash) (pfring *);
int (*poll) (pfring *, u_int);
+ int (*is_pkt_available) (pfring *);
int (*version) (pfring *, u_int32_t *);
int (*get_bound_device_address) (pfring *, u_char [6]);
u_int16_t (*get_slot_header_len) (pfring *);
@@ -210,7 +212,8 @@
void pfring_shutdown(pfring *ring);
void pfring_config(u_short cpu_percentage);
- int pfring_loop(pfring *ring, pfringProcesssPacket looper, const u_char *user_bytes);
+ int pfring_loop(pfring *ring, pfringProcesssPacket looper,
+ const u_char *user_bytes, u_int8_t wait_for_packet);
void pfring_breakloop(pfring *);
void pfring_close(pfring *ring);
@@ -253,6 +256,7 @@
int pfring_toggle_filtering_policy(pfring *ring, u_int8_t rules_default_accept_policy);
int pfring_enable_rss_rehash(pfring *ring);
int pfring_poll(pfring *ring, u_int wait_duration);
+ int pfring_is_pkt_available(pfring *ring);
int pfring_version(pfring *ring, u_int32_t *version);
int pfring_get_bound_device_address(pfring *ring, u_char mac_address[6]);
u_int16_t pfring_get_slot_header_len(pfring *ring);
|
[-]
[+]
|
Changed |
PF_RING-4.7.2.tar.bz2/userland/lib/pfring_mod.c
^
|
@@ -98,6 +98,12 @@
}
/* **************************************************** */
+
+int pfring_mod_is_pkt_available(pfring *ring) {
+ return(pfring_there_is_pkt_available(ring));
+}
+
+/* **************************************************** */
/* Functions part of the "specialized" subset */
/* **************************************************** */
@@ -145,6 +151,7 @@
ring->loopback_test = pfring_mod_loopback_test;
ring->enable_ring = pfring_mod_enable_ring;
ring->disable_ring = pfring_mod_disable_ring;
+ ring->is_pkt_available = pfring_mod_is_pkt_available;
ring->poll_duration = DEFAULT_POLL_DURATION;
ring->fd = socket(PF_RING, SOCK_RAW, htons(ETH_P_ALL));
@@ -549,19 +556,23 @@
/* **************************************************** */
int pfring_mod_poll(pfring *ring, u_int wait_duration) {
- struct pollfd pfd;
- int rc;
-
- /* Sleep when nothing is happening */
- pfd.fd = ring->fd;
- pfd.events = POLLIN /* | POLLERR */;
- pfd.revents = 0;
- errno = 0;
-
- rc = poll(&pfd, 1, wait_duration);
- ring->num_poll_calls++;
-
- return(rc);
+ if(wait_duration == 0)
+ return(ring->is_pkt_available(ring));
+ else {
+ struct pollfd pfd;
+ int rc;
+
+ /* Sleep when nothing is happening */
+ pfd.fd = ring->fd;
+ pfd.events = POLLIN /* | POLLERR */;
+ pfd.revents = 0;
+ errno = 0;
+
+ rc = poll(&pfd, 1, wait_duration);
+ ring->num_poll_calls++;
+
+ return(rc);
+ }
}
/* **************************************************** */
@@ -655,7 +666,7 @@
/* **************************************************** */
int pfring_mod_enable_ring(pfring *ring) {
- char dummy;
+ char dummy = 0;
return(setsockopt(ring->fd, 0, SO_ACTIVATE_RING, &dummy, sizeof(dummy)));
}
|
[-]
[+]
|
Changed |
PF_RING-4.7.2.tar.bz2/userland/lib/pfring_mod_dag.c
^
|
@@ -13,6 +13,7 @@
#include "pfring_mod_dag.h"
+
//#define DAG_DEBUG
int pfring_dag_open(pfring *ring) {
@@ -25,11 +26,16 @@
uint8_t stream_erf_types[MAX_CARD_ERF_TYPES];
uint8_t supported = 0;
- ring->close = pfring_dag_close;
- ring->stats = pfring_dag_stats;
- ring->recv = pfring_dag_recv;
+#ifdef DAG_DEBUG
+ printf("[PF_RING] DAG open\n");
+#endif
+
+ ring->close = pfring_dag_close;
+ ring->stats = pfring_dag_stats;
+ ring->recv = pfring_dag_recv;
ring->set_poll_watermark = pfring_dag_set_poll_watermark;
ring->set_poll_duration = pfring_dag_set_poll_duration;
+ ring->poll = pfring_dag_poll;
ring->set_direction = pfring_dag_set_direction;
ring->enable_ring = pfring_dag_enable_ring;
@@ -149,11 +155,12 @@
/* **************************************************** */
void pfring_dag_close(pfring *ring) {
-
+ pfring_dag *d;
+
if(ring->priv_data == NULL)
return;
- pfring_dag *d = (pfring_dag *) ring->priv_data;
+ d = (pfring_dag *) ring->priv_data;
dag_stop_stream(d->fd, d->stream_num);
dag_detach_stream(d->fd, d->stream_num);
@@ -176,11 +183,16 @@
uint32_t len;
unsigned long long ts;
int retval = 0;
+ pfring_dag *d;
+
+#ifdef DAG_DEBUG
+ printf("[PF_RING] DAG recv\n");
+#endif
if(ring->priv_data == NULL)
return -1;
- pfring_dag *d = (pfring_dag *) ring->priv_data;
+ d = (pfring_dag *) ring->priv_data;
if(ring->reentrant)
pthread_spin_lock(&ring->spinlock);
@@ -228,6 +240,9 @@
d->stats_drop += ntohs(erf_hdr->lctr);
}
break;
+ /* Note:
+ * In TYPE_COLOR_HASH_ETH, TYPE_DSM_COLOR_ETH, TYPE_COLOR_ETH
+ * the color value overwrites the lctr */
default:
break;
}
@@ -251,6 +266,12 @@
case TYPE_COLOR_HASH_ETH:
case TYPE_DSM_COLOR_ETH:
case TYPE_COLOR_ETH:
+#ifdef READ_DAG_STREAM_COLOR
+ /*Note:
+ * In TYPE_COLOR_HASH_ETH, TYPE_DSM_COLOR_ETH, TYPE_COLOR_ETH
+ * the color value overwrites the lctr */
+ hdr->extended_hdr.pkt_hash /* 32bit */ = erf_hdr->lctr /* 16bit */;
+#endif
case TYPE_ETH:
len = ntohs(erf_hdr->wlen);
@@ -302,6 +323,14 @@
hdr->ts.tv_sec++;
}
+ /* compute pf_ring timestamp_ns from ERF time stamp */
+ ts = erf_hdr->ts;
+ ts = (ts & 0xffffffffULL) * 1000000000;
+ ts += 0x80000000;
+ ts >>= 32;
+ ts += ((erf_hdr->ts >> 32) * 1000000000);
+ hdr->extended_hdr.timestamp_ns = ts;
+
#ifdef PFRING_DAG_PARSE_PKT
parse_pkt(*buffer, hdr);
#else
@@ -326,11 +355,12 @@
uint32_t mindata;
struct timeval maxwait;
struct timeval poll;
+ pfring_dag *d;
if(ring->priv_data == NULL)
return -1;
- pfring_dag *d = (pfring_dag *) ring->priv_data;
+ d = (pfring_dag *) ring->priv_data;
if (dag_get_stream_poll(d->fd, d->stream_num, &mindata, &maxwait, &poll) < 0) {
fprintf(stderr, "Error getting poll info\n");
@@ -353,11 +383,12 @@
uint32_t mindata;
struct timeval maxwait;
struct timeval poll;
+ pfring_dag *d;
if(ring->priv_data == NULL)
return -1;
- pfring_dag *d = (pfring_dag *) ring->priv_data;
+ d = (pfring_dag *) ring->priv_data;
if (dag_get_stream_poll(d->fd, d->stream_num, &mindata, &maxwait, &poll) < 0) {
fprintf(stderr, "Error getting poll info\n");
@@ -380,11 +411,12 @@
/* **************************************************** */
int pfring_dag_stats(pfring *ring, pfring_stat *stats) {
+ pfring_dag *d;
if(ring->priv_data == NULL)
return -1;
- pfring_dag *d = (pfring_dag *) ring->priv_data;
+ d = (pfring_dag *) ring->priv_data;
stats->recv = d->stats_recv;
stats->drop = d->stats_drop;
@@ -409,3 +441,25 @@
return 0;
}
+/* **************************************************** */
+
+int pfring_dag_poll(pfring *ring, u_int wait_duration) {
+ pfring_dag *d;
+
+ if(ring->priv_data == NULL)
+ return -1;
+
+ d = (pfring_dag *) ring->priv_data;
+
+ if ((d->top - d->bottom) >= dag_record_size)
+ return 1;
+
+ if ( (d->top = dag_advance_stream(d->fd, d->stream_num, (void * /* but it is void** */) &d->bottom)) == NULL)
+ return -1;
+
+ if ( (d->top - d->bottom) < dag_record_size )
+ return 0;
+
+ return 1;
+}
+
|
[-]
[+]
|
Changed |
PF_RING-4.7.2.tar.bz2/userland/lib/pfring_mod_dag.h
^
|
@@ -15,11 +15,13 @@
#define _PFRING_MOD_DAG_H_
#include "pfring.h"
-
#include "dagapi.h"
+#include <limits.h>
/* #define PFRING_DAG_PARSE_PKT */
+#define READ_DAG_STREAM_COLOR
+
#define MAX_CARD_ERF_TYPES 255
#define AVG_PACKET_SIZE 512
@@ -46,6 +48,7 @@
int pfring_dag_recv (pfring *ring, u_char** buffer, u_int buffer_len, struct pfring_pkthdr *hdr, u_int8_t wait_for_incoming_packet);
int pfring_dag_set_poll_watermark(pfring *ring, u_int16_t watermark);
int pfring_dag_set_poll_duration(pfring *ring, u_int duration);
+int pfring_dag_poll(pfring *ring, u_int wait_duration);
int pfring_dag_set_direction(pfring *ring, packet_direction direction);
int pfring_dag_enable_ring(pfring *ring);
|
[-]
[+]
|
Changed |
PF_RING-4.7.2.tar.bz2/userland/lib/pfring_mod_dna.c
^
|
@@ -40,6 +40,7 @@
} else
ring->last_dna_operation = operation;
+ memset(&mapping, 0, sizeof(mapping));
mapping.operation = operation;
snprintf(mapping.device_name, sizeof(mapping.device_name),
"%s", device_name);
@@ -52,27 +53,28 @@
/* **************************************************** */
void pfring_dna_close(pfring *ring) {
-
if(ring->dna_term)
ring->dna_term(ring);
if(ring->dna_dev.rx_packet_memory != 0)
munmap((void*)ring->dna_dev.rx_packet_memory,
- ring->dna_dev.packet_memory_tot_len);
+ ring->dna_dev.mem_info.packet_memory_tot_len);
if(ring->dna_dev.rx_descr_packet_memory != NULL)
- munmap(ring->dna_dev.rx_descr_packet_memory, ring->dna_dev.descr_packet_memory_tot_len);
+ munmap(ring->dna_dev.rx_descr_packet_memory,
+ ring->dna_dev.mem_info.descr_packet_memory_tot_len);
if(ring->dna_dev.tx_packet_memory != 0)
munmap((void*)ring->dna_dev.tx_packet_memory,
- ring->dna_dev.packet_memory_tot_len);
+ ring->dna_dev.mem_info.packet_memory_tot_len);
if(ring->dna_dev.tx_descr_packet_memory != NULL)
- munmap(ring->dna_dev.tx_descr_packet_memory, ring->dna_dev.descr_packet_memory_tot_len);
+ munmap(ring->dna_dev.tx_descr_packet_memory,
+ ring->dna_dev.mem_info.descr_packet_memory_tot_len);
if(ring->dna_dev.phys_card_memory != NULL)
munmap(ring->dna_dev.phys_card_memory,
- ring->dna_dev.phys_card_memory_len);
+ ring->dna_dev.mem_info.phys_card_memory_len);
pfring_map_dna_device(ring, remove_device_mapping, "");
@@ -95,7 +97,7 @@
struct pfring_pkthdr *hdr,
u_int8_t wait_for_incoming_packet) {
u_char *pkt = NULL;
- int8_t status = 1;
+ int8_t status = 0;
if(ring->is_shutting_down) return(-1);
@@ -123,10 +125,10 @@
if(wait_for_incoming_packet) {
status = ring->dna_check_packet_to_read(ring, wait_for_incoming_packet);
- }
- if(status > 0)
- goto redo_pfring_recv;
+ if(status > 0)
+ goto redo_pfring_recv;
+ }
if(ring->reentrant) pthread_spin_unlock(&ring->spinlock);
return(0);
@@ -140,7 +142,8 @@
if(dev == NULL)
return(-1);
else
- return(getsockopt(ring->fd, 0, SO_GET_MAPPED_DNA_DEVICE, dev, &len));
+ return(getsockopt(ring->fd, 0, SO_GET_MAPPED_DNA_DEVICE,
+ &dev->mem_info, &len));
}
/* **************************************************** */
@@ -236,7 +239,7 @@
rc = pfring_get_mapped_dna_device(ring, &ring->dna_dev);
- if (rc < 0) {
+ if(rc < 0) {
printf("pfring_get_mapped_dna_device() failed [rc=%d]\n", rc);
pfring_map_dna_device(ring, remove_device_mapping, ring->device_name);
close(ring->fd);
@@ -259,9 +262,9 @@
/* ***************************************** */
- if (ring->dna_dev.packet_memory_tot_len > 0){
+ if(ring->dna_dev.mem_info.packet_memory_tot_len > 0) {
ring->dna_dev.rx_packet_memory =
- (unsigned long)mmap(NULL, ring->dna_dev.packet_memory_tot_len,
+ (unsigned long)mmap(NULL, ring->dna_dev.mem_info.packet_memory_tot_len,
PROT_READ|PROT_WRITE, MAP_SHARED, ring->fd, 1*getpagesize());
if(ring->dna_dev.rx_packet_memory == (unsigned long)MAP_FAILED) {
@@ -273,9 +276,9 @@
/* ***************************************** */
- if (ring->dna_dev.descr_packet_memory_tot_len > 0){
+ if(ring->dna_dev.mem_info.descr_packet_memory_tot_len > 0) {
ring->dna_dev.rx_descr_packet_memory =
- (void*)mmap(NULL, ring->dna_dev.descr_packet_memory_tot_len,
+ (void*)mmap(NULL, ring->dna_dev.mem_info.descr_packet_memory_tot_len,
PROT_READ|PROT_WRITE, MAP_SHARED, ring->fd, 2*getpagesize());
if(ring->dna_dev.rx_descr_packet_memory == MAP_FAILED) {
@@ -287,10 +290,10 @@
/* ***************************************** */
- if (ring->dna_dev.phys_card_memory_len > 0) {
+ if(ring->dna_dev.mem_info.phys_card_memory_len > 0) {
/* some DNA drivers do not use this memory */
ring->dna_dev.phys_card_memory =
- (void*)mmap(NULL, ring->dna_dev.phys_card_memory_len,
+ (void*)mmap(NULL, ring->dna_dev.mem_info.phys_card_memory_len,
PROT_READ|PROT_WRITE, MAP_SHARED, ring->fd, 3*getpagesize());
if(ring->dna_dev.phys_card_memory == MAP_FAILED) {
@@ -300,12 +303,11 @@
}
}
-
/* ***************************************** */
- if (ring->dna_dev.packet_memory_tot_len > 0){
+ if(ring->dna_dev.mem_info.packet_memory_tot_len > 0) {
ring->dna_dev.tx_packet_memory =
- (unsigned long)mmap(NULL, ring->dna_dev.packet_memory_tot_len,
+ (unsigned long)mmap(NULL, ring->dna_dev.mem_info.packet_memory_tot_len,
PROT_READ|PROT_WRITE, MAP_SHARED, ring->fd, 4*getpagesize());
if(ring->dna_dev.tx_packet_memory == (unsigned long)MAP_FAILED) {
@@ -317,9 +319,9 @@
/* ***************************************** */
- if (ring->dna_dev.descr_packet_memory_tot_len > 0){
+ if(ring->dna_dev.mem_info.descr_packet_memory_tot_len > 0) {
ring->dna_dev.tx_descr_packet_memory =
- (void*)mmap(NULL, ring->dna_dev.descr_packet_memory_tot_len,
+ (void*)mmap(NULL, ring->dna_dev.mem_info.descr_packet_memory_tot_len,
PROT_READ|PROT_WRITE, MAP_SHARED, ring->fd, 5*getpagesize());
if(ring->dna_dev.tx_descr_packet_memory == MAP_FAILED) {
@@ -336,10 +338,12 @@
ring->clear_promisc = 1;
}
- if(dna_init(ring, sizeof(pfring)) == -1) {
+ rc = dna_init(ring, sizeof(pfring));
+
+ if(rc < 0) {
printf("dna_init() failed\n");
close(ring->fd);
- return -1;
+ return rc;
}
#ifdef DEBUG
|
[-]
[+]
|
Added |
PF_RING-4.7.2.tar.bz2/userland/lib/pfring_mod_multi.c
^
|
@@ -0,0 +1,185 @@
+/*
+ *
+ * (C) 2005-11 - Luca Deri <deri@ntop.org>
+ * Alfredo Cardigliano <cardigliano@ntop.org>
+ *
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lessed General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ */
+
+#include "pfring.h"
+#include "pfring_utils.h"
+#include "pfring_mod.h"
+#include "pfring_mod_multi.h"
+
+// #define MULTI_RING_DEBUG
+
+struct ring_list_element {
+ pfring *ring;
+ struct ring_list_element *next;
+};
+
+int pfring_mod_multi_open(pfring *ring) {
+ int rc;
+ char *device_list = ring->device_name;
+
+ /* Opening master ring */
+ ring->device_name = "none";
+ rc = pfring_mod_open(ring);
+ ring->device_name = device_list;
+
+ if (rc < 0)
+ return rc;
+
+ ring->close = pfring_mod_multi_close;
+ ring->add_hw_rule = pfring_mod_multi_add_hw_rule;
+ ring->remove_hw_rule = pfring_mod_multi_remove_hw_rule;
+ ring->bind = pfring_mod_multi_bind;
+ ring->set_sampling_rate = pfring_mod_multi_set_sampling_rate;
+ ring->set_direction = pfring_mod_multi_set_direction;
+ ring->enable_rss_rehash = pfring_mod_multi_enable_rss_rehash;
+
+ //TODO
+ //? ring->set_virtual_device
+ //? ring->set_channel_id
+ //? ring->set_application_name
+ //? ring->get_num_rx_channels
+
+ ring->send = NULL;
+ ring->set_cluster = NULL;
+ ring->remove_from_cluster = NULL;
+ ring->set_master_id = NULL;
+ ring->set_master = NULL;
+
+ ring->priv_data = NULL;
+
+ rc = pfring_bind(ring, device_list);
+
+ if (rc < 0) {
+ pfring_mod_multi_close(ring);
+ return rc;
+ }
+
+ return 0;
+}
+
+/* ******************************* */
+
+void pfring_mod_multi_close(pfring *ring) {
+ pfring_mod_close(ring);
+ struct ring_list_element *tmp_elem;
+ struct ring_list_element *elem = (struct ring_list_element *) ring->priv_data;
+ ring->priv_data = NULL;
+
+ while(elem != NULL) {
+ pfring_close(elem->ring);
+
+ tmp_elem = elem;
+ elem = elem->next;
+ free(tmp_elem);
+ }
+}
+
+/* ******************************* */
+
+int pfring_mod_multi_bind(pfring *ring, char *device_name) {
+ char *tok, *pos = NULL;
+ char dev_name[16];
+ int rc;
+
+ tok = strtok_r(device_name, ";", &pos);
+ while(tok != NULL){
+ pfring *new_ring = NULL;
+ struct ring_list_element *elem;
+
+ snprintf(dev_name, sizeof(dev_name), "default:%s", tok);
+
+ new_ring = pfring_open(dev_name, ring->promisc, ring->caplen, 0 /* set in master only */);
+ if (new_ring == NULL)
+ return -1;
+
+ rc = pfring_set_master(new_ring /* slave */, ring /* master */);
+ if (rc < 0)
+ return rc;
+
+ elem = malloc(sizeof(struct ring_list_element));
+ if (elem == NULL) {
+ pfring_close(new_ring);
+ return -1;
+ }
+
+ elem->ring = new_ring;
+ elem->next = (struct ring_list_element *) ring->priv_data;
+ ring->priv_data = (void *) elem;
+
+ tok = strtok_r(NULL, ";", &pos);
+ }
+
+ return 0;
+}
+
+/* ******************************* */
+
+int pfring_mod_multi_add_hw_rule(pfring *ring, hw_filtering_rule *rule) {
+ struct ring_list_element *elem = (struct ring_list_element *) ring->priv_data;
+ while(elem != NULL) {
+ if (pfring_add_hw_rule(elem->ring, rule) < 0) {
+ pfring_remove_hw_rule(ring, rule->rule_id);
+ return -1;
+ }
+ elem = elem->next;
+ }
+ return 0;
+}
+
+/* ******************************* */
+
+int pfring_mod_multi_remove_hw_rule(pfring *ring, u_int16_t rule_id) {
+ struct ring_list_element *elem = (struct ring_list_element *) ring->priv_data;
+ while(elem != NULL) {
+ pfring_remove_hw_rule(elem->ring, rule_id);
+ elem = elem->next;
+ }
+ return 0;
+}
+
+/* ******************************* */
+
+int pfring_mod_multi_set_sampling_rate(pfring *ring, u_int32_t rate /* 1 = no sampling */) {
+ struct ring_list_element *elem = (struct ring_list_element *) ring->priv_data;
+ while(elem != NULL) {
+ if(pfring_set_sampling_rate(elem->ring, rate)<0)
+ return -1;
+ elem = elem->next;
+ }
+ return 0;
+}
+
+/* ******************************* */
+
+int pfring_mod_multi_set_direction(pfring *ring, packet_direction direction) {
+ struct ring_list_element *elem = (struct ring_list_element *) ring->priv_data;
+ while(elem != NULL) {
+ if(pfring_set_direction(elem->ring, direction)<0)
+ return -1;
+ elem = elem->next;
+ }
+ return 0;
+}
+
+/* ******************************* */
+
+int pfring_mod_multi_enable_rss_rehash(pfring *ring) {
+ struct ring_list_element *elem = (struct ring_list_element *) ring->priv_data;
+ while(elem != NULL) {
+ if(pfring_enable_rss_rehash(elem->ring)<0)
+ return -1;
+ elem = elem->next;
+ }
+ return 0;
+}
+
|
[-]
[+]
|
Added |
PF_RING-4.7.2.tar.bz2/userland/lib/pfring_mod_multi.h
^
|
@@ -0,0 +1,28 @@
+/*
+ *
+ * (C) 2005-11 - Luca Deri <deri@ntop.org>
+ * Alfredo Cardigliano <cardigliano@ntop.org>
+ *
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesses General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ */
+
+#ifndef _PFRING_MOD_MULTI_H_
+#define _PFRING_MOD_MULTI_H_
+
+int pfring_mod_multi_open (pfring *ring);
+
+void pfring_mod_multi_close(pfring *ring);
+int pfring_mod_multi_stats(pfring *ring, pfring_stat *stats);
+int pfring_mod_multi_add_hw_rule(pfring *ring, hw_filtering_rule *rule);
+int pfring_mod_multi_remove_hw_rule(pfring *ring, u_int16_t rule_id);
+int pfring_mod_multi_bind(pfring *ring, char *device_name);
+int pfring_mod_multi_set_sampling_rate(pfring *ring, u_int32_t rate);
+int pfring_mod_multi_set_direction(pfring *ring, packet_direction direction);
+int pfring_mod_multi_enable_rss_rehash(pfring *ring);
+
+#endif /* _PFRING_MOD_MULTI_H_ */
|
[-]
[+]
|
Added |
PF_RING-4.7.2.tar.bz2/userland/lib/utils
^
|
+(directory)
|
[-]
[+]
|
Added |
PF_RING-4.7.2.tar.bz2/userland/lib/utils/dag_stream_init_receive.sh
^
|
@@ -0,0 +1,37 @@
+#!/bin/sh
+
+echo "Loading the DAG module"
+
+rmmod dag
+rmmod dagmem
+modprobe dagmem dsize=512M
+
+sleep 1
+
+dagload
+
+sleep 1
+
+echo "Configuring the DAG card (multiple queues)"
+
+dagconfig -d0 default
+
+sleep 1
+
+dagconfig mem=64:0:64:0:64:0:64:0:64:0:64:0:64:0:64:0
+
+sleep 1
+
+dagconfig -d0 -S ipf_enable=on -S hash_encoding_from_ipf=on
+
+dagconfig -d0 -S hash_width=3
+
+dagconfig -d0 -S n_tuple_select=2
+
+dagconfig -d0 -S hat_range=0-124:125-249:250-374:375-499:500-624:625-749:750-874:875-1000
+
+dagcat-setup -d0 -m z8
+
+#echo "Configuration done. Use dagbits -d0:X -c for testing."
+echo "Configuration completed."
+echo "Use -i dag:dagX:Y (e.g. dag:dag0:0) as device"
\ No newline at end of file
|
[-]
[+]
|
Added |
PF_RING-4.7.2.tar.bz2/userland/lib/utils/dag_stream_init_send.sh
^
|
@@ -0,0 +1,27 @@
+#!/bin/sh
+
+echo "Loading the DAG module"
+
+rmmod dag
+rmmod dagmem
+modprobe dagmem dsize=512M
+
+sleep 1
+
+/usr/local/bin/dagload
+
+sleep 1
+
+/usr/local/bin/dagconfig -d0 default
+
+sleep 1
+
+/usr/local/bin/dagconfig -d0 mem=256:256
+
+sleep 1
+
+echo "Configuration completed."
+
+echo "If you need to convert a pcap to .erf do"
+echo "/usr/local/bin/dagconvert -T pcap:erf -A 8 -i 10k_UDP_Flows.pcap -o 10k_UDP_Flows.erf"
+echo "/usr/local/bin/dagflood -f erf/10k_UDP_Flows_512byte.erf -d dag0 -t 10"
|
[-]
[+]
|
Changed |
PF_RING-4.7.2.tar.bz2/userland/libpcap-1.1.1-ring/pcap-linux.c
^
|
@@ -1174,6 +1174,7 @@
pfring_set_cluster(handle->ring, atoi(clusterId), cluster_round_robin);
pfring_set_poll_watermark(handle->ring, 1 /* watermark */);
+ handle->ring->dna_sync_watermark = 0; /* trick (otherwise tshark wouldn't work with DNA) */
} else
handle->ring = NULL;
} else
@@ -1363,6 +1364,7 @@
if(handle->ring) {
char *packet;
int wait_for_incoming_packet = handle->md.timeout < 0 ? 0 : 1;
+ int ret = 0;
if(!handle->ring->enabled) pfring_enable_ring(handle->ring);
@@ -1380,24 +1382,34 @@
}
pcap_header.ts.tv_sec = 0;
- packet_len = pfring_recv(handle->ring, (u_char**)&packet,
- 0, &pcap_header,
- wait_for_incoming_packet);
- if(packet_len == 0) {
+ ret = pfring_recv(handle->ring, (u_char**)&packet,
+ 0, &pcap_header,
+ wait_for_incoming_packet);
+
+ if(ret == 0) {
if (errno == EINTR)
continue;
- if (!wait_for_incoming_packet)
+ if (wait_for_incoming_packet)
+ continue;
+ else
return 0; /* non-blocking */
- } else if (packet_len > 0) {
+
+ } else if (ret > 0) {
bp = packet;
pcap_header.caplen = min(pcap_header.caplen, handle->bufsize);
caplen = pcap_header.caplen, packet_len = pcap_header.len;
if(pcap_header.ts.tv_sec == 0) gettimeofday((struct timeval*)&pcap_header.ts, NULL);
break;
+
+ } else {
+ if (errno == EINTR || errno == ENETDOWN)
+ continue;
+ else
+ return -1;
}
- } while (packet_len == -1 && (errno == EINTR || errno == ENETDOWN));
+ } while (1);
goto pfring_pcap_read_packet;
}
|
[-]
[+]
|
Changed |
pf_ring-2.6.32.tar.bz2/linux/pf_ring.h
^
|
@@ -37,8 +37,8 @@
#define pfring_ptr ec_ptr
/* Versioning */
-#define RING_VERSION "4.7.1"
-#define RING_VERSION_NUM 0x040701
+#define RING_VERSION "4.7.2"
+#define RING_VERSION_NUM 0x040702
/* Set */
#define SO_ADD_TO_CLUSTER 99
@@ -180,6 +180,7 @@
hardware timestamp, this is the place to read timestamp from */
int if_index; /* index of the interface on which the packet has been received.
It can be also used to report other information */
+ u_int32_t pkt_hash; /* Hash based on the packet header */
u_int16_t parsed_header_len; /* Extra parsing data before packet */
/* NOTE: leave it as last field of the memset on parse_pkt() will fail */
@@ -516,25 +517,31 @@
typedef enum {
intel_e1000e = 0,
intel_igb,
- intel_ixgbe
+ intel_ixgbe,
+ intel_ixgbe_82598,
+ intel_ixgbe_82599
} dna_device_model;
typedef struct {
+ u_int32_t packet_memory_num_slots;
+ u_int32_t packet_memory_slot_len;
+ u_int32_t packet_memory_tot_len;
+ u_int32_t descr_packet_memory_num_slots;
+ u_int32_t descr_packet_memory_slot_len;
+ u_int32_t descr_packet_memory_tot_len;
+ u_int32_t phys_card_memory_len;
+ dna_device_model device_model;
+} dna_memory_slots;
+
+typedef struct {
+ dna_memory_slots mem_info;
+ u_int16_t channel_id;
unsigned long rx_packet_memory; /* Invalid in userland */
void *rx_descr_packet_memory; /* Invalid in userland */
unsigned long tx_packet_memory; /* Invalid in userland */
void *tx_descr_packet_memory; /* Invalid in userland */
- u_int packet_memory_num_slots;
- u_int packet_memory_slot_len;
- u_int packet_memory_tot_len;
- u_int descr_packet_memory_num_slots;
- u_int descr_packet_memory_slot_len;
- u_int descr_packet_memory_tot_len;
- u_int channel_id;
char *phys_card_memory; /* Invalid in userland */
- u_int phys_card_memory_len;
struct net_device *netdev; /* Invalid in userland */
- dna_device_model device_model;
u_char device_address[6];
#ifdef __KERNEL__
wait_queue_head_t *packet_waitqueue;
|
[-]
[+]
|
Changed |
pf_ring-2.6.32.tar.bz2/pf_ring.c
^
|
@@ -156,7 +156,13 @@
/* List of virtual filtering devices */
static struct list_head virtual_filtering_devices_list;
-static rwlock_t virtual_filtering_lock = RW_LOCK_UNLOCKED;
+static rwlock_t virtual_filtering_lock =
+#if(LINUX_VERSION_CODE < KERNEL_VERSION(2,6,39))
+ RW_LOCK_UNLOCKED
+#else
+ __RW_LOCK_UNLOCKED(virtual_filtering_lock)
+#endif
+;
/* List of all clusters */
static struct list_head ring_cluster_list;
@@ -208,7 +214,13 @@
static rwlock_t ring_mgmt_lock;
-inline void init_ring_readers(void) { ring_mgmt_lock = RW_LOCK_UNLOCKED; }
+inline void init_ring_readers(void) { ring_mgmt_lock =
+#if(LINUX_VERSION_CODE < KERNEL_VERSION(2,6,39))
+ RW_LOCK_UNLOCKED
+#else
+ __RW_LOCK_UNLOCKED(ring_mgmt_lock)
+#endif
+; }
inline void ring_write_lock(void) { write_lock_bh(&ring_mgmt_lock); }
inline void ring_write_unlock(void) { write_unlock_bh(&ring_mgmt_lock); }
/* use ring_read_lock/ring_read_unlock in process context (a bottom half may use write_lock) */
@@ -367,6 +379,7 @@
return(dev->real_num_rx_queues);
#else
return(dev->real_num_tx_queues);
+ // return(1);
#endif
#endif
}
@@ -585,8 +598,10 @@
ring_proc_dir,
ring_proc_get_info, pfr);
- printk("[PF_RING] Added /proc/net/pf_ring/%s\n",
- pfr->sock_proc_name);
+ if(enable_debug)
+ printk("[PF_RING] Added /proc/net/pf_ring/%s\n", pfr->sock_proc_name);
+
+ ring_table_size++;
}
}
@@ -596,7 +611,8 @@
{
if((ring_proc_dir != NULL)
&& (pfr->sock_proc_name[0] != '\0')) {
- printk("[PF_RING] Removing /proc/net/pf_ring/%s\n", pfr->sock_proc_name);
+ if(enable_debug)
+ printk("[PF_RING] Removing /proc/net/pf_ring/%s\n", pfr->sock_proc_name);
remove_proc_entry(pfr->sock_proc_name, ring_proc_dir);
@@ -604,6 +620,7 @@
printk("[PF_RING] Removed /proc/net/pf_ring/%s\n", pfr->sock_proc_name);
pfr->sock_proc_name[0] = '\0';
+ ring_table_size--;
}
}
@@ -629,6 +646,12 @@
case intel_ixgbe:
dev_family = "Intel ixgbe"; break;
break;
+ case intel_ixgbe_82598:
+ dev_family = "Intel ixgbe 82598"; break;
+ break;
+ case intel_ixgbe_82599:
+ dev_family = "Intel ixgbe 82599"; break;
+ break;
}
} else {
switch(dev_ptr->device_type) {
@@ -1052,11 +1075,10 @@
{
if(ring_proc != NULL) {
remove_proc_entry(PROC_INFO, ring_proc_dir);
- printk("[PF_RING] removed /proc/net/pf_ring/%s\n", PROC_INFO);
+ if(enable_debug) printk("[PF_RING] removed /proc/net/pf_ring/%s\n", PROC_INFO);
remove_proc_entry(PROC_PLUGINS_INFO, ring_proc_dir);
- printk("[PF_RING] removed /proc/net/pf_ring/%s\n",
- PROC_PLUGINS_INFO);
+ if(enable_debug) printk("[PF_RING] removed /proc/net/pf_ring/%s\n", PROC_PLUGINS_INFO);
remove_proc_entry(PROC_DEV, ring_proc_dir);
@@ -1066,7 +1088,7 @@
init_net.
#endif
proc_net);
- printk("[PF_RING] deregistered /proc/net/pf_ring\n");
+ if(enable_debug) printk("[PF_RING] deregistered /proc/net/pf_ring\n");
}
}
}
@@ -1189,8 +1211,6 @@
printk("[PF_RING] net_ratelimit() failure\n");
}
- ring_table_size++;
-
pfr = (struct pf_ring_socket *)ring_sk(sk);
pfr->ring_pid = current->pid;
}
@@ -1234,7 +1254,7 @@
list_del(ptr);
to_delete = entry;
- ring_table_size--, socket_found = 1;
+ socket_found = 1;
}
if(master_found && socket_found) break;
@@ -1246,6 +1266,35 @@
printk("[PF_RING] leaving ring_remove()\n");
}
+/* ********************************** */
+
+inline u_int32_t hash_pkt(u_int16_t vlan_id, u_int8_t proto,
+ ip_addr host_peer_a, ip_addr host_peer_b,
+ u_int16_t port_peer_a, u_int16_t port_peer_b)
+{
+ return(vlan_id+proto+
+ host_peer_a.v6.s6_addr32[0]+host_peer_a.v6.s6_addr32[1]+
+ host_peer_a.v6.s6_addr32[2]+host_peer_a.v6.s6_addr32[3]+
+ host_peer_b.v6.s6_addr32[0]+host_peer_b.v6.s6_addr32[1]+
+ host_peer_b.v6.s6_addr32[2]+host_peer_b.v6.s6_addr32[3]+
+ port_peer_a+port_peer_b);
+}
+
+/* ********************************** */
+
+inline u_int32_t hash_pkt_header(struct pfring_pkthdr * hdr, u_char mask_src, u_char mask_dst)
+{
+ if(hdr->extended_hdr.pkt_hash == 0)
+ hdr->extended_hdr.pkt_hash = hash_pkt(hdr->extended_hdr.parsed_pkt.vlan_id,
+ hdr->extended_hdr.parsed_pkt.l3_proto,
+ mask_src ? ip_zero : hdr->extended_hdr.parsed_pkt.ip_src,
+ mask_dst ? ip_zero : hdr->extended_hdr.parsed_pkt.ip_dst,
+ mask_src ? 0 : hdr->extended_hdr.parsed_pkt.l4_src_port,
+ mask_dst ? 0 : hdr->extended_hdr.parsed_pkt.l4_dst_port);
+
+ return(hdr->extended_hdr.pkt_hash);
+}
+
/* ******************************************************* */
static int parse_raw_pkt(char *data, u_int data_len,
@@ -1398,6 +1447,8 @@
} else
hdr->extended_hdr.parsed_pkt.l4_src_port = hdr->extended_hdr.parsed_pkt.l4_dst_port = 0;
+ hash_pkt_header(hdr, 0, 0);
+
return(1); /* IP */
}
@@ -1424,33 +1475,6 @@
/* ********************************** */
-inline u_int32_t hash_pkt(u_int16_t vlan_id, u_int8_t proto,
- ip_addr host_peer_a, ip_addr host_peer_b,
- u_int16_t port_peer_a, u_int16_t port_peer_b)
-{
- return(vlan_id+proto+
- host_peer_a.v6.s6_addr32[0]+host_peer_a.v6.s6_addr32[1]+
- host_peer_a.v6.s6_addr32[2]+host_peer_a.v6.s6_addr32[3]+
- host_peer_b.v6.s6_addr32[0]+host_peer_b.v6.s6_addr32[1]+
- host_peer_b.v6.s6_addr32[2]+host_peer_b.v6.s6_addr32[3]+
- port_peer_a+port_peer_b);
-}
-
-/* ********************************** */
-
-inline u_int32_t hash_pkt_header(struct pfring_pkthdr * hdr, u_char mask_src,
- u_char mask_dst)
-{
- return(hash_pkt(hdr->extended_hdr.parsed_pkt.vlan_id,
- hdr->extended_hdr.parsed_pkt.l3_proto,
- mask_src ? ip_zero : hdr->extended_hdr.parsed_pkt.ip_src,
- mask_dst ? ip_zero : hdr->extended_hdr.parsed_pkt.ip_dst,
- mask_src ? 0 : hdr->extended_hdr.parsed_pkt.l4_src_port,
- mask_dst ? 0 : hdr->extended_hdr.parsed_pkt.l4_dst_port));
-}
-
-/* ********************************** */
-
static int hash_bucket_match(sw_filtering_hash_bucket * hash_bucket,
struct pfring_pkthdr *hdr,
u_char mask_src, u_char mask_dst)
@@ -1677,8 +1701,8 @@
}
if(rule->rule.balance_pool > 0) {
- u_int32_t balance_hash =
- hash_pkt_header(hdr, 0, 0) % rule->rule.balance_pool;
+ u_int32_t balance_hash = hash_pkt_header(hdr, 0, 0) % rule->rule.balance_pool;
+
if(balance_hash != rule->rule.balance_id)
return(0);
}
@@ -2389,7 +2413,7 @@
u_int8_t hash_found = 0;
if(pfr && pfr->rehash_rss && skb->dev)
- channel_id = hash_pkt_header(hdr, 0, 0) % get_num_rx_queues(skb->dev);
+ channel_id = hash_pkt_header(hdr, 0, 0) % get_num_rx_queues(skb->dev);
/* This is a memory holder for storing parsed packet information
that will then be freed when the packet has been handled
@@ -2400,9 +2424,21 @@
hdr->len, channel_id, num_rx_channels,
pfr->ring_active, pfr->ring_netdev->dev->name);
+ {
+ static int once = 0;
+
+ while(once < 25) {
+ printk("[PF_RING] add_skb_to_ring on device index %d [active=%d]\n",
+ skb->dev->ifindex, pfr->ring_active);
+ once++;
+ }
+ }
+
if((!pfring_enabled) || ((!pfr->ring_active) && (pfr->master_ring == NULL)))
return(-1);
+
+
pfr->num_rx_channels = num_rx_channels; /* Constantly updated */
hdr->extended_hdr.parsed_pkt.last_matched_rule_id = (u_int16_t)-1;
@@ -2837,6 +2873,15 @@
skb->dev->name, num_rings_per_device[skb->dev->ifindex], num_any_rings);
}
+ if(skb->dev->ifindex != 10) {
+ static int once = 0;
+
+ while(once < 25) {
+ printk("[PF_RING] Received pkt on device index %d\n", skb->dev->ifindex);
+ once++;
+ }
+ }
+
if((num_any_rings == 0)
&& (skb->dev
&& (skb->dev->ifindex < MAX_NUM_IFIDX)
@@ -2890,6 +2935,7 @@
if(pfr && pfr->rehash_rss && skb->dev) {
parse_pkt(skb, displ, &hdr, 1);
+
channel_id = hash_pkt_header(&hdr, 0, 0) % get_num_rx_queues(skb->dev);
}
@@ -2904,7 +2950,6 @@
room_available |= copy_data_to_ring(skb, pfr, &hdr, displ, 0, NULL, NULL, 0);
}
} else {
-
is_ip_pkt = parse_pkt(skb, displ, &hdr, 1);
if(enable_ip_defrag) {
@@ -2923,6 +2968,7 @@
else
hdr.extended_hdr.if_index = UNKNOWN_INTERFACE;
+
/* Avoid the ring to be manipulated while playing with it */
ring_read_lock();
@@ -2947,6 +2993,7 @@
) {
/* We've found the ring where the packet can be stored */
int old_caplen = hdr.caplen; /* Keep old lenght */
+
hdr.caplen = min_val(hdr.caplen, pfr->bucket_len);
room_available |= add_skb_to_ring(skb, pfr, &hdr, is_ip_pkt,
displ, channel_id, num_rx_channels);
@@ -4168,16 +4215,12 @@
if(enable_debug)
printk("[PF_RING] wait_packet_function_ptr(0) returned %d\n", rc);
- //*pfr->dna_device->interrupt_received = rc;
- if(rc == 0)
- rc = *pfr->dna_device->interrupt_received;
-
if(enable_debug)
printk("[PF_RING] poll %s return [%d]\n",
pfr->ring_netdev->dev->name,
*pfr->dna_device->interrupt_received);
- if(rc) {
+ if(*pfr->dna_device->interrupt_received) {
return(POLLIN | POLLRDNORM);
} else {
return(0);
@@ -4449,8 +4492,9 @@
}
}
- printk("[PF_RING] ring_map_dna_device(%s, %u): mapping failed\n",
- mapping->device_name, mapping->channel_id);
+ if(enable_debug)
+ printk("[PF_RING] ring_map_dna_device(%s, %u): mapping failed or not a dna device\n",
+ mapping->device_name, mapping->channel_id);
return(-1);
}
@@ -5210,7 +5254,8 @@
case SO_SET_MASTER_RING:
/* Avoid using master sockets with bound rings */
- if(pfr->ring_netdev == &none_device_element) return -EFAULT;
+ if(pfr->ring_netdev == &none_device_element)
+ return -EFAULT;
if(optlen != sizeof(ring_id))
return -EINVAL;
@@ -5610,10 +5655,10 @@
case SO_GET_MAPPED_DNA_DEVICE:
{
- if((pfr->dna_device == NULL) || (len < sizeof(dna_device)))
+ if((pfr->dna_device == NULL) || (len < sizeof(dna_memory_slots)))
return -EFAULT;
- if(copy_to_user(optval, pfr->dna_device, sizeof(dna_device)))
+ if(copy_to_user(optval, &pfr->dna_device->mem_info, sizeof(dna_memory_slots)))
return -EFAULT;
break;
@@ -5779,21 +5824,22 @@
next->in_use = 0;
next->dev.rx_packet_memory = rx_packet_memory;
- next->dev.packet_memory_num_slots = packet_memory_num_slots;
- next->dev.packet_memory_slot_len = packet_memory_slot_len;
- next->dev.packet_memory_tot_len = packet_memory_tot_len;
+ next->dev.mem_info.packet_memory_num_slots = packet_memory_num_slots;
+ next->dev.mem_info.packet_memory_slot_len = packet_memory_slot_len;
+ next->dev.mem_info.packet_memory_tot_len = packet_memory_tot_len;
+ next->dev.mem_info.device_model = device_model;
next->dev.rx_descr_packet_memory = descr_packet_memory;
- next->dev.descr_packet_memory_num_slots = descr_packet_memory_num_slots;
- next->dev.descr_packet_memory_slot_len = descr_packet_memory_slot_len;
- next->dev.descr_packet_memory_tot_len = descr_packet_memory_tot_len;
+ next->dev.mem_info.descr_packet_memory_num_slots = descr_packet_memory_num_slots;
+ next->dev.mem_info.descr_packet_memory_slot_len = descr_packet_memory_slot_len;
+ next->dev.mem_info.descr_packet_memory_tot_len = descr_packet_memory_tot_len;
next->dev.phys_card_memory = phys_card_memory;
- next->dev.phys_card_memory_len = phys_card_memory_len;
+ next->dev.mem_info.phys_card_memory_len = phys_card_memory_len;
/* TX */
next->dev.tx_packet_memory = tx_packet_memory;
next->dev.tx_descr_packet_memory = tx_descr_packet_memory;
next->dev.channel_id = channel_id;
next->dev.netdev = netdev;
- next->dev.device_model = device_model;
+ next->dev.mem_info.device_model = device_model;
memcpy(next->dev.device_address, device_address, 6);
next->dev.packet_waitqueue = packet_waitqueue;
next->dev.interrupt_received = interrupt_received;
@@ -6013,7 +6059,7 @@
if(enable_debug)
printk("[PF_RING] set_eeprom returned %d\n", rc);
- if(rc == 0) {
+ if(rc == RING_MAGIC_VALUE) {
/* This device supports hardware filtering */
dev_ptr->device_type = intel_82599_family;
@@ -6027,14 +6073,17 @@
ring_proc_dev_rule_read, dev_ptr);
if(entry) {
entry->write_proc = ring_proc_dev_rule_write;
- printk("[PF_RING] Device %s (Intel 82599) DOES support hardware packet filtering\n", dev->name);
- } else
- printk("[PF_RING] Error while creating /proc entry 'rules' for device %s\n", dev->name);
+ if(enable_debug) printk("[PF_RING] Device %s (Intel 82599) DOES support hardware packet filtering\n", dev->name);
+ } else {
+ if(enable_debug) printk("[PF_RING] Error while creating /proc entry 'rules' for device %s\n", dev->name);
+ }
#endif
- } else
- printk("[PF_RING] Device %s does NOT support hardware packet filtering [1]\n", dev->name);
- } else
- printk("[PF_RING] Device %s does NOT support hardware packet filtering [2]\n", dev->name);
+ } else {
+ if(enable_debug) printk("[PF_RING] Device %s does NOT support hardware packet filtering [1]\n", dev->name);
+ }
+ } else {
+ if(enable_debug) printk("[PF_RING] Device %s does NOT support hardware packet filtering [2]\n", dev->name);
+ }
#endif
list_add(&dev_ptr->device_list, &ring_aware_device_list);
@@ -6189,6 +6238,7 @@
kfree(entry);
}
+ list_del(&any_device_element.device_list);
list_for_each_safe(ptr, tmp_ptr, &ring_aware_device_list) {
ring_device_element *dev_ptr;
@@ -6205,7 +6255,7 @@
remove_proc_entry(dev_ptr->dev->name, ring_proc_dev_dir);
if(hook->magic == PF_RING) {
- printk("[PF_RING] Unregister hook for %s\n", dev_ptr->dev->name);
+ if(enable_debug) printk("[PF_RING] Unregister hook for %s\n", dev_ptr->dev->name);
dev_ptr->dev->pfring_ptr = NULL; /* Unhook PF_RING */
}
@@ -6280,6 +6330,9 @@
memset(&any_device_element, 0, sizeof(any_device_element));
any_device_element.dev = &any_dev, any_device_element.device_type = standard_nic_family;
+ INIT_LIST_HEAD(&any_device_element.device_list);
+ list_add(&any_device_element.device_list, &ring_aware_device_list);
+
memset(&none_dev, 0, sizeof(none_dev));
strcpy(none_dev.name, "none");
none_dev.ifindex = MAX_NUM_IFIDX-2;
|