Print this page
8368 remove warlock leftovers from usr/src/uts
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/common/io/ib/mgt/ibcm/ibcm_arp.c
+++ new/usr/src/uts/common/io/ib/mgt/ibcm/ibcm_arp.c
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
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 (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
23 23 */
24 24
25 25 #include <sys/types.h>
26 26 #include <sys/ddi.h>
27 27 #include <sys/sunddi.h>
28 28 #include <sys/strsubr.h>
29 29 #include <sys/socket.h>
30 30 #include <net/if_arp.h>
31 31 #include <net/if_types.h>
32 32 #include <sys/sockio.h>
33 33 #include <sys/pathname.h>
34 34
35 35 #include <sys/ib/mgt/ibcm/ibcm_arp.h>
36 36
37 37 #include <sys/kstr.h>
↓ open down ↓ |
37 lines elided |
↑ open up ↑ |
38 38 #include <sys/t_kuser.h>
39 39
40 40 #include <sys/dls.h>
41 41
42 42 extern char cmlog[];
43 43
44 44 extern int ibcm_resolver_pr_lookup(ibcm_arp_streams_t *ib_s,
45 45 ibt_ip_addr_t *dst_addr, ibt_ip_addr_t *src_addr, zoneid_t myzoneid);
46 46 extern void ibcm_arp_delete_prwqn(ibcm_arp_prwqn_t *wqnp);
47 47
48 -_NOTE(SCHEME_PROTECTS_DATA("Unshared data", ibt_ip_addr_s))
49 -_NOTE(SCHEME_PROTECTS_DATA("Unshared data", ibcm_arp_ip_t))
50 -_NOTE(SCHEME_PROTECTS_DATA("Unshared data", ibcm_arp_ibd_insts_t))
51 -_NOTE(SCHEME_PROTECTS_DATA("Unshared data", ibcm_arp_prwqn_t))
52 -_NOTE(SCHEME_PROTECTS_DATA("Unshared data", sockaddr_in))
53 -_NOTE(SCHEME_PROTECTS_DATA("Unshared data", sockaddr_in6))
54 -
55 48 int ibcm_printip = 0;
56 49
57 50 /*
58 51 * Function:
59 52 * ibcm_ip_print
60 53 * Input:
61 54 * label Arbitrary qualifying string
62 55 * ipa Pointer to IP Address to print
63 56 */
64 57 void
65 58 ibcm_ip_print(char *label, ibt_ip_addr_t *ipaddr)
66 59 {
67 60 char buf[INET6_ADDRSTRLEN];
68 61
69 62 if (ipaddr->family == AF_INET) {
70 63 IBTF_DPRINTF_L2(cmlog, "%s: %s", label,
71 64 inet_ntop(AF_INET, &ipaddr->un.ip4addr, buf, sizeof (buf)));
72 65 } else if (ipaddr->family == AF_INET6) {
73 66 IBTF_DPRINTF_L2(cmlog, "%s: %s", label, inet_ntop(AF_INET6,
74 67 &ipaddr->un.ip6addr, buf, sizeof (buf)));
75 68 } else {
76 69 IBTF_DPRINTF_L2(cmlog, "%s: IP ADDR NOT SPECIFIED ", label);
77 70 }
78 71 }
79 72
80 73
81 74 ibt_status_t
82 75 ibcm_arp_get_ibaddr(zoneid_t myzoneid, ibt_ip_addr_t srcaddr,
83 76 ibt_ip_addr_t destaddr, ib_gid_t *sgid, ib_gid_t *dgid,
84 77 ibt_ip_addr_t *saddrp)
85 78 {
86 79 ibcm_arp_streams_t *ib_s;
87 80 ibcm_arp_prwqn_t *wqnp;
88 81 int ret = 0;
89 82 int len;
90 83
91 84 IBTF_DPRINTF_L4(cmlog, "ibcm_arp_get_ibaddr(%d, %p, %p, %p, %p, %p)",
92 85 myzoneid, srcaddr, destaddr, sgid, dgid, saddrp);
93 86
94 87 ib_s = (ibcm_arp_streams_t *)kmem_zalloc(sizeof (ibcm_arp_streams_t),
95 88 KM_SLEEP);
96 89
97 90 mutex_init(&ib_s->lock, NULL, MUTEX_DEFAULT, NULL);
98 91 cv_init(&ib_s->cv, NULL, CV_DRIVER, NULL);
99 92
100 93 mutex_enter(&ib_s->lock);
101 94 ib_s->done = B_FALSE;
102 95 mutex_exit(&ib_s->lock);
103 96
104 97 ret = ibcm_resolver_pr_lookup(ib_s, &destaddr, &srcaddr, myzoneid);
105 98
106 99 IBTF_DPRINTF_L3(cmlog, "ibcm_arp_get_ibaddr: ibcm_resolver_pr_lookup "
107 100 "returned: %d", ret);
108 101 if (ret == 0) {
109 102 mutex_enter(&ib_s->lock);
110 103 while (ib_s->done != B_TRUE)
111 104 cv_wait(&ib_s->cv, &ib_s->lock);
112 105 mutex_exit(&ib_s->lock);
113 106 }
114 107
115 108 mutex_enter(&ib_s->lock);
116 109 wqnp = ib_s->wqnp;
117 110 if (ib_s->status == 0) {
118 111 if (sgid)
119 112 *sgid = wqnp->sgid;
120 113 if (dgid)
121 114 *dgid = wqnp->dgid;
122 115 /*
123 116 * If the user supplied a address, then verify we got
124 117 * for the same address.
125 118 */
126 119 if (wqnp->usrc_addr.family && sgid) {
127 120 len = (wqnp->usrc_addr.family == AF_INET) ?
128 121 IP_ADDR_LEN : sizeof (in6_addr_t);
129 122 if (bcmp(&wqnp->usrc_addr.un,
130 123 &wqnp->src_addr.un, len)) {
131 124 IBTF_DPRINTF_L3(cmlog, "ibcm_arp_get_ibaddr: "
132 125 "srcaddr mismatch");
133 126
134 127 /* Clean-up old data, and reset the done flag */
135 128 ibcm_arp_delete_prwqn(wqnp);
136 129 ib_s->done = B_FALSE;
137 130 mutex_exit(&ib_s->lock);
138 131
139 132 ret = ibcm_resolver_pr_lookup(ib_s, &srcaddr,
140 133 &srcaddr, myzoneid);
141 134 if (ret == 0) {
142 135 mutex_enter(&ib_s->lock);
143 136 while (ib_s->done != B_TRUE)
144 137 cv_wait(&ib_s->cv, &ib_s->lock);
145 138 mutex_exit(&ib_s->lock);
146 139 }
147 140 mutex_enter(&ib_s->lock);
148 141 wqnp = ib_s->wqnp;
149 142 if (ib_s->status == 0) {
150 143 if (sgid)
151 144 *sgid = wqnp->dgid;
152 145
153 146 if (saddrp)
154 147 bcopy(&wqnp->src_addr, saddrp,
155 148 sizeof (ibt_ip_addr_t));
156 149
157 150 IBTF_DPRINTF_L4(cmlog,
158 151 "ibcm_arp_get_ibaddr: "
159 152 "SGID: %llX:%llX DGID: %llX:%llX",
160 153 sgid->gid_prefix, sgid->gid_guid,
161 154 dgid->gid_prefix, dgid->gid_guid);
162 155
163 156 ibcm_arp_delete_prwqn(wqnp);
164 157 } else if (ret == 0) {
165 158 if (wqnp)
166 159 kmem_free(wqnp,
167 160 sizeof (ibcm_arp_prwqn_t));
168 161 }
169 162 goto arp_ibaddr_done;
170 163 }
171 164 }
172 165
173 166 if (saddrp)
174 167 bcopy(&wqnp->src_addr, saddrp, sizeof (ibt_ip_addr_t));
175 168
176 169 IBTF_DPRINTF_L4(cmlog, "ibcm_arp_get_ibaddr: SGID: %llX:%llX"
177 170 " DGID: %llX:%llX", sgid->gid_prefix, sgid->gid_guid,
178 171 dgid->gid_prefix, dgid->gid_guid);
179 172
180 173 ibcm_arp_delete_prwqn(wqnp);
181 174 } else if (ret == 0) {
182 175 /*
183 176 * We come here only when lookup has returned empty (failed)
184 177 * via callback routine.
185 178 * i.e. ib_s->status is non-zero, while ret is zero.
186 179 */
187 180 if (wqnp)
188 181 kmem_free(wqnp, sizeof (ibcm_arp_prwqn_t));
189 182 }
190 183 arp_ibaddr_done:
191 184 ret = ib_s->status;
192 185 mutex_exit(&ib_s->lock);
193 186
194 187 arp_ibaddr_error:
195 188
196 189 mutex_destroy(&ib_s->lock);
197 190 cv_destroy(&ib_s->cv);
198 191 kmem_free(ib_s, sizeof (ibcm_arp_streams_t));
199 192
200 193 if (ret)
201 194 return (IBT_FAILURE);
202 195 else
203 196 return (IBT_SUCCESS);
204 197 }
205 198
206 199 void
207 200 ibcm_arp_free_ibds(ibcm_arp_ibd_insts_t *ibds)
208 201 {
209 202 if (ibds->ibcm_arp_ip) {
210 203 kmem_free(ibds->ibcm_arp_ip, ibds->ibcm_arp_ibd_alloc *
211 204 sizeof (ibcm_arp_ip_t));
212 205 ibds->ibcm_arp_ibd_alloc = 0;
213 206 ibds->ibcm_arp_ibd_cnt = 0;
214 207 ibds->ibcm_arp_ip = NULL;
215 208 }
216 209 }
217 210
218 211 static void
219 212 ibcm_arp_get_ibd_insts(ibcm_arp_ibd_insts_t *ibds)
220 213 {
221 214 ibcm_arp_ip_t *ipp;
222 215 ib_gid_t port_gid;
223 216 ibt_part_attr_t *attr_list, *attr;
224 217 int nparts;
225 218
226 219 if ((ibt_get_all_part_attr(&attr_list, &nparts) != IBT_SUCCESS) ||
227 220 (nparts == 0)) {
228 221 IBTF_DPRINTF_L2(cmlog, "ibcm_arp_get_ibd_insts: Failed to "
229 222 "IB Part List - %d", nparts);
230 223 ibds->ibcm_arp_ibd_alloc = 0;
231 224 ibds->ibcm_arp_ibd_cnt = 0;
232 225 ibds->ibcm_arp_ip = NULL;
233 226 return;
234 227 }
235 228 IBTF_DPRINTF_L4(cmlog, "ibcm_arp_get_ibd_insts: Found %d IB Part List",
236 229 nparts);
237 230
238 231 ibds->ibcm_arp_ibd_alloc = nparts;
239 232 ibds->ibcm_arp_ibd_cnt = 0;
240 233 ibds->ibcm_arp_ip = (ibcm_arp_ip_t *)kmem_zalloc(
241 234 nparts * sizeof (ibcm_arp_ip_t), KM_SLEEP);
242 235
243 236 attr = attr_list;
244 237 while (nparts--) {
245 238 if (ibt_get_port_state_byguid(attr->pa_hca_guid,
246 239 attr->pa_port, &port_gid, NULL) == IBT_SUCCESS) {
247 240
248 241 ipp = &ibds->ibcm_arp_ip[ibds->ibcm_arp_ibd_cnt];
249 242 ipp->ip_linkid = attr->pa_plinkid;
250 243 ipp->ip_pkey = attr->pa_pkey;
251 244 ipp->ip_hca_guid = attr->pa_hca_guid;
252 245 ipp->ip_port_gid = port_gid;
253 246 ibds->ibcm_arp_ibd_cnt++;
254 247
255 248 IBTF_DPRINTF_L4(cmlog, "PartAttr: p-linkid %lX, "
256 249 "d-linkid %lX, pkey 0x%lX", ipp->ip_linkid,
257 250 attr->pa_dlinkid, ipp->ip_pkey);
258 251 IBTF_DPRINTF_L4(cmlog, "hca_guid 0x%llX, "
259 252 "port_gid %llX \n attr-port_guid %llX",
260 253 ipp->ip_hca_guid, ipp->ip_port_gid.gid_guid,
261 254 attr->pa_port_guid);
262 255 }
263 256 attr++;
264 257 }
265 258
266 259 (void) ibt_free_part_attr(attr_list, ibds->ibcm_arp_ibd_alloc);
267 260 }
268 261
269 262 /*
270 263 * Issue an ioctl down to IP. There are several similar versions of this
271 264 * function (e.g., rpcib_do_ip_ioctl()); clearly a utility routine is needed.
272 265 */
273 266 static int
274 267 ibcm_do_ip_ioctl(int cmd, int len, void *arg)
275 268 {
276 269 vnode_t *kkvp;
277 270 TIUSER *tiptr;
278 271 struct strioctl iocb;
279 272 int err = 0;
280 273
281 274 if (lookupname("/dev/udp", UIO_SYSSPACE, FOLLOW, NULLVPP, &kkvp) != 0)
282 275 return (EPROTO);
283 276
284 277 if (t_kopen(NULL, kkvp->v_rdev, FREAD|FWRITE, &tiptr, CRED()) != 0) {
285 278 VN_RELE(kkvp);
286 279 return (EPROTO);
287 280 }
288 281
289 282 iocb.ic_cmd = cmd;
290 283 iocb.ic_timout = 0;
291 284 iocb.ic_len = len;
292 285 iocb.ic_dp = (caddr_t)arg;
293 286 err = kstr_ioctl(tiptr->fp->f_vnode, I_STR, (intptr_t)&iocb);
294 287 (void) t_kclose(tiptr, 0);
295 288 VN_RELE(kkvp);
296 289 return (err);
297 290 }
298 291
299 292 /*
300 293 * Issue an SIOCGLIFCONF down to IP and return the result in `lifcp'.
301 294 * lifcp->lifc_buf is dynamically allocated to be *bufsizep bytes.
302 295 */
303 296 static int
304 297 ibcm_do_lifconf(struct lifconf *lifcp, uint_t *bufsizep, sa_family_t family_loc)
305 298 {
306 299 int err;
307 300 struct lifnum lifn;
308 301
309 302 bzero(&lifn, sizeof (struct lifnum));
310 303 lifn.lifn_family = family_loc;
311 304 lifn.lifn_flags = LIFC_NOXMIT | LIFC_TEMPORARY | LIFC_ALLZONES;
312 305
313 306 err = ibcm_do_ip_ioctl(SIOCGLIFNUM, sizeof (struct lifnum), &lifn);
314 307 if (err != 0)
315 308 return (err);
↓ open down ↓ |
251 lines elided |
↑ open up ↑ |
316 309
317 310 IBTF_DPRINTF_L3(cmlog, "ibcm_do_lifconf: Family %d, lifn_count %d",
318 311 family_loc, lifn.lifn_count);
319 312 /*
320 313 * Pad the interface count to account for additional interfaces that
321 314 * may have been configured between the SIOCGLIFNUM and SIOCGLIFCONF.
322 315 */
323 316 lifn.lifn_count += 4;
324 317
325 318 bzero(lifcp, sizeof (struct lifconf));
326 - _NOTE(NOW_INVISIBLE_TO_OTHER_THREADS(*lifcp))
327 319 lifcp->lifc_family = family_loc;
328 320 lifcp->lifc_len = *bufsizep = lifn.lifn_count * sizeof (struct lifreq);
329 321 lifcp->lifc_buf = kmem_zalloc(*bufsizep, KM_SLEEP);
330 322 lifcp->lifc_flags = LIFC_NOXMIT | LIFC_TEMPORARY | LIFC_ALLZONES;
331 323
332 324 err = ibcm_do_ip_ioctl(SIOCGLIFCONF, sizeof (struct lifconf), lifcp);
333 325 if (err != 0) {
334 326 kmem_free(lifcp->lifc_buf, *bufsizep);
335 327 return (err);
336 328 }
337 329 return (0);
338 330 }
339 331
340 332 static ibcm_arp_ip_t *
341 333 ibcm_arp_lookup(ibcm_arp_ibd_insts_t *ibds, char *linkname)
342 334 {
343 335 datalink_id_t linkid;
344 336 int i;
345 337
346 338 IBTF_DPRINTF_L4(cmlog, "ibcm_arp_lookup: linkname = %s", linkname);
347 339
348 340 /*
349 341 * If at first we don't succeed, try again, just in case it is in
350 342 * hiding. The first call requires the datalink management daemon
351 343 * (the authorative source of information about name to id mapping)
352 344 * to be present and answering upcalls, the second does not.
353 345 */
354 346 if (dls_mgmt_get_linkid(linkname, &linkid) != 0) {
355 347 if (dls_devnet_macname2linkid(linkname, &linkid) != 0) {
356 348 IBTF_DPRINTF_L2(cmlog, "ibcm_arp_lookup: could not "
357 349 "get linkid from linkname (%s)", linkname);
358 350 return (NULL);
359 351 }
360 352 }
361 353
362 354 for (i = 0; i < ibds->ibcm_arp_ibd_cnt; i++) {
363 355 if (ibds->ibcm_arp_ip[i].ip_linkid == linkid)
364 356 return (&ibds->ibcm_arp_ip[i]);
365 357 }
366 358
367 359 IBTF_DPRINTF_L2(cmlog, "ibcm_arp_lookup: returning NULL for "
368 360 "linkname (%s)", linkname);
369 361 return (NULL);
370 362 }
371 363
372 364 /*
373 365 * Fill in `ibds' with IP addresses tied to IFT_IB IP interfaces. Returns
374 366 * B_TRUE if at least one address was filled in.
375 367 */
376 368 static boolean_t
377 369 ibcm_arp_get_ibd_ipaddr(ibcm_arp_ibd_insts_t *ibds, sa_family_t family_loc)
378 370 {
379 371 int i, nifs, naddr = 0;
380 372 uint_t bufsize;
381 373 struct lifconf lifc;
382 374 struct lifreq *lifrp, lifr_copy;
383 375 ibcm_arp_ip_t *ipp;
384 376 lifgroupinfo_t lifgr;
385 377 int err;
386 378 char ifname[LIFNAMSIZ + 1];
387 379 uint64_t ifflags = 0;
388 380 zoneid_t ifzoneid;
389 381
390 382 if (ibcm_do_lifconf(&lifc, &bufsize, family_loc) != 0)
391 383 return (B_FALSE);
392 384
393 385 nifs = lifc.lifc_len / sizeof (struct lifreq);
394 386
395 387 IBTF_DPRINTF_L4(cmlog, "ibcm_arp_get_ibd_ipaddr: Family %d, nifs %d",
396 388 family_loc, nifs);
397 389
398 390 for (lifrp = lifc.lifc_req, i = 0; i < nifs; i++, lifrp++) {
399 391
400 392 if (lifrp->lifr_type != IFT_IB)
401 393 continue;
402 394
403 395 IBTF_DPRINTF_L4(cmlog, "\nInterface# : %d", i);
404 396 IBTF_DPRINTF_L4(cmlog, "lifr_name : %s, lifr_family :%X, "
405 397 "lifr_type : 0x%lX", lifrp->lifr_name,
406 398 lifrp->lifr_addr.ss_family, lifrp->lifr_type);
407 399
408 400 (void) strlcpy(ifname, lifrp->lifr_name, LIFNAMSIZ);
409 401
410 402 /* Get ZoneId. */
411 403 lifr_copy = *lifrp;
412 404 ifzoneid = 0;
413 405 err = ibcm_do_ip_ioctl(SIOCGLIFZONE, sizeof (struct lifreq),
414 406 &lifr_copy);
415 407 if (err != 0) {
416 408 IBTF_DPRINTF_L2(cmlog, "IFZONE ioctl Failed: err = %d",
417 409 err);
418 410 } else {
419 411 IBTF_DPRINTF_L4(cmlog, "lifr_zoneid : 0x%X",
420 412 lifr_copy.lifr_zoneid);
421 413 ifzoneid = lifr_copy.lifr_zoneid;
422 414 }
423 415
424 416 /* Get IfIndex. */
425 417 lifr_copy = *lifrp;
426 418 err = ibcm_do_ip_ioctl(SIOCGLIFINDEX, sizeof (struct lifreq),
427 419 &lifr_copy);
428 420 if (err != 0) {
429 421 IBTF_DPRINTF_L2(cmlog, "IFINDEX ioctl Failed: err = %d",
430 422 err);
431 423 } else
432 424 IBTF_DPRINTF_L4(cmlog, "lifr_index : 0x%X",
433 425 lifr_copy.lifr_index);
434 426
435 427 /* Get Interface flags. */
436 428 lifr_copy = *lifrp;
437 429 err = ibcm_do_ip_ioctl(SIOCGLIFFLAGS, sizeof (struct lifreq),
438 430 &lifr_copy);
439 431 if (err != 0) {
440 432 IBTF_DPRINTF_L2(cmlog, "IFFLAGS ioctl Failed: err = %d",
441 433 err);
442 434 } else {
443 435 ifflags = lifr_copy.lifr_flags;
444 436 IBTF_DPRINTF_L4(cmlog, "lifr_flags : 0x%llX",
445 437 ifflags);
446 438 }
447 439
448 440 lifr_copy = *lifrp;
449 441 err = ibcm_do_ip_ioctl(SIOCGLIFGROUPNAME,
450 442 sizeof (struct lifreq), &lifr_copy);
451 443 if (err != 0) {
452 444 IBTF_DPRINTF_L3(cmlog, "IFGroupName ioctl Failed: "
453 445 "err = %d", err);
454 446 }
455 447
456 448 if (lifr_copy.lifr_groupname[0] != '\0') {
457 449 IBTF_DPRINTF_L4(cmlog, "lifr_groupname : %s",
458 450 lifr_copy.lifr_groupname);
459 451 (void) strlcpy(lifgr.gi_grname,
460 452 lifr_copy.lifr_groupname, LIFGRNAMSIZ);
461 453 err = ibcm_do_ip_ioctl(SIOCGLIFGROUPINFO,
462 454 sizeof (struct lifgroupinfo), &lifgr);
463 455 if (err != 0) {
464 456 IBTF_DPRINTF_L2(cmlog, "IFGroupINFO ioctl "
465 457 "Failed: err = %d", err);
466 458 } else {
467 459 IBTF_DPRINTF_L4(cmlog, "lifgroupinfo details");
468 460 IBTF_DPRINTF_L4(cmlog, "grname : %s, grifname :"
469 461 " %s, m4ifname : %s, m6ifname : %s",
470 462 lifgr.gi_grname, lifgr.gi_grifname,
471 463 lifgr.gi_m4ifname, lifgr.gi_m6ifname);
472 464 IBTF_DPRINTF_L4(cmlog, "gi_bcifname : %s",
473 465 lifgr.gi_bcifname);
474 466 IBTF_DPRINTF_L4(cmlog, "gi_v4 %d, gi_v6 %d, "
475 467 "gi_nv4 %d, gi_nv6 %d, gi_mactype %d",
476 468 lifgr.gi_v4, lifgr.gi_v6, lifgr.gi_nv4,
477 469 lifgr.gi_nv6, lifgr.gi_mactype);
478 470
479 471 (void) strlcpy(ifname, lifgr.gi_bcifname,
480 472 LIFNAMSIZ);
481 473 }
482 474 }
483 475
484 476 if ((ipp = ibcm_arp_lookup(ibds, ifname)) == NULL)
485 477 continue;
486 478
487 479 ipp->ip_zoneid = ifzoneid; /* Copy back the zoneid info */
488 480 switch (lifrp->lifr_addr.ss_family) {
489 481 case AF_INET:
490 482 ipp->ip_inet_family = AF_INET;
491 483 bcopy(&lifrp->lifr_addr, &ipp->ip_cm_sin,
492 484 sizeof (struct sockaddr_in));
493 485 naddr++;
494 486 break;
495 487 case AF_INET6:
496 488 ipp->ip_inet_family = AF_INET6;
497 489 bcopy(&lifrp->lifr_addr, &ipp->ip_cm_sin6,
498 490 sizeof (struct sockaddr_in6));
499 491 naddr++;
500 492 break;
501 493 }
502 494 }
503 495
504 496 kmem_free(lifc.lifc_buf, bufsize);
505 497 return (naddr > 0);
506 498 }
507 499
508 500 ibt_status_t
509 501 ibcm_arp_get_ibds(ibcm_arp_ibd_insts_t *ibdp, sa_family_t family_loc)
510 502 {
511 503 #ifdef DEBUG
512 504 int i;
513 505 #endif
514 506
515 507 IBTF_DPRINTF_L4(cmlog, "ibcm_arp_get_ibds(%p)", ibdp);
516 508
517 509 ibcm_arp_get_ibd_insts(ibdp);
518 510
519 511 IBTF_DPRINTF_L3(cmlog, "ibcm_arp_get_ibds: Found %d ibd instances",
520 512 ibdp->ibcm_arp_ibd_cnt);
521 513
522 514 if (ibdp->ibcm_arp_ibd_cnt == 0)
523 515 return (IBT_SRC_IP_NOT_FOUND);
524 516
525 517 /* Get the IP addresses of active ports. */
526 518 if (!ibcm_arp_get_ibd_ipaddr(ibdp, family_loc)) {
527 519 IBTF_DPRINTF_L2(cmlog, "ibcm_arp_get_ibds: failed to get "
528 520 "ibd instance: IBT_SRC_IP_NOT_FOUND");
529 521 ibcm_arp_free_ibds(ibdp);
530 522 return (IBT_SRC_IP_NOT_FOUND);
531 523 }
532 524
533 525 #ifdef DEBUG
534 526 for (i = 0; i < ibdp->ibcm_arp_ibd_cnt; i++) {
535 527 char my_buf[INET6_ADDRSTRLEN];
536 528 ibcm_arp_ip_t *aip = &ibdp->ibcm_arp_ip[i];
537 529
538 530 IBTF_DPRINTF_L4(cmlog, "ibcm_arp_get_ibds: Linkid %d Family %d "
539 531 "PKey 0x%lX \n HCAGUID 0x%llX SGID %llX:%llX",
540 532 aip->ip_linkid, aip->ip_inet_family, aip->ip_pkey,
541 533 aip->ip_hca_guid, aip->ip_port_gid.gid_prefix,
542 534 aip->ip_port_gid.gid_guid);
543 535 if (aip->ip_inet_family == AF_INET) {
544 536 IBTF_DPRINTF_L4(cmlog, "ibcm_arp_get_ibds: IPV4: %s",
545 537 inet_ntop(AF_INET, &aip->ip_cm_sin.sin_addr, my_buf,
546 538 sizeof (my_buf)));
547 539 } else if (aip->ip_inet_family == AF_INET6) {
548 540 IBTF_DPRINTF_L4(cmlog, "ibcm_arp_get_ibds: IPV6: %s",
549 541 inet_ntop(AF_INET6, &aip->ip_cm_sin6.sin6_addr,
550 542 my_buf, sizeof (my_buf)));
551 543 } else {
552 544 IBTF_DPRINTF_L2(cmlog, "ibcm_arp_get_ibds: Unknown "
553 545 "Family %d", aip->ip_inet_family);
554 546 }
555 547 }
556 548 #endif
557 549
558 550 return (IBT_SUCCESS);
559 551 }
↓ open down ↓ |
223 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX