From 7d33d3b1d50f40f76d792d23f80e64cfbe24acb0 Mon Sep 17 00:00:00 2001 From: Michael Blizek Date: Wed, 17 Mar 2010 19:06:29 +0100 Subject: [PATCH] ping send timing, skb memory leak --- net/cor/cor.h | 6 ++++++ net/cor/kpacket_gen.c | 35 +++++++++++++++++++++++++---------- net/cor/kpacket_parse.c | 2 -- net/cor/neighbor.c | 6 ++---- net/cor/snd.c | 25 ++++++++++++++++--------- 5 files changed, 49 insertions(+), 25 deletions(-) diff --git a/net/cor/cor.h b/net/cor/cor.h index 6d0dc5f95cd..d971396bc9a 100644 --- a/net/cor/cor.h +++ b/net/cor/cor.h @@ -274,6 +274,10 @@ struct neighbor{ struct list_head control_msgs_out; __u64 timeout; __u32 length; + unsigned long last_ping_time; + __u32 noping_cnt; + + atomic_t kpacket_seqno; atomic_t ooo_packets; @@ -544,6 +548,8 @@ extern void ping_resp(struct neighbor *nb, __u32 cookie, __u32 respdelay); extern __u32 add_ping_req(struct neighbor *nb); +extern int force_ping(struct neighbor *nb); + extern void rcv_announce(struct sk_buff *skb); extern int __init cor_neighbor_init(void); diff --git a/net/cor/kpacket_gen.c b/net/cor/kpacket_gen.c index ee720eef068..1b57dcdbfe9 100644 --- a/net/cor/kpacket_gen.c +++ b/net/cor/kpacket_gen.c @@ -325,20 +325,34 @@ static void _send_messages(struct neighbor *nb, struct sk_buff *skb, static void send_messages(struct neighbor *nb, int allmsgs) { int targetmss = mss(nb); - __u32 pingcookie; + int ping = 0; + + int pingdelay1 = 1000; + int pingdelay2 = 400; mutex_lock(&(nb->cmsg_lock)); BUG_ON(list_empty(&(nb->control_msgs_out)) && (nb->length != 0)); BUG_ON((list_empty(&(nb->control_msgs_out)) == 0) && (nb->length == 0)); + + ping = time_before_eq(nb->last_ping_time + msecs_to_jiffies(pingdelay1), + jiffies); - while (likely(list_empty(&(nb->control_msgs_out)) == 0) && - (nb->length >= targetmss || allmsgs)) { - pingcookie = add_ping_req(nb); - + while ((list_empty(&(nb->control_msgs_out)) == 0 && + (nb->length >= targetmss || allmsgs)) || + ping) { struct sk_buff *skb; int size = targetmss; - __u32 length = nb->length + (pingcookie != 0 ? 5 : 0); + __u32 length; + + if (nb->noping_cnt > 3) + ping = 1; + if (time_before_eq(nb->last_ping_time + + msecs_to_jiffies(pingdelay2), jiffies)) + ping = 1; + nb->noping_cnt++; + + length = nb->length + (ping != 0 ? 5 : 0); if (size > length) size = length; mutex_unlock(&(nb->cmsg_lock)); @@ -349,12 +363,15 @@ static void send_messages(struct neighbor *nb, int allmsgs) goto out; } - if (pingcookie != 0) { + if (ping) { + __u32 pingcookie = add_ping_req(nb); int rc = add_ping(skb, pingcookie, size); if (rc == 0) goto err; + nb->noping_cnt = 0; + nb->last_ping_time = jiffies; size -= rc; - + ping = 0; } _send_messages(nb, skb, size); @@ -417,8 +434,6 @@ void schedule_controlmsg_timerfunc(struct neighbor *nb) static void add_control_msg(struct control_msg_out *msg, struct neighbor *nb) { BUG_ON(msg == 0); - - printk(KERN_ERR "add_msg %d", msg->type); mutex_lock(&(nb->cmsg_lock)); diff --git a/net/cor/kpacket_parse.c b/net/cor/kpacket_parse.c index ed6f4d4dff5..ef4fd30c9ca 100644 --- a/net/cor/kpacket_parse.c +++ b/net/cor/kpacket_parse.c @@ -208,8 +208,6 @@ static void kernel_packet2(struct neighbor *nb, struct sk_buff *skb, break; code = *codeptr; - - printk(KERN_ERR "parse2_1 %d", code); switch (code) { case KP_PADDING: diff --git a/net/cor/neighbor.c b/net/cor/neighbor.c index f03a21e185e..1417ccb27ac 100644 --- a/net/cor/neighbor.c +++ b/net/cor/neighbor.c @@ -126,14 +126,12 @@ static struct neighbor *alloc_neighbor(gfp_t allocflags) ref_counter_init(&(nb->refs), &neighbor_ref); mutex_init(&(nb->cmsg_lock)); - /*struct control_msg_out *first_cm; - struct control_msg_out *last_cm; - unsigned long timedue;*/ - nb->latency = 10; INIT_LIST_HEAD(&(nb->control_msgs_out)); + nb->last_ping_time = jiffies; atomic_set(&(nb->ooo_packets), 0); get_random_bytes((char *) &seqno, sizeof(seqno)); atomic_set(&(nb->kpacket_seqno), seqno); + nb->latency = 10; mutex_init(&(nb->conn_list_lock)); INIT_LIST_HEAD(&(nb->rcv_conn_list)); INIT_LIST_HEAD(&(nb->snd_conn_list)); diff --git a/net/cor/snd.c b/net/cor/snd.c index 385998ab810..74356fcbcc7 100644 --- a/net/cor/snd.c +++ b/net/cor/snd.c @@ -145,21 +145,24 @@ static int cor_enqueue(struct sk_buff *skb, struct Qdisc *sch) return NET_XMIT_SUCCESS; } */ -static void cor_xmit(struct sk_buff *skb, int atomic) +static void cor_xmit(struct sk_buff *skb, int atomic, int clone) { struct sk_buff *skb2; BUG_ON(skb == 0); - skb2 = skb_clone(skb, __GFP_DMA | (atomic ? GFP_ATOMIC : GFP_KERNEL)); + if (clone) { + skb2 = skb_clone(skb, __GFP_DMA | (atomic ? GFP_ATOMIC : GFP_KERNEL)); - if (skb2 == 0) { - printk(KERN_WARNING "cor_xmit: cannot clone skb, " - "allocation failure?"); - return; + if (skb2 == 0) { + printk(KERN_WARNING "cor_xmit: cannot clone skb, " + "allocation failure?"); + return; + } + } else { + skb2 = skb; } - printk(KERN_ERR "xmit"); dev_queue_xmit(skb2); } @@ -197,7 +200,7 @@ void retransmit_timerfunc(unsigned long arg) __skb_queue_tail(&(nb->retrans_list), skb); spin_unlock_irqrestore( &(nb->retrans_lock), iflags ); - cor_xmit(skb, 1); + cor_xmit(skb, 1, 1); } modtimer: @@ -329,7 +332,7 @@ void send_packet(struct sk_buff *skb, struct neighbor *nb, int retransmit) if (ps->rconn != 0) ref_counter_incr(&(ps->rconn->refs)); - cor_xmit(skb, 0); + cor_xmit(skb, 0, retransmit); } void ack_received(struct neighbor *nb, __u32 conn_id, __u32 seqno) @@ -370,6 +373,10 @@ void ack_received(struct neighbor *nb, __u32 conn_id, __u32 seqno) skb->next->prev = skb->prev; skb->prev->next = skb->next; + #warning todo ps->rconn refcnt ? + + kfree_skb(skb); + if (first) { if (unlikely(skb_queue_empty(&(nb->retrans_list)))) { mod_timer(&(nb->retrans_timer), jiffies + nb->latency); -- 2.11.4.GIT