Exemplo n.º 1
0
static void
i_xnbo_close_mac(xnb_t *xnbp, boolean_t locked)
{
	xnbo_t *xnbop = xnbp->xnb_flavour_data;
	xmca_t *loop;

	ASSERT(!locked || MUTEX_HELD(&xnbp->xnb_state_lock));

	if (xnbop->o_mh == NULL)
		return;

	if (xnbop->o_running)
		xnbop->o_running = B_FALSE;

	if (!locked)
		mutex_enter(&xnbp->xnb_state_lock);
	loop = xnbop->o_mca;
	xnbop->o_mca = NULL;
	if (!locked)
		mutex_exit(&xnbp->xnb_state_lock);

	while (loop != NULL) {
		xmca_t *next = loop->next;

		DTRACE_PROBE3(mcast_remove,
		    (char *), "close",
		    (void *), xnbp,
		    (etheraddr_t *), loop->addr);
		(void) mac_multicast_remove(xnbop->o_mch, loop->addr);
		kmem_free(loop, sizeof (*loop));
		loop = next;
	}

	if (xnbop->o_promiscuous) {
		if (xnbop->o_mphp != NULL) {
			mac_promisc_remove(xnbop->o_mphp);
			xnbop->o_mphp = NULL;
		}
		xnbop->o_promiscuous = B_FALSE;
	} else {
		if (xnbop->o_mch != NULL)
			mac_rx_clear(xnbop->o_mch);
	}

	if (xnbop->o_mah != NULL) {
		(void) mac_unicast_remove(xnbop->o_mch, xnbop->o_mah);
		xnbop->o_mah = NULL;
	}

	if (xnbop->o_mch != NULL) {
		mac_client_close(xnbop->o_mch, 0);
		xnbop->o_mch = NULL;
	}

	mac_close(xnbop->o_mh);
	xnbop->o_mh = NULL;
}
Exemplo n.º 2
0
/*
 * Set the promiscuous mode of a network interface.
 * This function only calls the mac layer when there is a change to the
 * status of a network interface's promiscous mode. Tracking of how many
 * sockets have the network interface in promiscuous mode, and thus the
 * control over the physical device's status, is left to the mac layer.
 */
static int
pfp_set_promisc(struct pfpsock *ps, mac_client_promisc_type_t turnon)
{
	int error = 0;
	int flags;

	/*
	 * There are 4 combinations of turnon/ps_promisc.
	 * This if handles 2 (both false, both true) and the if() below
	 * handles the remaining one - when change is required.
	 */
	if (turnon == ps->ps_promisc)
		return (error);

	if (ps->ps_phd != 0) {
		mac_promisc_remove(ps->ps_phd);
		ps->ps_phd = 0;

		/*
		 * ps_promisc is set here in case the call to mac_promisc_add
		 * fails: leaving it to indicate that the interface is still
		 * in some sort of promiscuous mode is false.
		 */
		if (ps->ps_promisc != MAC_CLIENT_PROMISC_FILTERED) {
			ps->ps_promisc = MAC_CLIENT_PROMISC_FILTERED;
			flags = MAC_PROMISC_FLAGS_NO_PHYS;
		} else {
			flags = 0;
		}
		flags |= MAC_PROMISC_FLAGS_VLAN_TAG_STRIP;
	}

	error = mac_promisc_add(ps->ps_mch, turnon, pfp_packet, ps,
	    &ps->ps_phd, flags);
	if (error == 0)
		ps->ps_promisc = turnon;

	return (error);
}
Exemplo n.º 3
0
/* ARGSUSED */
static int
sdpfp_close(sock_lower_handle_t handle, int flag, struct cred *cr)
{
	struct pfpsock *ps = (struct pfpsock *)handle;

	if (ps->ps_phd != 0) {
		mac_promisc_remove(ps->ps_phd);
		ps->ps_phd = 0;
	}

	if (ps->ps_mch != 0) {
		mac_client_close(ps->ps_mch, 0);
		ps->ps_mch = 0;
	}

	if (ps->ps_mh != 0) {
		mac_close(ps->ps_mh);
		ps->ps_mh = 0;
	}

	kmem_free(ps, sizeof (*ps));

	return (0);
}
Exemplo n.º 4
0
static void
mac_bpf_promisc_remove(uintptr_t phandle)
{
	mac_promisc_remove((mac_promisc_handle_t)phandle);
}