Esempio n. 1
0
static ibcm_arp_ip_t *
ibcm_arp_lookup(ibcm_arp_ibd_insts_t *ibds, char *linkname)
{
	datalink_id_t	linkid;
	int		i;

	IBTF_DPRINTF_L4(cmlog, "ibcm_arp_lookup: linkname =  %s", linkname);

	/*
	 * If at first we don't succeed, try again, just in case it is in
	 * hiding. The first call requires the datalink management daemon
	 * (the authorative source of information about name to id mapping)
	 * to be present and answering upcalls, the second does not.
	 */
	if (dls_mgmt_get_linkid(linkname, &linkid) != 0) {
		if (dls_devnet_macname2linkid(linkname, &linkid) != 0) {
			IBTF_DPRINTF_L2(cmlog, "ibcm_arp_lookup: could not "
			    "get linkid from linkname (%s)", linkname);
			return (NULL);
		}
	}

	for (i = 0; i < ibds->ibcm_arp_ibd_cnt; i++) {
		if (ibds->ibcm_arp_ip[i].ip_linkid == linkid)
			return (&ibds->ibcm_arp_ip[i]);
	}

	IBTF_DPRINTF_L2(cmlog, "ibcm_arp_lookup: returning NULL for "
	    "linkname (%s)", linkname);
	return (NULL);
}
Esempio n. 2
0
/*ARGSUSED*/
static int
mac_bpf_getlinkid(const char *name, datalink_id_t *idp, zoneid_t zoneid)
{
	int error;

	/*
	 * If at first we don't succeed, try again, just in case it is in
	 * hiding. The first call requires the datalink management daemon
	 * (the authorative source of information about name to id mapping)
	 * to be present and answering upcalls, the seond does not.
	 */
	error = dls_mgmt_get_linkid(name, idp);
	if (error != 0)
		error = dls_devnet_macname2linkid(name, idp);

	return (error);
}
/*
 * Given a pointer (arg) to a "struct lifreq" (potentially in user space),
 * determine the linkid for the interface name stored in that structure.
 * name is used as a buffer so that we can ensure a trailing \0 is appended
 * to the name safely.
 */
static int
pfp_lifreq_getlinkid(intptr_t arg, struct lifreq *lifreqp,
    datalink_id_t *linkidp)
{
	char name[LIFNAMSIZ + 1];
	int error;

	if (ddi_copyin((void *)arg, lifreqp, sizeof (*lifreqp), 0) != 0)
		return (EFAULT);

	(void) strlcpy(name, lifreqp->lifr_name, sizeof (name));

	error = dls_mgmt_get_linkid(name, linkidp);
	if (error != 0)
		error = dls_devnet_macname2linkid(name, linkidp);

	return (error);
}