28 #include <sys/strsubr.h>
29 #include <sys/socket.h>
30 #include <net/if_arp.h>
31 #include <net/if_types.h>
32 #include <sys/sockio.h>
33 #include <sys/pathname.h>
34
35 #include <sys/ib/mgt/ibcm/ibcm_arp.h>
36
37 #include <sys/kstr.h>
38 #include <sys/t_kuser.h>
39
40 #include <sys/dls.h>
41
42 extern char cmlog[];
43
44 extern int ibcm_resolver_pr_lookup(ibcm_arp_streams_t *ib_s,
45 ibt_ip_addr_t *dst_addr, ibt_ip_addr_t *src_addr, zoneid_t myzoneid);
46 extern void ibcm_arp_delete_prwqn(ibcm_arp_prwqn_t *wqnp);
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 int ibcm_printip = 0;
56
57 /*
58 * Function:
59 * ibcm_ip_print
60 * Input:
61 * label Arbitrary qualifying string
62 * ipa Pointer to IP Address to print
63 */
64 void
65 ibcm_ip_print(char *label, ibt_ip_addr_t *ipaddr)
66 {
67 char buf[INET6_ADDRSTRLEN];
68
69 if (ipaddr->family == AF_INET) {
70 IBTF_DPRINTF_L2(cmlog, "%s: %s", label,
71 inet_ntop(AF_INET, &ipaddr->un.ip4addr, buf, sizeof (buf)));
72 } else if (ipaddr->family == AF_INET6) {
73 IBTF_DPRINTF_L2(cmlog, "%s: %s", label, inet_ntop(AF_INET6,
74 &ipaddr->un.ip6addr, buf, sizeof (buf)));
306 int err;
307 struct lifnum lifn;
308
309 bzero(&lifn, sizeof (struct lifnum));
310 lifn.lifn_family = family_loc;
311 lifn.lifn_flags = LIFC_NOXMIT | LIFC_TEMPORARY | LIFC_ALLZONES;
312
313 err = ibcm_do_ip_ioctl(SIOCGLIFNUM, sizeof (struct lifnum), &lifn);
314 if (err != 0)
315 return (err);
316
317 IBTF_DPRINTF_L3(cmlog, "ibcm_do_lifconf: Family %d, lifn_count %d",
318 family_loc, lifn.lifn_count);
319 /*
320 * Pad the interface count to account for additional interfaces that
321 * may have been configured between the SIOCGLIFNUM and SIOCGLIFCONF.
322 */
323 lifn.lifn_count += 4;
324
325 bzero(lifcp, sizeof (struct lifconf));
326 _NOTE(NOW_INVISIBLE_TO_OTHER_THREADS(*lifcp))
327 lifcp->lifc_family = family_loc;
328 lifcp->lifc_len = *bufsizep = lifn.lifn_count * sizeof (struct lifreq);
329 lifcp->lifc_buf = kmem_zalloc(*bufsizep, KM_SLEEP);
330 lifcp->lifc_flags = LIFC_NOXMIT | LIFC_TEMPORARY | LIFC_ALLZONES;
331
332 err = ibcm_do_ip_ioctl(SIOCGLIFCONF, sizeof (struct lifconf), lifcp);
333 if (err != 0) {
334 kmem_free(lifcp->lifc_buf, *bufsizep);
335 return (err);
336 }
337 return (0);
338 }
339
340 static ibcm_arp_ip_t *
341 ibcm_arp_lookup(ibcm_arp_ibd_insts_t *ibds, char *linkname)
342 {
343 datalink_id_t linkid;
344 int i;
345
346 IBTF_DPRINTF_L4(cmlog, "ibcm_arp_lookup: linkname = %s", linkname);
|
28 #include <sys/strsubr.h>
29 #include <sys/socket.h>
30 #include <net/if_arp.h>
31 #include <net/if_types.h>
32 #include <sys/sockio.h>
33 #include <sys/pathname.h>
34
35 #include <sys/ib/mgt/ibcm/ibcm_arp.h>
36
37 #include <sys/kstr.h>
38 #include <sys/t_kuser.h>
39
40 #include <sys/dls.h>
41
42 extern char cmlog[];
43
44 extern int ibcm_resolver_pr_lookup(ibcm_arp_streams_t *ib_s,
45 ibt_ip_addr_t *dst_addr, ibt_ip_addr_t *src_addr, zoneid_t myzoneid);
46 extern void ibcm_arp_delete_prwqn(ibcm_arp_prwqn_t *wqnp);
47
48 int ibcm_printip = 0;
49
50 /*
51 * Function:
52 * ibcm_ip_print
53 * Input:
54 * label Arbitrary qualifying string
55 * ipa Pointer to IP Address to print
56 */
57 void
58 ibcm_ip_print(char *label, ibt_ip_addr_t *ipaddr)
59 {
60 char buf[INET6_ADDRSTRLEN];
61
62 if (ipaddr->family == AF_INET) {
63 IBTF_DPRINTF_L2(cmlog, "%s: %s", label,
64 inet_ntop(AF_INET, &ipaddr->un.ip4addr, buf, sizeof (buf)));
65 } else if (ipaddr->family == AF_INET6) {
66 IBTF_DPRINTF_L2(cmlog, "%s: %s", label, inet_ntop(AF_INET6,
67 &ipaddr->un.ip6addr, buf, sizeof (buf)));
299 int err;
300 struct lifnum lifn;
301
302 bzero(&lifn, sizeof (struct lifnum));
303 lifn.lifn_family = family_loc;
304 lifn.lifn_flags = LIFC_NOXMIT | LIFC_TEMPORARY | LIFC_ALLZONES;
305
306 err = ibcm_do_ip_ioctl(SIOCGLIFNUM, sizeof (struct lifnum), &lifn);
307 if (err != 0)
308 return (err);
309
310 IBTF_DPRINTF_L3(cmlog, "ibcm_do_lifconf: Family %d, lifn_count %d",
311 family_loc, lifn.lifn_count);
312 /*
313 * Pad the interface count to account for additional interfaces that
314 * may have been configured between the SIOCGLIFNUM and SIOCGLIFCONF.
315 */
316 lifn.lifn_count += 4;
317
318 bzero(lifcp, sizeof (struct lifconf));
319 lifcp->lifc_family = family_loc;
320 lifcp->lifc_len = *bufsizep = lifn.lifn_count * sizeof (struct lifreq);
321 lifcp->lifc_buf = kmem_zalloc(*bufsizep, KM_SLEEP);
322 lifcp->lifc_flags = LIFC_NOXMIT | LIFC_TEMPORARY | LIFC_ALLZONES;
323
324 err = ibcm_do_ip_ioctl(SIOCGLIFCONF, sizeof (struct lifconf), lifcp);
325 if (err != 0) {
326 kmem_free(lifcp->lifc_buf, *bufsizep);
327 return (err);
328 }
329 return (0);
330 }
331
332 static ibcm_arp_ip_t *
333 ibcm_arp_lookup(ibcm_arp_ibd_insts_t *ibds, char *linkname)
334 {
335 datalink_id_t linkid;
336 int i;
337
338 IBTF_DPRINTF_L4(cmlog, "ibcm_arp_lookup: linkname = %s", linkname);
|