Bug 104623

Summary: "rc.d/ppp restart" stops all instances of ppp
Product: Base System Reporter: Nicolas Rachinsky <freebsd-pr>
Component: binAssignee: emax
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: 6.2-PRERELEASE   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
ppp.diff
none
rcd-ppp-patch none

Description Nicolas Rachinsky 2006-10-20 19:30:18 UTC
"rc.d/ppp restart" stops all running instances of ppp, but restarts only
the one configured in rc.conf.

Fix: 

Don't know how to fix this. If the tun device is known, the pid file could
be used. But without that, it seems hard to find the right one.
How-To-Repeat: Start multiple instances of ppp (e.g. one for your dsl line and another
with pptpclient to use a pptp tunnel). Now do "rc.d/ppp restart" while both
are running. After it completes, only one of them is running.
Comment 1 Mark Linimon freebsd_committer freebsd_triage 2006-10-21 18:23:55 UTC
Responsible Changed
From-To: freebsd-bugs->freebsd-rc

Over to maintainer(s).
Comment 2 Mike Makonnen freebsd_committer freebsd_triage 2007-03-31 11:49:59 UTC
Can you try the attached patch?
It allows you to specify the ppp instance to control by specifying
the tunnel device name as an addtional argument:
 # /etc/rc.d/ppp restart tun0

Cheers.
-- 
Mike Makonnen          | GPG-KEY: http://people.freebsd.org/~mtm/mtm.asc
mmakonnen_at_gmail.com | AC7B 5672 2D11 F4D0 EBF8  5279 5359 2B82 7CD4 1F55
mtm_at_FreeBSD.Org     | FreeBSD - http://www.freebsd.org
Comment 3 Nicolas Rachinsky 2007-03-31 12:49:00 UTC
* Mike Makonnen <mtm@FreeBSD.Org> [2007-03-31 13:49 +0300]:
> +# usage: /etc/rc.d/ppp <cmd> [tunX]

I haven't yet tried it, but I see one problem. AFAIK there is no
mechanism to start more than one ppp with the current rc.d/ppp script
via rc.conf. Thus I can't imagine how this can work if I do this with
a tun device that does correspond to the ppp started via rc.d/ppp.

And it will still terminate processes that are unrelated to the pp
started via rc.d/ppp if it is used without the additional parameter.

So I don't think, this can fix the real problem, that there is no way
to identify the ppp instance that were started via rc.d/ppp. At least
I see no such way.

Do I miss something?

Nicolas
Comment 4 Mike Makonnen freebsd_committer freebsd_triage 2007-03-31 13:22:01 UTC
State Changed
From-To: open->feedback

I'll look into this. 
Patch has been worked up and awaiting response from 
Originator. 


Comment 5 Mike Makonnen freebsd_committer freebsd_triage 2007-03-31 13:22:01 UTC
Responsible Changed
From-To: freebsd-rc->mtm

I'll look into this. 
Patch has been worked up and awaiting response from 
Originator.
Comment 6 Mike Makonnen freebsd_committer freebsd_triage 2007-03-31 13:46:10 UTC
On Sat, Mar 31, 2007 at 01:49:00PM +0200, Nicolas Rachinsky wrote:
> * Mike Makonnen <mtm@FreeBSD.Org> [2007-03-31 13:49 +0300]:
> > +# usage: /etc/rc.d/ppp <cmd> [tunX]
> 
> I haven't yet tried it, but I see one problem. AFAIK there is no
> mechanism to start more than one ppp with the current rc.d/ppp script
> via rc.conf. Thus I can't imagine how this can work if I do this with
> a tun device that does correspond to the ppp started via rc.d/ppp.

Whether you can start more than one ppp with rc.d/ppp is immaterial.
That's an issue for another PR(1) :-)
If you start more than one ppp (however you started them), the patch gives
you the option of stoping/restarting them selectively using rc.d/ppp
by specifying the tunnel device. So, if you want to stop the ppp daemon
associated with tun1, for example, without affecting tun0 you can
now do that.

> 
> And it will still terminate processes that are unrelated to the pp
> started via rc.d/ppp if it is used without the additional parameter.
> 
> So I don't think, this can fix the real problem, that there is no way
> to identify the ppp instance that were started via rc.d/ppp. At least
> I see no such way.

Sorry, I should have included an explanation with the patch.

As you say there's no easy or straight-forward way to determine
which ppp was started with rc.d/ppp. The patch was a compromise to
allow an admin to selectively stop/restart a ppp instance without
terminating all others. Also, arguably, running rc.d/ppp stop
without additional arguments *should* terminate *all* ppp instances.

Cheers.
-- 
Mike Makonnen          | GPG-KEY: http://people.freebsd.org/~mtm/mtm.asc
mmakonnen_at_gmail.com | AC7B 5672 2D11 F4D0 EBF8  5279 5359 2B82 7CD4 1F55
mtm_at_FreeBSD.Org     | FreeBSD - http://www.freebsd.org
Comment 7 Nicolas Rachinsky 2007-03-31 14:04:03 UTC
* Mike Makonnen <mtm@FreeBSD.Org> [2007-03-31 15:46 +0300]:
> If you start more than one ppp (however you started them), the patch gives
> you the option of stoping/restarting them selectively using rc.d/ppp
> by specifying the tunnel device. So, if you want to stop the ppp daemon
> associated with tun1, for example, without affecting tun0 you can
> now do that.

Stopping does work, restarting not, it tries to start the ppp that is
started by rc.d/ppp. Restarting the one started by rc.d/ppp does work.

> As you say there's no easy or straight-forward way to determine
> which ppp was started with rc.d/ppp. The patch was a compromise to
> allow an admin to selectively stop/restart a ppp instance without
> terminating all others. Also, arguably, running rc.d/ppp stop
> without additional arguments *should* terminate *all* ppp instances.

I can not agree with the last sentence. "rc.d/ppp stop" should stop
everything started by "rc.d/ppp start" and nothing else. I think it is
a POLA violation if "rc.d/ppp stop" stops every instance of ppp, even
instances started by other users!

Nicolas
Comment 8 Mike Makonnen freebsd_committer freebsd_triage 2007-10-20 00:34:35 UTC
I think the following commit should fix this issue. It starts/stops based on
the ppp profile. I've attached a patch relative to RELENG_6 to make
it easier for you to try.

----- Forwarded message from Maksim Yevmenkin <emax@FreeBSD.org> -----

Date: Thu, 18 Oct 2007 17:10:40 +0000 (UTC)
To: src-committers@FreeBSD.org, cvs-src@FreeBSD.org, cvs-all@FreeBSD.org
From: Maksim Yevmenkin <emax@FreeBSD.org>
Subject: cvs commit: src/etc/rc.d ppp
Authentication-Results: mx.google.com; spf=pass (google.com: domain of owner-src-committers@freebsd.org designates 69.147.83.53 as permitted sender) smtp.mail=owner-src-committers@freebsd.org

emax        2007-10-18 17:10:40 UTC

  FreeBSD src repository

  Modified files:
    etc/rc.d             ppp 
  Log:
  Teach /etc/rc.d/ppp how to start/stop individual instances
  of ppp. This is an extension of previous commit.
  
  Submitted by:   Yuri Kurenkov < y dot kurenkov at init dot ru >
  Reviewed by:    mtm
  MFC after:      3 days
  
  Revision  Changes    Path
  1.15      +36 -3     src/etc/rc.d/ppp

----- End forwarded message -----

Cheers.
-- 
Mike Makonnen         | GPG-KEY: http://people.freebsd.org/~mtm/mtm.asc
mmakonnen @ gmail.com | AC7B 5672 2D11 F4D0 EBF8  5279 5359 2B82 7CD4 1F55
mtm @ FreeBSD.Org     | FreeBSD - http://www.freebsd.org
Comment 9 Mike Makonnen freebsd_committer freebsd_triage 2007-10-20 01:17:33 UTC
Sorry, I forgot to attach the patch :(
-- 
Mike Makonnen         | GPG-KEY: http://people.freebsd.org/~mtm/mtm.asc
mmakonnen @ gmail.com | AC7B 5672 2D11 F4D0 EBF8  5279 5359 2B82 7CD4 1F55
mtm @ FreeBSD.Org     | FreeBSD - http://www.freebsd.org
Comment 10 Mark Linimon freebsd_committer freebsd_triage 2008-03-02 06:04:36 UTC
State Changed
From-To: feedback->patched

emax committed a patch that should address this, but it has not been 
MFCed to 6 yet. 


Comment 11 Mark Linimon freebsd_committer freebsd_triage 2008-03-02 06:04:36 UTC
Responsible Changed
From-To: mtm->emax
Comment 12 emax freebsd_committer freebsd_triage 2008-03-04 17:22:09 UTC
State Changed
From-To: patched->closed

the patch was MFC'ed to RELENG_6. for whatever reason it does not show up 
in cvsweb.