* Re: getting the device of the ppp connection
2009-11-13 13:54 getting the device of the ppp connection Mark Ryden
@ 2009-11-13 14:01 ` Charlie Brady
2009-11-13 15:00 ` walter harms
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Charlie Brady @ 2009-11-13 14:01 UTC (permalink / raw)
To: linux-ppp
On Fri, 13 Nov 2009, Mark Ryden wrote:
> What I mean is this: I have eth0 - eth3 on a machine, and a ppp
> connection. I want to know by a
> short program which device is the one which the ppp connection is
> using (I know that usually this can
> be deduced by running "ps" for the corresponding ppp daemon, and
> inspecting the parameters; for example, with pppoe, I have "-I eth1"
> parameter (-I stands for interface). But I want a more general
> way which can be used in cases when we cannot get this info).
I would do this via an environment variable that you set via your start
script:
PPPOE_DEVICE=eth1 pppoe .... -I eth1
Have a look at daemontools or runit for mechanisms to give you good
reliable control of the execution environment of long-running processes.
---
Charlie
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: getting the device of the ppp connection
2009-11-13 13:54 getting the device of the ppp connection Mark Ryden
2009-11-13 14:01 ` Charlie Brady
@ 2009-11-13 15:00 ` walter harms
2009-11-13 16:34 ` James Carlson
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: walter harms @ 2009-11-13 15:00 UTC (permalink / raw)
To: linux-ppp
Charlie Brady schrieb:
>
> On Fri, 13 Nov 2009, Mark Ryden wrote:
>
>> What I mean is this: I have eth0 - eth3 on a machine, and a ppp
>> connection. I want to know by a
>> short program which device is the one which the ppp connection is
>> using (I know that usually this can
>> be deduced by running "ps" for the corresponding ppp daemon, and
>> inspecting the parameters; for example, with pppoe, I have "-I eth1"
>> parameter (-I stands for interface). But I want a more general
>> way which can be used in cases when we cannot get this info).
>
> I would do this via an environment variable that you set via your start
> script:
>
> PPPOE_DEVICE=eth1 pppoe .... -I eth1
>
> Have a look at daemontools or runit for mechanisms to give you good
> reliable control of the execution environment of long-running processes.
>
> ---
you can scan the output of ifconfig -a,
but normaly pppd setups a ppp0.
re,
wh
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: getting the device of the ppp connection
2009-11-13 13:54 getting the device of the ppp connection Mark Ryden
2009-11-13 14:01 ` Charlie Brady
2009-11-13 15:00 ` walter harms
@ 2009-11-13 16:34 ` James Carlson
2009-11-13 16:42 ` Charlie Brady
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: James Carlson @ 2009-11-13 16:34 UTC (permalink / raw)
To: linux-ppp
walter harms wrote:
>
> Charlie Brady schrieb:
>> Have a look at daemontools or runit for mechanisms to give you good
>> reliable control of the execution environment of long-running processes.
>>
>> ---
>
> you can scan the output of ifconfig -a,
> but normaly pppd setups a ppp0.
I think he's actually asking about the device _underneath_ PPP that's in
use, not the "ppp0" network interface that's visible to IP.
For a serial link, that underlying interface is something like "tty0"
(perhaps including information about the number dialed, if it's a modem
or TA link), and for a PPPoE session, that's something like "eth0" plus
access server name and server Ethernet address. There are many other
cases, including tunneled connections (L2TP and the like) and more
exotic media such as PPPoA and Frame Relay where the underlying
mechanism may have multiple forms of addressing. In fact, it may have
multiple layers of information to dig through. (SNMP uses ifstack for
this, I think.)
This is information that's really known only to the dialer involved, and
not to pppd, which 'sees' only a channel for PPP frames. You can hack
around the issue by setting an environment variable to communicate the
information needed, but there's no native support in the current design
for recording this medium-dependent information.
There probably should be something added, and I'm sure something could
be hacked together for a few special cases, but it's likely a
complicated problem to solve _well_.
--
James Carlson 42.703N 71.076W <carlsonj@workingcode.com>
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: getting the device of the ppp connection
2009-11-13 13:54 getting the device of the ppp connection Mark Ryden
` (2 preceding siblings ...)
2009-11-13 16:34 ` James Carlson
@ 2009-11-13 16:42 ` Charlie Brady
2009-11-13 16:54 ` James Carlson
2009-11-14 5:47 ` Paul Mackerras
5 siblings, 0 replies; 7+ messages in thread
From: Charlie Brady @ 2009-11-13 16:42 UTC (permalink / raw)
To: linux-ppp
On Fri, 13 Nov 2009, James Carlson wrote:
> This is information that's really known only to the dialer involved, and
> not to pppd, which 'sees' only a channel for PPP frames. You can hack
> around the issue by setting an environment variable to communicate the
> information needed, but there's no native support in the current design
> for recording this medium-dependent information.
>
> There probably should be something added,
I don't agree. The caller of pppd can provide the information in the
environment. Adding stuff to pppd would just be bloat, and more code
generally means more bugs.
KISS.
> and I'm sure something could be hacked together for a few special cases,
> but it's likely a complicated problem to solve _well_.
Indeed.
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: getting the device of the ppp connection
2009-11-13 13:54 getting the device of the ppp connection Mark Ryden
` (3 preceding siblings ...)
2009-11-13 16:42 ` Charlie Brady
@ 2009-11-13 16:54 ` James Carlson
2009-11-14 5:47 ` Paul Mackerras
5 siblings, 0 replies; 7+ messages in thread
From: James Carlson @ 2009-11-13 16:54 UTC (permalink / raw)
To: linux-ppp
Charlie Brady wrote:
>
> On Fri, 13 Nov 2009, James Carlson wrote:
>
>> This is information that's really known only to the dialer involved, and
>> not to pppd, which 'sees' only a channel for PPP frames. You can hack
>> around the issue by setting an environment variable to communicate the
>> information needed, but there's no native support in the current design
>> for recording this medium-dependent information.
>>
>> There probably should be something added,
>
> I don't agree. The caller of pppd can provide the information in the
> environment. Adding stuff to pppd would just be bloat, and more code
> generally means more bugs.
>
> KISS.
I didn't say it would necessarily need to be something added to pppd.
How to arrange for storing and retrieving that information sounds like a
detailed design decision to me, and might not necessarily involve pppd.
The high level issue is that it should be possible for the user (or the
user's application) to know just the "ppp0" identity and end up knowing
where that interface actually goes.
I think stuffing it into the environment is just a hack. It sort of
works, but there's no standard way to encode the information in a string
format, so how it's done is going to end up varying by vendor or even by
system administrator whim. That's not a great answer for folks trying
to build third party applications. (Such as, say, an SNMP agent
supporting interface stacking ...)
For what it's worth, I agree that pppd probably shouldn't care much
about this.
--
James Carlson 42.703N 71.076W <carlsonj@workingcode.com>
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: getting the device of the ppp connection
2009-11-13 13:54 getting the device of the ppp connection Mark Ryden
` (4 preceding siblings ...)
2009-11-13 16:54 ` James Carlson
@ 2009-11-14 5:47 ` Paul Mackerras
5 siblings, 0 replies; 7+ messages in thread
From: Paul Mackerras @ 2009-11-14 5:47 UTC (permalink / raw)
To: linux-ppp
Mark Ryden writes:
> Is there a way from user space to know which device is the one which
> the ppp connection uses ?
Yes, that information is in the tdb database (/var/run/pppd2.tdb).
As an example, here is the list of records in /var/run/pppd2.tdb for
my gateway machine (IP addresses obscured):
DEVICE=eth0: pppd2480
IPREMOTE=xx.xx.xx.xx: pppd2480
IFNAME=ppp0: pppd2480
pppd2480: ORIG_UID=0;PPPD_PID$83;PPPLOGNAME=root;DEVICE=eth0;LINKNAME=transact;IPLOCAL=yy.yy.yy.yy;IPREMOTE=xx.xx.xx.xx;IFNAME=ppp0
LINKNAME=transact: pppd2480
PPPD_PID$83: pppd2480
That is for one connection.
Below is the source for the little "tdbdump" program that I used to
print the above. It needs to be linked with pppd/tdb.o and
pppd/spinlock.o.
It wouldn't be hard to write a program to use the lookup routines
in pppd/tdb.c and extract the underlying device for a given ppp
interface.
Paul.
#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
#include <fcntl.h>
#include <signal.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <sys/time.h>
#include "tdb.h"
static int print_rec(TDB_CONTEXT *tdb, TDB_DATA key, TDB_DATA dbuf, void *p)
{
printf("%*.*s: %*.*s\n",
(int)key.dsize, (int)key.dsize, key.dptr,
(int)dbuf.dsize, (int)dbuf.dsize, dbuf.dptr);
return 0;
}
main(int ac, char **av)
{
TDB_CONTEXT *tdb;
if (ac != 2) {
fprintf(stderr, "Usage: %s database\n", av[0]);
exit(1);
}
tdb = tdb_open(av[1], 0, 0, O_RDONLY, 0600);
if (tdb = 0) {
perror(av[1]);
exit(1);
}
tdb_traverse(tdb, print_rec, NULL);
exit(0);
}
^ permalink raw reply [flat|nested] 7+ messages in thread