1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-02 08:42:48 +00:00

This commit does two things:

1. rt_check() cleanup:
    rt_check() is only necessary for some address families to gain access
    to the corresponding arp entry, so call it only in/near the *resolve()
    routines where it is actually used -- at the moment this is
    arpresolve(), nd6_storelladdr() (the call is embedded here),
    and atmresolve() (the call is just before atmresolve to reduce
    the number of changes).
    This change will make it a lot easier to decouple the arp table
    from the routing table.

    There is an extra call to rt_check() in if_iso88025subr.c to
    determine the routing info length. I have left it alone for
    the time being.

    The interface of arpresolve() and nd6_storelladdr() now changes slightly:
     + the 'rtentry' parameter (really a hint from the upper level layer)
       is now passed unchanged from *_output(), so it becomes the route
       to the final destination and not to the gateway.
     + the routines will return 0 if resolution is possible, non-zero
       otherwise.
     + arpresolve() returns EWOULDBLOCK in case the mbuf is being held
       waiting for an arp reply -- in this case the error code is masked
       in the caller so the upper layer protocol will not see a failure.

2. arpcom untangling
    Where possible, use 'struct ifnet' instead of 'struct arpcom' variables,
    and use the IFP2AC macro to access arpcom fields.
    This mostly affects the netatalk code.

=== Detailed changes: ===
net/if_arcsubr.c
   rt_check() cleanup, remove a useless variable

net/if_atmsubr.c
   rt_check() cleanup

net/if_ethersubr.c
   rt_check() cleanup, arpcom untangling

net/if_fddisubr.c
   rt_check() cleanup, arpcom untangling

net/if_iso88025subr.c
   rt_check() cleanup

netatalk/aarp.c
   arpcom untangling, remove a block of duplicated code

netatalk/at_extern.h
   arpcom untangling

netinet/if_ether.c
   rt_check() cleanup (change arpresolve)

netinet6/nd6.c
   rt_check() cleanup (change nd6_storelladdr)
This commit is contained in:
Luigi Rizzo 2004-04-25 09:24:52 +00:00
parent 8cd65c072e
commit cd46a114fc
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=128636
9 changed files with 118 additions and 111 deletions

View File

@ -107,8 +107,6 @@ arc_output(ifp, m, dst, rt0)
struct sockaddr *dst;
struct rtentry *rt0;
{
struct rtentry *rt;
struct arccom *ac;
struct arc_header *ah;
int error;
u_int8_t atype, adst;
@ -119,11 +117,6 @@ arc_output(ifp, m, dst, rt0)
return(ENETDOWN); /* m, m1 aren't initialized yet */
error = 0;
ac = (struct arccom *)ifp;
error = rt_check(&rt, &rt0, dst);
if (error)
goto bad;
switch (dst->sa_family) {
#ifdef INET
@ -136,8 +129,11 @@ arc_output(ifp, m, dst, rt0)
adst = arcbroadcastaddr; /* ARCnet broadcast address */
else if (ifp->if_flags & IFF_NOARP)
adst = ntohl(SIN(dst)->sin_addr.s_addr) & 0xFF;
else if (!arpresolve(ifp, rt, m, dst, &adst))
return 0; /* not resolved yet */
else {
error = arpresolve(ifp, rt0, m, dst, &adst);
if (error)
return (error == EWOULDBLOCK ? 0 : error);
}
atype = (ifp->if_flags & IFF_LINK0) ?
ARCTYPE_IP_OLD : ARCTYPE_IP;
@ -172,13 +168,9 @@ arc_output(ifp, m, dst, rt0)
#endif
#ifdef INET6
case AF_INET6:
#ifdef OLDIP6OUTPUT
if (!nd6_resolve(ifp, rt, m, dst, (u_char *)&adst))
return(0); /* if not yet resolves */
#else
if (!nd6_storelladdr(ifp, rt, m, dst, (u_char *)&adst))
return(0); /* it must be impossible, but... */
#endif /* OLDIP6OUTPUT */
error = nd6_storelladdr(ifp, rt0, m, dst, (u_char *)&adst);
if (error)
return (error);
atype = ARCTYPE_INET6;
break;
#endif

View File

@ -126,7 +126,6 @@ atm_output(struct ifnet *ifp, struct mbuf *m0, struct sockaddr *dst,
int error = 0, sz;
struct atm_pseudohdr atmdst, *ad;
struct mbuf *m = m0;
struct rtentry *rt;
struct atmllc *atmllc;
struct atmllc *llc_hdr = NULL;
u_int32_t atm_flags;
@ -140,13 +139,6 @@ atm_output(struct ifnet *ifp, struct mbuf *m0, struct sockaddr *dst,
if ((ifp->if_flags & (IFF_UP | IFF_RUNNING)) != (IFF_UP | IFF_RUNNING))
senderr(ENETDOWN);
/*
* check route
*/
error = rt_check(&rt, &rt0, dst);
if (error)
goto bad;
/*
* check for non-native ATM traffic (dst != NULL)
*/
@ -156,6 +148,15 @@ atm_output(struct ifnet *ifp, struct mbuf *m0, struct sockaddr *dst,
#if defined(INET) || defined(INET6)
case AF_INET:
case AF_INET6:
{
struct rtentry *rt;
/*
* check route
*/
error = rt_check(&rt, &rt0, dst);
if (error)
goto bad;
if (dst->sa_family == AF_INET6)
etype = ETHERTYPE_IPV6;
else
@ -167,6 +168,7 @@ atm_output(struct ifnet *ifp, struct mbuf *m0, struct sockaddr *dst,
/* XXX: put ATMARP stuff here */
/* XXX: watch who frees m on failure */
}
}
break;
#endif /* INET || INET6 */

View File

@ -132,9 +132,8 @@ ether_output(struct ifnet *ifp, struct mbuf *m,
struct sockaddr *dst, struct rtentry *rt0)
{
short type;
int error = 0, hdrcmplt = 0;
int error, hdrcmplt = 0;
u_char esrc[ETHER_ADDR_LEN], edst[ETHER_ADDR_LEN];
struct rtentry *rt;
struct ether_header *eh;
int loop_copy = 0;
int hlen; /* link layer header length */
@ -150,16 +149,13 @@ ether_output(struct ifnet *ifp, struct mbuf *m,
if ((ifp->if_flags & (IFF_UP|IFF_RUNNING)) != (IFF_UP|IFF_RUNNING))
senderr(ENETDOWN);
error = rt_check(&rt, &rt0, dst);
if (error)
goto bad;
hlen = ETHER_HDR_LEN;
switch (dst->sa_family) {
#ifdef INET
case AF_INET:
if (!arpresolve(ifp, rt, m, dst, edst))
return (0); /* if not yet resolved */
error = arpresolve(ifp, rt0, m, dst, edst);
if (error)
return (error == EWOULDBLOCK ? 0 : error);
type = htons(ETHERTYPE_IP);
break;
case AF_ARP:
@ -192,10 +188,9 @@ ether_output(struct ifnet *ifp, struct mbuf *m,
#endif
#ifdef INET6
case AF_INET6:
if (!nd6_storelladdr(ifp, rt, m, dst, (u_char *)edst)) {
/* Something bad happened */
return(0);
}
error = nd6_storelladdr(ifp, rt0, m, dst, (u_char *)edst);
if (error)
return error;
type = htons(ETHERTYPE_IPV6);
break;
#endif
@ -216,15 +211,12 @@ ether_output(struct ifnet *ifp, struct mbuf *m,
{
struct at_ifaddr *aa;
if ((aa = at_ifawithnet((struct sockaddr_at *)dst)) == NULL) {
goto bad;
}
if (!aarpresolve(IFP2AC(ifp), m, (struct sockaddr_at *)dst, edst))
if ((aa = at_ifawithnet((struct sockaddr_at *)dst)) == NULL)
senderr(EHOSTUNREACH); /* XXX */
if (!aarpresolve(ifp, m, (struct sockaddr_at *)dst, edst))
return (0);
/*
* In the phase 2 case, need to prepend an mbuf for the llc header.
* Since we must preserve the value of m, which is passed to us by
* value, we m_copy() the first mbuf, and use it for our llc header.
*/
if ( aa->aa_flags & AFA_PHASE2 ) {
struct llc llc;

View File

@ -117,7 +117,6 @@ fddi_output(ifp, m, dst, rt0)
u_int16_t type;
int loop_copy = 0, error = 0, hdrcmplt = 0;
u_char esrc[FDDI_ADDR_LEN], edst[FDDI_ADDR_LEN];
struct rtentry *rt;
struct fddi_header *fh;
#ifdef MAC
@ -132,15 +131,12 @@ fddi_output(ifp, m, dst, rt0)
senderr(ENETDOWN);
getmicrotime(&ifp->if_lastchange);
error = rt_check(&rt, &rt0, dst);
if (error)
goto bad;
switch (dst->sa_family) {
#ifdef INET
case AF_INET: {
if (!arpresolve(ifp, rt, m, dst, edst))
return (0); /* if not yet resolved */
error = arpresolve(ifp, rt0, m, dst, edst);
if (error)
return (error == EWOULDBLOCK ? 0 : error);
type = htons(ETHERTYPE_IP);
break;
}
@ -174,10 +170,9 @@ fddi_output(ifp, m, dst, rt0)
#endif /* INET */
#ifdef INET6
case AF_INET6:
if (!nd6_storelladdr(ifp, rt, m, dst, (u_char *)edst)) {
/* Something bad happened */
return (0);
}
error = nd6_storelladdr(ifp, rt0, m, dst, (u_char *)edst);
if (error)
return (error); /* Something bad happened */
type = htons(ETHERTYPE_IPV6);
break;
#endif /* INET6 */
@ -191,7 +186,7 @@ fddi_output(ifp, m, dst, rt0)
#ifdef NETATALK
case AF_APPLETALK: {
struct at_ifaddr *aa;
if (!aarpresolve(IFP2AC(ifp), m, (struct sockaddr_at *)dst, edst))
if (!aarpresolve(ifp, m, (struct sockaddr_at *)dst, edst))
return (0);
/*
* ifaddr is the first thing in at_ifaddr

View File

@ -259,11 +259,12 @@ iso88025_output(ifp, m, dst, rt0)
senderr(ENETDOWN);
getmicrotime(&ifp->if_lastchange);
/* Calculate routing info length based on arp table entry */
/* XXX any better way to do this ? */
error = rt_check(&rt, &rt0, dst);
if (error)
goto bad;
/* Calculate routing info length based on arp table entry */
if (rt && (sdl = (struct sockaddr_dl *)rt->rt_gateway))
if (SDL_ISO88025(sdl)->trld_rcf != 0)
rif_len = TR_RCF_RIFLEN(SDL_ISO88025(sdl)->trld_rcf);
@ -286,8 +287,9 @@ iso88025_output(ifp, m, dst, rt0)
switch (dst->sa_family) {
#ifdef INET
case AF_INET:
if (!arpresolve(ifp, rt, m, dst, edst))
return (0); /* if not yet resolved */
error = arpresolve(ifp, rt0, m, dst, edst);
if (error)
return (error == EWOULDBLOCK ? 0 : error);
snap_type = ETHERTYPE_IP;
break;
case AF_ARP:
@ -320,10 +322,9 @@ iso88025_output(ifp, m, dst, rt0)
#endif /* INET */
#ifdef INET6
case AF_INET6:
if (!nd6_storelladdr(ifp, rt, m, dst, (u_char *)edst)) {
/* Something bad happened */
return(0);
}
error = nd6_storelladdr(ifp, rt0, m, dst, (u_char *)edst);
if (error)
return (error);
snap_type = ETHERTYPE_IPV6;
break;
#endif /* INET6 */

View File

@ -29,7 +29,7 @@
#include <netatalk/at_extern.h>
static void aarptfree(struct aarptab *aat);
static void at_aarpinput(struct arpcom *ac, struct mbuf *m);
static void at_aarpinput(struct ifnet *ifp, struct mbuf *m);
#define AARPTAB_BSIZ 9
#define AARPTAB_NB 19
@ -130,7 +130,7 @@ at_ifawithnet(struct sockaddr_at *sat)
}
static void
aarpwhohas(struct arpcom *ac, struct sockaddr_at *sat)
aarpwhohas(struct ifnet *ifp, struct sockaddr_at *sat)
{
struct mbuf *m;
struct ether_header *eh;
@ -144,7 +144,7 @@ aarpwhohas(struct arpcom *ac, struct sockaddr_at *sat)
return;
}
#ifdef MAC
mac_create_mbuf_linklayer(&ac->ac_if, m);
mac_create_mbuf_linklayer(ifp, m);
#endif
m->m_len = sizeof(*ea);
m->m_pkthdr.len = sizeof(*ea);
@ -158,7 +158,7 @@ aarpwhohas(struct arpcom *ac, struct sockaddr_at *sat)
ea->aarp_hln = sizeof(ea->aarp_sha);
ea->aarp_pln = sizeof(ea->aarp_spu);
ea->aarp_op = htons(AARPOP_REQUEST);
bcopy((caddr_t)ac->ac_enaddr, (caddr_t)ea->aarp_sha,
bcopy(IFP2AC(ifp)->ac_enaddr, (caddr_t)ea->aarp_sha,
sizeof(ea->aarp_sha));
/*
@ -195,7 +195,7 @@ aarpwhohas(struct arpcom *ac, struct sockaddr_at *sat)
ea->aarp_spnode = AA_SAT(aa)->sat_addr.s_node;
ea->aarp_tpnode = sat->sat_addr.s_node;
} else {
bcopy(ac->ac_if.if_broadcastaddr, (caddr_t)eh->ether_dhost,
bcopy(ifp->if_broadcastaddr, (caddr_t)eh->ether_dhost,
sizeof(eh->ether_dhost));
eh->ether_type = htons(ETHERTYPE_AARP);
@ -211,13 +211,12 @@ aarpwhohas(struct arpcom *ac, struct sockaddr_at *sat)
sa.sa_len = sizeof(struct sockaddr);
sa.sa_family = AF_UNSPEC;
(*ac->ac_if.if_output)(&ac->ac_if,
m, &sa, NULL); /* XXX NULL should be routing information */
ifp->if_output(ifp, m, &sa, NULL /* route */);
}
int
aarpresolve(ac, m, destsat, desten)
struct arpcom *ac;
aarpresolve(ifp, m, destsat, desten)
struct ifnet *ifp;
struct mbuf *m;
struct sockaddr_at *destsat;
u_char *desten;
@ -234,8 +233,8 @@ aarpresolve(ac, m, destsat, desten)
if (aa->aa_flags & AFA_PHASE2) {
bcopy(atmulticastaddr, (caddr_t)desten, sizeof(atmulticastaddr));
} else {
bcopy(ac->ac_if.if_broadcastaddr, (caddr_t)desten,
sizeof(ac->ac_if.if_addrlen));
bcopy(ifp->if_broadcastaddr, (caddr_t)desten,
sizeof(ifp->if_addrlen));
}
return (1);
}
@ -244,13 +243,10 @@ aarpresolve(ac, m, destsat, desten)
AARPTAB_LOOK(aat, destsat->sat_addr);
if (aat == NULL) { /* No entry */
aat = aarptnew(&destsat->sat_addr);
if (aat == NULL) {
if (aat == NULL) { /* we should fail more gracefully! */
panic("aarpresolve: no free entry");
}
aat->aat_hold = m;
AARPTAB_UNLOCK();
aarpwhohas(ac, destsat);
return (0);
goto done;
}
/* found an entry */
aat->aat_timer = 0;
@ -264,9 +260,10 @@ aarpresolve(ac, m, destsat, desten)
if (aat->aat_hold) {
m_freem(aat->aat_hold);
}
done:
aat->aat_hold = m;
AARPTAB_UNLOCK();
aarpwhohas(ac, destsat);
aarpwhohas(ifp, destsat);
return (0);
}
@ -275,10 +272,10 @@ aarpintr(m)
struct mbuf *m;
{
struct arphdr *ar;
struct arpcom *ac;
struct ifnet *ifp;
ac = (struct arpcom *)m->m_pkthdr.rcvif;
if (ac->ac_if.if_flags & IFF_NOARP)
ifp = m->m_pkthdr.rcvif;
if (ifp->if_flags & IFF_NOARP)
goto out;
if (m->m_len < sizeof(struct arphdr)) {
@ -297,7 +294,7 @@ aarpintr(m)
switch(ntohs(ar->ar_pro)) {
case ETHERTYPE_AT :
at_aarpinput(ac, m);
at_aarpinput(ifp, m);
return;
default:
@ -309,7 +306,7 @@ aarpintr(m)
}
static void
at_aarpinput(struct arpcom *ac, struct mbuf *m)
at_aarpinput(struct ifnet *ifp, struct mbuf *m)
{
struct ether_aarp *ea;
struct at_ifaddr *aa;
@ -327,8 +324,8 @@ at_aarpinput(struct arpcom *ac, struct mbuf *m)
ea = mtod(m, struct ether_aarp *);
/* Check to see if from my hardware address */
if (!bcmp((caddr_t)ea->aarp_sha, (caddr_t)ac->ac_enaddr,
sizeof(ac->ac_enaddr))) {
if (!bcmp((caddr_t)ea->aarp_sha, IFP2AC(ifp)->ac_enaddr,
sizeof(IFP2AC(ifp)->ac_enaddr))) {
m_freem(m);
return;
}
@ -351,7 +348,7 @@ at_aarpinput(struct arpcom *ac, struct mbuf *m)
* Since we don't know the net, we just look for the first
* phase 1 address on the interface.
*/
for (aa = (struct at_ifaddr *)TAILQ_FIRST(&ac->ac_if.if_addrhead); aa;
for (aa = (struct at_ifaddr *)TAILQ_FIRST(&ifp->if_addrhead); aa;
aa = (struct at_ifaddr *)aa->aa_ifa.ifa_link.tqe_next) {
if (AA_SAT(aa)->sat_family == AF_APPLETALK &&
(aa->aa_flags & AFA_PHASE2) == 0) {
@ -380,7 +377,7 @@ at_aarpinput(struct arpcom *ac, struct mbuf *m)
* probed for the same address we'd like to use. Change the
* address we're probing for.
*/
untimeout(aarpprobe, ac, aa->aa_ch);
untimeout(aarpprobe, ifp, aa->aa_ch);
wakeup(aa);
m_freem(m);
return;
@ -424,7 +421,7 @@ at_aarpinput(struct arpcom *ac, struct mbuf *m)
sat.sat_len = sizeof(struct sockaddr_at);
sat.sat_family = AF_APPLETALK;
sat.sat_addr = spa;
(*ac->ac_if.if_output)(&ac->ac_if, mhold,
(*ifp->if_output)(ifp, mhold,
(struct sockaddr *)&sat, NULL); /* XXX */
} else
AARPTAB_UNLOCK();
@ -451,7 +448,7 @@ at_aarpinput(struct arpcom *ac, struct mbuf *m)
bcopy((caddr_t)ea->aarp_sha, (caddr_t)ea->aarp_tha,
sizeof(ea->aarp_sha));
bcopy((caddr_t)ac->ac_enaddr, (caddr_t)ea->aarp_sha,
bcopy(IFP2AC(ifp)->ac_enaddr, (caddr_t)ea->aarp_sha,
sizeof(ea->aarp_sha));
/* XXX */
@ -484,7 +481,7 @@ at_aarpinput(struct arpcom *ac, struct mbuf *m)
sa.sa_len = sizeof(struct sockaddr);
sa.sa_family = AF_UNSPEC;
(*ac->ac_if.if_output)(&ac->ac_if, m, &sa, NULL); /* XXX */
(*ifp->if_output)(ifp, m, &sa, NULL); /* XXX */
return;
}
@ -540,7 +537,7 @@ aarptnew(addr)
void
aarpprobe(void *arg)
{
struct arpcom *ac = arg;
struct ifnet *ifp = arg;
struct mbuf *m;
struct ether_header *eh;
struct ether_aarp *ea;
@ -555,7 +552,7 @@ aarpprobe(void *arg)
* interface with the same address as we're looking for. If the
* net is phase 2, generate an 802.2 and SNAP header.
*/
for (aa = (struct at_ifaddr *)TAILQ_FIRST(&ac->ac_if.if_addrhead); aa;
for (aa = (struct at_ifaddr *)TAILQ_FIRST(&ifp->if_addrhead); aa;
aa = (struct at_ifaddr *)aa->aa_ifa.ifa_link.tqe_next) {
if (AA_SAT(aa)->sat_family == AF_APPLETALK &&
(aa->aa_flags & AFA_PROBING)) {
@ -572,14 +569,14 @@ aarpprobe(void *arg)
wakeup(aa);
return;
} else {
aa->aa_ch = timeout(aarpprobe, (caddr_t)ac, hz / 5);
aa->aa_ch = timeout(aarpprobe, (caddr_t)ifp, hz / 5);
}
if ((m = m_gethdr(M_DONTWAIT, MT_DATA)) == NULL) {
return;
}
#ifdef MAC
mac_create_mbuf_linklayer(&ac->ac_if, m);
mac_create_mbuf_linklayer(ifp, m);
#endif
m->m_len = sizeof(*ea);
m->m_pkthdr.len = sizeof(*ea);
@ -593,7 +590,7 @@ aarpprobe(void *arg)
ea->aarp_hln = sizeof(ea->aarp_sha);
ea->aarp_pln = sizeof(ea->aarp_spu);
ea->aarp_op = htons(AARPOP_PROBE);
bcopy((caddr_t)ac->ac_enaddr, (caddr_t)ea->aarp_sha,
bcopy(IFP2AC(ifp)->ac_enaddr, (caddr_t)ea->aarp_sha,
sizeof(ea->aarp_sha));
eh = (struct ether_header *)sa.sa_data;
@ -618,7 +615,7 @@ aarpprobe(void *arg)
sizeof(ea->aarp_tpnet));
ea->aarp_spnode = ea->aarp_tpnode = AA_SAT(aa)->sat_addr.s_node;
} else {
bcopy(ac->ac_if.if_broadcastaddr, (caddr_t)eh->ether_dhost,
bcopy(ifp->if_broadcastaddr, (caddr_t)eh->ether_dhost,
sizeof(eh->ether_dhost));
eh->ether_type = htons(ETHERTYPE_AARP);
ea->aarp_spa = ea->aarp_tpa = AA_SAT(aa)->sat_addr.s_node;
@ -632,7 +629,7 @@ aarpprobe(void *arg)
sa.sa_len = sizeof(struct sockaddr);
sa.sa_family = AF_UNSPEC;
(*ac->ac_if.if_output)(&ac->ac_if, m, &sa, NULL); /* XXX */
(*ifp->if_output)(ifp, m, &sa, NULL); /* XXX */
aa->aa_probcnt--;
}

View File

@ -6,7 +6,7 @@ struct sockaddr_at;
#ifdef _NET_IF_ARP_H_
extern timeout_t aarpprobe;
extern int aarpresolve (struct arpcom *,
extern int aarpresolve (struct ifnet *,
struct mbuf *,
struct sockaddr_at *,
u_char *);

View File

@ -341,21 +341,42 @@ arprequest(ifp, sip, tip, enaddr)
* that desten has been filled in and the packet should be sent
* normally; a 0 return indicates that the packet has been
* taken over here, either now or for later transmission.
*
* NEW COMMENT
* Resolve an IP address into an ethernet address.
* On input:
* ifp is the interface we use
* dst is the next hop,
* rt0 is the route to the final destination (possibly useless)
* m is the mbuf
* desten is where we want the address.
*
* On success, desten is filled in and the function returns 0;
* If the packet must be held pending resolution, we return EWOULDBLOCK
* On other errors, we return the corresponding error code.
*/
int
arpresolve(struct ifnet *ifp, struct rtentry *rt, struct mbuf *m,
arpresolve(struct ifnet *ifp, struct rtentry *rt0, struct mbuf *m,
struct sockaddr *dst, u_char *desten)
{
struct llinfo_arp *la = 0;
struct sockaddr_dl *sdl;
int error;
struct rtentry *rt;
error = rt_check(&rt, &rt0, dst);
if (error) {
m_freem(m);
return error;
}
if (m->m_flags & M_BCAST) { /* broadcast */
(void)memcpy(desten, ifp->if_broadcastaddr, ifp->if_addrlen);
return (1);
return (0);
}
if (m->m_flags & M_MCAST && ifp->if_type != IFT_ARCNET) {/* multicast */
ETHER_MAP_IP_MULTICAST(&SIN(dst)->sin_addr, desten);
return(1);
return (0);
}
if (rt)
la = (struct llinfo_arp *)rt->rt_llinfo;
@ -369,7 +390,7 @@ arpresolve(struct ifnet *ifp, struct rtentry *rt, struct mbuf *m,
inet_ntoa(SIN(dst)->sin_addr), la ? "la" : "",
rt ? "rt" : "");
m_freem(m);
return (0);
return (EINVAL); /* XXX */
}
sdl = SDL(rt->rt_gateway);
/*
@ -393,7 +414,7 @@ arpresolve(struct ifnet *ifp, struct rtentry *rt, struct mbuf *m,
}
bcopy(LLADDR(sdl), desten, sdl->sdl_alen);
return 1;
return (0);
}
/*
* If ARP is disabled or static on this interface, stop.
@ -403,7 +424,7 @@ arpresolve(struct ifnet *ifp, struct rtentry *rt, struct mbuf *m,
*/
if (ifp->if_flags & (IFF_NOARP | IFF_STATICARP)) {
m_freem(m);
return (0);
return (EINVAL);
}
/*
* There is an arptab entry, but no ethernet address
@ -433,7 +454,7 @@ arpresolve(struct ifnet *ifp, struct rtentry *rt, struct mbuf *m,
}
RT_UNLOCK(rt);
}
return (0);
return (EWOULDBLOCK);
}
/*

View File

@ -2032,15 +2032,16 @@ nd6_need_cache(ifp)
}
int
nd6_storelladdr(ifp, rt, m, dst, desten)
nd6_storelladdr(ifp, rt0, m, dst, desten)
struct ifnet *ifp;
struct rtentry *rt;
struct rtentry *rt0;
struct mbuf *m;
struct sockaddr *dst;
u_char *desten;
{
int i;
struct sockaddr_dl *sdl;
struct rtentry *rt;
if (m->m_flags & M_MCAST) {
switch (ifp->if_type) {
@ -2073,26 +2074,32 @@ nd6_storelladdr(ifp, rt, m, dst, desten)
}
}
i = rt_check(&rt, &rt0, dst);
if (i) {
m_freem(m);
return i;
}
if (rt == NULL) {
/* this could happen, if we could not allocate memory */
m_freem(m);
return (0);
return (ENOMEM);
}
if (rt->rt_gateway->sa_family != AF_LINK) {
printf("nd6_storelladdr: something odd happens\n");
m_freem(m);
return (0);
return (EINVAL);
}
sdl = SDL(rt->rt_gateway);
if (sdl->sdl_alen == 0) {
/* this should be impossible, but we bark here for debugging */
printf("nd6_storelladdr: sdl_alen == 0\n");
m_freem(m);
return (0);
return (EINVAL);
}
bcopy(LLADDR(sdl), desten, sdl->sdl_alen);
return (1);
return (0);
}
static int nd6_sysctl_drlist(SYSCTL_HANDLER_ARGS);