dummynet.c (ffbeadc45a6a262d956425e85cc836a6bbf02d19) | dummynet.c (fa8d2a59bc9c9e62abc0160ad59a9e6faad58773) |
---|---|
1/* 2 * Copyright (c) 2002-2003,2010 Luigi Rizzo 3 * 4 * Redistribution and use in source forms, with and without modification, 5 * are permitted provided that this entire comment appears intact. 6 * 7 * Redistribution in binary form may occur without any restrictions. 8 * Obviously, it would be nice if you gave credit where credit is due --- 747 unchanged lines hidden (view full) --- 756 * optional Pipe N config ... 757 * pipe ==> 758 */ 759void 760ipfw_config_pipe(int ac, char **av) 761{ 762 int i, j; 763 char *end; | 1/* 2 * Copyright (c) 2002-2003,2010 Luigi Rizzo 3 * 4 * Redistribution and use in source forms, with and without modification, 5 * are permitted provided that this entire comment appears intact. 6 * 7 * Redistribution in binary form may occur without any restrictions. 8 * Obviously, it would be nice if you gave credit where credit is due --- 747 unchanged lines hidden (view full) --- 756 * optional Pipe N config ... 757 * pipe ==> 758 */ 759void 760ipfw_config_pipe(int ac, char **av) 761{ 762 int i, j; 763 char *end; |
764 void *par = NULL; | |
765 struct dn_id *buf, *base; 766 struct dn_sch *sch = NULL; 767 struct dn_link *p = NULL; 768 struct dn_fs *fs = NULL; 769 struct dn_profile *pf = NULL; 770 struct ipfw_flow_id *mask = NULL; 771 int lmax; 772 uint32_t _foo = 0, *flags = &_foo , *buckets = &_foo; --- 127 unchanged lines hidden (view full) --- 900 case TOK_SCHED_MASK: 901 case TOK_MASK: 902 NEED(mask, "tok_mask"); 903 NEED1("mask needs mask specifier\n"); 904 /* 905 * per-flow queue, mask is dst_ip, dst_port, 906 * src_ip, src_port, proto measured in bits 907 */ | 764 struct dn_id *buf, *base; 765 struct dn_sch *sch = NULL; 766 struct dn_link *p = NULL; 767 struct dn_fs *fs = NULL; 768 struct dn_profile *pf = NULL; 769 struct ipfw_flow_id *mask = NULL; 770 int lmax; 771 uint32_t _foo = 0, *flags = &_foo , *buckets = &_foo; --- 127 unchanged lines hidden (view full) --- 899 case TOK_SCHED_MASK: 900 case TOK_MASK: 901 NEED(mask, "tok_mask"); 902 NEED1("mask needs mask specifier\n"); 903 /* 904 * per-flow queue, mask is dst_ip, dst_port, 905 * src_ip, src_port, proto measured in bits 906 */ |
908 par = NULL; | |
909 910 bzero(mask, sizeof(*mask)); 911 end = NULL; 912 913 while (ac >= 1) { 914 uint32_t *p32 = NULL; 915 uint16_t *p16 = NULL; 916 uint32_t *p20 = NULL; --- 257 unchanged lines hidden (view full) --- 1174 limit = 100; 1175 if (fs->qsize > limit) 1176 errx(EX_DATAERR, "2 <= queue size <= %ld", limit); 1177 } 1178 1179 if (fs->flags & DN_IS_RED) { 1180 size_t len; 1181 int lookup_depth, avg_pkt_size; | 907 908 bzero(mask, sizeof(*mask)); 909 end = NULL; 910 911 while (ac >= 1) { 912 uint32_t *p32 = NULL; 913 uint16_t *p16 = NULL; 914 uint32_t *p20 = NULL; --- 257 unchanged lines hidden (view full) --- 1172 limit = 100; 1173 if (fs->qsize > limit) 1174 errx(EX_DATAERR, "2 <= queue size <= %ld", limit); 1175 } 1176 1177 if (fs->flags & DN_IS_RED) { 1178 size_t len; 1179 int lookup_depth, avg_pkt_size; |
1182 double w_q; | |
1183 1184 if (fs->min_th >= fs->max_th) 1185 errx(EX_DATAERR, "min_th %d must be < than max_th %d", 1186 fs->min_th, fs->max_th); 1187 if (fs->max_th == 0) 1188 errx(EX_DATAERR, "max_th must be > 0"); 1189 1190 len = sizeof(int); --- 9 unchanged lines hidden (view full) --- 1200 &avg_pkt_size, &len, NULL, 0) == -1) 1201 avg_pkt_size = 512; 1202 1203 if (avg_pkt_size == 0) 1204 errx(EX_DATAERR, 1205 "net.inet.ip.dummynet.red_avg_pkt_size must" 1206 " be greater than zero"); 1207 | 1180 1181 if (fs->min_th >= fs->max_th) 1182 errx(EX_DATAERR, "min_th %d must be < than max_th %d", 1183 fs->min_th, fs->max_th); 1184 if (fs->max_th == 0) 1185 errx(EX_DATAERR, "max_th must be > 0"); 1186 1187 len = sizeof(int); --- 9 unchanged lines hidden (view full) --- 1197 &avg_pkt_size, &len, NULL, 0) == -1) 1198 avg_pkt_size = 512; 1199 1200 if (avg_pkt_size == 0) 1201 errx(EX_DATAERR, 1202 "net.inet.ip.dummynet.red_avg_pkt_size must" 1203 " be greater than zero"); 1204 |
1205#if 0 /* the following computation is now done in the kernel */ |
|
1208 /* 1209 * Ticks needed for sending a medium-sized packet. 1210 * Unfortunately, when we are configuring a WF2Q+ queue, we 1211 * do not have bandwidth information, because that is stored 1212 * in the parent pipe, and also we have multiple queues 1213 * competing for it. So we set s=0, which is not very 1214 * correct. But on the other hand, why do we want RED with 1215 * WF2Q+ ? 1216 */ | 1206 /* 1207 * Ticks needed for sending a medium-sized packet. 1208 * Unfortunately, when we are configuring a WF2Q+ queue, we 1209 * do not have bandwidth information, because that is stored 1210 * in the parent pipe, and also we have multiple queues 1211 * competing for it. So we set s=0, which is not very 1212 * correct. But on the other hand, why do we want RED with 1213 * WF2Q+ ? 1214 */ |
1217#if 0 | |
1218 if (p.bandwidth==0) /* this is a WF2Q+ queue */ 1219 s = 0; 1220 else 1221 s = (double)ck.hz * avg_pkt_size * 8 / p.bandwidth; | 1215 if (p.bandwidth==0) /* this is a WF2Q+ queue */ 1216 s = 0; 1217 else 1218 s = (double)ck.hz * avg_pkt_size * 8 / p.bandwidth; |
1222#endif | |
1223 /* 1224 * max idle time (in ticks) before avg queue size becomes 0. 1225 * NOTA: (3/w_q) is approx the value x so that 1226 * (1-w_q)^x < 10^-3. 1227 */ 1228 w_q = ((double)fs->w_q) / (1 << SCALE_RED); | 1219 /* 1220 * max idle time (in ticks) before avg queue size becomes 0. 1221 * NOTA: (3/w_q) is approx the value x so that 1222 * (1-w_q)^x < 10^-3. 1223 */ 1224 w_q = ((double)fs->w_q) / (1 << SCALE_RED); |
1229#if 0 // go in kernel | |
1230 idle = s * 3. / w_q; 1231 fs->lookup_step = (int)idle / lookup_depth; 1232 if (!fs->lookup_step) 1233 fs->lookup_step = 1; 1234 weight = 1 - w_q; 1235 for (t = fs->lookup_step; t > 1; --t) 1236 weight *= 1 - w_q; 1237 fs->lookup_weight = (int)(weight * (1 << SCALE_RED)); | 1225 idle = s * 3. / w_q; 1226 fs->lookup_step = (int)idle / lookup_depth; 1227 if (!fs->lookup_step) 1228 fs->lookup_step = 1; 1229 weight = 1 - w_q; 1230 for (t = fs->lookup_step; t > 1; --t) 1231 weight *= 1 - w_q; 1232 fs->lookup_weight = (int)(weight * (1 << SCALE_RED)); |
1238#endif | 1233#endif /* code moved in the kernel */ |
1239 } 1240 } 1241 1242 i = do_cmd(IP_DUMMYNET3, base, (char *)buf - (char *)base); 1243 1244 if (i) 1245 err(1, "setsockopt(%s)", "IP_DUMMYNET_CONFIGURE"); 1246} --- 148 unchanged lines hidden --- | 1234 } 1235 } 1236 1237 i = do_cmd(IP_DUMMYNET3, base, (char *)buf - (char *)base); 1238 1239 if (i) 1240 err(1, "setsockopt(%s)", "IP_DUMMYNET_CONFIGURE"); 1241} --- 148 unchanged lines hidden --- |