Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 445582 - Name ppp devices arbitrarily
Summary: Name ppp devices arbitrarily
Status: CONFIRMED
Alias: None
Product: Gentoo Hosted Projects
Classification: Unclassified
Component: netifrc (show other bugs)
Hardware: All Linux
: Normal enhancement (vote)
Assignee: netifrc Team
URL:
Whiteboard: netifrc:pppd
Keywords:
Depends on:
Blocks:
 
Reported: 2012-12-02 09:05 UTC by Stuart Longland (RETIRED)
Modified: 2023-10-13 14:10 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Stuart Longland (RETIRED) gentoo-dev 2012-12-02 09:05:45 UTC
Hi,

I've been just thinking about this problem at work.  We have a number of ppp links; namely our ADSL service (PPPoE), a 3G link (PPP link to /dev/ttyACM0) and temporary dial-up links to either the Internet, or to various customer sites.

It is important that any link be easily identifiable.  The problem with having them named pppN; is that one cannot easily tell which is which.  For most of us, there is only one ppp link, but if we start adding PPP links, it eventually gets to a point when one cannot easily tell them apart.  This was one of the reasons we have /etc/udev/rules.d/70-persistent-net.rules — a very handy feature!

pppd doesn't provide an option for setting what the ppp device will be called; but a parameter could be passed in the `ipparam` part of the pppd options, which is then passed to /etc/ppp/ip-up as parameter 6.

One can then add the following code to the start:

if [ -n "${6}" ]; then
    /sbin/ip link set ${1} down && /sbin/ip link set ${1} name ${6} && /sbin/ip link set ${6} up && set -- ${6} ${2} ${3} ${4} ${5} ${6}
fi

The problem is convincing OpenRC to use pppd, as it expects the link to be called pppN.  I therefore propose the following...

We support a configuration type called "ppp".  The /etc/init.d/net.LINKNAME looks for a parameter called config_LINKNAME; and magic currently assumes that if LINKNAME matches the regex ^ppp\d+$, then config_LINKNAME="ppp".

In cases where LINKNAME does not match this pattern, the user can explicitly configure it like so:

config_LINKNAME="ppp" # Tells OpenRC this is a PPP link
link_LINKNAME="e100"  # PPPoE using ethernet device "e100"
username_LINKNAME="me@isp.net"
password_LINKNAME="password"
pppd_LINKNAME="options"

To the pppd options; the following would be appended:
    ipparam=${LINKNAME}

Aside: it may be handy to have an ipparam_LINKNAME option; which would be appended using a colon, and could be plucked out by the ppp scripts before being handed to the user for transparency.

The kernel will bring the link up calling it pppX; but then the baselayout ppp scripts can pick up the proper name from the LINKNAME parameter, rename the interface as above, then continue processing as normal.

I'm not sure how much work the above is to make it happen in OpenRC; adding lines to /etc/ppp/ip-up already gets most of it working, just that OpenRC still expects the device to be called pppX when pppd returns.
Comment 1 Stuart Longland (RETIRED) gentoo-dev 2012-12-02 09:19:01 UTC
Just noticed this:

http://ppp.samba.org/cgi-bin/ppp-bugs/incoming?id=1840;expression=rename;user=guest

which renames the ppp device to the parameter given as the `linkname`.
Comment 2 Robin Johnson archtester Gentoo Infrastructure gentoo-dev Security 2013-08-28 17:22:32 UTC
I think we need to see if that patch you linked is merged upstream yet.
Comment 3 Ian Stakenvicius (RETIRED) gentoo-dev 2013-08-28 17:43:30 UTC
(In reply to Robin Johnson from comment #2)
> I think we need to see if that patch you linked is merged upstream yet.

it's not in latest ppp stable (2.4.5-r3)
Comment 4 Jaco Kroon 2023-10-13 14:10:05 UTC
From man page for pppd (2.5.0):

       linkname name
              Sets the logical name of  the  link  to  name.   Pppd  will  create  a  file  named
              ppp-name.pid  in  /var/run (or /etc/ppp on some systems) containing its process ID.
              This can be useful in determining which instance of pppd  is  responsible  for  the
              link to a given peer system.  This is a privileged option.

It should also be from 2.5.1 onwards be possible to rename interfaces from net-pre-up script based on arbitrary criteria.  Just not sure how that would integrate with netifrc, we don't have a specific need for this.