SOURCES: linux-PF_RING.patch (NEW) - http://www.ntop.org/PF_RING.h...
areq
areq at pld-linux.org
Sun Jun 10 21:07:01 CEST 2007
Author: areq Date: Sun Jun 10 19:07:01 2007 GMT
Module: SOURCES Tag: HEAD
---- Log message:
- http://www.ntop.org/PF_RING.html 20070610
---- Files affected:
SOURCES:
linux-PF_RING.patch (NONE -> 1.1) (NEW)
---- Diffs:
================================================================
Index: SOURCES/linux-PF_RING.patch
diff -u /dev/null SOURCES/linux-PF_RING.patch:1.1
--- /dev/null Sun Jun 10 21:07:01 2007
+++ SOURCES/linux-PF_RING.patch Sun Jun 10 21:06:56 2007
@@ -0,0 +1,8288 @@
+diff --unified --recursive --new-file linux-2.6.21.4/include/linux/ring.h linux-2.6.21.4-1-686-smp-ring3/include/linux/ring.h
+--- linux-2.6.21.4/include/linux/ring.h 1970-01-01 00:00:00.000000000 +0000
++++ linux-2.6.21.4-1-686-smp-ring3/include/linux/ring.h 2007-06-10 16:43:04.346421348 +0000
+@@ -0,0 +1,240 @@
++/*
++ * Definitions for packet ring
++ *
++ * 2004-07 Luca Deri <deri at ntop.org>
++ */
++#ifndef __RING_H
++#define __RING_H
++
++#define INCLUDE_MAC_INFO
++
++#ifdef INCLUDE_MAC_INFO
++#define SKB_DISPLACEMENT 14 /* Include MAC address information */
++#else
++#define SKB_DISPLACEMENT 0 /* Do NOT include MAC address information */
++#endif
++
++#define RING_MAGIC
++#define RING_MAGIC_VALUE 0x88
++#define RING_FLOWSLOT_VERSION 6
++#define RING_VERSION "3.4.1"
++
++#define SO_ADD_TO_CLUSTER 99
++#define SO_REMOVE_FROM_CLUSTER 100
++#define SO_SET_REFLECTOR 101
++#define SO_SET_BLOOM 102
++#define SO_SET_STRING 103
++#define SO_TOGGLE_BLOOM_STATE 104
++#define SO_RESET_BLOOM_FILTERS 105
++
++#define BITMASK_SET(n, p) (((char*)p->bits_memory)[n/8] |= (1<<(n % 8)))
++#define BITMASK_CLR(n, p) (((char*)p->bits_memory)[n/8] &= ~(1<<(n % 8)))
++#define BITMASK_ISSET(n, p) (((char*)p->bits_memory)[n/8] & (1<<(n % 8)))
++
++/* *********************************** */
++
++/*
++ Aho-Corasick code taken from Snort
++ under GPL license
++*/
++/*
++ * DEFINES and Typedef's
++ */
++#define MAX_ALPHABET_SIZE 256
++
++/*
++ FAIL STATE for 1,2,or 4 bytes for state transitions
++
++ Uncomment this define to use 32 bit state values
++ #define AC32
++*/
++
++typedef unsigned short acstate_t;
++#define ACSM_FAIL_STATE2 0xffff
++
++/*
++ *
++ */
++typedef
++struct _acsm_pattern2
++{
++ struct _acsm_pattern2 *next;
++
++ unsigned char *patrn;
++ unsigned char *casepatrn;
++ int n;
++ int nocase;
++ int offset;
++ int depth;
++ void * id;
++ int iid;
++
++} ACSM_PATTERN2;
++
++/*
++ * transition nodes - either 8 or 12 bytes
++ */
++typedef
++struct trans_node_s {
++
++ acstate_t key; /* The character that got us here - sized to keep structure aligned on 4 bytes */
++ /* to better the caching opportunities. A value that crosses the cache line */
++ /* forces an expensive reconstruction, typing this as acstate_t stops that. */
++ acstate_t next_state; /* */
++ struct trans_node_s * next; /* next transition for this state */
++
++} trans_node_t;
++
++
++/*
++ * User specified final storage type for the state transitions
++ */
++enum {
++ ACF_FULL,
++ ACF_SPARSE,
++ ACF_BANDED,
++ ACF_SPARSEBANDS,
++};
++
++/*
++ * User specified machine types
++ *
++ * TRIE : Keyword trie
++ * NFA :
++ * DFA :
++ */
++enum {
++ FSA_TRIE,
++ FSA_NFA,
++ FSA_DFA,
++};
++
++/*
++ * Aho-Corasick State Machine Struct - one per group of pattterns
++ */
++typedef struct {
++ int acsmMaxStates;
++ int acsmNumStates;
++
++ ACSM_PATTERN2 * acsmPatterns;
++ acstate_t * acsmFailState;
++ ACSM_PATTERN2 ** acsmMatchList;
++
++ /* list of transitions in each state, this is used to build the nfa & dfa */
++ /* after construction we convert to sparse or full format matrix and free */
++ /* the transition lists */
++ trans_node_t ** acsmTransTable;
++
++ acstate_t ** acsmNextState;
++ int acsmFormat;
++ int acsmSparseMaxRowNodes;
++ int acsmSparseMaxZcnt;
++
++ int acsmNumTrans;
++ int acsmAlphabetSize;
++ int acsmFSA;
++
++} ACSM_STRUCT2;
++
++/* *********************************** */
++
++#ifndef HAVE_PCAP
++struct pcap_pkthdr {
++ struct timeval ts; /* time stamp */
++ u_int32_t caplen; /* length of portion present */
++ u_int32_t len; /* length this packet (off wire) */
++ /* packet parsing info */
++ u_int16_t eth_type; /* Ethernet type */
++ u_int16_t vlan_id; /* VLAN Id or -1 for no vlan */
++ u_int8_t l3_proto; /* Layer 3 protocol */
++ u_int16_t l3_offset, l4_offset, payload_offset; /* Offsets of L3/L4/payload elements */
++ u_int32_t ipv4_src, ipv4_dst; /* IPv4 src/dst IP addresses */
++ u_int16_t l4_src_port, l4_dst_port; /* Layer 4 src/dst ports */
++};
++#endif
++
++/* *********************************** */
++
++typedef struct _counter_list {
++ u_int32_t bit_id;
++ u_int32_t bit_counter;
++ struct _counter_list *next;
++} bitmask_counter_list;
++
++typedef struct {
++ u_int32_t num_bits, order, num_pages;
++ unsigned long bits_memory;
++ bitmask_counter_list *clashes;
++} bitmask_selector;
++
++/* *********************************** */
++
++enum cluster_type {
++ cluster_per_flow = 0,
++ cluster_round_robin
++};
++
++/* *********************************** */
++
++#define RING_MIN_SLOT_SIZE (60+sizeof(struct pcap_pkthdr))
++#define RING_MAX_SLOT_SIZE (1514+sizeof(struct pcap_pkthdr))
++
++/* *********************************** */
++
++typedef struct flowSlotInfo {
++ u_int16_t version, sample_rate;
++ u_int32_t tot_slots, slot_len, data_len, tot_mem;
++
++ u_int64_t tot_pkts, tot_lost;
++ u_int64_t tot_insert, tot_read;
++ u_int32_t insert_idx, remove_idx;
++} FlowSlotInfo;
++
++/* *********************************** */
++
++typedef struct flowSlot {
++#ifdef RING_MAGIC
++ u_char magic; /* It must alwasy be zero */
++#endif
++ u_char slot_state; /* 0=empty, 1=full */
++ u_char bucket; /* bucket[bucketLen] */
++} FlowSlot;
++
++/* *********************************** */
++
++#ifdef __KERNEL__
++
++FlowSlotInfo* getRingPtr(void);
++int allocateRing(char *deviceName, u_int numSlots,
++ u_int bucketLen, u_int sampleRate);
++unsigned int pollRing(struct file *fp, struct poll_table_struct * wait);
++void deallocateRing(void);
++
++/* ************************* */
++
++typedef int (*handle_ring_skb)(struct sk_buff *skb,
++ u_char recv_packet, u_char real_skb);
++extern handle_ring_skb get_skb_ring_handler(void);
++extern void set_skb_ring_handler(handle_ring_skb the_handler);
++extern void do_skb_ring_handler(struct sk_buff *skb,
++ u_char recv_packet, u_char real_skb);
++
++typedef int (*handle_ring_buffer)(struct net_device *dev,
++ char *data, int len);
++extern handle_ring_buffer get_buffer_ring_handler(void);
++extern void set_buffer_ring_handler(handle_ring_buffer the_handler);
++extern int do_buffer_ring_handler(struct net_device *dev,
++ char *data, int len);
++#endif /* __KERNEL__ */
++
++/* *********************************** */
++
++#define PF_RING 27 /* Packet Ring */
++#define SOCK_RING PF_RING
++
++/* ioctl() */
++#define SIORINGPOLL 0x8888
++
++/* *********************************** */
++
++#endif /* __RING_H */
+diff --unified --recursive --new-file linux-2.6.21.4/net/Kconfig linux-2.6.21.4-1-686-smp-ring3/net/Kconfig
+--- linux-2.6.21.4/net/Kconfig 2007-06-07 21:27:31.000000000 +0000
++++ linux-2.6.21.4-1-686-smp-ring3/net/Kconfig 2007-06-10 16:43:04.402423771 +0000
+@@ -39,6 +39,7 @@
+ source "net/xfrm/Kconfig"
+ source "net/iucv/Kconfig"
+
++source "net/ring/Kconfig"
+ config INET
+ bool "TCP/IP networking"
+ ---help---
+diff --unified --recursive --new-file linux-2.6.21.4/net/Makefile linux-2.6.21.4-1-686-smp-ring3/net/Makefile
+--- linux-2.6.21.4/net/Makefile 2007-06-07 21:27:31.000000000 +0000
++++ linux-2.6.21.4-1-686-smp-ring3/net/Makefile 2007-06-10 16:43:04.394423425 +0000
+@@ -42,6 +42,7 @@
+ obj-$(CONFIG_DECNET) += decnet/
+ obj-$(CONFIG_ECONET) += econet/
+ obj-$(CONFIG_VLAN_8021Q) += 8021q/
++obj-$(CONFIG_RING) += ring/
+ obj-$(CONFIG_IP_DCCP) += dccp/
+ obj-$(CONFIG_IP_SCTP) += sctp/
+ obj-$(CONFIG_IEEE80211) += ieee80211/
+diff --unified --recursive --new-file linux-2.6.21.4/net/Makefile.ORG linux-2.6.21.4-1-686-smp-ring3/net/Makefile.ORG
+--- linux-2.6.21.4/net/Makefile.ORG 1970-01-01 00:00:00.000000000 +0000
++++ linux-2.6.21.4-1-686-smp-ring3/net/Makefile.ORG 2007-06-10 16:43:04.386423079 +0000
+@@ -0,0 +1,54 @@
++#
++# Makefile for the linux networking.
++#
++# 2 Sep 2000, Christoph Hellwig <hch at infradead.org>
++# Rewritten to use lists instead of if-statements.
++#
++
++obj-y := nonet.o
++
++obj-$(CONFIG_NET) := socket.o core/
++
++tmp-$(CONFIG_COMPAT) := compat.o
++obj-$(CONFIG_NET) += $(tmp-y)
++
++# LLC has to be linked before the files in net/802/
++obj-$(CONFIG_LLC) += llc/
++obj-$(CONFIG_NET) += ethernet/ 802/ sched/ netlink/
++obj-$(CONFIG_NETFILTER) += netfilter/
++obj-$(CONFIG_INET) += ipv4/
++obj-$(CONFIG_XFRM) += xfrm/
++obj-$(CONFIG_UNIX) += unix/
++ifneq ($(CONFIG_IPV6),)
++obj-y += ipv6/
++endif
++obj-$(CONFIG_PACKET) += packet/
++obj-$(CONFIG_NET_KEY) += key/
++obj-$(CONFIG_NET_SCHED) += sched/
++obj-$(CONFIG_BRIDGE) += bridge/
++obj-$(CONFIG_IPX) += ipx/
++obj-$(CONFIG_ATALK) += appletalk/
++obj-$(CONFIG_WAN_ROUTER) += wanrouter/
++obj-$(CONFIG_X25) += x25/
++obj-$(CONFIG_LAPB) += lapb/
++obj-$(CONFIG_NETROM) += netrom/
++obj-$(CONFIG_ROSE) += rose/
++obj-$(CONFIG_AX25) += ax25/
++obj-$(CONFIG_IRDA) += irda/
++obj-$(CONFIG_BT) += bluetooth/
++obj-$(CONFIG_SUNRPC) += sunrpc/
++obj-$(CONFIG_RXRPC) += rxrpc/
++obj-$(CONFIG_ATM) += atm/
++obj-$(CONFIG_DECNET) += decnet/
++obj-$(CONFIG_ECONET) += econet/
++obj-$(CONFIG_VLAN_8021Q) += 8021q/
++obj-$(CONFIG_IP_DCCP) += dccp/
++obj-$(CONFIG_IP_SCTP) += sctp/
++obj-$(CONFIG_IEEE80211) += ieee80211/
++obj-$(CONFIG_TIPC) += tipc/
++obj-$(CONFIG_NETLABEL) += netlabel/
++obj-$(CONFIG_IUCV) += iucv/
++
++ifeq ($(CONFIG_NET),y)
++obj-$(CONFIG_SYSCTL) += sysctl_net.o
++endif
+diff --unified --recursive --new-file linux-2.6.21.4/net/core/dev.c linux-2.6.21.4-1-686-smp-ring3/net/core/dev.c
+--- linux-2.6.21.4/net/core/dev.c 2007-06-07 21:27:31.000000000 +0000
++++ linux-2.6.21.4-1-686-smp-ring3/net/core/dev.c 2007-06-10 16:43:04.382422906 +0000
+@@ -117,6 +117,56 @@
+ #include <linux/err.h>
+ #include <linux/ctype.h>
+
++#if defined (CONFIG_RING) || defined(CONFIG_RING_MODULE)
++
++/* #define RING_DEBUG */
++
++#include <linux/ring.h>
++#include <linux/version.h>
++
++static handle_ring_skb ring_handler = NULL;
++
++handle_ring_skb get_skb_ring_handler() { return(ring_handler); }
++
++void set_skb_ring_handler(handle_ring_skb the_handler) {
++ ring_handler = the_handler;
++}
++
++void do_skb_ring_handler(struct sk_buff *skb,
++ u_char recv_packet, u_char real_skb) {
++ if(ring_handler)
++ ring_handler(skb, recv_packet, real_skb);
++}
++
++/* ******************* */
++
++static handle_ring_buffer buffer_ring_handler = NULL;
++
++handle_ring_buffer get_buffer_ring_handler() { return(buffer_ring_handler); }
++
++void set_buffer_ring_handler(handle_ring_buffer the_handler) {
++ buffer_ring_handler = the_handler;
++}
++
++int do_buffer_ring_handler(struct net_device *dev, char *data, int len) {
++ if(buffer_ring_handler) {
++ buffer_ring_handler(dev, data, len);
++ return(1);
++ } else
++ return(0);
++}
++
++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0))
++EXPORT_SYMBOL(get_skb_ring_handler);
++EXPORT_SYMBOL(set_skb_ring_handler);
++EXPORT_SYMBOL(do_skb_ring_handler);
++
++EXPORT_SYMBOL(get_buffer_ring_handler);
++EXPORT_SYMBOL(set_buffer_ring_handler);
++EXPORT_SYMBOL(do_buffer_ring_handler);
++#endif
++
++#endif
+ /*
+ * The list of packet types we will receive (as opposed to discard)
+ * and the routines to invoke.
+@@ -1474,6 +1524,10 @@
+ skb->tc_verd = SET_TC_AT(skb->tc_verd,AT_EGRESS);
+ #endif
+ if (q->enqueue) {
++#if defined (CONFIG_RING) || defined(CONFIG_RING_MODULE)
++ if(ring_handler) ring_handler(skb, 0, 1);
++#endif /* CONFIG_RING */
++
+ /* Grab device queue */
+ spin_lock(&dev->queue_lock);
+ q = dev->qdisc;
+@@ -1574,6 +1628,13 @@
+ unsigned long flags;
+
+ /* if netpoll wants it, pretend we never saw it */
++#if defined (CONFIG_RING) || defined(CONFIG_RING_MODULE)
++ if(ring_handler && ring_handler(skb, 1, 1)) {
++ /* The packet has been copied into a ring */
++ return(NET_RX_SUCCESS);
++ }
++#endif /* CONFIG_RING */
++
+ if (netpoll_rx(skb))
+ return NET_RX_DROP;
+
+@@ -1764,6 +1825,13 @@
+ struct net_device *orig_dev;
+ int ret = NET_RX_DROP;
+ __be16 type;
++#if defined (CONFIG_RING) || defined(CONFIG_RING_MODULE)
++ if(ring_handler && ring_handler(skb, 1, 1)) {
++ /* The packet has been copied into a ring */
++ return(NET_RX_SUCCESS);
++ }
++#endif /* CONFIG_RING */
++
+
+ /* if we've gotten here through NAPI, check netpoll */
+ if (skb->dev->poll && netpoll_rx(skb))
+diff --unified --recursive --new-file linux-2.6.21.4/net/core/dev.c.ORG linux-2.6.21.4-1-686-smp-ring3/net/core/dev.c.ORG
+--- linux-2.6.21.4/net/core/dev.c.ORG 1970-01-01 00:00:00.000000000 +0000
++++ linux-2.6.21.4-1-686-smp-ring3/net/core/dev.c.ORG 2007-06-10 16:43:04.354421694 +0000
+@@ -0,0 +1,3571 @@
++/*
++ * NET3 Protocol independent device support routines.
++ *
++ * 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.
++ *
++ * Derived from the non IP parts of dev.c 1.0.19
++ * Authors: Ross Biro
++ * Fred N. van Kempen, <waltje at uWalt.NL.Mugnet.ORG>
++ * Mark Evans, <evansmp at uhura.aston.ac.uk>
++ *
++ * Additional Authors:
++ * Florian la Roche <rzsfl at rz.uni-sb.de>
++ * Alan Cox <gw4pts at gw4pts.ampr.org>
++ * David Hinds <dahinds at users.sourceforge.net>
++ * Alexey Kuznetsov <kuznet at ms2.inr.ac.ru>
++ * Adam Sulmicki <adam at cfar.umd.edu>
++ * Pekka Riikonen <priikone at poesidon.pspt.fi>
++ *
++ * Changes:
++ * D.J. Barrow : Fixed bug where dev->refcnt gets set
++ * to 2 if register_netdev gets called
++ * before net_dev_init & also removed a
++ * few lines of code in the process.
++ * Alan Cox : device private ioctl copies fields back.
++ * Alan Cox : Transmit queue code does relevant
++ * stunts to keep the queue safe.
++ * Alan Cox : Fixed double lock.
++ * Alan Cox : Fixed promisc NULL pointer trap
++ * ???????? : Support the full private ioctl range
++ * Alan Cox : Moved ioctl permission check into
++ * drivers
++ * Tim Kordas : SIOCADDMULTI/SIOCDELMULTI
++ * Alan Cox : 100 backlog just doesn't cut it when
++ * you start doing multicast video 8)
++ * Alan Cox : Rewrote net_bh and list manager.
++ * Alan Cox : Fix ETH_P_ALL echoback lengths.
++ * Alan Cox : Took out transmit every packet pass
++ * Saved a few bytes in the ioctl handler
++ * Alan Cox : Network driver sets packet type before
++ * calling netif_rx. Saves a function
++ * call a packet.
++ * Alan Cox : Hashed net_bh()
++ * Richard Kooijman: Timestamp fixes.
++ * Alan Cox : Wrong field in SIOCGIFDSTADDR
++ * Alan Cox : Device lock protection.
++ * Alan Cox : Fixed nasty side effect of device close
++ * changes.
++ * Rudi Cilibrasi : Pass the right thing to
++ * set_mac_address()
++ * Dave Miller : 32bit quantity for the device lock to
++ * make it work out on a Sparc.
++ * Bjorn Ekwall : Added KERNELD hack.
++ * Alan Cox : Cleaned up the backlog initialise.
++ * Craig Metz : SIOCGIFCONF fix if space for under
++ * 1 device.
++ * Thomas Bogendoerfer : Return ENODEV for dev_open, if there
++ * is no device open function.
++ * Andi Kleen : Fix error reporting for SIOCGIFCONF
++ * Michael Chastain : Fix signed/unsigned for SIOCGIFCONF
++ * Cyrus Durgin : Cleaned for KMOD
++ * Adam Sulmicki : Bug Fix : Network Device Unload
++ * A network device unload needs to purge
++ * the backlog queue.
++ * Paul Rusty Russell : SIOCSIFNAME
++ * Pekka Riikonen : Netdev boot-time settings code
++ * Andrew Morton : Make unregister_netdevice wait
++ * indefinitely on dev->refcnt
++ * J Hadi Salim : - Backlog queue sampling
++ * - netif_rx() feedback
++ */
++
++#include <asm/uaccess.h>
++#include <asm/system.h>
++#include <linux/bitops.h>
++#include <linux/capability.h>
++#include <linux/cpu.h>
++#include <linux/types.h>
++#include <linux/kernel.h>
++#include <linux/sched.h>
++#include <linux/mutex.h>
++#include <linux/string.h>
++#include <linux/mm.h>
++#include <linux/socket.h>
++#include <linux/sockios.h>
++#include <linux/errno.h>
++#include <linux/interrupt.h>
++#include <linux/if_ether.h>
++#include <linux/netdevice.h>
++#include <linux/etherdevice.h>
++#include <linux/notifier.h>
++#include <linux/skbuff.h>
++#include <net/sock.h>
++#include <linux/rtnetlink.h>
++#include <linux/proc_fs.h>
++#include <linux/seq_file.h>
++#include <linux/stat.h>
++#include <linux/if_bridge.h>
++#include <net/dst.h>
++#include <net/pkt_sched.h>
++#include <net/checksum.h>
++#include <linux/highmem.h>
++#include <linux/init.h>
++#include <linux/kmod.h>
++#include <linux/module.h>
++#include <linux/kallsyms.h>
++#include <linux/netpoll.h>
++#include <linux/rcupdate.h>
++#include <linux/delay.h>
++#include <linux/wireless.h>
++#include <net/iw_handler.h>
++#include <asm/current.h>
++#include <linux/audit.h>
++#include <linux/dmaengine.h>
++#include <linux/err.h>
++#include <linux/ctype.h>
++
++/*
++ * The list of packet types we will receive (as opposed to discard)
++ * and the routines to invoke.
++ *
++ * Why 16. Because with 16 the only overlap we get on a hash of the
++ * low nibble of the protocol value is RARP/SNAP/X.25.
++ *
++ * NOTE: That is no longer true with the addition of VLAN tags. Not
++ * sure which should go first, but I bet it won't make much
++ * difference if we are running VLANs. The good news is that
++ * this protocol won't be in the list unless compiled in, so
++ * the average user (w/out VLANs) will not be adversely affected.
++ * --BLG
++ *
++ * 0800 IP
++ * 8100 802.1Q VLAN
++ * 0001 802.3
++ * 0002 AX.25
++ * 0004 802.2
++ * 8035 RARP
++ * 0005 SNAP
++ * 0805 X.25
++ * 0806 ARP
++ * 8137 IPX
++ * 0009 Localtalk
++ * 86DD IPv6
++ */
++
++static DEFINE_SPINLOCK(ptype_lock);
++static struct list_head ptype_base[16]; /* 16 way hashed list */
++static struct list_head ptype_all; /* Taps */
++
++#ifdef CONFIG_NET_DMA
++static struct dma_client *net_dma_client;
++static unsigned int net_dma_count;
++static spinlock_t net_dma_event_lock;
++#endif
++
++/*
++ * The @dev_base list is protected by @dev_base_lock and the rtnl
++ * semaphore.
++ *
++ * Pure readers hold dev_base_lock for reading.
++ *
++ * Writers must hold the rtnl semaphore while they loop through the
<<Diff was trimmed, longer than 597 lines>>
More information about the pld-cvs-commit
mailing list