source: trunk/package/ppp/patches/320-custom_iface_names.patch @ 21283

Last change on this file since 21283 was 21283, checked in by jow, 6 years ago

[package] ppp:

  • patch pppd to support named interfaces (e.g. "pppoe-wan")
  • use named interfaces when bringing up 3g, pptp, ppp or pppoe connections
  • get rid of unit count logic
  • shutdown pppd when ifdown is invoked
  • bump package revision
File size: 4.0 KB
  • pppd/main.c

    a b void 
    742742set_ifunit(iskey) 
    743743    int iskey; 
    744744{ 
    745     info("Using interface %s%d", PPP_DRV_NAME, ifunit); 
    746     slprintf(ifname, sizeof(ifname), "%s%d", PPP_DRV_NAME, ifunit); 
     745    if (use_ifname[0] == 0) 
     746        slprintf(ifname, sizeof(ifname), "%s%d", PPP_DRV_NAME, ifunit); 
     747    else 
     748        slprintf(ifname, sizeof(ifname), "%s", use_ifname); 
     749    info("Using interface %s", ifname); 
    747750    script_setenv("IFNAME", ifname, iskey); 
    748751    if (iskey) { 
    749752        create_pidfile(getpid());       /* write pid to file */ 
  • pppd/options.c

    a b int log_to_fd = 1; /* send log messages 
    111111bool    log_default = 1;        /* log_to_fd is default (stdout) */ 
    112112int     maxfail = 10;           /* max # of unsuccessful connection attempts */ 
    113113char    linkname[MAXPATHLEN];   /* logical name for link */ 
     114char    use_ifname[IFNAMSIZ];   /* physical name for PPP link */ 
    114115bool    tune_kernel;            /* may alter kernel settings */ 
    115116int     connect_delay = 1000;   /* wait this many ms after connect script */ 
    116117int     req_unit = -1;          /* requested interface unit */ 
    option_t general_options[] = { 
    264265    { "linkname", o_string, linkname, 
    265266      "Set logical name for link", 
    266267      OPT_PRIO | OPT_PRIV | OPT_STATIC, NULL, MAXPATHLEN }, 
     268    { "ifname", o_string, use_ifname, 
     269      "Set physical name for PPP interface", 
     270      OPT_PRIO | OPT_PRIV | OPT_STATIC, NULL, IFNAMSIZ }, 
    267271 
    268272    { "maxfail", o_int, &maxfail, 
    269273      "Maximum number of unsuccessful connection attempts to allow", 
  • pppd/pppd.h

    a b  
    7171#include "eui64.h" 
    7272#endif 
    7373 
     74#ifndef IFNAMSIZ 
     75#define IFNAMSIZ        16 
     76#endif 
     77 
    7478/* 
    7579 * Limits. 
    7680 */ 
    extern char *record_file; /* File to rec 
    308312extern bool     sync_serial;    /* Device is synchronous serial device */ 
    309313extern int      maxfail;        /* Max # of unsuccessful connection attempts */ 
    310314extern char     linkname[MAXPATHLEN]; /* logical name for link */ 
     315extern char     use_ifname[IFNAMSIZ]; /* physical name for PPP interface */ 
    311316extern bool     tune_kernel;    /* May alter kernel settings as necessary */ 
    312317extern int      connect_delay;  /* Time to delay after connect script */ 
    313318extern int      max_data_rate;  /* max bytes/sec through charshunt */ 
  • pppd/sys-linux.c

    a b struct in6_ifreq { 
    168168/* We can get an EIO error on an ioctl if the modem has hung up */ 
    169169#define ok_error(num) ((num)==EIO) 
    170170 
     171#if !defined(PPP_DRV_NAME) 
     172#define PPP_DRV_NAME    "ppp" 
     173#endif /* !defined(PPP_DRV_NAME) */ 
     174 
    171175static int tty_disc = N_TTY;    /* The TTY discipline */ 
    172176static int ppp_disc = N_PPP;    /* The PPP discpline */ 
    173177static int initfdflags = -1;    /* Initial file descriptor flags for fd */ 
    void generic_disestablish_ppp(int dev_fd 
    622626 */ 
    623627static int make_ppp_unit() 
    624628{ 
    625         int x, flags; 
     629        struct ifreq ifr; 
     630        int x, flags, s; 
    626631 
    627632        if (ppp_dev_fd >= 0) { 
    628633                dbglog("in make_ppp_unit, already had /dev/ppp open?"); 
    static int make_ppp_unit() 
    645650        } 
    646651        if (x < 0) 
    647652                error("Couldn't create new ppp unit: %m"); 
     653 
     654        if (use_ifname[0] != 0) { 
     655                s = socket(PF_INET, SOCK_DGRAM, 0); 
     656                if (s < 0) 
     657                        s = socket(PF_PACKET, SOCK_DGRAM, 0); 
     658                if (s < 0) 
     659                        s = socket(PF_INET6, SOCK_DGRAM, 0); 
     660                if (s < 0) 
     661                        s = socket(PF_UNIX, SOCK_DGRAM, 0); 
     662                if (s >= 0) { 
     663                        slprintf(ifr.ifr_name, sizeof(ifr.ifr_name), "%s%d", PPP_DRV_NAME, ifunit); 
     664                        slprintf(ifr.ifr_newname, sizeof(ifr.ifr_newname), "%s", use_ifname); 
     665                        x = ioctl(s, SIOCSIFNAME, &ifr); 
     666                        close(s); 
     667                } else { 
     668                        x = s; 
     669                } 
     670                if (x < 0) { 
     671                        error("Couldn't rename %s to %s", ifr.ifr_name, ifr.ifr_newname); 
     672                        close(ppp_dev_fd); 
     673                        ppp_dev_fd = -1; 
     674                } else { 
     675                        info("Renamed %s to %s", ifr.ifr_name, ifr.ifr_newname); 
     676                } 
     677        } 
     678 
    648679        return x; 
    649680} 
    650681 
  • pppstats/pppstats.c

    a b main(argc, argv) 
    506506    if (argc > 0) 
    507507        interface = argv[0]; 
    508508 
     509/* 
    509510    if (sscanf(interface, PPP_DRV_NAME "%d", &unit) != 1) { 
    510511        fprintf(stderr, "%s: invalid interface '%s' specified\n", 
    511512                progname, interface); 
    512513    } 
     514*/ 
    513515 
    514516#ifndef STREAMS 
    515517    { 
Note: See TracBrowser for help on using the repository browser.