Print this page
8634 epoll fails to wake on certain edge-triggered conditions
8635 epoll should not emit POLLNVAL
8636 recursive epoll should emit EPOLLRDNORM
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>
Reviewed by: Robert Mustacchi <rm@joyent.com>
Reviewed by: Toomas Soome <tsoome@me.com>
Reviewed by: Igor Kozhukhov <igor@dilos.org>
| Split |
Close |
| Expand all |
| Collapse all |
--- old/usr/src/uts/common/io/bpf/net/bpfdesc.h
+++ new/usr/src/uts/common/io/bpf/net/bpfdesc.h
1 1 /* $NetBSD: bpfdesc.h,v 1.29 2009/03/14 14:46:10 dsl Exp $ */
2 2
3 3 /*
4 4 * Copyright (c) 1990, 1991, 1993
5 5 * The Regents of the University of California. All rights reserved.
6 6 *
7 7 * This code is derived from the Stanford/CMU enet packet filter,
8 8 * (net/enet.c) distributed as part of 4.3BSD, and code contributed
9 9 * to Berkeley by Steven McCanne and Van Jacobson both of Lawrence
10 10 * Berkeley Laboratory.
11 11 *
12 12 * Redistribution and use in source and binary forms, with or without
13 13 * modification, are permitted provided that the following conditions
14 14 * are met:
15 15 * 1. Redistributions of source code must retain the above copyright
16 16 * notice, this list of conditions and the following disclaimer.
17 17 * 2. Redistributions in binary form must reproduce the above copyright
18 18 * notice, this list of conditions and the following disclaimer in the
19 19 * documentation and/or other materials provided with the distribution.
20 20 * 3. Neither the name of the University nor the names of its contributors
21 21 * may be used to endorse or promote products derived from this software
22 22 * without specific prior written permission.
23 23 *
24 24 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25 25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 27 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 34 * SUCH DAMAGE.
35 35 *
36 36 * @(#)bpfdesc.h 8.1 (Berkeley) 6/10/93
37 37 *
38 38 * @(#) Header: bpfdesc.h,v 1.14 96/06/16 22:28:07 leres Exp (LBL)
39 39 */
40 40 /*
41 41 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
42 42 * Use is subject to license terms.
43 43 */
44 44
45 45 #ifndef _NET_BPFDESC_H_
46 46 #define _NET_BPFDESC_H_
47 47
48 48 #include <net/if.h> /* for IFNAMSIZ */
49 49 #include <sys/mutex.h>
50 50 #include <sys/condvar.h>
51 51 #include <sys/queue.h>
52 52
53 53 /*
54 54 * Access to "layer 2" networking is provided through each such provider
55 55 * delcaring a set of functions to use in the structure below. It has been
56 56 * modeled around what's required to use the mac layer. All of the functions
57 57 * below must be declared, even if only filled by a stub function.
58 58 */
59 59 typedef struct bpf_provider_s {
60 60 int bpr_unit;
61 61 int (*bpr_open)(const char *, uintptr_t *, zoneid_t);
62 62 void (*bpr_close)(uintptr_t);
63 63 const char *(*bpr_name)(uintptr_t);
64 64 int (*bpr_type)(uintptr_t);
65 65 void (*bpr_sdu_get)(uintptr_t, uint_t *);
66 66 int (*bpr_tx)(uintptr_t, mblk_t *);
67 67 uintptr_t (*bpr_promisc_add)(uintptr_t, int, void *, uintptr_t *,
68 68 int);
69 69 void (*bpr_promisc_remove)(uintptr_t);
70 70 int (*bpr_getlinkid)(const char *, datalink_id_t *,
71 71 zoneid_t);
72 72 void (*bpr_client_close)(uintptr_t);
73 73 const char *(*bpr_client_name)(uintptr_t);
74 74 int (*bpr_client_open)(uintptr_t, uintptr_t *);
75 75 int (*bpr_getzone)(uintptr_t, zoneid_t *);
76 76 int (*bpr_getdlt)(uintptr_t, uint_t *);
77 77 } bpf_provider_t;
78 78
79 79 typedef struct bpf_provider_list {
80 80 LIST_ENTRY(bpf_provider_list) bpl_next;
81 81 bpf_provider_t *bpl_what;
82 82 } bpf_provider_list_t;
83 83
84 84 /*
85 85 * The bpr_field from bpf_provider_t expects an integer that comes from
86 86 * the list of defines below.
87 87 */
88 88 #define BPR_MAC 1
89 89 #define BPR_IPNET 2
90 90
91 91 #define MBPF_OPEN(_m, _n, _p, _z) (_m)->bpr_open(_n, (uintptr_t *)_p, _z)
92 92 #define MBPF_CLOSE(_m, _h) (_m)->bpr_close(_h)
93 93 #define MBPF_NAME(_m, _h) (_m)->bpr_name(_h)
94 94 #define MBPF_TYPE(_m, _h) (_m)->bpr_type(_h)
95 95 #define MBPF_SDU_GET(_m, _h, _p) (_m)->bpr_sdu_get(_h, _p)
96 96 #define MBPF_TX(_m, _h, _pkt) (_m)->bpr_tx(_h, _pkt)
97 97 #define MBPF_PROMISC_ADD(_m, _h, _o, _d, _p, _f) \
98 98 (_m)->bpr_promisc_add(_h, _o, _d, _p, _f)
99 99 #define MBPF_PROMISC_REMOVE(_m, _h) (_m)->bpr_promisc_remove(_h)
100 100 #define MBPF_GET_LINKID(_m, _n, _ip, _z) \
101 101 (_m)->bpr_getlinkid(_n, _ip, _z)
102 102 #define MBPF_CLIENT_CLOSE(_m, _h) (_m)->bpr_client_close(_h)
103 103 #define MBPF_CLIENT_NAME(_m, _h) (_m)->bpr_client_name(_h)
104 104 #define MBPF_CLIENT_OPEN(_m, _h, _p) (_m)->bpr_client_open((uintptr_t)_h, \
105 105 (uintptr_t *)_p)
106 106 #define MBPF_GET_ZONE(_m, _h, _zp) (_m)->bpr_getzone(_h, _zp)
107 107 #define MBPF_GET_DLT(_m, _h, _dp) (_m)->bpr_getdlt(_h, _dp);
108 108 #define MBPF_GET_HDRLEN(_m, _h, _dp) (_m)->bpr_gethdrlen(_h, _dp);
109 109
110 110
111 111 /*
112 112 * Descriptor associated with each open bpf file.
113 113 */
114 114 struct bpf_d {
115 115 LIST_ENTRY(bpf_d) bd_list; /* List of bpf_d */
116 116 LIST_ENTRY(bpf_d) bd_next; /* List attaced to bif_if */
117 117 /*
118 118 * Buffer slots: two mbuf clusters buffer the incoming packets.
119 119 * The model has three slots. Sbuf is always occupied.
120 120 * sbuf (store) - Receive interrupt puts packets here.
121 121 * hbuf (hold) - When sbuf is full, put cluster here and
122 122 * wakeup read (replace sbuf with fbuf).
123 123 * fbuf (free) - When read is done, put cluster here.
124 124 * On receiving, if sbuf is full and fbuf is 0, packet is dropped.
125 125 */
126 126 void * bd_sbuf; /* store slot */
127 127 void * bd_hbuf; /* hold slot */
128 128 void * bd_fbuf; /* free slot */
129 129 int bd_slen; /* current length of store buffer */
130 130 int bd_hlen; /* current length of hold buffer */
131 131
132 132 int bd_bufsize; /* absolute length of buffers */
133 133
134 134 uintptr_t bd_bif; /* interface pointer */
135 135 ulong_t bd_rtout; /* Read timeout in 'ticks' */
136 136 struct bpf_insn *bd_filter; /* filter code */
137 137 size_t bd_filter_size;
138 138 ulong_t bd_rcount; /* number of packets received */
139 139 ulong_t bd_dcount; /* number of packets dropped */
140 140 ulong_t bd_ccount; /* number of packets captured */
141 141
|
↓ open down ↓ |
141 lines elided |
↑ open up ↑ |
142 142 uchar_t bd_promisc; /* true if listening promiscuously */
143 143 uchar_t bd_state; /* idle, waiting, or timed out */
144 144 uchar_t bd_immediate; /* true to return on packet arrival */
145 145 int bd_hdrcmplt; /* false to fill in src lladdr */
146 146 int bd_seesent; /* true if bpf should see sent pkts */
147 147 int bd_async; /* non-zero if packet reception .. */
148 148 /* .. should generate signal */
149 149 int bd_nonblock; /* non-zero for non-blocking read */
150 150 pid_t bd_pgid; /* process or group id for signal */
151 151 int bd_timedout;
152 - struct pollhead bd_poll;
153 152 timeout_id_t bd_callout; /* for BPF timeouts with select */
154 153 pid_t bd_pid; /* corresponding PID */
155 154 void *bd_sih; /* soft interrupt handle */
156 155 /*
157 156 * Solaris specific bits after this.
158 157 */
159 158 kmutex_t bd_lock;
160 159 kcondvar_t bd_wait;
161 160 uintptr_t bd_mh; /* where mac_handle gets put */
162 161 uintptr_t bd_mcip; /* Where mac_client_handle_t gets put */
163 162 uintptr_t bd_promisc_handle;
164 163 minor_t bd_dev; /* device number for this handle */
165 164 int bd_fmode; /* flags from bpfopen */
166 165 zoneid_t bd_zone; /* zoneid of the opening process */
167 166 int bd_inuse;
168 167 int bd_waiting;
169 168 char bd_ifname[LIFNAMSIZ];
170 169 int bd_dlt;
171 170 int bd_hdrlen;
172 171 bpf_provider_t bd_mac;
173 172 datalink_id_t bd_linkid;
174 173 /*
175 174 * bd_promisc_flags is used to store the promiscuous state of the
176 175 * the interface in BPF so that the correct mode of operation can
177 176 * be kept across changing DLT or network interface.
178 177 */
179 178 int bd_promisc_flags;
180 179 };
181 180
182 181
183 182 /* Values for bd_state */
184 183 #define BPF_IDLE 0 /* no select in progress */
185 184 #define BPF_WAITING 1 /* waiting for read timeout in select */
186 185 #define BPF_TIMED_OUT 2 /* read timeout has expired in select */
187 186
188 187 /*
189 188 * Description associated with the external representation of each
190 189 * open bpf file.
191 190 */
192 191 struct bpf_d_ext {
193 192 int32_t bde_bufsize;
194 193 uint8_t bde_promisc;
195 194 uint8_t bde_state;
196 195 uint8_t bde_immediate;
197 196 int32_t bde_hdrcmplt;
198 197 int32_t bde_seesent;
199 198 pid_t bde_pid;
200 199 uint64_t bde_rcount; /* number of packets received */
201 200 uint64_t bde_dcount; /* number of packets dropped */
202 201 uint64_t bde_ccount; /* number of packets captured */
203 202 char bde_ifname[IFNAMSIZ];
204 203 };
205 204
206 205 #ifdef _KERNEL
207 206 typedef struct bpf_kstats_s {
208 207 kstat_named_t kp_read_wait;
209 208 kstat_named_t kp_write_ok;
210 209 kstat_named_t kp_write_error;
211 210 kstat_named_t kp_receive;
212 211 kstat_named_t kp_capture;
213 212 kstat_named_t kp_dropped;
214 213 } bpf_kstats_t;
215 214
216 215 int bpf_setf(struct bpf_d *, struct bpf_program *);
217 216 #endif
218 217
219 218 typedef void (*bpf_attach_fn_t)(uintptr_t, int, zoneid_t, int);
220 219 typedef void (*bpf_detach_fn_t)(uintptr_t);
221 220 typedef int (*bpf_provider_reg_fn_t)(bpf_provider_t *);
222 221 typedef LIST_HEAD(, bpf_provider_list) bpf_provider_head_t;
223 222
224 223 extern bpf_provider_t *bpf_find_provider_by_id(int);
225 224 extern int bpf_provider_tickle(char *, zoneid_t);
226 225 extern bpf_provider_head_t bpf_providers;
227 226
228 227 #endif /* !_NET_BPFDESC_H_ */
|
↓ open down ↓ |
66 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX