Bring back some slight cleanups from 2.2

This commit is contained in:
Julian Elischer 1998-07-06 09:06:58 +00:00
parent e37a54892b
commit efe39c6a1a
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=37433
2 changed files with 21 additions and 6 deletions

View File

@ -30,7 +30,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: ip_divert.c,v 1.32 1998/07/02 05:49:07 julian Exp $
* $Id: ip_divert.c,v 1.33 1998/07/02 06:31:25 julian Exp $
*/
#include "opt_inet.h"
@ -156,7 +156,7 @@ div_input(struct mbuf *m, int hlen)
}
ip = mtod(m, struct ip *);
/* Record divert port */
/* Record divert cookie */
divsrc.sin_port = ip_divert_cookie;
ip_divert_cookie = 0;
@ -165,7 +165,10 @@ div_input(struct mbuf *m, int hlen)
HTONS(ip->ip_len);
HTONS(ip->ip_off);
/* Record receive interface address, if any */
/*
* Record receive interface address, if any
* But only for incoming packets.
*/
divsrc.sin_addr.s_addr = 0;
if (hlen) {
struct ifaddr *ifa;
@ -191,6 +194,9 @@ div_input(struct mbuf *m, int hlen)
break;
}
}
/*
* Record the incoming interface name whenever we have one.
*/
if (m->m_pkthdr.rcvif) {
char name[32];
/*
@ -222,6 +228,7 @@ div_input(struct mbuf *m, int hlen)
if (inp->inp_lport == htons(ip_divert_port))
sa = inp->inp_socket;
}
ip_divert_port = 0;
if (sa) {
if (sbappendaddr(&sa->so_rcv, (struct sockaddr *)&divsrc,
m, (struct mbuf *)0) == 0)
@ -261,6 +268,7 @@ div_output(so, m, addr, control)
if (sin) {
int len = 0;
char *c = sin->sin_zero;
ip_divert_cookie = sin->sin_port;
/*

View File

@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)ip_input.c 8.2 (Berkeley) 1/4/94
* $Id: ip_input.c,v 1.92 1998/07/06 03:20:16 julian Exp $
* $Id: ip_input.c,v 1.93 1998/07/06 05:00:52 julian Exp $
* $ANA: ip_input.c,v 1.5 1996/09/18 14:34:59 wollman Exp $
*/
@ -607,6 +607,8 @@ found:
#ifdef IPDIVERT
/*
* Divert reassembled packets to the divert protocol if required
* If divert port is null then cookie should be too,
* so we shouldn't need to clear them here. Assume ip_divert does so.
*/
if (frag_divert_port) {
ipstat.ips_delivered++;
@ -736,7 +738,8 @@ ip_reass(ip, fp, where)
* While we overlap succeeding segments trim them or,
* if they are completely covered, dequeue them.
*/
while (q != (struct ipasfrag *)fp && ip->ip_off + ip->ip_len > q->ip_off) {
while (q != (struct ipasfrag *)fp &&
ip->ip_off + ip->ip_len > q->ip_off) {
struct mbuf *m0;
i = (ip->ip_off + ip->ip_len) - q->ip_off;
@ -758,7 +761,7 @@ insert:
/*
* Any fragment diverting causes the whole packet to divert
*/
if (frag_divert_port != 0) {
if (frag_divert_port) {
fp->ipq_divert = frag_divert_port;
fp->ipq_div_cookie = ip_divert_cookie;
}
@ -840,6 +843,10 @@ insert:
return ((struct ip *)ip);
dropfrag:
#ifdef IPDIVERT
frag_divert_port = 0;
ip_divert_cookie = 0;
#endif
ipstat.ips_fragdropped++;
m_freem(m);
return (0);