projects
/
unix-history
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
tags
|
clone url
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fix per Jeffrey Jongeward
[unix-history]
/
usr
/
src
/
sys
/
netinet
/
ip_output.c
diff --git
a/usr/src/sys/netinet/ip_output.c
b/usr/src/sys/netinet/ip_output.c
index
25e3692
..
fb2d21d
100644
(file)
--- a/
usr/src/sys/netinet/ip_output.c
+++ b/
usr/src/sys/netinet/ip_output.c
@@
-1,4
+1,4
@@
-/* ip_output.c 1.
29 82/03/3
0 */
+/* ip_output.c 1.
32 82/04/1
0 */
#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;
@@
-38,8
+39,8
@@
COUNT(IP_OUTPUT);
/*
* Find interface for this packet in the routing
* table. Note each interface has placed itself
/*
* Find interface for this packet in the routing
* table. Note each interface has placed itself
- * in there at boot time, so call
on route degenerates
- * to if_ifonnetof(ip->ip_dst.s_net).
+ * in there at boot time, so call
s to rtalloc
+ *
degenerate
to if_ifonnetof(ip->ip_dst.s_net).
*/
if (ro == 0) {
ro = &iproute;
*/
if (ro == 0) {
ro = &iproute;
@@
-51,17
+52,26
@@
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\n", ip->ip_dst.s_addr);
+ 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;
(struct sockaddr *)&ro->ro_dst : &ro->ro_rt->rt_gateway;
+ if (ro == &iproute)
+ RTFREE(ro->ro_rt);
if (!allowbroadcast && (ifp->if_flags & IFF_BROADCAST)) {
struct sockaddr_in *sin;
sin = (struct sockaddr_in *)&ifp->if_broadaddr;
if (!allowbroadcast && (ifp->if_flags & IFF_BROADCAST)) {
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;
+ }
}
/*
}
/*
@@
-74,6
+84,7
@@
printf("no route to %x\n", ip->ip_dst.s_addr);
#endif
ip->ip_sum = 0;
ip->ip_sum = in_cksum(m, hlen);
#endif
ip->ip_sum = 0;
ip->ip_sum = in_cksum(m, hlen);
+ ro->ro_rt->rt_use++;
return ((*ifp->if_output)(ifp, m, dst));
}
return ((*ifp->if_output)(ifp, m, dst));
}
@@
-81,11
+92,15
@@
printf("no route to %x\n", ip->ip_dst.s_addr);
* 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.
@@
-98,8
+113,10
@@
printf("no route to %x\n", ip->ip_dst.s_addr);
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;
@@
-122,6
+139,7
@@
printf("no route to %x\n", ip->ip_dst.s_addr);
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
@@
-129,14
+147,13
@@
printf("no route to %x\n", ip->ip_dst.s_addr);
#endif
mhip->ip_sum = 0;
mhip->ip_sum = in_cksum(mh, hlen);
#endif
mhip->ip_sum = 0;
mhip->ip_sum = in_cksum(mh, hlen);
- if ((*ifp->if_output)(ifp, mh, dst) == 0)
- goto bad;
+ ro->ro_rt->rt_use++;
+ 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
);
}
/*
}
/*