From 0ace2f8e64a62b0fa17b0acc993593b1030e80da Mon Sep 17 00:00:00 2001 From: Michael Blizek Date: Mon, 15 Feb 2010 19:44:45 +0100 Subject: [PATCH] matches_skb_connid_seqno bugfix on kernel packets, ref counter is_active is now gone (skb_procstate would have been bigger than sk_buff.cb, it is still too big for 64 bit archs...) --- net/cor/common.c | 25 ++++++++++--------------- net/cor/cor.h | 4 +--- net/cor/snd.c | 6 +++++- 3 files changed, 16 insertions(+), 19 deletions(-) diff --git a/net/cor/common.c b/net/cor/common.c index 9b7244f62f8..73ec2149154 100644 --- a/net/cor/common.c +++ b/net/cor/common.c @@ -64,13 +64,11 @@ int ref_counter_incr(struct ref_counter *cnt) int ret = 1; spin_lock_irqsave(&(cnt->lock), iflags); - if (likely(cnt->is_active)) { - ret = 0; - cnt->refs++; - } + ret = 0; + cnt->refs++; spin_unlock_irqrestore(&(cnt->lock), iflags); - return ret; + return 0; } void ref_counter_init(struct ref_counter *cnt, struct ref_counter_def *def) @@ -80,7 +78,6 @@ void ref_counter_init(struct ref_counter *cnt, struct ref_counter_def *def) spin_lock_init(&(cnt->lock)); cnt->refs = 1; - cnt->is_active = 1; cnt->def = def; } @@ -155,6 +152,8 @@ char *htable_get(struct htable *ht, __u32 key, void *searcheditem) unsigned long iflags; char *element; + printk(KERN_ERR "get %d", key); + if (ht->htable == 0) return 0; @@ -176,6 +175,8 @@ int htable_delete(struct htable *ht, __u32 key, char **next; int rc = 0; + printk(KERN_ERR "des %d", key); + if (ht->htable == 0) return 1; @@ -206,6 +207,8 @@ void htable_insert(struct htable *ht, char *newelement, __u32 key) unsigned long iflags; char **element; + printk(KERN_ERR "insert %d %d", (int) newelement, key); + if (ht->htable == 0) return; @@ -663,17 +666,9 @@ void reset_conn(struct conn *conn) static int matches_connid_in(void *htentry, void *searcheditem) { struct conn *conn = (struct conn *) htentry; - /*printk(KERN_ERR "conn is %d", (int) conn); - printk(KERN_ERR "item is %d", (int) searcheditem);*/ __u32 conn_id = *((__u32 *) searcheditem); - /* printk(KERN_ERR "1"); */ - if (conn->sourcetype != SOURCE_IN) - printk(KERN_ERR "bug"); BUG_ON(conn->sourcetype != SOURCE_IN); - /* printk(KERN_ERR "2"); */ - int res = (conn->source.in.conn_id == conn_id); - /* printk(KERN_ERR "3"); */ - return res; + return (conn->source.in.conn_id == conn_id); } static int __init cor_common_init(void) diff --git a/net/cor/cor.h b/net/cor/cor.h index 240aff7e970..576c8645b80 100644 --- a/net/cor/cor.h +++ b/net/cor/cor.h @@ -220,9 +220,6 @@ struct ref_counter{ /* initialised with 1 */ int refs; - /* initialised with 1, if 0 deny mem_counter_incr */ - int is_active; - /* should be a pointer to a global variable */ struct ref_counter_def *def; }; @@ -472,6 +469,7 @@ struct skb_procstate{ unsigned long timeout; __u32 conn_id; __u32 seqno; + struct neighbor *nb; }retransmit_queue; }funcstate; }; diff --git a/net/cor/snd.c b/net/cor/snd.c index 29c3d552997..21289b82dcd 100644 --- a/net/cor/snd.c +++ b/net/cor/snd.c @@ -234,8 +234,12 @@ static struct sk_buff *create_packet(struct neighbor *nb, int size, ps->rconn = target; memset(&(ps->funcstate.retransmit_queue), 0, sizeof(ps->funcstate.retransmit_queue)); + #warning todo funcstate.retransmit_queue.htab_entry ps->funcstate.retransmit_queue.conn_id = conn_id; ps->funcstate.retransmit_queue.seqno = seqno; + ps->funcstate.retransmit_queue.nb = nb; + #warning todo decr refcnt + ref_counter_incr(&(nb->refs)); dest = skb_put(ret, 9); BUG_ON(0 == dest); @@ -419,7 +423,7 @@ static int matches_skb_connid_seqno(void *htentry, void *searcheditem) return rm->conn_id == ps->funcstate.retransmit_queue.conn_id && rm->seqno == ps->funcstate.retransmit_queue.seqno && - rm->nb == ps->rconn->target.out.nb; + rm->nb == ps->funcstate.retransmit_queue.nb; } static inline __u32 retransmit_entryoffset(void) -- 2.11.4.GIT