From nobody@FreeBSD.org  Mon Jul 15 13:10:00 2002
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 5902E37B405
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 15 Jul 2002 13:09:59 -0700 (PDT)
Received: from www.freebsd.org (www.FreeBSD.org [216.136.204.117])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 0CC7243E64
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 15 Jul 2002 13:09:59 -0700 (PDT)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.12.4/8.12.4) with ESMTP id g6FK9sOT078200
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 15 Jul 2002 13:09:54 -0700 (PDT)
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.12.4/8.12.4/Submit) id g6FK9sVd078199;
	Mon, 15 Jul 2002 13:09:54 -0700 (PDT)
Message-Id: <200207152009.g6FK9sVd078199@www.freebsd.org>
Date: Mon, 15 Jul 2002 13:09:54 -0700 (PDT)
From: Masanori Takeishi <marina@yaya.forks.co.jp>
To: freebsd-gnats-submit@FreeBSD.org
Subject: /usr/sbin/ppp is not able to bind the natd(8) -alias_address option.
X-Send-Pr-Version: www-1.0

>Number:         40617
>Category:       bin
>Synopsis:       /usr/sbin/ppp is not able to bind the natd(8) -alias_address option.
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    brian
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Mon Jul 15 13:10:01 PDT 2002
>Closed-Date:    Mon Dec 13 18:29:50 GMT 2004
>Last-Modified:  Mon Dec 13 18:29:50 GMT 2004
>Originator:     Masanori Takeishi
>Release:        FreeBSD 4.6-STABLE
>Organization:
Forks Inc.
>Environment:
FreeBSD **.***.jp 4.6-STABLE FreeBSD 4.6-STABLE #0: Mon Jul 15 02:21:45
 JST 2002     marina@**.***.jp:/usr/obj/usr/src/sys/IX  i386
      
>Description:
When several providers is make unnumberd PPPoE conect the allocation address for a network address.
if Allocation area is x.x.x.0/28
My Side: IP = x.x.x.0 !! too BAD!! 
>How-To-Repeat:
Present condition becomes so

>Fix:
/usr/sbin/ppp is able to bind the natd(8) -alias_address option.

sample ppp.conf:
+ nat alias x.x.x.1

patch:
diff -urN ppp.org/command.c ppp/command.c
--- ppp.org/command.c   Sat Jun  8 15:37:48 2002
+++ ppp/command.c       Sat Jun  8 15:30:32 2002
@@ -641,6 +641,8 @@
    (const void *) PKT_ALIAS_SAME_PORTS},
   {"target", NULL, nat_SetTarget, LOCAL_AUTH,
    "Default address for incoming connections", "nat target addr" },
+  {"alias", NULL, nat_SetAlias, LOCAL_AUTH,
+   "Use addr as the aliasing address", "nat alias addr" },
   {"unregistered_only", NULL, NatOption, LOCAL_AUTH,
    "translate unregistered (private) IP address space only",
    "nat unregistered_only yes|no",
@@ -2371,6 +2373,8 @@
   return 0;
 }

+extern struct in_addr alias_address_addr;
+
 #ifndef NONAT
 static int
 NatEnable(struct cmdargs const *arg)
@@ -2378,8 +2382,12 @@
   if (arg->argc == arg->argn+1) {
     if (strcasecmp(arg->argv[arg->argn], "yes") == 0) {
       if (!arg->bundle->NatEnabled) {
-        if (arg->bundle->ncp.ipcp.fsm.state == ST_OPENED)
-          PacketAliasSetAddress(arg->bundle->ncp.ipcp.my_ip);
+        if (arg->bundle->ncp.ipcp.fsm.state == ST_OPENED){
+          if (alias_address_addr.s_addr == INADDR_NONE || alias_address_addr.s_
addr == 0)
+            PacketAliasSetAddress(arg->bundle->ncp.ipcp.my_ip);
+         else
+            PacketAliasSetAddress(alias_address_addr);
+        }
         arg->bundle->NatEnabled = 1;
       }
       return 0;
diff -urN ppp.org/ipcp.c ppp/ipcp.c
--- ppp.org/ipcp.c      Sat Jun  8 15:37:48 2002
+++ ppp/ipcp.c  Sat Jun  8 15:30:32 2002
@@ -991,6 +991,8 @@
   recursing--;
 }

+extern struct in_addr alias_address_addr;
+
 int
 ipcp_InterfaceUp(struct ipcp *ipcp)
 {
@@ -1006,8 +1008,12 @@
   }

 #ifndef NONAT
-  if (ipcp->fsm.bundle->NatEnabled)
-    PacketAliasSetAddress(ipcp->my_ip);
+  if (ipcp->fsm.bundle->NatEnabled) {
+    if (alias_address_addr.s_addr == INADDR_NONE || alias_address_addr.s_addr =
= 0)
+      PacketAliasSetAddress(ipcp->my_ip);
+    else
+      PacketAliasSetAddress(alias_address_addr);
+  }
 #endif

   return 1;
diff -urN ppp.org/nat_cmd.c ppp/nat_cmd.c
--- ppp.org/nat_cmd.c   Sat Jun  8 15:37:49 2002
+++ ppp/nat_cmd.c       Sat Jun  8 16:43:01 2002
@@ -435,6 +435,30 @@
   return 0;
 }

+struct in_addr alias_address_addr;
+
+int
+nat_SetAlias(struct cmdargs const *arg)
+{
+  if (arg->argc != arg->argn + 1)
+    return -1;
+
+  if (!strcasecmp(arg->argv[arg->argn], "MYADDR")) {
+    alias_address_addr.s_addr = INADDR_ANY;
+    PacketAliasSetAddress(alias_address_addr);
+    return 0;
+  }
+
+  alias_address_addr = GetIpAddr(arg->argv[arg->argn]);
+  if (alias_address_addr.s_addr == INADDR_NONE) {
+    log_Printf(LogWARN, "%s: invalid address\n", arg->argv[arg->argn]);
+    return 1;
+  }
+
+  PacketAliasSetAddress(alias_address_addr);
+  return 0;
+}
+
 static struct mbuf *
 nat_LayerPush(struct bundle *bundle, struct link *l, struct mbuf *bp,
                 int pri, u_short *proto)
diff -urN ppp.org/nat_cmd.h ppp/nat_cmd.h
--- ppp.org/nat_cmd.h   Sat Jun  8 15:37:49 2002
+++ ppp/nat_cmd.h       Sat Jun  8 13:58:20 2002
@@ -34,5 +34,6 @@
 extern int nat_RedirectProto(struct cmdargs const *);
 extern int nat_ProxyRule(struct cmdargs const *);
 extern int nat_SetTarget(struct cmdargs const *);
+extern int nat_SetAlias(struct cmdargs const *);

 extern struct layer natlayer;

>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->brian 
Responsible-Changed-By: matusita 
Responsible-Changed-When: Mon Jul 15 15:44:01 PDT 2002 
Responsible-Changed-Why:  
I believe that brian actively maintains our ppp(8).  Brian, would you 
please take care of this PR?  This patch may help lots of Japanese 
users who subscribe NTT's flets service (ISDN/ADSL/Optical). 

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

From: Makoto Matsushita <matusita@jp.FreeBSD.org>
To: brian@FreeBSD.org
Cc: bug-followup@FreeBSD.org
Subject: Re: bin/40617: /usr/sbin/ppp is not able to bind the natd(8)
 -alias_address option.
Date: Tue, 16 Jul 2002 14:43:45 +0900

 brian> I'm not sure I understand the problem.  What is meant by an
 brian> unnumbered PPPoE connection ?
 
 In this situation, a subscriber has assigned a static IPv4 address
 block.  Imagine the block is a.b.c.0/28, and a subscriber uses FreeBSD
 box for a router.  The router has an internal private network, and
 FreeBSD box also provides NAT facility for that network.
 
 Please note that when a subscriber makes an uplink to ISP (via PPPoE
 for example), ISP assigns "a.b.c.0" IPv4 address for subscriber's side
 of point-to-point network.  I've heard that the address is passwd by
 IPCP type3 packet, not IPCP type0 packet.  This is by design of this
 service, and there are no other choices.
 
 After the connection was established, most of connections from a.b.c.X
 (where 0 < X < 15) is OK.  However, a connection from the private
 network is NATed to the connection from a.b.c.0, in the viewpoint of
 external networks.  It should cause zero problem, but the life is not
 easy; a subscriber meets troubles that they can't connect to some
 websites (or services available in the Internet).
 
 If the source address of NATed packet can be changed to something
 other than a.b.c.0, a subscriber is happy.  In natd(8), this feature
 is available by the option '-alias_address'.  The PR submitter want to
 implement exactly the same feature to ppp(8).
 
 brian> Perhaps rather than ``nat alias 1.2.3.1'' we just need ``set
 brian> ifaddr 1.2.3.1'' ?
 
 Sorry I don't know it works or not.  Takeishi-san, would you please
 explain your situations also, and try 'set ifaddr a.b.c.1' works or not?
 
 -- -
 Makoto `MAR' Matsushita

From: Masanori Takeishi <marina@yaya.forks.co.jp>
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/40617: /usr/sbin/ppp is not able to bind the
 =?ISO-2022-JP?B?bmF0ZCg4KRskQiEhGyhCLWFsaWFzX2FkZA==?=
 =?ISO-2022-JP?B?cmVzcw==?= option.
Date: Fri, 19 Jul 2002 16:13:35 +0900

 I tried it.
 " set ifaddr a.b.c.1/32 10.0.0.1/0 255.255.255.248 a.b.c.1"
 
 but, connect src ip address is "a.b.c.0"
 -----------------------------------------------------
 Masanori Takeishi,  E-Mail: marina@yaya.forks.co.jp
 

From: Masanori Takeishi <marina@yaya.forks.co.jp>
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/40617: /usr/sbin/ppp is not able to bind the
 =?ISO-2022-JP?B?bmF0ZCg4KRskQiEhGyhCLWFsaWFzX2FkZA==?=
 =?ISO-2022-JP?B?cmVzcw==?= option.
Date: Fri, 19 Jul 2002 11:28:43 +0900

 I tried it.
 " set ifaddr a.b.c.1/32 10.0.0.1/0 255.255.255.248 a.b.c.1"
 
 but, connect src ip address is "a.b.c.0"
 -----------------------------------------------------
 Masanori Takeishi,  E-Mail: marina@yaya.forks.co.jp
 

From: Masanori Takeishi <marina@yaya.forks.co.jp>
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/40617: /usr/sbin/ppp is not able to bind the
 =?ISO-2022-JP?B?bmF0ZCg4KRskQiEhGyhCLWFsaWFzX2FkZA==?=
 =?ISO-2022-JP?B?cmVzcw==?= option.
Date: Wed, 28 Aug 2002 19:39:35 +0900

 I entered into real practical use and not able to test.
 There is the problem that ppp is not able to pass a fragment packet and this one.
 I use router unit.
 I apologize for not be cooperate.
 -----------------------------------------------------
 Masanori Takeishi,  E-Mail: marina @yaya.forks.co.jp
 
State-Changed-From-To: open->feedback 
State-Changed-By: brian 
State-Changed-When: Tue Jun 29 12:53:14 GMT 2004 
State-Changed-Why:  
Requesting information from anybody that still has a connection with this ISP 

http://www.freebsd.org/cgi/query-pr.cgi?pr=40617 
State-Changed-From-To: feedback->closed 
State-Changed-By: brian 
State-Changed-When: Mon Dec 13 18:28:23 GMT 2004 
State-Changed-Why:  
Feedback timeout 

http://www.freebsd.org/cgi/query-pr.cgi?pr=40617 
>Unformatted:
 If anybody still has a connection with this ISP, could they send me a
 copy of the IPCP conversation at connection time (``set log +ipcp'') ?

 If there's any way of identifying this situation, it would be easy to
 handle.  I'm loathe to add the ability to use an IP address that was
 never negotiated...
