Module Name: src Committed By: rtr Date: Fri Apr 24 23:36:49 UTC 2015
Modified Files: src/sys/netatalk: ddp_usrreq.c Log Message: make at_pcbconnect() take sockaddr_at * instead of mbuf *. move m_len check into callers which results in small duplication of code that will go away when the callers are converted to receive sockaddr * instead of mbuf *. To generate a diff of this commit: cvs rdiff -u -r1.65 -r1.66 src/sys/netatalk/ddp_usrreq.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/netatalk/ddp_usrreq.c diff -u src/sys/netatalk/ddp_usrreq.c:1.65 src/sys/netatalk/ddp_usrreq.c:1.66 --- src/sys/netatalk/ddp_usrreq.c:1.65 Fri Apr 24 22:32:37 2015 +++ src/sys/netatalk/ddp_usrreq.c Fri Apr 24 23:36:48 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: ddp_usrreq.c,v 1.65 2015/04/24 22:32:37 rtr Exp $ */ +/* $NetBSD: ddp_usrreq.c,v 1.66 2015/04/24 23:36:48 rtr Exp $ */ /* * Copyright (c) 1990,1991 Regents of The University of Michigan. @@ -27,7 +27,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ddp_usrreq.c,v 1.65 2015/04/24 22:32:37 rtr Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ddp_usrreq.c,v 1.66 2015/04/24 23:36:48 rtr Exp $"); #include "opt_mbuftrace.h" @@ -59,7 +59,7 @@ __KERNEL_RCSID(0, "$NetBSD: ddp_usrreq.c static void at_pcbdisconnect(struct ddpcb *); static void at_sockaddr(struct ddpcb *, struct sockaddr_at *); static int at_pcbsetaddr(struct ddpcb *, struct sockaddr_at *); -static int at_pcbconnect(struct ddpcb *, struct mbuf *); +static int at_pcbconnect(struct ddpcb *, struct sockaddr_at *); static void ddp_detach(struct socket *); struct ifqueue atintrq1, atintrq2; @@ -231,18 +231,15 @@ at_pcbsetaddr(struct ddpcb *ddp, struct } static int -at_pcbconnect(struct ddpcb *ddp, struct mbuf *addr) +at_pcbconnect(struct ddpcb *ddp, struct sockaddr_at *sat) { struct rtentry *rt; const struct sockaddr_at *cdst; - struct sockaddr_at *sat = mtod(addr, struct sockaddr_at *); struct route *ro; struct at_ifaddr *aa; struct ifnet *ifp; u_short hintnet = 0, net; - if (addr->m_len != sizeof(*sat)) - return EINVAL; if (sat->sat_family != AF_APPLETALK) { return EAFNOSUPPORT; } @@ -435,7 +432,9 @@ ddp_connect(struct socket *so, struct mb if (ddp->ddp_fsat.sat_port != ATADDR_ANYPORT) return EISCONN; - error = at_pcbconnect(ddp, nam); + if (nam->m_len != sizeof(struct sockaddr_at)) + return EINVAL; + error = at_pcbconnect(ddp, mtod(nam, struct sockaddr_at *)); if (error == 0) soisconnected(so); @@ -550,7 +549,9 @@ ddp_send(struct socket *so, struct mbuf if (ddp->ddp_fsat.sat_port != ATADDR_ANYPORT) return EISCONN; s = splnet(); - error = at_pcbconnect(ddp, nam); + if (nam->m_len != sizeof(struct sockaddr_at)) + return EINVAL; + error = at_pcbconnect(ddp, mtod(nam, struct sockaddr_at *)); if (error) { splx(s); return error;