Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys arpresolve() now returns 0 on success otherwise an error...



details:   https://anonhg.NetBSD.org/src/rev/fd7b52da0319
branches:  trunk
changeset: 811131:fd7b52da0319
user:      roy <roy%NetBSD.org@localhost>
date:      Tue Oct 13 12:33:07 2015 +0000

description:
arpresolve() now returns 0 on success otherwise an error code.
Callers of arpresolve() now pass the error code back to their caller,
masking out EWOULDBLOCK.

This allows applications such as ping(8) to display a suitable error
condition.

diffstat:

 sys/net/if_arcsubr.c      |   8 ++++----
 sys/net/if_ethersubr.c    |  10 +++++-----
 sys/net/if_fddisubr.c     |   8 ++++----
 sys/net/if_ieee1394subr.c |   9 +++++----
 sys/netinet/if_arp.c      |  26 ++++++++++++++------------
 5 files changed, 32 insertions(+), 29 deletions(-)

diffs (222 lines):

diff -r 102478ab4cc5 -r fd7b52da0319 sys/net/if_arcsubr.c
--- a/sys/net/if_arcsubr.c      Tue Oct 13 12:17:04 2015 +0000
+++ b/sys/net/if_arcsubr.c      Tue Oct 13 12:33:07 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_arcsubr.c,v 1.68 2015/08/24 22:21:26 pooka Exp $    */
+/*     $NetBSD: if_arcsubr.c,v 1.69 2015/10/13 12:33:07 roy Exp $      */
 
 /*
  * Copyright (c) 1994, 1995 Ignatios Souvatzis
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_arcsubr.c,v 1.68 2015/08/24 22:21:26 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_arcsubr.c,v 1.69 2015/10/13 12:33:07 roy Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -151,8 +151,8 @@
                        adst = arcbroadcastaddr; /* ARCnet broadcast address */
                else if (ifp->if_flags & IFF_NOARP)
                        adst = ntohl(satocsin(dst)->sin_addr.s_addr) & 0xFF;
-               else if (!arpresolve(ifp, rt, m, dst, &adst))
-                       return 0;       /* not resolved yet */
+               else if ((error = arpresolve(ifp, rt, m, dst, &adst)) != 0)
+                       return error == EWOULDBLOCK ? 0 : error;
 
                /* If broadcasting on a simplex interface, loopback a copy */
                if ((m->m_flags & (M_BCAST|M_MCAST)) &&
diff -r 102478ab4cc5 -r fd7b52da0319 sys/net/if_ethersubr.c
--- a/sys/net/if_ethersubr.c    Tue Oct 13 12:17:04 2015 +0000
+++ b/sys/net/if_ethersubr.c    Tue Oct 13 12:33:07 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_ethersubr.c,v 1.213 2015/08/31 08:05:20 ozaki-r Exp $       */
+/*     $NetBSD: if_ethersubr.c,v 1.214 2015/10/13 12:33:07 roy Exp $   */
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -61,7 +61,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_ethersubr.c,v 1.213 2015/08/31 08:05:20 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ethersubr.c,v 1.214 2015/10/13 12:33:07 roy Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -242,8 +242,8 @@
                        (void)memcpy(edst, etherbroadcastaddr, sizeof(edst));
                else if (m->m_flags & M_MCAST)
                        ETHER_MAP_IP_MULTICAST(&satocsin(dst)->sin_addr, edst);
-               else if (!arpresolve(ifp, rt, m, dst, edst))
-                       return 0;       /* if not yet resolved */
+               else if ((error = arpresolve(ifp, rt, m, dst, edst)) != 0)
+                       return error == EWOULDBLOCK ? 0 : error;
                /* If broadcasting on a simplex interface, loopback a copy */
                if ((m->m_flags & M_BCAST) && (ifp->if_flags & IFF_SIMPLEX))
                        mcopy = m_copy(m, 0, (int)M_COPYALL);
@@ -291,7 +291,7 @@
 #endif
 #ifdef NETATALK
     case AF_APPLETALK:
-               if (!aarpresolve(ifp, m, (const struct sockaddr_at *)dst, edst)) {
+               if (aarpresolve(ifp, m, (const struct sockaddr_at *)dst, edst)) {
 #ifdef NETATALKDEBUG
                        printf("aarpresolv failed\n");
 #endif /* NETATALKDEBUG */
diff -r 102478ab4cc5 -r fd7b52da0319 sys/net/if_fddisubr.c
--- a/sys/net/if_fddisubr.c     Tue Oct 13 12:17:04 2015 +0000
+++ b/sys/net/if_fddisubr.c     Tue Oct 13 12:33:07 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_fddisubr.c,v 1.94 2015/09/30 06:25:59 ozaki-r Exp $ */
+/*     $NetBSD: if_fddisubr.c,v 1.95 2015/10/13 12:33:07 roy Exp $     */
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -96,7 +96,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_fddisubr.c,v 1.94 2015/09/30 06:25:59 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_fddisubr.c,v 1.95 2015/10/13 12:33:07 roy Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_gateway.h"
@@ -235,8 +235,8 @@
                else if (m->m_flags & M_MCAST) {
                        ETHER_MAP_IP_MULTICAST(&satocsin(dst)->sin_addr,
                            (char *)edst);
-               } else if (!arpresolve(ifp, rt, m, dst, edst))
-                       return (0);     /* if not yet resolved */
+               } else if ((error = arpresolve(ifp, rt, m, dst, edst)) != 0)
+                       return error == EWOULDBLOCK ? 0 : error;
                /* If broadcasting on a simplex interface, loopback a copy */
                if ((m->m_flags & M_BCAST) && (ifp->if_flags & IFF_SIMPLEX))
                        mcopy = m_copy(m, 0, (int)M_COPYALL);
diff -r 102478ab4cc5 -r fd7b52da0319 sys/net/if_ieee1394subr.c
--- a/sys/net/if_ieee1394subr.c Tue Oct 13 12:17:04 2015 +0000
+++ b/sys/net/if_ieee1394subr.c Tue Oct 13 12:33:07 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_ieee1394subr.c,v 1.50 2015/08/24 22:21:26 pooka Exp $       */
+/*     $NetBSD: if_ieee1394subr.c,v 1.51 2015/10/13 12:33:07 roy Exp $ */
 
 /*
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_ieee1394subr.c,v 1.50 2015/08/24 22:21:26 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ieee1394subr.c,v 1.51 2015/10/13 12:33:07 roy Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -138,8 +138,9 @@
        switch (dst->sa_family) {
 #ifdef INET
        case AF_INET:
-               if (unicast && (!arpresolve(ifp, rt, m0, dst, (u_char *)hwdst)))
-                       return 0;       /* if not yet resolved */
+               if (unicast &&
+                   (error = arpresolve(ifp, rt, m0, dst, (u_char *)hwdst)) !=0)
+                       return error == EWOULDBLOCK ? 0 : error;
                /* if broadcasting on a simplex interface, loopback a copy */
                if ((m0->m_flags & M_BCAST) && (ifp->if_flags & IFF_SIMPLEX))
                        mcopy = m_copy(m0, 0, M_COPYALL);
diff -r 102478ab4cc5 -r fd7b52da0319 sys/netinet/if_arp.c
--- a/sys/netinet/if_arp.c      Tue Oct 13 12:17:04 2015 +0000
+++ b/sys/netinet/if_arp.c      Tue Oct 13 12:33:07 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_arp.c,v 1.186 2015/10/13 11:13:37 roy Exp $ */
+/*     $NetBSD: if_arp.c,v 1.187 2015/10/13 12:33:07 roy Exp $ */
 
 /*-
  * Copyright (c) 1998, 2000, 2008 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_arp.c,v 1.186 2015/10/13 11:13:37 roy Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_arp.c,v 1.187 2015/10/13 12:33:07 roy Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ddb.h"
@@ -780,10 +780,11 @@
  * desten is filled in.  If there is no entry in arptab,
  * set one up and broadcast a request for the IP address.
  * Hold onto this mbuf and resend it once the address
- * is finally resolved.  A return value of 1 indicates
+ * is finally resolved.  A return value of 0 indicates
  * 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.
+ * normally; a return value of EWOULDBLOCK indicates that the packet has been
+ * held pending resolution.
+ * Any other value indicates an error.
  */
 int
 arpresolve(struct ifnet *ifp, struct rtentry *rt, struct mbuf *m,
@@ -813,7 +814,7 @@
                    min(sdl->sdl_alen, ifp->if_addrlen));
                rt->rt_pksent = time_uptime; /* Time for last pkt sent */
                LLE_RUNLOCK(la);
-               return 1;
+               return 0;
        }
 
        /*
@@ -838,7 +839,7 @@
                if (la != NULL)
                        LLE_RUNLOCK(la);
                m_freem(m);
-               return 0;
+               return ENOTSUP;
        }
 #undef _IFF_NOARP
        if (la == NULL) {
@@ -862,17 +863,18 @@
                    __func__, create_lookup, inet_ntoa(satocsin(dst)->sin_addr),
                    ifp->if_xname);
                m_freem(m);
-               return 0;
+               return EINVAL;
        }
 
        /* Just in case */
        if (la->la_rt == NULL) {
+               LLE_WUNLOCK(la);
                log(LOG_DEBUG,
                    "%s: valid llentry has no rtentry for %s on %s\n",
                    __func__, inet_ntoa(satocsin(dst)->sin_addr),
                    ifp->if_xname);
                m_freem(m);
-               return 0;
+               return EINVAL;
        }
        rt = la->la_rt;
 
@@ -909,7 +911,7 @@
                            &satocsin(dst)->sin_addr, enaddr);
                }
 
-               return 1;
+               return 0;
        }
 
        if (la->la_flags & LLE_STATIC) {   /* should not happen! */
@@ -977,12 +979,12 @@
 
                arprequest(ifp, &satocsin(rt->rt_ifa->ifa_addr)->sin_addr,
                    &satocsin(dst)->sin_addr, enaddr);
-               return error == 0;
+               return error;
        }
 done:
        LLE_RUNLOCK(la);
 
-       return error == 0;
+       return error;
 }
 
 /*



Home | Main Index | Thread Index | Old Index