Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. =================================================================== RCS file: /ftp/cvs/cvsroot/src/sys/netinet/ip_input.c,v rcsdiff: /ftp/cvs/cvsroot/src/sys/netinet/ip_input.c,v: warning: Unknown phrases like `commitid ...;' are present. retrieving revision 1.319.10.2 retrieving revision 1.320 diff -u -p -r1.319.10.2 -r1.320 --- src/sys/netinet/ip_input.c 2019/09/17 18:08:13 1.319.10.2 +++ src/sys/netinet/ip_input.c 2015/03/26 04:05:58 1.320 @@ -1,4 +1,4 @@ -/* $NetBSD: ip_input.c,v 1.319.10.2 2019/09/17 18:08:13 martin Exp $ */ +/* $NetBSD: ip_input.c,v 1.320 2015/03/26 04:05:58 ozaki-r Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -91,7 +91,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ip_input.c,v 1.319.10.2 2019/09/17 18:08:13 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ip_input.c,v 1.320 2015/03/26 04:05:58 ozaki-r Exp $"); #include "opt_inet.h" #include "opt_compat_netbsd.h" @@ -157,10 +157,10 @@ __KERNEL_RCSID(0, "$NetBSD: ip_input.c,v #define IPSENDREDIRECTS 1 #endif #ifndef IPFORWSRCRT -#define IPFORWSRCRT 0 /* forward source-routed packets */ +#define IPFORWSRCRT 1 /* forward source-routed packets */ #endif #ifndef IPALLOWSRCRT -#define IPALLOWSRCRT 0 /* allow source-routed packets */ +#define IPALLOWSRCRT 1 /* allow source-routed packets */ #endif #ifndef IPMTUDISC #define IPMTUDISC 1 @@ -526,25 +526,8 @@ ip_input(struct mbuf *m) if (freed || m == NULL) { return; } - if (__predict_false(m->m_len < sizeof (struct ip))) { - if ((m = m_pullup(m, sizeof (struct ip))) == NULL) { - IP_STATINC(IP_STAT_TOOSMALL); - return; - } - } ip = mtod(m, struct ip *); hlen = ip->ip_hl << 2; - if (hlen < sizeof(struct ip)) { /* minimum header length */ - IP_STATINC(IP_STAT_BADHLEN); - goto bad; - } - if (hlen > m->m_len) { - if ((m = m_pullup(m, hlen)) == NULL) { - IP_STATINC(IP_STAT_BADHLEN); - return; - } - ip = mtod(m, struct ip *); - } /* * XXX The setting of "srcrt" here is to prevent ip_forward() @@ -1206,6 +1189,7 @@ ip_forward(struct mbuf *m, int srcrt) struct sockaddr dst; struct sockaddr_in dst4; } u; + uint64_t *ips; KASSERTMSG(cpu_softintr_p(), "ip_forward: not in the software " "interrupt handler; synchronization assumptions violated"); @@ -1286,27 +1270,34 @@ ip_forward(struct mbuf *m, int srcrt) (IP_FORWARDING | (ip_directedbcast ? IP_ALLOWBROADCAST : 0)), NULL, NULL); - if (error) + if (error) { IP_STATINC(IP_STAT_CANTFORWARD); - else { - uint64_t *ips = IP_STAT_GETREF(); - ips[IP_STAT_FORWARD]++; - if (type) { - ips[IP_STAT_REDIRECTSENT]++; - IP_STAT_PUTREF(); - } else { - IP_STAT_PUTREF(); - if (mcopy) { + goto error; + } + + ips = IP_STAT_GETREF(); + ips[IP_STAT_FORWARD]++; + + if (type) { + ips[IP_STAT_REDIRECTSENT]++; + IP_STAT_PUTREF(); + goto redirect; + } + + IP_STAT_PUTREF(); + if (mcopy) { #ifdef GATEWAY - if (mcopy->m_flags & M_CANFASTFWD) - ipflow_create(&ipforward_rt, mcopy); + if (mcopy->m_flags & M_CANFASTFWD) + ipflow_create(&ipforward_rt, mcopy); #endif - m_freem(mcopy); - } - SOFTNET_UNLOCK(); - return; - } + m_freem(mcopy); } + + SOFTNET_UNLOCK(); + return; + +redirect: +error: if (mcopy == NULL) { SOFTNET_UNLOCK(); return;