ip_dummynet.c (163758) | ip_dummynet.c (169454) |
---|---|
1/*- 2 * Copyright (c) 1998-2002 Luigi Rizzo, Universita` di Pisa 3 * Portions Copyright (c) 2000 Akamba Corp. 4 * All rights reserved 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 10 unchanged lines hidden (view full) --- 19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 * SUCH DAMAGE. 26 * | 1/*- 2 * Copyright (c) 1998-2002 Luigi Rizzo, Universita` di Pisa 3 * Portions Copyright (c) 2000 Akamba Corp. 4 * All rights reserved 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 10 unchanged lines hidden (view full) --- 19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 * SUCH DAMAGE. 26 * |
27 * $FreeBSD: head/sys/netinet/ip_dummynet.c 163758 2006-10-29 12:09:24Z oleg $ | 27 * $FreeBSD: head/sys/netinet/ip_dummynet.c 169454 2007-05-10 15:58:48Z rwatson $ |
28 */ 29 30#define DUMMYNET_DEBUG 31 32#include "opt_inet6.h" 33 34/* 35 * This module implements IP dummynet, a bandwidth limiter/delay emulator --- 465 unchanged lines hidden (view full) --- 501 ((_m)->m_pkthdr.len*8*hz - (q)->numbytes + p->bandwidth - 1 ) / \ 502 p->bandwidth ; 503 504/* 505 * extract pkt from queue, compute output time (could be now) 506 * and put into delay line (p_queue) 507 */ 508static void | 28 */ 29 30#define DUMMYNET_DEBUG 31 32#include "opt_inet6.h" 33 34/* 35 * This module implements IP dummynet, a bandwidth limiter/delay emulator --- 465 unchanged lines hidden (view full) --- 501 ((_m)->m_pkthdr.len*8*hz - (q)->numbytes + p->bandwidth - 1 ) / \ 502 p->bandwidth ; 503 504/* 505 * extract pkt from queue, compute output time (could be now) 506 * and put into delay line (p_queue) 507 */ 508static void |
509move_pkt(struct mbuf *pkt, struct dn_flow_queue *q, 510 struct dn_pipe *p, int len) | 509move_pkt(struct mbuf *pkt, struct dn_flow_queue *q, struct dn_pipe *p, 510 int len) |
511{ 512 struct dn_pkt_tag *dt = dn_tag_get(pkt); 513 514 q->head = pkt->m_nextpkt ; 515 q->len-- ; 516 q->len_bytes -= len ; 517 518 dt->output_time = curr_time + p->delay ; --- 197 unchanged lines hidden (view full) --- 716 717/* 718 * This is called one tick, after previous run. It is used to 719 * schedule next run. 720 */ 721static void 722dummynet(void * __unused unused) 723{ | 511{ 512 struct dn_pkt_tag *dt = dn_tag_get(pkt); 513 514 q->head = pkt->m_nextpkt ; 515 q->len-- ; 516 q->len_bytes -= len ; 517 518 dt->output_time = curr_time + p->delay ; --- 197 unchanged lines hidden (view full) --- 716 717/* 718 * This is called one tick, after previous run. It is used to 719 * schedule next run. 720 */ 721static void 722dummynet(void * __unused unused) 723{ |
724 |
|
724 taskqueue_enqueue(dn_tq, &dn_task); 725} 726 727/* 728 * The main dummynet processing function. 729 */ 730static void 731dummynet_task(void *context, int pending) 732{ | 725 taskqueue_enqueue(dn_tq, &dn_task); 726} 727 728/* 729 * The main dummynet processing function. 730 */ 731static void 732dummynet_task(void *context, int pending) 733{ |
733 | |
734 struct mbuf *head = NULL, *tail = NULL; 735 struct dn_pipe *pipe; 736 struct dn_heap *heaps[3]; 737 struct dn_heap *h; 738 void *p; /* generic parameter to handler */ 739 int i; 740 741 NET_LOCK_GIANT(); --- 804 unchanged lines hidden (view full) --- 1546 } 1547 DUMMYNET_UNLOCK(); 1548} 1549 1550/* 1551 * setup RED parameters 1552 */ 1553static int | 734 struct mbuf *head = NULL, *tail = NULL; 735 struct dn_pipe *pipe; 736 struct dn_heap *heaps[3]; 737 struct dn_heap *h; 738 void *p; /* generic parameter to handler */ 739 int i; 740 741 NET_LOCK_GIANT(); --- 804 unchanged lines hidden (view full) --- 1546 } 1547 DUMMYNET_UNLOCK(); 1548} 1549 1550/* 1551 * setup RED parameters 1552 */ 1553static int |
1554config_red(struct dn_flow_set *p, struct dn_flow_set * x) | 1554config_red(struct dn_flow_set *p, struct dn_flow_set *x) |
1555{ 1556 int i; 1557 1558 x->w_q = p->w_q; 1559 x->min_th = SCALE(p->min_th); 1560 x->max_th = SCALE(p->max_th); 1561 x->max_p = p->max_p; 1562 --- 250 unchanged lines hidden (view full) --- 1813 } 1814 } 1815} 1816 1817/* 1818 * drain all queues. Called in case of severe mbuf shortage. 1819 */ 1820void | 1555{ 1556 int i; 1557 1558 x->w_q = p->w_q; 1559 x->min_th = SCALE(p->min_th); 1560 x->max_th = SCALE(p->max_th); 1561 x->max_p = p->max_p; 1562 --- 250 unchanged lines hidden (view full) --- 1813 } 1814 } 1815} 1816 1817/* 1818 * drain all queues. Called in case of severe mbuf shortage. 1819 */ 1820void |
1821dummynet_drain() | 1821dummynet_drain(void) |
1822{ 1823 struct dn_flow_set *fs; 1824 struct dn_pipe *pipe; 1825 struct mbuf *m, *mnext; 1826 int i; 1827 1828 DUMMYNET_LOCK_ASSERT(); 1829 --- 20 unchanged lines hidden (view full) --- 1850} 1851 1852/* 1853 * Fully delete a pipe or a queue, cleaning up associated info. 1854 */ 1855static int 1856delete_pipe(struct dn_pipe *p) 1857{ | 1822{ 1823 struct dn_flow_set *fs; 1824 struct dn_pipe *pipe; 1825 struct mbuf *m, *mnext; 1826 int i; 1827 1828 DUMMYNET_LOCK_ASSERT(); 1829 --- 20 unchanged lines hidden (view full) --- 1850} 1851 1852/* 1853 * Fully delete a pipe or a queue, cleaning up associated info. 1854 */ 1855static int 1856delete_pipe(struct dn_pipe *p) 1857{ |
1858 |
|
1858 if (p->pipe_nr == 0 && p->fs.fs_nr == 0) 1859 return EINVAL ; 1860 if (p->pipe_nr != 0 && p->fs.fs_nr != 0) 1861 return EINVAL ; 1862 if (p->pipe_nr != 0) { /* this is an old-style pipe */ 1863 struct dn_pipe *pipe; 1864 struct dn_flow_set *fs; 1865 int i; --- 299 unchanged lines hidden (view full) --- 2165 2166 DUMMYNET_LOCK_DESTROY(); 2167} 2168#endif /* KLD_MODULE */ 2169 2170static int 2171dummynet_modevent(module_t mod, int type, void *data) 2172{ | 1859 if (p->pipe_nr == 0 && p->fs.fs_nr == 0) 1860 return EINVAL ; 1861 if (p->pipe_nr != 0 && p->fs.fs_nr != 0) 1862 return EINVAL ; 1863 if (p->pipe_nr != 0) { /* this is an old-style pipe */ 1864 struct dn_pipe *pipe; 1865 struct dn_flow_set *fs; 1866 int i; --- 299 unchanged lines hidden (view full) --- 2166 2167 DUMMYNET_LOCK_DESTROY(); 2168} 2169#endif /* KLD_MODULE */ 2170 2171static int 2172dummynet_modevent(module_t mod, int type, void *data) 2173{ |
2174 |
|
2173 switch (type) { 2174 case MOD_LOAD: 2175 if (DUMMYNET_LOADED) { 2176 printf("DUMMYNET already loaded\n"); 2177 return EEXIST ; 2178 } 2179 ip_dn_init(); 2180 break; --- 24 unchanged lines hidden --- | 2175 switch (type) { 2176 case MOD_LOAD: 2177 if (DUMMYNET_LOADED) { 2178 printf("DUMMYNET already loaded\n"); 2179 return EEXIST ; 2180 } 2181 ip_dn_init(); 2182 break; --- 24 unchanged lines hidden --- |