Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compat modifications #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion qdisc.c
Original file line number Diff line number Diff line change
Expand Up @@ -272,11 +272,21 @@ static int mq_dump_class_stats(struct Qdisc *sch, unsigned long cl,
struct gnet_dump *d)
{
struct netdev_queue *dev_queue = mq_queue_get(sch, cl);

#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0)
struct gnet_stats_basic_cpu __percpu *cpu_bstats = NULL;
struct gnet_stats_queue __percpu *cpu_qstats = NULL;
__u32 qlen;
#endif
sch = dev_queue->qdisc_sleeping;
sch->qstats.qlen = sch->q.qlen;
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,18,0)
if (gnet_stats_copy_basic(d, &sch->bstats) < 0 ||
gnet_stats_copy_queue(d, &sch->qstats) < 0)
#else
qlen = sch->q.qlen;
if (gnet_stats_copy_basic(d, cpu_bstats, &sch->bstats) < 0 ||
gnet_stats_copy_queue(d, cpu_qstats, &sch->qstats, qlen) < 0)
#endif
return -1;
return 0;
}
Expand Down
25 changes: 21 additions & 4 deletions stats.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ static void iso_stats_proc_seq_stop(struct seq_file *s, void *v)
static int iso_stats_proc_seq_show(struct seq_file *s, void *v)
{
struct hlist_head *head;
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0)
struct hlist_node *node;
#endif
struct iso_tx_class *txc;
struct iso_vq *vq, *vq_next;
struct iso_tx_context *txctx, *txctx_next;
Expand All @@ -50,7 +52,11 @@ static int iso_stats_proc_seq_show(struct seq_file *s, void *v)

for(i = 0; i < ISO_MAX_TX_BUCKETS; i++) {
head = &txctx->iso_tx_bucket[i];
hlist_for_each_entry_rcu(txc, node, head, hash_node) {
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0)
hlist_for_each_entry_rcu(txc, node, head, hash_node) {
#else
hlist_for_each_entry_rcu(txc, head, hash_node) {
#endif
iso_txc_show(txc, s);
}
}
Expand Down Expand Up @@ -107,7 +113,9 @@ static int iso_csvstats_proc_seq_show(struct seq_file *s, void *v) {
return 0;
}

#if LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)
static struct proc_dir_entry *iso_stats_proc;
#endif

static struct seq_operations iso_stats_proc_seq_ops = {
.start = iso_stats_proc_seq_start,
Expand All @@ -131,7 +139,9 @@ static struct file_operations iso_stats_proc_file_ops = {


/* For program friendly CSV stats */
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)
static struct proc_dir_entry *iso_csvstats_proc;
#endif

static struct seq_operations iso_csvstats_proc_seq_ops = {
.start = iso_stats_proc_seq_start,
Expand All @@ -157,14 +167,14 @@ static struct file_operations iso_csvstats_proc_file_ops = {
int iso_stats_init() {
int ret = 0;

#if LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)
iso_stats_proc = create_proc_entry(ISO_STATS_PROC_NAME, 0, NULL);
if(iso_stats_proc) {
iso_stats_proc->proc_fops = &iso_stats_proc_file_ops;
} else {
ret = 1;
goto out;
}

iso_csvstats_proc = create_proc_entry(ISO_CSVSTATS_PROC_NAME, 0, NULL);
if(iso_csvstats_proc) {
iso_csvstats_proc->proc_fops = &iso_csvstats_proc_file_ops;
Expand All @@ -173,8 +183,15 @@ int iso_stats_init() {
remove_proc_entry(ISO_STATS_PROC_NAME, NULL);
goto out;
}

out:
#else
proc_create(ISO_STATS_PROC_NAME, 0, NULL, &iso_stats_proc_file_ops);
proc_create(ISO_CSVSTATS_PROC_NAME, 0, NULL, &iso_csvstats_proc_file_ops);
#endif


#if LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)
out:
#endif
return ret;
}

Expand Down
52 changes: 47 additions & 5 deletions tx.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

#include <linux/netfilter_bridge.h>
#include <linux/if_ether.h>
#include <linux/list.h>
#include "tx.h"
#include "vq.h"

Expand Down Expand Up @@ -57,7 +58,10 @@ int iso_tx_init(struct iso_tx_context *context) {
void iso_tx_exit(struct iso_tx_context *context) {
int i;
struct hlist_head *head;
struct hlist_node *node, *nextnode;
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0)
struct *nextnode;
#endif
struct hlist_node *node;
struct iso_tx_class *txc;

iso_rl_exit(context->rlcb);
Expand All @@ -66,7 +70,11 @@ void iso_tx_exit(struct iso_tx_context *context) {

for(i = 0; i < ISO_MAX_TX_BUCKETS; i++) {
head = &context->iso_tx_bucket[i];
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0)
hlist_for_each_entry_safe(txc, nextnode, node, head, hash_node) {
#else
hlist_for_each_entry_safe(txc, node, head, hash_node) {
#endif
hlist_del(&txc->hash_node);
iso_txc_free(txc);
}
Expand Down Expand Up @@ -143,7 +151,9 @@ inline void iso_txc_tick(struct iso_tx_context *context) {
/* Called with rcu lock */
void iso_txc_show(struct iso_tx_class *txc, struct seq_file *s) {
int i, nth;
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0)
struct hlist_node *node;
#endif
struct hlist_head *head;
struct iso_rl *rl;
struct iso_per_dest_state *state;
Expand Down Expand Up @@ -171,7 +181,11 @@ void iso_txc_show(struct iso_tx_class *txc, struct seq_file *s) {
seq_printf(s, "per dest state:\n");
for(i = 0; i < ISO_MAX_STATE_BUCKETS; i++) {
head = &txc->state_bucket[i];
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0)
hlist_for_each_entry_rcu(state, node, head, hash_node) {
#else
hlist_for_each_entry_rcu(state, head, hash_node) {
#endif
seq_printf(s, "ip %x rl %p hash %d\n", state->ip_key, state->rl, i);
iso_rc_show(&state->tx_rc, s);
}
Expand All @@ -182,8 +196,11 @@ void iso_txc_show(struct iso_tx_class *txc, struct seq_file *s) {
for(i = 0; i < ISO_MAX_RL_BUCKETS; i++) {
head = &txc->rl_bucket[i];
nth = 0;

#if LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0)
hlist_for_each_entry_rcu(rl, node, head, hash_node) {
#else
hlist_for_each_entry_rcu(rl, head, hash_node) {
#endif
if(nth == 0) {
seq_printf(s, "hash %d ", i);
}
Expand Down Expand Up @@ -243,8 +260,9 @@ struct iso_per_dest_state
struct iphdr *iph;
struct iso_per_dest_state *state = NULL, *nextstate;
struct hlist_head *head;
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0)
struct hlist_node *node;

#endif
u32 ip, hash;

eth = eth_hdr(skb);
Expand All @@ -264,7 +282,11 @@ struct iso_per_dest_state
head = &txc->state_bucket[hash];

state = NULL;
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0)
hlist_for_each_entry_rcu(state, node, head, hash_node) {
#else
hlist_for_each_entry_rcu(state, head, hash_node) {
#endif
if(state->ip_key == ip)
break;
}
Expand All @@ -276,14 +298,17 @@ struct iso_per_dest_state
return NULL;

/* Check again; shouldn't we use a rwlock_t? */
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0)
hlist_for_each_entry_rcu(state, node, head, hash_node) {
#else
hlist_for_each_entry_rcu(state, head, hash_node) {
#endif
if(state->ip_key == ip)
break;
}

if(unlikely(state != NULL))
goto unlock;

list_for_each_entry_safe(state, nextstate, &txc->prealloc_state_list, prealloc_list) {
state->ip_key = ip;
state->rl = iso_pick_rl(txc, ip);
Expand Down Expand Up @@ -318,11 +343,17 @@ void iso_state_free(struct iso_per_dest_state *state) {
struct iso_rl *iso_pick_rl(struct iso_tx_class *txc, __le32 ip) {
struct iso_rl *rl = NULL, *temp;
struct hlist_head *head;
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0)
struct hlist_node *node;
#endif
rcu_read_lock();

head = &txc->rl_bucket[jhash_1word(ip, 0xfaceface) & (ISO_MAX_RL_BUCKETS - 1)];
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0)
hlist_for_each_entry_rcu(rl, node, head, hash_node) {
#else
hlist_for_each_entry_rcu(rl, head, hash_node) {
#endif
if(rl->ip == ip)
goto found;
}
Expand Down Expand Up @@ -453,7 +484,10 @@ void iso_txc_prealloc(struct iso_tx_class *txc, int num) {
/* Called with rcu lock */
void iso_txc_free(struct iso_tx_class *txc) {
struct hlist_head *head;
struct hlist_node *n, *nn;
struct hlist_node *n;
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0)
struct hlist_node *nn;
#endif
struct iso_rl *rl, *temprl;
struct iso_per_dest_state *state, *tempstate;
int i;
Expand All @@ -463,7 +497,11 @@ void iso_txc_free(struct iso_tx_class *txc) {
/* Kill each rate limiter */
for(i = 0; i < ISO_MAX_RL_BUCKETS; i++) {
head = &txc->rl_bucket[i];
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0)
hlist_for_each_entry_safe(rl, n, nn, head, hash_node) {
#else
hlist_for_each_entry_safe(rl, n, head, hash_node) {
#endif
hlist_del_init_rcu(&rl->hash_node);
iso_rl_free(rl);
}
Expand All @@ -472,7 +510,11 @@ void iso_txc_free(struct iso_tx_class *txc) {
/* Kill each state */
for(i = 0; i < ISO_MAX_STATE_BUCKETS; i++) {
head = &txc->state_bucket[i];
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0)
hlist_for_each_entry_safe(state, n, nn, head, hash_node) {
#else
hlist_for_each_entry_safe(state, n, head, hash_node) {
#endif
hlist_del_init_rcu(&state->hash_node);
iso_state_free(state);
}
Expand Down
7 changes: 6 additions & 1 deletion tx.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,15 @@ static inline struct iso_tx_class *iso_txc_find(iso_class_t klass, struct iso_tx
struct hlist_head *head = iso_txc_find_bucket(klass, context);
struct iso_tx_class *txc;
struct iso_tx_class *found = NULL;
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0)
struct hlist_node *n;

#endif
rcu_read_lock();
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0)
hlist_for_each_entry_rcu(txc, n, head, hash_node) {
#else
hlist_for_each_entry_rcu(txc, head, hash_node) {
#endif
if(iso_class_cmp(txc->klass, klass) == 0) {
found = txc;
break;
Expand Down
7 changes: 5 additions & 2 deletions vq.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,13 @@ void iso_vq_show(struct iso_vq *, struct seq_file *);
static inline struct iso_vq *iso_vq_find(iso_class_t klass, struct iso_rx_context *rxctx) {
u32 hash = iso_class_hash(klass);
struct hlist_head *head = &rxctx->vq_bucket[hash & (ISO_MAX_VQ_BUCKETS - 1)];
struct hlist_node *node;
struct iso_vq *vq;

#if LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0)
struct hlist_node *node;
hlist_for_each_entry_rcu(vq, node, head, hash_node) {
#else
hlist_for_each_entry_rcu(vq, head, hash_node) {
#endif
if(iso_class_cmp(vq->klass, klass) == 0)
return vq;
}
Expand Down