summaryrefslogtreecommitdiffstats
path: root/sys/net
diff options
context:
space:
mode:
authorluigi <luigi@FreeBSD.org>2004-04-25 09:24:52 +0000
committerluigi <luigi@FreeBSD.org>2004-04-25 09:24:52 +0000
commit59063f7a089ed07823309dc56641c8a847f21c23 (patch)
treeb64da6798f0d544a1f0a0369b5c8f192b6c31e34 /sys/net
parent6430766c7e3512aa8239ab4ffe30ab8faa9dfe7d (diff)
downloadFreeBSD-src-59063f7a089ed07823309dc56641c8a847f21c23.zip
FreeBSD-src-59063f7a089ed07823309dc56641c8a847f21c23.tar.gz
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)
Diffstat (limited to 'sys/net')
-rw-r--r--sys/net/if_arcsubr.c24
-rw-r--r--sys/net/if_atmsubr.c18
-rw-r--r--sys/net/if_ethersubr.c28
-rw-r--r--sys/net/if_fddisubr.c19
-rw-r--r--sys/net/if_iso88025subr.c15
5 files changed, 43 insertions, 61 deletions
diff --git a/sys/net/if_arcsubr.c b/sys/net/if_arcsubr.c
index 47d7b5c..b4aa519 100644
--- a/sys/net/if_arcsubr.c
+++ b/sys/net/if_arcsubr.c
@@ -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
diff --git a/sys/net/if_atmsubr.c b/sys/net/if_atmsubr.c
index f404984..e7df9c3 100644
--- a/sys/net/if_atmsubr.c
+++ b/sys/net/if_atmsubr.c
@@ -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;
@@ -141,13 +140,6 @@ atm_output(struct ifnet *ifp, struct mbuf *m0, struct sockaddr *dst,
senderr(ENETDOWN);
/*
- * check route
- */
- error = rt_check(&rt, &rt0, dst);
- if (error)
- goto bad;
-
- /*
* check for non-native ATM traffic (dst != NULL)
*/
if (dst) {
@@ -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 */
diff --git a/sys/net/if_ethersubr.c b/sys/net/if_ethersubr.c
index ae59947..47ba291 100644
--- a/sys/net/if_ethersubr.c
+++ b/sys/net/if_ethersubr.c
@@ -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;
diff --git a/sys/net/if_fddisubr.c b/sys/net/if_fddisubr.c
index d9330ee5..47bf0c3 100644
--- a/sys/net/if_fddisubr.c
+++ b/sys/net/if_fddisubr.c
@@ -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
diff --git a/sys/net/if_iso88025subr.c b/sys/net/if_iso88025subr.c
index 72b246f..a34f929 100644
--- a/sys/net/if_iso88025subr.c
+++ b/sys/net/if_iso88025subr.c
@@ -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 */
OpenPOWER on IntegriCloud