From owner-freebsd-net Fri Apr 12 15:32:24 2002 Delivered-To: freebsd-net@freebsd.org Received: from InterJet.dellroad.org (adsl-63-194-81-26.dsl.snfc21.pacbell.net [63.194.81.26]) by hub.freebsd.org (Postfix) with ESMTP id 77F7A37B485 for ; Fri, 12 Apr 2002 15:30:03 -0700 (PDT) Received: from arch20m.dellroad.org (arch20m.dellroad.org [10.1.1.20]) by InterJet.dellroad.org (8.9.1a/8.9.1) with ESMTP id PAA23175; Fri, 12 Apr 2002 15:12:44 -0700 (PDT) Received: (from archie@localhost) by arch20m.dellroad.org (8.11.6/8.11.6) id g3CMBko12496; Fri, 12 Apr 2002 15:11:46 -0700 (PDT) (envelope-from archie) From: Archie Cobbs Message-Id: <200204122211.g3CMBko12496@arch20m.dellroad.org> Subject: Re: mpd PPTP and NAT In-Reply-To: <200204112320.g3BNKjg08185@arch20m.dellroad.org> "from Archie Cobbs at Apr 11, 2002 04:20:45 pm" To: Archie Cobbs Date: Fri, 12 Apr 2002 15:11:46 -0700 (PDT) Cc: Elliott Perrin , freebsd-net@FreeBSD.ORG X-Mailer: ELM [version 2.4ME+ PL88 (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII 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 Archie Cobbs writes: > > that is exactly what I am seeing, the clients are behind this stupid > > little GVC IP0008 machine, and I am using your mpd software for the pptp > > server. I know about the "BUG" in libalias. > > > > Is this part of the PPTP spec, that only one TCP control connection can be > > open to an IP, or is it a purely libalias thing. > > Yes it is part of the PPTP spec.. however, I've seen servers > that ignore the spec and accept multiple connections from a > single remote source. Mpd should probably do the same thing > when configured for 'server only' mode.. hmm, maybe I'll look > into that (will send you a patch if/when). Please try the patch below and see if it works. I haven't tested it at all myself.. Thanks, -Archie __________________________________________________________________________ Archie Cobbs * Packet Design * http://www.packetdesign.com Index: pptp.c =================================================================== RCS file: /home/cvs/archie/mpd/src/pptp.c,v retrieving revision 1.4 diff -u -r1.4 pptp.c --- pptp.c 2002/03/01 02:42:24 1.4 +++ pptp.c 2002/04/12 22:12:25 @@ -680,22 +680,32 @@ static void PptpListenUpdate(void) { + int allow_incoming = 0; + int allow_multiple = 1; int k; + /* Examine all PPTP links */ for (k = 0; k < gNumLinks; k++) { if (gLinks[k] && gLinks[k]->phys->type == &gPptpPhysType) { PptpInfo const p = (PptpInfo)gLinks[k]->phys->info; if (Enabled(&p->options, PPTP_CONF_INCOMING)) - break; + allow_incoming = 1; + if (Enabled(&p->options, PPTP_CONF_ORIGINATE) + && p->peer_addr_req.ipaddr.s_addr != 0) + allow_multiple = 0; } } + + /* Initialize first time */ if (!gInitialized) { - if (k == gNumLinks) + if (!allow_incoming) return; /* wait till later; we may not have an IP address yet */ PptpInitCtrl(); } - PptpCtrlListen(k < gNumLinks, gLocalPort); + + /* Set up listening for incoming connections */ + PptpCtrlListen(allow_incoming, gLocalPort, allow_multiple); } /* @@ -727,6 +737,7 @@ pptp->peer_addr_req = rng; pptp->peer_port_req = port; } + PptpListenUpdate(); break; case SET_PHONENUM: if (ac != 1) Index: pptp_ctrl.c =================================================================== RCS file: /home/cvs/archie/mpd/src/pptp_ctrl.c,v retrieving revision 1.4 diff -u -r1.4 pptp_ctrl.c --- pptp_ctrl.c 2002/03/16 18:29:37 1.4 +++ pptp_ctrl.c 2002/04/12 22:12:27 @@ -228,6 +228,7 @@ static u_char gInitialized; static u_long gStartTime; static u_int16_t gLastCallId; + static int gAllowMultiple; static int gListenSock = -1; static struct in_addr gListenIp; static EventRef gListenRetry; @@ -518,11 +519,12 @@ */ int -PptpCtrlListen(int enable, int port) +PptpCtrlListen(int enable, int port, int allow_multiple) { assert(gInitialized); port = port ? port : PPTP_PORT; if (enable) { + gAllowMultiple = allow_multiple; if (gListenSock >= 0 || EventIsRegistered(gListenRetry)) return(0); if ((gListenSock = TcpGetListenPort(gListenIp, &port)) < 0) { @@ -536,6 +538,7 @@ EventRegister(&gListenEvent, EVENT_READ, gListenSock, DEV_PRIO, PptpCtrlListenEvent, NULL); } else { + gAllowMultiple = 0; if (gListenSock < 0) return(0); close(gListenSock); @@ -557,7 +560,7 @@ { const u_short port = (u_short) (int) cookie; - PptpCtrlListen(TRUE, port); + PptpCtrlListen(TRUE, port, gAllowMultiple); } /* @@ -1826,6 +1829,10 @@ struct pptpStartCtrlConnReply reply; int k; + /* Are we allowing multiple connections from the same IP address? */ + if (gAllowMultiple) + goto reply; + /* Check for a collision */ for (k = 0; k < gNumPptpCtrl; k++) { PptpCtrl const c2 = gPptpCtrl[k]; @@ -1845,6 +1852,7 @@ PptpCtrlKillCtrl(c2); /* Kill the connection that I initiated */ } +reply: /* Initialize reply */ memset(&reply, 0, sizeof(reply)); reply.vers = PPTP_PROTO_VERS; Index: pptp_ctrl.h =================================================================== RCS file: /home/cvs/archie/mpd/src/pptp_ctrl.h,v retrieving revision 1.3 diff -u -r1.3 pptp_ctrl.h --- pptp_ctrl.h 2001/12/15 20:59:51 1.3 +++ pptp_ctrl.h 2002/04/12 22:12:27 @@ -406,7 +406,8 @@ PptpGetOutLink_t getOutLink, struct in_addr myip); - extern int PptpCtrlListen(int enable, int port); + extern int PptpCtrlListen(int enable, int port, + int allow_multiple); extern struct pptpctrlinfo PptpCtrlInCall(struct pptplinkinfo linfo, struct in_addr ip, int port, int bearType, To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-net" in the body of the message