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/udp_usrreq.c,v rcsdiff: /ftp/cvs/cvsroot/src/sys/netinet/udp_usrreq.c,v: warning: Unknown phrases like `commitid ...;' are present. retrieving revision 1.58 retrieving revision 1.67 diff -u -p -r1.58 -r1.67 --- src/sys/netinet/udp_usrreq.c 2000/01/31 14:18:58 1.58 +++ src/sys/netinet/udp_usrreq.c 2000/06/28 03:01:17 1.67 @@ -1,4 +1,4 @@ -/* $NetBSD: udp_usrreq.c,v 1.58 2000/01/31 14:18:58 itojun Exp $ */ +/* $NetBSD: udp_usrreq.c,v 1.67 2000/06/28 03:01:17 mrg Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -65,8 +65,7 @@ */ #include "opt_ipsec.h" - -#include "ipkdb.h" +#include "opt_ipkdb.h" #include #include @@ -80,7 +79,7 @@ #include #include -#include +#include #include #include @@ -119,6 +118,10 @@ #include #endif /*IPSEC*/ +#ifdef IPKDB +#include +#endif + /* * UDP protocol implementation. * Per RFC 768, August, 1980. @@ -240,32 +243,11 @@ udp_input(m, va_alist) * Checksum extended UDP header and data. */ if (uh->uh_sum) { -#ifndef PULLDOWN_TEST - struct ip save_ip; - - /* - * Save a copy of the IP header in case we want restore it - * for sending an ICMP error message in response. - */ - save_ip = *ip; - - bzero(((struct ipovly *)ip)->ih_x1, - sizeof ((struct ipovly *)ip)->ih_x1); - ((struct ipovly *)ip)->ih_len = uh->uh_ulen; - if (in_cksum(m, len + sizeof (struct ip)) != 0) { - udpstat.udps_badsum++; - m_freem(m); - return; - } - - *ip = save_ip; -#else if (in4_cksum(m, IPPROTO_UDP, iphlen, len) != 0) { udpstat.udps_badsum++; m_freem(m); return; } -#endif } /* construct source and dst sockaddrs. */ @@ -305,12 +287,12 @@ udp_input(m, va_alist) #endif if (n == 0) { - udpstat.udps_noport++; if (m->m_flags & (M_BCAST | M_MCAST)) { udpstat.udps_noportbcast++; goto bad; } -#if NIPKDB > 0 + udpstat.udps_noport++; +#ifdef IPKDB if (checkipkdb(&ip->ip_src, uh->uh_sport, uh->uh_dport, m, iphlen + sizeof(struct udphdr), m->m_pkthdr.len - iphlen - sizeof(struct udphdr))) { @@ -433,11 +415,11 @@ udp6_input(mp, offp, proto) dst.sin6_port = uh->uh_dport; if (udp6_realinput(AF_INET6, &src, &dst, m, off) == 0) { - udp6stat.udp6s_noport++; if (m->m_flags & M_MCAST) { udp6stat.udp6s_noportmcast++; goto bad; } + udp6stat.udp6s_noport++; icmp6_error(m, ICMP6_DST_UNREACH, ICMP6_DST_UNREACH_NOPORT, 0); m = NULL; } @@ -638,7 +620,6 @@ udp4_realinput(src, dst, m, off) * (No need to send an ICMP Port Unreachable * for a broadcast or multicast datgram.) */ - udpstat.udps_noport++; udpstat.udps_noportbcast++; goto bad; } @@ -655,12 +636,12 @@ udp4_realinput(src, dst, m, off) #if 0 struct mbuf *n; - udpstat.udps_noport++; if (m->m_flags & (M_BCAST | M_MCAST)) { udpstat.udps_noportbcast++; goto bad; } -#if NIPKDB > 0 + udpstat.udps_noport++; +#ifdef IPKDB if (checkipkdb(src4, *sport, *dport, m, off, m->m_pkthdr.len - off)) { /* @@ -691,7 +672,7 @@ bad: static int in6_mcmatch(in6p, ia6, ifp) struct in6pcb *in6p; - register struct in6_addr *ia6; + struct in6_addr *ia6; struct ifnet *ifp; { struct ip6_moptions *im6o = in6p->in6p_moptions; @@ -821,11 +802,9 @@ udp6_realinput(af, src, dst, m, off) */ switch (af) { case AF_INET: - udpstat.udps_noport++; udpstat.udps_noportbcast++; break; case AF_INET6: - udp6stat.udp6s_noport++; udp6stat.udp6s_noportmcast++; break; } @@ -847,21 +826,21 @@ udp6_realinput(af, src, dst, m, off) n = m_copy(m, 0, M_COPYALL); switch (af) { case AF_INET: - udpstat.udps_noport++; if (m->m_flags & (M_BCAST | M_MCAST)) { udpstat.udps_noportbcast++; goto bad; } + udpstat.udps_noport++; if (n != NULL) icmp_error(n, ICMP_UNREACH, ICMP_UNREACH_PORT, 0, 0); break; case AF_INET6: - udp6stat.udp6s_noport++; if (m->m_flags & M_MCAST) { udp6stat.udp6s_noportmcast++; goto bad; } + udp6stat.udp6s_noport++; if (n != NULL) icmp6_error(n, ICMP6_DST_UNREACH, ICMP6_DST_UNREACH_NOPORT, 0); @@ -894,9 +873,9 @@ udp_input(m, va_alist) #endif { int proto; - register struct ip *ip; - register struct udphdr *uh; - register struct inpcb *inp; + struct ip *ip; + struct udphdr *uh; + struct inpcb *inp; struct mbuf *opts = 0; int len; struct ip save_ip; @@ -1075,7 +1054,6 @@ udp_input(m, va_alist) * (No need to send an ICMP Port Unreachable * for a broadcast or multicast datgram.) */ - udpstat.udps_noport++; udpstat.udps_noportbcast++; goto bad; } @@ -1109,13 +1087,13 @@ udp_input(m, va_alist) ++udpstat.udps_pcbhashmiss; inp = in_pcblookup_bind(&udbtable, ip->ip_dst, uh->uh_dport); if (inp == 0) { - udpstat.udps_noport++; if (m->m_flags & (M_BCAST | M_MCAST)) { udpstat.udps_noportbcast++; goto bad; } + udpstat.udps_noport++; *ip = save_ip; -#if NIPKDB > 0 +#ifdef IPKDB if (checkipkdb(&ip->ip_src, uh->uh_sport, uh->uh_dport, @@ -1166,7 +1144,7 @@ bad: */ static void udp_notify(inp, errno) - register struct inpcb *inp; + struct inpcb *inp; int errno; { @@ -1181,9 +1159,8 @@ udp_ctlinput(cmd, sa, v) struct sockaddr *sa; void *v; { - register struct ip *ip = v; - register struct udphdr *uh; - extern int inetctlerrmap[]; + struct ip *ip = v; + struct udphdr *uh; void (*notify) __P((struct inpcb *, int)) = udp_notify; int errno; @@ -1220,9 +1197,9 @@ udp_output(m, va_alist) va_dcl #endif { - register struct inpcb *inp; - register struct udpiphdr *ui; - register int len = m->m_pkthdr.len; + struct inpcb *inp; + struct udpiphdr *ui; + int len = m->m_pkthdr.len; int error = 0; va_list ap; @@ -1277,7 +1254,7 @@ udp_output(m, va_alist) udpstat.udps_opackets++; #ifdef IPSEC - m->m_pkthdr.rcvif = (struct ifnet *)inp->inp_socket; + ipsec_setsocket(m, inp->inp_socket); #endif /*IPSEC*/ return (ip_output(m, inp->inp_options, &inp->inp_route, @@ -1301,14 +1278,20 @@ udp_usrreq(so, req, m, nam, control, p) struct mbuf *m, *nam, *control; struct proc *p; { - register struct inpcb *inp; + struct inpcb *inp; int s; - register int error = 0; + int error = 0; if (req == PRU_CONTROL) return (in_control(so, (long)m, (caddr_t)nam, (struct ifnet *)control, p)); + if (req == PRU_PURGEIF) { + in_purgeif((struct ifnet *)control); + in_pcbpurgeif(&udbtable, (struct ifnet *)control); + return (0); + } + s = splsoftnet(); inp = sotoinpcb(so); #ifdef DIAGNOSTIC