ports/69868: [MAINTAINER] net/rp-pppoe: enable pppoe-relay (fixup lost patch)

Matthias Andree matthias.andree at gmx.de
Sun Aug 1 10:10:21 UTC 2004


>Number:         69868
>Category:       ports
>Synopsis:       [MAINTAINER] net/rp-pppoe: enable pppoe-relay (fixup lost patch)
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          maintainer-update
>Submitter-Id:   current-users
>Arrival-Date:   Sun Aug 01 10:10:18 GMT 2004
>Closed-Date:
>Last-Modified:
>Originator:     Matthias Andree
>Release:        FreeBSD 4.10-RELEASE-p2 i386
>Organization:
>Environment:
System: FreeBSD libertas.emma.line.org 4.10-RELEASE-p2 FreeBSD 4.10-RELEASE-p2 #2: Thu Jul  1 00:06:57 CEST
>Description:
This patch is a revised edition of the now closed ports/64041.

* enable pppoe-relay 
  patches originally submitted by SeaD (Cc'd) on 2004-03-10
  patch got lost as my ports/68113 was committed

Generated with FreeBSD Port Tools 0.50
>How-To-Repeat:
>Fix:

--- rp-pppoe-3.5_1.patch begins here ---
diff -ruN --exclude=CVS /usr/ports/net/rp-pppoe/Makefile /root/ports/net/rp-pppoe/Makefile
--- /usr/ports/net/rp-pppoe/Makefile	Thu Jun 24 16:26:50 2004
+++ /root/ports/net/rp-pppoe/Makefile	Sun Aug  1 11:59:14 2004
@@ -7,6 +7,7 @@
 
 PORTNAME=	rp-pppoe
 PORTVERSION=	3.5
+PORTREVISION=	1
 CATEGORIES=	net
 MASTER_SITES=	http://www.roaringpenguin.com/penguin/pppoe/
 
@@ -15,6 +16,7 @@
 
 USE_REINPLACE=	yes
 GNU_CONFIGURE=	yes
+PATCH_WRKSRC=	${WRKSRC}/src
 CONFIGURE_WRKSRC=	${WRKSRC}/src
 BUILD_WRKSRC=	${WRKSRC}/src
 
@@ -50,7 +52,7 @@
 
 do-install:
 # Binaries
-.for f in pppoe pppoe-server
+.for f in pppoe pppoe-server pppoe-relay
 	@${INSTALL_PROGRAM} ${BUILD_WRKSRC}/${f} ${PREFIX}/sbin
 .endfor
 # Configurations
@@ -59,10 +61,6 @@
 	@${INSTALL_DATA} ${WRKSRC}/configs/${f} \
 		${PREFIX}/etc/ppp/${f}.sample
 .endfor
-.if !exists(${PREFIX}/etc/ppp/pppoe.conf)
-	${INSTALL_SCRIPT} ${PREFIX}/etc/ppp/pppoe.conf.sample \
-		${PREFIX}/etc/ppp/pppoe.conf
-.endif
 # Manual pages
 	@${MKDIR} ${MAN5PREFIX}/man/man5
 .for f in ${MAN5}
@@ -76,6 +74,11 @@
 .for f in ${SCRIPT_FILES}
 	@${INSTALL_SCRIPT} ${WRKSRC}/scripts/${f} ${PREFIX}/sbin
 .endfor
+# Startup scripts
+.for f in 04pppoe-relay.sh.sample 04pppoe-server.sh.sample
+	@${INSTALL_SCRIPT} ${FILESDIR}/${f} ${PREFIX}/etc/rc.d/
+.endfor
+
 # Documentation
 .ifndef (NOPORTDOCS)
 	@${MKDIR} ${DOCSDIR}
diff -ruN --exclude=CVS /usr/ports/net/rp-pppoe/files/04pppoe-relay.sh.sample /root/ports/net/rp-pppoe/files/04pppoe-relay.sh.sample
--- /usr/ports/net/rp-pppoe/files/04pppoe-relay.sh.sample	Thu Jan  1 01:00:00 1970
+++ /root/ports/net/rp-pppoe/files/04pppoe-relay.sh.sample	Tue Jul 27 00:13:57 2004
@@ -0,0 +1,30 @@
+#! /bin/sh
+
+# use a subshell to support new -CURRENT rc.d structure
+(
+daemon=pppoe-relay
+daemon_path=/usr/local/sbin
+daemon_flags=
+
+case $1 in
+    start)
+        if [ -x ${daemon_path}/$daemon ]; then
+            ${daemon_path}/$daemon $daemon_flags
+            echo -n " $daemon"
+        fi
+        ;;
+    stop)
+        killall $daemon && echo -n " $daemon"
+        ;;
+    restart)
+        $0 stop
+        sleep 1
+        $0 start
+        ;;
+    *)
+        echo "Usage: `basename $0` {start|stop|restart}" >&2
+        exit 64
+        ;;
+esac
+exit 0
+)
diff -ruN --exclude=CVS /usr/ports/net/rp-pppoe/files/04pppoe-server.sh.sample /root/ports/net/rp-pppoe/files/04pppoe-server.sh.sample
--- /usr/ports/net/rp-pppoe/files/04pppoe-server.sh.sample	Thu Jan  1 01:00:00 1970
+++ /root/ports/net/rp-pppoe/files/04pppoe-server.sh.sample	Tue Jul 27 00:13:26 2004
@@ -0,0 +1,31 @@
+#! /bin/sh
+
+# use a subshell to support new -CURRENT rc.d structure
+(
+daemon=pppoe-server
+daemon_path=/usr/local/sbin
+daemon_flags=
+
+case $1 in
+    start)
+        if [ -x ${daemon_path}/$daemon ]; then
+            ${daemon_path}/$daemon $daemon_flags
+            echo -n " $daemon"
+        fi
+        ;;
+    stop)
+        killall $daemon && echo -n " $daemon"
+        ;;
+    restart)
+        $0 stop
+        sleep 1
+        $0 start
+        ;;
+    *)
+        echo "Usage: `basename $0` {start|stop|restart}" >&2
+        exit 64
+        ;;
+esac
+
+exit 0
+)
diff -ruN --exclude=CVS /usr/ports/net/rp-pppoe/files/patch-ab /root/ports/net/rp-pppoe/files/patch-ab
--- /usr/ports/net/rp-pppoe/files/patch-ab	Thu Jan  1 01:00:00 1970
+++ /root/ports/net/rp-pppoe/files/patch-ab	Wed Mar 10 13:49:47 2004
@@ -0,0 +1,11 @@
+--- configure.orig	Mon Jul  8 20:38:24 2002
++++ configure	Wed Mar 10 15:50:51 2004
+@@ -2083,7 +2083,7 @@
+ 
+ 
+ # Determine what targets to build
+-TARGETS="pppoe pppoe-server"
++TARGETS="pppoe pppoe-server pppoe-relay"
+ 
+ # pppoe-sniff is built only on Linux and Solaris
+ if test "$ac_cv_header_linux_if_packet_h" = "yes" -o "$ac_cv_header_sys_dlpi_h" = "yes" ; then
diff -ruN --exclude=CVS /usr/ports/net/rp-pppoe/files/patch-ac /root/ports/net/rp-pppoe/files/patch-ac
--- /usr/ports/net/rp-pppoe/files/patch-ac	Thu Jan  1 01:00:00 1970
+++ /root/ports/net/rp-pppoe/files/patch-ac	Wed Mar 10 13:49:47 2004
@@ -0,0 +1,15 @@
+--- if.c.orig	Mon Jul  8 20:38:24 2002
++++ if.c	Wed Mar 10 15:47:26 2004
+@@ -285,7 +285,12 @@
+     int i;
+ 
+     /* BSD only opens one socket for both Discovery and Session packets */
++#if defined(__FreeBSD__)
++    /* Confirmed for FreeBSD 4.8-R [SeaD] */
++    if (!hwaddr) {
++#else
+     if (fd >= 0) {
++#endif
+ 	return fd;
+     }
+ 
diff -ruN --exclude=CVS /usr/ports/net/rp-pppoe/files/patch-ad /root/ports/net/rp-pppoe/files/patch-ad
--- /usr/ports/net/rp-pppoe/files/patch-ad	Thu Jan  1 01:00:00 1970
+++ /root/ports/net/rp-pppoe/files/patch-ad	Wed Mar 10 13:49:47 2004
@@ -0,0 +1,179 @@
+--- relay.c.orig	Mon Jul  8 20:38:24 2002
++++ relay.c	Wed Mar 10 16:29:40 2004
+@@ -743,6 +743,11 @@
+ relayLoop()
+ {
+     fd_set readable, readableCopy;
++#if defined(__FreeBSD__)
++    PPPoEPacket packet;
++    int size;
++    int type;
++#endif
+     int maxFD;
+     int i, r;
+     int sock;
+@@ -772,6 +777,27 @@
+ 	    continue;
+ 	}
+ 
++#if defined(__FreeBSD__)
++        for (i=0; i<NumInterfaces; i++) {
++            /* Because FreeBSD use one interface for both Discovery and
++            Session types we use first socket for packet receiving [SeaD] */
++            if (!FD_ISSET(Interfaces[i].discoverySock, &readableCopy))
++                continue;
++            if (receivePacket(Interfaces[i].discoverySock, &packet, &size) < 0)
++                continue;
++
++            /* Ignore unknown code/version */
++            if (packet.ver != 1 || packet.type != 1)
++                continue;
++
++            type = etherType(&packet);
++            if (type == Eth_PPPOE_Discovery) {
++                relayGotDiscoveryPacket(&Interfaces[i], &packet, size);
++            } else if (type == Eth_PPPOE_Session) {
++                relayGotSessionPacket(&Interfaces[i], &packet, size);
++            }
++        }
++#else
+ 	/* Handle session packets first */
+ 	for (i=0; i<NumInterfaces; i++) {
+ 	    if (FD_ISSET(Interfaces[i].sessionSock, &readableCopy)) {
+@@ -786,6 +812,7 @@
+ 	    }
+ 	}
+ 
++#endif
+ 	/* Handle the session-cleaning process */
+ 	if (FD_ISSET(CleanPipe[0], &readableCopy)) {
+ 	    char dummy;
+@@ -805,6 +832,46 @@
+ *%DESCRIPTION:
+ * Receives and processes a discovery packet.
+ ***********************************************************************/
++#if defined(__FreeBSD__)
++void
++relayGotDiscoveryPacket(PPPoEInterface const *iface,
++                        PPPoEPacket *packet,
++                        int size)
++{
++
++    if (ntohs(packet->length) + HDR_SIZE > size) {
++	syslog(LOG_ERR, "Bogus PPPoE length field (%u)",
++	       (unsigned int) ntohs(packet->length));
++	return;
++    }
++
++    /* Drop Ethernet frame padding */
++    if (size > ntohs(packet->length) + HDR_SIZE) {
++	size = ntohs(packet->length) + HDR_SIZE;
++    }
++
++    switch(packet->code) {
++    case CODE_PADT:
++	relayHandlePADT(iface, packet, size);
++	break;
++    case CODE_PADI:
++	relayHandlePADI(iface, packet, size);
++	break;
++    case CODE_PADO:
++	relayHandlePADO(iface, packet, size);
++	break;
++    case CODE_PADR:
++	relayHandlePADR(iface, packet, size);
++	break;
++    case CODE_PADS:
++	relayHandlePADS(iface, packet, size);
++	break;
++    default:
++	syslog(LOG_ERR, "Discovery packet on %s with unknown code %d",
++	       iface->name, (int) packet->code);
++    }
++}
++#else
+ void
+ relayGotDiscoveryPacket(PPPoEInterface const *iface)
+ {
+@@ -852,6 +919,7 @@
+ 	       iface->name, (int) packet.code);
+     }
+ }
++#endif
+ 
+ /**********************************************************************
+ *%FUNCTION: relayGotSessionPacket
+@@ -862,6 +930,65 @@
+ *%DESCRIPTION:
+ * Receives and processes a session packet.
+ ***********************************************************************/
++#if defined(__FreeBSD__)
++void
++relayGotSessionPacket(PPPoEInterface const *iface,
++                        PPPoEPacket *packet,
++                        int size)
++{
++    SessionHash *sh;
++    PPPoESession *ses;
++
++    /* Must be a session packet */
++    if (packet->code != CODE_SESS) {
++	syslog(LOG_ERR, "Session packet with code %d", (int) packet->code);
++	return;
++    }
++
++    /* Ignore session packets whose destination address isn't ours */
++    if (memcmp(packet->ethHdr.h_dest, iface->mac, ETH_ALEN)) {
++	return;
++    }
++
++    /* Validate length */
++    if (ntohs(packet->length) + HDR_SIZE > size) {
++	syslog(LOG_ERR, "Bogus PPPoE length field (%u)",
++	       (unsigned int) ntohs(packet->length));
++	return;
++    }
++
++    /* Drop Ethernet frame padding */
++    if (size > ntohs(packet->length) + HDR_SIZE) {
++	size = ntohs(packet->length) + HDR_SIZE;
++    }
++
++    /* We're in business!  Find the hash */
++    sh = findSession(packet->ethHdr.h_source, packet->session);
++    if (!sh) {
++	/* Don't log this.  Someone could be running the client and the
++	   relay on the same box. */
++	return;
++    }
++
++    /* Relay it */
++    ses = sh->ses;
++    ses->epoch = Epoch;
++    sh = sh->peer;
++    packet->session = sh->sesNum;
++    memcpy(packet->ethHdr.h_source, sh->interface->mac, ETH_ALEN);
++    memcpy(packet->ethHdr.h_dest, sh->peerMac, ETH_ALEN);
++#if 0
++    fprintf(stderr, "Relaying %02x:%02x:%02x:%02x:%02x:%02x(%s:%d) to %02x:%02x:%02x:%02x:%02x:%02x(%s:%d)\n",
++	    sh->peer->peerMac[0], sh->peer->peerMac[1], sh->peer->peerMac[2],
++	    sh->peer->peerMac[3], sh->peer->peerMac[4], sh->peer->peerMac[5],
++	    sh->peer->interface->name, ntohs(sh->peer->sesNum),
++	    sh->peerMac[0], sh->peerMac[1], sh->peerMac[2],
++	    sh->peerMac[3], sh->peerMac[4], sh->peerMac[5],
++	    sh->interface->name, ntohs(sh->sesNum));
++#endif
++    sendPacket(NULL, sh->interface->sessionSock, packet, size);
++}
++#else
+ void
+ relayGotSessionPacket(PPPoEInterface const *iface)
+ {
+@@ -928,6 +1055,7 @@
+ #endif
+     sendPacket(NULL, sh->interface->sessionSock, &packet, size);
+ }
++#endif
+ 
+ /**********************************************************************
+ *%FUNCTION: relayHandlePADT
diff -ruN --exclude=CVS /usr/ports/net/rp-pppoe/files/patch-ae /root/ports/net/rp-pppoe/files/patch-ae
--- /usr/ports/net/rp-pppoe/files/patch-ae	Thu Jan  1 01:00:00 1970
+++ /root/ports/net/rp-pppoe/files/patch-ae	Wed Mar 10 13:49:47 2004
@@ -0,0 +1,16 @@
+--- relay.h.orig	Mon Jul  8 20:38:24 2002
++++ relay.h	Wed Mar 10 15:50:51 2004
+@@ -51,8 +51,13 @@
+ 
+ /* Function prototypes */
+ 
++#if defined(__FreeBSD__)
++void relayGotSessionPacket(PPPoEInterface const *iface, PPPoEPacket *packet, int size);
++void relayGotDiscoveryPacket(PPPoEInterface const *iface, PPPoEPacket *packet, int size);
++#else
+ void relayGotSessionPacket(PPPoEInterface const *i);
+ void relayGotDiscoveryPacket(PPPoEInterface const *i);
++#endif
+ PPPoEInterface *findInterface(int sock);
+ unsigned int hash(unsigned char const *mac, UINT16_t sesNum);
+ SessionHash *findSession(unsigned char const *mac, UINT16_t sesNum);
diff -ruN --exclude=CVS /usr/ports/net/rp-pppoe/pkg-message /root/ports/net/rp-pppoe/pkg-message
--- /usr/ports/net/rp-pppoe/pkg-message	Thu Jan  1 01:00:00 1970
+++ /root/ports/net/rp-pppoe/pkg-message	Tue Jul 27 01:13:30 2004
@@ -0,0 +1,4 @@
+Note that many of the script this port installs haven't been tested in
+a long time and the components tested are pppoe and pppoe-relay for the
+major part. Use the adsl-* configuration scripts at your own risk.
+Feedback about success and failure to the port maintainer is appreciated though.
diff -ruN --exclude=CVS /usr/ports/net/rp-pppoe/pkg-plist /root/ports/net/rp-pppoe/pkg-plist
--- /usr/ports/net/rp-pppoe/pkg-plist	Thu Jun 24 16:26:50 2004
+++ /root/ports/net/rp-pppoe/pkg-plist	Tue Jul 27 01:11:36 2004
@@ -5,11 +5,14 @@
 sbin/adsl-status
 sbin/adsl-stop
 sbin/pppoe
+sbin/pppoe-relay
 sbin/pppoe-server
 etc/ppp/firewall-masq.sample
 etc/ppp/firewall-standalone.sample
 etc/ppp/pap-secrets.sample
 etc/ppp/pppoe-server-options.sample
- at unexec if cmp -s %D/etc/ppp/pppoe.conf.sample %D/etc/ppp/pppoe.conf ; then rm %D/etc/ppp/pppoe.conf ; fi
+ at unexec for i in ppp/pppoe.conf rc.d/04pppoe-server.sh rc.d/04pppoe-relay.sh ; do if cmp -s %D/etc/$i.sample %D/etc/$i ; then rm %D/etc/$i ; fi ; done
 etc/ppp/pppoe.conf.sample
+etc/rc.d/04pppoe-server.sh.sample
+etc/rc.d/04pppoe-relay.sh.sample
 @unexec rmdir %D/etc/ppp 2>/dev/null || echo "If you are permanently removing pppoe, you should also ``rm -Rf ${PKG_PREFIX}/etc/ppp'' removing any configuration and password files left." | /usr/bin/fmt
--- rp-pppoe-3.5_1.patch ends here ---

>Release-Note:
>Audit-Trail:
>Unformatted:



More information about the freebsd-ports-bugs mailing list