From owner-freebsd-hackers Wed Jan 14 14:11:02 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id OAA03091 for hackers-outgoing; Wed, 14 Jan 1998 14:11:02 -0800 (PST) (envelope-from owner-freebsd-hackers@FreeBSD.ORG) Received: from filer2.isc.rit.edu (filer2.isc.rit.edu [129.21.3.107]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id OAA02475 for ; Wed, 14 Jan 1998 14:07:22 -0800 (PST) (envelope-from ajl8039@osfmail.isc.rit.edu) From: ajl8039@osfmail.isc.rit.edu Received: from grace.isc.rit.edu by osfmail.isc.rit.edu (PMDF V5.1-10 #21576) with ESMTP id <0EMS008PSO49QH@osfmail.isc.rit.edu> for hackers@freebsd.org; Wed, 14 Jan 1998 17:07:21 -0500 (EST) Received: (from ajl8039@localhost) by grace.isc.rit.edu (8.8.5/8.8.5) id RAA27529 for hackers@freebsd.org; Wed, 14 Jan 1998 17:07:21 -0500 (EST) Date: Wed, 14 Jan 1998 17:07:21 -0500 (EST) Subject: iijppp dynamic IP suggestions (inc. diffs) To: hackers@FreeBSD.ORG Message-id: <199801142207.RAA27529@grace.isc.rit.edu> Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk I use iijppp at home to give a small network of machines access to the Internet. My provider assigns me a dynamic IP address, and my local network is a simple TCP/IP 10base2 ethernet. I run named with authority for my private domain and a forwarders list pointing to my ISP's nameservers. I've had two problems with iijppp. First, TCP FIN and RST packets would cause a dial-up. A one line hack fixed this, and could be made more general. Second, the initial packets sent out over the modem would come back (if they came back at all) with the make-believe IP address given to "set ifaddr". I hacked this to work by aliasing (masquerading) only after the link had gone up and setting up an IP alias (second address) for the tunnel device. The ugly part is forcing mbuf.c to allocate MAX_MRU bytes for every packet in the IP queue since aliasing can increase packet size. Of course, the initial packets are important since I run named and not every connection with the Internet starts with a (remote) name lookup. Attached are diffs against the directory /usr/src/usr.sbin/ppp of 2.2.5-RELEASE. I have also included necessary parts of ppp.conf, ppp.linkup, and ppp.linkdown. Aaron Luz aaron@csh.rit.edu diff ../ppp/ip.c ./ip.c 174a175,180 > > /* XXX Hack: never allow TCP with FIN or RST flags set to */ > /* cause a dialup. */ > if (direction == FL_DIAL && (th->th_flags & (TH_FIN | TH_RST))) > return (A_DENY); > 473a480,483 > if (mode & MODE_ALIAS) { > VarPacketAliasOut(MBUF_CTOP(bp), MAX_MRU); > bp->cnt = ntohs (((struct ip *) MBUF_CTOP(bp))->ip_len); > } diff ../ppp/main.c ./main.c 1002,1005d1001 < if (mode & MODE_ALIAS) { < VarPacketAliasOut(rbuff, sizeof rbuff); < n = ntohs(((struct ip *) rbuff)->ip_len); < } 1013,1016d1008 < if (mode & MODE_ALIAS) { < VarPacketAliasOut(rbuff, sizeof rbuff); < n = ntohs(((struct ip *) rbuff)->ip_len); < } diff ../ppp/mbuf.c ./mbuf.c 30a31 > #include "hdlc.h" /* XXX for MAX_MRU */ 64c65 < p = (u_char *) malloc(cnt); --- > p = (u_char *) malloc(MAX_MRU); /* XXX cnt */ 66c67 < LogPrintf(LogALERT, "failed to allocate memory: %d\n", cnt); --- > LogPrintf(LogALERT, "failed to allocate memory: %d\n", MAX_MRU); 70,71c71,72 < MemMap[type].count += cnt; < totalalloced += cnt; --- > MemMap[type].count += MAX_MRU; /* XXX */ > totalalloced += MAX_MRU; /* XXX */ 73c74,75 < bp->size = bp->cnt = cnt; --- > bp->size = MAX_MRU; /* XXX */ > bp->cnt = cnt; from /etc/ppp/ppp.conf myisp: set phone ... set login ... load fake-route fake-route: set ifaddr 10.0.0.1/0 10.0.0.2/0 delete ALL add 0 0 10.0.0.2 set openmode active /etc/ppp/ppp.linkup myisp: delete ALL add 0 0 HISADDR shell ifconfig tun0 10.0.0.1 HISADDR alias /etc/ppp/ppp.linkdown myisp: shell ifconfig tun0 10.0.0.1 delete load fake-route