From frank@pinky.sax.de  Wed Jun 27 19:41:44 2007
Return-Path: <frank@pinky.sax.de>
Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52])
	by hub.freebsd.org (Postfix) with ESMTP id 9644316A400
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 27 Jun 2007 19:41:44 +0000 (UTC)
	(envelope-from frank@pinky.sax.de)
Received: from pinky.frank-behrens.de (pinky.frank-behrens.de [82.139.199.24])
	by mx1.freebsd.org (Postfix) with ESMTP id DB72913C43E
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 27 Jun 2007 19:41:43 +0000 (UTC)
	(envelope-from frank@pinky.sax.de)
Received: from moon.behrens (localhost [127.0.0.1])
	by pinky.frank-behrens.de (8.14.1/8.14.1) with ESMTP-MSA id l5RJfV0O041480
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO)
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 27 Jun 2007 21:41:32 +0200 (CEST)
	(envelope-from frank@moon.behrens)
Received: (from frank@localhost)
	by moon.behrens (8.14.1/8.14.1/Submit) id l5RJfVqO041479;
	Wed, 27 Jun 2007 21:41:31 +0200 (CEST)
	(envelope-from frank)
Message-Id: <200706271941.l5RJfVqO041479@moon.behrens>
Date: Wed, 27 Jun 2007 21:41:31 +0200 (CEST)
From: Frank Behrens <frank@pinky.sax.de>
To: FreeBSD-gnats-submit@freebsd.org
Subject: ppp(8) should be able to set ethernet address for PPPoE [patch]
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         114081
>Category:       bin
>Synopsis:       [patch] [ppp] ppp(8) should be able to set ethernet address for PPPoE
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    gnn
>State:          suspended
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Wed Jun 27 19:50:03 GMT 2007
>Closed-Date:    
>Last-Modified:  Sun May 18 05:04:11 UTC 2014
>Originator:     Frank Behrens
>Release:        FreeBSD 6.2-STABLE-200705211513 i386
>Organization:
>Environment:
>Description:
ppp(8) should be able to set ethernet address for PPPoE [patch]

In general it is possible to have multiple, concurrent sessions on a
PPPoE connection. So it is possible to connect to different
internet providers simultaneously on a single DSL line. However a big 
german DSL provider requires a different MAC address for each session
to avoid inadvertent double connects.

So it is desired to be able to set the ethernet address for
outgoing PPPoE connections via ppp(8). Fortunately ng_pppoe(4)
has already this possibility: NGM_PPPOE_SETENADDR. The attached
patch adds this functionality to ppp(8).

still todo:
- rename option numbers (meanwhile others were added?)
- Is option name ok?
- bump man page date
- adjust version number for ppp

>How-To-Repeat:
>Fix:

--- pppether.patch begins here ---
--- command.c.orig	Tue Feb  8 11:38:24 2005
+++ command.c	Tue Jun 19 17:37:23 2007
@@ -144,6 +144,7 @@
 #define	VAR_IPV6CPRETRY	37
 #define	VAR_RAD_ALIVE	38
 #define	VAR_PPPOE	39
+#define	VAR_PPPOEENADD	57	/* todo: renumber */
 
 /* ``accept|deny|disable|enable'' masks */
 #define NEG_HISMASK (1)
@@ -168,7 +169,7 @@
 #define NEG_MPPE	55
 #define NEG_CHAP81	56
 
-const char Version[] = "3.4.2";
+const char Version[] = "3.4.2.fb1";
 
 static int ShowCommand(struct cmdargs const *);
 static int TerminalCommand(struct cmdargs const *);
@@ -2312,8 +2313,12 @@
     }
     break;
 
-  }
+  case VAR_PPPOEENADD:
+    res = physical_SetPPPoEEtherAddr(arg->cx->physical, argp);
+    break;
 
+
+  }
   return res;
 }
 
@@ -2444,6 +2449,9 @@
   {"pppoe", NULL, SetVariable, LOCAL_AUTH | LOCAL_CX,
    "Connect using standard/3Com mode", "set pppoe [standard|3Com]",
    (const char *)VAR_PPPOE},
+  {"pppoeethadd", NULL, SetVariable, LOCAL_AUTH | LOCAL_CX,
+   "set pppoe ethernet address", "set pppoeethadd linkaddress",
+   (const char *)VAR_PPPOEENADD},
   {NULL, NULL, NULL, 0, NULL, NULL, NULL},
 };
 
--- ether.c.orig	Mon Sep  6 02:07:58 2004
+++ ether.c	Tue Jun 19 17:45:04 2007
@@ -636,6 +636,16 @@
       }
     }
 
+    /* Set ethernet address for outgoing packets */
+    if (p->cfg.pppoe_addrset) {
+      if (NgSendMsg(dev->cs, connectpath, NGM_PPPOE_COOKIE,
+		NGM_PPPOE_SETENADDR, p->cfg.etheradd, PPP_ETHER_ADDR_LEN) == -1) {
+        log_Printf(LogWARN, "``%s'': Cannot set ethernet address: %s\n",
+                 connectpath, strerror(errno));
+        return ether_Abandon(dev, p);
+      }
+    }
+
     /* And finally, request a connection to the given provider */
 
     data = (struct ngpppoe_init_data *)alloca(sizeof *data + providerlen);
--- physical.c.orig	Sun May 21 17:26:19 2006
+++ physical.c	Tue Jun 19 17:39:32 2007
@@ -24,6 +24,7 @@
 #include <netinet/in.h>
 #include <netinet/in_systm.h>
 #include <netinet/ip.h>
+#include <net/if_dl.h>
 #include <sys/socket.h>
 #include <sys/un.h>
 
@@ -1147,4 +1148,30 @@
    p->cfg.nonstandard_pppoe = enable ? 1 : 0;
    p->cfg.pppoe_configured = 1;
    return 1;
+}
+
+int
+physical_SetPPPoEEtherAddr(struct physical *p, const char* addrstr)
+{
+
+  char *temp;
+  struct sockaddr_dl sdl;
+
+  if ((temp = malloc(strlen(addrstr) + 2)) == NULL) {
+      log_Printf(LogALERT, "malloc failed");
+      return 1;
+  }
+  temp[0] = ':';
+  strcpy(temp + 1, addrstr);
+  sdl.sdl_len = sizeof(sdl);
+  link_addr(temp, &sdl);
+  free(temp);
+  if (sdl.sdl_alen != PPP_ETHER_ADDR_LEN) {
+      log_Printf(LogERROR, "malformed link-level address: %s", addrstr);
+      return 1;
+  }
+  p->cfg.pppoe_addrset = 1;
+  bcopy(LLADDR(&sdl), p->cfg.etheradd, sdl.sdl_alen);
+
+  return 0;
 }
--- physical.h.orig	Sun Sep  5 03:46:52 2004
+++ physical.h	Tue Jun 19 17:36:41 2007
@@ -49,6 +49,11 @@
 #define CD_NOTREQUIRED	2
 #define CD_DEFAULT	3
 
+/* length of ethernet address. This is already in <net/ethernet.h>, 
+   but avoid to include it in every source. */
+#define PPP_ETHER_ADDR_LEN 6
+
+
 struct cd {
   unsigned necessity : 2;  /* A CD_ value */
   int delay;               /* Wait this many seconds after login script */
@@ -106,12 +111,14 @@
     unsigned rts_cts : 1;      /* Is rts/cts enabled ? */
     unsigned nonstandard_pppoe : 1; /* Is PPPoE mode nonstandard */
     unsigned pppoe_configured : 1; /* temporary hack */
+    unsigned pppoe_addrset : 1; /* Is PPPoE ethernet address set? */
     unsigned parity;           /* What parity is enabled? (tty flags) */
     unsigned speed;            /* tty speed */
 
     char devlist[LINE_LEN];    /* NUL separated list of devices */
     int ndev;                  /* number of devices in list */
     struct cd cd;
+    char etheradd[PPP_ETHER_ADDR_LEN];
   } cfg;
 };
 
@@ -174,3 +181,4 @@
 extern void physical_SetAsyncParams(struct physical *, u_int32_t, u_int32_t);
 extern int physical_Slot(struct physical *);
 extern int physical_SetPPPoEnonstandard(struct physical *, int);
+extern int physical_SetPPPoEEtherAddr(struct physical *, const char* addrstr);
--- ppp.8.m4.orig	Fri May  6 18:13:32 2005
+++ ppp.8.m4	Wed Jun 27 21:28:55 2007
@@ -27,7 +27,7 @@
 .\"
 .\" $FreeBSD: src/usr.sbin/ppp/ppp.8.m4,v 1.322 2005/05/06 16:13:32 brian Exp $
 .\"
-.Dd July 20, 2004
+.Dd June 27, 2007
 .Dt PPP 8
 .Os
 .Sh NAME
@@ -5345,6 +5345,10 @@
 .Xr ng_pppoe 4
 node to either standard RFC2516 PPPoE or proprietary 3Com mode.
 If not set the system default will be used.
+.It set pppoeethadd Ar nn:nn:nn:nn:nn:nn
+This option sets the node Ethernet address for outgoing PPPoE
+sessions.
+If not set the address of interface will be used.
 .It set Op proc Ns Xo
 .No title Op Ar value
 .Xc
--- pppether.patch ends here ---


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->freebsd-net 
Responsible-Changed-By: remko 
Responsible-Changed-When: Thu Jun 28 05:54:16 UTC 2007 
Responsible-Changed-Why:  
I think this is more something for the networking team, reassign. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=114081 

From: "Bjoern A. Zeeb" <bz@FreeBSD.org>
To: bug-followup@FreeBSD.org
Cc: frank@pinky.sax.de
Subject: Re: bin/114081: [patch] ppp(8) should be able to set ethernet address
 for PPPoE
Date: Thu, 28 Jun 2007 08:54:28 +0000 (UTC)

 On Thu, 28 Jun 2007, Remko Lodder wrote:
 
 > Synopsis: [patch] ppp(8) should be able to set ethernet address for PPPoE
 >
 > Responsible-Changed-From-To: freebsd-bugs->freebsd-net
 > Responsible-Changed-By: remko
 > Responsible-Changed-When: Thu Jun 28 05:54:16 UTC 2007
 > Responsible-Changed-Why:
 > I think this is more something for the networking team, reassign.
 >
 > http://www.freebsd.org/cgi/query-pr.cgi?pr=114081
 
 I have more complete patches since 2004 in my private tree for exactly
 the same DTAG reason;-)
 
 The very early versions are still around here:
  	http://sources.zabbadoz.net/freebsd/patchset/
 10005-10008* I think. But they are highly outdated.
 
 I can upload newer versions somewhen the next days.
 
 BTW: are you putting your NIC into promisc mode using ifconfig? I
 cannot see how you would receive the packets for a different MAC else?
 
 -- 
 Bjoern A. Zeeb                                 bzeeb at Zabbadoz dot NeT
 Software is harder than hardware  so better get it right the first time.

From: "Frank Behrens" <frank@pinky.sax.de>
To: "Bjoern A. Zeeb" <bz@FreeBSD.org>
Cc: bug-followup@FreeBSD.org
Subject: Re: bin/114081: [patch] ppp(8) should be able to set ethernet address for PPPoE
Date: Thu, 28 Jun 2007 13:39:10 +0200

 Bjoern A. Zeeb <bz@FreeBSD.org> wrote on 28 Jun 2007 8:54:
 > On Thu, 28 Jun 2007, Remko Lodder wrote:
 > 
 > > Synopsis: [patch] ppp(8) should be able to set ethernet address for PPPoE
 > >...
 > > http://www.freebsd.org/cgi/query-pr.cgi?pr=114081
 > 
 > I have more complete patches since 2004 in my private tree for exactly
 > the same DTAG reason;-)
 
 :-) Unfortunately I did not find them before. I believe we need in offical FreeBSD documention 
 a link list to users patch directories. ;-)  
 
 > The very early versions are still around here:
 >  	http://sources.zabbadoz.net/freebsd/patchset/
 > 10005-10008* I think. But they are highly outdated.
 > 
 > I can upload newer versions somewhen the next days.
 
 Fine. Do you believe, that this functionality can go into FreeBSD sources? 
 
 > BTW: are you putting your NIC into promisc mode using ifconfig? I
 > cannot see how you would receive the packets for a different MAC else?
 
 Hm, interesting question. *I* did not bring the NIC into promisc mode, but it seems to be. For 
 PPPoE I use a vlan interface, and parent and sibling are marked PROMISC. I don't know, 
 where it comes from: dhcpd, rtadvd, ...?  
 
 Conclusions?
 1. My patch may not work, because it may require PROMISC mode. I will test this.
 2. Should we create a patch for mpd? (See discussion on freebsd-net).
 
 Thanks for your answer. Regards,
    Frank
 -- 
 Frank Behrens, Osterwieck, Germany
 PGP-key 0x5B7C47ED on public servers available.
 
Responsible-Changed-From-To: freebsd-net->bz 
Responsible-Changed-By: bz 
Responsible-Changed-When: Sun Jul 1 13:15:01 UTC 2007 
Responsible-Changed-Why:  
Take this one as I have had more related patches for years. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=114081 

From: "Bjoern A. Zeeb" <bzeeb+freebsd@zabbadoz.net>
To: bug-followup@FreeBSD.org, frank@pinky.sax.de
Cc:  
Subject: Re: bin/114081: [patch] ppp(8) should be able to set ethernet address
 for PPPoE
Date: Mon, 2 Jul 2007 17:15:33 +0000 (UTC)

 I uploaded my patches to
    http://sources.zabbadoz.net/freebsd/patchset/multi-mac-pppoe/
 some of them might need review or examples.
 
 * patch-20061003-01-ng-ether-promiscmode.diff
    renames the promic mode variable name in ng_ether.
 
 * patch-20061003-02-ng-ether-promisc.diff
    adds another hook to if_ethersubr.c/ng_ether that supports
    promisc mode (incl. man page update).
 
 * patch-20061003-03-ng-pppoe-acmac.diff
    Adds a command to ng_pppoe to report the MAC of the peer
    to user space.
 
 * patch-20061003-04-ng-pppoe-nondflt.diff
    Make sure that only non default MAC address is reported
    to ng_ether if set.
 
 * patch-20061003-05-ng-pppoe-CSCsd13298.diff
    Is a special hack that is needed to work around the named
    Cisco bug (see also http://sources.zabbadoz.net/ipv6/CSCsd13298/ )
 
 * patch-20061003-06-ppp-ifunit.diff
    Lets you sepcify the tun<N> unit number in ppp.conf
    (useful with multiple sessions to always get the same tun for the
     same session)
 
 * patch-20061003-07-ppp-CSCsd13298.diff
    Adds a command to enable patch-20061003-05-ng-pppoe-CSCsd13298
    kernel logic.
 
 * patch-20061003-08-ppp-acinfo.diff
    Teaches ppp to understand and log the "ACINFO" from
    patch-20061003-03-ng-pppoe-acmac.
 
 * patch-20061004-01-ppp-enaddr.diff
    Adds command set pppoe-enaddr xx:xx:xx:xx:xx:xx
    to set MAC address for the connection
    (you need to do it for all connections from the very first
     if you want to enable it for one or more)
 
 * patch-20061008-01-ppp-setendaddr-path.diff
    Fix previous patch: simplify logic and use correct path to node.
 
 And I'll soon add another one:
 
 * patch-20070702-01-etc-rcd-ppp.diff
    Make it possible to start multiple ppps from startup script
    configured in rc.conf.
 
    Instead of ppp_profile="..." you give:
      ppp_profiles="foo bar baz"
    you can then overwrite defaults per profile with
      ppp_mode_foo=".."
      ppp_nat_foo="..."
    If no _<profilename> is given the defaults are taken.
    I have to check I did not break single profile support
    for people who only set ppp_profile="..."
 
State-Changed-From-To: open->suspended 
State-Changed-By: bz 
State-Changed-When: Tue Nov 17 21:30:31 UTC 2009 
State-Changed-Why:  
The patches presented need to be updated and re-worked, 
so that they are acceptable for inclusion in the base system. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=114081 
Responsible-Changed-From-To: bz->gnn 
Responsible-Changed-By: bz 
Responsible-Changed-When: Sun May 18 05:04:00 UTC 2014 
Responsible-Changed-Why:  
I shall not use bugzilla (at least until we will have a CLI). 

http://www.freebsd.org/cgi/query-pr.cgi?pr=114081 
>Unformatted:
