Print this page
11378 ncec_last_time_defended needs to be clock_t
Reviewed by: Patrick Mooney <patrick.mooney@joyent.com>
Reviewed by: Toomas Soome <tsoome@me.com>
Reviewed by: Andy Stormont <astormont@racktopsystems.com>
Approved by:
| Split |
Close |
| Expand all |
| Collapse all |
--- old/usr/src/uts/common/inet/ip_ndp.h
+++ new/usr/src/uts/common/inet/ip_ndp.h
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
|
↓ open down ↓ |
15 lines elided |
↑ open up ↑ |
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21 /*
22 22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
23 23 * Use is subject to license terms.
24 24 */
25 25
26 +/*
27 + * Copyright 2019 Joyent, Inc.
28 + */
29 +
26 30 #ifndef _INET_IP_NDP_H
27 31 #define _INET_IP_NDP_H
28 32
29 33 #include <sys/mutex.h>
30 34 #include <sys/stream.h>
31 35 #include <netinet/in.h>
32 36 #include <netinet/icmp6.h>
33 37 #include <inet/ip.h>
34 38 #include <inet/ip2mac.h>
35 39
36 40 /*
37 41 * Internal definitions for the kernel implementation of the IPv6
38 42 * Neighbor Discovery Protocol (NDP) and Address Resolution Protocol (ARP).
39 43 */
40 44
41 45 #ifdef __cplusplus
42 46 extern "C" {
43 47 #endif
44 48
45 49 #ifdef _KERNEL
46 50 #define NCE_TABLE_SIZE 256
47 51 /*
48 52 * callbacks set up with ip2mac interface, waiting for result
49 53 * of neighbor resolution.
50 54 */
51 55 typedef struct ncec_cb_s {
52 56 list_node_t ncec_cb_node; /* next entry in list */
53 57 void *ncec_cb_id;
54 58 uint32_t ncec_cb_flags;
55 59 ip2mac_callback_t *ncec_cb_func;
56 60 void *ncec_cb_arg;
57 61 } ncec_cb_t;
58 62
59 63 #define NCE_CB_DISPATCHED 0x00000001
60 64
61 65 /*
62 66 * Core information tracking Neighbor Reachability is tracked in the
63 67 * ncec_s/ncec_t. The information contained in the ncec_t does not contain
64 68 * any link-specific details other than the pointer to the ill_t itself.
65 69 * The link-specific information is tracked in the nce_t structure.
66 70 */
67 71 struct ncec_s {
68 72 struct ncec_s *ncec_next; /* Hash chain next pointer */
69 73 struct ncec_s **ncec_ptpn; /* Pointer to previous next */
70 74 struct ill_s *ncec_ill; /* Associated ill */
71 75 uint16_t ncec_flags; /* See below */
72 76 uint16_t ncec_state; /* See reachability states in if.h */
73 77 int16_t ncec_pcnt; /* Probe counter */
74 78 uint16_t ncec_rcnt; /* Retransmit counter */
75 79 in6_addr_t ncec_addr; /* address of the nighbor */
|
↓ open down ↓ |
40 lines elided |
↑ open up ↑ |
76 80 uchar_t *ncec_lladdr;
77 81 mblk_t *ncec_qd_mp; /* Head outgoing queued packets */
78 82 uint64_t ncec_last; /* Time last reachable in msec */
79 83 uint32_t ncec_refcnt; /* ncec active usage count */
80 84 kmutex_t ncec_lock; /* See comments on top for what */
81 85 /* this field protects */
82 86 int ncec_unsolicit_count; /* Unsolicited Adv count */
83 87 timeout_id_t ncec_timeout_id;
84 88 uchar_t ncec_ipversion; /* IPv4(ARP)/IPv6(NDP) version */
85 89 uint_t ncec_defense_count; /* number of NDP conflicts */
86 - uint_t ncec_last_time_defended; /* last time defended (secs) */
90 + clock_t ncec_last_time_defended; /* defended last (ticks) */
87 91 uint64_t ncec_init_time; /* time when it was set to ND_INITIAL */
88 92 boolean_t ncec_trace_disable; /* True when alloc fails */
89 93 /*
90 94 * interval to keep track of DAD probes.
91 95 */
92 96 clock_t ncec_xmit_interval;
93 97 ip_stack_t *ncec_ipst; /* Does not have a netstack_hold */
94 98 list_t ncec_cb; /* callbacks waiting for resolution */
95 99 uint_t ncec_cb_walker_cnt;
96 100 uint_t ncec_nprobes;
97 101 uint_t ncec_lladdr_length;
98 102 };
99 103
100 104 /*
101 105 * The nce_t list hangs off the ill_s and tracks information that depends
102 106 * on the underlying physical link. Thus when the ill goes down,
103 107 * the nce_t list has to be flushed. This is done as part of ill_delete()
104 108 *
105 109 * When the fastpath ack comes back in ill_fastpath_ack we call
106 110 * nce_fastpath_update to update the nce_t. We never actually
107 111 * flush the fastpath list, which is kept as an index into the
108 112 * ncec_t structures.
109 113 *
110 114 * when we ndp_delete, we remove the nce entries pointing
111 115 * at the dying ncec from the ill_fastpath_list chain.
112 116 *
113 117 */
114 118 struct nce_s {
115 119 list_node_t nce_node;
116 120 ill_t *nce_ill;
117 121 boolean_t nce_is_condemned;
118 122 in6_addr_t nce_addr;
119 123 /*
120 124 * link-layer specific fields below
121 125 */
122 126 mblk_t *nce_dlur_mp; /* DL_UNITDATA_REQ mp */
123 127 mblk_t *nce_fp_mp; /* fast path mp */
124 128 struct ncec_s *nce_common;
125 129 kmutex_t nce_lock;
126 130 uint32_t nce_refcnt;
127 131 uint_t nce_ipif_cnt; /* number of ipifs with the nce_addr */
128 132 /* as their local address */
129 133 };
130 134
131 135 /*
132 136 * The ndp_g_t structure contains protocol specific information needed
133 137 * to synchronize and manage neighbor cache entries for IPv4 and IPv6.
134 138 * There are 2 such structures, ips_ndp4 and ips_ndp6.
135 139 * ips_ndp6 contains the data structures needed for IPv6 Neighbor Discovery.
136 140 * ips_ndp4 contains the data structures for IPv4 ARP.
137 141 *
138 142 * Locking notes:
139 143 * ndp_g_lock protects neighbor cache tables access and
140 144 * insertion/removal of cache entries into/from these tables. The ncec_lock
141 145 * and nce_lock protect fields in the ncec_t and nce_t structures.
142 146 * Should there be a need to obtain nce[c]_lock and ndp_g_lock, ndp_g_lock is
143 147 * acquired first.
144 148 */
145 149 typedef struct ndp_g_s {
146 150 kmutex_t ndp_g_lock; /* Lock protecting cache hash table */
147 151 ncec_t *nce_hash_tbl[NCE_TABLE_SIZE];
148 152 int ndp_g_walker; /* # of active thread walking hash list */
149 153 boolean_t ndp_g_walker_cleanup; /* true implies defer deletion. */
150 154 } ndp_g_t;
151 155
152 156 /* ncec_flags */
153 157 #define NCE_F_MYADDR 0x1 /* ipif exists for the ncec_addr */
154 158 #define NCE_F_UNVERIFIED 0x2 /* DAD in progress. */
155 159 #define NCE_F_ISROUTER 0x4
156 160 #define NCE_F_FAST 0x8
157 161
158 162 /*
159 163 * NCE_F_NONUD is used to disable IPv6 Neighbor Unreachability Detection or
160 164 * IPv4 aging and maps to the ATF_PERM flag for arp(1m)
161 165 */
162 166 #define NCE_F_NONUD 0x10
163 167
164 168 #define NCE_F_ANYCAST 0x20
165 169 #define NCE_F_CONDEMNED 0x40
166 170 #define NCE_F_UNSOL_ADV 0x80
167 171 #define NCE_F_BCAST 0x100
168 172 #define NCE_F_MCAST 0x200
169 173
170 174 /*
171 175 * NCE_F_PUBLISH is set for all ARP/ND entries that we announce. This
172 176 * includes locally configured addresses as well as those that we proxy for.
173 177 */
174 178 #define NCE_F_PUBLISH 0x400
175 179
176 180 /*
177 181 * NCE_F_AUTHORITY is set for any address that we have authoritatitve
178 182 * information for. This includes locally configured addresses as well
179 183 * as statically configured arp entries that are set up using the "permanent"
180 184 * option described in arp(1m). The NCE_F_AUTHORITY asserts that we would
181 185 * reject any updates for that nce's (host, link-layer-address) information
182 186 */
183 187 #define NCE_F_AUTHORITY 0x800
184 188
185 189 #define NCE_F_DELAYED 0x1000 /* rescheduled on dad_defend_rate */
186 190 #define NCE_F_STATIC 0x2000
187 191
188 192 /* State REACHABLE, STALE, DELAY or PROBE */
189 193 #define NCE_ISREACHABLE(ncec) \
190 194 (((((ncec)->ncec_state) >= ND_REACHABLE) && \
191 195 ((ncec)->ncec_state) <= ND_PROBE))
192 196
193 197 #define NCE_ISCONDEMNED(ncec) ((ncec)->ncec_flags & NCE_F_CONDEMNED)
194 198
195 199 /* NDP flags set in SOL/ADV requests */
196 200 #define NDP_UNICAST 0x1
197 201 #define NDP_ISROUTER 0x2
198 202 #define NDP_SOLICITED 0x4
199 203 #define NDP_ORIDE 0x8
200 204 #define NDP_PROBE 0x10
201 205
202 206 /* Number of packets queued in NDP for a neighbor */
203 207 #define ND_MAX_Q 4
204 208
205 209 /*
206 210 * Structure for nce_update_hw_changed;
207 211 */
208 212 typedef struct {
209 213 ipaddr_t hwm_addr; /* IPv4 address */
210 214 uint_t hwm_hwlen; /* Length of hardware address (may be 0) */
211 215 uchar_t *hwm_hwaddr; /* Pointer to new hardware address, if any */
212 216 int hwm_flags;
213 217 } nce_hw_map_t;
214 218
215 219 /* When SAP is greater than zero address appears before SAP */
216 220 #define NCE_LL_ADDR_OFFSET(ill) (((ill)->ill_sap_length) < 0 ? \
217 221 (sizeof (dl_unitdata_req_t)) : \
218 222 ((sizeof (dl_unitdata_req_t)) + (ABS((ill)->ill_sap_length))))
219 223
220 224 #define NCE_LL_SAP_OFFSET(ill) (((ill)->ill_sap_length) < 0 ? \
221 225 ((sizeof (dl_unitdata_req_t)) + ((ill)->ill_phys_addr_length)) : \
222 226 (sizeof (dl_unitdata_req_t)))
223 227
224 228 #define NCE_MYADDR(ncec) (((ncec)->ncec_flags & NCE_F_MYADDR) != 0)
225 229
226 230 /*
227 231 * NCE_PUBLISH() identifies the addresses that we are publishing. This
228 232 * includes locally configured address (NCE_MYADDR()) as well as those that
229 233 * we are proxying.
230 234 */
231 235 #define NCE_PUBLISH(ncec) ((ncec->ncec_flags & NCE_F_PUBLISH) != 0)
232 236
233 237 #ifdef _BIG_ENDIAN
234 238 #define NCE_LL_SAP_COPY(ill, mp) \
235 239 { \
236 240 size_t abs_sap_len = ABS((ill)->ill_sap_length); \
237 241 if (abs_sap_len > 0) { \
238 242 ASSERT(abs_sap_len <= sizeof (uint32_t)); \
239 243 ASSERT((mp)->b_rptr + NCE_LL_SAP_OFFSET(ill) + \
240 244 abs_sap_len <= ((mp)->b_wptr)); \
241 245 bcopy((uint8_t *)&(ill)->ill_sap + sizeof (ill->ill_sap) - \
242 246 abs_sap_len, \
243 247 ((mp)->b_rptr + NCE_LL_SAP_OFFSET(ill)), \
244 248 abs_sap_len); \
245 249 } \
246 250 }
247 251 #else
248 252 #define NCE_LL_SAP_COPY(ill, mp) \
249 253 { \
250 254 size_t abs_sap_len = ABS((ill)->ill_sap_length); \
251 255 if (abs_sap_len > 0) { \
252 256 uint32_t abs_sap_len = ABS((ill)->ill_sap_length); \
253 257 ASSERT(abs_sap_len <= sizeof (uint32_t)); \
254 258 ASSERT((mp)->b_rptr + NCE_LL_SAP_OFFSET(ill) + \
255 259 abs_sap_len <= ((mp)->b_wptr)); \
256 260 bcopy(&((ill)->ill_sap), \
257 261 ((mp)->b_rptr + NCE_LL_SAP_OFFSET(ill)), \
258 262 abs_sap_len); \
259 263 } \
260 264 }
261 265 #endif
262 266
263 267 /*
264 268 * Exclusive-or the 6 bytes that are likely to contain the MAC
265 269 * address. Assumes table_size does not exceed 256.
266 270 * Assumes EUI-64 format for good hashing.
267 271 */
268 272 #define NCE_ADDR_HASH_V6(addr, table_size) \
269 273 (((addr).s6_addr8[8] ^ (addr).s6_addr8[9] ^ \
270 274 (addr).s6_addr8[10] ^ (addr).s6_addr8[13] ^ \
271 275 (addr).s6_addr8[14] ^ (addr).s6_addr8[15]) % (table_size))
272 276
273 277 /* NDP Cache Entry Hash Table */
274 278 #define NCE_TABLE_SIZE 256
275 279
276 280 typedef void (*ncec_walk_cb_t)(ncec_t *, void *);
277 281
278 282 extern void ip_nce_reclaim(void *);
279 283 extern void ncec_delete(ncec_t *);
280 284 extern void ncec_delete_per_ill(ncec_t *, void *);
281 285 extern void nce_fastpath_update(ill_t *, mblk_t *);
282 286 extern nd_opt_hdr_t *ndp_get_option(nd_opt_hdr_t *, int, int);
283 287 extern void ncec_inactive(ncec_t *);
284 288 extern void ndp_input(mblk_t *, ip_recv_attr_t *);
285 289 extern ncec_t *ncec_lookup_illgrp_v6(ill_t *, const in6_addr_t *);
286 290 extern ncec_t *ncec_lookup_illgrp_v4(ill_t *, const in_addr_t *);
287 291 extern nce_t *nce_lookup_v4(ill_t *, const in_addr_t *);
288 292 extern nce_t *nce_lookup_v6(ill_t *, const in6_addr_t *);
289 293 extern void nce_make_unreachable(ncec_t *);
290 294 extern mblk_t *ndp_mcastreq(ill_t *, const in6_addr_t *, uint32_t, uint32_t,
291 295 mblk_t *);
292 296 extern nce_t *ndp_nce_init(ill_t *, const in6_addr_t *, int);
293 297 extern void nce_process(ncec_t *, uchar_t *, uint32_t, boolean_t);
294 298 extern int ndp_query(ill_t *, lif_nd_req_t *);
295 299 extern int ndp_sioc_update(ill_t *, lif_nd_req_t *);
296 300 extern boolean_t ndp_verify_optlen(nd_opt_hdr_t *, int);
297 301 extern void nce_timer(void *);
298 302 extern void ncec_walk(ill_t *, ncec_walk_cb_t, void *, ip_stack_t *);
299 303 extern void ncec_walk_common(ndp_g_t *, ill_t *, ncec_walk_cb_t,
300 304 void *, boolean_t);
301 305 extern boolean_t nce_restart_dad(ncec_t *);
302 306 extern void ndp_resolv_failed(ncec_t *);
303 307 extern void arp_resolv_failed(ncec_t *);
304 308 extern void nce_fastpath_list_delete(ill_t *, ncec_t *, list_t *);
305 309 extern void nce_queue_mp(ncec_t *, mblk_t *, boolean_t);
306 310 extern void nce_update_hw_changed(ncec_t *, void *);
307 311 extern int nce_lookup_then_add_v6(ill_t *, uchar_t *, uint_t,
308 312 const in6_addr_t *, uint16_t, uint16_t, nce_t **);
309 313 extern int nce_lookup_then_add_v4(ill_t *, uchar_t *, uint_t,
310 314 const in_addr_t *, uint16_t, uint16_t, nce_t **);
311 315 extern boolean_t nce_cmp_ll_addr(const ncec_t *, const uchar_t *, uint32_t);
312 316 extern void nce_update(ncec_t *, uint16_t, uchar_t *);
313 317 extern nce_t *nce_lookup_mapping(ill_t *, const in6_addr_t *);
314 318
315 319 extern void nce_restart_timer(ncec_t *, uint_t);
316 320 extern void ncec_refrele(ncec_t *);
317 321 extern void ncec_refhold(ncec_t *);
318 322 extern void ncec_refrele_notr(ncec_t *);
319 323 extern void ncec_refhold_notr(ncec_t *);
320 324 extern void nce_resolv_ok(ncec_t *);
321 325 extern uint32_t ndp_solicit(ncec_t *, in6_addr_t, ill_t *);
322 326 extern boolean_t ip_nce_conflict(mblk_t *, ip_recv_attr_t *, ncec_t *);
323 327 extern boolean_t ndp_announce(ncec_t *);
324 328 extern void ip_nce_lookup_and_update(ipaddr_t *, ipif_t *, ip_stack_t *,
325 329 uchar_t *, int, int);
326 330 extern void nce_refrele(nce_t *);
327 331 extern void nce_refhold(nce_t *);
328 332 extern void nce_delete(nce_t *);
329 333 extern void nce_flush(ill_t *, boolean_t);
330 334 extern void nce_walk(ill_t *, pfi_t, void *);
331 335 extern void ip_ndp_resolve(struct ncec_s *);
332 336 extern void ip_addr_recover(ipsq_t *, queue_t *, mblk_t *, void *);
333 337
334 338 #ifdef DEBUG
335 339 extern void nce_trace_ref(ncec_t *);
336 340 extern void nce_untrace_ref(ncec_t *);
337 341 #endif
338 342
339 343 #endif /* _KERNEL */
340 344
341 345 #ifdef __cplusplus
342 346 }
343 347 #endif
344 348
345 349 #endif /* _INET_IP_NDP_H */
|
↓ open down ↓ |
249 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX