From: S.Çağlar Onur <caglar@cs.princeton.edu>
Date: Tue, 7 Dec 2010 11:07:40 -0500
Subject: [PATCH] linux-2.6-525-sknid-elevator.patch
-
+
---
include/linux/netdevice.h | 1 +
net/core/dev.c | 30 +++++++++++++++++++
3 files changed, 100 insertions(+), 2 deletions(-)
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
-index 17b0c3c..186d772 100644
+index 3af28fb..8730e89 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
-@@ -1099,6 +1099,7 @@ struct napi_gro_cb {
+@@ -1259,6 +1259,7 @@ struct napi_gro_cb {
struct packet_type {
__be16 type; /* This is really htons(ether_type). */
struct net_device *dev; /* NULL is wildcarded here */
struct net_device *,
struct packet_type *,
diff --git a/net/core/dev.c b/net/core/dev.c
-index 32a2b7e..7fda319 100644
+index 1226d0d..e8d66b6 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -99,6 +99,8 @@
#include <linux/if_bridge.h>
#include <linux/if_macvlan.h>
#include <net/dst.h>
-@@ -2333,6 +2335,10 @@ void netif_nit_deliver(struct sk_buff *skb)
+@@ -2620,6 +2622,10 @@ void netif_nit_deliver(struct sk_buff *skb)
rcu_read_unlock();
}
+ * sequentially on the same CPU. -Sapan */
+DEFINE_PER_CPU(int, sknid_elevator) = 0;
+
- /**
- * netif_receive_skb - process receive buffer from network
- * @skb: buffer to process
-@@ -2355,8 +2361,11 @@ int netif_receive_skb(struct sk_buff *skb)
+ int __netif_receive_skb(struct sk_buff *skb)
+ {
+ struct packet_type *ptype, *pt_prev;
+@@ -2627,8 +2633,11 @@ int __netif_receive_skb(struct sk_buff *skb)
struct net_device *null_or_orig;
struct net_device *null_or_bond;
int ret = NET_RX_DROP;
if (!skb->tstamp.tv64)
net_timestamp(skb);
-@@ -2456,7 +2465,27 @@ ncls:
+@@ -2729,7 +2738,27 @@ ncls:
}
if (pt_prev) {
+ /* At this point, cur_elevator may be -2 or a positive value, in
-+ * case a previous protocol handler marked it */
-+ if (*cur_elevator) {
-+ atomic_inc(&skb->users);
-+ }
-+
++ * case a previous protocol handler marked it */
++ if (*cur_elevator) {
++ atomic_inc(&skb->users);
++ }
++
ret = pt_prev->func(skb, skb->dev, pt_prev, orig_dev);
+
-+ if ((*cur_elevator)>0) {
-+ skb->skb_tag = *cur_elevator;
-+ list_for_each_entry_rcu(ptype, &ptype_all, list) {
-+ if ((!ptype->dev || ptype->dev == skb->dev) && (ptype->sknid_elevator)) {
-+ ret = deliver_skb(skb, ptype, orig_dev);
-+ }
-+ }
-+ }
-+
-+ if (*cur_elevator) {
-+ /* We have a packet */
-+ kfree_skb(skb);
-+ }
++ if ((*cur_elevator)>0) {
++ skb->skb_tag = *cur_elevator;
++ list_for_each_entry_rcu(ptype, &ptype_all, list) {
++ if ((!ptype->dev || ptype->dev == skb->dev) && (ptype->sknid_elevator)) {
++ ret = deliver_skb(skb, ptype, orig_dev);
++ }
++ }
++ }
++
++ if (*cur_elevator) {
++ /* We have a packet */
++ kfree_skb(skb);
++ }
} else {
kfree_skb(skb);
/* Jamal, now you will not able to escape explaining
-@@ -4210,6 +4239,7 @@ unsigned dev_get_flags(const struct net_device *dev)
+@@ -4576,6 +4605,7 @@ unsigned dev_get_flags(const struct net_device *dev)
return flags;
}
EXPORT_SYMBOL(dev_get_flags);
/**
* dev_change_flags - change device settings
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
-index b4bf950..cbf8d22 100644
+index d67f5e4..fcaa094 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -78,6 +78,7 @@
+#include <linux/vs_network.h>
#include <linux/mutex.h>
#include <linux/if_vlan.h>
-
-@@ -338,12 +339,54 @@ static const struct proto_ops packet_ops;
+ #include <linux/net_tstamp.h>
+@@ -340,12 +341,54 @@ static const struct proto_ops packet_ops;
static const struct proto_ops packet_ops_spkt;
/*
* When we registered the protocol we saved the socket in the data
* field for just this event.
-@@ -362,6 +405,16 @@ static int packet_rcv_spkt(struct sk_buff *skb, struct net_device *dev,
+@@ -364,6 +407,16 @@ static int packet_rcv_spkt(struct sk_buff *skb, struct net_device *dev,
* so that this procedure is noop.
*/
if (skb->pkt_type == PACKET_LOOPBACK)
goto out;
-@@ -420,6 +473,9 @@ static int packet_sendmsg_spkt(struct kiocb *iocb, struct socket *sock,
+@@ -422,6 +475,9 @@ static int packet_sendmsg_spkt(struct kiocb *iocb, struct socket *sock,
__be16 proto = 0;
int err;
/*
* Get and verify the address.
*/
-@@ -510,11 +566,16 @@ out_unlock:
+@@ -512,11 +568,16 @@ out_unlock:
return err;
}
rcu_read_lock_bh();
filter = rcu_dereference(sk->sk_filter);
if (filter != NULL)
-@@ -1073,6 +1134,9 @@ static int packet_snd(struct socket *sock,
+@@ -1088,6 +1149,9 @@ static int packet_snd(struct socket *sock,
unsigned char *addr;
int ifindex, err, reserve = 0;
/*
* Get and verify the address.
*/
-@@ -1258,6 +1322,7 @@ static int packet_do_bind(struct sock *sk, struct net_device *dev, __be16 protoc
+@@ -1273,6 +1337,7 @@ static int packet_do_bind(struct sock *sk, struct net_device *dev, __be16 protoc
po->num = protocol;
po->prot_hook.type = protocol;
po->prot_hook.dev = dev;
po->ifindex = dev ? dev->ifindex : 0;
-@@ -1358,8 +1423,9 @@ static int packet_create(struct net *net, struct socket *sock, int protocol,
+@@ -1373,8 +1438,9 @@ static int packet_create(struct net *net, struct socket *sock, int protocol,
__be16 proto = (__force __be16)protocol; /* weird, but documented */
int err;
if (sock->type != SOCK_DGRAM && sock->type != SOCK_RAW &&
sock->type != SOCK_PACKET)
return -ESOCKTNOSUPPORT;
-@@ -1391,6 +1457,7 @@ static int packet_create(struct net *net, struct socket *sock, int protocol,
+@@ -1406,6 +1472,7 @@ static int packet_create(struct net *net, struct socket *sock, int protocol,
spin_lock_init(&po->bind_lock);
mutex_init(&po->pg_vec_lock);
po->prot_hook.func = packet_rcv;
if (sock->type == SOCK_PACKET)
po->prot_hook.func = packet_rcv_spkt;
---
-1.5.4.3
-