Bug 72402

Summary: PPPoE issues with net/mpd
Product: Ports & Packages Reporter: Oleg Sharoiko <os>
Component: Individual Port(s)Assignee: Archie Cobbs <archie>
Status: Closed FIXED    
Severity: Affects Only Me CC: and
Priority: Normal    
Version: Latest   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
mpd-pppoe.diff none

Description Oleg Sharoiko 2004-10-06 21:30:23 UTC
	mpd fails to establish pppoe connection.

	mpd.conf
	----------
pppoe-aaanet-orig:
        new -i ng0 pppoe-aaanet-orig pppoe-fxp0-orig
        set bundle authname "authname"
        set bundle password "password"
        set bundle enable compression

        set link keep-alive 15 30
        set link disable pap chap
        set link accept pap chap
        set link enable acfcomp protocomp
        set link enable no-orig-auth

        set ccp enable mppc mpp-compress mpp-e40 mpp-e56 mpp-e128
        set ecp enable des

        set ipcp enable vjcomp
        set ipcp no req-pri-dns req-sec-dns req-pri-nbns req-sec-nbns

        set iface route default

        open iface
	--------

	mpd.links
	--------
pppoe-fxp0-orig:
        set link type pppoe
        set pppoe iface fxp0
        set pppoe disable incoming
        set pppoe enable originate

	--------

	log
	--------
Oct  6 22:26:36 wolf mpd: mpd: pid 507, version 3.18 (root@wolf.os.rsu.ru 20:32  5-Oct-2004)
Oct  6 22:26:36 wolf mpd: [pppoe-aaanet-orig] ppp node is "mpd507-pppoe-aaanet-orig"
Oct  6 22:26:36 wolf mpd: [pppoe-aaanet-orig] using interface ng0
Oct  6 22:26:36 wolf mpd: [pppoe-aaanet-orig] IFACE: Open event
Oct  6 22:26:36 wolf mpd: [pppoe-aaanet-orig] IPCP: Open event
Oct  6 22:26:36 wolf mpd: [pppoe-aaanet-orig] IPCP: state change Initial --> Starting
Oct  6 22:26:36 wolf mpd: [pppoe-aaanet-orig] IPCP: LayerStart
Oct  6 22:26:36 wolf mpd: [pppoe-aaanet-orig] bundle: OPEN event in state CLOSED
Oct  6 22:26:36 wolf mpd: [pppoe-aaanet-orig] opening link "pppoe-fxp0-orig"...
Oct  6 22:26:36 wolf mpd: [pppoe-fxp0-orig] link: OPEN event
Oct  6 22:26:36 wolf mpd: [pppoe-fxp0-orig] LCP: Open event
Oct  6 22:26:36 wolf mpd: [pppoe-fxp0-orig] LCP: state change Initial --> Starting
Oct  6 22:26:36 wolf mpd: [pppoe-fxp0-orig] LCP: LayerStart
Oct  6 22:26:36 wolf mpd: [pppoe-fxp0-orig] device: OPEN event in state DOWN
Oct  6 22:26:36 wolf mpd: [pppoe-aaanet-orig] can't connect bypass,link0 and fxp0:orphans,mpd507-pppoe-fxp0-orig: No such file or directory
Oct  6 22:26:36 wolf mpd: [pppoe-aaanet-orig] can't remove hook mpd507-pppoe-fxp0-orig from node "fxp0:orphans": No such file or directory
Oct  6 22:26:36 wolf mpd: [pppoe-fxp0-orig] device is now in state OPENING
Oct  6 22:26:36 wolf mpd: [pppoe-fxp0-orig] device: DOWN event in state OPENING
Oct  6 22:26:36 wolf mpd: [pppoe-fxp0-orig] device is now in state DOWN
Oct  6 22:26:36 wolf mpd: [pppoe-fxp0-orig] link: DOWN event
Oct  6 22:26:36 wolf mpd: [pppoe-fxp0-orig] LCP: Down event
Oct  6 22:26:36 wolf mpd: [pppoe-fxp0-orig] device: OPEN event in state DOWN
Oct  6 22:26:36 wolf mpd: [pppoe-fxp0-orig] pausing 6 seconds before open
Oct  6 22:26:36 wolf mpd: [pppoe-fxp0-orig] device is now in state DOWN
	--------

	This looks very similar to ports/62477.
	If mpd started after ppp with pppoe setup then mpd works fine.
	Executing

        /sbin/ifconfig fxp0 up
        /usr/sbin/ngctl mkpeer fxp0: pppoe orphans ethernet

	before mpd also make mpd happy.

	It looks like
	1) mpd doesn't put interface into UP state and
	2) mpd fails to create netgraph hook

Fix: 

Workaround:

	Execute

        /sbin/ifconfig fxp0 up
        /usr/sbin/ngctl mkpeer fxp0: pppoe orphans ethernet

	before running mpd.

	The following startup script will help starting mpd in such a situations:

	---------
#!/bin/sh

# PROVIDE: mpd
# REQUIRE: netif isdnd
# KEYWORD: FreeBSD nojail shutdown

. /etc/rc.subr

name="mpd"
rcvar=`set_rcvar`

mpd_start_precmd()
{
	/sbin/ifconfig fxp0 up
	/usr/sbin/ngctl mkpeer fxp0: pppoe orphans ethernet || true
}

mpd_stop_postcmd()
{
	/usr/sbin/ngctl rmhook fxp0: orphans
}

load_rc_config $name

start_precmd="mpd_start_precmd"
stop_postcmd="mpd_stop_postcmd"

command=${mpd_program:-"/usr/local/sbin/mpd"}
pidfile=${mpd_pidfile:-"/var/run/mpd.pid"}
flags=${mpd_flags:-"-b -p ${pidfile} ${mpd_profile}"}

run_rc_command "$1"
	---------

	It would be nice to switch mpd to rcNG startup script. This one can be used after this issues have been resolved and workarounds (mpd_start_precmd/mpd_stop_precmd) removed.
How-To-Repeat: 
	Reboot a system
	Run mpd with pppoe setup
Comment 1 Sergei Kolobov freebsd_committer freebsd_triage 2004-10-07 07:33:06 UTC
Responsible Changed
From-To: freebsd-ports-bugs->archie

Over to maintainer.
Comment 2 Gleb Smirnoff 2004-10-28 14:01:26 UTC
  Oleg,

  I believe, the problem is related to long bundle and link
names. Node names are constructed from bundle name, 
and netgraph truncates them, so mpd is sending messages
to nonexistent nodes.

Can you try shorten bundle name to "pppoe", and link name
to "pppoe" and reproduce the problem?

-- 
Totus tuus, Glebius.
GLEBIUS-RIPN GLEB-RIPE
Comment 3 Oleg Sharoiko 2004-10-28 17:20:20 UTC
Hello!

On Thu, 28 Oct 2004, Gleb Smirnoff wrote:

GS>Can you try shorten bundle name to "pppoe", and link name
GS>to "pppoe" and reproduce the problem?

Shortening names doesn't help:

[pppoe] device: OPEN event in state DOWN
[pppoe] can't connect bypass,link0 and fxp0:orphans,mpd545-pppoe: No such file or directory
[pppoe] can't remove hook mpd545-pppoe from node "fxp0:orphans": No such file or directory

I was expecting this result as I can load necessary node "by hand" and it 
works with long names. So I conclude that the problem is not in looking up 
names but in loading or creating nodes.

I currentlyu use (as a workaround)

/usr/sbin/ngctl mkpeer fxp0: pppoe orphans ethernet

If I start mpd after running this command mpd works fine. Both with short and 
long names.

p.s. And I still need to 'ifconfig up' the interface before running mpd. No 
matter short or long names I use.

I'm ready to help debugging this problem.

-- 
Oleg Sharoiko.
Software and Network Engineer
Computer Center of Rostov State University.
Comment 4 Archie Cobbs 2004-10-28 18:12:13 UTC
Oleg Sharoiko wrote:
>  GS>Can you try shorten bundle name to "pppoe", and link name
>  GS>to "pppoe" and reproduce the problem?
>  
>  Shortening names doesn't help:
>  
>  [pppoe] device: OPEN event in state DOWN
>  [pppoe] can't connect bypass,link0 and fxp0:orphans,mpd545-pppoe: No such file or directory
>  [pppoe] can't remove hook mpd545-pppoe from node "fxp0:orphans": No such file or directory
>  
>  I was expecting this result as I can load necessary node "by hand" and it 
>  works with long names. So I conclude that the problem is not in looking up 
>  names but in loading or creating nodes.
>  
>  I currentlyu use (as a workaround)
>  
>  /usr/sbin/ngctl mkpeer fxp0: pppoe orphans ethernet
>  
>  If I start mpd after running this command mpd works fine. Both with short and 
>  long names.
>  
>  p.s. And I still need to 'ifconfig up' the interface before running mpd. No 
>  matter short or long names I use.
>  
>  I'm ready to help debugging this problem.

I would try reverting, one by one in this order, revisions 1.9, 1.8,
1.7, 1.6, 1.5, and 1.4 of pppoe.c until the problem goes away...
hopefully it will..  and then let us know the result...

  http://cvs.sourceforge.net/viewcvs.py/mpd/mpd/src/pppoe.c?rev=1.13&view=log

-Archie

__________________________________________________________________________
Archie Cobbs      *        CTO, Awarix        *      http://www.awarix.com
Comment 5 Oleg Sharoiko 2004-10-31 15:54:46 UTC
On Thu, 28 Oct 2004, Archie Cobbs wrote:

AC>I would try reverting, one by one in this order, revisions 1.9, 1.8,
AC>1.7, 1.6, 1.5, and 1.4 of pppoe.c until the problem goes away...
AC>hopefully it will..  and then let us know the result...

It looks like I've resolved this issue. I happened to run into two problems:

1. I had no set pppoe service "" line in my mpd.links. This resulted in mpd 
skipping my link in PppoeNodeUpdate() :

  for (k = 0; k < gNumLinks; k++) {
    if (gLinks[k] && gLinks[k]->phys->type == &gPppoePhysType
      && strcmp(((PppoeInfo)(gLinks[k]->phys->info))->path,"undefined:")
      && strcmp(((PppoeInfo)(gLinks[k]->phys->info))->session,"undefined")) {
// Skip
 }

Well, documentation says empty string is the default. But the code says 
default is "undefined", which effectively disables the link. This is 
confusing, isn't it?

2. I had no ng_ether loaded. My fault. Docs say I should. I expected mpd to 
load it - it would be really nice and user-friendly. Would it be hard to 
implemet autoloading of ng_ether module?

-- 
Oleg Sharoiko.
Software and Network Engineer
Computer Center of Rostov State University.
Comment 6 Gleb Smirnoff freebsd_committer freebsd_triage 2004-10-31 17:58:33 UTC
On Sun, Oct 31, 2004 at 06:54:46PM +0300, Oleg Sharoiko wrote:
O> AC>I would try reverting, one by one in this order, revisions 1.9, 1.8,
O> AC>1.7, 1.6, 1.5, and 1.4 of pppoe.c until the problem goes away...
O> AC>hopefully it will..  and then let us know the result...
O> 
O> It looks like I've resolved this issue. I happened to run into two problems:
O> 
O> 1. I had no set pppoe service "" line in my mpd.links. This resulted in mpd 
O> skipping my link in PppoeNodeUpdate() :
O> 
O>   for (k = 0; k < gNumLinks; k++) {
O>     if (gLinks[k] && gLinks[k]->phys->type == &gPppoePhysType
O>       && strcmp(((PppoeInfo)(gLinks[k]->phys->info))->path,"undefined:")
O>       && strcmp(((PppoeInfo)(gLinks[k]->phys->info))->session,"undefined")) {
O> // Skip
O>  }
O> 
O> Well, documentation says empty string is the default. But the code says 
O> default is "undefined", which effectively disables the link. This is 
O> confusing, isn't it?

I suppose default service must be "*", and no "set pppoe service" line
should be needed. Archie, Alexander?

O> 2. I had no ng_ether loaded. My fault. Docs say I should. I expected mpd to 
O> load it - it would be really nice and user-friendly. Would it be hard to 
O> implemet autoloading of ng_ether module?

Oleg is not a first person complaining about this. I think autoloading
of ng_ether should be added.

-- 
Totus tuus, Glebius.
GLEBIUS-RIPN GLEB-RIPE
Comment 7 Oleg Sharoiko 2004-11-07 18:53:14 UTC
Hello!

Please consider attached patch. I'd be happy if you review it.
It's against version 3.18 and supposed to fix both issues: 
 - pppoe service is set to * by default, and service name "undefined" is not 
treated as illegal anymore.
 - CreatePppoeNode() checks for NG_ETHER_NODE_TYPE and tries to 
kldload("ng_ether") if it's not available.

It works fine for me so far. Any comments are welcome and appreciated.
The patch is against mpd itself, not against net/mpd direcory in ports.

On Sun, 31 Oct 2004, Gleb Smirnoff wrote:

GS>On Sun, Oct 31, 2004 at 06:54:46PM +0300, Oleg Sharoiko wrote:
GS>O> AC>I would try reverting, one by one in this order, revisions 1.9, 1.8,
GS>O> AC>1.7, 1.6, 1.5, and 1.4 of pppoe.c until the problem goes away...
GS>O> AC>hopefully it will..  and then let us know the result...
GS>O> 
GS>O> It looks like I've resolved this issue. I happened to run into two problems:
GS>O> 
GS>O> 1. I had no set pppoe service "" line in my mpd.links. This resulted in mpd 
GS>O> skipping my link in PppoeNodeUpdate() :
GS>O> 
GS>O>   for (k = 0; k < gNumLinks; k++) {
GS>O>     if (gLinks[k] && gLinks[k]->phys->type == &gPppoePhysType
GS>O>       && strcmp(((PppoeInfo)(gLinks[k]->phys->info))->path,"undefined:")
GS>O>       && strcmp(((PppoeInfo)(gLinks[k]->phys->info))->session,"undefined")) {
GS>O> // Skip
GS>O>  }
GS>O> 
GS>O> Well, documentation says empty string is the default. But the code says 
GS>O> default is "undefined", which effectively disables the link. This is 
GS>O> confusing, isn't it?
GS>
GS>I suppose default service must be "*", and no "set pppoe service" line
GS>should be needed. Archie, Alexander?
GS>
GS>O> 2. I had no ng_ether loaded. My fault. Docs say I should. I expected mpd to 
GS>O> load it - it would be really nice and user-friendly. Would it be hard to 
GS>O> implemet autoloading of ng_ether module?
GS>
GS>Oleg is not a first person complaining about this. I think autoloading
GS>of ng_ether should be added.
GS>
GS>

-- 
Oleg Sharoiko.
Software and Network Engineer
Computer Center of Rostov State University.
Comment 8 Archie Cobbs 2004-11-07 20:12:20 UTC
Oleg Sharoiko wrote:
> Please consider attached patch. I'd be happy if you review it.

Committed, with a minor fix.

Thanks!

-Archie

__________________________________________________________________________
Archie Cobbs      *        CTO, Awarix        *      http://www.awarix.com
Comment 9 Archie Cobbs freebsd_committer freebsd_triage 2004-11-07 20:12:34 UTC
State Changed
From-To: open->closed

Patch committed.
Comment 10 Alexander Motin 2004-11-07 23:04:41 UTC
Oleg Sharoiko wrote:
> Please consider attached patch. I'd be happy if you review it.
> It's against version 3.18 and supposed to fix both issues: 
>  - pppoe service is set to * by default, and service name "undefined" is not 
> treated as illegal anymore.

It is not so unquestionable. For incoming connections it really can be 
"*" as default, but for outgoing it's more correct to use empty ("") 
service.

> It works fine for me so far. Any comments are welcome and appreciated.

-- 
Alexander Motin mav@alkar.net
ISP "Alkar-Teleport"
Comment 11 Oleg Sharoiko 2004-11-08 13:44:56 UTC
Hello!

On Mon, 8 Nov 2004, Alexander Motin wrote:

AM>> It's against version 3.18 and supposed to fix both issues:  - pppoe service
AM>> is set to * by default, and service name "undefined" is not treated as
AM>> illegal anymore.
AM>It is not so unquestionable. For incoming connections it really can be "*" as
AM>default, but for outgoing it's more correct to use empty ("") service.

I'd say it's not for me to decide. I just implemented what Gleb has suggested 
and it's anyway better than it was before. In fact changing default from "*" 
into "" is quite easy so you as the developers of mpd can now decide what is 
the right thing. If you ask me - well, I would probably vote for "", but it 
works for me either ways so I don't object against "*". By the way, default of 
"*" should be reflected in documentation (it now says that default is "").

-- 
Oleg Sharoiko.
Software and Network Engineer
Computer Center of Rostov State University.