diff options
author | Daniil Baturin <daniil@vyos.io> | 2008-12-19 18:00:15 -0800 |
---|---|---|
committer | Daniil Baturin <daniil@baturin.org> | 2020-11-08 19:57:12 +0700 |
commit | 31db94f4f74809b687ef25e369b449b02964c6f8 (patch) | |
tree | 7e67da10571c606e613f5e92ef3440958ac2d69e /pppd | |
parent | a3f379befd11934466271aaca76b2809ae8595d0 (diff) | |
download | ppp-31db94f4f74809b687ef25e369b449b02964c6f8.tar.gz |
Support renaming interfaces from a pre-up script.
This is useful for PPP server operators
who want control over the naming of client interfaces.
Originally implemented by Stephen Hemminger.
Signed-off-by: Daniil Baturin <daniil@baturin.org>
Diffstat (limited to 'pppd')
-rw-r--r-- | pppd/ipcp.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/pppd/ipcp.c b/pppd/ipcp.c index e9738fe..48d7095 100644 --- a/pppd/ipcp.c +++ b/pppd/ipcp.c @@ -55,6 +55,7 @@ #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> +#include <net/if.h> #include "pppd.h" #include "fsm.h" @@ -1788,6 +1789,7 @@ ipcp_up(f) ipcp_options *ho = &ipcp_hisoptions[f->unit]; ipcp_options *go = &ipcp_gotoptions[f->unit]; ipcp_options *wo = &ipcp_wantoptions[f->unit]; + int ifindex; IPCPDEBUG(("ipcp: up")); @@ -1901,9 +1903,18 @@ ipcp_up(f) } #endif + ifindex = if_nametoindex(ifname); + /* run the pre-up script, if any, and wait for it to finish */ ipcp_script(_PATH_IPPREUP, 1); + /* check if preup script renamed the interface */ + if (!if_indextoname(ifindex, ifname)) { + error("Interface index %d failed to get renamed by a pre-up script", ifindex); + ipcp_close(f->unit, "Interface configuration failed"); + return; + } + /* bring the interface up for IP */ if (!sifup(f->unit)) { if (debug) |