ip2mac.c revision 4b7cbb468ccaa93f260f3964b823da34e5b0e1e5
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* Functions to implement IP address -> link layer address (PSARC 2006/482)
*/
#include <inet/ip2mac_impl.h>
/*
* dispatch pending callbacks.
*/
void
{
return;
}
/*
* IP does not hold internal locks like nce_lock across calls to
* other subsystems for fear of recursive lock entry and lock
* hierarchy violation. The caller may be holding locks across
* the call to IP. (It would be ideal if no subsystem holds locks
* across calls into another subsystem, especially if calls can
* happen in either direction).
*/
continue;
}
}
/*
* fill up the ip2m response fields with inforamation from the nce.
*/
void
{
struct sockaddr_dl *sdl;
ip2m->ip2mac_err = 0;
else
if (isv6) {
}
if (ip2m->ip2mac_err == 0) {
}
}
void
{
nce->nce_cb_walker_cnt++;
}
void
{
if (--nce->nce_cb_walker_cnt == 0) {
nce_cb = nce_cb_next) {
continue;
}
}
}
/*
* add a callback to the nce, so that the callback can be invoked
*/
static ip2mac_id_t
{
return (ip2mid);
/*
* We identify the nce_cb_t during cancellation by the address
* of the nce_cb_t itself, and, as a short-cut for eliminating
* clear mismatches, only look in the callback list of nce's
* whose address is equal to the nce_cb_id.
*/
return (nce_cb);
}
/*
* Resolve an IP address to a link-layer address using the data-structures
* defined in PSARC 2006/482. If the current link-layer address for the
* IP address is not known, the state-machine for resolving the resolution
* will be triggered, and the callback function (*cb) will be invoked after
* the resolution completes.
*/
{
netstack_t *ns;
int err;
if (!isv6) {
/*
* IPv4 is not currently supported.
*/
return (NULL);
}
return (NULL);
}
/*
* For exclusive stacks we reset the zoneid to zero
* since IP uses the global zoneid in the exclusive stacks.
*/
/*
* find the ill from the ip2m->ip2mac_ifindex
*/
return (NULL);
}
if (isv6) {
if (flags == IP2MAC_LOOKUP) {
B_FALSE);
} else {
0, 0, ND_INCOMPLETE, &nce);
}
} else {
goto done;
}
if (flags == IP2MAC_LOOKUP) {
goto done;
}
if (NCE_ISREACHABLE(nce)) {
ip2m->ip2mac_err = 0;
} else {
}
goto done;
} else {
goto done;
}
}
} else if (!NCE_ISREACHABLE(nce) ||
if (NCE_ISREACHABLE(nce)) {
/*
* Since we do not control the packet output
* path for ip2mac() callers, we need to verify
* if the existing information in the nce is
* very old, and retrigger resolution if necessary.
* We will not return the existing stale
* information until it is verified through a
*
* In the future, we may want to support extensions
* that do additional callbacks on link-layer updates,
* so that we can return the stale information but
* also update the caller if the lladdr changes.
*/
err = 0; /* treat this nce as a new one */
}
/*
* Still resolving this nce, so we can
* queue the callback information in nce->nce_cb
*/
} else {
/*
* Resolution failed.
*/
}
} else {
ip2m->ip2mac_err = 0;
}
done:
return (ip2mid);
}
/*
* data passed to nce_walk for canceling outstanding callbacks.
*/
typedef struct ip2mac_cancel_data_s {
int ip2m_cancel_err;
/*
* callback invoked for each active nce. If the ip2mac_id_t corresponds
* to an active nce_cb_t in the nce's callback list, we want to remove
* the callback (if there are no walkers) or return EBUSY to the caller
*/
static int
{
return (0);
return (0);
}
/*
* IP does not hold internal locks like nce_lock across calls to
* other subsystems for fear of recursive lock entry and lock
* hierarchy violation. The caller may be holding locks across
* the call to IP. (It would be ideal if no subsystem holds locks
* across calls into another subsystem, especially if calls can
* happen in either direction).
*/
if (nce_cb != ip2m_nce_cb)
continue;
/*
* If there are no walkers we can remove the nce_cb.
* Otherwise the exiting walker will clean up.
*/
if (nce->nce_cb_walker_cnt == 0) {
} else {
}
break;
}
return (0);
}
/*
* cancel an outstanding timeout set up via ip2mac
*/
int
{
netstack_t *ns;
return (ip2m_wdata.ip2m_cancel_err);
}
/*
* For exclusive stacks we reset the zoneid to zero
* since IP uses the global zoneid in the exclusive stacks.
*/
/*
* We may return EBUSY if a walk to dispatch callbacks is
* in progress, in which case the caller needs to synchronize
* with the registered callback function to make sure the
* module does not exit when there is a callback pending.
*/
return (ip2m_wdata.ip2m_cancel_err);
}