summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
Diffstat (limited to 'sys')
-rw-r--r--sys/netinet/if_ether.c28
-rw-r--r--sys/netinet/if_ether.h21
-rw-r--r--sys/netinet/igmp.c24
-rw-r--r--sys/netinet/igmp_var.h5
-rw-r--r--sys/netinet/in.c10
-rw-r--r--sys/netinet/in.h11
-rw-r--r--sys/netinet/in_pcb.c140
-rw-r--r--sys/netinet/in_pcb.h30
-rw-r--r--sys/netinet/in_proto.c14
-rw-r--r--sys/netinet/in_var.h5
-rw-r--r--sys/netinet/ip_icmp.c35
-rw-r--r--sys/netinet/ip_icmp.h5
-rw-r--r--sys/netinet/ip_input.c88
-rw-r--r--sys/netinet/ip_mroute.c106
-rw-r--r--sys/netinet/ip_mroute.h23
-rw-r--r--sys/netinet/ip_output.c33
-rw-r--r--sys/netinet/ip_var.h10
-rw-r--r--sys/netinet/raw_ip.c42
-rw-r--r--sys/netinet/tcp_debug.c5
-rw-r--r--sys/netinet/tcp_input.c66
-rw-r--r--sys/netinet/tcp_output.c8
-rw-r--r--sys/netinet/tcp_subr.c33
-rw-r--r--sys/netinet/tcp_timer.c5
-rw-r--r--sys/netinet/tcp_usrreq.c21
-rw-r--r--sys/netinet/tcp_var.h11
-rw-r--r--sys/netinet/udp_usrreq.c86
-rw-r--r--sys/netinet/udp_var.h12
27 files changed, 600 insertions, 277 deletions
diff --git a/sys/netinet/if_ether.c b/sys/netinet/if_ether.c
index b8e6cf4398f..2dd939b5f5e 100644
--- a/sys/netinet/if_ether.c
+++ b/sys/netinet/if_ether.c
@@ -1,4 +1,5 @@
-/* $NetBSD: if_ether.c,v 1.27 1995/08/12 23:59:29 mycroft Exp $ */
+/* $OpenBSD: if_ether.c,v 1.4 1996/03/03 22:30:24 niklas Exp $ */
+/* $NetBSD: if_ether.c,v 1.28 1996/02/13 23:40:59 christos Exp $ */
/*
* Copyright (c) 1982, 1986, 1988, 1993
@@ -53,6 +54,7 @@
#include <sys/errno.h>
#include <sys/ioctl.h>
#include <sys/syslog.h>
+#include <sys/proc.h>
#include <net/if.h>
#include <net/if_dl.h>
@@ -101,6 +103,19 @@ static int myip_initialized = 0;
static int revarp_in_progress = 0;
static struct ifnet *myip_ifp = NULL;
+static void arptimer __P((void *));
+static void arprequest __P((struct arpcom *, u_int32_t *, u_int32_t *,
+ u_int8_t *));
+static void in_arpinput __P((struct mbuf *));
+static void arptfree __P((struct llinfo_arp *));
+static struct llinfo_arp *arplookup __P((u_int32_t, int, int ));
+#ifdef DDB
+static void db_print_sa __P((struct sockaddr *));
+static void db_print_ifa __P((struct ifaddr *));
+static void db_print_llinfo __P((caddr_t));
+static int db_show_radix_node __P((struct radix_node *, void *));
+#endif
+
/*
* Timeout routine. Age arp_tab entries periodically.
*/
@@ -330,7 +345,7 @@ arpresolve(ac, rt, m, dst, desten)
if (rt)
la = (struct llinfo_arp *)rt->rt_llinfo;
else {
- if (la = arplookup(SIN(dst)->sin_addr.s_addr, 1, 0))
+ if ((la = arplookup(SIN(dst)->sin_addr.s_addr, 1, 0)) != NULL)
rt = la->la_rt;
}
if (la == 0 || rt == 0) {
@@ -617,7 +632,6 @@ revarpinput(m)
struct mbuf *m;
{
struct arphdr *ar;
- int op, s;
if (m->m_len < sizeof(struct arphdr))
goto out;
@@ -651,12 +665,13 @@ out:
*
* Note: also supports ARP via RARP packets, per the RFC.
*/
+void
in_revarpinput(m)
struct mbuf *m;
{
struct ifnet *ifp;
struct ether_arp *ar;
- int op, s;
+ int op;
ar = mtod(m, struct ether_arp *);
op = ntohs(ar->arp_op);
@@ -775,6 +790,10 @@ revarpwhoami(in, ifp)
#ifdef DDB
+
+#include <machine/db_machdep.h>
+#include <ddb/db_interface.h>
+#include <ddb/db_output.h>
static void
db_print_sa(sa)
struct sockaddr *sa;
@@ -870,6 +889,7 @@ db_show_radix_node(rn, w)
* Function to print all the route trees.
* Use this from ddb: "call db_show_arptab"
*/
+int
db_show_arptab()
{
struct radix_node_head *rnh;
diff --git a/sys/netinet/if_ether.h b/sys/netinet/if_ether.h
index 2bc23cd2a6e..d7433d3aced 100644
--- a/sys/netinet/if_ether.h
+++ b/sys/netinet/if_ether.h
@@ -1,4 +1,5 @@
-/* $NetBSD: if_ether.h,v 1.20 1995/06/12 00:47:27 mycroft Exp $ */
+/* $OpenBSD: if_ether.h,v 1.2 1996/03/03 22:30:25 niklas Exp $ */
+/* $NetBSD: if_ether.h,v 1.21 1996/02/13 23:41:17 christos Exp $ */
/*
* Copyright (c) 1982, 1986, 1993
@@ -231,3 +232,21 @@ struct ether_multistep {
(step).e_enm = (ac)->ac_multiaddrs.lh_first; \
ETHER_NEXT_MULTI((step), (enm)); \
}
+
+#ifdef _KERNEL
+
+void arp_rtrequest __P((int, struct rtentry *, struct sockaddr *));
+void arpwhohas __P((struct arpcom *, struct in_addr *));
+int arpresolve __P((struct arpcom *, struct rtentry *, struct mbuf *,
+ struct sockaddr *, u_char *));
+void arpintr __P((void));
+int arpioctl __P((u_long, caddr_t));
+void arp_ifinit __P((struct arpcom *, struct ifaddr *));
+void revarpinput __P((struct mbuf *));
+void in_revarpinput __P((struct mbuf *));
+void revarprequest __P((struct ifnet *));
+int revarpwhoarewe __P((struct ifnet *, struct in_addr *, struct in_addr *));
+int revarpwhoami __P((struct in_addr *, struct ifnet *));
+int db_show_arptab __P((void));
+
+#endif
diff --git a/sys/netinet/igmp.c b/sys/netinet/igmp.c
index cdc3abee23c..e37d502e7e5 100644
--- a/sys/netinet/igmp.c
+++ b/sys/netinet/igmp.c
@@ -1,4 +1,5 @@
-/* $NetBSD: igmp.c,v 1.14 1995/08/12 23:59:31 mycroft Exp $ */
+/* $OpenBSD: igmp.c,v 1.2 1996/03/03 22:30:26 niklas Exp $ */
+/* $NetBSD: igmp.c,v 1.15 1996/02/13 23:41:25 christos Exp $ */
/*
* Internet Group Management Protocol (IGMP) routines.
@@ -14,6 +15,7 @@
#include <sys/mbuf.h>
#include <sys/socket.h>
#include <sys/protosw.h>
+#include <sys/systm.h>
#include <net/if.h>
#include <net/route.h>
@@ -26,12 +28,16 @@
#include <netinet/igmp.h>
#include <netinet/igmp_var.h>
+#include <machine/stdarg.h>
+
#define IP_MULTICASTOPTS 0
int igmp_timers_are_running;
static struct router_info *rti_head;
void igmp_sendpkt __P((struct in_multi *, int));
+static int rti_fill __P((struct in_multi *));
+static struct router_info * rti_find __P((struct ifnet *));
void
igmp_init()
@@ -91,10 +97,15 @@ rti_find(ifp)
}
void
-igmp_input(m, iphlen)
- register struct mbuf *m;
- register int iphlen;
+#if __STDC__
+igmp_input(struct mbuf *m, ...)
+#else
+igmp_input(m, va_alist)
+ struct mbuf *m;
+ va_dcl
+#endif
{
+ register int iphlen;
register struct ifnet *ifp = m->m_pkthdr.rcvif;
register struct ip *ip = mtod(m, struct ip *);
register struct igmp *igmp;
@@ -105,6 +116,11 @@ igmp_input(m, iphlen)
struct router_info *rti;
register struct in_ifaddr *ia;
int timer;
+ va_list ap;
+
+ va_start(ap, m);
+ iphlen = va_arg(ap, int);
+ va_end(ap);
++igmpstat.igps_rcv_total;
diff --git a/sys/netinet/igmp_var.h b/sys/netinet/igmp_var.h
index 8d39d8b406e..dccbd637b81 100644
--- a/sys/netinet/igmp_var.h
+++ b/sys/netinet/igmp_var.h
@@ -1,4 +1,5 @@
-/* $NetBSD: igmp_var.h,v 1.8 1995/05/31 06:08:24 mycroft Exp $ */
+/* $OpenBSD: igmp_var.h,v 1.2 1996/03/03 22:30:27 niklas Exp $ */
+/* $NetBSD: igmp_var.h,v 1.9 1996/02/13 23:41:31 christos Exp $ */
/*
* Copyright (c) 1988 Stephen Deering.
@@ -73,7 +74,7 @@ struct igmpstat igmpstat;
#define IGMP_RANDOM_DELAY(X) (random() % (X) + 1)
void igmp_init __P((void));
-void igmp_input __P((struct mbuf *, int));
+void igmp_input __P((struct mbuf *, ...));
void igmp_joingroup __P((struct in_multi *));
void igmp_leavegroup __P((struct in_multi *));
void igmp_fasttimo __P((void));
diff --git a/sys/netinet/in.c b/sys/netinet/in.c
index 2fcda154006..5de33584784 100644
--- a/sys/netinet/in.c
+++ b/sys/netinet/in.c
@@ -1,4 +1,5 @@
-/* $NetBSD: in.c,v 1.25 1995/08/12 23:59:32 mycroft Exp $ */
+/* $OpenBSD: in.c,v 1.2 1996/03/03 22:30:28 niklas Exp $ */
+/* $NetBSD: in.c,v 1.26 1996/02/13 23:41:39 christos Exp $ */
/*
* Copyright (c) 1982, 1986, 1991, 1993
@@ -41,6 +42,7 @@
#include <sys/malloc.h>
#include <sys/socket.h>
#include <sys/socketvar.h>
+#include <sys/systm.h>
#include <net/if.h>
#include <net/route.h>
@@ -50,6 +52,7 @@
#include <netinet/in_var.h>
#include <netinet/if_ether.h>
#include <netinet/ip_mroute.h>
+#include <netinet/igmp_var.h>
#include "ether.h"
@@ -138,7 +141,6 @@ in_control(so, cmd, data, ifp)
{
register struct ifreq *ifr = (struct ifreq *)data;
register struct in_ifaddr *ia = 0;
- register struct ifaddr *ifa;
struct in_aliasreq *ifra = (struct in_aliasreq *)data;
struct sockaddr_in oldaddr;
int error, hostIsNew, maskIsNew;
@@ -348,7 +350,7 @@ in_ifinit(ifp, ia, sin, scrub)
{
register u_int32_t i = sin->sin_addr.s_addr;
struct sockaddr_in oldaddr;
- int s = splimp(), flags = RTF_UP, error, ether_output();
+ int s = splimp(), flags = RTF_UP, error;
oldaddr = ia->ia_addr;
ia->ia_addr = *sin;
@@ -525,7 +527,7 @@ in_addmulti(ap, ifp)
/*
* Delete a multicast address record.
*/
-int
+void
in_delmulti(inm)
register struct in_multi *inm;
{
diff --git a/sys/netinet/in.h b/sys/netinet/in.h
index b1974b046a0..9bfe6041ec2 100644
--- a/sys/netinet/in.h
+++ b/sys/netinet/in.h
@@ -1,4 +1,5 @@
-/* $NetBSD: in.h,v 1.17 1995/06/04 05:06:55 mycroft Exp $ */
+/* $OpenBSD: in.h,v 1.5 1996/03/03 22:30:29 niklas Exp $ */
+/* $NetBSD: in.h,v 1.20 1996/02/13 23:41:47 christos Exp $ */
/*
* Copyright (c) 1982, 1986, 1990, 1993
@@ -91,7 +92,7 @@ struct in_addr {
* on these macros not doing byte-swapping.
*/
#ifdef _KERNEL
-#define __IPADDR(x) htonl((u_int32_t)(x))
+#define __IPADDR(x) ((u_int32_t) htonl((u_int32_t)(x)))
#else
#define __IPADDR(x) ((u_int32_t)(x))
#endif
@@ -244,8 +245,9 @@ struct ip_mreq {
#ifdef notyet
#define IPCTL_DEFMTU 4 /* default MTU */
#endif
-#define IPCTL_SOURCEROUTE 5 /* may perform source routes */
-#define IPCTL_MAXID 6
+#define IPCTL_SOURCEROUTE 5 /* may perform source routes */
+#define IPCTL_DIRECTEDBCAST 6 /* default broadcast behavior */
+#define IPCTL_MAXID 7
#define IPCTL_NAMES { \
{ 0, 0 }, \
@@ -254,6 +256,7 @@ struct ip_mreq {
{ "ttl", CTLTYPE_INT }, \
{ "mtu", CTLTYPE_INT }, \
{ "sourceroute", CTLTYPE_INT }, \
+ { "directed-broadcast", CTLTYPE_INT }, \
}
diff --git a/sys/netinet/in_pcb.c b/sys/netinet/in_pcb.c
index 7f957b93a28..1bb338ddff4 100644
--- a/sys/netinet/in_pcb.c
+++ b/sys/netinet/in_pcb.c
@@ -1,4 +1,5 @@
-/* $NetBSD: in_pcb.c,v 1.23 1995/08/17 02:57:27 mycroft Exp $ */
+/* $OpenBSD: in_pcb.c,v 1.2 1996/03/03 22:30:31 niklas Exp $ */
+/* $NetBSD: in_pcb.c,v 1.25 1996/02/13 23:41:53 christos Exp $ */
/*
* Copyright (c) 1982, 1986, 1991, 1993
@@ -59,21 +60,28 @@
struct in_addr zeroin_addr;
+#define INPCBHASH(table, faddr, fport, laddr, lport) \
+ &(table)->inpt_hashtbl[(ntohl((faddr)->s_addr) + ntohs((fport)) + ntohs((lport))) & (table->inpt_hash)]
+
void
-in_pcbinit(table)
+in_pcbinit(table, hashsize)
struct inpcbtable *table;
+ int hashsize;
{
CIRCLEQ_INIT(&table->inpt_queue);
+ table->inpt_hashtbl = hashinit(hashsize, M_PCB, &table->inpt_hash);
table->inpt_lastport = 0;
}
int
-in_pcballoc(so, table)
+in_pcballoc(so, v)
struct socket *so;
- struct inpcbtable *table;
+ void *v;
{
+ struct inpcbtable *table = v;
register struct inpcb *inp;
+ int s;
MALLOC(inp, struct inpcb *, sizeof(*inp), M_PCB, M_WAITOK);
if (inp == NULL)
@@ -81,16 +89,21 @@ in_pcballoc(so, table)
bzero((caddr_t)inp, sizeof(*inp));
inp->inp_table = table;
inp->inp_socket = so;
+ s = splnet();
CIRCLEQ_INSERT_HEAD(&table->inpt_queue, inp, inp_queue);
+ LIST_INSERT_HEAD(INPCBHASH(table, &inp->inp_faddr, inp->inp_fport,
+ &inp->inp_laddr, inp->inp_lport), inp, inp_hash);
+ splx(s);
so->so_pcb = inp;
return (0);
}
int
-in_pcbbind(inp, nam)
- register struct inpcb *inp;
+in_pcbbind(v, nam)
+ register void *v;
struct mbuf *nam;
{
+ register struct inpcb *inp = v;
register struct socket *so = inp->inp_socket;
register struct inpcbtable *table = inp->inp_table;
register struct sockaddr_in *sin;
@@ -158,6 +171,7 @@ in_pcbbind(inp, nam)
} while (in_pcblookup(table,
zeroin_addr, 0, inp->inp_laddr, lport, wild));
inp->inp_lport = lport;
+ in_pcbrehash(inp);
return (0);
}
@@ -168,12 +182,13 @@ in_pcbbind(inp, nam)
* then pick one.
*/
int
-in_pcbconnect(inp, nam)
- register struct inpcb *inp;
+in_pcbconnect(v, nam)
+ register void *v;
struct mbuf *nam;
{
+ register struct inpcb *inp = v;
struct in_ifaddr *ia;
- struct sockaddr_in *ifaddr;
+ struct sockaddr_in *ifaddr = NULL;
register struct sockaddr_in *sin = mtod(nam, struct sockaddr_in *);
if (nam->m_len != sizeof (*sin))
@@ -265,12 +280,9 @@ in_pcbconnect(inp, nam)
}
ifaddr = satosin(&ia->ia_addr);
}
- if (in_pcblookup(inp->inp_table,
- sin->sin_addr,
- sin->sin_port,
+ if (in_pcbhashlookup(inp->inp_table, sin->sin_addr, sin->sin_port,
inp->inp_laddr.s_addr ? inp->inp_laddr : ifaddr->sin_addr,
- inp->inp_lport,
- 0))
+ inp->inp_lport) != 0)
return (EADDRINUSE);
if (inp->inp_laddr.s_addr == INADDR_ANY) {
if (inp->inp_lport == 0)
@@ -279,25 +291,30 @@ in_pcbconnect(inp, nam)
}
inp->inp_faddr = sin->sin_addr;
inp->inp_fport = sin->sin_port;
+ in_pcbrehash(inp);
return (0);
}
-int
-in_pcbdisconnect(inp)
- struct inpcb *inp;
+void
+in_pcbdisconnect(v)
+ void *v;
{
+ struct inpcb *inp = v;
inp->inp_faddr.s_addr = INADDR_ANY;
inp->inp_fport = 0;
+ in_pcbrehash(inp);
if (inp->inp_socket->so_state & SS_NOFDREF)
in_pcbdetach(inp);
}
-int
-in_pcbdetach(inp)
- struct inpcb *inp;
+void
+in_pcbdetach(v)
+ void *v;
{
+ struct inpcb *inp = v;
struct socket *so = inp->inp_socket;
+ int s;
so->so_pcb = 0;
sofree(so);
@@ -306,11 +323,14 @@ in_pcbdetach(inp)
if (inp->inp_route.ro_rt)
rtfree(inp->inp_route.ro_rt);
ip_freemoptions(inp->inp_moptions);
+ s = splnet();
+ LIST_REMOVE(inp, inp_hash);
CIRCLEQ_REMOVE(&inp->inp_table->inpt_queue, inp, inp_queue);
+ splx(s);
FREE(inp, M_PCB);
}
-int
+void
in_setsockaddr(inp, nam)
register struct inpcb *inp;
struct mbuf *nam;
@@ -326,7 +346,7 @@ in_setsockaddr(inp, nam)
sin->sin_addr = inp->inp_laddr;
}
-int
+void
in_setpeeraddr(inp, nam)
struct inpcb *inp;
struct mbuf *nam;
@@ -425,7 +445,7 @@ in_pcbnotifyall(table, dst, errno, notify)
* routing information. If the route was created dynamically
* (by a redirect), time to try a default gateway again.
*/
-int
+void
in_losing(inp)
struct inpcb *inp;
{
@@ -488,15 +508,6 @@ in_pcblookup(table, faddr, fport_arg, laddr, lport_arg, flags)
if (inp->inp_lport != lport)
continue;
wildcard = 0;
- if (inp->inp_laddr.s_addr != INADDR_ANY) {
- if (laddr.s_addr == INADDR_ANY)
- wildcard++;
- else if (inp->inp_laddr.s_addr != laddr.s_addr)
- continue;
- } else {
- if (laddr.s_addr != INADDR_ANY)
- wildcard++;
- }
if (inp->inp_faddr.s_addr != INADDR_ANY) {
if (faddr.s_addr == INADDR_ANY)
wildcard++;
@@ -507,6 +518,15 @@ in_pcblookup(table, faddr, fport_arg, laddr, lport_arg, flags)
if (faddr.s_addr != INADDR_ANY)
wildcard++;
}
+ if (inp->inp_laddr.s_addr != INADDR_ANY) {
+ if (laddr.s_addr == INADDR_ANY)
+ wildcard++;
+ else if (inp->inp_laddr.s_addr != laddr.s_addr)
+ continue;
+ } else {
+ if (laddr.s_addr != INADDR_ANY)
+ wildcard++;
+ }
if (wildcard && (flags & INPLOOKUP_WILDCARD) == 0)
continue;
if (wildcard < matchwild) {
@@ -518,3 +538,59 @@ in_pcblookup(table, faddr, fport_arg, laddr, lport_arg, flags)
}
return (match);
}
+
+void
+in_pcbrehash(inp)
+ struct inpcb *inp;
+{
+ struct inpcbtable *table = inp->inp_table;
+ int s;
+
+ s = splnet();
+ LIST_REMOVE(inp, inp_hash);
+ LIST_INSERT_HEAD(INPCBHASH(table, &inp->inp_faddr, inp->inp_fport,
+ &inp->inp_laddr, inp->inp_lport), inp, inp_hash);
+ splx(s);
+}
+
+#ifdef DIAGNOSTIC
+int in_pcbnotifymiss = 0;
+#endif
+
+struct inpcb *
+in_pcbhashlookup(table, faddr, fport_arg, laddr, lport_arg)
+ struct inpcbtable *table;
+ struct in_addr faddr, laddr;
+ u_int fport_arg, lport_arg;
+{
+ struct inpcbhead *head;
+ register struct inpcb *inp;
+ u_int16_t fport = fport_arg, lport = lport_arg;
+
+ head = INPCBHASH(table, &faddr, fport, &laddr, lport);
+ for (inp = head->lh_first; inp != NULL; inp = inp->inp_hash.le_next) {
+ if (inp->inp_faddr.s_addr == faddr.s_addr &&
+ inp->inp_fport == fport &&
+ inp->inp_lport == lport &&
+ inp->inp_laddr.s_addr == laddr.s_addr) {
+ /*
+ * Move this PCB to the head of hash chain so that
+ * repeated accesses are quicker. This is analogous to
+ * the historic single-entry PCB cache.
+ */
+ if (inp != head->lh_first) {
+ LIST_REMOVE(inp, inp_hash);
+ LIST_INSERT_HEAD(head, inp, inp_hash);
+ }
+ break;
+ }
+ }
+#ifdef DIAGNOSTIC
+ if (inp == NULL && in_pcbnotifymiss) {
+ printf("in_pcbhashlookup: faddr=%08x fport=%d laddr=%08x lport=%d\n",
+ ntohl(faddr.s_addr), ntohs(fport),
+ ntohl(laddr.s_addr), ntohs(lport));
+ }
+#endif
+ return (inp);
+}
diff --git a/sys/netinet/in_pcb.h b/sys/netinet/in_pcb.h
index 1b62eaf3daa..6a533ca4703 100644
--- a/sys/netinet/in_pcb.h
+++ b/sys/netinet/in_pcb.h
@@ -1,4 +1,5 @@
-/* $NetBSD: in_pcb.h,v 1.12 1995/06/18 20:01:13 cgd Exp $ */
+/* $OpenBSD: in_pcb.h,v 1.2 1996/03/03 22:30:32 niklas Exp $ */
+/* $NetBSD: in_pcb.h,v 1.14 1996/02/13 23:42:00 christos Exp $ */
/*
* Copyright (c) 1982, 1986, 1990, 1993
@@ -45,6 +46,7 @@
* control block.
*/
struct inpcb {
+ LIST_ENTRY(inpcb) inp_hash;
CIRCLEQ_ENTRY(inpcb) inp_queue;
struct inpcbtable *inp_table;
struct in_addr inp_faddr; /* foreign host table entry */
@@ -61,7 +63,9 @@ struct inpcb {
};
struct inpcbtable {
- CIRCLEQ_HEAD(inpcbhead, inpcb) inpt_queue;
+ CIRCLEQ_HEAD(, inpcb) inpt_queue;
+ LIST_HEAD(inpcbhead, inpcb) *inpt_hashtbl;
+ u_long inpt_hash;
u_int16_t inpt_lastport;
};
@@ -78,13 +82,16 @@ struct inpcbtable {
#define sotoinpcb(so) ((struct inpcb *)(so)->so_pcb)
#ifdef _KERNEL
-int in_losing __P((struct inpcb *));
-int in_pcballoc __P((struct socket *, struct inpcbtable *));
-int in_pcbbind __P((struct inpcb *, struct mbuf *));
-int in_pcbconnect __P((struct inpcb *, struct mbuf *));
-int in_pcbdetach __P((struct inpcb *));
-int in_pcbdisconnect __P((struct inpcb *));
-void in_pcbinit __P((struct inpcbtable *));
+void in_losing __P((struct inpcb *));
+int in_pcballoc __P((struct socket *, void *));
+int in_pcbbind __P((void *, struct mbuf *));
+int in_pcbconnect __P((void *, struct mbuf *));
+void in_pcbdetach __P((void *));
+void in_pcbdisconnect __P((void *));
+struct inpcb *
+ in_pcbhashlookup __P((struct inpcbtable *, struct in_addr,
+ u_int, struct in_addr, u_int));
+void in_pcbinit __P((struct inpcbtable *, int));
struct inpcb *
in_pcblookup __P((struct inpcbtable *,
struct in_addr, u_int, struct in_addr, u_int, int));
@@ -92,7 +99,8 @@ void in_pcbnotify __P((struct inpcbtable *, struct sockaddr *,
u_int, struct in_addr, u_int, int, void (*)(struct inpcb *, int)));
void in_pcbnotifyall __P((struct inpcbtable *, struct sockaddr *,
int, void (*)(struct inpcb *, int)));
+void in_pcbrehash __P((struct inpcb *));
void in_rtchange __P((struct inpcb *, int));
-int in_setpeeraddr __P((struct inpcb *, struct mbuf *));
-int in_setsockaddr __P((struct inpcb *, struct mbuf *));
+void in_setpeeraddr __P((struct inpcb *, struct mbuf *));
+void in_setsockaddr __P((struct inpcb *, struct mbuf *));
#endif
diff --git a/sys/netinet/in_proto.c b/sys/netinet/in_proto.c
index 495587a7376..51dc49af433 100644
--- a/sys/netinet/in_proto.c
+++ b/sys/netinet/in_proto.c
@@ -1,4 +1,5 @@
-/* $NetBSD: in_proto.c,v 1.12 1995/09/30 07:02:00 thorpej Exp $ */
+/* $OpenBSD: in_proto.c,v 1.2 1996/03/03 22:30:33 niklas Exp $ */
+/* $NetBSD: in_proto.c,v 1.13 1996/02/13 23:42:09 christos Exp $ */
/*
* Copyright (c) 1982, 1986, 1993
@@ -66,20 +67,21 @@
*/
#ifdef NSIP
-void idpip_input(), nsip_ctlinput();
+#include <netns/ns_var.h>
+#include <netns/idp_var.h>
#endif /* NSIP */
#ifdef TPIP
-void tpip_input(), tpip_ctlinput(), tp_init(), tp_slowtimo(), tp_drain();
-int tp_ctloutput(), tp_usrreq();
+#include <netiso/tp_param.h>
+#include <netiso/tp_var.h>
#endif /* TPIP */
#ifdef EON
-void eoninput(), eonctlinput(), eonprotoinit();
+#include <netiso/eonvar.h>
#endif /* EON */
#ifdef MROUTING
-void ipip_input();
+#include <netinet/mroute.h>
#endif /* MROUTING */
extern struct domain inetdomain;
diff --git a/sys/netinet/in_var.h b/sys/netinet/in_var.h
index d59be82df1f..7dafa91702d 100644
--- a/sys/netinet/in_var.h
+++ b/sys/netinet/in_var.h
@@ -1,4 +1,5 @@
-/* $NetBSD: in_var.h,v 1.15 1995/06/12 00:47:37 mycroft Exp $ */
+/* $OpenBSD: in_var.h,v 1.2 1996/03/03 22:30:34 niklas Exp $ */
+/* $NetBSD: in_var.h,v 1.16 1996/02/13 23:42:15 christos Exp $ */
/*
* Copyright (c) 1985, 1986, 1993
@@ -208,7 +209,7 @@ struct in_multistep {
int in_ifinit __P((struct ifnet *,
struct in_ifaddr *, struct sockaddr_in *, int));
struct in_multi *in_addmulti __P((struct in_addr *, struct ifnet *));
-int in_delmulti __P((struct in_multi *));
+void in_delmulti __P((struct in_multi *));
void in_ifscrub __P((struct ifnet *, struct in_ifaddr *));
int in_control __P((struct socket *, u_long, caddr_t, struct ifnet *));
#endif
diff --git a/sys/netinet/ip_icmp.c b/sys/netinet/ip_icmp.c
index ad8dbddd243..f4a8c0d6e16 100644
--- a/sys/netinet/ip_icmp.c
+++ b/sys/netinet/ip_icmp.c
@@ -1,4 +1,5 @@
-/* $NetBSD: ip_icmp.c,v 1.18 1995/06/12 00:47:39 mycroft Exp $ */
+/* $OpenBSD: ip_icmp.c,v 1.3 1996/03/03 22:30:35 niklas Exp $ */
+/* $NetBSD: ip_icmp.c,v 1.19 1996/02/13 23:42:22 christos Exp $ */
/*
* Copyright (c) 1982, 1986, 1988, 1993
@@ -43,6 +44,10 @@
#include <sys/socket.h>
#include <sys/time.h>
#include <sys/kernel.h>
+#include <sys/proc.h>
+
+#include <vm/vm.h>
+#include <sys/sysctl.h>
#include <net/if.h>
#include <net/route.h>
@@ -52,8 +57,11 @@
#include <netinet/in_var.h>
#include <netinet/ip.h>
#include <netinet/ip_icmp.h>
+#include <netinet/ip_var.h>
#include <netinet/icmp_var.h>
+#include <machine/stdarg.h>
+
/*
* ICMP routines: error generation, receive packet processing, and
* routines to turnaround packets back to the originator, and
@@ -172,18 +180,28 @@ struct sockaddr_in icmpmask = { 8, 0 };
* Process a received ICMP message.
*/
void
-icmp_input(m, hlen)
- register struct mbuf *m;
- int hlen;
+#if __STDC__
+icmp_input(struct mbuf *m, ...)
+#else
+icmp_input(m, va_alist)
+ struct mbuf *m;
+ va_dcl
+#endif
{
register struct icmp *icp;
register struct ip *ip = mtod(m, struct ip *);
int icmplen = ip->ip_len;
register int i;
struct in_ifaddr *ia;
- void (*ctlfunc) __P((int, struct sockaddr *, struct ip *));
+ void *(*ctlfunc) __P((int, struct sockaddr *, void *));
int code;
extern u_char ip_protox[];
+ int hlen;
+ va_list ap;
+
+ va_start(ap, m);
+ hlen = va_arg(ap, int);
+ va_end(ap);
/*
* Locate icmp structure in mbuf, and check
@@ -297,7 +315,8 @@ icmp_input(m, hlen)
printf("deliver to protocol %d\n", icp->icmp_ip.ip_p);
#endif
icmpsrc.sin_addr = icp->icmp_ip.ip_dst;
- if (ctlfunc = inetsw[ip_protox[icp->icmp_ip.ip_p]].pr_ctlinput)
+ ctlfunc = inetsw[ip_protox[icp->icmp_ip.ip_p]].pr_ctlinput;
+ if (ctlfunc)
(*ctlfunc)(code, sintosa(&icmpsrc), &icp->icmp_ip);
break;
@@ -417,7 +436,7 @@ icmp_reflect(m)
register struct ip *ip = mtod(m, struct ip *);
register struct in_ifaddr *ia;
struct in_addr t;
- struct mbuf *opts = 0, *ip_srcroute();
+ struct mbuf *opts = 0;
int optlen = (ip->ip_hl << 2) - sizeof(struct ip);
if (!in_canforward(ip->ip_src) &&
@@ -498,7 +517,7 @@ icmp_reflect(m)
}
}
/* Terminate & pad, if necessary */
- if (cnt = opts->m_len % 4) {
+ if ((cnt = opts->m_len % 4) != 0) {
for (; cnt < 4; cnt++) {
*(mtod(opts, caddr_t) + opts->m_len) =
IPOPT_EOL;
diff --git a/sys/netinet/ip_icmp.h b/sys/netinet/ip_icmp.h
index c1960e7fcf3..2f8f3c7b5bf 100644
--- a/sys/netinet/ip_icmp.h
+++ b/sys/netinet/ip_icmp.h
@@ -1,4 +1,5 @@
-/* $NetBSD: ip_icmp.h,v 1.9 1995/04/17 05:32:57 cgd Exp $ */
+/* $OpenBSD: ip_icmp.h,v 1.2 1996/03/03 22:30:36 niklas Exp $ */
+/* $NetBSD: ip_icmp.h,v 1.10 1996/02/13 23:42:28 christos Exp $ */
/*
* Copyright (c) 1982, 1986, 1993
@@ -155,7 +156,7 @@ struct icmp {
#ifdef _KERNEL
void icmp_error __P((struct mbuf *, int, int, n_long, struct ifnet *));
-void icmp_input __P((struct mbuf *, int));
+void icmp_input __P((struct mbuf *, ...));
void icmp_reflect __P((struct mbuf *));
void icmp_send __P((struct mbuf *, struct mbuf *));
int icmp_sysctl __P((int *, u_int, void *, size_t *, void *, size_t));
diff --git a/sys/netinet/ip_input.c b/sys/netinet/ip_input.c
index 6b446c2780f..8d07f8897b2 100644
--- a/sys/netinet/ip_input.c
+++ b/sys/netinet/ip_input.c
@@ -1,4 +1,5 @@
-/* $NetBSD: ip_input.c,v 1.25 1995/11/21 01:07:34 cgd Exp $ */
+/* $OpenBSD: ip_input.c,v 1.9 1996/03/03 22:30:37 niklas Exp $ */
+/* $NetBSD: ip_input.c,v 1.28 1996/02/13 23:42:37 christos Exp $ */
/*
* Copyright (c) 1982, 1986, 1988, 1993
@@ -46,6 +47,10 @@
#include <sys/time.h>
#include <sys/kernel.h>
#include <sys/syslog.h>
+#include <sys/proc.h>
+
+#include <vm/vm.h>
+#include <sys/sysctl.h>
#include <net/if.h>
#include <net/route.h>
@@ -68,10 +73,22 @@
#ifndef IPSENDREDIRECTS
#define IPSENDREDIRECTS 1
#endif
+/*
+ * Note: DIRECTED_BROADCAST is handled this way so that previous
+ * configuration using this option will Just Work.
+ */
+#ifndef IPDIRECTEDBCAST
+#ifdef DIRECTED_BROADCAST
+#define IPDIRECTEDBCAST 1
+#else
+#define IPDIRECTEDBCAST 0
+#endif /* DIRECTED_BROADCAST */
+#endif /* IPDIRECTEDBCAST */
int ipforwarding = IPFORWARDING;
int ipsendredirects = IPSENDREDIRECTS;
-int ip_dosourceroute = 0; /* no source routing unless sysctl'd to enable */
+int ip_dosourceroute = 0; /* no src-routing unless sysctl'd to enable */
int ip_defttl = IPDEFTTL;
+int ip_directedbcast = IPDIRECTEDBCAST;
#ifdef DIAGNOSTIC
int ipprintfs = 0;
#endif
@@ -82,9 +99,6 @@ u_char ip_protox[IPPROTO_MAX];
int ipqmaxlen = IFQ_MAXLEN;
struct in_ifaddrhead in_ifaddr;
struct ifqueue ipintrq;
-#if defined(IPFILTER) || defined(IPFILTER_LKM)
-int (*fr_checkp) __P((struct ip *, int, struct ifnet *, int, struct mbuf **));
-#endif
char *
inet_ntoa(ina)
@@ -200,7 +214,7 @@ next:
}
ip = mtod(m, struct ip *);
}
- if (ip->ip_sum = in_cksum(m, hlen)) {
+ if ((ip->ip_sum = in_cksum(m, hlen)) != 0) {
ipstat.ips_badsum++;
goto bad;
}
@@ -234,19 +248,6 @@ next:
m_adj(m, ip->ip_len - m->m_pkthdr.len);
}
-#if defined(IPFILTER) || defined(IPFILTER_LKM)
- /*
- * Check if we want to allow this packet to be processed.
- * Consider it to be bad if not.
- */
- {
- struct mbuf *m0 = m;
- if (fr_checkp && (*fr_checkp)(ip, hlen, m->m_pkthdr.rcvif, 0, &m0))
- goto next;
- else
- ip = mtod(m = m0, struct ip *);
- }
-#endif
/*
* Process options and, if not destined for us,
* ship it on. ip_dooptions returns 1 when an
@@ -263,10 +264,8 @@ next:
for (ia = in_ifaddr.tqh_first; ia; ia = ia->ia_list.tqe_next) {
if (ip->ip_dst.s_addr == ia->ia_addr.sin_addr.s_addr)
goto ours;
- if (
-#ifdef DIRECTED_BROADCAST
- ia->ia_ifp == m->m_pkthdr.rcvif &&
-#endif
+ if (((ip_directedbcast == 0) || (ip_directedbcast &&
+ ia->ia_ifp == m->m_pkthdr.rcvif)) &&
(ia->ia_ifp->if_flags & IFF_BROADCAST)) {
if (ip->ip_dst.s_addr == ia->ia_broadaddr.sin_addr.s_addr ||
ip->ip_dst.s_addr == ia->ia_netbroadcast.s_addr ||
@@ -386,10 +385,10 @@ found:
ip->ip_len -= hlen;
mff = (ip->ip_off & IP_MF) != 0;
if (mff) {
- /*
- * Make sure that fragments have a data length
+ /*
+ * Make sure that fragments have a data length
* that's a non-zero multiple of 8 bytes.
- */
+ */
if (ip->ip_len == 0 || (ip->ip_len & 0x7) != 0) {
ipstat.ips_badfrags++;
goto bad;
@@ -765,6 +764,19 @@ ip_dooptions(m)
code = &cp[IPOPT_OFFSET] - (u_char *)ip;
goto bad;
}
+
+ if (!ip_dosourceroute) {
+ char buf[4*sizeof "123"];
+
+ strcpy(buf, inet_ntoa(ip->ip_dst));
+ log(LOG_WARNING,
+ "attempted source route from %s to %s\n",
+ inet_ntoa(ip->ip_src), buf);
+ type = ICMP_UNREACH;
+ code = ICMP_UNREACH_SRCFAIL;
+ goto bad;
+ }
+
/*
* If no space remains, ignore.
*/
@@ -1028,7 +1040,7 @@ ip_forward(m, srcrt)
register struct ip *ip = mtod(m, struct ip *);
register struct sockaddr_in *sin;
register struct rtentry *rt;
- int error, type = 0, code;
+ int error, type = 0, code = 0;
struct mbuf *mcopy;
n_long dest;
struct ifnet *destifp;
@@ -1037,7 +1049,7 @@ ip_forward(m, srcrt)
#ifdef DIAGNOSTIC
if (ipprintfs)
printf("forward: src %lx dst %x ttl %x\n", ip->ip_src.s_addr,
- ip->ip_dst.s_addr, ip->ip_ttl);
+ ip->ip_dst.s_addr, ip->ip_ttl);
#endif
if (m->m_flags & M_BCAST || in_canforward(ip->ip_dst) == 0) {
ipstat.ips_cantforward++;
@@ -1100,16 +1112,13 @@ ip_forward(m, srcrt)
code = ICMP_REDIRECT_HOST;
#ifdef DIAGNOSTIC
if (ipprintfs)
- printf("redirect (%d) to %lx\n", code, (u_int32_t)dest);
+ printf("redirect (%d) to %lx\n", code, (u_int32_t)dest);
#endif
}
}
- error = ip_output(m, (struct mbuf *)0, &ipforward_rt, IP_FORWARDING
-#ifdef DIRECTED_BROADCAST
- | IP_ALLOWBROADCAST
-#endif
- , 0);
+ error = ip_output(m, (struct mbuf *)0, &ipforward_rt,
+ (IP_FORWARDING | (ip_directedbcast ? IP_ALLOWBROADCAST : 0)), 0);
if (error)
ipstat.ips_cantforward++;
else {
@@ -1183,7 +1192,16 @@ ip_sysctl(name, namelen, oldp, oldlenp, newp, newlen)
return (sysctl_int(oldp, oldlenp, newp, newlen, &ip_mtu));
#endif
case IPCTL_SOURCEROUTE:
- return (sysctl_int(oldp, oldlenp, newp, newlen, &ip_dosourceroute));
+ /*
+ * Don't allow this to change in a secure environment.
+ */
+ if (securelevel > 0)
+ return (EPERM);
+ return (sysctl_int(oldp, oldlenp, newp, newlen,
+ &ip_dosourceroute));
+ case IPCTL_DIRECTEDBCAST:
+ return (sysctl_int(oldp, oldlenp, newp, newlen,
+ &ip_directedbcast));
default:
return (EOPNOTSUPP);
}
diff --git a/sys/netinet/ip_mroute.c b/sys/netinet/ip_mroute.c
index 9bb6c32c81d..c15f5394625 100644
--- a/sys/netinet/ip_mroute.c
+++ b/sys/netinet/ip_mroute.c
@@ -1,4 +1,5 @@
-/* $NetBSD: ip_mroute.c,v 1.24 1995/08/12 23:59:38 mycroft Exp $ */
+/* $OpenBSD: ip_mroute.c,v 1.2 1996/03/03 22:30:39 niklas Exp $ */
+/* $NetBSD: ip_mroute.c,v 1.25 1996/02/13 23:42:46 christos Exp $ */
/*
* IP multicast forwarding procedures
@@ -39,6 +40,8 @@
#include <netinet/igmp_var.h>
#include <netinet/ip_mroute.h>
+#include <machine/stdarg.h>
+
#define IP_MULTICASTOPTS 0
#define M_PULLUP(m, len) \
do { \
@@ -46,10 +49,6 @@
(m) = m_pullup((m), (len)); \
} while (0)
-static int ip_mdq();
-static void phyint_send();
-static void encap_send();
-
/*
* Globals. All but ip_mrouter and ip_mrtproto could be static,
* except for netstat or debugging purposes.
@@ -81,7 +80,6 @@ extern struct socket *ip_rsvpd;
extern int rsvp_on;
#endif /* RSVP_ISI */
-static void expire_upcalls();
#define EXPIRE_TIMEOUT (hz / 4) /* 4x / second */
#define UPCALL_EXPIRE 6 /* number of timeouts */
@@ -92,16 +90,41 @@ static void expire_upcalls();
struct pkt_queue qtable[MAXVIFS][MAXQSIZE];
-static void tbf_control __P((struct vif *, struct mbuf *, struct ip *,
- u_int32_t));
-static void tbf_queue __P((struct vif *, struct mbuf *, struct ip *));
-static void tbf_dequeue __P((struct vif *, int));
-static void tbf_process_q __P((struct vif *));
-static void tbf_reprocess_q __P((void *));
-static int tbf_dq_sel __P((struct vif *, struct ip *));
-static void tbf_send_packet __P((struct vif *, struct mbuf *));
-static void tbf_update_tokens __P((struct vif *));
-static int priority __P((struct vif *, struct ip *));
+static int get_sg_cnt __P((struct sioc_sg_req *));
+static int get_vif_cnt __P((struct sioc_vif_req *));
+static int ip_mrouter_init __P((struct socket *, struct mbuf *));
+static int get_version __P((struct mbuf *));
+static int set_assert __P((struct mbuf *));
+static int get_assert __P((struct mbuf *));
+static int add_vif __P((struct mbuf *));
+static int del_vif __P((struct mbuf *));
+static void update_mfc __P((struct mfcctl *, struct mfc *));
+static void expire_mfc __P((struct mfc *));
+static int add_mfc __P((struct mbuf *));
+#ifdef UPCALL_TIMING
+static void collate __P((struct timeval *));
+#endif
+static int del_mfc __P((struct mbuf *));
+static int socket_send __P((struct socket *, struct mbuf *,
+ struct sockaddr_in *));
+static void expire_upcalls __P((void *));
+#ifdef RSVP_ISI
+static int ip_mdq __P((struct mbuf *, struct ifnet *, struct mfc *, vifi_t));
+#else
+static int ip_mdq __P((struct mbuf *, struct ifnet *, struct mfc *));
+#endif
+static void phyint_send __P((struct ip *, struct vif *, struct mbuf *));
+static void encap_send __P((struct ip *, struct vif *, struct mbuf *));
+static void tbf_control __P((struct vif *, struct mbuf *, struct ip *,
+ u_int32_t));
+static void tbf_queue __P((struct vif *, struct mbuf *, struct ip *));
+static void tbf_process_q __P((struct vif *));
+static void tbf_dequeue __P((struct vif *, int));
+static void tbf_reprocess_q __P((void *));
+static int tbf_dq_sel __P((struct vif *, struct ip *));
+static void tbf_send_packet __P((struct vif *, struct mbuf *));
+static void tbf_update_tokens __P((struct vif *));
+static int priority __P((struct vif *, struct ip *));
/*
* 'Interfaces' associated with decapsulator (so we can tell
@@ -202,23 +225,8 @@ static int pim_assert;
#ifdef UPCALL_TIMING
u_int32_t upcall_data[51];
-static void collate __P((struct timeval *));
#endif /* UPCALL_TIMING */
-static int get_sg_cnt __P((struct sioc_sg_req *));
-static int get_vif_cnt __P((struct sioc_vif_req *));
-static int ip_mrouter_init __P((struct socket *, struct mbuf *));
-static int get_version __P((struct mbuf *));
-static int set_assert __P((struct mbuf *));
-static int get_assert __P((struct mbuf *));
-static int add_vif __P((struct mbuf *));
-static void reset_vif __P((struct vif *));
-static int del_vif __P((struct mbuf *));
-static void update_mfc __P((struct mfcctl *, struct mfc *));
-static void expire_mfc __P((struct mfc *));
-static int add_mfc __P((struct mbuf *));
-static int del_mfc __P((struct mbuf *));
-
/*
* Handle MRT setsockopt commands to modify the multicast routing tables.
*/
@@ -718,9 +726,8 @@ add_mfc(m)
struct mbuf *m;
{
struct mfcctl *mfccp;
- struct mfc *rt, *rt1;
- u_int32_t hash;
- vifi_t vifi;
+ struct mfc *rt;
+ u_int32_t hash = 0;
struct rtdetq *rte, *nrte;
register u_short nstl;
int s;
@@ -931,13 +938,12 @@ ip_mforward(m, ifp)
{
register struct ip *ip = mtod(m, struct ip *);
register struct mfc *rt;
- register struct vif *vifp;
register u_char *ipoptions;
- static struct sockproto k_igmpproto = { AF_INET, IPPROTO_IGMP };
static int srctun = 0;
- register struct mbuf *mm, *mn;
+ register struct mbuf *mm;
int s;
#ifdef RSVP_ISI
+ register struct vif *vifp;
vifi_t vifi;
#endif /* RSVP_ISI */
@@ -1146,8 +1152,10 @@ ip_mforward(m, ifp)
}
+/*ARGSUSED*/
static void
-expire_upcalls()
+expire_upcalls(v)
+ void *v;
{
int i;
int s;
@@ -1202,7 +1210,6 @@ ip_mdq(m, ifp, rt)
register struct ip *ip = mtod(m, struct ip *);
register vifi_t vifi;
register struct vif *vifp;
- register struct mbuf *tmp;
register int plen = ntohs(ip->ip_len);
/*
@@ -1420,14 +1427,24 @@ encap_send(ip, vifp, m)
* ENCAP_PROTO and a local destination address).
*/
void
-ipip_input(m, hlen)
- register struct mbuf *m;
- register int hlen;
+#if __STDC__
+ipip_input(struct mbuf *m, ...)
+#else
+ipip_input(m, va_alist)
+ struct mbuf *m;
+ va_dcl
+#endif
{
+ register int hlen;
register struct ip *ip = mtod(m, struct ip *);
register int s;
register struct ifqueue *ifq;
register struct vif *vifp;
+ va_list ap;
+
+ va_start(ap, m);
+ hlen = va_arg(ap, int);
+ va_end(ap);
if (!have_encap_tunnel) {
rip_input(m);
@@ -1566,7 +1583,6 @@ static void
tbf_process_q(vifp)
register struct vif *vifp;
{
- register struct mbuf *m;
register struct pkt_queue pkt_1;
register int index = (vifp - viftable);
register int s = splsoftnet();
@@ -1667,7 +1683,6 @@ tbf_send_packet(vifp,m)
register struct vif *vifp;
register struct mbuf *m;
{
- register struct mbuf *mcp;
int error;
int s = splsoftnet();
@@ -1726,7 +1741,6 @@ priority(vifp, ip)
register struct vif *vifp;
register struct ip *ip;
{
- register u_short port;
register int prio;
/* temporary hack; may add general packet classifier some day */
@@ -1867,6 +1881,7 @@ ip_rsvp_vif_done(so, m)
return (0);
}
+void
ip_rsvp_force_done(so)
struct socket *so;
{
@@ -1899,6 +1914,7 @@ ip_rsvp_force_done(so)
return;
}
+void
rsvp_input(m, ifp)
struct mbuf *m;
struct ifnet *ifp;
diff --git a/sys/netinet/ip_mroute.h b/sys/netinet/ip_mroute.h
index 411f8e8bf8d..ea68714db30 100644
--- a/sys/netinet/ip_mroute.h
+++ b/sys/netinet/ip_mroute.h
@@ -1,4 +1,5 @@
-/* $NetBSD: ip_mroute.h,v 1.9 1995/05/31 21:50:43 mycroft Exp $ */
+/* $OpenBSD: ip_mroute.h,v 1.2 1996/03/03 22:30:40 niklas Exp $ */
+/* $NetBSD: ip_mroute.h,v 1.10 1996/02/13 23:42:55 christos Exp $ */
/*
* Definitions for IP multicast forwarding.
@@ -210,9 +211,21 @@ struct pkt_queue {
};
-int ip_mforward __P((struct mbuf *, struct ifnet *));
-int ip_mrouter_get __P((int, struct socket *, struct mbuf **));
-int ip_mrouter_set __P((int, struct socket *, struct mbuf **));
-int ip_mrouter_done __P((void));
+int ip_mrouter_set __P((int, struct socket *, struct mbuf **));
+int ip_mrouter_get __P((int, struct socket *, struct mbuf **));
+int mrt_ioctl __P((u_long, caddr_t));
+int ip_mrouter_done __P((void));
+void reset_vif __P((struct vif *));
+#ifdef RSVP_ISI
+int ip_mforward __P((struct mbuf *, struct ifnet *, struct ip_moptions *));
+int legal_vif_num __P((int));
+int ip_rsvp_vif_init __P((struct socket *, struct mbuf *));
+int ip_rsvp_vif_done __P((struct socket *, struct mbuf *));
+void ip_rsvp_force_done __P((struct socket *));
+void rsvp_input __P((struct mbuf *, struct ifnet *));
+#else
+int ip_mforward __P((struct mbuf *, struct ifnet *));
+#endif
+void ipip_input __P((struct mbuf *, ...));
#endif /* _KERNEL */
diff --git a/sys/netinet/ip_output.c b/sys/netinet/ip_output.c
index cb399c1cfff..f28a9f79f04 100644
--- a/sys/netinet/ip_output.c
+++ b/sys/netinet/ip_output.c
@@ -1,4 +1,5 @@
-/* $NetBSD: ip_output.c,v 1.27 1995/07/01 03:44:55 cgd Exp $ */
+/* $OpenBSD: ip_output.c,v 1.4 1996/03/03 22:30:41 niklas Exp $ */
+/* $NetBSD: ip_output.c,v 1.28 1996/02/13 23:43:07 christos Exp $ */
/*
* Copyright (c) 1982, 1986, 1988, 1990, 1993
@@ -42,6 +43,7 @@
#include <sys/protosw.h>
#include <sys/socket.h>
#include <sys/socketvar.h>
+#include <sys/systm.h>
#include <net/if.h>
#include <net/route.h>
@@ -57,6 +59,8 @@
#include <machine/mtpr.h>
#endif
+#include <machine/stdarg.h>
+
static struct mbuf *ip_insertoptions __P((struct mbuf *, struct mbuf *, int *));
static void ip_mloopback
__P((struct ifnet *, struct mbuf *, struct sockaddr_in *));
@@ -71,12 +75,13 @@ extern int (*fr_checkp) __P((struct ip *, int, struct ifnet *, int, struct mbuf
* The mbuf opt, if present, will not be freed.
*/
int
-ip_output(m0, opt, ro, flags, imo)
+#if __STDC__
+ip_output(struct mbuf *m0, ...)
+#else
+ip_output(m0, va_alist)
struct mbuf *m0;
- struct mbuf *opt;
- struct route *ro;
- int flags;
- struct ip_moptions *imo;
+ va_dcl
+#endif
{
register struct ip *ip, *mhip;
register struct ifnet *ifp;
@@ -86,6 +91,20 @@ ip_output(m0, opt, ro, flags, imo)
struct route iproute;
struct sockaddr_in *dst;
struct in_ifaddr *ia;
+ struct mbuf *opt;
+ struct route *ro;
+ int flags;
+ struct ip_moptions *imo;
+ va_list ap;
+
+ va_start(ap, m0);
+ opt = va_arg(ap, struct mbuf *);
+ ro = va_arg(ap, struct route *);
+ flags = va_arg(ap, int);
+ imo = va_arg(ap, struct ip_moptions *);
+ va_end(ap);
+
+
#ifdef DIAGNOSTIC
if ((m->m_flags & M_PKTHDR) == 0)
@@ -497,7 +516,7 @@ ip_ctloutput(op, so, level, optname, mp)
{
register struct inpcb *inp = sotoinpcb(so);
register struct mbuf *m = *mp;
- register int optval;
+ register int optval = 0;
int error = 0;
if (level != IPPROTO_IP) {
diff --git a/sys/netinet/ip_var.h b/sys/netinet/ip_var.h
index c78365d93f8..7caed51f3e9 100644
--- a/sys/netinet/ip_var.h
+++ b/sys/netinet/ip_var.h
@@ -1,4 +1,5 @@
-/* $NetBSD: ip_var.h,v 1.15 1995/11/21 01:07:38 cgd Exp $ */
+/* $OpenBSD: ip_var.h,v 1.3 1996/03/03 22:30:42 niklas Exp $ */
+/* $NetBSD: ip_var.h,v 1.16 1996/02/13 23:43:20 christos Exp $ */
/*
* Copyright (c) 1982, 1986, 1993
@@ -167,8 +168,7 @@ int ip_getmoptions __P((int, struct ip_moptions *, struct mbuf **));
void ip_init __P((void));
int ip_mforward __P((struct mbuf *, struct ifnet *));
int ip_optcopy __P((struct ip *, struct ip *));
-int ip_output __P((struct mbuf *,
- struct mbuf *, struct route *, int, struct ip_moptions *));
+int ip_output __P((struct mbuf *, ...));
int ip_pcbopts __P((struct mbuf **, struct mbuf *));
struct ip *
ip_reass __P((struct ipqent *, struct ipq *));
@@ -183,8 +183,8 @@ int ip_sysctl __P((int *, u_int, void *, size_t *, void *, size_t));
void ipintr __P((void));
int rip_ctloutput __P((int, struct socket *, int, int, struct mbuf **));
void rip_init __P((void));
-void rip_input __P((struct mbuf *));
-int rip_output __P((struct mbuf *, struct socket *, u_long));
+void rip_input __P((struct mbuf *, ...));
+int rip_output __P((struct mbuf *, ...));
int rip_usrreq __P((struct socket *,
int, struct mbuf *, struct mbuf *, struct mbuf *));
#endif
diff --git a/sys/netinet/raw_ip.c b/sys/netinet/raw_ip.c
index 785e4b309cd..498d38a6e04 100644
--- a/sys/netinet/raw_ip.c
+++ b/sys/netinet/raw_ip.c
@@ -1,4 +1,5 @@
-/* $NetBSD: raw_ip.c,v 1.22 1995/11/30 16:42:18 pk Exp $ */
+/* $OpenBSD: raw_ip.c,v 1.3 1996/03/03 22:30:43 niklas Exp $ */
+/* $NetBSD: raw_ip.c,v 1.24 1996/02/13 23:43:29 christos Exp $ */
/*
* Copyright (c) 1982, 1986, 1988, 1993
@@ -53,6 +54,9 @@
#include <netinet/ip_var.h>
#include <netinet/ip_mroute.h>
#include <netinet/in_pcb.h>
+#include <netinet/in_var.h>
+
+#include <machine/stdarg.h>
struct inpcbtable rawcbtable;
@@ -73,7 +77,7 @@ void
rip_init()
{
- in_pcbinit(&rawcbtable);
+ in_pcbinit(&rawcbtable, 1);
}
struct sockaddr_in ripsrc = { sizeof(ripsrc), AF_INET };
@@ -83,8 +87,13 @@ struct sockaddr_in ripsrc = { sizeof(ripsrc), AF_INET };
* mbuf chain.
*/
void
-rip_input(m)
+#if __STDC__
+rip_input(struct mbuf *m, ...)
+#else
+rip_input(m, va_alist)
struct mbuf *m;
+ va_dcl
+#endif
{
register struct ip *ip = mtod(m, struct ip *);
register struct inpcb *inp;
@@ -104,7 +113,7 @@ rip_input(m)
continue;
if (last) {
struct mbuf *n;
- if (n = m_copy(m, 0, (int)M_COPYALL)) {
+ if ((n = m_copy(m, 0, (int)M_COPYALL)) != NULL) {
if (sbappendaddr(&last->so_rcv,
sintosa(&ripsrc), n,
(struct mbuf *)0) == 0)
@@ -134,15 +143,29 @@ rip_input(m)
* Tack on options user may have setup with control call.
*/
int
-rip_output(m, so, dst)
- register struct mbuf *m;
+#if __STDC__
+rip_output(struct mbuf *m, ...)
+#else
+rip_output(m, va_alist)
+ struct mbuf *m;
+ va_dcl
+#endif
+{
struct socket *so;
u_long dst;
-{
register struct ip *ip;
- register struct inpcb *inp = sotoinpcb(so);
+ register struct inpcb *inp;
struct mbuf *opts;
- int flags = (so->so_options & SO_DONTROUTE) | IP_ALLOWBROADCAST;
+ int flags;
+ va_list ap;
+
+ va_start(ap, m);
+ so = va_arg(ap, struct socket *);
+ dst = va_arg(ap, u_long);
+ va_end(ap);
+
+ inp = sotoinpcb(so);
+ flags = (so->so_options & SO_DONTROUTE) | IP_ALLOWBROADCAST;
/*
* If the user handed us a complete IP packet, use it.
@@ -182,7 +205,6 @@ rip_ctloutput(op, so, level, optname, m)
struct mbuf **m;
{
register struct inpcb *inp = sotoinpcb(so);
- register int error;
if (level != IPPROTO_IP) {
if (m != 0 && *m != 0)
diff --git a/sys/netinet/tcp_debug.c b/sys/netinet/tcp_debug.c
index beabcd33c96..17e038acf8d 100644
--- a/sys/netinet/tcp_debug.c
+++ b/sys/netinet/tcp_debug.c
@@ -1,4 +1,5 @@
-/* $NetBSD: tcp_debug.c,v 1.9 1995/04/13 06:36:32 cgd Exp $ */
+/* $OpenBSD: tcp_debug.c,v 1.2 1996/03/03 22:30:44 niklas Exp $ */
+/* $NetBSD: tcp_debug.c,v 1.10 1996/02/13 23:43:36 christos Exp $ */
/*
* Copyright (c) 1982, 1986, 1993
@@ -80,8 +81,10 @@ tcp_trace(act, ostate, tp, ti, req)
struct tcpiphdr *ti;
int req;
{
+#ifdef TCPDEBUG
tcp_seq seq, ack;
int len, flags;
+#endif
struct tcp_debug *td = &tcp_debug[tcp_debx++];
if (tcp_debx == TCP_NDEBUG)
diff --git a/sys/netinet/tcp_input.c b/sys/netinet/tcp_input.c
index b49c0e9defe..9db513df8dd 100644
--- a/sys/netinet/tcp_input.c
+++ b/sys/netinet/tcp_input.c
@@ -1,4 +1,5 @@
-/* $NetBSD: tcp_input.c,v 1.20 1995/11/21 01:07:39 cgd Exp $ */
+/* $OpenBSD: tcp_input.c,v 1.3 1996/03/03 22:30:45 niklas Exp $ */
+/* $NetBSD: tcp_input.c,v 1.23 1996/02/13 23:43:44 christos Exp $ */
/*
* Copyright (c) 1982, 1986, 1988, 1990, 1993, 1994
@@ -61,9 +62,10 @@
#include <netinet/tcpip.h>
#include <netinet/tcp_debug.h>
+#include <machine/stdarg.h>
+
int tcprexmtthresh = 3;
struct tcpiphdr tcp_saveti;
-struct inpcb *tcp_last_inpcb = 0;
extern u_long sb_max;
@@ -234,26 +236,35 @@ present:
* protocol specification dated September, 1981 very closely.
*/
void
-tcp_input(m, iphlen)
+#if __STDC__
+tcp_input(struct mbuf *m, ...)
+#else
+tcp_input(m, va_alist)
register struct mbuf *m;
- int iphlen;
+#endif
{
register struct tcpiphdr *ti;
register struct inpcb *inp;
caddr_t optp = NULL;
- int optlen;
+ int optlen = 0;
int len, tlen, off;
register struct tcpcb *tp = 0;
register int tiflags;
- struct socket *so;
+ struct socket *so = NULL;
int todrop, acked, ourfinisacked, needoutput = 0;
- short ostate;
+ short ostate = 0;
struct in_addr laddr;
int dropsocket = 0;
int iss = 0;
u_long tiwin;
u_int32_t ts_val, ts_ecr;
int ts_present = 0;
+ int iphlen;
+ va_list ap;
+
+ va_start(ap, m);
+ iphlen = va_arg(ap, int);
+ va_end(ap);
tcpstat.tcps_rcvtotal++;
/*
@@ -279,7 +290,7 @@ tcp_input(m, iphlen)
bzero(ti->ti_x1, sizeof ti->ti_x1);
ti->ti_len = (u_int16_t)tlen;
HTONS(ti->ti_len);
- if (ti->ti_sum = in_cksum(m, len)) {
+ if ((ti->ti_sum = in_cksum(m, len)) != 0) {
tcpstat.tcps_rcvbadsum++;
goto drop;
}
@@ -338,13 +349,10 @@ tcp_input(m, iphlen)
* Locate pcb for segment.
*/
findpcb:
- inp = tcp_last_inpcb;
- if (inp == 0 ||
- inp->inp_lport != ti->ti_dport ||
- inp->inp_fport != ti->ti_sport ||
- inp->inp_faddr.s_addr != ti->ti_src.s_addr ||
- inp->inp_laddr.s_addr != ti->ti_dst.s_addr) {
- ++tcpstat.tcps_pcbcachemiss;
+ inp = in_pcbhashlookup(&tcbtable, ti->ti_src, ti->ti_sport,
+ ti->ti_dst, ti->ti_dport);
+ if (inp == 0) {
+ ++tcpstat.tcps_pcbhashmiss;
inp = in_pcblookup(&tcbtable, ti->ti_src, ti->ti_sport,
ti->ti_dst, ti->ti_dport, INPLOOKUP_WILDCARD);
/*
@@ -353,9 +361,10 @@ findpcb:
* If the TCB exists but is in CLOSED state, it is embryonic,
* but should either do a listen or a connect soon.
*/
- if (inp == 0)
+ if (inp == 0) {
+ ++tcpstat.tcps_noport;
goto dropwithreset;
- tcp_last_inpcb = inp;
+ }
}
tp = intotcpcb(inp);
@@ -395,6 +404,7 @@ findpcb:
inp = (struct inpcb *)so->so_pcb;
inp->inp_laddr = ti->ti_dst;
inp->inp_lport = ti->ti_dport;
+ in_pcbrehash(inp);
#if BSD>=43
inp->inp_options = ip_srcroute();
#endif
@@ -1124,10 +1134,9 @@ step6:
* Update window information.
* Don't look at window if no ACK: TAC's send garbage on first SYN.
*/
- if ((tiflags & TH_ACK) &&
- (SEQ_LT(tp->snd_wl1, ti->ti_seq) || tp->snd_wl1 == ti->ti_seq &&
- (SEQ_LT(tp->snd_wl2, ti->ti_ack) ||
- tp->snd_wl2 == ti->ti_ack && tiwin > tp->snd_wnd))) {
+ if (((tiflags & TH_ACK) && SEQ_LT(tp->snd_wl1, ti->ti_seq)) ||
+ (tp->snd_wl1 == ti->ti_seq && SEQ_LT(tp->snd_wl2, ti->ti_ack)) ||
+ (tp->snd_wl2 == ti->ti_ack && tiwin > tp->snd_wnd)) {
/* keep track of pure window updates */
if (ti->ti_len == 0 &&
tp->snd_wl2 == ti->ti_ack && tiwin > tp->snd_wnd)
@@ -1185,7 +1194,7 @@ step6:
* but if two URG's are pending at once, some out-of-band
* data may creep in... ick.
*/
- if (ti->ti_urp <= ti->ti_len
+ if (ti->ti_urp <= (u_int16_t) ti->ti_len
#ifdef SO_OOBINLINE
&& (so->so_options & SO_OOBINLINE) == 0
#endif
@@ -1209,7 +1218,7 @@ dodata: /* XXX */
* case PRU_RCVD). If a FIN has already been received on this
* connection then we just ignore the text.
*/
- if ((ti->ti_len || (tiflags&TH_FIN)) &&
+ if ((ti->ti_len || (tiflags & TH_FIN)) &&
TCPS_HAVERCVDFIN(tp->t_state) == 0) {
TCP_REASS(tp, ti, m, so, tiflags);
/*
@@ -1225,9 +1234,10 @@ dodata: /* XXX */
/*
* If FIN is received ACK the FIN and let the user know
- * that the connection is closing.
+ * that the connection is closing. Ignore a FIN received before
+ * the connection is fully established.
*/
- if (tiflags & TH_FIN) {
+ if ((tiflags & TH_FIN) && TCPS_HAVEESTABLISHED(tp->t_state)) {
if (TCPS_HAVERCVDFIN(tp->t_state) == 0) {
socantrcvmore(so);
tp->t_flags |= TF_ACKNOW;
@@ -1236,10 +1246,8 @@ dodata: /* XXX */
switch (tp->t_state) {
/*
- * In SYN_RECEIVED and ESTABLISHED STATES
- * enter the CLOSE_WAIT state.
+ * In ESTABLISHED STATE enter the CLOSE_WAIT state.
*/
- case TCPS_SYN_RECEIVED:
case TCPS_ESTABLISHED:
tp->t_state = TCPS_CLOSE_WAIT;
break;
@@ -1575,7 +1583,7 @@ tcp_mss(tp, offer)
/* default variation is +- 1 rtt */
tp->t_rttvar =
tp->t_srtt * TCP_RTTVAR_SCALE / TCP_RTT_SCALE;
- TCPT_RANGESET(tp->t_rxtcur,
+ TCPT_RANGESET((long) tp->t_rxtcur,
((tp->t_srtt >> 2) + tp->t_rttvar) >> 1,
tp->t_rttmin, TCPTV_REXMTMAX);
}
diff --git a/sys/netinet/tcp_output.c b/sys/netinet/tcp_output.c
index d237adfced0..b98f5a7d9dd 100644
--- a/sys/netinet/tcp_output.c
+++ b/sys/netinet/tcp_output.c
@@ -1,4 +1,5 @@
-/* $NetBSD: tcp_output.c,v 1.13 1995/04/13 20:09:23 cgd Exp $ */
+/* $OpenBSD: tcp_output.c,v 1.2 1996/03/03 22:30:46 niklas Exp $ */
+/* $NetBSD: tcp_output.c,v 1.14 1996/02/13 23:43:53 christos Exp $ */
/*
* Copyright (c) 1982, 1986, 1988, 1990, 1993
@@ -60,6 +61,11 @@
#include <netinet/tcpip.h>
#include <netinet/tcp_debug.h>
+#ifdef TUBA
+#include <netiso/iso.h>
+#include <netiso/tuba_table.h>
+#endif
+
#ifdef notyet
extern struct mbuf *m_copypack();
#endif
diff --git a/sys/netinet/tcp_subr.c b/sys/netinet/tcp_subr.c
index c64a868767a..7c4d2183013 100644
--- a/sys/netinet/tcp_subr.c
+++ b/sys/netinet/tcp_subr.c
@@ -1,4 +1,5 @@
-/* $NetBSD: tcp_subr.c,v 1.20 1995/11/21 01:07:41 cgd Exp $ */
+/* $OpenBSD: tcp_subr.c,v 1.3 1996/03/03 22:30:47 niklas Exp $ */
+/* $NetBSD: tcp_subr.c,v 1.22 1996/02/13 23:44:00 christos Exp $ */
/*
* Copyright (c) 1982, 1986, 1988, 1990, 1993
@@ -66,7 +67,10 @@ int tcp_mssdflt = TCP_MSS;
int tcp_rttdflt = TCPTV_SRTTDFLT / PR_SLOWHZ;
int tcp_do_rfc1323 = 1;
-extern struct inpcb *tcp_last_inpcb;
+#ifndef TCBHASHSIZE
+#define TCBHASHSIZE 128
+#endif
+int tcbhashsize = TCBHASHSIZE;
/*
* Tcp initialization
@@ -76,7 +80,7 @@ tcp_init()
{
tcp_iss = 1; /* wrong */
- in_pcbinit(&tcbtable);
+ in_pcbinit(&tcbtable, tcbhashsize);
if (max_protohdr < sizeof(struct tcpiphdr))
max_protohdr = sizeof(struct tcpiphdr);
if (max_linkhdr + sizeof(struct tcpiphdr) > MHLEN)
@@ -272,7 +276,6 @@ tcp_close(tp)
register struct ipqent *qe;
struct inpcb *inp = tp->t_inpcb;
struct socket *so = inp->inp_socket;
- register struct mbuf *m;
#ifdef RTV_RTT
register struct rtentry *rt;
@@ -291,7 +294,7 @@ tcp_close(tp)
if (SEQ_LT(tp->iss + so->so_snd.sb_hiwat * 16, tp->snd_max) &&
(rt = inp->inp_route.ro_rt) &&
satosin(rt_key(rt))->sin_addr.s_addr != INADDR_ANY) {
- register u_long i;
+ register u_long i = 0;
if ((rt->rt_rmx.rmx_locks & RTV_RTT) == 0) {
i = tp->t_srtt *
@@ -324,8 +327,8 @@ tcp_close(tp)
* before we start updating, then update on both good
* and bad news.
*/
- if ((rt->rt_rmx.rmx_locks & RTV_SSTHRESH) == 0 &&
- (i = tp->snd_ssthresh) && rt->rt_rmx.rmx_ssthresh ||
+ if (((rt->rt_rmx.rmx_locks & RTV_SSTHRESH) == 0 &&
+ (i = tp->snd_ssthresh) && rt->rt_rmx.rmx_ssthresh) ||
i < (rt->rt_rmx.rmx_sendpipe / 2)) {
/*
* convert the limit from user data bytes to
@@ -354,9 +357,6 @@ tcp_close(tp)
free(tp, M_PCB);
inp->inp_ppcb = 0;
soisdisconnected(so);
- /* clobber input pcb cache if we're closing the cached connection */
- if (inp == tcp_last_inpcb)
- tcp_last_inpcb = 0;
in_pcbdetach(inp);
tcpstat.tcps_closed++;
return ((struct tcpcb *)0);
@@ -402,20 +402,20 @@ tcp_notify(inp, error)
sowwakeup(so);
}
-void
-tcp_ctlinput(cmd, sa, ip)
+void *
+tcp_ctlinput(cmd, sa, v)
int cmd;
struct sockaddr *sa;
- register struct ip *ip;
+ register void *v;
{
+ register struct ip *ip = v;
register struct tcphdr *th;
- extern struct in_addr zeroin_addr;
extern int inetctlerrmap[];
void (*notify) __P((struct inpcb *, int)) = tcp_notify;
int errno;
if ((unsigned)cmd >= PRC_NCMDS)
- return;
+ return NULL;
errno = inetctlerrmap[cmd];
if (cmd == PRC_QUENCH)
notify = tcp_quench;
@@ -424,13 +424,14 @@ tcp_ctlinput(cmd, sa, ip)
else if (cmd == PRC_HOSTDEAD)
ip = 0;
else if (errno == 0)
- return;
+ return NULL;
if (ip) {
th = (struct tcphdr *)((caddr_t)ip + (ip->ip_hl << 2));
in_pcbnotify(&tcbtable, sa, th->th_dport, ip->ip_src,
th->th_sport, errno, notify);
} else
in_pcbnotifyall(&tcbtable, sa, errno, notify);
+ return NULL;
}
/*
diff --git a/sys/netinet/tcp_timer.c b/sys/netinet/tcp_timer.c
index 21784e535d5..73885ccf618 100644
--- a/sys/netinet/tcp_timer.c
+++ b/sys/netinet/tcp_timer.c
@@ -1,4 +1,5 @@
-/* $NetBSD: tcp_timer.c,v 1.13 1995/08/12 23:59:39 mycroft Exp $ */
+/* $OpenBSD: tcp_timer.c,v 1.2 1996/03/03 22:30:48 niklas Exp $ */
+/* $NetBSD: tcp_timer.c,v 1.14 1996/02/13 23:44:09 christos Exp $ */
/*
* Copyright (c) 1982, 1986, 1988, 1990, 1993
@@ -203,7 +204,7 @@ tcp_timers(tp, timer)
}
tcpstat.tcps_rexmttimeo++;
rexmt = TCP_REXMTVAL(tp) * tcp_backoff[tp->t_rxtshift];
- TCPT_RANGESET(tp->t_rxtcur, rexmt,
+ TCPT_RANGESET((long) tp->t_rxtcur, rexmt,
tp->t_rttmin, TCPTV_REXMTMAX);
tp->t_timer[TCPT_REXMT] = tp->t_rxtcur;
/*
diff --git a/sys/netinet/tcp_usrreq.c b/sys/netinet/tcp_usrreq.c
index c0cda168fa1..edd61e83389 100644
--- a/sys/netinet/tcp_usrreq.c
+++ b/sys/netinet/tcp_usrreq.c
@@ -1,4 +1,5 @@
-/* $NetBSD: tcp_usrreq.c,v 1.17 1995/09/30 07:02:05 thorpej Exp $ */
+/* $OpenBSD: tcp_usrreq.c,v 1.2 1996/03/03 22:30:49 niklas Exp $ */
+/* $NetBSD: tcp_usrreq.c,v 1.20 1996/02/13 23:44:16 christos Exp $ */
/*
* Copyright (c) 1982, 1986, 1988, 1993
@@ -45,6 +46,10 @@
#include <sys/protosw.h>
#include <sys/errno.h>
#include <sys/stat.h>
+#include <sys/proc.h>
+#include <sys/ucred.h>
+#include <vm/vm.h>
+#include <sys/sysctl.h>
#include <net/if.h>
#include <net/route.h>
@@ -81,7 +86,7 @@ tcp_usrreq(so, req, m, nam, control)
struct mbuf *m, *nam, *control;
{
register struct inpcb *inp;
- register struct tcpcb *tp;
+ register struct tcpcb *tp = NULL;
int s;
int error = 0;
int ostate;
@@ -521,8 +526,18 @@ tcp_usrclosed(tp)
tp->t_state = TCPS_LAST_ACK;
break;
}
- if (tp && tp->t_state >= TCPS_FIN_WAIT_2)
+ if (tp && tp->t_state >= TCPS_FIN_WAIT_2) {
soisdisconnected(tp->t_inpcb->inp_socket);
+ /*
+ * If we are in FIN_WAIT_2, we arrived here because the
+ * application did a shutdown of the send side. Like the
+ * case of a transition from FIN_WAIT_1 to FIN_WAIT_2 after
+ * a full close, we start a timer to make sure sockets are
+ * not left in FIN_WAIT_2 forever.
+ */
+ if (tp->t_state == TCPS_FIN_WAIT_2)
+ tp->t_timer[TCPT_2MSL] = tcp_maxidle;
+ }
return (tp);
}
diff --git a/sys/netinet/tcp_var.h b/sys/netinet/tcp_var.h
index 99ab071627c..ecae9f2469d 100644
--- a/sys/netinet/tcp_var.h
+++ b/sys/netinet/tcp_var.h
@@ -1,4 +1,5 @@
-/* $NetBSD: tcp_var.h,v 1.15 1995/11/21 01:07:43 cgd Exp $ */
+/* $OpenBSD: tcp_var.h,v 1.3 1996/03/03 22:30:50 niklas Exp $ */
+/* $NetBSD: tcp_var.h,v 1.17 1996/02/13 23:44:24 christos Exp $ */
/*
* Copyright (c) 1982, 1986, 1993, 1994
@@ -220,7 +221,9 @@ struct tcpstat {
u_long tcps_pawsdrop; /* segments dropped due to PAWS */
u_long tcps_predack; /* times hdr predict ok for acks */
u_long tcps_preddat; /* times hdr predict ok for data pkts */
- u_long tcps_pcbcachemiss;
+
+ u_long tcps_pcbhashmiss; /* input packets missing pcb hash */
+ u_long tcps_noport; /* no socket on port */
};
/*
@@ -245,7 +248,7 @@ int tcp_attach __P((struct socket *));
void tcp_canceltimers __P((struct tcpcb *));
struct tcpcb *
tcp_close __P((struct tcpcb *));
-void tcp_ctlinput __P((int, struct sockaddr *, struct ip *));
+void *tcp_ctlinput __P((int, struct sockaddr *, void *));
int tcp_ctloutput __P((int, struct socket *, int, int, struct mbuf **));
struct tcpcb *
tcp_disconnect __P((struct tcpcb *));
@@ -256,7 +259,7 @@ void tcp_dooptions __P((struct tcpcb *,
void tcp_drain __P((void));
void tcp_fasttimo __P((void));
void tcp_init __P((void));
-void tcp_input __P((struct mbuf *, int));
+void tcp_input __P((struct mbuf *, ...));
int tcp_mss __P((struct tcpcb *, u_int));
struct tcpcb *
tcp_newtcpcb __P((struct inpcb *));
diff --git a/sys/netinet/udp_usrreq.c b/sys/netinet/udp_usrreq.c
index b7647352803..08bd09b1a79 100644
--- a/sys/netinet/udp_usrreq.c
+++ b/sys/netinet/udp_usrreq.c
@@ -1,4 +1,5 @@
-/* $NetBSD: udp_usrreq.c,v 1.25 1995/11/21 01:07:46 cgd Exp $ */
+/* $OpenBSD: udp_usrreq.c,v 1.3 1996/03/03 22:30:51 niklas Exp $ */
+/* $NetBSD: udp_usrreq.c,v 1.27 1996/02/13 23:44:32 christos Exp $ */
/*
* Copyright (c) 1982, 1986, 1988, 1990, 1993
@@ -43,6 +44,11 @@
#include <sys/socketvar.h>
#include <sys/errno.h>
#include <sys/stat.h>
+#include <sys/systm.h>
+#include <sys/proc.h>
+
+#include <vm/vm.h>
+#include <sys/sysctl.h>
#include <net/if.h>
#include <net/route.h>
@@ -57,6 +63,8 @@
#include <netinet/udp.h>
#include <netinet/udp_var.h>
+#include <machine/stdarg.h>
+
/*
* UDP protocol implementation.
* Per RFC 768, August, 1980.
@@ -68,23 +76,31 @@ int udpcksum = 0; /* XXX */
#endif
struct sockaddr_in udp_in = { sizeof(udp_in), AF_INET };
-struct inpcb *udp_last_inpcb = 0;
static void udp_detach __P((struct inpcb *));
static void udp_notify __P((struct inpcb *, int));
static struct mbuf *udp_saveopt __P((caddr_t, int, int));
+#ifndef UDBHASHSIZE
+#define UDBHASHSIZE 128
+#endif
+int udbhashsize = UDBHASHSIZE;
+
void
udp_init()
{
- in_pcbinit(&udbtable);
+ in_pcbinit(&udbtable, udbhashsize);
}
void
-udp_input(m, iphlen)
- register struct mbuf *m;
- int iphlen;
+#if __STDC__
+udp_input(struct mbuf *m, ...)
+#else
+udp_input(m, va_alist)
+ struct mbuf *m;
+ va_dcl
+#endif
{
register struct ip *ip;
register struct udphdr *uh;
@@ -92,6 +108,12 @@ udp_input(m, iphlen)
struct mbuf *opts = 0;
int len;
struct ip save_ip;
+ int iphlen;
+ va_list ap;
+
+ va_start(ap, m);
+ iphlen = va_arg(ap, int);
+ va_end(ap);
udpstat.udps_ipackets++;
@@ -145,7 +167,7 @@ udp_input(m, iphlen)
bzero(((struct ipovly *)ip)->ih_x1,
sizeof ((struct ipovly *)ip)->ih_x1);
((struct ipovly *)ip)->ih_len = uh->uh_ulen;
- if (uh->uh_sum = in_cksum(m, len + sizeof (struct ip))) {
+ if ((uh->uh_sum = in_cksum(m, len + sizeof (struct ip))) != 0) {
udpstat.udps_badsum++;
m_freem(m);
return;
@@ -246,13 +268,10 @@ udp_input(m, iphlen)
/*
* Locate pcb for datagram.
*/
- inp = udp_last_inpcb;
- if (inp == 0 ||
- inp->inp_lport != uh->uh_dport ||
- inp->inp_fport != uh->uh_sport ||
- inp->inp_faddr.s_addr != ip->ip_src.s_addr ||
- inp->inp_laddr.s_addr != ip->ip_dst.s_addr) {
- udpstat.udpps_pcbcachemiss++;
+ inp = in_pcbhashlookup(&udbtable, ip->ip_src, uh->uh_sport,
+ ip->ip_dst, uh->uh_dport);
+ if (inp == 0) {
+ ++udpstat.udps_pcbhashmiss;
inp = in_pcblookup(&udbtable, ip->ip_src, uh->uh_sport,
ip->ip_dst, uh->uh_dport, INPLOOKUP_WILDCARD);
if (inp == 0) {
@@ -266,7 +285,6 @@ udp_input(m, iphlen)
icmp_error(m, ICMP_UNREACH, ICMP_UNREACH_PORT, 0, 0);
return;
}
- udp_last_inpcb = inp;
}
/*
@@ -357,45 +375,58 @@ udp_notify(inp, errno)
sowwakeup(inp->inp_socket);
}
-void
-udp_ctlinput(cmd, sa, ip)
+void *
+udp_ctlinput(cmd, sa, v)
int cmd;
struct sockaddr *sa;
- register struct ip *ip;
+ void *v;
{
+ register struct ip *ip = v;
register struct udphdr *uh;
- extern struct in_addr zeroin_addr;
extern int inetctlerrmap[];
void (*notify) __P((struct inpcb *, int)) = udp_notify;
int errno;
if ((unsigned)cmd >= PRC_NCMDS)
- return;
+ return NULL;
errno = inetctlerrmap[cmd];
if (PRC_IS_REDIRECT(cmd))
notify = in_rtchange, ip = 0;
else if (cmd == PRC_HOSTDEAD)
ip = 0;
else if (errno == 0)
- return;
+ return NULL;
if (ip) {
uh = (struct udphdr *)((caddr_t)ip + (ip->ip_hl << 2));
in_pcbnotify(&udbtable, sa, uh->uh_dport, ip->ip_src,
uh->uh_sport, errno, notify);
} else
in_pcbnotifyall(&udbtable, sa, errno, notify);
+ return NULL;
}
int
-udp_output(inp, m, addr, control)
+#if __STDC__
+udp_output(struct mbuf *m, ...)
+#else
+udp_output(m, va_alist)
+ struct mbuf *m;
+ va_dcl
+#endif
+{
register struct inpcb *inp;
- register struct mbuf *m;
struct mbuf *addr, *control;
-{
register struct udpiphdr *ui;
register int len = m->m_pkthdr.len;
struct in_addr laddr;
- int s, error = 0;
+ int s = 0, error = 0;
+ va_list ap;
+
+ va_start(ap, m);
+ inp = va_arg(ap, struct inpcb *);
+ addr = va_arg(ap, struct mbuf *);
+ control = va_arg(ap, struct mbuf *);
+ va_end(ap);
if (control)
m_freem(control); /* XXX */
@@ -568,7 +599,7 @@ udp_usrreq(so, req, m, addr, control)
break;
case PRU_SEND:
- return (udp_output(inp, m, addr, control));
+ return (udp_output(m, inp, addr, control));
case PRU_ABORT:
soisdisconnected(so);
@@ -621,8 +652,6 @@ udp_detach(inp)
{
int s = splsoftnet();
- if (inp == udp_last_inpcb)
- udp_last_inpcb = 0;
in_pcbdetach(inp);
splx(s);
}
@@ -630,6 +659,7 @@ udp_detach(inp)
/*
* Sysctl for udp variables.
*/
+int
udp_sysctl(name, namelen, oldp, oldlenp, newp, newlen)
int *name;
u_int namelen;
diff --git a/sys/netinet/udp_var.h b/sys/netinet/udp_var.h
index c58dbce9616..c4bf23fdf2e 100644
--- a/sys/netinet/udp_var.h
+++ b/sys/netinet/udp_var.h
@@ -1,4 +1,5 @@
-/* $NetBSD: udp_var.h,v 1.10 1995/11/21 01:07:48 cgd Exp $ */
+/* $OpenBSD: udp_var.h,v 1.3 1996/03/03 22:30:52 niklas Exp $ */
+/* $NetBSD: udp_var.h,v 1.12 1996/02/13 23:44:41 christos Exp $ */
/*
* Copyright (c) 1982, 1986, 1989, 1993
@@ -61,7 +62,7 @@ struct udpstat {
u_long udps_noport; /* no socket on port */
u_long udps_noportbcast; /* of above, arrived as broadcast */
u_long udps_fullsock; /* not delivered, input socket full */
- u_long udpps_pcbcachemiss; /* input packets missing pcb cache */
+ u_long udps_pcbhashmiss; /* input packets missing pcb hash */
/* output statistics: */
u_long udps_opackets; /* total output packets */
};
@@ -81,11 +82,10 @@ struct udpstat {
struct inpcbtable udbtable;
struct udpstat udpstat;
-void udp_ctlinput __P((int, struct sockaddr *, struct ip *));
+void *udp_ctlinput __P((int, struct sockaddr *, void *));
void udp_init __P((void));
-void udp_input __P((struct mbuf *, int));
-int udp_output __P((struct inpcb *,
- struct mbuf *, struct mbuf *, struct mbuf *));
+void udp_input __P((struct mbuf *, ...));
+int udp_output __P((struct mbuf *, ...));
int udp_sysctl __P((int *, u_int, void *, size_t *, void *, size_t));
int udp_usrreq __P((struct socket *,
int, struct mbuf *, struct mbuf *, struct mbuf *));