Package: rp-pppoe

When starting pppd, pppoe-server add local and remote address to it's
command line. But when I'm using pppd configuration for address
assigment (for ex. in pap-servrets or radius), then IP's specified in
command line of pppd by pppoe-server prevents normal working of address
configuration. There are no any way to turn off address assigment by 
pppoe-server.

By analogy, pptpd daemon have configuration option 'delegate' which 
delegate address assigment to pppd.

I created patch, which add new option "-D" to pppoe-server, which cause 
pppoe-server to skip adding addresses to pppd's command line and
delegate it to pppd configuration (pap-secrets or radius server).

This working fine for me many years and I think it will be very usefull 
to other ISP's like me. Please, consider to include this patch in
distribution.


diff -rubB rp-pppoe-3.10.orig/man/pppoe-server.8 rp-pppoe-3.10/man/pppoe-server.8
--- rp-pppoe-3.10.orig/man/pppoe-server.8	2008-06-30 17:00:42.000000000 +0300
+++ rp-pppoe-3.10/man/pppoe-server.8	2009-12-16 16:31:15.510557097 +0200
@@ -77,6 +77,11 @@
 of 10.67.15.1 is used.
 
 .TP
+.B \-D
+Delegate the allocation of IP addresses to \fBpppd\fR.  If specified, no
+local and remote addresses passed to pppd.
+
+.TP
 .B \-N \fInum\fR
 Allows at most \fInum\fR concurrent PPPoE sessions.  If not specified,
 the default is 64.
diff -rubB rp-pppoe-3.10.orig/src/pppoe-server.c rp-pppoe-3.10/src/pppoe-server.c
--- rp-pppoe-3.10.orig/src/pppoe-server.c	2008-06-30 17:00:43.000000000 +0300
+++ rp-pppoe-3.10/src/pppoe-server.c	2009-12-16 16:30:39.614556323 +0200
@@ -163,6 +163,9 @@
 unsigned char LocalIP[IPV4ALEN] = {10, 0, 0, 1}; /* Counter optionally STARTS here */
 unsigned char RemoteIP[IPV4ALEN] = {10, 67, 15, 1}; /* Counter STARTS here */
 
+/* Delegates the allocation of IP addresses to pppd (as the pptpd doing) */
+int DelegateIPAllocation = 0;
+
 /* Do we increment local IP for each connection? */
 int IncrLocalIP = 0;
 
@@ -229,6 +232,7 @@
     memset(&conn, 0, sizeof(conn));
     conn.useHostUniq = 0;
 
+    if (!DelegateIPAllocation) {
     syslog(LOG_INFO,
 	   "Session %u closed for client "
 	   "%02x:%02x:%02x:%02x:%02x:%02x (%d.%d.%d.%d) on %s",
@@ -238,6 +242,15 @@
 	   (int) session->realpeerip[0], (int) session->realpeerip[1],
 	   (int) session->realpeerip[2], (int) session->realpeerip[3],
 	   session->ethif->name);
+    } else {
+	syslog(LOG_INFO,
+	    "Session %u closed for client "
+	    "%02x:%02x:%02x:%02x:%02x:%02x on %s",
+	    (unsigned int) ntohs(session->sess),
+	    session->eth[0], session->eth[1], session->eth[2],
+	    session->eth[3], session->eth[4], session->eth[5],
+	    session->ethif->name);
+    }
     memcpy(conn.myEth, session->ethif->mac, ETH_ALEN);
     conn.discoverySocket = session->ethif->sock;
     conn.session = session->sess;
@@ -1044,6 +1057,7 @@
     fprintf(stderr, "   -L ip          -- Set local IP address.\n");
     fprintf(stderr, "   -l             -- Increment local IP address for each session.\n");
     fprintf(stderr, "   -R ip          -- Set start address of remote IP pool.\n");
+    fprintf(stderr, "   -D             -- Delegates the allocation of IP addresses to pppd.\n");
     fprintf(stderr, "   -S name        -- Advertise specified service-name.\n");
     fprintf(stderr, "   -O fname       -- Use PPPD options from specified file\n");
     fprintf(stderr, "                     (default %s).\n", PPPOE_SERVER_OPTIONS);
@@ -1103,9 +1117,9 @@
 #endif
 
 #ifndef HAVE_LINUX_KERNEL_PPPOE
-    char *options = "x:hI:C:L:R:T:m:FN:f:O:o:sp:lrudPc:S:1";
+    char *options = "x:hI:C:L:R:DT:m:FN:f:O:o:sp:lrudPc:S:1";
 #else
-    char *options = "x:hI:C:L:R:T:m:FN:f:O:o:skp:lrudPc:S:1";
+    char *options = "x:hI:C:L:R:DT:m:FN:f:O:o:skp:lrudPc:S:1";
 #endif
 
     if (getuid() != geteuid() ||
@@ -1283,6 +1297,10 @@
 	    }
 	    break;
 
+	case 'D':
+	    DelegateIPAllocation = 1;
+	    break;
+
 	case 'T':
 	case 'm':
 	    /* These just get passed to pppoe */
@@ -1719,6 +1737,7 @@
     argv[c++] = "file";
     argv[c++] = pppoptfile;
 
+    if (!DelegateIPAllocation) {
     snprintf(buffer, SMALLBUF, "%d.%d.%d.%d:%d.%d.%d.%d",
 	    (int) session->myip[0], (int) session->myip[1],
 	    (int) session->myip[2], (int) session->myip[3],
@@ -1734,6 +1753,16 @@
 	   session->ethif->name,
 	   session->serviceName);
     argv[c++] = strdup(buffer);
+    } else {
+	syslog(LOG_INFO,
+	    "Session %u created for client %02x:%02x:%02x:%02x:%02x:%02x on %s using Service-Name '%s'",
+	    (unsigned int) ntohs(session->sess),
+	    session->eth[0], session->eth[1], session->eth[2],
+	    session->eth[3], session->eth[4], session->eth[5],
+	    session->ethif->name,
+	    session->serviceName);
+    }
+    
     if (!argv[c-1]) {
 	/* TODO: Send a PADT */
 	exit(EXIT_FAILURE);
@@ -1805,6 +1834,7 @@
     argv[c++] = "file";
     argv[c++] = pppoptfile;
 
+    if (!DelegateIPAllocation) {
     snprintf(buffer, SMALLBUF, "%d.%d.%d.%d:%d.%d.%d.%d",
 	    (int) session->myip[0], (int) session->myip[1],
 	    (int) session->myip[2], (int) session->myip[3],
@@ -1820,6 +1850,16 @@
 	   session->ethif->name,
 	   session->serviceName);
     argv[c++] = strdup(buffer);
+    } else {
+	syslog(LOG_INFO,
+	    "Session %u created for client %02x:%02x:%02x:%02x:%02x:%02x on %s using Service-Name '%s'",
+	    (unsigned int) ntohs(session->sess),
+	    session->eth[0], session->eth[1], session->eth[2],
+	    session->eth[3], session->eth[4], session->eth[5],
+	    session->ethif->name,
+	    session->serviceName);
+    }
+
     if (!argv[c-1]) {
 	/* TODO: Send a PADT */
 	exit(EXIT_FAILURE);

Reply via email to