From 1917ef996d1b6aa6232992bf93d6f7c6b477235f Mon Sep 17 00:00:00 2001 From: Oleg Bulyzhin Date: Mon, 15 Jun 2009 17:14:47 +0000 Subject: [PATCH] Since dn_pipe.numbytes is int64_t now - remove unnecessary overflow detection code in ready_event_wfq(). --- sys/netinet/ipfw/ip_dummynet.c | 28 +++++++--------------------- 1 file changed, 7 insertions(+), 21 deletions(-) diff --git a/sys/netinet/ipfw/ip_dummynet.c b/sys/netinet/ipfw/ip_dummynet.c index d237433f0f30..bf54839ec7fa 100644 --- a/sys/netinet/ipfw/ip_dummynet.c +++ b/sys/netinet/ipfw/ip_dummynet.c @@ -56,7 +56,6 @@ __FBSDID("$FreeBSD$"); * include files marked with XXX are probably not needed */ -#include #include #include #include @@ -686,16 +685,11 @@ ready_event_wfq(struct dn_pipe *p, struct mbuf **head, struct mbuf **tail) int p_was_empty = (p->head == NULL); struct dn_heap *sch = &(p->scheduler_heap); struct dn_heap *neh = &(p->not_eligible_heap); - int64_t p_numbytes = p->numbytes; DUMMYNET_LOCK_ASSERT(); if (p->if_name[0] == 0) /* tx clock is simulated */ - /* - * Since result may not fit into p->numbytes (32bit) we - * are using 64bit var here. - */ - p_numbytes += (curr_time - p->sched_time) * p->bandwidth; + p->numbytes += (curr_time - p->sched_time) * p->bandwidth; else { /* * tx clock is for real, * the ifq must be empty or this is a NOP. @@ -712,7 +706,7 @@ ready_event_wfq(struct dn_pipe *p, struct mbuf **head, struct mbuf **tail) * While we have backlogged traffic AND credit, we need to do * something on the queue. */ - while (p_numbytes >= 0 && (sch->elements > 0 || neh->elements > 0)) { + while (p->numbytes >= 0 && (sch->elements > 0 || neh->elements > 0)) { if (sch->elements > 0) { /* Have some eligible pkts to send out. */ struct dn_flow_queue *q = sch->p[0].object; @@ -722,7 +716,7 @@ ready_event_wfq(struct dn_pipe *p, struct mbuf **head, struct mbuf **tail) int len_scaled = p->bandwidth ? len * 8 * hz : 0; heap_extract(sch, NULL); /* Remove queue from heap. */ - p_numbytes -= len_scaled; + p->numbytes -= len_scaled; move_pkt(pkt, q, p, len); p->V += (len << MY_M) / p->sum; /* Update V. */ @@ -763,11 +757,11 @@ ready_event_wfq(struct dn_pipe *p, struct mbuf **head, struct mbuf **tail) } if (p->if_name[0] != '\0') { /* Tx clock is from a real thing */ - p_numbytes = -1; /* Mark not ready for I/O. */ + p->numbytes = -1; /* Mark not ready for I/O. */ break; } } - if (sch->elements == 0 && neh->elements == 0 && p_numbytes >= 0 && + if (sch->elements == 0 && neh->elements == 0 && p->numbytes >= 0 && p->idle_heap.elements > 0) { /* * No traffic and no events scheduled. @@ -790,11 +784,11 @@ ready_event_wfq(struct dn_pipe *p, struct mbuf **head, struct mbuf **tail) * If we are under credit, schedule the next ready event. * Also fix the delivery time of the last packet. */ - if (p->if_name[0]==0 && p_numbytes < 0) { /* This implies bw > 0. */ + if (p->if_name[0]==0 && p->numbytes < 0) { /* This implies bw > 0. */ dn_key t = 0; /* Number of ticks i have to wait. */ if (p->bandwidth > 0) - t = (p->bandwidth - 1 - p_numbytes) / p->bandwidth; + t = (p->bandwidth - 1 - p->numbytes) / p->bandwidth; dn_tag_get(p->tail)->output_time += t; p->sched_time = curr_time; heap_insert(&wfq_ready_heap, curr_time + t, (void *)p); @@ -804,14 +798,6 @@ ready_event_wfq(struct dn_pipe *p, struct mbuf **head, struct mbuf **tail) */ } - /* Fit (adjust if necessary) 64bit result into 32bit variable. */ - if (p_numbytes > INT_MAX) - p->numbytes = INT_MAX; - else if (p_numbytes < INT_MIN) - p->numbytes = INT_MIN; - else - p->numbytes = p_numbytes; - /* * If the delay line was empty call transmit_event() now. * Otherwise, the scheduler will take care of it.