summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormaxim <maxim@FreeBSD.org>2002-09-23 08:56:24 +0000
committermaxim <maxim@FreeBSD.org>2002-09-23 08:56:24 +0000
commitf3b0200748c9e28aabdedeaa20d6ff3c4e7f0303 (patch)
treef415067439c00d8d2466d4a40dce8859740eb864
parent11c408b717079057e253544d1fa439ff6c140641 (diff)
downloadFreeBSD-src-f3b0200748c9e28aabdedeaa20d6ff3c4e7f0303.zip
FreeBSD-src-f3b0200748c9e28aabdedeaa20d6ff3c4e7f0303.tar.gz
Slightly rearrange a code in rev. 1.164:
o Move len initialization closer to place of its first usage. o Compare len with 0 to improve readability. o Explicitly zero out phlen in ip_insertoptions() in failure case. Suggested by: jhb Reviewed by: jhb MFC after: 2 weeks
-rw-r--r--sys/netinet/ip_output.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/sys/netinet/ip_output.c b/sys/netinet/ip_output.c
index b4bea16..2c765eb 100644
--- a/sys/netinet/ip_output.c
+++ b/sys/netinet/ip_output.c
@@ -141,7 +141,6 @@ ip_output(m0, opt, ro, flags, imo)
int rv;
#endif /* PFIL_HOOKS */
- len = 0;
args.eh = NULL;
args.rule = NULL;
args.next_hop = NULL;
@@ -199,8 +198,9 @@ ip_output(m0, opt, ro, flags, imo)
}
if (opt) {
+ len = 0;
m = ip_insertoptions(m, opt, &len);
- if (len >= sizeof(struct ip))
+ if (len != 0)
hlen = len;
}
ip = mtod(m, struct ip *);
@@ -1136,14 +1136,18 @@ ip_insertoptions(m, opt, phlen)
unsigned optlen;
optlen = opt->m_len - sizeof(p->ipopt_dst);
- if (optlen + (u_short)ip->ip_len > IP_MAXPACKET)
+ if (optlen + (u_short)ip->ip_len > IP_MAXPACKET) {
+ *phlen = 0;
return (m); /* XXX should fail */
+ }
if (p->ipopt_dst.s_addr)
ip->ip_dst = p->ipopt_dst;
if (m->m_flags & M_EXT || m->m_data - optlen < m->m_pktdat) {
MGETHDR(n, M_DONTWAIT, MT_HEADER);
- if (n == 0)
+ if (n == 0) {
+ *phlen = 0;
return (m);
+ }
n->m_pkthdr.rcvif = (struct ifnet *)0;
#ifdef MAC
mac_create_mbuf_from_mbuf(m, n);
OpenPOWER on IntegriCloud