invert output path to pass back error indications
authorSam Leffler <sam@ucbvax.Berkeley.EDU>
Sun, 11 Apr 1982 09:27:33 +0000 (01:27 -0800)
committerSam Leffler <sam@ucbvax.Berkeley.EDU>
Sun, 11 Apr 1982 09:27:33 +0000 (01:27 -0800)
SCCS-vsn: sys/vax/if/if_dmc.c 4.10
SCCS-vsn: sys/vax/if/if_en.c 4.54
SCCS-vsn: sys/deprecated/netimp/if_imp.c 4.24
SCCS-vsn: sys/netinet/ip_output.c 1.32
SCCS-vsn: sys/net/raw_usrreq.c 4.12
SCCS-vsn: sys/netinet/tcp_output.c 4.38
SCCS-vsn: sys/netinet/tcp_usrreq.c 1.55
SCCS-vsn: sys/netinet/udp_usrreq.c 4.25

usr/src/sys/deprecated/netimp/if_imp.c
usr/src/sys/net/raw_usrreq.c
usr/src/sys/netinet/ip_output.c
usr/src/sys/netinet/tcp_output.c
usr/src/sys/netinet/tcp_usrreq.c
usr/src/sys/netinet/udp_usrreq.c
usr/src/sys/vax/if/if_dmc.c
usr/src/sys/vax/if/if_en.c

index f7bd66f..9597018 100644 (file)
@@ -1,4 +1,4 @@
-/*     if_imp.c        4.23    82/04/10        */
+/*     if_imp.c        4.24    82/04/10        */
 
 #include "imp.h"
 #if NIMP > 0
 
 #include "imp.h"
 #if NIMP > 0
@@ -31,6 +31,7 @@
 #include "../net/ip.h"
 #include "../net/ip_var.h"
 #include "../net/route.h"
 #include "../net/ip.h"
 #include "../net/ip_var.h"
 #include "../net/route.h"
+#include <errno.h>
 
 /*
  * IMP software status per interface.
 
 /*
  * IMP software status per interface.
@@ -383,13 +384,16 @@ impoutput(ifp, m0, dst)
        register struct imp_leader *imp;
        register struct mbuf *m = m0;
        int x, dhost, dimp, dlink, len, dnet;
        register struct imp_leader *imp;
        register struct mbuf *m = m0;
        int x, dhost, dimp, dlink, len, dnet;
+       int error = 0;
 
 COUNT(IMPOUTPUT);
        /*
         * Don't even try if the IMP is unavailable.
         */
 
 COUNT(IMPOUTPUT);
        /*
         * Don't even try if the IMP is unavailable.
         */
-       if (imp_softc[ifp->if_unit].imp_state != IMPS_UP)
+       if (imp_softc[ifp->if_unit].imp_state != IMPS_UP) {
+               error = ENETDOWN;
                goto drop;
                goto drop;
+       }
 
        switch (dst->sa_family) {
 
 
        switch (dst->sa_family) {
 
@@ -412,6 +416,7 @@ COUNT(IMPOUTPUT);
        default:
                printf("imp%d: can't handle af%d\n", ifp->if_unit, 
                        dst->sa_family);
        default:
                printf("imp%d: can't handle af%d\n", ifp->if_unit, 
                        dst->sa_family);
+               error = EAFNOSUPPORT;
                goto drop;
        }
 
                goto drop;
        }
 
@@ -423,8 +428,10 @@ COUNT(IMPOUTPUT);
        if (m->m_off > MMAXOFF ||
            MMINOFF + sizeof(struct imp_leader) > m->m_off) {
                m = m_get(M_DONTWAIT);
        if (m->m_off > MMAXOFF ||
            MMINOFF + sizeof(struct imp_leader) > m->m_off) {
                m = m_get(M_DONTWAIT);
-               if (m == 0)
+               if (m == 0) {
+                       error = ENOBUFS;
                        goto drop;
                        goto drop;
+               }
                m->m_next = m0;
                m->m_off = MMINOFF;
                m->m_len = sizeof(struct imp_leader);
                m->m_next = m0;
                m->m_off = MMINOFF;
                m->m_len = sizeof(struct imp_leader);
@@ -451,7 +458,7 @@ leaderexists:
        return (impsnd(ifp, m));
 drop:
        m_freem(m0);
        return (impsnd(ifp, m));
 drop:
        m_freem(m0);
-       return (0);
+       return (error);
 }
 
 /* 
 }
 
 /* 
@@ -504,14 +511,14 @@ COUNT(IMPSND);
                }
                m_freem(m);
                splx(x);
                }
                m_freem(m);
                splx(x);
-               return (0);
+               return (ENOBUFS);       /* XXX */
        }
 enque:
        if (IF_QFULL(&ifp->if_snd)) {
                IF_DROP(&ifp->if_snd);
                m_freem(m);
                splx(x);
        }
 enque:
        if (IF_QFULL(&ifp->if_snd)) {
                IF_DROP(&ifp->if_snd);
                m_freem(m);
                splx(x);
-               return (0);
+               return (ENOBUFS);       /* XXX */
        }
        IF_ENQUEUE(&ifp->if_snd, m);
 start:
        }
        IF_ENQUEUE(&ifp->if_snd, m);
 start:
@@ -519,7 +526,7 @@ start:
        icp = &imp_softc[ifp->if_unit].imp_cb;
        if (icp->ic_oactive == 0)
                (*icp->ic_start)(ifp->if_unit);
        icp = &imp_softc[ifp->if_unit].imp_cb;
        if (icp->ic_oactive == 0)
                (*icp->ic_start)(ifp->if_unit);
-       return (1);
+       return (0);
 }
 
 /*
 }
 
 /*
index aee828e..c3cc019 100644 (file)
@@ -1,4 +1,4 @@
-/*     raw_usrreq.c    4.11    82/03/19        */
+/*     raw_usrreq.c    4.12    82/04/10        */
 
 #include "../h/param.h"
 #include "../h/mbuf.h"
 
 #include "../h/param.h"
 #include "../h/mbuf.h"
@@ -242,7 +242,7 @@ COUNT(RAW_USRREQ);
                        raw_connaddr(rp, (struct sockaddr *)addr);
                } else if ((rp->rcb_flags & RAW_ADDR) == 0)
                        return (ENOTCONN);
                        raw_connaddr(rp, (struct sockaddr *)addr);
                } else if ((rp->rcb_flags & RAW_ADDR) == 0)
                        return (ENOTCONN);
-               (void) (*so->so_proto->pr_output)(m, so);
+               error = (*so->so_proto->pr_output)(m, so);
                if (addr)
                        rp->rcb_flags &= ~RAW_ADDR;
                break;
                if (addr)
                        rp->rcb_flags &= ~RAW_ADDR;
                break;
index 26e041a..fb2d21d 100644 (file)
@@ -1,4 +1,4 @@
-/*     ip_output.c     1.31    82/03/31        */
+/*     ip_output.c     1.32    82/04/10        */
 
 #include "../h/param.h"
 #include "../h/mbuf.h"
 
 #include "../h/param.h"
 #include "../h/mbuf.h"
@@ -11,6 +11,7 @@
 #include "../net/ip.h"
 #include "../net/ip_var.h"
 #include "../net/route.h"
 #include "../net/ip.h"
 #include "../net/ip_var.h"
 #include "../net/route.h"
+#include <errno.h>
 
 ip_output(m, opt, ro, allowbroadcast)
        struct mbuf *m;
 
 ip_output(m, opt, ro, allowbroadcast)
        struct mbuf *m;
@@ -20,7 +21,7 @@ ip_output(m, opt, ro, allowbroadcast)
 {
        register struct ip *ip = mtod(m, struct ip *);
        register struct ifnet *ifp;
 {
        register struct ip *ip = mtod(m, struct ip *);
        register struct ifnet *ifp;
-       int len, hlen = sizeof (struct ip), off;
+       int len, hlen = sizeof (struct ip), off, error = 0;
        struct route iproute;
        struct sockaddr *dst;
 
        struct route iproute;
        struct sockaddr *dst;
 
@@ -51,11 +52,15 @@ COUNT(IP_OUTPUT);
                rtalloc(ro);
        }
        if (ro->ro_rt == 0 || (ifp = ro->ro_rt->rt_ifp) == 0) {
                rtalloc(ro);
        }
        if (ro->ro_rt == 0 || (ifp = ro->ro_rt->rt_ifp) == 0) {
-               printf("no route to %x (from %x, len %d)\n",
-                   ip->ip_dst.s_addr, ip->ip_src.s_addr, ip->ip_len);
+               extern int ipprintfs;
+
+               if (ipprintfs)
+                       printf("no route to %x (from %x, len %d)\n",
+                           ip->ip_dst.s_addr, ip->ip_src.s_addr, ip->ip_len);
+               error = ENETUNREACH;
                goto bad;
        }
                goto bad;
        }
-       dst = ro->ro_rt->rt_flags&RTF_DIRECT ?
+       dst = ro->ro_rt->rt_flags & RTF_DIRECT ?
            (struct sockaddr *)&ro->ro_dst : &ro->ro_rt->rt_gateway;
        if (ro == &iproute)
                RTFREE(ro->ro_rt);
            (struct sockaddr *)&ro->ro_dst : &ro->ro_rt->rt_gateway;
        if (ro == &iproute)
                RTFREE(ro->ro_rt);
@@ -63,8 +68,10 @@ COUNT(IP_OUTPUT);
                struct sockaddr_in *sin;
 
                sin = (struct sockaddr_in *)&ifp->if_broadaddr;
                struct sockaddr_in *sin;
 
                sin = (struct sockaddr_in *)&ifp->if_broadaddr;
-               if (sin->sin_addr.s_addr == ip->ip_dst.s_addr)
+               if (sin->sin_addr.s_addr == ip->ip_dst.s_addr) {
+                       error = EPERM;          /* ??? */
                        goto bad;
                        goto bad;
+               }
        }
 
        /*
        }
 
        /*
@@ -85,11 +92,15 @@ COUNT(IP_OUTPUT);
         * Too large for interface; fragment if possible.
         * Must be able to put at least 8 bytes per fragment.
         */
         * Too large for interface; fragment if possible.
         * Must be able to put at least 8 bytes per fragment.
         */
-       if (ip->ip_off & IP_DF)
+       if (ip->ip_off & IP_DF) {
+               error = EMSGSIZE;
                goto bad;
                goto bad;
+       }
        len = (ifp->if_mtu - hlen) &~ 7;
        len = (ifp->if_mtu - hlen) &~ 7;
-       if (len < 8)
+       if (len < 8) {
+               error = EMSGSIZE;
                goto bad;
                goto bad;
+       }
 
        /*
         * Discard IP header from logical mbuf for m_copy's sake.
 
        /*
         * Discard IP header from logical mbuf for m_copy's sake.
@@ -102,8 +113,10 @@ COUNT(IP_OUTPUT);
                struct mbuf *mh = m_get(M_DONTWAIT);
                struct ip *mhip;
 
                struct mbuf *mh = m_get(M_DONTWAIT);
                struct ip *mhip;
 
-               if (mh == 0)
+               if (mh == 0) {
+                       error = ENOBUFS;
                        goto bad;
                        goto bad;
+               }
                mh->m_off = MMAXOFF - hlen;
                mhip = mtod(mh, struct ip *);
                *mhip = *ip;
                mh->m_off = MMAXOFF - hlen;
                mhip = mtod(mh, struct ip *);
                *mhip = *ip;
@@ -126,6 +139,7 @@ COUNT(IP_OUTPUT);
                mh->m_next = m_copy(m, off, len);
                if (mh->m_next == 0) {
                        (void) m_free(mh);
                mh->m_next = m_copy(m, off, len);
                if (mh->m_next == 0) {
                        (void) m_free(mh);
+                       error = ENOBUFS;        /* ??? */
                        goto bad;
                }
 #if vax
                        goto bad;
                }
 #if vax
@@ -134,14 +148,12 @@ COUNT(IP_OUTPUT);
                mhip->ip_sum = 0;
                mhip->ip_sum = in_cksum(mh, hlen);
                ro->ro_rt->rt_use++;
                mhip->ip_sum = 0;
                mhip->ip_sum = in_cksum(mh, hlen);
                ro->ro_rt->rt_use++;
-               if ((*ifp->if_output)(ifp, mh, dst) == 0)
-                       goto bad;
+               if (error = (*ifp->if_output)(ifp, mh, dst))
+                       break;
        }
        }
-       m_freem(m);
-       return (1);
 bad:
        m_freem(m);
 bad:
        m_freem(m);
-       return (0);
+       return (error);
 }
 
 /*
 }
 
 /*
index 9b3825a..b2f99e0 100644 (file)
@@ -1,4 +1,4 @@
-/*     tcp_output.c    4.37    82/03/29        */
+/*     tcp_output.c    4.38    82/04/10        */
 
 #include "../h/param.h"
 #include "../h/systm.h"
 
 #include "../h/param.h"
 #include "../h/systm.h"
@@ -20,7 +20,7 @@
 #include "../net/tcp_var.h"
 #include "../net/tcpip.h"
 #include "../net/tcp_debug.h"
 #include "../net/tcp_var.h"
 #include "../net/tcpip.h"
 #include "../net/tcp_debug.h"
-#include "../errno.h"
+#include <errno.h>
 
 char *tcpstates[]; /* XXX */
 
 
 char *tcpstates[]; /* XXX */
 
@@ -44,7 +44,7 @@ tcp_output(tp)
        register struct socket *so = tp->t_inpcb->inp_socket;
        register int len;
        struct mbuf *m0;
        register struct socket *so = tp->t_inpcb->inp_socket;
        register int len;
        struct mbuf *m0;
-       int off, flags, win;
+       int off, flags, win, error;
        register struct mbuf *m;
        register struct tcpiphdr *ti;
        u_char *opt;
        register struct mbuf *m;
        register struct tcpiphdr *ti;
        u_char *opt;
@@ -61,7 +61,7 @@ COUNT(TCP_OUTPUT);
        off = tp->snd_nxt - tp->snd_una;
        len = MIN(so->so_snd.sb_cc, tp->snd_wnd+tp->t_force) - off;
        if (len < 0)
        off = tp->snd_nxt - tp->snd_una;
        len = MIN(so->so_snd.sb_cc, tp->snd_wnd+tp->t_force) - off;
        if (len < 0)
-               return (0);                     /* past FIN */
+               return (0);     /* ??? */       /* past FIN */
        if (len > tp->t_maxseg)
                len = tp->t_maxseg;
 
        if (len > tp->t_maxseg)
                len = tp->t_maxseg;
 
@@ -125,7 +125,7 @@ send:
         */
        MGET(m, 0);
        if (m == 0)
         */
        MGET(m, 0);
        if (m == 0)
-               return (0);
+               return (ENOBUFS);
        m->m_off = MMAXOFF - sizeof (struct tcpiphdr);
        m->m_len = sizeof (struct tcpiphdr);
        if (len) {
        m->m_off = MMAXOFF - sizeof (struct tcpiphdr);
        m->m_len = sizeof (struct tcpiphdr);
        if (len) {
@@ -178,7 +178,7 @@ send:
                if (m->m_next == 0) {
                        (void) m_free(m);
                        m_freem(m0);
                if (m->m_next == 0) {
                        (void) m_free(m);
                        m_freem(m0);
-                       return (0);
+                       return (ENOBUFS);
                }
                m->m_next->m_next = m0;
                m0 = m->m_next;
                }
                m->m_next->m_next = m0;
                m0 = m->m_next;
@@ -309,8 +309,8 @@ noopt:
         */
        ((struct ip *)ti)->ip_len = sizeof (struct tcpiphdr) + optlen + len;
        ((struct ip *)ti)->ip_ttl = TCP_TTL;
         */
        ((struct ip *)ti)->ip_len = sizeof (struct tcpiphdr) + optlen + len;
        ((struct ip *)ti)->ip_ttl = TCP_TTL;
-       if (ip_output(m, tp->t_ipopt, &tp->t_inpcb->inp_route, 0) == 0)
-               return (0);
+       if (error = ip_output(m, tp->t_ipopt, &tp->t_inpcb->inp_route, 0))
+               return (error);
 
        /*
         * Data sent (as far as we can tell).
 
        /*
         * Data sent (as far as we can tell).
@@ -323,5 +323,5 @@ noopt:
        tp->t_flags &= ~(TF_ACKNOW|TF_DELACK);
        if (SEQ_GT(tp->snd_nxt, tp->snd_max))
                tp->snd_max = tp->snd_nxt;
        tp->t_flags &= ~(TF_ACKNOW|TF_DELACK);
        if (SEQ_GT(tp->snd_nxt, tp->snd_max))
                tp->snd_max = tp->snd_nxt;
-       return (1);
+       return (0);
 }
 }
index fa02559..b471a42 100644 (file)
@@ -1,4 +1,4 @@
-/* tcp_usrreq.c 1.54 82/03/29 */
+/*     tcp_usrreq.c    1.55    82/04/10        */
 
 #include "../h/param.h"
 #include "../h/systm.h"
 
 #include "../h/param.h"
 #include "../h/systm.h"
@@ -20,7 +20,7 @@
 #include "../net/tcp_var.h"
 #include "../net/tcpip.h"
 #include "../net/tcp_debug.h"
 #include "../net/tcp_var.h"
 #include "../net/tcpip.h"
 #include "../net/tcp_debug.h"
-#include "../errno.h"
+#include <errno.h>
 
 /*
  * TCP protocol interface to socket abstraction.
 
 /*
  * TCP protocol interface to socket abstraction.
@@ -131,7 +131,7 @@ COUNT(TCP_USRREQ);
                tp->t_timer[TCPT_KEEP] = TCPTV_KEEP;
                tp->iss = tcp_iss; tcp_iss += TCP_ISSINCR/2;
                tcp_sendseqinit(tp);
                tp->t_timer[TCPT_KEEP] = TCPTV_KEEP;
                tp->iss = tcp_iss; tcp_iss += TCP_ISSINCR/2;
                tcp_sendseqinit(tp);
-               (void) tcp_output(tp);
+               error = tcp_output(tp);
                break;
 
        /*
                break;
 
        /*
@@ -172,7 +172,7 @@ COUNT(TCP_USRREQ);
        case PRU_SHUTDOWN:
                socantsendmore(so);
                tcp_usrclosed(tp);
        case PRU_SHUTDOWN:
                socantsendmore(so);
                tcp_usrclosed(tp);
-               (void) tcp_output(tp);
+               error = tcp_output(tp);
                break;
 
        /*
                break;
 
        /*
@@ -188,11 +188,11 @@ COUNT(TCP_USRREQ);
         */
        case PRU_SEND:
                sbappend(&so->so_snd, m);
         */
        case PRU_SEND:
                sbappend(&so->so_snd, m);
-/*
+#ifdef notdef
                if (tp->t_flags & TF_PUSH)
                        tp->snd_end = tp->snd_una + so->so_snd.sb_cc;
                if (tp->t_flags & TF_PUSH)
                        tp->snd_end = tp->snd_una + so->so_snd.sb_cc;
- */
-               (void) tcp_output(tp);
+#endif
+               error = tcp_output(tp);
                break;
 
        /*
                break;
 
        /*
@@ -233,7 +233,9 @@ COUNT(TCP_USRREQ);
                        tp->t_oobmark = tp->snd_una + so->so_snd.sb_cc;
 printf("sendoob seq now %x oobc %x\n", tp->t_oobseq, tp->t_oobc);
                        tp->t_oobflags |= TCPOOB_NEEDACK;
                        tp->t_oobmark = tp->snd_una + so->so_snd.sb_cc;
 printf("sendoob seq now %x oobc %x\n", tp->t_oobseq, tp->t_oobc);
                        tp->t_oobflags |= TCPOOB_NEEDACK;
-                       (void) tcp_output(tp);
+                       /* what to do ...? */
+                       if (error = tcp_output(tp))
+                               break;
                }
 #endif
                if (sbspace(&so->so_snd) < -512) {
                }
 #endif
                if (sbspace(&so->so_snd) < -512) {
@@ -242,12 +244,12 @@ printf("sendoob seq now %x oobc %x\n", tp->t_oobseq, tp->t_oobc);
                }
                tp->snd_up = tp->snd_una + so->so_snd.sb_cc + 1;
                sbappend(&so->so_snd, m);
                }
                tp->snd_up = tp->snd_una + so->so_snd.sb_cc + 1;
                sbappend(&so->so_snd, m);
-/*
+#ifdef notdef
                if (tp->t_flags & TF_PUSH)
                        tp->snd_end = tp->snd_una + so->so_snd.sb_cc;
                if (tp->t_flags & TF_PUSH)
                        tp->snd_end = tp->snd_una + so->so_snd.sb_cc;
- */
+#endif
                tp->t_force = 1;
                tp->t_force = 1;
-               (void) tcp_output(tp);
+               error = tcp_output(tp);
                tp->t_force = 0;
                break;
 
                tp->t_force = 0;
                break;
 
index 92cd487..baad4d3 100644 (file)
@@ -1,4 +1,4 @@
-/*     udp_usrreq.c    4.24    82/03/29        */
+/*     udp_usrreq.c    4.25    82/04/10        */
 
 #include "../h/param.h"
 #include "../h/dir.h"
 
 #include "../h/param.h"
 #include "../h/dir.h"
@@ -15,6 +15,7 @@
 #include "../net/ip_var.h"
 #include "../net/udp.h"
 #include "../net/udp_var.h"
 #include "../net/ip_var.h"
 #include "../net/udp.h"
 #include "../net/udp_var.h"
+#include <errno.h>
 
 /*
  * UDP protocol implementation.
 
 /*
  * UDP protocol implementation.
@@ -132,8 +133,10 @@ COUNT(UDP_OUTPUT);
        for (m = m0; m; m = m->m_next)
                len += m->m_len;
        m = m_get(M_DONTWAIT);
        for (m = m0; m; m = m->m_next)
                len += m->m_len;
        m = m_get(M_DONTWAIT);
-       if (m == 0)
-               goto bad;
+       if (m == 0) {
+               m_freem(m0);
+               return (ENOBUFS);
+       }
 
        /*
         * Fill in mbuf with extended UDP header
 
        /*
         * Fill in mbuf with extended UDP header
@@ -160,11 +163,8 @@ COUNT(UDP_OUTPUT);
        ui->ui_sum = in_cksum(m, sizeof (struct udpiphdr) + len);
        ((struct ip *)ui)->ip_len = sizeof (struct udpiphdr) + len;
        ((struct ip *)ui)->ip_ttl = MAXTTL;
        ui->ui_sum = in_cksum(m, sizeof (struct udpiphdr) + len);
        ((struct ip *)ui)->ip_len = sizeof (struct udpiphdr) + len;
        ((struct ip *)ui)->ip_ttl = MAXTTL;
-       (void) ip_output(m, (struct mbuf *)0, 0,
-           inp->inp_socket->so_state & SS_PRIV);
-       return;
-bad:
-       m_freem(m);
+       return (ip_output(m, (struct mbuf *)0, 0,
+           inp->inp_socket->so_state & SS_PRIV));
 }
 
 udp_usrreq(so, req, m, addr)
 }
 
 udp_usrreq(so, req, m, addr)
@@ -174,7 +174,7 @@ udp_usrreq(so, req, m, addr)
        caddr_t addr;
 {
        struct inpcb *inp = sotoinpcb(so);
        caddr_t addr;
 {
        struct inpcb *inp = sotoinpcb(so);
-       int error;
+       int error = 0;
 
 COUNT(UDP_USRREQ);
        if (inp == 0 && req != PRU_ATTACH)
 
 COUNT(UDP_USRREQ);
        if (inp == 0 && req != PRU_ATTACH)
@@ -184,9 +184,8 @@ COUNT(UDP_USRREQ);
        case PRU_ATTACH:
                if (inp != 0)
                        return (EINVAL);
        case PRU_ATTACH:
                if (inp != 0)
                        return (EINVAL);
-               error = in_pcbattach(so, &udb, 2048, 2048, (struct sockaddr_in *)addr);
-               if (error)
-                       return (error);
+               error = in_pcbattach(so, &udb, 2048, 2048,
+                               (struct sockaddr_in *)addr);
                break;
 
        case PRU_DETACH:
                break;
 
        case PRU_DETACH:
@@ -199,9 +198,8 @@ COUNT(UDP_USRREQ);
                if (inp->inp_faddr.s_addr)
                        return (EISCONN);
                error = in_pcbconnect(inp, (struct sockaddr_in *)addr);
                if (inp->inp_faddr.s_addr)
                        return (EISCONN);
                error = in_pcbconnect(inp, (struct sockaddr_in *)addr);
-               if (error)
-                       return (error);
-               soisconnected(so);
+               if (error == 0)
+                       soisconnected(so);
                break;
 
        case PRU_ACCEPT:
                break;
 
        case PRU_ACCEPT:
@@ -227,12 +225,12 @@ COUNT(UDP_USRREQ);
                                return (EISCONN);
                        error = in_pcbconnect(inp, (struct sockaddr_in *)addr);
                        if (error)
                                return (EISCONN);
                        error = in_pcbconnect(inp, (struct sockaddr_in *)addr);
                        if (error)
-                               return (error);
+                               break;
                } else {
                        if (inp->inp_faddr.s_addr == 0)
                                return (ENOTCONN);
                }
                } else {
                        if (inp->inp_faddr.s_addr == 0)
                                return (ENOTCONN);
                }
-               udp_output(inp, m);
+               error = udp_output(inp, m);
                if (addr) {
                        in_pcbdisconnect(inp);
                        inp->inp_laddr = laddr;
                if (addr) {
                        in_pcbdisconnect(inp);
                        inp->inp_laddr = laddr;
@@ -253,5 +251,5 @@ COUNT(UDP_USRREQ);
        default:
                panic("udp_usrreq");
        }
        default:
                panic("udp_usrreq");
        }
-       return (0);
+       return (error);
 }
 }
index 8984dc9..c9b497f 100644 (file)
@@ -1,4 +1,4 @@
-/*     if_dmc.c        4.9     82/03/30        */
+/*     if_dmc.c        4.10    82/04/10        */
 
 #include "dmc.h"
 #if NDMC > 0
 
 #include "dmc.h"
 #if NDMC > 0
@@ -32,6 +32,7 @@ int dmcdebug = 1;
 #include "../net/ip.h"
 #include "../net/ip_var.h"
 #include "../net/route.h"
 #include "../net/ip.h"
 #include "../net/ip_var.h"
 #include "../net/route.h"
+#include <errno.h>
 
 /*
  * Driver information for auto-configuration stuff.
 
 /*
  * Driver information for auto-configuration stuff.
@@ -412,18 +413,18 @@ COUNT(DMCOUTPUT);
        if (dst->sa_family != (ui->ui_flags & DMC_AF)) {
                printf("dmc%d: af%d not supported\n", ifp->if_unit, pf);
                m_freem(m);
        if (dst->sa_family != (ui->ui_flags & DMC_AF)) {
                printf("dmc%d: af%d not supported\n", ifp->if_unit, pf);
                m_freem(m);
-               return (0);
+               return (EAFNOSUPPORT);
        }
        s = splimp();
        if (IF_QFULL(&ifp->if_snd)) {
                IF_DROP(&ifp->if_snd);
                m_freem(m);
                splx(s);
        }
        s = splimp();
        if (IF_QFULL(&ifp->if_snd)) {
                IF_DROP(&ifp->if_snd);
                m_freem(m);
                splx(s);
-               return (0);
+               return (ENOBUFS);
        }
        IF_ENQUEUE(&ifp->if_snd, m);
        if (dmc_softc[ifp->if_unit].sc_oactive == 0)
                dmcstart(ifp->if_unit);
        splx(s);
        }
        IF_ENQUEUE(&ifp->if_snd, m);
        if (dmc_softc[ifp->if_unit].sc_oactive == 0)
                dmcstart(ifp->if_unit);
        splx(s);
-       return (1);
+       return (0);
 }
 }
index 0d40f58..37f267a 100644 (file)
@@ -1,4 +1,4 @@
-/*     if_en.c 4.53    82/04/07        */
+/*     if_en.c 4.54    82/04/10        */
 
 #include "en.h"
 #include "imp.h"
 
 #include "en.h"
 #include "imp.h"
@@ -29,6 +29,7 @@
 #include "../net/ip_var.h"
 #include "../net/pup.h"
 #include "../net/route.h"
 #include "../net/ip_var.h"
 #include "../net/pup.h"
 #include "../net/route.h"
+#include <errno.h>
 
 #define        ENMTU   (1024+512)
 
 
 #define        ENMTU   (1024+512)
 
@@ -453,7 +454,7 @@ enoutput(ifp, m0, dst)
        struct mbuf *m0;
        struct sockaddr *dst;
 {
        struct mbuf *m0;
        struct sockaddr *dst;
 {
-       int type, dest, s;
+       int type, dest, s, error;
        register struct mbuf *m = m0;
        register struct en_header *en;
        register int off;
        register struct mbuf *m = m0;
        register struct en_header *en;
        register int off;
@@ -464,8 +465,10 @@ COUNT(ENOUTPUT);
 #ifdef INET
        case AF_INET:
                dest = ((struct sockaddr_in *)dst)->sin_addr.s_addr;
 #ifdef INET
        case AF_INET:
                dest = ((struct sockaddr_in *)dst)->sin_addr.s_addr;
-               if (dest & 0x00ffff00)
+               if (dest & 0x00ffff00) {
+                       error = EPERM;          /* ??? */
                        goto bad;
                        goto bad;
+               }
                dest = (dest >> 24) & 0xff;
                off = ntohs((u_short)mtod(m, struct ip *)->ip_len) - m->m_len;
                if (off > 0 && (off & 0x1ff) == 0 &&
                dest = (dest >> 24) & 0xff;
                off = ntohs((u_short)mtod(m, struct ip *)->ip_len) - m->m_len;
                if (off > 0 && (off & 0x1ff) == 0 &&
@@ -492,8 +495,8 @@ COUNT(ENOUTPUT);
        default:
                printf("en%d: can't handle af%d\n", ifp->if_unit,
                        dst->sa_family);
        default:
                printf("en%d: can't handle af%d\n", ifp->if_unit,
                        dst->sa_family);
-               m_freem(m0);
-               return (0);
+               error = EAFNOSUPPORT;
+               goto bad;
        }
 
 gottrailertype:
        }
 
 gottrailertype:
@@ -517,8 +520,8 @@ gottype:
            MMINOFF + sizeof (struct en_header) > m->m_off) {
                m = m_get(M_DONTWAIT);
                if (m == 0) {
            MMINOFF + sizeof (struct en_header) > m->m_off) {
                m = m_get(M_DONTWAIT);
                if (m == 0) {
-                       m_freem(m0);
-                       return (0);
+                       error = ENOBUFS;
+                       goto bad;
                }
                m->m_next = m0;
                m->m_off = MMINOFF;
                }
                m->m_next = m0;
                m->m_off = MMINOFF;
@@ -539,17 +542,20 @@ gottype:
        s = splimp();
        if (IF_QFULL(&ifp->if_snd)) {
                IF_DROP(&ifp->if_snd);
        s = splimp();
        if (IF_QFULL(&ifp->if_snd)) {
                IF_DROP(&ifp->if_snd);
-               goto bad;
+               error = ENOBUFS;
+               goto qfull;
        }
        IF_ENQUEUE(&ifp->if_snd, m);
        if (en_softc[ifp->if_unit].es_oactive == 0)
                enstart(ifp->if_unit);
        splx(s);
        }
        IF_ENQUEUE(&ifp->if_snd, m);
        if (en_softc[ifp->if_unit].es_oactive == 0)
                enstart(ifp->if_unit);
        splx(s);
-       return (1);
-bad:
-       m_freem(m);
-       splx(s);
        return (0);
        return (0);
+qfull:
+       m0 = m;
+       splx(s);
+bad:
+       m_freem(m0);
+       return (error);
 }
 
 #if NIMP == 0 && NEN > 0
 }
 
 #if NIMP == 0 && NEN > 0