altq_flowvalve.h revision 1.1 1 /* $KAME: altq_flowvalve.h,v 1.4 2000/12/14 08:12:46 thorpej Exp $ */
2
3 /*
4 * Copyright (C) 1998-2000
5 * Sony Computer Science Laboratories Inc. All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY SONY CSL AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL SONY CSL OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 */
28
29 #ifndef _ALTQ_ALTQ_FLOWVALVE_H_
30 #define _ALTQ_ALTQ_FLOWVALVE_H_
31
32 #ifdef _KERNEL
33
34 /* fv_flow structure to define a unique address pair */
35 struct fv_flow {
36 int flow_af; /* address family */
37 union {
38 struct {
39 struct in_addr ip_src;
40 struct in_addr ip_dst;
41 } _ip;
42 #ifdef INET6
43 struct {
44 struct in6_addr ip6_src;
45 struct in6_addr ip6_dst;
46 } _ip6;
47 #endif
48 } flow_un;
49 };
50
51 #define flow_ip flow_un._ip
52 #define flow_ip6 flow_un._ip6
53
54 /* flowvalve entry */
55 struct fve {
56 TAILQ_ENTRY(fve) fve_lru; /* for LRU list */
57
58 enum fv_state { Green, Red } fve_state;
59
60 int fve_p; /* scaled average drop rate */
61 int fve_f; /* scaled average fraction */
62 int fve_count; /* counter to update f */
63 u_int fve_ifseq; /* ifseq at the last update of f */
64 struct timeval fve_lastdrop; /* timestamp of the last drop */
65
66 struct fv_flow fve_flow; /* unique address pair */
67 };
68
69 /* flowvalve structure */
70 struct flowvalve {
71 u_int fv_ifseq; /* packet sequence number */
72 int fv_flows; /* number of valid flows in the flowlist */
73 int fv_pthresh; /* drop rate threshold */
74
75 TAILQ_HEAD(fv_flowhead, fve) fv_flowlist; /* LRU list */
76
77 struct fve *fv_fves; /* pointer to the allocated fves */
78
79 int *fv_p2ftab; /* drop rate to fraction table */
80
81 struct {
82 u_int pass; /* # of packets that have the fve
83 but aren't predropped */
84 u_int predrop; /* # of packets predropped */
85 u_int alloc; /* # of fves assigned */
86 u_int escape; /* # of fves escaped */
87 } fv_stats;
88 };
89
90 #endif /* _KERNEL */
91
92 #endif /* _ALTQ_ALTQ_FLOWVALVE_H_ */
93