summaryrefslogtreecommitdiffstats
path: root/sys/netipx
diff options
context:
space:
mode:
authorwollman <wollman@FreeBSD.org>1997-08-16 19:16:27 +0000
committerwollman <wollman@FreeBSD.org>1997-08-16 19:16:27 +0000
commit4542c1cf5d7077caf33d6d9468f5e647cd9d19e5 (patch)
tree69fd093ef1e8c080592999507b664fe6315c0e10 /sys/netipx
parentf4edc7fc6748272644fb845fc8636a5c261247d6 (diff)
downloadFreeBSD-src-4542c1cf5d7077caf33d6d9468f5e647cd9d19e5.zip
FreeBSD-src-4542c1cf5d7077caf33d6d9468f5e647cd9d19e5.tar.gz
Fix all areas of the system (or at least all those in LINT) to avoid storing
socket addresses in mbufs. (Socket buffers are the one exception.) A number of kernel APIs needed to get fixed in order to make this happen. Also, fix three protocol families which kept PCBs in mbufs to not malloc them instead. Delete some old compatibility cruft while we're at it, and add some new routines in the in_cksum family.
Diffstat (limited to 'sys/netipx')
-rw-r--r--sys/netipx/ipx_pcb.c41
-rw-r--r--sys/netipx/ipx_pcb.h10
-rw-r--r--sys/netipx/ipx_usrreq.c24
-rw-r--r--sys/netipx/ipx_var.h6
-rw-r--r--sys/netipx/spx_usrreq.c58
5 files changed, 67 insertions, 72 deletions
diff --git a/sys/netipx/ipx_pcb.c b/sys/netipx/ipx_pcb.c
index e0a66f7..483bab3 100644
--- a/sys/netipx/ipx_pcb.c
+++ b/sys/netipx/ipx_pcb.c
@@ -33,7 +33,7 @@
*
* @(#)ipx_pcb.c
*
- * $Id: ipx_pcb.c,v 1.9 1997/05/10 09:58:54 jhay Exp $
+ * $Id: ipx_pcb.c,v 1.10 1997/06/26 19:35:53 jhay Exp $
*/
#include <sys/param.h>
@@ -59,13 +59,12 @@ ipx_pcballoc(so, head, p)
struct ipxpcb *head;
struct proc *p;
{
- struct mbuf *m;
register struct ipxpcb *ipxp;
- m = m_getclr(M_DONTWAIT, MT_PCB);
- if (m == NULL)
+ MALLOC(ipxp, struct ipxpcb *, sizeof *ipxp, M_PCB, M_NOWAIT);
+ if (ipxp == NULL)
return (ENOBUFS);
- ipxp = mtod(m, struct ipxpcb *);
+ bzero(ipxp, sizeof *ipxp);
ipxp->ipxp_socket = so;
insque(ipxp, head);
so->so_pcb = (caddr_t)ipxp;
@@ -75,7 +74,7 @@ ipx_pcballoc(so, head, p)
int
ipx_pcbbind(ipxp, nam, p)
register struct ipxpcb *ipxp;
- struct mbuf *nam;
+ struct sockaddr *nam;
struct proc *p;
{
register struct sockaddr_ipx *sipx;
@@ -85,9 +84,7 @@ ipx_pcbbind(ipxp, nam, p)
return (EINVAL);
if (nam == NULL)
goto noname;
- sipx = mtod(nam, struct sockaddr_ipx *);
- if (nam->m_len != sizeof(*sipx))
- return (EINVAL);
+ sipx = (struct sockaddr_ipx *)nam;
if (!ipx_nullhost(sipx->sipx_addr)) {
int tport = sipx->sipx_port;
@@ -130,19 +127,17 @@ noname:
int
ipx_pcbconnect(ipxp, nam, p)
struct ipxpcb *ipxp;
- struct mbuf *nam;
+ struct sockaddr *nam;
struct proc *p;
{
struct ipx_ifaddr *ia;
- register struct sockaddr_ipx *sipx = mtod(nam, struct sockaddr_ipx *);
+ register struct sockaddr_ipx *sipx = (struct sockaddr_ipx *)nam;
register struct ipx_addr *dst;
register struct route *ro;
struct ifnet *ifp;
ia = NULL;
- if (nam->m_len != sizeof(*sipx))
- return (EINVAL);
if (sipx->sipx_family != AF_IPX)
return (EAFNOSUPPORT);
if (sipx->sipx_port == 0 || ipx_nullhost(sipx->sipx_addr))
@@ -248,7 +243,7 @@ ipx_pcbconnect(ipxp, nam, p)
if (ipx_pcblookup(&sipx->sipx_addr, ipxp->ipxp_lport, 0))
return (EADDRINUSE);
if (ipxp->ipxp_lport == 0)
- ipx_pcbbind(ipxp, (struct mbuf *)NULL, p);
+ ipx_pcbbind(ipxp, (struct sockaddr *)NULL, p);
/* XXX just leave it zero if we can't find a route */
@@ -278,37 +273,37 @@ ipx_pcbdetach(ipxp)
if (ipxp->ipxp_route.ro_rt != NULL)
rtfree(ipxp->ipxp_route.ro_rt);
remque(ipxp);
- m_free(dtom(ipxp));
+ FREE(ipxp, M_PCB);
}
void
ipx_setsockaddr(ipxp, nam)
register struct ipxpcb *ipxp;
- struct mbuf *nam;
+ struct sockaddr **nam;
{
- register struct sockaddr_ipx *sipx = mtod(nam, struct sockaddr_ipx *);
+ struct sockaddr_ipx *sipx, ssipx;
- nam->m_len = sizeof(*sipx);
- sipx = mtod(nam, struct sockaddr_ipx *);
+ sipx = &ssipx;
bzero((caddr_t)sipx, sizeof(*sipx));
sipx->sipx_len = sizeof(*sipx);
sipx->sipx_family = AF_IPX;
sipx->sipx_addr = ipxp->ipxp_laddr;
+ *nam = dup_sockaddr((struct sockaddr *)sipx, 0);
}
void
ipx_setpeeraddr(ipxp, nam)
register struct ipxpcb *ipxp;
- struct mbuf *nam;
+ struct sockaddr **nam;
{
- register struct sockaddr_ipx *sipx = mtod(nam, struct sockaddr_ipx *);
+ struct sockaddr_ipx *sipx, ssipx;
- nam->m_len = sizeof(*sipx);
- sipx = mtod(nam, struct sockaddr_ipx *);
+ sipx = &ssipx;
bzero((caddr_t)sipx, sizeof(*sipx));
sipx->sipx_len = sizeof(*sipx);
sipx->sipx_family = AF_IPX;
sipx->sipx_addr = ipxp->ipxp_faddr;
+ *nam = dup_sockaddr((struct sockaddr *)sipx, 0);
}
/*
diff --git a/sys/netipx/ipx_pcb.h b/sys/netipx/ipx_pcb.h
index be13c1a..3f03602 100644
--- a/sys/netipx/ipx_pcb.h
+++ b/sys/netipx/ipx_pcb.h
@@ -33,7 +33,7 @@
*
* @(#)ipx_pcb.h
*
- * $Id: ipx_pcb.h,v 1.10 1997/05/10 09:58:54 jhay Exp $
+ * $Id: ipx_pcb.h,v 1.11 1997/06/26 19:35:54 jhay Exp $
*/
#ifndef _NETIPX_IPX_PCB_H_
@@ -83,9 +83,9 @@ extern struct ipxpcb ipxpcb; /* head of list */
int ipx_pcballoc __P((struct socket *so, struct ipxpcb *head,
struct proc *p));
-int ipx_pcbbind __P((struct ipxpcb *ipxp, struct mbuf *nam,
+int ipx_pcbbind __P((struct ipxpcb *ipxp, struct sockaddr *nam,
struct proc *p));
-int ipx_pcbconnect __P((struct ipxpcb *ipxp, struct mbuf *nam,
+int ipx_pcbconnect __P((struct ipxpcb *ipxp, struct sockaddr *nam,
struct proc *p));
void ipx_pcbdetach __P((struct ipxpcb *ipxp));
void ipx_pcbdisconnect __P((struct ipxpcb *ipxp));
@@ -93,8 +93,8 @@ struct ipxpcb *
ipx_pcblookup __P((struct ipx_addr *faddr, int lport, int wildp));
void ipx_pcbnotify __P((struct ipx_addr *dst, int errno,
void (*notify)(struct ipxpcb *), long param));
-void ipx_setpeeraddr __P((struct ipxpcb *ipxp, struct mbuf *nam));
-void ipx_setsockaddr __P((struct ipxpcb *ipxp, struct mbuf *nam));
+void ipx_setpeeraddr __P((struct ipxpcb *ipxp, struct sockaddr **nam));
+void ipx_setsockaddr __P((struct ipxpcb *ipxp, struct sockaddr **nam));
#endif /* KERNEL */
#endif /* !_NETIPX_IPX_PCB_H_ */
diff --git a/sys/netipx/ipx_usrreq.c b/sys/netipx/ipx_usrreq.c
index d266310..afc4210 100644
--- a/sys/netipx/ipx_usrreq.c
+++ b/sys/netipx/ipx_usrreq.c
@@ -33,7 +33,7 @@
*
* @(#)ipx_usrreq.c
*
- * $Id: ipx_usrreq.c,v 1.14 1997/05/10 09:58:55 jhay Exp $
+ * $Id: ipx_usrreq.c,v 1.15 1997/06/26 19:35:58 jhay Exp $
*/
#include <sys/param.h>
@@ -70,12 +70,14 @@ SYSCTL_INT(_net_ipx_ipx, OID_AUTO, ipxrecvspace, CTLFLAG_RW,
static int ipx_usr_abort(struct socket *so);
static int ipx_attach(struct socket *so, int proto, struct proc *p);
-static int ipx_bind(struct socket *so, struct mbuf *nam, struct proc *p);
-static int ipx_connect(struct socket *so, struct mbuf *nam, struct proc *p);
+static int ipx_bind(struct socket *so, struct sockaddr *nam, struct proc *p);
+static int ipx_connect(struct socket *so, struct sockaddr *nam,
+ struct proc *p);
static int ipx_detach(struct socket *so);
static int ipx_disconnect(struct socket *so);
static int ipx_send(struct socket *so, int flags, struct mbuf *m,
- struct mbuf *addr, struct mbuf *control, struct proc *p);
+ struct sockaddr *addr, struct mbuf *control,
+ struct proc *p);
static int ipx_shutdown(struct socket *so);
static int ripx_attach(struct socket *so, int proto, struct proc *p);
static int ipx_output(struct ipxpcb *ipxp, struct mbuf *m0);
@@ -458,7 +460,7 @@ ipx_attach(so, proto, p)
static int
ipx_bind(so, nam, p)
struct socket *so;
- struct mbuf *nam;
+ struct sockaddr *nam;
struct proc *p;
{
struct ipxpcb *ipxp = sotoipxpcb(so);
@@ -469,7 +471,7 @@ ipx_bind(so, nam, p)
static int
ipx_connect(so, nam, p)
struct socket *so;
- struct mbuf *nam;
+ struct sockaddr *nam;
struct proc *p;
{
int error;
@@ -520,11 +522,11 @@ ipx_disconnect(so)
int
ipx_peeraddr(so, nam)
struct socket *so;
- struct mbuf *nam;
+ struct sockaddr **nam;
{
struct ipxpcb *ipxp = sotoipxpcb(so);
- ipx_setpeeraddr(ipxp, nam);
+ ipx_setpeeraddr(ipxp, nam); /* XXX what if alloc fails? */
return (0);
}
@@ -533,7 +535,7 @@ ipx_send(so, flags, m, nam, control, p)
struct socket *so;
int flags;
struct mbuf *m;
- struct mbuf *nam;
+ struct sockaddr *nam;
struct mbuf *control;
struct proc *p;
{
@@ -589,11 +591,11 @@ ipx_shutdown(so)
int
ipx_sockaddr(so, nam)
struct socket *so;
- struct mbuf *nam;
+ struct sockaddr **nam;
{
struct ipxpcb *ipxp = sotoipxpcb(so);
- ipx_setsockaddr(ipxp, nam);
+ ipx_setsockaddr(ipxp, nam); /* XXX what if alloc fails? */
return (0);
}
diff --git a/sys/netipx/ipx_var.h b/sys/netipx/ipx_var.h
index 6ee1579..7e6731f 100644
--- a/sys/netipx/ipx_var.h
+++ b/sys/netipx/ipx_var.h
@@ -33,7 +33,7 @@
*
* @(#)ipx_var.h
*
- * $Id: ipx_var.h,v 1.6 1997/05/10 09:58:55 jhay Exp $
+ * $Id: ipx_var.h,v 1.7 1997/06/26 19:35:59 jhay Exp $
*/
#ifndef _NETIPX_IPX_VAR_H_
@@ -92,9 +92,9 @@ void ipx_input __P((struct mbuf *m, struct ipxpcb *ipxp));
void ipxintr __P((void));
int ipx_outputfl __P((struct mbuf *m0, struct route *ro, int flags));
int ipx_output_type20 __P((struct mbuf *));
-int ipx_peeraddr __P((struct socket *so, struct mbuf *nam));
+int ipx_peeraddr __P((struct socket *so, struct sockaddr **nam));
void ipx_printhost __P((struct ipx_addr *addr));
-int ipx_sockaddr __P((struct socket *so, struct mbuf *nam));
+int ipx_sockaddr __P((struct socket *so, struct sockaddr **nam));
void ipx_watch_output __P((struct mbuf *m, struct ifnet *ifp));
#endif /* KERNEL */
diff --git a/sys/netipx/spx_usrreq.c b/sys/netipx/spx_usrreq.c
index 9c3cfc4..216cfd4 100644
--- a/sys/netipx/spx_usrreq.c
+++ b/sys/netipx/spx_usrreq.c
@@ -33,7 +33,7 @@
*
* @(#)spx_usrreq.h
*
- * $Id: spx_usrreq.c,v 1.13 1997/05/10 09:58:58 jhay Exp $
+ * $Id: spx_usrreq.c,v 1.14 1997/06/26 19:36:02 jhay Exp $
*/
#include <sys/param.h>
@@ -87,17 +87,19 @@ static struct spxpcb *spx_timers(struct spxpcb *cb, int timer);
static struct spxpcb *spx_usrclosed(struct spxpcb *cb);
static int spx_usr_abort(struct socket *so);
-static int spx_accept(struct socket *so, struct mbuf *nam);
+static int spx_accept(struct socket *so, struct sockaddr **nam);
static int spx_attach(struct socket *so, int proto, struct proc *p);
-static int spx_bind(struct socket *so, struct mbuf *nam, struct proc *p);
-static int spx_connect(struct socket *so, struct mbuf *nam, struct proc *p);
+static int spx_bind(struct socket *so, struct sockaddr *nam, struct proc *p);
+static int spx_connect(struct socket *so, struct sockaddr *nam,
+ struct proc *p);
static int spx_detach(struct socket *so);
static int spx_usr_disconnect(struct socket *so);
static int spx_listen(struct socket *so, struct proc *p);
static int spx_rcvd(struct socket *so, int flags);
static int spx_rcvoob(struct socket *so, struct mbuf *m, int flags);
static int spx_send(struct socket *so, int flags, struct mbuf *m,
- struct mbuf *addr, struct mbuf *control, struct proc *p);
+ struct sockaddr *addr, struct mbuf *control,
+ struct proc *p);
static int spx_shutdown(struct socket *so);
static int spx_sp_attach(struct socket *so, int proto, struct proc *p);
@@ -200,8 +202,7 @@ spx_input(m, ipxp)
switch (cb->s_state) {
case TCPS_LISTEN:{
- struct mbuf *am;
- register struct sockaddr_ipx *sipx;
+ struct sockaddr_ipx *sipx, ssipx;
struct ipx_addr laddr;
/*
@@ -213,24 +214,19 @@ spx_input(m, ipxp)
spx_istat.gonawy++;
goto dropwithreset;
}
- am = m_get(M_DONTWAIT, MT_SONAME);
- if (am == NULL)
- goto drop;
- am->m_len = sizeof(struct sockaddr_ipx);
- sipx = mtod(am, struct sockaddr_ipx *);
+ sipx = &ssipx;
+ bzero(sipx, sizeof *sipx);
sipx->sipx_len = sizeof(*sipx);
sipx->sipx_family = AF_IPX;
sipx->sipx_addr = si->si_sna;
laddr = ipxp->ipxp_laddr;
if (ipx_nullhost(laddr))
ipxp->ipxp_laddr = si->si_dna;
- if (ipx_pcbconnect(ipxp, am, &proc0)) {
+ if (ipx_pcbconnect(ipxp, (struct sockaddr *)sipx, &proc0)) {
ipxp->ipxp_laddr = laddr;
- m_free(am);
spx_istat.noconn++;
goto drop;
}
- m_free(am);
spx_template(cb);
dropsocket = 0; /* committed to socket */
cb->s_did = si->si_sid;
@@ -1307,17 +1303,18 @@ spx_usr_abort(so)
static int
spx_accept(so, nam)
struct socket *so;
- struct mbuf *nam;
+ struct sockaddr **nam;
{
struct ipxpcb *ipxp;
- struct sockaddr_ipx *sipx;
+ struct sockaddr_ipx *sipx, ssipx;
ipxp = sotoipxpcb(so);
- sipx = mtod(nam, struct sockaddr_ipx *);
-
- nam->m_len = sizeof(struct sockaddr_ipx);
+ sipx = &ssipx;
+ bzero(sipx, sizeof *sipx);
+ sipx->sipx_len = sizeof *sipx;
sipx->sipx_family = AF_IPX;
sipx->sipx_addr = ipxp->ipxp_faddr;
+ *nam = dup_sockaddr((struct sockaddr *)sipx, 0);
return (0);
}
@@ -1350,17 +1347,18 @@ spx_attach(so, proto, p)
}
ipxp = sotoipxpcb(so);
- mm = m_getclr(M_DONTWAIT, MT_PCB);
+ MALLOC(cb, struct spxpcb *, sizeof *cb, M_PCB, M_NOWAIT);
+ bzero(cb, sizeof *cb);
sb = &so->so_snd;
- if (mm == NULL) {
+ if (cb == NULL) {
error = ENOBUFS;
goto spx_attach_end;
}
- cb = mtod(mm, struct spxpcb *);
+
mm = m_getclr(M_DONTWAIT, MT_HEADER);
if (mm == NULL) {
- m_freem(dtom(cb));
+ FREE(cb, M_PCB);
error = ENOBUFS;
goto spx_attach_end;
}
@@ -1390,7 +1388,7 @@ spx_attach_end:
static int
spx_bind(so, nam, p)
struct socket *so;
- struct mbuf *nam;
+ struct sockaddr *nam;
struct proc *p;
{
struct ipxpcb *ipxp;
@@ -1409,7 +1407,7 @@ spx_bind(so, nam, p)
static int
spx_connect(so, nam, p)
struct socket *so;
- struct mbuf *nam;
+ struct sockaddr *nam;
struct proc *p;
{
int error;
@@ -1422,7 +1420,7 @@ spx_connect(so, nam, p)
s = splnet();
if (ipxp->ipxp_lport == 0) {
- error = ipx_pcbbind(ipxp, (struct mbuf *)NULL, p);
+ error = ipx_pcbbind(ipxp, (struct sockaddr *)NULL, p);
if (error)
goto spx_connect_end;
}
@@ -1509,7 +1507,7 @@ spx_listen(so, p)
cb = ipxtospxpcb(ipxp);
if (ipxp->ipxp_lport == 0)
- error = ipx_pcbbind(ipxp, (struct mbuf *)NULL, p);
+ error = ipx_pcbbind(ipxp, (struct sockaddr *)NULL, p);
if (error == 0)
cb->s_state = TCPS_LISTEN;
return (error);
@@ -1565,7 +1563,7 @@ spx_send(so, flags, m, addr, controlp, p)
struct socket *so;
int flags;
struct mbuf *m;
- struct mbuf *addr;
+ struct sockaddr *addr;
struct mbuf *controlp;
struct proc *p;
{
@@ -1698,7 +1696,7 @@ spx_close(cb)
m_freem(m);
}
m_free(dtom(cb->s_ipx));
- m_free(dtom(cb));
+ FREE(cb, M_PCB);
ipxp->ipxp_pcb = 0;
soisdisconnected(so);
ipx_pcbdetach(ipxp);
OpenPOWER on IntegriCloud