SpeedTouch for unix with NetBSD pppoe (work in progress)

César Catrián C.
http://mioficina.cjc.cl

Intro

This text is oriented to the SpeedTouch project for unix and in special its implementation in NetBSD 2.0 . It is assumed that speedtouch 1.3.1 is installed and working.

Due to the fact that this paper is focused on developers, and there is a litle problem yet that needs to be solved with this setup, I'll be brief.

The problem

The userppp implementation used by the SpeedTouch project as complement for the USB driver, has the following problems on the system:

For that reason I wanted to replace the userppp program, by the native ppp of NetBSD, and this is the way I did.

What is needed

tap(4) device

Since some days ago, a tap(4) device is available on pkgsrc (HEAD branch), and it can be built as a LKM for being loaded on NetBSD 2.0 and above. This device is available on NetBSD current, as well.

Building the device:

$ cd /usr/pkgsrc/net/netbsd-tap
# make install

Follow the instructions of the installation.

Populating /dev:

# /usr/pkg/sbin/tap_postinstall

Loading the module:

# modload /usr/pkg/lkm/tap.o

And it need to be activated on boot. Also, the modem_run program can be started from here (optionally).

$ cat /etc/ifconfig.tap0
create
up
! /usr/pkg/sbin/modem_run -f /usr/pkg/libdata/alcaudsl.sys -v 2

Patching pppoa2

The pppoa2 program must be patched, because bridging was available only since a few days ago. This is the patch. It needs to be added to the file pkgsrc/net/speedtouch/patches/patch-af (unexistent)

--snip-->
--- src/pppoa2.c.orig   2004-09-29 16:56:31.000000000 -0400
+++ src/pppoa2.c        2005-01-25 23:33:11.000000000 -0300
@@ -27,7 +27,8 @@
 #ifndef _PPPOA2_C_
 #define _PPPOA2_C_
 
-#if defined (__FreeBSD__) || defined (__linux__) || defined (__OpenBSD__) || defined (__DragonFly__)
+#if defined (__FreeBSD__) || defined (__linux__) || defined (__OpenBSD__) || defined (__DragonFly__) \
+       || defined (__NetBSD__)
 #define BRIDGING_ENABLED
 #endif
 
@@ -1405,7 +1406,7 @@
 {
        int fd;
 
-#if defined (__FreeBSD__) || defined (__DragonFly__)
+#if defined (__FreeBSD__) || defined (__DragonFly__) || defined (__NetBSD__)
   int i;
   char devname[] = "/dev/tapXX";
<--snip--

The patch needs to be reviewed. Then the checksum for the patch is made:

$ pwd
/usr/pkgsrc/net/speedtouch
$ make makepatchsum

Then, speedtouch is built:

$ pwd
/usr/pkgsrc/net/speedtouch
$ make deinstall
# make install

Setting up PPPoE

The last thing to do is to configure the pppoe device to be activated on boot:

# cat /etc/ifconfig.pppoe0
create
#Comment Replace vpi and vci as needed.
! /usr/pkg/sbin/pppoa2 -vpi 8 -vci 32 -v 1 -b
#Comment Let pppoe0 use tap0 as its Ethernet interface
! /sbin/pppoectl -e tap0 pppoe0
#Comment Configure authentication
! /sbin/pppoectl pppoe0 myauthproto=pap 'myauthname=XXX' 'myauthsecret=YYY' hisauthproto=none
#Comment Configure the PPPoE interface itself. These addresses are magic
#Comment meaning we don't care about either address and let the remote
#Comment ppp choose them.
0.0.0.0 0.0.0.1 up

The file rc.conf needs to be modified: /etc/rc.conf:

net_interfaces="tap0 pppoe0" 	## add other interfaces as needed.
adsl=NO				# not needed
ifwatchd=YES			# watch pppoe0 if comes down

The last unsolved problem

After the link comes up and the PPPoE connection is made, one of the two pppoa2 instances (father or child, I don't know actually), is killed by signal 1. Then:

restores the connection and it behaves stable. Comments are welcome :)

Thanks

It is appreciated the help of Christos Zoulas and Benoit Papillault for help me to deal with this problem, and Quentin Garnier for making the tap device available for NetBSD.