Lines Matching refs:ipf
125 struct ipflow *ipf;
129 ipf = LIST_FIRST(&ipflows[hash]);
130 while (ipf != NULL) {
131 if (ip->ip_dst.s_addr == ipf->ipf_dst.s_addr
132 && ip->ip_src.s_addr == ipf->ipf_src.s_addr
133 && ip->ip_tos == ipf->ipf_tos)
135 ipf = LIST_NEXT(ipf, ipf_next);
137 return ipf;
145 struct ipflow *ipf;
165 if ((ipf = ipflow_lookup(ip)) == NULL)
171 rt = ipf->ipf_ro.ro_rt;
195 ipf->ipf_uses++;
196 ipf->ipf_timer = IPFLOW_TIMER;
201 dst = &ipf->ipf_ro.ro_dst;
210 ipf->ipf_dropped++;
212 ipf->ipf_errors++;
220 struct ipflow *ipf)
222 ipf->ipf_ro.ro_rt->rt_use += ipf->ipf_uses;
223 OSAddAtomic(ipf->ipf_errors + ipf->ipf_dropped, (SInt32*)&ipstat.ips_cantforward);
224 OSAddAtomic(ipf->ipf_uses, (SInt32*)&ipstat.ips_forward);
225 OSAddAtomic(ipf->ipf_uses, (SInt32*)&ipstat.ips_fastforward);
230 struct ipflow *ipf)
237 LIST_REMOVE(ipf, ipf_next);
238 ipflow_addstats(ipf);
239 rtfree(ipf->ipf_ro.ro_rt);
241 FREE(ipf, M_IPFLOW);
248 struct ipflow *ipf, *maybe_ipf = NULL;
252 ipf = LIST_FIRST(&ipflows[idx]);
253 while (ipf != NULL) {
258 if ((ipf->ipf_ro.ro_rt->rt_flags & RTF_UP) == 0)
266 || ipf->ipf_timer < maybe_ipf->ipf_timer
267 || (ipf->ipf_timer == maybe_ipf->ipf_timer
268 && ipf->ipf_last_uses + ipf->ipf_uses <
271 maybe_ipf = ipf;
272 ipf = LIST_NEXT(ipf, ipf_next);
275 ipf = maybe_ipf;
280 LIST_REMOVE(ipf, ipf_next);
281 ipflow_addstats(ipf);
282 rtfree(ipf->ipf_ro.ro_rt);
283 ipf->ipf_ro.ro_rt = NULL;
284 return ipf;
291 struct ipflow *ipf;
295 ipf = LIST_FIRST(&ipflows[idx]);
296 while (ipf != NULL) {
297 struct ipflow *next_ipf = LIST_NEXT(ipf, ipf_next);
298 if (--ipf->ipf_timer == 0) {
299 ipflow_free(ipf);
301 ipf->ipf_last_uses = ipf->ipf_uses;
302 ipf->ipf_ro.ro_rt->rt_use += ipf->ipf_uses;
303 OSAddAtomic(ipf->ipf_uses, (SInt32*)&ipstat.ips_forward);
304 OSAddAtomic(ipf->ipf_uses, (SInt32*)&ipstat.ips_fastforward);
305 ipstat.ips_forward += ipf->ipf_uses;
306 ipstat.ips_fastforward += ipf->ipf_uses;
307 ipf->ipf_uses = 0;
309 ipf = next_ipf;
320 struct ipflow *ipf;
333 ipf = ipflow_lookup(ip);
334 if (ipf == NULL) {
336 ipf = ipflow_reap();
338 ipf = (struct ipflow *) _MALLOC(sizeof(*ipf), M_IPFLOW,
340 if (ipf == NULL)
344 bzero((caddr_t) ipf, sizeof(*ipf));
346 LIST_REMOVE(ipf, ipf_next);
347 ipflow_addstats(ipf);
348 rtfree(ipf->ipf_ro.ro_rt);
349 ipf->ipf_ro.ro_rt = NULL;
350 ipf->ipf_uses = ipf->ipf_last_uses = 0;
351 ipf->ipf_errors = ipf->ipf_dropped = 0;
358 ipf->ipf_ro = *ro;
361 ipf->ipf_dst = ip->ip_dst;
362 ipf->ipf_src = ip->ip_src;
363 ipf->ipf_tos = ip->ip_tos;
364 ipf->ipf_timer = IPFLOW_TIMER;
369 LIST_INSERT_HEAD(&ipflows[hash], ipf, ipf_next);