diff options
Diffstat (limited to 'sys/netinet')
34 files changed, 382 insertions, 847 deletions
diff --git a/sys/netinet/fil.c b/sys/netinet/fil.c index f91ee3dec08b..d634bbb74655 100644 --- a/sys/netinet/fil.c +++ b/sys/netinet/fil.c @@ -7,7 +7,7 @@ */ #if !defined(lint) static const char sccsid[] = "@(#)fil.c 1.36 6/5/96 (C) 1993-1996 Darren Reed"; -static const char rcsid[] = "@(#)$Id: fil.c,v 1.3 1998/06/20 18:37:49 peter Exp $"; +static const char rcsid[] = "@(#)$Id: fil.c,v 1.2 1998/03/21 11:33:54 peter Exp $"; #endif #include "opt_ipfilter.h" @@ -153,7 +153,7 @@ static int frflushlist __P((int, int, int *, frentry_t *, frentry_t **)); /* * bit values for identifying presence of individual IP options */ -static struct optlist ipopts[20] = { +struct optlist ipopts[20] = { { IPOPT_NOP, 0x000001 }, { IPOPT_RR, 0x000002 }, { IPOPT_ZSU, 0x000004 }, @@ -179,7 +179,7 @@ static struct optlist ipopts[20] = { /* * bit values for identifying presence of individual IP security options */ -static struct optlist secopt[8] = { +struct optlist secopt[8] = { { IPSO_CLASS_RES4, 0x01 }, { IPSO_CLASS_TOPS, 0x02 }, { IPSO_CLASS_SECR, 0x04 }, @@ -1098,7 +1098,7 @@ nodata: * SUCH DAMAGE. * * @(#)uipc_mbuf.c 8.2 (Berkeley) 1/4/94 - * $Id: fil.c,v 1.3 1998/06/20 18:37:49 peter Exp $ + * $Id: fil.c,v 1.2 1998/03/21 11:33:54 peter Exp $ */ /* * Copy data from an mbuf chain starting "off" bytes from the beginning, diff --git a/sys/netinet/icmp_var.h b/sys/netinet/icmp_var.h index 7ccbe4b31ef2..13b778e159ee 100644 --- a/sys/netinet/icmp_var.h +++ b/sys/netinet/icmp_var.h @@ -31,16 +31,12 @@ * SUCH DAMAGE. * * @(#)icmp_var.h 8.1 (Berkeley) 6/10/93 - * $Id: icmp_var.h,v 1.11 1998/12/04 03:49:18 dillon Exp $ + * $Id: icmp_var.h,v 1.8 1997/08/25 16:29:25 wollman Exp $ */ #ifndef _NETINET_ICMP_VAR_H_ #define _NETINET_ICMP_VAR_H_ -#ifdef KERNEL -#include "opt_icmp_bandlim.h" /* for ICMP_BANDLIM */ -#endif - /* * Variables related to this implementation * of the internet control message protocol. @@ -67,20 +63,12 @@ struct icmpstat { */ #define ICMPCTL_MASKREPL 1 /* allow replies to netmask requests */ #define ICMPCTL_STATS 2 /* statistics (read-only) */ -#define ICMPCTL_ICMPLIM 3 -#define ICMPCTL_MAXID 4 +#define ICMPCTL_MAXID 3 #define ICMPCTL_NAMES { \ { 0, 0 }, \ { "maskrepl", CTLTYPE_INT }, \ { "stats", CTLTYPE_STRUCT }, \ - { "icmplim", CTLTYPE_INT }, \ } -#ifdef KERNEL -#ifdef ICMP_BANDLIM -extern int badport_bandlim __P((int)); -#endif -#endif - #endif diff --git a/sys/netinet/if_ether.c b/sys/netinet/if_ether.c index 4f57f64b2bad..ac8d86db643a 100644 --- a/sys/netinet/if_ether.c +++ b/sys/netinet/if_ether.c @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)if_ether.c 8.1 (Berkeley) 6/10/93 - * $Id: if_ether.c,v 1.51 1999/01/18 01:54:36 fenner Exp $ + * $Id: if_ether.c,v 1.47 1998/06/12 03:48:14 julian Exp $ */ /* @@ -41,7 +41,6 @@ */ #include "opt_inet.h" -#include "opt_bdg.h" #include <sys/param.h> #include <sys/kernel.h> @@ -327,7 +326,7 @@ arpresolve(ac, rt, m, dst, desten, rt0) register u_char *desten; struct rtentry *rt0; { - register struct llinfo_arp *la = 0; + register struct llinfo_arp *la; struct sockaddr_dl *sdl; if (m->m_flags & M_BCAST) { /* broadcast */ @@ -340,7 +339,7 @@ arpresolve(ac, rt, m, dst, desten, rt0) } if (rt) la = (struct llinfo_arp *)rt->rt_llinfo; - if (la == 0) { + else { la = arplookup(SIN(dst)->sin_addr.s_addr, 1, 0); if (la) rt = la->la_rt; @@ -462,16 +461,7 @@ in_arpinput(m) (void)memcpy(&isaddr, ea->arp_spa, sizeof (isaddr)); (void)memcpy(&itaddr, ea->arp_tpa, sizeof (itaddr)); for (ia = in_ifaddrhead.tqh_first; ia; ia = ia->ia_link.tqe_next) -#ifdef BRIDGE - /* - * For a bridge, we want to check the address irrespective - * of the receive interface. (This will change slightly - * when we have clusters of interfaces). - */ - { -#else if (ia->ia_ifp == &ac->ac_if) { -#endif maybe_ia = ia; if ((itaddr.s_addr == ia->ia_addr.sin_addr.s_addr) || (isaddr.s_addr == ia->ia_addr.sin_addr.s_addr)) @@ -504,7 +494,6 @@ in_arpinput(m) } la = arplookup(isaddr.s_addr, itaddr.s_addr == myaddr.s_addr, 0); if (la && (rt = la->la_rt) && (sdl = SDL(rt->rt_gateway))) { -#ifndef BRIDGE /* the following is not an error when doing bridging */ if (rt->rt_ifp != &ac->ac_if) { log(LOG_ERR, "arp: %s is on %s%d but got reply from %6D on %s%d\n", inet_ntoa(isaddr), @@ -513,7 +502,6 @@ in_arpinput(m) ac->ac_if.if_name, ac->ac_if.if_unit); goto reply; } -#endif if (sdl->sdl_alen && bcmp((caddr_t)ea->arp_sha, LLADDR(sdl), sdl->sdl_alen)) if (rt->rt_expire) diff --git a/sys/netinet/igmp.c b/sys/netinet/igmp.c index c1c90c041642..8a4bd8577c6f 100644 --- a/sys/netinet/igmp.c +++ b/sys/netinet/igmp.c @@ -35,7 +35,7 @@ * SUCH DAMAGE. * * @(#)igmp.c 8.1 (Berkeley) 7/19/93 - * $Id: igmp.c,v 1.26 1998/12/12 21:45:49 dillon Exp $ + * $Id: igmp.c,v 1.24 1997/10/11 18:31:31 phk Exp $ */ /* @@ -69,7 +69,7 @@ #include <netinet/igmp.h> #include <netinet/igmp_var.h> -static MALLOC_DEFINE(M_IGMP, "igmp", "igmp state"); +static MALLOC_DEFINE(M_MRTABLE, "mrt", "multicast routing tables"); static struct router_info * find_rti __P((struct ifnet *ifp)); @@ -133,7 +133,7 @@ find_rti(ifp) } rti = rti->rti_next; } - MALLOC(rti, struct router_info *, sizeof *rti, M_IGMP, M_NOWAIT); + MALLOC(rti, struct router_info *, sizeof *rti, M_MRTABLE, M_NOWAIT); rti->rti_ifp = ifp; rti->rti_type = IGMP_V2_ROUTER; rti->rti_time = 0; @@ -198,8 +198,6 @@ igmp_input(m, iphlen) ip = mtod(m, struct ip *); timer = igmp->igmp_code * PR_FASTHZ / IGMP_TIMER_SCALE; - if (timer == 0) - timer = 1; rti = find_rti(ifp); /* diff --git a/sys/netinet/in.c b/sys/netinet/in.c index 9fe7095db720..45121066d1fa 100644 --- a/sys/netinet/in.c +++ b/sys/netinet/in.c @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)in.c 8.4 (Berkeley) 1/9/95 - * $Id: in.c,v 1.38 1998/06/07 17:12:13 dfr Exp $ + * $Id: in.c,v 1.37 1997/10/12 20:25:23 phk Exp $ */ #include <sys/param.h> @@ -179,8 +179,6 @@ in_control(so, cmd, data, ifp, p) case SIOCAIFADDR: case SIOCDIFADDR: - if (ifp == 0) - return (EADDRNOTAVAIL); if (ifra->ifra_addr.sin_family == AF_INET) { for (oia = ia; ia; ia = ia->ia_link.tqe_next) { if (ia->ia_ifp == ifp && @@ -205,7 +203,7 @@ in_control(so, cmd, data, ifp, p) return error; if (ifp == 0) - return (EADDRNOTAVAIL); + panic("in_control"); if (ia == (struct in_ifaddr *)0) { ia = (struct in_ifaddr *) malloc(sizeof *ia, M_IFADDR, M_WAITOK); diff --git a/sys/netinet/in.h b/sys/netinet/in.h index 1188bdea11d6..67e58515775b 100644 --- a/sys/netinet/in.h +++ b/sys/netinet/in.h @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)in.h 8.3 (Berkeley) 1/3/94 - * $Id: in.h,v 1.37 1998/08/23 03:07:14 wollman Exp $ + * $Id: in.h,v 1.36 1998/07/06 03:20:12 julian Exp $ */ #ifndef _NETINET_IN_H_ @@ -323,11 +323,6 @@ struct ip_opts { #define IP_FW_GET 54 /* get entire firewall rule chain */ #define IP_NAT 55 /* set/get NAT opts */ -#define IP_DUMMYNET_CONFIGURE 60 /* add/configure a dummynet pipe */ -#define IP_DUMMYNET_DEL 61 /* delete a dummynet pipe from chain */ -#define IP_DUMMYNET_FLUSH 62 /* flush dummynet */ -#define IP_DUMMYNET_GET 64 /* get entire dummynet pipes */ - /* * Defaults and limits for options */ diff --git a/sys/netinet/in_pcb.c b/sys/netinet/in_pcb.c index d604ad06a88b..c8ac1c0ee298 100644 --- a/sys/netinet/in_pcb.c +++ b/sys/netinet/in_pcb.c @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)in_pcb.c 8.4 (Berkeley) 5/24/95 - * $Id: in_pcb.c,v 1.45 1998/09/17 18:42:16 fenner Exp $ + * $Id: in_pcb.c,v 1.44 1998/05/15 20:11:32 wollman Exp $ */ #include <sys/param.h> @@ -688,7 +688,7 @@ in_pcblookup_local(pcbinfo, laddr, lport_arg, wild_okay) u_int lport_arg; int wild_okay; { - register struct inpcb *inp; + register struct inpcb *inp, *match = NULL; int matchwild = 3, wildcard; u_short lport = lport_arg; diff --git a/sys/netinet/ip_auth.c b/sys/netinet/ip_auth.c index dab93b0ef0c2..9996c8d1a527 100644 --- a/sys/netinet/ip_auth.c +++ b/sys/netinet/ip_auth.c @@ -6,7 +6,7 @@ * to the original author and the contributors. */ #if !defined(lint) -static const char rcsid[] = "@(#)$Id: ip_auth.c,v 1.5 1998/08/15 21:51:53 bde Exp $"; +static const char rcsid[] = "@(#)$Id: ip_auth.c,v 1.4 1998/06/20 18:37:50 peter Exp $"; #endif #if defined(KERNEL) && !defined(_KERNEL) @@ -117,10 +117,10 @@ int fr_authsize = FR_NUMAUTH; int fr_authused = 0; int fr_defaultauthage = 600; fr_authstat_t fr_authstats; -static frauth_t fr_auth[FR_NUMAUTH]; +frauth_t fr_auth[FR_NUMAUTH]; mb_t *fr_authpkts[FR_NUMAUTH]; -static int fr_authstart = 0, fr_authend = 0, fr_authnext = 0; -static frauthent_t *fae_list = NULL; +int fr_authstart = 0, fr_authend = 0, fr_authnext = 0; +frauthent_t *fae_list = NULL; frentry_t *ipauth = NULL; diff --git a/sys/netinet/ip_divert.c b/sys/netinet/ip_divert.c index b39948e9c66c..87ae6715b5db 100644 --- a/sys/netinet/ip_divert.c +++ b/sys/netinet/ip_divert.c @@ -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.34 1998/07/06 09:06:58 julian Exp $ + * $Id: ip_divert.c,v 1.33 1998/07/02 06:31:25 julian Exp $ */ #include "opt_inet.h" @@ -197,8 +197,8 @@ div_input(struct mbuf *m, int hlen) /* * Record the incoming interface name whenever we have one. */ - bzero(&divsrc.sin_zero, sizeof(divsrc.sin_zero)); if (m->m_pkthdr.rcvif) { + char name[32]; /* * Hide the actual interface name in there in the * sin_zero array. XXX This needs to be moved to a @@ -217,9 +217,9 @@ div_input(struct mbuf *m, int hlen) * this iface name will come along for the ride. * (see div_output for the other half of this.) */ - snprintf(divsrc.sin_zero, sizeof(divsrc.sin_zero), - "%s%d", m->m_pkthdr.rcvif->if_name, - m->m_pkthdr.rcvif->if_unit); + sprintf(name, "%s%d", + m->m_pkthdr.rcvif->if_name, m->m_pkthdr.rcvif->if_unit); + strncpy(divsrc.sin_zero, name, 7); } /* Put packet on socket queue, if any */ diff --git a/sys/netinet/ip_dummynet.c b/sys/netinet/ip_dummynet.c index e495b60450b0..31b424995472 100644 --- a/sys/netinet/ip_dummynet.c +++ b/sys/netinet/ip_dummynet.c @@ -10,7 +10,7 @@ * * This software is provided ``AS IS'' without any warranties of any kind. * - * $Id: ip_dummynet.c,v 1.6 1999/01/12 16:40:57 eivind Exp $ + * $Id: ip_dummynet.c 1.2 1998/08/21 15:01:13 luigi Exp $ */ /* @@ -40,7 +40,6 @@ #include <sys/queue.h> /* XXX */ #include <sys/kernel.h> #include <sys/socket.h> -#include <sys/socketvar.h> #include <sys/time.h> #include <sys/sysctl.h> #include <net/if.h> @@ -51,7 +50,6 @@ #include <netinet/ip.h> #include <netinet/ip_fw.h> #include <netinet/ip_dummynet.h> -#include <netinet/ip_var.h> #ifdef BRIDGE #include <netinet/if_ether.h> /* for struct arpcom */ @@ -70,13 +68,11 @@ SYSCTL_INT(_net_inet_ip_dummynet, OID_AUTO, calls, CTLFLAG_RD, &dn_calls, 0, "") SYSCTL_INT(_net_inet_ip_dummynet, OID_AUTO, idle, CTLFLAG_RD, &dn_idle, 0, ""); #endif -static int ip_dn_ctl(struct sockopt *sopt); +static int ip_dn_ctl(int optname, struct mbuf **mm); -static void rt_unref(struct rtentry *); -static void dummynet(void *); +static void dummynet(void); static void dn_restart(void); static void dn_move(struct dn_pipe *pipe, int immediate); -static void dummynet_flush(void); /* * the following is needed when deleting a pipe, because rules can @@ -100,29 +96,19 @@ dn_restart() /* if there any pipe that needs work, restart */ if (pipe->r.head || pipe->p.head || pipe->numbytes < 0 ) { dn_idle = 0; - timeout(dummynet, NULL, 1); + timeout(dummynet, (caddr_t)NULL, 1); return ; } } } -static void -rt_unref(struct rtentry *rt) -{ - if (rt == NULL) - return ; - if (rt->rt_refcnt <= 0) - printf("-- warning, refcnt now %d, decreasing\n", rt->rt_refcnt); - RTFREE(rt); -} - /* * move packets from R-queue to P-queue */ static void dn_move(struct dn_pipe *pipe, int immediate) { - struct dn_pkt *pkt; + struct dn_pkt *tmp, *pkt; /* * consistency check, should catch new pipes which are @@ -130,7 +116,7 @@ dn_move(struct dn_pipe *pipe, int immediate) */ if ( pipe->p.head == NULL && pipe->ticks_from_last_insert != pipe->delay) { - printf("Warning, empty pipe and delay %d (should be %d)\n", + printf("Warning, empty pipe and delay %d (should be %a)d\n", pipe->ticks_from_last_insert, pipe->delay); pipe->ticks_from_last_insert = pipe->delay; } @@ -180,8 +166,8 @@ dn_move(struct dn_pipe *pipe, int immediate) /*** XXX just a sanity check */ if ( ( pkt == NULL && pipe->r_len != 0) || ( pkt != NULL && pipe->r_len == 0) ) - printf("-- Warning, pipe head %p len %d\n", - (void *)pkt, pipe->r_len); + printf("-- Warning, pipe head %x len %d\n", + pkt, pipe->r_len); } /* @@ -216,7 +202,8 @@ dn_move(struct dn_pipe *pipe, int immediate) (void)ip_output((struct mbuf *)pkt, (struct mbuf *)pkt->ifp, &(pkt->ro), pkt->dn_hlen, NULL); - rt_unref (tmp_rt) ; + if (tmp_rt) + tmp_rt->rt_refcnt--; /* XXX return a reference count */ } break ; case DN_TO_IP_IN : @@ -239,9 +226,8 @@ dn_move(struct dn_pipe *pipe, int immediate) * this is the periodic task that moves packets between the R- * and the P- queue */ -/*ARGSUSED*/ void -dummynet(void * __unused unused) +dummynet() { struct dn_pipe *p ; int s ; @@ -321,7 +307,6 @@ dummynet_io(int pipe_nr, int dir, m_freem(m); return 0 ; /* XXX error */ } - bzero(pkt, sizeof(*pkt) ); /* build and enqueue packet */ pkt->hdr.mh_type = MT_DUMMYNET ; (struct ip_fw_chain *)pkt->hdr.mh_data = rule ; @@ -368,14 +353,16 @@ purge_pipe(struct dn_pipe *pipe) struct rtentry *tmp_rt ; for (pkt = pipe->r.head ; pkt ; ) { - rt_unref (tmp_rt = pkt->ro.ro_rt ) ; + if (tmp_rt = pkt->ro.ro_rt ) + tmp_rt->rt_refcnt--; /* XXX return a reference count */ m_freem(pkt->dn_m); n = pkt ; pkt = (struct dn_pkt *)pkt->dn_next ; free(n, M_IPFW) ; } for (pkt = pipe->p.head ; pkt ; ) { - rt_unref (tmp_rt = pkt->ro.ro_rt ) ; + if (tmp_rt = pkt->ro.ro_rt ) + tmp_rt->rt_refcnt--; /* XXX return a reference count */ m_freem(pkt->dn_m); n = pkt ; pkt = (struct dn_pkt *)pkt->dn_next ; @@ -413,25 +400,18 @@ extern struct ip_fw_chain *ip_fw_default_rule ; void dn_rule_delete(void *r) { - struct dn_pipe *p ; - int matches = 0 ; - for ( p = all_pipes ; p ; p = p->next ) { + struct dn_pipe *q, *p = all_pipes ; + + for ( p= all_pipes ; p ; p = p->next ) { struct dn_pkt *x ; for (x = p->r.head ; x ; x = (struct dn_pkt *)x->dn_next ) - if (x->hdr.mh_data == r) { - matches++ ; + if (x->hdr.mh_data == r) x->hdr.mh_data = (void *)ip_fw_default_rule ; - } for (x = p->p.head ; x ; x = (struct dn_pkt *)x->dn_next ) - if (x->hdr.mh_data == r) { - matches++ ; + if (x->hdr.mh_data == r) x->hdr.mh_data = (void *)ip_fw_default_rule ; - } } - printf("dn_rule_delete, r %p, default %p%s, %d matches\n", - (void *)r, (void *)ip_fw_default_rule, - r == ip_fw_default_rule ? " AARGH!":"", matches); } /* @@ -439,53 +419,51 @@ dn_rule_delete(void *r) * (get, flush, config, del) */ static int -ip_dn_ctl(struct sockopt *sopt) +ip_dn_ctl(int optname, struct mbuf **mm) { - int error = 0 ; - size_t size ; - char *buf, *bp ; - struct dn_pipe *p, tmp_pipe ; - - struct dn_pipe *x, *a, *b ; - - /* Disallow sets in really-really secure mode. */ - if (sopt->sopt_dir == SOPT_SET && securelevel >= 3) - return (EPERM); - - switch (sopt->sopt_name) { - default : - panic("ip_dn_ctl -- unknown option"); - - case IP_DUMMYNET_GET : - for (p = all_pipes, size = 0 ; p ; p = p->next ) - size += sizeof( *p ) ; - buf = malloc(size, M_TEMP, M_WAITOK); - if (buf == 0) { - error = ENOBUFS ; - break ; - } - for (p = all_pipes, bp = buf ; p ; p = p->next ) { - struct dn_pipe *q = (struct dn_pipe *)bp ; - - bcopy(p, bp, sizeof( *p ) ); + struct mbuf *m ; + if (optname == IP_DUMMYNET_GET) { + struct dn_pipe *p = all_pipes ; + *mm = m = m_get(M_WAIT, MT_SOOPTS); + m->m_len = 0 ; + m->m_next = NULL ; + for (; p ; p = p->next ) { + struct dn_pipe *q = mtod(m,struct dn_pipe *) ; + memcpy( m->m_data, p, sizeof(*p) ); /* * return bw and delay in bits/s and ms, respectively */ q->bandwidth *= (8*hz) ; q->delay = (q->delay * 1000) / hz ; - bp += sizeof( *p ) ; + + m->m_len = sizeof(*p) ; + m->m_next = m_get(M_WAIT, MT_SOOPTS); + m = m->m_next ; + m->m_len = 0 ; + } + return 0 ; + } + if (securelevel > 2) { /* like in the firewall code... */ + if (m) (void)m_free(m); + return (EPERM) ; } - error = sooptcopyout(sopt, buf, size); - FREE(buf, M_TEMP); - break ; - case IP_DUMMYNET_FLUSH : + m = *mm ; + if (optname == IP_DUMMYNET_FLUSH) { dummynet_flush() ; - break ; - case IP_DUMMYNET_CONFIGURE : - p = &tmp_pipe ; - error = sooptcopyin(sopt, p, sizeof *p, sizeof *p); - if (error) - break ; + if (m) (void)m_free(m); + return 0 ; + } + if (!m) /* need an argument for the following */ + return (EINVAL); + if (optname == IP_DUMMYNET_CONFIGURE) { + struct dn_pipe *p = mtod(m,struct dn_pipe *) ; + struct dn_pipe *x, *a, *b ; + if (m->m_len != sizeof (*p) ) { + printf("dn_pipe Invalid length, %d instead of %d\n", + m->m_len, sizeof(*p) ); + (void)m_free(m); + return (EINVAL); + } /* * The config program passes parameters as follows: * bandwidth = bits/second (0 = no limits); @@ -531,8 +509,7 @@ ip_dn_ctl(struct sockopt *sopt) x = malloc(sizeof(struct dn_pipe), M_IPFW, M_DONTWAIT) ; if (x == NULL) { printf("ip_dummynet.c: sorry no memory\n"); - error = ENOSPC ; - break ; + return (ENOSPC) ; } bzero(x, sizeof(*x) ); x->bandwidth = p->bandwidth ; @@ -551,13 +528,12 @@ ip_dn_ctl(struct sockopt *sopt) a->next = x ; splx(s); } - break ; - - case IP_DUMMYNET_DEL : - p = &tmp_pipe ; - error = sooptcopyin(sopt, p, sizeof *p, sizeof *p); - if (error) - break ; + (void)m_free(m); + return 0 ; + } + if (optname == IP_DUMMYNET_DEL) { + struct dn_pipe *p = mtod(m,struct dn_pipe *) ; + struct dn_pipe *x, *a, *b ; for (a = NULL , b = all_pipes ; b && b->pipe_nr < p->pipe_nr ; a = b , b = b->next) ; @@ -581,9 +557,8 @@ ip_dn_ctl(struct sockopt *sopt) purge_pipe(b); /* remove pkts from here */ free(b, M_IPFW); } - break ; } - return error ; + return 0 ; } void diff --git a/sys/netinet/ip_dummynet.h b/sys/netinet/ip_dummynet.h index f01406fdc6cf..33833fcaffb0 100644 --- a/sys/netinet/ip_dummynet.h +++ b/sys/netinet/ip_dummynet.h @@ -16,8 +16,6 @@ #ifndef _IP_DUMMYNET_H #define _IP_DUMMYNET_H -typedef int ip_dn_ctl_t __P((struct sockopt *)) ; -extern ip_dn_ctl_t *ip_dn_ctl_ptr; /* * Definition of dummynet data structures. * Dummynet handles a list of pipes, each one identified by a unique @@ -87,20 +85,12 @@ struct dn_pipe { /* a pipe */ }; /* - * The following is used to define a new mbuf type that is - * prepended to the packet when it comes out of a pipe. The definition - * ought to go in /sys/sys/mbuf.h but here it is less intrusive. - */ - -#define MT_DUMMYNET MT_CONTROL -/* * what to do of a packet when it comes out of a pipe */ #define DN_TO_IP_OUT 1 #define DN_TO_IP_IN 2 #define DN_TO_BDG_FWD 3 #ifdef KERNEL -MALLOC_DECLARE(M_IPFW); void ip_dn_init(void); /* called in ip_input.c */ void dn_rule_delete(void *r); /* used in ip_fw.c */ int dummynet_io(int pipe, int dir, diff --git a/sys/netinet/ip_fil.c b/sys/netinet/ip_fil.c index 6cbdac90533c..1075316718d1 100644 --- a/sys/netinet/ip_fil.c +++ b/sys/netinet/ip_fil.c @@ -7,7 +7,7 @@ */ #if !defined(lint) static const char sccsid[] = "@(#)ip_fil.c 2.41 6/5/96 (C) 1993-1995 Darren Reed"; -static const char rcsid[] = "@(#)$Id: ip_fil.c,v 1.6 1998/08/15 21:51:53 bde Exp $"; +static const char rcsid[] = "@(#)$Id: ip_fil.c,v 1.5 1998/06/20 18:37:50 peter Exp $"; #endif #include "opt_ipfilter.h" @@ -1110,12 +1110,12 @@ ip_t *ip; # if (defined(NetBSD) && (NetBSD <= 1991011) && (NetBSD >= 199606)) || \ (defined(OpenBSD) && (OpenBSD >= 199603)) - snprintf(fname, sizeof(fname), "/tmp/%s", ifp->if_xname); + sprintf(fname, "/tmp/%s", ifp->if_xname); if ((fp = fopen(fname, "a"))) { fclose(fp); } # else - snprintf(fname, sizeof(fname), "/tmp/%s%d", ifp->if_name, ifp->if_unit); + sprintf(fname, "/tmp/%s%d", ifp->if_name, ifp->if_unit); if ((fp = fopen(fname, "a"))) { fwrite((char *)ip, ntohs(ip->ip_len), 1, fp); fclose(fp); @@ -1139,8 +1139,7 @@ char *name; char ifname[32], *s; for (ifa = ifneta; ifa && (ifp = *ifa); ifa++) { - (void) snprintf(ifname, sizeof(ifname), - "%s%d", ifp->if_name, ifp->if_unit); + (void) sprintf(ifname, "%s%d", ifp->if_name, ifp->if_unit); if (!strcmp(name, ifname)) return ifp; } @@ -1191,7 +1190,7 @@ void init_ifp() (defined(OpenBSD) && (OpenBSD >= 199603)) for (ifa = ifneta; ifa && (ifp = *ifa); ifa++) { ifp->if_output = write_output; - snprintf(fname, sizeof(fname), "/tmp/%s", ifp->if_xname); + sprintf(fname, "/tmp/%s", ifp->if_xname); if ((fp = fopen(fname, "w"))) fclose(fp); } @@ -1199,8 +1198,7 @@ void init_ifp() for (ifa = ifneta; ifa && (ifp = *ifa); ifa++) { ifp->if_output = write_output; - snprintf(fname, sizeof(fname), - "/tmp/%s%d", ifp->if_name, ifp->if_unit); + sprintf(fname, "/tmp/%s%d", ifp->if_name, ifp->if_unit); if ((fp = fopen(fname, "w"))) fclose(fp); } diff --git a/sys/netinet/ip_flow.c b/sys/netinet/ip_flow.c index d4a2439ed547..b9a000ce532b 100644 --- a/sys/netinet/ip_flow.c +++ b/sys/netinet/ip_flow.c @@ -33,7 +33,7 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - * $Id: ip_flow.c,v 1.5 1998/06/21 14:53:29 bde Exp $ + * $Id: ip_flow.c,v 1.4 1998/05/19 17:47:11 jdp Exp $ */ #include <sys/param.h> @@ -109,6 +109,7 @@ ipflow_fastforward( struct ip *ip; struct ipflow *ipf; struct rtentry *rt; + u_int32_t sum; int error; /* diff --git a/sys/netinet/ip_frag.c b/sys/netinet/ip_frag.c index 7ad47f784b08..a379c67b6601 100644 --- a/sys/netinet/ip_frag.c +++ b/sys/netinet/ip_frag.c @@ -7,7 +7,7 @@ */ #if !defined(lint) static const char sccsid[] = "@(#)ip_frag.c 1.11 3/24/96 (C) 1993-1995 Darren Reed"; -static const char rcsid[] = "@(#)$Id: ip_frag.c,v 1.2 1998/03/21 11:34:06 peter Exp $"; +static const char rcsid[] = "@(#)$Id: ip_frag.c,v 1.1.1.5 1997/11/16 05:55:34 peter Exp $"; #endif #if !defined(_KERNEL) && defined(KERNEL) @@ -76,11 +76,11 @@ static const char rcsid[] = "@(#)$Id: ip_frag.c,v 1.2 1998/03/21 11:34:06 peter #include "netinet/ip_state.h" #include "netinet/ip_auth.h" -static ipfr_t *ipfr_heads[IPFT_SIZE]; -static ipfr_t *ipfr_nattab[IPFT_SIZE]; -static ipfrstat_t ipfr_stats; -static int ipfr_inuse = 0; - int fr_ipfrttl = 120; /* 60 seconds */ +ipfr_t *ipfr_heads[IPFT_SIZE]; +ipfr_t *ipfr_nattab[IPFT_SIZE]; +ipfrstat_t ipfr_stats; +int ipfr_inuse = 0, + fr_ipfrttl = 120; /* 60 seconds */ #ifdef _KERNEL extern int ipfr_timer_id; #endif diff --git a/sys/netinet/ip_ftp_pxy.c b/sys/netinet/ip_ftp_pxy.c index dd70c8124015..1a66a9ba0c42 100644 --- a/sys/netinet/ip_ftp_pxy.c +++ b/sys/netinet/ip_ftp_pxy.c @@ -165,7 +165,7 @@ nat_t *nat; a4 = a1 & 0xff; a1 >>= 24; olen = s - portbuf + 1; - (void) snprintf(newbuf, sizeof(newbuf), "PORT %d,%d,%d,%d,%d,%d\r\n", + (void) sprintf(newbuf, "PORT %d,%d,%d,%d,%d,%d\r\n", a1, a2, a3, a4, a5, a6); nlen = strlen(newbuf); inc = nlen - olen; diff --git a/sys/netinet/ip_fw.c b/sys/netinet/ip_fw.c index 4bad5b66e3cc..bf4beb4702b1 100644 --- a/sys/netinet/ip_fw.c +++ b/sys/netinet/ip_fw.c @@ -12,7 +12,7 @@ * * This software is provided ``AS IS'' without any warranties of any kind. * - * $Id: ip_fw.c,v 1.102 1998/12/22 20:38:06 luigi Exp $ + * $Id: ip_fw.c,v 1.96 1998/08/23 03:07:14 wollman Exp $ */ /* @@ -21,7 +21,6 @@ #if !defined(KLD_MODULE) && !defined(IPFIREWALL_MODULE) #include "opt_ipfw.h" -#include "opt_ipdn.h" #include "opt_ipdivert.h" #include "opt_inet.h" #ifndef INET @@ -44,25 +43,18 @@ #include <netinet/ip_var.h> #include <netinet/ip_icmp.h> #include <netinet/ip_fw.h> -#ifdef DUMMYNET -#include <net/route.h> -#include <netinet/ip_dummynet.h> -#endif #include <netinet/tcp.h> #include <netinet/tcp_timer.h> #include <netinet/tcp_var.h> #include <netinet/tcpip.h> #include <netinet/udp.h> -#include <netinet/if_ether.h> /* XXX ethertype_ip */ - static int fw_debug = 1; #ifdef IPFIREWALL_VERBOSE static int fw_verbose = 1; #else static int fw_verbose = 0; #endif -static int fw_one_pass = 0; /* XXX */ #ifdef IPFIREWALL_VERBOSE_LIMIT static int fw_verbose_limit = IPFIREWALL_VERBOSE_LIMIT; #else @@ -71,14 +63,13 @@ static int fw_verbose_limit = 0; #define IPFW_DEFAULT_RULE ((u_int)(u_short)~0) -LIST_HEAD (ip_fw_head, ip_fw_chain) ip_fw_chain; +static LIST_HEAD (ip_fw_head, ip_fw_chain) ip_fw_chain; -MALLOC_DEFINE(M_IPFW, "IpFw/IpAcct", "IpFw/IpAcct chain's"); +static MALLOC_DEFINE(M_IPFW, "IpFw/IpAcct", "IpFw/IpAcct chain's"); #ifdef SYSCTL_NODE SYSCTL_NODE(_net_inet_ip, OID_AUTO, fw, CTLFLAG_RW, 0, "Firewall"); SYSCTL_INT(_net_inet_ip_fw, OID_AUTO, debug, CTLFLAG_RW, &fw_debug, 0, ""); -SYSCTL_INT(_net_inet_ip_fw, OID_AUTO,one_pass,CTLFLAG_RW, &fw_one_pass, 0, ""); SYSCTL_INT(_net_inet_ip_fw, OID_AUTO, verbose, CTLFLAG_RW, &fw_verbose, 0, ""); SYSCTL_INT(_net_inet_ip_fw, OID_AUTO, verbose_limit, CTLFLAG_RW, &fw_verbose_limit, 0, ""); #endif @@ -109,11 +100,8 @@ static int icmptype_match __P((struct icmp * icmp, struct ip_fw * f)); static void ipfw_report __P((struct ip_fw *f, struct ip *ip, struct ifnet *rif, struct ifnet *oif)); -static void flush_rule_ptrs(void); - static int ip_fw_chk __P((struct ip **pip, int hlen, struct ifnet *oif, u_int16_t *cookie, struct mbuf **m, - struct ip_fw_chain **flow_id, struct sockaddr_in **next_hop)); static int ip_fw_ctl __P((struct sockopt *sopt)); @@ -291,7 +279,6 @@ static void ipfw_report(struct ip_fw *f, struct ip *ip, struct ifnet *rif, struct ifnet *oif) { - if (ip) { static u_int64_t counter; struct tcphdr *const tcp = (struct tcphdr *) ((u_int32_t *) ip+ ip->ip_hl); struct udphdr *const udp = (struct udphdr *) ((u_int32_t *) ip+ ip->ip_hl); @@ -332,11 +319,6 @@ ipfw_report(struct ip_fw *f, struct ip *ip, case IP_FW_F_SKIPTO: printf("SkipTo %d", f->fw_skipto_rule); break; -#ifdef DUMMYNET - case IP_FW_F_PIPE: - printf("Pipe %d", f->fw_skipto_rule); - break; -#endif #ifdef IPFIREWALL_FORWARD case IP_FW_F_FWD: printf("Forward to "); @@ -400,46 +382,16 @@ ipfw_report(struct ip_fw *f, struct ip *ip, if (fw_verbose_limit != 0 && count == fw_verbose_limit) printf("ipfw: limit reached on rule #%d\n", f ? f->fw_number : -1); - } -} - -/* - * given an ip_fw_chain *, lookup_next_rule will return a pointer - * of the same type to the next one. This can be either the jump - * target (for skipto instructions) or the next one in the chain (in - * all other cases including a missing jump target). - * Backward jumps are not allowed, so start looking from the next - * rule... - */ -static struct ip_fw_chain * lookup_next_rule(struct ip_fw_chain *me); - -static struct ip_fw_chain * -lookup_next_rule(struct ip_fw_chain *me) -{ - struct ip_fw_chain *chain ; - int rule = me->rule->fw_skipto_rule ; /* guess... */ - - if ( (me->rule->fw_flg & IP_FW_F_COMMAND) == IP_FW_F_SKIPTO ) - for (chain = me->chain.le_next; chain ; chain = chain->chain.le_next ) - if (chain->rule->fw_number >= rule) - return chain ; - return me->chain.le_next ; /* failure or not a skipto */ } /* * Parameters: * - * pip Pointer to packet header (struct ip **) - * bridge_ipfw extension: pip = NULL means a complete ethernet packet - * including ethernet header in the mbuf. Other fields - * are ignored/invalid. - * + * ip Pointer to packet header (struct ip *) * hlen Packet header length * oif Outgoing interface, or NULL if packet is incoming * *cookie Skip up to the first rule past this rule number; * *m The packet; we set to NULL when/if we nuke it. - * *flow_id pointer to the last matching rule (in/out) - * *next_hop socket we are forwarding to (in/out). * * Return value: * @@ -452,58 +404,17 @@ lookup_next_rule(struct ip_fw_chain *me) static int ip_fw_chk(struct ip **pip, int hlen, struct ifnet *oif, u_int16_t *cookie, struct mbuf **m, - struct ip_fw_chain **flow_id, struct sockaddr_in **next_hop) { struct ip_fw_chain *chain; struct ip_fw *rule = NULL; - struct ip *ip = NULL ; + struct ip *ip = *pip; struct ifnet *const rif = (*m)->m_pkthdr.rcvif; - u_short offset = 0 ; + u_short offset = (ip->ip_off & IP_OFFMASK); u_short src_port, dst_port; u_int16_t skipto = *cookie; - if (pip) { /* normal ip packet */ - ip = *pip; - offset = (ip->ip_off & IP_OFFMASK); - } else { /* bridged or non-ip packet */ - struct ether_header *eh = mtod(*m, struct ether_header *); - switch (ntohs(eh->ether_type)) { - case ETHERTYPE_IP : - if ((*m)->m_len<sizeof(struct ether_header) + sizeof(struct ip)) - goto non_ip ; - ip = (struct ip *)(eh + 1 ); - if (ip->ip_v != IPVERSION) - goto non_ip ; - hlen = ip->ip_hl << 2; - if (hlen < sizeof(struct ip)) /* minimum header length */ - goto non_ip ; - if ((*m)->m_len < 14 + hlen + 14) { - printf("-- m_len %d, need more...\n", (*m)->m_len); - goto non_ip ; - } - offset = (ntohs(ip->ip_off) & IP_OFFMASK); - break ; - default : -non_ip: ip = NULL ; - break ; - } - } - - if (*flow_id) { - if (fw_one_pass) - return 0 ; /* accept if passed first test */ - /* - * pkt has already been tagged. Look for the next rule - * to restart processing - */ - chain = LIST_NEXT( *flow_id, chain); - - if ( (chain = (*flow_id)->rule->next_rule_ptr) == NULL ) - chain = (*flow_id)->rule->next_rule_ptr = - lookup_next_rule(*flow_id) ; - if (! chain) goto dropit; - } else { + *cookie = 0; /* * Go down the chain, looking for enlightment * If we've been asked to start at a given rule immediatly, do so. @@ -517,12 +428,8 @@ non_ip: ip = NULL ; } if (! chain) goto dropit; } - } - *cookie = 0; for (; chain; chain = LIST_NEXT(chain, chain)) { - register struct ip_fw * f ; -again: - f = chain->rule; + register struct ip_fw *const f = chain->rule; if (oif) { /* Check direction outbound */ @@ -533,43 +440,9 @@ again: if (!(f->fw_flg & IP_FW_F_IN)) continue; } - if (ip == NULL ) { - /* - * do relevant checks for non-ip packets: - * after this, only goto got_match or continue - */ - struct ether_header *eh = mtod(*m, struct ether_header *); - - /* - * make default rule always match or we have a panic - */ - if (f->fw_number == IPFW_DEFAULT_RULE) - goto got_match ; - /* - * temporary hack: - * udp from 0.0.0.0 means this rule applies. - * 1 src port is match ether type - * 2 src ports (interval) is match ether type - * 3 src ports is match ether address - */ - if ( f->fw_src.s_addr != 0 || f->fw_prot != IPPROTO_UDP) - continue; - switch (IP_FW_GETNSRCP(f)) { - case 1: /* match one type */ - if ( /* ( (f->fw_flg & IP_FW_F_INVSRC) != 0) ^ */ - ( f->fw_uar.fw_pts[0] == ntohs(eh->ether_type) ) ) { - printf("match!\n"); - goto got_match ; - } - break ; - default: - break ; - } - continue ; - } /* Fragments */ - if ((f->fw_flg & IP_FW_F_FRAG) && offset == 0 ) + if ((f->fw_flg & IP_FW_F_FRAG) && !(ip->ip_off & IP_OFFMASK)) continue; /* If src-addr doesn't match, not this rule. */ @@ -615,19 +488,14 @@ again: if (ip->ip_p != f->fw_prot) continue; -#define PULLUP_TO(len) \ - do { \ - if ((*m)->m_len < (len) ) { \ - if ( (*m = m_pullup(*m, (len))) == 0) \ - goto bogusfrag; \ - ip = mtod(*m, struct ip *); \ - if (pip) { \ - *pip = ip ; \ - offset = (ip->ip_off & IP_OFFMASK); \ - } else \ - offset = (ntohs(ip->ip_off) & IP_OFFMASK); \ - } \ - } while (0) +#define PULLUP_TO(len) do { \ + if ((*m)->m_len < (len) \ + && (*m = m_pullup(*m, (len))) == 0) { \ + goto bogusfrag; \ + } \ + *pip = ip = mtod(*m, struct ip *); \ + offset = (ip->ip_off & IP_OFFMASK); \ + } while (0) /* Protocol specific checks */ switch (ip->ip_p) { @@ -710,12 +578,9 @@ bogusfrag: } got_match: - *flow_id = chain ; /* XXX set flow id */ /* Update statistics */ f->fw_pcnt += 1; - if (ip) { - f->fw_bcnt += pip ? ip->ip_len : ntohs(ip->ip_len); - } + f->fw_bcnt += ip->ip_len; f->timestamp = time_second; /* Log to console if desired */ @@ -728,11 +593,9 @@ got_match: return(0); case IP_FW_F_COUNT: continue; -#ifdef IPDIVERT case IP_FW_F_DIVERT: *cookie = f->fw_number; return(f->fw_divert_port); -#endif case IP_FW_F_TEE: /* * XXX someday tee packet here, but beware that you @@ -743,17 +606,17 @@ got_match: * to write custom routine. */ continue; - case IP_FW_F_SKIPTO: /* XXX check */ - if ( f->next_rule_ptr ) - chain = f->next_rule_ptr ; - else - chain = lookup_next_rule(chain) ; - if (! chain) goto dropit; - goto again ; -#ifdef DUMMYNET - case IP_FW_F_PIPE: - return(f->fw_pipe_nr | 0x10000 ); + case IP_FW_F_SKIPTO: +#ifdef DIAGNOSTIC + while (LIST_NEXT(chain, chain) + && LIST_NEXT(chain, chain)->rule->fw_number + < f->fw_skipto_rule) +#else + while (LIST_NEXT(chain, chain)->rule->fw_number + < f->fw_skipto_rule) #endif + chain = LIST_NEXT(chain, chain); + continue; #ifdef IPFIREWALL_FORWARD case IP_FW_F_FWD: /* Change the next-hop address for this packet. @@ -793,7 +656,6 @@ got_match: * - The packet is not a multicast or broadcast packet */ if ((rule->fw_flg & IP_FW_F_COMMAND) == IP_FW_F_REJECT - && ip && (ip->ip_p != IPPROTO_ICMP || is_icmp_query(ip)) && !((*m)->m_flags & (M_BCAST|M_MCAST)) && !IN_MULTICAST(ntohl(ip->ip_dst.s_addr))) { @@ -836,7 +698,7 @@ dropit: /* * Finally, drop the packet. */ - /* *cookie = 0; */ /* XXX is this necessary ? */ + *cookie = 0; if (*m) { m_freem(*m); *m = NULL; @@ -844,22 +706,6 @@ dropit: return(0); } -/* - * when a rule is added/deleted, zero the direct pointers within - * all firewall rules. These will be reconstructed on the fly - * as packets are matched. - * Must be called at splnet(). - */ -static void -flush_rule_ptrs() -{ - struct ip_fw_chain *fcp ; - - for (fcp = ip_fw_chain.lh_first; fcp; fcp = fcp->chain.le_next) { - fcp->rule->next_rule_ptr = NULL ; - } -} - static int add_entry(struct ip_fw_head *chainptr, struct ip_fw *frwl) { @@ -881,8 +727,6 @@ add_entry(struct ip_fw_head *chainptr, struct ip_fw *frwl) ftmp->fw_in_if.fu_via_if.name[FW_IFNLEN - 1] = '\0'; ftmp->fw_pcnt = 0L; ftmp->fw_bcnt = 0L; - ftmp->next_rule_ptr = NULL ; - ftmp->pipe_ptr = NULL ; fwc->rule = ftmp; s = splnet(); @@ -919,7 +763,6 @@ add_entry(struct ip_fw_head *chainptr, struct ip_fw *frwl) fcpl = fcp; } } - flush_rule_ptrs(); splx(s); return (0); @@ -943,10 +786,6 @@ del_entry(struct ip_fw_head *chainptr, u_short number) next = LIST_NEXT(fcp, chain); LIST_REMOVE(fcp, chain); -#ifdef DUMMYNET - dn_rule_delete(fcp) ; -#endif - flush_rule_ptrs(); free(fcp->rule, M_IPFW); free(fcp, M_IPFW); fcp = next; @@ -1102,7 +941,6 @@ check_ipfw_struct(struct ip_fw *frwl) } break; case IP_FW_F_DIVERT: /* Diverting to port zero is invalid */ - case IP_FW_F_PIPE: /* piping through 0 is invalid */ case IP_FW_F_TEE: if (frwl->fw_divert_port == 0) { dprintf(("%s can't divert to port 0\n", err_prefix)); @@ -1211,15 +1049,12 @@ ip_fw_ctl(struct sockopt *sopt) break; default: - printf("ip_fw_ctl invalid option %d\n", sopt->sopt_name); - error = EINVAL ; + panic("ip_fw_ctl"); } return (error); } -struct ip_fw_chain *ip_fw_default_rule ; - void ip_fw_init(void) { @@ -1242,7 +1077,6 @@ ip_fw_init(void) add_entry(&ip_fw_chain, &default_rule)) panic("ip_fw_init"); - ip_fw_default_rule = ip_fw_chain.lh_first ; printf("IP packet filtering initialized, " #ifdef IPDIVERT "divert enabled, "); @@ -1320,7 +1154,7 @@ ipfw_mod(struct lkm_table *lkmtp, int cmd, int ver) } #else static int -ipfw_modevent(module_t mod, int type, void *unused) +ipfw_modevent(module_t mod, modeventtype_t type, void *unused) { int s; @@ -1356,7 +1190,7 @@ ipfw_modevent(module_t mod, int type, void *unused) return 0; } -static moduledata_t ipfwmod = { +moduledata_t ipfwmod = { "ipfw", ipfw_modevent, 0 diff --git a/sys/netinet/ip_fw.h b/sys/netinet/ip_fw.h index a4cee76ed8e0..31e8366e82f8 100644 --- a/sys/netinet/ip_fw.h +++ b/sys/netinet/ip_fw.h @@ -11,7 +11,7 @@ * * This software is provided ``AS IS'' without any warranties of any kind. * - * $Id: ip_fw.h,v 1.35 1998/09/02 19:14:01 phk Exp $ + * $Id: ip_fw.h,v 1.34 1998/08/23 03:07:14 wollman Exp $ */ #ifndef _IP_FW_H @@ -35,7 +35,7 @@ union ip_fw_if { struct in_addr fu_via_ip; /* Specified by IP address */ struct { /* Specified by interface name */ -#define FW_IFNLEN 10 /* need room ! was IFNAMSIZ */ +#define FW_IFNLEN IFNAMSIZ char name[FW_IFNLEN]; short unit; /* -1 means match any unit */ } fu_via_if; @@ -69,7 +69,6 @@ struct ip_fw { union ip_fw_if fw_in_if, fw_out_if; /* Incoming and outgoing interfaces */ union { u_short fu_divert_port; /* Divert/tee port (options IPDIVERT) */ - u_short fu_pipe_nr; /* pipe number (option DUMMYNET) */ u_short fu_skipto_rule; /* SKIPTO command rule number */ u_short fu_reject_code; /* REJECT response code */ struct sockaddr_in fu_fwd_ip; @@ -79,8 +78,6 @@ struct ip_fw { /* in ports array (dst ports follow */ /* src ports; max of 10 ports in all; */ /* count of 0 means match all ports) */ - void *pipe_ptr; /* Pipe ptr in case of dummynet pipe */ - void *next_rule_ptr ; /* next rule in case of match */ }; #define IP_FW_GETNSRCP(rule) ((rule)->fw_nports & 0x0f) @@ -97,7 +94,6 @@ struct ip_fw { #define fw_divert_port fw_un.fu_divert_port #define fw_skipto_rule fw_un.fu_skipto_rule #define fw_reject_code fw_un.fu_reject_code -#define fw_pipe_nr fw_un.fu_pipe_nr #define fw_fwd_ip fw_un.fu_fwd_ip struct ip_fw_chain { @@ -117,7 +113,6 @@ struct ip_fw_chain { #define IP_FW_F_TEE 0x00000005 /* This is a tee rule */ #define IP_FW_F_SKIPTO 0x00000006 /* This is a skipto rule */ #define IP_FW_F_FWD 0x00000007 /* This is a "change forwarding address" rule */ -#define IP_FW_F_PIPE 0x00000008 /* This is a dummynet rule */ #define IP_FW_F_IN 0x00000100 /* Check inbound packets */ #define IP_FW_F_OUT 0x00000200 /* Check outbound packets */ @@ -193,7 +188,7 @@ void ip_fw_init __P((void)); struct ip; struct sockopt; typedef int ip_fw_chk_t __P((struct ip **, int, struct ifnet *, u_int16_t *, - struct mbuf **, struct ip_fw_chain **, struct sockaddr_in **)); + struct mbuf **, struct sockaddr_in **)); typedef int ip_fw_ctl_t __P((struct sockopt *)); extern ip_fw_chk_t *ip_fw_chk_ptr; extern ip_fw_ctl_t *ip_fw_ctl_ptr; diff --git a/sys/netinet/ip_icmp.c b/sys/netinet/ip_icmp.c index d4eb5ca816dd..186b8e676774 100644 --- a/sys/netinet/ip_icmp.c +++ b/sys/netinet/ip_icmp.c @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)ip_icmp.c 8.2 (Berkeley) 1/4/94 - * $Id: ip_icmp.c,v 1.32 1998/12/03 20:23:20 dillon Exp $ + * $Id: ip_icmp.c,v 1.30 1998/05/26 11:34:30 dg Exp $ */ #include <sys/param.h> @@ -69,33 +69,10 @@ static int icmpmaskrepl = 0; SYSCTL_INT(_net_inet_icmp, ICMPCTL_MASKREPL, maskrepl, CTLFLAG_RW, &icmpmaskrepl, 0, ""); -#ifdef ICMP_BANDLIM - -/* - * ICMP error-response bandwidth limiting sysctl. If not enabled, sysctl - * variable content is -1 and read-only. - */ - -static int icmplim = 100; -SYSCTL_INT(_net_inet_icmp, ICMPCTL_ICMPLIM, icmplim, CTLFLAG_RW, - &icmplim, 0, ""); -#else - -static int icmplim = -1; -SYSCTL_INT(_net_inet_icmp, ICMPCTL_ICMPLIM, icmplim, CTLFLAG_RD, - &icmplim, 0, ""); - -#endif - -/* - * ICMP broadcast echo sysctl - */ - static int icmpbmcastecho = 0; SYSCTL_INT(_net_inet_icmp, OID_AUTO, bmcastecho, CTLFLAG_RW, &icmpbmcastecho, 0, ""); - #ifdef ICMPPRINTFS int icmpprintfs = 0; #endif @@ -727,69 +704,3 @@ ip_next_mtu(mtu, dir) } } #endif - -#ifdef ICMP_BANDLIM - -/* - * badport_bandlim() - check for ICMP bandwidth limit - * - * Return 0 if it is ok to send an ICMP error response, -1 if we have - * hit our bandwidth limit and it is not ok. - * - * If icmplim is <= 0, the feature is disabled and 0 is returned. - * - * For now we separate the TCP and UDP subsystems w/ different 'which' - * values. We may eventually remove this separation (and simplify the - * code further). - * - * Note that the printing of the error message is delayed so we can - * properly print the icmp error rate that the system was trying to do - * (i.e. 22000/100 pps, etc...). This can cause long delays in printing - * the 'final' error, but it doesn't make sense to solve the printing - * delay with more complex code. - */ - -int -badport_bandlim(int which) -{ - static int lticks[2]; - static int lpackets[2]; - int dticks; - - /* - * Return ok status if feature disabled or argument out of - * ranage. - */ - - if (icmplim <= 0 || which >= 2 || which < 0) - return(0); - dticks = ticks - lticks[which]; - - /* - * reset stats when cumulative dt exceeds one second. - */ - - if ((unsigned int)dticks > hz) { - if (lpackets[which] > icmplim) { - printf("icmp-response bandwidth limit %d/%d pps\n", - lpackets[which], - icmplim - ); - } - lticks[which] = ticks; - lpackets[which] = 0; - } - - /* - * bump packet count - */ - - if (++lpackets[which] > icmplim) { - return(-1); - } - return(0); -} - -#endif - - diff --git a/sys/netinet/ip_input.c b/sys/netinet/ip_input.c index d6cc0d532469..18f9fe209edb 100644 --- a/sys/netinet/ip_input.c +++ b/sys/netinet/ip_input.c @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)ip_input.c 8.2 (Berkeley) 1/4/94 - * $Id: ip_input.c,v 1.110 1998/12/21 22:40:54 luigi Exp $ + * $Id: ip_input.c,v 1.101 1998/09/10 08:56:40 dfr Exp $ * $ANA: ip_input.c,v 1.5 1996/09/18 14:34:59 wollman Exp $ */ @@ -39,7 +39,6 @@ #include "opt_bootp.h" #include "opt_ipfw.h" -#include "opt_ipdn.h" #include "opt_ipdivert.h" #include "opt_ipfilter.h" @@ -48,7 +47,6 @@ #include <sys/param.h> #include <sys/systm.h> #include <sys/mbuf.h> -#include <sys/malloc.h> #include <sys/domain.h> #include <sys/protosw.h> #include <sys/socket.h> @@ -78,10 +76,6 @@ #include <netinet/ip_fw.h> #endif -#ifdef DUMMYNET -#include <netinet/ip_dummynet.h> -#endif - int rsvp_on = 0; static int ip_rsvp_on; struct socket *ip_rsvpd; @@ -155,10 +149,6 @@ SYSCTL_INT(_net_inet_ip, IPCTL_DEFMTU, mtu, CTLFLAG_RW, ip_fw_chk_t *ip_fw_chk_ptr; ip_fw_ctl_t *ip_fw_ctl_ptr; -#ifdef DUMMYNET -ip_dn_ctl_t *ip_dn_ctl_ptr; -#endif - /* IP Network Address Translation (NAT) hooks */ ip_nat_t *ip_nat_ptr; ip_nat_ctl_t *ip_nat_ctl_ptr; @@ -234,9 +224,6 @@ ip_init() ip_id = time_second & 0xffff; ipintrq.ifq_maxlen = ipqmaxlen; -#ifdef DUMMYNET - ip_dn_init(); -#endif #ifdef IPNAT ip_nat_init(); #endif @@ -258,33 +245,10 @@ ip_input(struct mbuf *m) { struct ip *ip; struct ipq *fp; + struct ipqent *ipqe; struct in_ifaddr *ia; int i, hlen, mff; u_short sum; -#ifndef IPDIVERT /* dummy variable for the firewall code to play with */ - u_short ip_divert_cookie = 0 ; -#endif -#ifdef COMPAT_IPFW - struct ip_fw_chain *rule = NULL ; -#endif - -#if defined(IPFIREWALL) && defined(DUMMYNET) - /* - * dummynet packet are prepended a vestigial mbuf with - * m_type = MT_DUMMYNET and m_data pointing to the matching - * rule. - */ - if (m->m_type == MT_DUMMYNET) { - struct mbuf *m0 = m ; - rule = (struct ip_fw_chain *)(m->m_data) ; - m = m->m_next ; - free(m0, M_IPFW); - ip = mtod(m, struct ip *); - hlen = IP_VHL_HL(ip->ip_vhl) << 2; - goto iphack ; - } else - rule = NULL ; -#endif #ifdef DIAGNOSTIC if (m == NULL || (m->m_flags & M_PKTHDR) == 0) @@ -373,14 +337,9 @@ tooshort: * deals with it. * - Firewall: deny/allow/divert * - Xlate: translate packet's addr/port (NAT). - * - Pipe: pass pkt through dummynet. * - Wrap: fake packet's addr/port <unimpl.> * - Encapsulate: put it in another IP and send out. <unimp.> */ - -#if defined(IPFIREWALL) && defined(DUMMYNET) -iphack: -#endif #if defined(IPFILTER) || defined(IPFILTER_LKM) /* * Check if we want to allow this packet to be processed. @@ -396,6 +355,8 @@ iphack: #endif #ifdef COMPAT_IPFW if (ip_fw_chk_ptr) { + u_int16_t port; + #ifdef IPFIREWALL_FORWARD /* * If we've been forwarded from the output side, then @@ -404,41 +365,29 @@ iphack: if (ip_fw_fwd_addr) goto ours; #endif /* IPFIREWALL_FORWARD */ - i = (*ip_fw_chk_ptr)(&ip, hlen, NULL, &ip_divert_cookie, - &m, &rule, &ip_fw_fwd_addr); - /* - * see the comment in ip_output for the return values - * produced by the firewall. - */ - if (!m) /* packet discarded by firewall */ - return ; - if (i == 0 && ip_fw_fwd_addr == NULL) /* common case */ - goto pass ; -#ifdef DUMMYNET - if (i & 0x10000) { - /* send packet to the appropriate pipe */ - dummynet_io(i&0xffff,DN_TO_IP_IN,m,NULL,NULL,0, rule); - return ; - } -#endif #ifdef IPDIVERT - if (i > 0 && i < 0x10000) { + port = (*ip_fw_chk_ptr)(&ip, hlen, NULL, &ip_divert_cookie, + &m, &ip_fw_fwd_addr); + if (port) { /* Divert packet */ - frag_divert_port = i & 0xffff ; + frag_divert_port = port; goto ours; } -#endif -#ifdef IPFIREWALL_FORWARD - if (i == 0 && ip_fw_fwd_addr != NULL) - goto pass ; -#endif +#else /* !DIVERT */ /* - * if we get here, the packet must be dropped + * If ipfw says divert, we have to just drop packet + * Use port as a dummy argument. */ + port = 0; + if ((*ip_fw_chk_ptr)(&ip, hlen, NULL, &port, + &m, &ip_fw_fwd_addr)) { m_freem(m); + m = NULL; + } +#endif /* !DIVERT */ + if (!m) return; } -pass: if (ip_nat_ptr && !(*ip_nat_ptr)(&ip, &m, m->m_pkthdr.rcvif, IP_NAT_IN)) return; @@ -564,7 +513,7 @@ ours: */ if (ip->ip_off & (IP_MF | IP_OFFMASK | IP_RF)) { if (m->m_flags & M_EXT) { /* XXX */ - if ((m = m_pullup(m, hlen)) == 0) { + if ((m = m_pullup(m, sizeof (struct ip))) == 0) { ipstat.ips_toosmall++; #ifdef IPDIVERT frag_divert_port = 0; @@ -762,13 +711,13 @@ ip_reass(m, fp, where) fp->ipq_id = ip->ip_id; fp->ipq_src = ip->ip_src; fp->ipq_dst = ip->ip_dst; - fp->ipq_frags = m; - m->m_nextpkt = NULL; + fp->ipq_frags = 0; #ifdef IPDIVERT fp->ipq_divert = 0; fp->ipq_div_cookie = 0; #endif - goto inserted; + q = 0; + goto insert; } #define GETIP(m) ((struct ip*)((m)->m_pkthdr.header)) @@ -783,8 +732,7 @@ ip_reass(m, fp, where) /* * If there is a preceding segment, it may provide some of * our data already. If so, drop the data from the incoming - * segment. If it provides all of our data, drop us, otherwise - * stick new segment in the proper place. + * segment. If it provides all of our data, drop us. */ if (p) { i = GETIP(p)->ip_off + GETIP(p)->ip_len - ip->ip_off; @@ -795,11 +743,6 @@ ip_reass(m, fp, where) ip->ip_off += i; ip->ip_len -= i; } - m->m_nextpkt = p->m_nextpkt; - p->m_nextpkt = m; - } else { - m->m_nextpkt = fp->ipq_frags; - fp->ipq_frags = m; } /* @@ -807,7 +750,7 @@ ip_reass(m, fp, where) * if they are completely covered, dequeue them. */ for (; q != NULL && ip->ip_off + ip->ip_len > GETIP(q)->ip_off; - q = nq) { + p = q, q = nq) { i = (ip->ip_off + ip->ip_len) - GETIP(q)->ip_off; if (i < GETIP(q)->ip_len) { @@ -817,11 +760,14 @@ ip_reass(m, fp, where) break; } nq = q->m_nextpkt; - m->m_nextpkt = nq; + if (p) + p->m_nextpkt = nq; + else + fp->ipq_frags = nq; m_freem(q); } -inserted: +insert: #ifdef IPDIVERT /* @@ -836,8 +782,16 @@ inserted: #endif /* - * Check for complete reassembly. + * Stick new segment in its place; + * check for complete reassembly. */ + if (p == NULL) { + m->m_nextpkt = fp->ipq_frags; + fp->ipq_frags = m; + } else { + m->m_nextpkt = p->m_nextpkt; + p->m_nextpkt = m; + } next = 0; for (p = NULL, q = fp->ipq_frags; q; p = q, q = q->m_nextpkt) { if (GETIP(q)->ip_off != next) @@ -1293,7 +1247,7 @@ ip_srcroute() *(mtod(m, struct in_addr *)) = *p--; #ifdef DIAGNOSTIC if (ipprintfs) - printf(" hops %lx", (u_long)ntohl(mtod(m, struct in_addr *)->s_addr)); + printf(" hops %lx", ntohl(mtod(m, struct in_addr *)->s_addr)); #endif /* @@ -1313,7 +1267,7 @@ ip_srcroute() while (p >= ip_srcrt.route) { #ifdef DIAGNOSTIC if (ipprintfs) - printf(" %lx", (u_long)ntohl(q->s_addr)); + printf(" %lx", ntohl(q->s_addr)); #endif *q++ = *p--; } @@ -1323,7 +1277,7 @@ ip_srcroute() *q = ip_srcrt.dst; #ifdef DIAGNOSTIC if (ipprintfs) - printf(" %lx\n", (u_long)ntohl(q->s_addr)); + printf(" %lx\n", ntohl(q->s_addr)); #endif return (m); } diff --git a/sys/netinet/ip_log.c b/sys/netinet/ip_log.c index 8a826ed2985c..2d789154a46a 100644 --- a/sys/netinet/ip_log.c +++ b/sys/netinet/ip_log.c @@ -5,7 +5,7 @@ * provided that this notice is preserved and due credit is given * to the original author and the contributors. * - * $Id: ip_log.c,v 1.5 1998/11/26 18:54:52 eivind Exp $ + * $Id: ip_log.c,v 1.3 1998/03/21 14:42:45 peter Exp $ */ #include "opt_ipfilter.h" @@ -122,8 +122,8 @@ extern kcondvar_t iplwait; iplog_t **iplh[IPL_LOGMAX+1], *iplt[IPL_LOGMAX+1]; int iplused[IPL_LOGMAX+1]; -static u_long iplcrc[IPL_LOGMAX+1]; -static u_long iplcrcinit; +u_long iplcrc[IPL_LOGMAX+1]; +u_long iplcrcinit; #ifdef linux static struct wait_queue *iplwait[IPL_LOGMAX+1]; #endif @@ -135,6 +135,7 @@ static struct wait_queue *iplwait[IPL_LOGMAX+1]; */ void ipflog_init() { + struct timeval tv; int i; for (i = IPL_LOGMAX; i >= 0; i--) { @@ -145,16 +146,12 @@ void ipflog_init() # if defined(__FreeBSD__) && __FreeBSD_version >= 300000 read_random(&iplcrcinit, sizeof iplcrcinit); # else - { - struct timeval tv; - #if BSD >= 199306 || defined(__FreeBSD__) || defined(__sgi) - microtime(&tv); + microtime(&tv); # else - uniqtime(&tv); + uniqtime(&tv); # endif - iplcrcinit = tv.tv_sec ^ (tv.tv_usec << 8) ^ tv.tv_usec; - } + iplcrcinit = tv.tv_sec ^ (tv.tv_usec << 8) ^ tv.tv_usec; # endif } diff --git a/sys/netinet/ip_mroute.c b/sys/netinet/ip_mroute.c index 65bfecfaf0a9..3c11f8247274 100644 --- a/sys/netinet/ip_mroute.c +++ b/sys/netinet/ip_mroute.c @@ -9,14 +9,13 @@ * Modified by Bill Fenner, PARC, April 1995 * * MROUTING Revision: 3.5 - * $Id: ip_mroute.c,v 1.52 1999/01/12 12:16:50 eivind Exp $ + * $Id: ip_mroute.c,v 1.48 1998/08/17 01:05:24 bde Exp $ */ #include "opt_mrouting.h" #include <sys/param.h> #include <sys/systm.h> -#include <sys/malloc.h> #include <sys/mbuf.h> #include <sys/socket.h> #include <sys/socketvar.h> @@ -64,6 +63,8 @@ extern int _mrt_ioctl __P((int req, caddr_t data, struct proc *p)); */ struct socket *ip_mrouter = NULL; +static u_int ip_mrtproto = 0; +static struct mrtstat mrtstat; u_int rsvpdebug = 0; int @@ -186,7 +187,7 @@ ip_rsvp_force_done(so) #define same(a1, a2) \ (bcmp((caddr_t)(a1), (caddr_t)(a2), INSIZ) == 0) -static MALLOC_DEFINE(M_MRTABLE, "mroutetbl", "multicast routing tables"); +#define MT_MRTABLE MT_RTABLE /* since nothing else uses it */ /* * Globals. All but ip_mrouter and ip_mrtproto could be static, @@ -195,6 +196,8 @@ static MALLOC_DEFINE(M_MRTABLE, "mroutetbl", "multicast routing tables"); #ifndef MROUTE_LKM struct socket *ip_mrouter = NULL; static struct mrtstat mrtstat; + +static int ip_mrtproto = IGMP_DVMRP; /* for netstat only */ #else /* MROUTE_LKM */ extern void X_ipip_input __P((struct mbuf *m, int iphlen)); extern struct mrtstat mrtstat; @@ -204,7 +207,7 @@ static int ip_mrtproto; #define NO_RTE_FOUND 0x1 #define RTE_FOUND 0x2 -static struct mfc *mfctable[MFCTBLSIZ]; +static struct mbuf *mfctable[MFCTBLSIZ]; static u_char nexpire[MFCTBLSIZ]; static struct vif viftable[MAXVIFS]; static u_int mrtdebug = 0; /* debug level */ @@ -322,17 +325,19 @@ static int pim_assert; */ #define MFCFIND(o, g, rt) { \ - register struct mfc *_rt = mfctable[MFCHASH(o,g)]; \ + register struct mbuf *_mb_rt = mfctable[MFCHASH(o,g)]; \ + register struct mfc *_rt = NULL; \ rt = NULL; \ ++mrtstat.mrts_mfc_lookups; \ - while (_rt) { \ + while (_mb_rt) { \ + _rt = mtod(_mb_rt, struct mfc *); \ if ((_rt->mfc_origin.s_addr == o) && \ (_rt->mfc_mcastgrp.s_addr == g) && \ - (_rt->mfc_stall == NULL)) { \ + (_mb_rt->m_act == NULL)) { \ rt = _rt; \ break; \ } \ - _rt = _rt->mfc_next; \ + _mb_rt = _mb_rt->m_next; \ } \ if (rt == NULL) { \ ++mrtstat.mrts_mfc_misses; \ @@ -424,7 +429,6 @@ X_ip_mrouter_set(so, sopt) error = add_mfc(&mfc); else error = del_mfc(&mfc); - break; case MRT_ASSERT: error = sooptcopyin(sopt, &optval, sizeof optval, @@ -432,7 +436,6 @@ X_ip_mrouter_set(so, sopt) if (error) break; set_assert(optval); - break; default: error = EOPNOTSUPP; @@ -553,6 +556,8 @@ ip_mrouter_init(so, version) struct socket *so; int version; { + int *v; + if (mrtdebug) log(LOG_DEBUG,"ip_mrouter_init: so_type = %d, pr_protocol = %d\n", so->so_type, so->so_proto->pr_protocol); @@ -590,7 +595,8 @@ X_ip_mrouter_done() int i; struct ifnet *ifp; struct ifreq ifr; - struct mfc *rt; + struct mbuf *mb_rt; + struct mbuf *m; struct rtdetq *rte; int s; @@ -621,18 +627,18 @@ X_ip_mrouter_done() * Free all multicast forwarding cache entries. */ for (i = 0; i < MFCTBLSIZ; i++) { - for (rt = mfctable[i]; rt != NULL; ) { - struct mfc *nr = rt->mfc_next; - - for (rte = rt->mfc_stall; rte != NULL; ) { - struct rtdetq *n = rte->next; - - m_freem(rte->m); - free(rte, M_MRTABLE); - rte = n; + mb_rt = mfctable[i]; + while (mb_rt) { + if (mb_rt->m_act != NULL) { + while (mb_rt->m_act) { + m = mb_rt->m_act; + mb_rt->m_act = m->m_act; + rte = mtod(m, struct rtdetq *); + m_freem(rte->m); + m_free(m); + } } - free(rt, M_MRTABLE); - rt = nr; + mb_rt = m_free(mb_rt); } } @@ -685,6 +691,7 @@ add_vif(vifcp) static struct sockaddr_in sin = {sizeof sin, AF_INET}; struct ifaddr *ifa; struct ifnet *ifp; + struct ifreq ifr; int error, s; struct tbf *v_tbf = tbftable + vifcp->vifc_vifi; @@ -838,7 +845,9 @@ add_mfc(mfccp) struct mfcctl *mfccp; { struct mfc *rt; + register struct mbuf *mb_rt; u_long hash; + struct mbuf *mb_ntry; struct rtdetq *rte; register u_short nstl; int s; @@ -867,24 +876,25 @@ add_mfc(mfccp) */ s = splnet(); hash = MFCHASH(mfccp->mfcc_origin.s_addr, mfccp->mfcc_mcastgrp.s_addr); - for (rt = mfctable[hash], nstl = 0; rt; rt = rt->mfc_next) { + for (mb_rt = mfctable[hash], nstl = 0; mb_rt; mb_rt = mb_rt->m_next) { + rt = mtod(mb_rt, struct mfc *); if ((rt->mfc_origin.s_addr == mfccp->mfcc_origin.s_addr) && (rt->mfc_mcastgrp.s_addr == mfccp->mfcc_mcastgrp.s_addr) && - (rt->mfc_stall != NULL)) { + (mb_rt->m_act != NULL)) { if (nstl++) log(LOG_ERR, "add_mfc %s o %lx g %lx p %x dbx %p\n", "multiple kernel entries", (u_long)ntohl(mfccp->mfcc_origin.s_addr), (u_long)ntohl(mfccp->mfcc_mcastgrp.s_addr), - mfccp->mfcc_parent, (void *)rt->mfc_stall); + mfccp->mfcc_parent, (void *)mb_rt->m_act); if (mrtdebug & DEBUG_MFC) log(LOG_DEBUG,"add_mfc o %lx g %lx p %x dbg %p\n", (u_long)ntohl(mfccp->mfcc_origin.s_addr), (u_long)ntohl(mfccp->mfcc_mcastgrp.s_addr), - mfccp->mfcc_parent, (void *)rt->mfc_stall); + mfccp->mfcc_parent, (void *)mb_rt->m_act); rt->mfc_origin = mfccp->mfcc_origin; rt->mfc_mcastgrp = mfccp->mfcc_mcastgrp; @@ -901,18 +911,19 @@ add_mfc(mfccp) nexpire[hash]--; /* free packets Qed at the end of this entry */ - for (rte = rt->mfc_stall; rte != NULL; ) { - struct rtdetq *n = rte->next; - + while (mb_rt->m_act) { + mb_ntry = mb_rt->m_act; + rte = mtod(mb_ntry, struct rtdetq *); +/* #ifdef RSVP_ISI */ ip_mdq(rte->m, rte->ifp, rt, -1); +/* #endif */ + mb_rt->m_act = mb_ntry->m_act; m_freem(rte->m); #ifdef UPCALL_TIMING collate(&(rte->t)); #endif /* UPCALL_TIMING */ - free(rte, M_MRTABLE); - rte = n; + m_free(mb_ntry); } - rt->mfc_stall = NULL; } } @@ -926,8 +937,9 @@ add_mfc(mfccp) (u_long)ntohl(mfccp->mfcc_mcastgrp.s_addr), mfccp->mfcc_parent); - for (rt = mfctable[hash]; rt != NULL; rt = rt->mfc_next) { + for (mb_rt = mfctable[hash]; mb_rt; mb_rt = mb_rt->m_next) { + rt = mtod(mb_rt, struct mfc *); if ((rt->mfc_origin.s_addr == mfccp->mfcc_origin.s_addr) && (rt->mfc_mcastgrp.s_addr == mfccp->mfcc_mcastgrp.s_addr)) { @@ -946,14 +958,16 @@ add_mfc(mfccp) rt->mfc_expire = 0; } } - if (rt == NULL) { + if (mb_rt == NULL) { /* no upcall, so make a new entry */ - rt = (struct mfc *)malloc(sizeof(*rt), M_MRTABLE, M_NOWAIT); - if (rt == NULL) { + MGET(mb_rt, M_DONTWAIT, MT_MRTABLE); + if (mb_rt == NULL) { splx(s); return ENOBUFS; } + rt = mtod(mb_rt, struct mfc *); + /* insert new entry at head of hash chain */ rt->mfc_origin = mfccp->mfcc_origin; rt->mfc_mcastgrp = mfccp->mfcc_mcastgrp; @@ -966,11 +980,11 @@ add_mfc(mfccp) rt->mfc_wrong_if = 0; rt->mfc_last_assert.tv_sec = rt->mfc_last_assert.tv_usec = 0; rt->mfc_expire = 0; - rt->mfc_stall = NULL; /* link into table */ - rt->mfc_next = mfctable[hash]; - mfctable[hash] = rt; + mb_rt->m_next = mfctable[hash]; + mfctable[hash] = mb_rt; + mb_rt->m_act = NULL; } } splx(s); @@ -1013,7 +1027,8 @@ del_mfc(mfccp) struct in_addr origin; struct in_addr mcastgrp; struct mfc *rt; - struct mfc **nptr; + struct mbuf *mb_rt; + struct mbuf **nptr; u_long hash; int s; @@ -1028,21 +1043,21 @@ del_mfc(mfccp) s = splnet(); nptr = &mfctable[hash]; - while ((rt = *nptr) != NULL) { + while ((mb_rt = *nptr) != NULL) { + rt = mtod(mb_rt, struct mfc *); if (origin.s_addr == rt->mfc_origin.s_addr && mcastgrp.s_addr == rt->mfc_mcastgrp.s_addr && - rt->mfc_stall == NULL) + mb_rt->m_act == NULL) break; - nptr = &rt->mfc_next; + nptr = &mb_rt->m_next; } - if (rt == NULL) { + if (mb_rt == NULL) { splx(s); return EADDRNOTAVAIL; } - *nptr = rt->mfc_next; - free(rt, M_MRTABLE); + MFREE(mb_rt, *nptr); splx(s); @@ -1168,9 +1183,13 @@ X_ip_mforward(ip, ifp, m, imo) * send message to routing daemon */ + register struct mbuf *mb_rt; + register struct mbuf *mb_ntry; register struct mbuf *mb0; register struct rtdetq *rte; + register struct mbuf *rte_m; register u_long hash; + register int npkts; int hlen = ip->ip_hl << 2; #ifdef UPCALL_TIMING struct timeval tp; @@ -1189,8 +1208,8 @@ X_ip_mforward(ip, ifp, m, imo) * just going to fail anyway. Make sure to pullup the header so * that other people can't step on it. */ - rte = (struct rtdetq *)malloc((sizeof *rte), M_MRTABLE, M_NOWAIT); - if (rte == NULL) { + MGET(mb_ntry, M_DONTWAIT, MT_DATA); + if (mb_ntry == NULL) { splx(s); return ENOBUFS; } @@ -1198,28 +1217,29 @@ X_ip_mforward(ip, ifp, m, imo) if (mb0 && (M_HASCL(mb0) || mb0->m_len < hlen)) mb0 = m_pullup(mb0, hlen); if (mb0 == NULL) { - free(rte, M_MRTABLE); + m_free(mb_ntry); splx(s); return ENOBUFS; } /* is there an upcall waiting for this packet? */ hash = MFCHASH(ip->ip_src.s_addr, ip->ip_dst.s_addr); - for (rt = mfctable[hash]; rt; rt = rt->mfc_next) { + for (mb_rt = mfctable[hash]; mb_rt; mb_rt = mb_rt->m_next) { + rt = mtod(mb_rt, struct mfc *); if ((ip->ip_src.s_addr == rt->mfc_origin.s_addr) && (ip->ip_dst.s_addr == rt->mfc_mcastgrp.s_addr) && - (rt->mfc_stall != NULL)) + (mb_rt->m_act != NULL)) break; } - if (rt == NULL) { + if (mb_rt == NULL) { int i; struct igmpmsg *im; /* no upcall, so make a new entry */ - rt = (struct mfc *)malloc(sizeof(*rt), M_MRTABLE, M_NOWAIT); - if (rt == NULL) { - free(rte, M_MRTABLE); + MGET(mb_rt, M_DONTWAIT, MT_MRTABLE); + if (mb_rt == NULL) { + m_free(mb_ntry); m_freem(mb0); splx(s); return ENOBUFS; @@ -1227,9 +1247,9 @@ X_ip_mforward(ip, ifp, m, imo) /* Make a copy of the header to send to the user level process */ mm = m_copy(mb0, 0, hlen); if (mm == NULL) { - free(rte, M_MRTABLE); + m_free(mb_ntry); m_freem(mb0); - free(rt, M_MRTABLE); + m_free(mb_rt); splx(s); return ENOBUFS; } @@ -1249,13 +1269,15 @@ X_ip_mforward(ip, ifp, m, imo) if (socket_send(ip_mrouter, mm, &k_igmpsrc) < 0) { log(LOG_WARNING, "ip_mforward: ip_mrouter socket queue full\n"); ++mrtstat.mrts_upq_sockfull; - free(rte, M_MRTABLE); + m_free(mb_ntry); m_freem(mb0); - free(rt, M_MRTABLE); + m_free(mb_rt); splx(s); return ENOBUFS; } + rt = mtod(mb_rt, struct mfc *); + /* insert new entry at head of hash chain */ rt->mfc_origin.s_addr = ip->ip_src.s_addr; rt->mfc_mcastgrp.s_addr = ip->ip_dst.s_addr; @@ -1266,36 +1288,36 @@ X_ip_mforward(ip, ifp, m, imo) rt->mfc_parent = -1; /* link into table */ - rt->mfc_next = mfctable[hash]; - mfctable[hash] = rt; - rt->mfc_stall = rte; + mb_rt->m_next = mfctable[hash]; + mfctable[hash] = mb_rt; + mb_rt->m_act = NULL; + rte_m = mb_rt; } else { /* determine if q has overflowed */ - int npkts = 0; - struct rtdetq **p; - - for (p = &rt->mfc_stall; *p != NULL; p = &(*p)->next) + for (rte_m = mb_rt, npkts = 0; rte_m->m_act; rte_m = rte_m->m_act) npkts++; if (npkts > MAX_UPQ) { mrtstat.mrts_upq_ovflw++; - free(rte, M_MRTABLE); + m_free(mb_ntry); m_freem(mb0); splx(s); return 0; } - - /* Add this entry to the end of the queue */ - *p = rte; } + mb_ntry->m_act = NULL; + rte = mtod(mb_ntry, struct rtdetq *); + rte->m = mb0; rte->ifp = ifp; #ifdef UPCALL_TIMING rte->t = tp; #endif - rte->next = NULL; + + /* Add this entry to the end of the queue */ + rte_m->m_act = mb_ntry; splx(s); @@ -1314,8 +1336,9 @@ int (*ip_mforward)(struct ip *, struct ifnet *, struct mbuf *, static void expire_upcalls(void *unused) { + struct mbuf *mb_rt, *m, **nptr; struct rtdetq *rte; - struct mfc *mfc, **nptr; + struct mfc *mfc; int i; int s; @@ -1324,13 +1347,15 @@ expire_upcalls(void *unused) if (nexpire[i] == 0) continue; nptr = &mfctable[i]; - for (mfc = *nptr; mfc != NULL; mfc = *nptr) { + for (mb_rt = *nptr; mb_rt != NULL; mb_rt = *nptr) { + mfc = mtod(mb_rt, struct mfc *); + /* * Skip real cache entries * Make sure it wasn't marked to not expire (shouldn't happen) * If it expires now */ - if (mfc->mfc_stall != NULL && + if (mb_rt->m_act != NULL && mfc->mfc_expire != 0 && --mfc->mfc_expire == 0) { if (mrtdebug & DEBUG_EXPIRE) @@ -1341,20 +1366,20 @@ expire_upcalls(void *unused) * drop all the packets * free the mbuf with the pkt, if, timing info */ - for (rte = mfc->mfc_stall; rte; ) { - struct rtdetq *n = rte->next; - + while (mb_rt->m_act) { + m = mb_rt->m_act; + mb_rt->m_act = m->m_act; + + rte = mtod(m, struct rtdetq *); m_freem(rte->m); - free(rte, M_MRTABLE); - rte = n; + m_free(m); } ++mrtstat.mrts_cache_cleanups; nexpire[i]--; - *nptr = mfc->mfc_next; - free(mfc, M_MRTABLE); + MFREE(mb_rt, *nptr); } else { - nptr = &mfc->mfc_next; + nptr = &mb_rt->m_next; } } } @@ -1535,7 +1560,7 @@ phyint_send(ip, vifp, m) if (mb_copy == NULL) return; - if (vifp->v_rate_limit == 0) + if (vifp->v_rate_limit <= 0) tbf_send_packet(vifp, mb_copy); else tbf_control(vifp, mb_copy, mtod(mb_copy, struct ip *), ip->ip_len); @@ -1596,7 +1621,7 @@ encap_send(ip, vifp, m) ip->ip_sum = in_cksum(mb_copy, ip->ip_hl << 2); mb_copy->m_data -= sizeof(multicast_encap_iphdr); - if (vifp->v_rate_limit == 0) + if (vifp->v_rate_limit <= 0) tbf_send_packet(vifp, mb_copy); else tbf_control(vifp, mb_copy, ip, ip_copy->ip_len); diff --git a/sys/netinet/ip_mroute.h b/sys/netinet/ip_mroute.h index 0526bbb18f75..94ddeac0608a 100644 --- a/sys/netinet/ip_mroute.h +++ b/sys/netinet/ip_mroute.h @@ -35,7 +35,7 @@ * SUCH DAMAGE. * * @(#)ip_mroute.h 8.1 (Berkeley) 6/10/93 - * $Id: ip_mroute.h,v 1.14 1998/08/23 03:07:14 wollman Exp $ + * $Id: ip_mroute.h,v 1.13 1997/02/22 09:41:35 peter Exp $ */ #ifndef _NETINET_IP_MROUTE_H_ @@ -188,8 +188,6 @@ struct mfc { u_long mfc_wrong_if; /* wrong if for src-grp */ int mfc_expire; /* time to clean entry up */ struct timeval mfc_last_assert; /* last time I sent an assert*/ - struct rtdetq *mfc_stall; /* q of packets awaiting mfc */ - struct mfc *mfc_next; /* next mfc entry */ }; /* @@ -218,7 +216,6 @@ struct rtdetq { #ifdef UPCALL_TIMING struct timeval t; /* Timestamp */ #endif /* UPCALL_TIMING */ - struct rtdetq *next; /* Next in list of packets */ }; #define MFCTBLSIZ 256 diff --git a/sys/netinet/ip_nat.c b/sys/netinet/ip_nat.c index 243c8bb19144..673e1f3a80b8 100644 --- a/sys/netinet/ip_nat.c +++ b/sys/netinet/ip_nat.c @@ -9,7 +9,7 @@ */ #if !defined(lint) static const char sccsid[] = "@(#)ip_nat.c 1.11 6/5/96 (C) 1995 Darren Reed"; -static const char rcsid[] = "@(#)$Id: ip_nat.c,v 1.4 1998/08/15 21:51:53 bde Exp $"; +static const char rcsid[] = "@(#)$Id: ip_nat.c,v 1.3 1998/06/20 18:37:50 peter Exp $"; #endif #include "opt_ipfilter.h" @@ -103,11 +103,11 @@ extern struct ifnet vpnif; #undef SOCKADDR_IN #define SOCKADDR_IN struct sockaddr_in - nat_t *nat_table[2][NAT_SIZE], *nat_instances = NULL; -static ipnat_t *nat_list = NULL; +nat_t *nat_table[2][NAT_SIZE], *nat_instances = NULL; +ipnat_t *nat_list = NULL; u_long fr_defnatage = 1200, /* 10 minutes (600 seconds) */ fr_defnaticmpage = 6; /* 3 seconds */ -static natstat_t nat_stats; +natstat_t nat_stats; #if (SOLARIS || defined(__sgi)) && defined(_KERNEL) extern kmutex_t ipf_nat; #endif diff --git a/sys/netinet/ip_output.c b/sys/netinet/ip_output.c index a180e401b8de..be7722885a65 100644 --- a/sys/netinet/ip_output.c +++ b/sys/netinet/ip_output.c @@ -31,19 +31,17 @@ * SUCH DAMAGE. * * @(#)ip_output.c 8.3 (Berkeley) 1/21/94 - * $Id: ip_output.c,v 1.84 1998/12/14 18:09:13 luigi Exp $ + * $Id: ip_output.c,v 1.81 1998/08/23 03:07:14 wollman Exp $ */ #define _IP_VHL #include "opt_ipfw.h" -#include "opt_ipdn.h" #include "opt_ipdivert.h" #include "opt_ipfilter.h" #include <sys/param.h> #include <sys/systm.h> -#include <sys/kernel.h> #include <sys/malloc.h> #include <sys/mbuf.h> #include <sys/protosw.h> @@ -78,10 +76,6 @@ static MALLOC_DEFINE(M_IPMOPTS, "ip_moptions", "internet multicast options"); #include <netinet/ip_fw.h> #endif -#ifdef DUMMYNET -#include <netinet/ip_dummynet.h> -#endif - #ifdef IPFIREWALL_FORWARD_DEBUG #define print_ip(a) printf("%ld.%ld.%ld.%ld",(ntohl(a.s_addr)>>24)&0xFF,\ (ntohl(a.s_addr)>>16)&0xFF,\ @@ -136,41 +130,6 @@ ip_output(m0, opt, ro, flags, imo) int fwd_rewrite_src = 0; #endif -#ifndef IPDIVERT /* dummy variable for the firewall code to play with */ - u_short ip_divert_cookie = 0 ; -#endif -#ifdef COMPAT_IPFW - struct ip_fw_chain *rule = NULL ; -#endif - -#if defined(IPFIREWALL) && defined(DUMMYNET) - /* - * dummynet packet are prepended a vestigial mbuf with - * m_type = MT_DUMMYNET and m_data pointing to the matching - * rule. - */ - if (m->m_type == MT_DUMMYNET) { - struct mbuf *tmp_m = m ; - /* - * the packet was already tagged, so part of the - * processing was already done, and we need to go down. - * opt, flags and imo have already been used, and now - * they are used to hold ifp and hlen and NULL, respectively. - */ - rule = (struct ip_fw_chain *)(m->m_data) ; - m = m->m_next ; - free(tmp_m, M_IPFW); - ip = mtod(m, struct ip *); - dst = (struct sockaddr_in *)&ro->ro_dst; - ifp = (struct ifnet *)opt; - hlen = IP_VHL_HL(ip->ip_vhl) << 2 ; - opt = NULL ; - flags = 0 ; /* XXX is this correct ? */ - goto sendit; - } else - rule = NULL ; -#endif - #ifdef DIAGNOSTIC if ((m->m_flags & M_PKTHDR) == 0) panic("ip_output no HDR"); @@ -434,52 +393,28 @@ sendit: * Check with the firewall... */ if (ip_fw_chk_ptr) { +#ifdef IPFIREWALL_FORWARD struct sockaddr_in *old = dst; - - off = (*ip_fw_chk_ptr)(&ip, - hlen, ifp, &ip_divert_cookie, &m, &rule, &dst); - /* - * On return we must do the following: - * m == NULL -> drop the pkt - * 1<=off<= 0xffff -> DIVERT - * (off & 0x10000) -> send to a DUMMYNET pipe - * dst != old -> IPFIREWALL_FORWARD - * off==0, dst==old -> accept - * If some of the above modules is not compiled in, then - * we should't have to check the corresponding condition - * (because the ipfw control socket should not accept - * unsupported rules), but better play safe and drop - * packets in case of doubt. - */ - if (!m) { /* firewall said to reject */ - error = EACCES; +#endif +#ifdef IPDIVERT + ip_divert_port = (*ip_fw_chk_ptr)(&ip, + hlen, ifp, &ip_divert_cookie, &m, &dst); + if (ip_divert_port) { /* Divert packet */ + (*inetsw[ip_protox[IPPROTO_DIVERT]].pr_input)(m, 0); goto done; } - if (off == 0 && dst == old) /* common case */ - goto pass ; -#ifdef DUMMYNET - if (off & 0x10000) { - /* - * pass the pkt to dummynet. Need to include - * pipe number, m, ifp, ro, hlen because these are - * not recomputed in the next pass. - * All other parameters have been already used and - * so they are not needed anymore. - * XXX note: if the ifp or ro entry are deleted - * while a pkt is in dummynet, we are in trouble! - */ - dummynet_io(off & 0xffff, DN_TO_IP_OUT, m,ifp,ro,hlen,rule); +#else /* !IPDIVERT */ + u_int16_t dummy = 0; + /* If ipfw says divert, we have to just drop packet */ + if ((*ip_fw_chk_ptr)(&ip, hlen, ifp, &dummy, &m, &dst)) { + m_freem(m); goto done; } -#endif -#ifdef IPDIVERT - if (off > 0 && off < 0x10000) { /* Divert packet */ - ip_divert_port = off & 0xffff ; - (*inetsw[ip_protox[IPPROTO_DIVERT]].pr_input)(m, 0); +#endif /* !IPDIVERT */ + if (!m) { + error = EACCES; goto done; } -#endif - #ifdef IPFIREWALL_FORWARD /* Here we check dst to make sure it's directly reachable on the * interface we previously thought it was. @@ -490,7 +425,7 @@ sendit: * such control is nigh impossible. So we do it here. * And I'm babbling. */ - if (off == 0 && old != dst) { + if (old != dst) { struct in_ifaddr *ia; /* It's changed... */ @@ -579,20 +514,12 @@ sendit: */ if (fwd_rewrite_src) ip->ip_src = IA_SIN(ia)->sin_addr; - goto pass ; } #endif /* IPFIREWALL_FORWARD */ - /* - * if we get here, none of the above matches, and - * we have to drop the pkt - */ - m_freem(m); - error = EACCES; /* not sure this is the right error msg */ - goto done; } #endif /* COMPAT_IPFW */ -pass: + /* * If small enough for interface, can just send directly. */ diff --git a/sys/netinet/ip_state.c b/sys/netinet/ip_state.c index 5545b3daea0f..98cc86295ade 100644 --- a/sys/netinet/ip_state.c +++ b/sys/netinet/ip_state.c @@ -7,7 +7,7 @@ */ #if !defined(lint) static const char sccsid[] = "@(#)ip_state.c 1.8 6/5/96 (C) 1993-1995 Darren Reed"; -static const char rcsid[] = "@(#)$Id: ip_state.c,v 1.3 1998/06/20 18:37:51 peter Exp $"; +static const char rcsid[] = "@(#)$Id: ip_state.c,v 1.2 1998/03/21 11:34:27 peter Exp $"; #endif #include "opt_ipfilter.h" @@ -85,9 +85,9 @@ static const char rcsid[] = "@(#)$Id: ip_state.c,v 1.3 1998/06/20 18:37:51 peter #define TCP_CLOSE (TH_FIN|TH_RST) -static ipstate_t *ips_table[IPSTATE_SIZE]; -static int ips_num = 0; -static ips_stat_t ips_stats; +ipstate_t *ips_table[IPSTATE_SIZE]; +int ips_num = 0; +ips_stat_t ips_stats; #if (SOLARIS || defined(__sgi)) && defined(_KERNEL) extern kmutex_t ipf_state; #endif diff --git a/sys/netinet/mlf_ipl.c b/sys/netinet/mlf_ipl.c index 1ef9077e53d5..d3abe3e8faf0 100644 --- a/sys/netinet/mlf_ipl.c +++ b/sys/netinet/mlf_ipl.c @@ -81,8 +81,29 @@ extern int lkmenodev __P((void)); +static char *ipf_devfiles[] = { IPL_NAME, IPL_NAT, IPL_STATE, IPL_AUTH, + NULL }; +static int if_ipl_unload __P((struct lkm_table *, int)); +static int if_ipl_load __P((struct lkm_table *, int)); +static int if_ipl_remove __P((void)); int xxxinit __P((struct lkm_table *, int, int)); + +struct cdevsw ipldevsw = +{ + iplopen, /* open */ + iplclose, /* close */ + iplread, /* read */ + (void *)nullop, /* write */ + iplioctl, /* ioctl */ + (void *)nullop, /* stop */ + (void *)nullop, /* reset */ + (void *)NULL, /* tty */ + (void *)nullop, /* select */ + (void *)nullop, /* mmap */ + NULL /* strategy */ +}; + #ifdef SYSCTL_INT SYSCTL_NODE(_net_inet, OID_AUTO, ipf, CTLFLAG_RW, 0, "IPF"); SYSCTL_INT(_net_inet_ipf, OID_AUTO, fr_flags, CTLFLAG_RW, &fr_flags, 0, ""); @@ -119,33 +140,19 @@ SYSCTL_INT(_net_inet_ipf, OID_AUTO, fr_defaultauthage, CTLFLAG_RW, #endif #ifdef DEVFS -static void *ipf_devfs[IPL_LOGMAX + 1]; +void *ipf_devfs[IPL_LOGMAX + 1]; #endif #if !defined(__FreeBSD_version) || (__FreeBSD_version < 220000) int ipl_major = 0; -static struct cdevsw ipldevsw = -{ - iplopen, /* open */ - iplclose, /* close */ - iplread, /* read */ - (void *)nullop, /* write */ - iplioctl, /* ioctl */ - (void *)nullop, /* stop */ - (void *)nullop, /* reset */ - (void *)NULL, /* tty */ - (void *)nullop, /* select */ - (void *)nullop, /* mmap */ - NULL /* strategy */ -}; - MOD_DEV(IPL_VERSION, LM_DT_CHAR, -1, &ipldevsw); extern struct cdevsw cdevsw[]; extern int vd_unuseddev __P((void)); extern int nchrdev; #else +int ipl_major = CDEV_MAJOR; static struct cdevsw ipl_cdevsw = { iplopen, iplclose, iplread, nowrite, /* 79 */ @@ -159,13 +166,8 @@ static struct cdevsw ipl_cdevsw = { static void ipl_drvinit __P((void *)); #ifdef ACTUALLY_LKM_NOT_KERNEL -static int if_ipl_unload __P((struct lkm_table *, int)); -static int if_ipl_load __P((struct lkm_table *, int)); -static int if_ipl_remove __P((void)); -static int ipl_major = CDEV_MAJOR; - static int iplaction __P((struct lkm_table *, int)); -static char *ipf_devfiles[] = { IPL_NAME, IPL_NAT, IPL_STATE, IPL_AUTH, NULL }; + static int iplaction(lkmtp, cmd) struct lkm_table *lkmtp; int cmd; diff --git a/sys/netinet/raw_ip.c b/sys/netinet/raw_ip.c index 1dd361822dd2..ee05690cb94f 100644 --- a/sys/netinet/raw_ip.c +++ b/sys/netinet/raw_ip.c @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)raw_ip.c 8.7 (Berkeley) 5/15/95 - * $Id: raw_ip.c,v 1.55 1998/08/23 03:07:14 wollman Exp $ + * $Id: raw_ip.c,v 1.54 1998/05/15 20:11:34 wollman Exp $ */ #include <sys/param.h> @@ -61,10 +61,6 @@ #include <netinet/ip_fw.h> -#include "opt_ipdn.h" -#ifdef DUMMYNET -#include <netinet/ip_dummynet.h> -#endif #if !defined(COMPAT_IPFW) || COMPAT_IPFW == 1 #undef COMPAT_IPFW #define COMPAT_IPFW 1 @@ -263,14 +259,6 @@ rip_ctloutput(so, sopt) else error = ip_nat_ctl_ptr(sopt); break; -#ifdef DUMMYNET - case IP_DUMMYNET_GET: - if (ip_dn_ctl_ptr == NULL) - error = ENOPROTOOPT ; - else - error = ip_dn_ctl_ptr(sopt); - break ; -#endif /* DUMMYNET */ #endif /* COMPAT_IPFW */ case MRT_INIT: @@ -320,16 +308,6 @@ rip_ctloutput(so, sopt) else error = ip_nat_ctl_ptr(sopt); break; -#ifdef DUMMYNET - case IP_DUMMYNET_CONFIGURE: - case IP_DUMMYNET_DEL: - case IP_DUMMYNET_FLUSH: - if (ip_dn_ctl_ptr == NULL) - error = ENOPROTOOPT ; - else - error = ip_dn_ctl_ptr(sopt); - break ; -#endif #endif /* COMPAT_IPFW */ case IP_RSVP_ON: diff --git a/sys/netinet/tcp_input.c b/sys/netinet/tcp_input.c index 97d1983b0078..bb88d163986b 100644 --- a/sys/netinet/tcp_input.c +++ b/sys/netinet/tcp_input.c @@ -31,10 +31,10 @@ * SUCH DAMAGE. * * @(#)tcp_input.c 8.12 (Berkeley) 5/24/95 - * $Id: tcp_input.c,v 1.81 1998/09/11 16:04:03 wollman Exp $ + * $Id: tcp_input.c,v 1.80 1998/08/24 07:47:39 dfr Exp $ */ -#include "opt_ipfw.h" /* for ipfw_fwd */ +#include "opt_ipfw.h" /* for ipfw_fwd */ #include "opt_tcpdebug.h" #include <sys/param.h> @@ -57,10 +57,8 @@ #include <netinet/in.h> #include <netinet/in_systm.h> #include <netinet/ip.h> -#include <netinet/ip_icmp.h> /* for ICMP_BANDLIM */ #include <netinet/in_pcb.h> #include <netinet/ip_var.h> -#include <netinet/icmp_var.h> /* for ICMP_BANDLIM */ #include <netinet/tcp.h> #include <netinet/tcp_fsm.h> #include <netinet/tcp_seq.h> @@ -399,10 +397,6 @@ findpcb: buf, ntohs(ti->ti_dport), inet_ntoa(ti->ti_src), ntohs(ti->ti_sport)); } -#ifdef ICMP_BANDLIM - if (badport_bandlim(1) < 0) - goto drop; -#endif goto dropwithreset; } tp = intotcpcb(inp); diff --git a/sys/netinet/tcp_output.c b/sys/netinet/tcp_output.c index 36f431ac6182..a0ae43af0b4b 100644 --- a/sys/netinet/tcp_output.c +++ b/sys/netinet/tcp_output.c @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)tcp_output.c 8.4 (Berkeley) 5/24/95 - * $Id: tcp_output.c,v 1.31 1998/07/13 11:53:59 bde Exp $ + * $Id: tcp_output.c,v 1.30 1998/05/24 18:41:04 fenner Exp $ */ #include "opt_tcpdebug.h" @@ -223,8 +223,7 @@ again: if (len) { if (len == tp->t_maxseg) goto send; - if (!(tp->t_flags & TF_MORETOCOME) && - (idle || tp->t_flags & TF_NODELAY) && + if ((idle || tp->t_flags & TF_NODELAY) && (tp->t_flags & TF_NOPUSH) == 0 && len + off >= so->so_snd.sb_cc) goto send; diff --git a/sys/netinet/tcp_subr.c b/sys/netinet/tcp_subr.c index 12ca0258f12f..c1c29e4524f8 100644 --- a/sys/netinet/tcp_subr.c +++ b/sys/netinet/tcp_subr.c @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)tcp_subr.c 8.2 (Berkeley) 5/24/95 - * $Id: tcp_subr.c,v 1.48 1998/11/15 21:35:09 guido Exp $ + * $Id: tcp_subr.c,v 1.46 1998/08/24 07:47:39 dfr Exp $ */ #include "opt_compat.h" @@ -209,8 +209,7 @@ tcp_respond(tp, ti, m, ack, seq, flags) struct route sro; if (tp) { - if (!(flags & TH_RST)) - win = sbspace(&tp->t_inpcb->inp_socket->so_rcv); + win = sbspace(&tp->t_inpcb->inp_socket->so_rcv); ro = &tp->t_inpcb->inp_route; } else { ro = &sro; @@ -348,6 +347,7 @@ tcp_close(tp) register struct mbuf *nq; struct inpcb *inp = tp->t_inpcb; struct socket *so = inp->inp_socket; + register struct mbuf *m; register struct rtentry *rt; int dosavessthresh; diff --git a/sys/netinet/tcp_usrreq.c b/sys/netinet/tcp_usrreq.c index 66519cef45f8..ba0c01233636 100644 --- a/sys/netinet/tcp_usrreq.c +++ b/sys/netinet/tcp_usrreq.c @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * From: @(#)tcp_usrreq.c 8.2 (Berkeley) 1/3/94 - * $Id: tcp_usrreq.c,v 1.39 1998/12/07 21:58:42 archie Exp $ + * $Id: tcp_usrreq.c,v 1.37 1998/01/27 09:15:11 davidg Exp $ */ #include "opt_tcpdebug.h" @@ -368,13 +368,8 @@ tcp_usr_send(struct socket *so, int flags, struct mbuf *m, socantsendmore(so); tp = tcp_usrclosed(tp); } - if (tp != NULL) { - if (flags & PRUS_MORETOCOME) - tp->t_flags |= TF_MORETOCOME; + if (tp != NULL) error = tcp_output(tp); - if (flags & PRUS_MORETOCOME) - tp->t_flags &= ~TF_MORETOCOME; - } } else { if (sbspace(&so->so_snd) < -512) { m_freem(m); @@ -580,6 +575,7 @@ tcp_ctloutput(so, sopt) int error, opt, optval, s; struct inpcb *inp; struct tcpcb *tp; + struct mbuf *m; error = 0; s = splnet(); /* XXX */ diff --git a/sys/netinet/tcp_var.h b/sys/netinet/tcp_var.h index db4f401a060d..4e8d88c086fd 100644 --- a/sys/netinet/tcp_var.h +++ b/sys/netinet/tcp_var.h @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)tcp_var.h 8.4 (Berkeley) 5/24/95 - * $Id: tcp_var.h,v 1.48 1998/08/24 07:47:39 dfr Exp $ + * $Id: tcp_var.h,v 1.47 1998/08/23 03:07:15 wollman Exp $ */ #ifndef _NETINET_TCP_VAR_H_ @@ -54,23 +54,22 @@ struct tcpcb { struct inpcb *t_inpcb; /* back pointer to internet pcb */ int t_state; /* state of this connection */ u_int t_flags; -#define TF_ACKNOW 0x00001 /* ack peer immediately */ -#define TF_DELACK 0x00002 /* ack, but try to delay it */ -#define TF_NODELAY 0x00004 /* don't delay packets to coalesce */ -#define TF_NOOPT 0x00008 /* don't use tcp options */ -#define TF_SENTFIN 0x00010 /* have sent FIN */ -#define TF_REQ_SCALE 0x00020 /* have/will request window scaling */ -#define TF_RCVD_SCALE 0x00040 /* other side has requested scaling */ -#define TF_REQ_TSTMP 0x00080 /* have/will request timestamps */ -#define TF_RCVD_TSTMP 0x00100 /* a timestamp was received in SYN */ -#define TF_SACK_PERMIT 0x00200 /* other side said I could SACK */ -#define TF_NEEDSYN 0x00400 /* send SYN (implicit state) */ -#define TF_NEEDFIN 0x00800 /* send FIN (implicit state) */ -#define TF_NOPUSH 0x01000 /* don't push */ -#define TF_REQ_CC 0x02000 /* have/will request CC */ -#define TF_RCVD_CC 0x04000 /* a CC was received in SYN */ -#define TF_SENDCCNEW 0x08000 /* send CCnew instead of CC in SYN */ -#define TF_MORETOCOME 0x10000 /* More data to be appended to sock */ +#define TF_ACKNOW 0x0001 /* ack peer immediately */ +#define TF_DELACK 0x0002 /* ack, but try to delay it */ +#define TF_NODELAY 0x0004 /* don't delay packets to coalesce */ +#define TF_NOOPT 0x0008 /* don't use tcp options */ +#define TF_SENTFIN 0x0010 /* have sent FIN */ +#define TF_REQ_SCALE 0x0020 /* have/will request window scaling */ +#define TF_RCVD_SCALE 0x0040 /* other side has requested scaling */ +#define TF_REQ_TSTMP 0x0080 /* have/will request timestamps */ +#define TF_RCVD_TSTMP 0x0100 /* a timestamp was received in SYN */ +#define TF_SACK_PERMIT 0x0200 /* other side said I could SACK */ +#define TF_NEEDSYN 0x0400 /* send SYN (implicit state) */ +#define TF_NEEDFIN 0x0800 /* send FIN (implicit state) */ +#define TF_NOPUSH 0x1000 /* don't push */ +#define TF_REQ_CC 0x2000 /* have/will request CC */ +#define TF_RCVD_CC 0x4000 /* a CC was received in SYN */ +#define TF_SENDCCNEW 0x8000 /* send CCnew instead of CC in SYN */ int t_force; /* 1 if forcing out a byte */ tcp_seq snd_una; /* send unacknowledged */ diff --git a/sys/netinet/udp_usrreq.c b/sys/netinet/udp_usrreq.c index 3462c70908d3..d5eae08ae4fd 100644 --- a/sys/netinet/udp_usrreq.c +++ b/sys/netinet/udp_usrreq.c @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)udp_usrreq.c 8.6 (Berkeley) 5/23/95 - * $Id: udp_usrreq.c,v 1.48 1998/08/24 07:47:39 dfr Exp $ + * $Id: udp_usrreq.c,v 1.47 1998/05/15 20:11:35 wollman Exp $ */ #include <sys/param.h> @@ -57,7 +57,6 @@ #include <netinet/in_var.h> #include <netinet/ip_var.h> #include <netinet/ip_icmp.h> -#include <netinet/icmp_var.h> #include <netinet/udp.h> #include <netinet/udp_var.h> @@ -297,10 +296,6 @@ udp_input(m, iphlen) goto bad; } *ip = save_ip; -#ifdef ICMP_BANDLIM - if (badport_bandlim(0) < 0) - goto bad; -#endif icmp_error(m, ICMP_UNREACH, ICMP_UNREACH_PORT, 0, 0); return; } @@ -696,4 +691,3 @@ struct pr_usrreqs udp_usrreqs = { pru_rcvoob_notsupp, udp_send, pru_sense_null, udp_shutdown, in_setsockaddr, sosend, soreceive, sopoll }; - diff --git a/sys/netinet/udp_var.h b/sys/netinet/udp_var.h index 6fed4bf57957..8aee42687512 100644 --- a/sys/netinet/udp_var.h +++ b/sys/netinet/udp_var.h @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)udp_var.h 8.1 (Berkeley) 6/10/93 - * $Id: udp_var.h,v 1.15 1998/05/15 20:11:36 wollman Exp $ + * $Id: udp_var.h,v 1.14 1997/09/07 05:26:51 bde Exp $ */ #ifndef _NETINET_UDP_VAR_H_ @@ -44,6 +44,8 @@ struct udpiphdr { struct ipovly ui_i; /* overlaid ip structure */ struct udphdr ui_u; /* udp header */ }; +#define ui_next ui_i.ih_next +#define ui_prev ui_i.ih_prev #define ui_x1 ui_i.ih_x1 #define ui_pr ui_i.ih_pr #define ui_len ui_i.ih_len |
