From owner-freebsd-net Tue Mar 4 17:10:51 2003 Delivered-To: freebsd-net@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 3DAC137B401; Tue, 4 Mar 2003 17:10:07 -0800 (PST) Received: from heron.mail.pas.earthlink.net (heron.mail.pas.earthlink.net [207.217.120.189]) by mx1.FreeBSD.org (Postfix) with ESMTP id 3AAC143FBD; Tue, 4 Mar 2003 17:10:05 -0800 (PST) (envelope-from tlambert2@mindspring.com) Received: from pool0118.cvx21-bradley.dialup.earthlink.net ([209.179.192.118] helo=mindspring.com) by heron.mail.pas.earthlink.net with asmtp (SSLv3:RC4-MD5:128) (Exim 3.33 #1) id 18qNPl-0005K9-00; Tue, 04 Mar 2003 17:09:46 -0800 Message-ID: <3E654D75.E37B5861@mindspring.com> Date: Tue, 04 Mar 2003 17:05:57 -0800 From: Terry Lambert X-Mailer: Mozilla 4.79 [en] (Win98; U) X-Accept-Language: en MIME-Version: 1.0 To: Peter Wemm , Mike Barcroft , Tim Robbins , freebsd-net@freebsd.org, freebsd-current@freebsd.org Subject: [PATCH] make netns compile cleanly (was Re: Removal of netns - politically correct version References: <20030304194017.022FD2A8BB@canning.wemm.org> <3E6539B5.2F5D31B@mindspring.com> Content-Type: multipart/mixed; boundary="------------81B31A38BCFEF66ED364CE7A" X-ELNK-Trace: b1a02af9316fbb217a47c185c03b154d40683398e744b8a47a597f4a0f4a1bd46bb4710ccc6b8b30667c3043c0873f7e350badd9bab72f9c350badd9bab72f9c Sender: owner-freebsd-net@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org This is a multi-part message in MIME format. --------------81B31A38BCFEF66ED364CE7A Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Terry Lambert wrote: > Peter Wemm wrote: > > Terry: will you please check your facts? It takes around 30 seconds > > to find out that it doesn't even compile. > > [ ... lots of trivial to fix warnings and errors ... ] > > Tell you what, I'll fix these and post a patch. Will that make you > guys happy? > > This crap is *soooooooo* trivial to fix, it's easier to fix than > to watch you guys bitch about it not being fixable. Here are two patches. The first fixes missing pieces in /sys/conf/files and /sys/conf/options, the second fixes all the files that need it in /sys/netns/. It's now possible to add: options NS to a kernel config, and still get a kernel that does it's thing. Note that I did not go through and made the protosw[] changes, so there's some initialization warnings there, but by my clock, I only spent an hour on the thing, and what you guys were bitching about was "it doesn't even compile". If you want that fixed too, then it's an easy fix, using the IPX sources as a guide, since IPX is derives from XNS. -- Terry --------------81B31A38BCFEF66ED364CE7A Content-Type: text/plain; charset=us-ascii; name="netnsconf.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="netnsconf.diff" Index: files =================================================================== RCS file: /usr/cvs/src/sys/conf/files,v retrieving revision 1.340.2.87 diff -c -r1.340.2.87 files *** files 19 Dec 2001 20:59:27 -0000 1.340.2.87 --- files 5 Mar 2003 00:49:18 -0000 *************** *** 923,928 **** --- 923,929 ---- netns/ns_output.c optional ns netns/ns_pcb.c optional ns netns/ns_proto.c optional ns + netns/ns_cksum.c optional ns netns/spp_debug.c optional ns netns/spp_usrreq.c optional ns nfs/nfs_bio.c optional nfs Index: options =================================================================== RCS file: /usr/cvs/src/sys/conf/options,v retrieving revision 1.191.2.37 diff -c -r1.191.2.37 options *** options 3 Nov 2001 01:41:07 -0000 1.191.2.37 --- options 4 Mar 2003 22:10:11 -0000 *************** *** 272,277 **** --- 272,278 ---- TCPDEBUG TCP_DROP_SYNFIN opt_tcp_input.h XBONEHACK + NS opt_ns.h # Netgraph(4). Use option NETGRAPH to enable the base netgraph code. # Each netgraph node type can be either be compiled into the kernel --------------81B31A38BCFEF66ED364CE7A Content-Type: text/plain; charset=us-ascii; name="netns.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="netns.diff" Index: idp_usrreq.c =================================================================== RCS file: /usr/cvs/src/sys/netns/idp_usrreq.c,v retrieving revision 1.9 diff -c -r1.9 idp_usrreq.c *** idp_usrreq.c 28 Aug 1999 00:49:47 -0000 1.9 --- idp_usrreq.c 5 Mar 2003 01:15:42 -0000 *************** *** 54,59 **** --- 54,63 ---- #include #include + extern int idpcksum; /* from ns_input.c */ + extern long ns_pexseq; /* from ns_input.c */ + extern struct nspcb nsrawpcb; /* from ns_input.c */ + /* * IDP protocol implementation. */ *************** *** 63,68 **** --- 67,73 ---- /* * This may also be called for raw listeners. */ + void idp_input(m, nsp) struct mbuf *m; register struct nspcb *nsp; *************** *** 79,92 **** idp_ns.sns_addr = idp->idp_sna; if (ns_neteqnn(idp->idp_sna.x_net, ns_zeronet) && ifp) { register struct ifaddr *ifa; ! for (ifa = ifp->if_addrlist; ifa; ifa = ifa->ifa_next) { if (ifa->ifa_addr->sa_family == AF_NS) { idp_ns.sns_addr.x_net = IA_SNS(ifa)->sns_addr.x_net; break; } ! } } nsp->nsp_rpt = idp->idp_pt; if ( ! (nsp->nsp_flags & NSP_RAWIN) ) { --- 84,99 ---- idp_ns.sns_addr = idp->idp_sna; if (ns_neteqnn(idp->idp_sna.x_net, ns_zeronet) && ifp) { register struct ifaddr *ifa; + int s; ! s = splimp(); ! TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) if (ifa->ifa_addr->sa_family == AF_NS) { idp_ns.sns_addr.x_net = IA_SNS(ifa)->sns_addr.x_net; break; } ! splx(s); } nsp->nsp_rpt = idp->idp_pt; if ( ! (nsp->nsp_flags & NSP_RAWIN) ) { *************** *** 103,108 **** --- 110,116 ---- m_freem(m); } + void idp_abort(nsp) struct nspcb *nsp; { *************** *** 134,153 **** so->so_error = errno; ns_pcbdisconnect(nsp); soisdisconnected(so); } int noIdpRoute; idp_output(nsp, m0) struct nspcb *nsp; struct mbuf *m0; { ! register struct mbuf *m; register struct idp *idp; register struct socket *so; register int len = 0; register struct route *ro; ! struct mbuf *mprev; ! extern int idpcksum; /* * Calculate data length. --- 142,163 ---- so->so_error = errno; ns_pcbdisconnect(nsp); soisdisconnected(so); + return(NULL); /* XXX */ } int noIdpRoute; + + int idp_output(nsp, m0) struct nspcb *nsp; struct mbuf *m0; { ! struct mbuf *m; register struct idp *idp; register struct socket *so; register int len = 0; register struct route *ro; ! struct mbuf *mprev = NULL; /* * Calculate data length. *************** *** 259,265 **** --- 269,277 ---- if (noIdpRoute) ro = 0; return (ns_output(m, ro, so->so_options & SO_BROADCAST)); } + /* ARGSUSED */ + int idp_ctloutput(req, so, level, name, value) int req, level; struct socket *so; *************** *** 269,275 **** register struct mbuf *m; struct nspcb *nsp = sotonspcb(so); int mask, error = 0; - extern long ns_pexseq; if (nsp == NULL) return (EINVAL); --- 281,286 ---- *************** *** 371,376 **** --- 382,388 ---- } /*ARGSUSED*/ + int idp_usrreq(so, req, m, nam, control) struct socket *so; int req; *************** *** 455,461 **** case PRU_SEND: { struct ns_addr laddr; ! int s; if (nam) { laddr = nsp->nsp_laddr; --- 467,473 ---- case PRU_SEND: { struct ns_addr laddr; ! int s = -1; /* XXX compiler warns improperly */ if (nam) { laddr = nsp->nsp_laddr; *************** *** 532,538 **** --- 544,552 ---- m_freem(m); return (error); } + /*ARGSUSED*/ + int idp_raw_usrreq(so, req, m, nam, control) struct socket *so; int req; *************** *** 540,555 **** { int error = 0; struct nspcb *nsp = sotonspcb(so); - extern struct nspcb nsrawpcb; switch (req) { case PRU_ATTACH: if (!(so->so_state & SS_PRIV) || (nsp != NULL)) { error = EINVAL; break; } error = ns_pcballoc(so, &nsrawpcb); if (error) break; --- 554,571 ---- { int error = 0; struct nspcb *nsp = sotonspcb(so); switch (req) { case PRU_ATTACH: + #ifdef NS_PRIV_SOCKETS if (!(so->so_state & SS_PRIV) || (nsp != NULL)) { error = EINVAL; break; } + #endif /* NS_PRIV_SOCKETS */ + error = ns_pcballoc(so, &nsrawpcb); if (error) break; Index: idp_var.h =================================================================== RCS file: /usr/cvs/src/sys/netns/idp_var.h,v retrieving revision 1.10 diff -c -r1.10 idp_var.h *** idp_var.h 29 Dec 1999 04:46:18 -0000 1.10 --- idp_var.h 5 Mar 2003 01:15:42 -0000 *************** *** 50,55 **** --- 50,66 ---- #ifdef _KERNEL struct idpstat idpstat; + struct nspcb; /* declare in scope for ptr parameter */ + + void idp_abort __P((struct nspcb *)); + void idp_input __P((struct mbuf *, struct nspcb *)); + struct nspcb *idp_drop __P((struct nspcb *, int)); + int idp_output __P(( struct nspcb *, struct mbuf *)); + int idp_ctloutput __P((int, struct socket *, int, int, struct mbuf **)); + int idp_usrreq __P(( struct socket *, int, struct mbuf *, struct mbuf *, + struct mbuf *)); + int idp_raw_usrreq __P(( struct socket *, int, struct mbuf *, struct mbuf *, + struct mbuf *)); #endif #endif Index: ns.c =================================================================== RCS file: /usr/cvs/src/sys/netns/ns.c,v retrieving revision 1.9 diff -c -r1.9 ns.c *** ns.c 28 Aug 1999 00:49:47 -0000 1.9 --- ns.c 5 Mar 2003 01:15:42 -0000 *************** *** 36,41 **** --- 36,42 ---- #include #include + #include #include #include #include *************** *** 49,54 **** --- 50,57 ---- #include #include + #include "opt_ns.h" + #ifdef NS struct ns_ifaddr *ns_ifaddr; *************** *** 59,64 **** --- 62,68 ---- * Generic internet control operations (ioctl's). */ /* ARGSUSED */ + int ns_control(so, cmd, data, ifp) struct socket *so; int cmd; *************** *** 68,76 **** register struct ifreq *ifr = (struct ifreq *)data; register struct ns_aliasreq *ifra = (struct ns_aliasreq *)data; register struct ns_ifaddr *ia; ! struct ifaddr *ifa; struct ns_ifaddr *oia; ! int error, dstIsNew, hostIsNew; /* * Find address for this interface, if it exists. --- 72,81 ---- register struct ifreq *ifr = (struct ifreq *)data; register struct ns_aliasreq *ifra = (struct ns_aliasreq *)data; register struct ns_ifaddr *ia; ! struct ifaddr *ifa = NULL; /* XXX used uninitialized ?*/ struct ns_ifaddr *oia; ! int dstIsNew, hostIsNew; ! int error = 0; /* initialize because of scoping */ /* * Find address for this interface, if it exists. *************** *** 107,114 **** --- 112,121 ---- return (0); } + #ifdef NS_PRIV_SOCKETS if ((so->so_state & SS_PRIV) == 0) return (EPERM); + #endif /* NS_PRIV_SOCKETS */ switch (cmd) { case SIOCAIFADDR: *************** *** 132,150 **** if (oia == (struct ns_ifaddr *)NULL) return (ENOBUFS); bzero((caddr_t)oia, sizeof(*oia)); ! if (ia = ns_ifaddr) { for ( ; ia->ia_next; ia = ia->ia_next) ; ia->ia_next = oia; } else ns_ifaddr = oia; ia = oia; ! if (ifa = ifp->if_addrlist) { ! for ( ; ifa->ifa_next; ifa = ifa->ifa_next) ! ; ! ifa->ifa_next = (struct ifaddr *) ia; ! } else ! ifp->if_addrlist = (struct ifaddr *) ia; ia->ia_ifp = ifp; ia->ia_ifa.ifa_addr = (struct sockaddr *)&ia->ia_addr; --- 139,153 ---- if (oia == (struct ns_ifaddr *)NULL) return (ENOBUFS); bzero((caddr_t)oia, sizeof(*oia)); ! if ((ia = ns_ifaddr) != NULL) { for ( ; ia->ia_next; ia = ia->ia_next) ; ia->ia_next = oia; } else ns_ifaddr = oia; ia = oia; ! ! TAILQ_INSERT_TAIL(&ifp->if_addrhead, ifa, ifa_link); ia->ia_ifp = ifp; ia->ia_ifa.ifa_addr = (struct sockaddr *)&ia->ia_addr; *************** *** 163,170 **** } switch (cmd) { - int error; - case SIOCSIFDSTADDR: if ((ifp->if_flags & IFF_POINTOPOINT) == 0) return (EINVAL); --- 166,171 ---- *************** *** 173,179 **** ia->ia_flags &= ~IFA_ROUTE; } if (ifp->if_ioctl) { ! error = (*ifp->if_ioctl)(ifp, SIOCSIFDSTADDR, ia); if (error) return (error); } --- 174,181 ---- ia->ia_flags &= ~IFA_ROUTE; } if (ifp->if_ioctl) { ! error = (*ifp->if_ioctl)(ifp, SIOCSIFDSTADDR, ! (caddr_t)ia); if (error) return (error); } *************** *** 181,203 **** return (0); case SIOCSIFADDR: ! return (ns_ifinit(ifp, ia, (struct sockaddr_ns *)&ifr->ifr_addr, 1)); case SIOCDIFADDR: ! ns_ifscrub(ifp, ia); ! if ((ifa = ifp->if_addrlist) == (struct ifaddr *)ia) ! ifp->if_addrlist = ifa->ifa_next; ! else { ! while (ifa->ifa_next && ! (ifa->ifa_next != (struct ifaddr *)ia)) ! ifa = ifa->ifa_next; ! if (ifa->ifa_next) ! ifa->ifa_next = ((struct ifaddr *)ia)->ifa_next; ! else ! printf("Couldn't unlink nsifaddr from ifp\n"); ! } oia = ia; if (oia == (ia = ns_ifaddr)) { ns_ifaddr = ia->ia_next; } else { --- 183,196 ---- return (0); case SIOCSIFADDR: ! return (ns_ifinit(ifp, (struct ns_ifaddr *)ia, (struct sockaddr_ns *)&ifr->ifr_addr, 1)); case SIOCDIFADDR: ! ns_ifscrub(ifp, (struct ns_ifaddr *)ia); ! /* XXX not on list? */ oia = ia; + TAILQ_REMOVE(&ifp->if_addrhead, (struct ifaddr *)ia, ifa_link); if (oia == (ia = ns_ifaddr)) { ns_ifaddr = ia->ia_next; } else { *************** *** 231,243 **** if ((ifp->if_flags & IFF_POINTOPOINT) && (ifra->ifra_dstaddr.sns_family == AF_NS)) { if (hostIsNew == 0) ! ns_ifscrub(ifp, ia); ia->ia_dstaddr = ifra->ifra_dstaddr; dstIsNew = 1; } if (ifra->ifra_addr.sns_family == AF_NS && (hostIsNew || dstIsNew)) ! error = ns_ifinit(ifp, ia, &ifra->ifra_addr, 0); return (error); default: --- 224,237 ---- if ((ifp->if_flags & IFF_POINTOPOINT) && (ifra->ifra_dstaddr.sns_family == AF_NS)) { if (hostIsNew == 0) ! ns_ifscrub(ifp, (struct ns_ifaddr *)ia); ia->ia_dstaddr = ifra->ifra_dstaddr; dstIsNew = 1; } if (ifra->ifra_addr.sns_family == AF_NS && (hostIsNew || dstIsNew)) ! error = ns_ifinit(ifp, (struct ns_ifaddr *)ia, ! &ifra->ifra_addr, 0); return (error); default: *************** *** 250,255 **** --- 244,250 ---- /* * Delete any previous route for an old address. */ + void ns_ifscrub(ifp, ia) register struct ifnet *ifp; register struct ns_ifaddr *ia; *************** *** 266,275 **** --- 261,272 ---- * Initialize an interface's internet address * and routing table entry. */ + int ns_ifinit(ifp, ia, sns, scrub) register struct ifnet *ifp; register struct ns_ifaddr *ia; register struct sockaddr_ns *sns; + int scrub; { struct sockaddr_ns oldaddr; register union ns_host *h = &ia->ia_addr.sns_addr.x_host; *************** *** 294,300 **** */ if (ns_hosteqnh(ns_thishost, ns_zerohost)) { if (ifp->if_ioctl && ! (error = (*ifp->if_ioctl)(ifp, SIOCSIFADDR, ia))) { ia->ia_addr = oldaddr; splx(s); return (error); --- 291,298 ---- */ if (ns_hosteqnh(ns_thishost, ns_zerohost)) { if (ifp->if_ioctl && ! (error = (*ifp->if_ioctl)(ifp, SIOCSIFADDR, ! (caddr_t)ia))) { ia->ia_addr = oldaddr; splx(s); return (error); *************** *** 304,310 **** || ns_hosteqnh(sns->sns_addr.x_host, ns_thishost)) { *h = ns_thishost; if (ifp->if_ioctl && ! (error = (*ifp->if_ioctl)(ifp, SIOCSIFADDR, ia))) { ia->ia_addr = oldaddr; splx(s); return (error); --- 302,309 ---- || ns_hosteqnh(sns->sns_addr.x_host, ns_thishost)) { *h = ns_thishost; if (ifp->if_ioctl && ! (error = (*ifp->if_ioctl)(ifp, SIOCSIFADDR, ! (caddr_t)ia))) { ia->ia_addr = oldaddr; splx(s); return (error); *************** *** 352,358 **** union ns_net net = dst->x_net; for (ia = ns_ifaddr; ia; ia = ia->ia_next) { ! if (ifp = ia->ia_ifp) { if (ifp->if_flags & IFF_POINTOPOINT) { compare = &satons_addr(ia->ia_dstaddr); if (ns_hosteq(*dst, *compare)) --- 351,357 ---- union ns_net net = dst->x_net; for (ia = ns_ifaddr; ia; ia = ia->ia_next) { ! if ((ifp = ia->ia_ifp) != NULL) { if (ifp->if_flags & IFF_POINTOPOINT) { compare = &satons_addr(ia->ia_dstaddr); if (ns_hosteq(*dst, *compare)) Index: ns.h =================================================================== RCS file: /usr/cvs/src/sys/netns/ns.h,v retrieving revision 1.13 diff -c -r1.13 ns.h *** ns.h 29 Dec 1999 04:46:19 -0000 1.13 --- ns.h 5 Mar 2003 01:15:42 -0000 *************** *** 142,148 **** union ns_host ns_broadhost; union ns_net ns_zeronet; union ns_net ns_broadnet; ! u_short ns_cksum(); #else #include --- 142,164 ---- union ns_host ns_broadhost; union ns_net ns_zeronet; union ns_net ns_broadnet; ! ! struct route; ! struct ns_ifaddr; ! ! u_short ns_cksum __P(( struct mbuf *, int)); ! int ns_output __P((struct mbuf *, struct route *, int)); ! int ns_control __P((struct socket *, int, caddr_t, struct ifnet *)); ! void ns_init __P((void)); ! void idp_forward __P((struct mbuf *)); ! void idp_ctlinput __P((int, caddr_t)); ! int idp_do_route __P((struct ns_addr *, struct route *)); ! void idp_undo_route __P((struct route *)); ! void ns_watch_output __P((struct mbuf *, struct ifnet *)); ! int ns_ifinit __P((struct ifnet *, struct ns_ifaddr *, struct sockaddr_ns *, ! int)); ! void ns_ifscrub __P((struct ifnet *, struct ns_ifaddr *)); ! #else #include Index: ns_error.c =================================================================== RCS file: /usr/cvs/src/sys/netns/ns_error.c,v retrieving revision 1.9 diff -c -r1.9 ns_error.c *** ns_error.c 28 Aug 1999 00:49:49 -0000 1.9 --- ns_error.c 5 Mar 2003 01:15:42 -0000 *************** *** 50,55 **** --- 50,59 ---- #include #include + extern int idpcksum; /* from ns_input.c */ + extern void spp_ctlinput( int, caddr_t); /* from spp_usrreq.c XXX */ + + #ifdef lint #define NS_ERRPRINTFS 1 #endif *************** *** 62,68 **** --- 66,74 ---- int ns_errprintfs = 0; #endif + int ns_err_x(c) + int c; { register u_short *w, *lim, *base = ns_errstat.ns_es_codes; u_short x = c; *************** *** 86,101 **** * Generate an error packet of type error * in response to bad packet. */ ! ns_error(om, type, param) struct mbuf *om; int type; { register struct ns_epidp *ep; struct mbuf *m; struct idp *nip; register struct idp *oip = mtod(om, struct idp *); - extern int idpcksum; /* * If this packet was sent to the echo port, --- 92,107 ---- * Generate an error packet of type error * in response to bad packet. */ ! void ns_error(om, type, param) struct mbuf *om; int type; + int param; { register struct ns_epidp *ep; struct mbuf *m; struct idp *nip; register struct idp *oip = mtod(om, struct idp *); /* * If this packet was sent to the echo port, *************** *** 165,170 **** --- 171,177 ---- m_freem(om); } + void ns_printhost(p) register struct ns_addr *p; { *************** *** 182,192 **** --- 189,202 ---- /* * Process a received NS_ERR message. */ + void ns_err_input(m) struct mbuf *m; { register struct ns_errp *ep; + #ifdef NS_ERRPRINTFS register struct ns_epidp *epidp = mtod(m, struct ns_epidp *); + #endif register int i; int type, code, param; *************** *** 295,300 **** --- 305,311 ---- } #endif + int ns_echo(m) struct mbuf *m; { Index: ns_error.h =================================================================== RCS file: /usr/cvs/src/sys/netns/ns_error.h,v retrieving revision 1.10 diff -c -r1.10 ns_error.h *** ns_error.h 29 Dec 1999 04:46:19 -0000 1.10 --- ns_error.h 5 Mar 2003 01:15:42 -0000 *************** *** 91,96 **** --- 91,102 ---- #ifdef _KERNEL struct ns_errstat ns_errstat; + + int ns_err_x __P((int)); + void ns_error __P((struct mbuf *, int, int)); + int ns_echo __P((struct mbuf *)); + void ns_printhost __P((struct ns_addr *)); + void ns_err_input __P((struct mbuf *)); #endif #endif Index: ns_if.h =================================================================== RCS file: /usr/cvs/src/sys/netns/ns_if.h,v retrieving revision 1.12 diff -c -r1.12 ns_if.h *** ns_if.h 29 Dec 1999 04:46:19 -0000 1.12 --- ns_if.h 5 Mar 2003 01:15:42 -0000 *************** *** 80,89 **** #endif #ifdef _KERNEL ! struct ns_ifaddr *ns_ifaddr; ! struct ns_ifaddr *ns_iaonnetof(); void nsintr __P((void)); ! struct ifqueue nsintrq; /* XNS input packet queue */ #endif #endif --- 80,91 ---- #endif #ifdef _KERNEL ! extern struct ns_ifaddr *ns_ifaddr; ! ! struct ns_ifaddr *ns_iaonnetof __P((struct ns_addr *)); void nsintr __P((void)); ! ! extern struct ifqueue nsintrq; /* XNS input packet queue */ #endif #endif Index: ns_input.c =================================================================== RCS file: /usr/cvs/src/sys/netns/ns_input.c,v retrieving revision 1.13 diff -c -r1.13 ns_input.c *** ns_input.c 13 Feb 2000 03:32:04 -0000 1.13 --- ns_input.c 5 Mar 2003 01:15:42 -0000 *************** *** 59,77 **** #include #include /* * NS initialization. */ - union ns_host ns_thishost; - union ns_host ns_zerohost; - union ns_host ns_broadhost; - union ns_net ns_zeronet; - union ns_net ns_broadnet; struct sockaddr_ns ns_netmask, ns_hostmask; static u_short allones[] = {-1, -1, -1}; - struct nspcb nspcb; struct nspcb nsrawpcb; int nsqmaxlen = IFQ_MAXLEN; --- 59,74 ---- #include #include + extern void spp_input(struct mbuf *, struct nspcb *); /* spp_usrreq.c XXX */ + + /* * NS initialization. */ struct sockaddr_ns ns_netmask, ns_hostmask; static u_short allones[] = {-1, -1, -1}; struct nspcb nsrawpcb; int nsqmaxlen = IFQ_MAXLEN; *************** *** 81,96 **** const int nsintrq_present = 1; ns_init() { - extern struct timeval time; - ns_broadhost = * (union ns_host *) allones; ns_broadnet = * (union ns_net *) allones; nspcb.nsp_next = nspcb.nsp_prev = &nspcb; nsrawpcb.nsp_next = nsrawpcb.nsp_prev = &nsrawpcb; nsintrq.ifq_maxlen = nsqmaxlen; ! ns_pexseq = time.tv_usec; ns_netmask.sns_len = 6; ns_netmask.sns_addr.x_net = ns_broadnet; ns_hostmask.sns_len = 12; --- 78,92 ---- const int nsintrq_present = 1; + void ns_init() { ns_broadhost = * (union ns_host *) allones; ns_broadnet = * (union ns_net *) allones; nspcb.nsp_next = nspcb.nsp_prev = &nspcb; nsrawpcb.nsp_next = nsrawpcb.nsp_prev = &nsrawpcb; nsintrq.ifq_maxlen = nsqmaxlen; ! ns_pexseq = tick; ns_netmask.sns_len = 6; ns_netmask.sns_addr.x_net = ns_broadnet; ns_hostmask.sns_len = 12; *************** *** 141,147 **** idp = mtod(m, struct idp *); len = ntohs(idp->idp_len); ! if (oddpacketp = len & 1) { len++; /* If this packet is of odd length, preserve garbage byte for checksum */ } --- 137,143 ---- idp = mtod(m, struct idp *); len = ntohs(idp->idp_len); ! if ((oddpacketp = (len & 1))) { len++; /* If this packet is of odd length, preserve garbage byte for checksum */ } *************** *** 250,264 **** int idp_donosocks = 1; idp_ctlinput(cmd, arg) int cmd; caddr_t arg; { struct ns_addr *ns; struct nspcb *nsp; ! struct ns_errp *errp; ! int idp_abort(); ! extern struct nspcb *idp_drop(); int type; if (cmd < 0 || cmd > PRC_NCMDS) --- 246,259 ---- int idp_donosocks = 1; + void idp_ctlinput(cmd, arg) int cmd; caddr_t arg; { struct ns_addr *ns; struct nspcb *nsp; ! struct ns_errp *errp = (struct ns_errp *)arg; /* XXX */ int type; if (cmd < 0 || cmd > PRC_NCMDS) *************** *** 309,314 **** --- 304,310 ---- struct route idp_droute; struct route idp_sroute; + void idp_forward(m) struct mbuf *m; { *************** *** 428,433 **** --- 424,430 ---- m_freem(mcopy); } + int idp_do_route(src, ro) struct ns_addr *src; struct route *ro; *************** *** 450,461 **** --- 447,460 ---- return (1); } + void idp_undo_route(ro) register struct route *ro; { if (ro->ro_rt) {RTFREE(ro->ro_rt);} } + void ns_watch_output(m, ifp) struct mbuf *m; struct ifnet *ifp; *************** *** 477,489 **** idp->idp_sna.x_net = ns_zeronet; idp->idp_sna.x_host = ns_thishost; if (ifp && (ifp->if_flags & IFF_POINTOPOINT)) ! for(ifa = ifp->if_addrlist; ifa; ! ifa = ifa->ifa_next) { if (ifa->ifa_addr->sa_family==AF_NS) { idp->idp_sna = IA_SNS(ifa)->sns_addr; break; } - } idp->idp_len = ntohl(m0->m_pkthdr.len); idp_input(m0, nsp); } --- 476,486 ---- idp->idp_sna.x_net = ns_zeronet; idp->idp_sna.x_host = ns_thishost; if (ifp && (ifp->if_flags & IFF_POINTOPOINT)) ! TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) if (ifa->ifa_addr->sa_family==AF_NS) { idp->idp_sna = IA_SNS(ifa)->sns_addr; break; } idp->idp_len = ntohl(m0->m_pkthdr.len); idp_input(m0, nsp); } Index: ns_output.c =================================================================== RCS file: /usr/cvs/src/sys/netns/ns_output.c,v retrieving revision 1.7 diff -c -r1.7 ns_output.c *** ns_output.c 28 Aug 1999 00:49:51 -0000 1.7 --- ns_output.c 5 Mar 2003 01:15:42 -0000 *************** *** 57,62 **** --- 57,63 ---- int ns_output_cnt = 0; struct mbuf *ns_lastout; + int ns_output(m0, ro, flags) struct mbuf *m0; struct route *ro; *************** *** 67,73 **** int error = 0; struct route idproute; struct sockaddr_ns *dst; - extern int idpcksum; if (ns_hold_output) { if (ns_lastout) { --- 68,73 ---- Index: ns_pcb.c =================================================================== RCS file: /usr/cvs/src/sys/netns/ns_pcb.c,v retrieving revision 1.9 diff -c -r1.9 ns_pcb.c *** ns_pcb.c 28 Aug 1999 00:49:51 -0000 1.9 --- ns_pcb.c 5 Mar 2003 01:15:42 -0000 *************** *** 51,56 **** --- 51,57 ---- struct ns_addr zerons_addr; + int ns_pcballoc(so, head) struct socket *so; struct nspcb *head; *************** *** 58,64 **** struct mbuf *m; register struct nspcb *nsp; ! m = m_getclr(M_DONTWAIT, MT_PCB); if (m == NULL) return (ENOBUFS); nsp = mtod(m, struct nspcb *); --- 59,65 ---- struct mbuf *m; register struct nspcb *nsp; ! m = m_getclr(M_DONTWAIT, MT_CONTROL); /* protocol private PCB */ if (m == NULL) return (ENOBUFS); nsp = mtod(m, struct nspcb *); *************** *** 68,73 **** --- 69,75 ---- return (0); } + int ns_pcbbind(nsp, nam) register struct nspcb *nsp; struct mbuf *nam; *************** *** 92,102 **** --- 94,107 ---- } lport = sns->sns_port; if (lport) { + #ifdef NS_PRIV_SOCKETS u_short aport = ntohs(lport); if (aport < NSPORT_RESERVED && (nsp->nsp_socket->so_state & SS_PRIV) == 0) return (EACCES); + #endif /* NS_PRIV_SOCKETS */ + if (ns_pcblookup(&zerons_addr, lport, 0)) return (EADDRINUSE); } *************** *** 118,123 **** --- 123,129 ---- * If don't have a local address for this socket yet, * then pick one. */ + int ns_pcbconnect(nsp, nam) struct nspcb *nsp; struct mbuf *nam; *************** *** 217,222 **** --- 223,229 ---- return (0); } + void ns_pcbdisconnect(nsp) struct nspcb *nsp; { *************** *** 226,231 **** --- 233,239 ---- ns_pcbdetach(nsp); } + void ns_pcbdetach(nsp) struct nspcb *nsp; { *************** *** 239,244 **** --- 247,253 ---- (void) m_free(dtom(nsp)); } + void ns_setsockaddr(nsp, nam) register struct nspcb *nsp; struct mbuf *nam; *************** *** 253,258 **** --- 262,268 ---- sns->sns_addr = nsp->nsp_laddr; } + void ns_setpeeraddr(nsp, nam) register struct nspcb *nsp; struct mbuf *nam; *************** *** 274,283 **** * Also pass an extra paramter via the nspcb. (which may in fact * be a parameter list!) */ ns_pcbnotify(dst, errno, notify, param) register struct ns_addr *dst; long param; ! int errno, (*notify)(); { register struct nspcb *nsp, *oinp; int s = splimp(); --- 284,295 ---- * Also pass an extra paramter via the nspcb. (which may in fact * be a parameter list!) */ + void ns_pcbnotify(dst, errno, notify, param) register struct ns_addr *dst; long param; ! void (*notify)(struct nspcb *); ! int errno; { register struct nspcb *nsp, *oinp; int s = splimp(); Index: ns_pcb.h =================================================================== RCS file: /usr/cvs/src/sys/netns/ns_pcb.h,v retrieving revision 1.11 diff -c -r1.11 ns_pcb.h *** ns_pcb.h 29 Dec 1999 04:46:20 -0000 1.11 --- ns_pcb.h 5 Mar 2003 01:15:42 -0000 *************** *** 79,85 **** #ifdef _KERNEL struct nspcb nspcb; /* head of list */ ! struct nspcb *ns_pcblookup(); #endif #endif --- 79,93 ---- #ifdef _KERNEL struct nspcb nspcb; /* head of list */ ! struct nspcb *ns_pcblookup __P((struct ns_addr *, u_short, int)); ! void ns_pcbdisconnect __P((struct nspcb *)); ! void ns_pcbdetach __P((struct nspcb *)); ! int ns_pcballoc __P((struct socket *, struct nspcb *)); ! int ns_pcbbind __P((struct nspcb *, struct mbuf *)); ! int ns_pcbconnect __P((struct nspcb *, struct mbuf *)); ! void ns_setsockaddr __P((struct nspcb *, struct mbuf *)); ! void ns_setpeeraddr __P((struct nspcb *, struct mbuf *)); ! void ns_pcbnotify __P(( struct ns_addr *, int, void(*)(struct nspcb *), long)); #endif #endif Index: ns_proto.c =================================================================== RCS file: /usr/cvs/src/sys/netns/ns_proto.c,v retrieving revision 1.10 diff -c -r1.10 ns_proto.c *** ns_proto.c 28 Aug 1999 00:49:51 -0000 1.10 --- ns_proto.c 5 Mar 2003 01:15:42 -0000 *************** *** 44,62 **** #include #include /* * NS protocol family: IDP, ERR, PE, SPP, ROUTE. */ - int ns_init(); - int idp_input(), idp_output(), idp_ctlinput(), idp_usrreq(); - int idp_raw_usrreq(), idp_ctloutput(); - int spp_input(), spp_ctlinput(); - int spp_usrreq(), spp_usrreq_sp(), spp_ctloutput(); - int spp_init(), spp_fasttimo(), spp_slowtimo(); - extern int raw_usrreq(); - extern struct domain nsdomain; struct protosw nssw[] = { { 0, &nsdomain, 0, 0, --- 44,68 ---- #include #include + #include + + /* XXX+ */ + void spp_input( struct mbuf *, struct nspcb *); + void spp_ctlinput( int, caddr_t); + int spp_ctloutput( int, struct socket *, int, int, struct mbuf **); + int spp_usrreq( struct socket *, int, struct mbuf *, struct mbuf *, struct mbuf *); + int spp_usrreq_sp( struct socket *, int, struct mbuf *, struct mbuf *, struct mbuf *); + void spp_init(void); + void spp_fasttimo(void); + void spp_slowtimo(void); + + /* XXX- */ + /* * NS protocol family: IDP, ERR, PE, SPP, ROUTE. */ struct protosw nssw[] = { { 0, &nsdomain, 0, 0, Index: spp_debug.c =================================================================== RCS file: /usr/cvs/src/sys/netns/spp_debug.c,v retrieving revision 1.10 diff -c -r1.10 spp_debug.c *** spp_debug.c 28 Aug 1999 00:49:52 -0000 1.10 --- spp_debug.c 5 Mar 2003 01:15:42 -0000 *************** *** 64,69 **** --- 64,70 ---- /* * spp debug routines */ + void spp_trace(act, ostate, sp, si, req) short act; u_char ostate; Index: spp_debug.h =================================================================== RCS file: /usr/cvs/src/sys/netns/spp_debug.h,v retrieving revision 1.9 diff -c -r1.9 spp_debug.h *** spp_debug.h 28 Aug 1999 00:49:53 -0000 1.9 --- spp_debug.h 5 Mar 2003 01:15:42 -0000 *************** *** 63,65 **** --- 63,70 ---- int spp_debx; #endif + + #ifdef _KERNEL + + void spp_trace __P(( short, u_char, struct sppcb *, struct spidp *, int)); + #endif Index: spp_usrreq.c =================================================================== RCS file: /usr/cvs/src/sys/netns/spp_usrreq.c,v retrieving revision 1.11 diff -c -r1.11 spp_usrreq.c *** spp_usrreq.c 28 Aug 1999 00:49:53 -0000 1.11 --- spp_usrreq.c 5 Mar 2003 01:15:42 -0000 *************** *** 58,66 **** --- 58,73 ---- #include #include + extern u_char nsctlerrmap[]; /* from ns_input.c */ + extern int idpcksum; /* from ns_input.c */ + + int spp_backoff[SPP_MAXRXTSHIFT+1] = + { 1, 2, 4, 8, 16, 32, 64, 64, 64, 64, 64, 64, 64 }; + /* * SP protocol implementation. */ + void spp_init() { *************** *** 74,79 **** --- 81,87 ---- u_short spp_newchecks[50]; /*ARGSUSED*/ + void spp_input(m, nsp) register struct mbuf *m; register struct nspcb *nsp; *************** *** 81,87 **** register struct sppcb *cb; register struct spidp *si = mtod(m, struct spidp *); register struct socket *so; ! short ostate; int dropsocket = 0; --- 89,95 ---- register struct sppcb *cb; register struct spidp *si = mtod(m, struct spidp *); register struct socket *so; ! short ostate = 0; /* compiler erroneously flags */ int dropsocket = 0; *************** *** 287,292 **** --- 295,301 ---- * but its function is somewhat different: It merely queues * packets up, and suppresses duplicates. */ + int spp_reass(cb, si) register struct sppcb *cb; register struct spidp *si; *************** *** 415,423 **** update_window: if (SSEQ_LT(cb->s_snxt, cb->s_rack)) cb->s_snxt = cb->s_rack; ! if (SSEQ_LT(cb->s_swl1, si->si_seq) || cb->s_swl1 == si->si_seq && (SSEQ_LT(cb->s_swl2, si->si_ack) || ! cb->s_swl2 == si->si_ack && SSEQ_LT(cb->s_ralo, si->si_alo))) { /* keep track of pure window updates */ if ((si->si_cc & SP_SP) && cb->s_swl2 == si->si_ack && SSEQ_LT(cb->s_ralo, si->si_alo)) { --- 424,432 ---- update_window: if (SSEQ_LT(cb->s_snxt, cb->s_rack)) cb->s_snxt = cb->s_rack; ! if (SSEQ_LT(cb->s_swl1, si->si_seq) || (cb->s_swl1 == si->si_seq && (SSEQ_LT(cb->s_swl2, si->si_ack) || ! (cb->s_swl2 == si->si_ack && SSEQ_LT(cb->s_ralo, si->si_alo))))) { /* keep track of pure window updates */ if ((si->si_cc & SP_SP) && cb->s_swl2 == si->si_ack && SSEQ_LT(cb->s_ralo, si->si_alo)) { *************** *** 575,589 **** return (0); } spp_ctlinput(cmd, arg) int cmd; caddr_t arg; { struct ns_addr *na; ! extern u_char nsctlerrmap[]; ! extern spp_abort(), spp_quench(); ! extern struct nspcb *idp_drop(); ! struct ns_errp *errp; struct nspcb *nsp; struct sockaddr_ns *sns; int type; --- 584,596 ---- return (0); } + void spp_ctlinput(cmd, arg) int cmd; caddr_t arg; { struct ns_addr *na; ! struct ns_errp *errp = 0; /* compiler erroneously flags */ struct nspcb *nsp; struct sockaddr_ns *sns; int type; *************** *** 639,644 **** --- 646,652 ---- * When a source quench is received, close congestion window * to one packet. We will gradually open it again as we proceed. */ + void spp_quench(nsp) struct nspcb *nsp; { *************** *** 697,702 **** --- 705,711 ---- } #endif + int spp_output(cb, m0) register struct sppcb *cb; struct mbuf *m0; *************** *** 713,719 **** int idle; #endif struct mbuf *mprev; - extern int idpcksum; if (m0) { int mtu = cb->s_mtu; --- 722,727 ---- *************** *** 1112,1122 **** int spp_do_persist_panics = 0; spp_setpersist(cb) register struct sppcb *cb; { ! register t = ((cb->s_srtt >> 2) + cb->s_rttvar) >> 1; ! extern int spp_backoff[]; if (cb->s_timer[SPPT_REXMT] && spp_do_persist_panics) panic("spp_output REXMT"); --- 1120,1130 ---- int spp_do_persist_panics = 0; + void spp_setpersist(cb) register struct sppcb *cb; { ! register int t = ((cb->s_srtt >> 2) + cb->s_rttvar) >> 1; if (cb->s_timer[SPPT_REXMT] && spp_do_persist_panics) panic("spp_output REXMT"); *************** *** 1130,1135 **** --- 1138,1144 ---- cb->s_rxtshift++; } /*ARGSUSED*/ + int spp_ctloutput(req, so, level, name, value) int req; struct socket *so; *************** *** 1255,1267 **** } /*ARGSUSED*/ spp_usrreq(so, req, m, nam, controlp) struct socket *so; int req; struct mbuf *m, *nam, *controlp; { struct nspcb *nsp = sotonspcb(so); ! register struct sppcb *cb; int s = splnet(); int error = 0, ostate; struct mbuf *mm; --- 1264,1277 ---- } /*ARGSUSED*/ + int spp_usrreq(so, req, m, nam, controlp) struct socket *so; int req; struct mbuf *m, *nam, *controlp; { struct nspcb *nsp = sotonspcb(so); ! register struct sppcb *cb = NULL; int s = splnet(); int error = 0, ostate; struct mbuf *mm; *************** *** 1297,1303 **** } nsp = sotonspcb(so); ! mm = m_getclr(M_DONTWAIT, MT_PCB); sb = &so->so_snd; if (mm == NULL) { --- 1307,1314 ---- } nsp = sotonspcb(so); ! /* private PCB */ ! mm = m_getclr(M_DONTWAIT, MT_CONTROL); sb = &so->so_snd; if (mm == NULL) { *************** *** 1507,1512 **** --- 1518,1524 ---- return (error); } + int spp_usrreq_sp(so, req, m, nam, controlp) struct socket *so; int req; *************** *** 1528,1533 **** --- 1540,1546 ---- * in a skeletal spp header (choosing connection id), * minimizing the amount of work necessary when the connection is used. */ + void spp_template(cb) register struct sppcb *cb; { *************** *** 1622,1627 **** --- 1635,1641 ---- return (spp_close(cb)); } + void spp_abort(nsp) struct nspcb *nsp; { *************** *** 1629,1639 **** (void) spp_close((struct sppcb *)nsp->nsp_pcb); } - int spp_backoff[SPP_MAXRXTSHIFT+1] = - { 1, 2, 4, 8, 16, 32, 64, 64, 64, 64, 64, 64, 64 }; /* * Fast timeout routine for processing delayed acks */ spp_fasttimo() { register struct nspcb *nsp; --- 1643,1652 ---- (void) spp_close((struct sppcb *)nsp->nsp_pcb); } /* * Fast timeout routine for processing delayed acks */ + void spp_fasttimo() { register struct nspcb *nsp; *************** *** 1658,1663 **** --- 1671,1677 ---- * Updates the timers in all active pcb's and * causes finite state machine actions if timers expire. */ + void spp_slowtimo() { register struct nspcb *ip, *ipnxt; *************** *** 1682,1689 **** if (cb->s_timer[i] && --cb->s_timer[i] == 0) { (void) spp_usrreq(cb->s_nspcb->nsp_socket, PRU_SLOWTIMO, (struct mbuf *)0, ! (struct mbuf *)i, (struct mbuf *)0, ! (struct mbuf *)0); if (ipnxt->nsp_prev != ip) goto tpgone; } --- 1696,1702 ---- if (cb->s_timer[i] && --cb->s_timer[i] == 0) { (void) spp_usrreq(cb->s_nspcb->nsp_socket, PRU_SLOWTIMO, (struct mbuf *)0, ! (struct mbuf *)i, (struct mbuf *)0); if (ipnxt->nsp_prev != ip) goto tpgone; } Index: spp_var.h =================================================================== RCS file: /usr/cvs/src/sys/netns/spp_var.h,v retrieving revision 1.11 diff -c -r1.11 spp_var.h *** spp_var.h 29 Dec 1999 04:46:21 -0000 1.11 --- spp_var.h 5 Mar 2003 01:15:42 -0000 *************** *** 195,202 **** #endif u_short spp_iss; ! extern struct sppcb *spp_close(), *spp_disconnect(), ! *spp_usrclosed(), *spp_timers(), *spp_drop(); #endif #define SPP_ISSINCR 128 --- 195,224 ---- #endif u_short spp_iss; ! ! void spp_init __P((void)); ! void spp_input __P((struct mbuf *, struct nspcb *)); ! void spp_ctlinput __P((int, caddr_t)); ! int spp_ctloutput __P((int, struct socket *, int, int, struct mbuf **)); ! int spp_usrreq __P((struct socket *, int, struct mbuf *, struct mbuf *, ! struct mbuf *)); ! int spp_usrreq_sp __P((struct socket *, int, struct mbuf *, struct mbuf *, ! struct mbuf *)); ! void spp_fasttimo __P((void)); ! void spp_slowtimo __P((void)); ! void spp_template __P((struct sppcb *)); ! int spp_reass __P((struct sppcb *, struct spidp *)); ! int spp_output __P((struct sppcb *, struct mbuf *)); ! void spp_quench __P((struct nspcb *)); ! void spp_abort __P((struct nspcb *)); ! void spp_setpersist __P((struct sppcb *)); ! ! struct sppcb *spp_close __P((struct sppcb *)); ! struct sppcb *spp_disconnect __P((struct sppcb *)); ! struct sppcb *spp_usrclosed __P((struct sppcb *)); ! struct sppcb *spp_timers __P((struct sppcb *, int)); ! struct sppcb *spp_drop __P((struct sppcb *, int)); ! #endif #define SPP_ISSINCR 128 --------------81B31A38BCFEF66ED364CE7A-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-net" in the body of the message