diff --git a/usr.sbin/ppp/bundle.c b/usr.sbin/ppp/bundle.c index c2e659e09575..325f37ba6905 100644 --- a/usr.sbin/ppp/bundle.c +++ b/usr.sbin/ppp/bundle.c @@ -791,7 +791,7 @@ bundle_Create(const char *prefix, int type, int unit) #endif #endif - if (!iface_SetFlags(bundle.iface, IFF_UP)) { + if (!iface_SetFlags(bundle.iface->name, IFF_UP)) { iface_Destroy(bundle.iface); bundle.iface = NULL; close(bundle.dev.fd); @@ -886,7 +886,7 @@ static void bundle_DownInterface(struct bundle *bundle) { route_IfDelete(bundle, 1); - iface_ClearFlags(bundle->iface, IFF_UP); + iface_ClearFlags(bundle->iface->name, IFF_UP); } void diff --git a/usr.sbin/ppp/ether.c b/usr.sbin/ppp/ether.c index e3ab77f430ee..aaa86a567cf4 100644 --- a/usr.sbin/ppp/ether.c +++ b/usr.sbin/ppp/ether.c @@ -34,6 +34,8 @@ #include #include #include +#include +#include #include #include #include @@ -88,6 +90,7 @@ #endif #include "bundle.h" #include "id.h" +#include "iface.h" #include "ether.h" @@ -399,9 +402,12 @@ ether_Create(struct physical *p) struct ng_mesg *resp; const struct hooklist *hlist; const struct nodeinfo *ninfo; - int f; + char *path; + int ifacelen, f; dev = NULL; + path = NULL; + ifacelen = 0; if (p->fd < 0 && !strncasecmp(p->name.full, NG_PPPOE_NODE_TYPE, PPPOE_NODE_TYPE_LEN) && p->name.full[PPPOE_NODE_TYPE_LEN] == ':') { @@ -410,8 +416,8 @@ ether_Create(struct physical *p) struct ngm_mkpeer mkp; struct ngm_connect ngc; const char *iface, *provider; - char *path, etherid[12]; - int ifacelen, providerlen; + char etherid[12]; + int providerlen; char connectpath[sizeof dev->hook + 2]; /* .: */ p->fd--; /* We own the device - change fd */ @@ -674,6 +680,15 @@ ether_Create(struct physical *p) p->dl->bundle->cfg.mtu = 1492; } + if (path != NULL) { + /* Mark the interface as UP if it's not already */ + + path[ifacelen] = '\0'; /* Remove the trailing ':' */ + if (!iface_SetFlags(path, IFF_UP)) + log_Printf(LogWARN, "%s: Failed to set the IFF_UP flag on %s\n", + p->link.name, path); + } + return &dev->dev; } diff --git a/usr.sbin/ppp/iface.c b/usr.sbin/ppp/iface.c index 67d2631818b0..c64ad5a10762 100644 --- a/usr.sbin/ppp/iface.c +++ b/usr.sbin/ppp/iface.c @@ -420,7 +420,7 @@ iface_inDelete(struct iface *iface, struct in_addr ip) #define IFACE_DELFLAGS 2 static int -iface_ChangeFlags(struct iface *iface, int flags, int how) +iface_ChangeFlags(const char *ifname, int flags, int how) { struct ifreq ifrq; int s; @@ -432,7 +432,7 @@ iface_ChangeFlags(struct iface *iface, int flags, int how) } memset(&ifrq, '\0', sizeof ifrq); - strncpy(ifrq.ifr_name, iface->name, sizeof ifrq.ifr_name - 1); + strncpy(ifrq.ifr_name, ifname, sizeof ifrq.ifr_name - 1); ifrq.ifr_name[sizeof ifrq.ifr_name - 1] = '\0'; if (ID0ioctl(s, SIOCGIFFLAGS, &ifrq) < 0) { log_Printf(LogERROR, "iface_ChangeFlags: ioctl(SIOCGIFFLAGS): %s\n", @@ -458,15 +458,15 @@ iface_ChangeFlags(struct iface *iface, int flags, int how) } int -iface_SetFlags(struct iface *iface, int flags) +iface_SetFlags(const char *ifname, int flags) { - return iface_ChangeFlags(iface, flags, IFACE_ADDFLAGS); + return iface_ChangeFlags(ifname, flags, IFACE_ADDFLAGS); } int -iface_ClearFlags(struct iface *iface, int flags) +iface_ClearFlags(const char *ifname, int flags) { - return iface_ChangeFlags(iface, flags, IFACE_DELFLAGS); + return iface_ChangeFlags(ifname, flags, IFACE_DELFLAGS); } void diff --git a/usr.sbin/ppp/iface.h b/usr.sbin/ppp/iface.h index f22883b2fa63..6de1b50684b5 100644 --- a/usr.sbin/ppp/iface.h +++ b/usr.sbin/ppp/iface.h @@ -59,7 +59,7 @@ extern int iface_inAdd(struct iface *, struct in_addr, struct in_addr, struct in_addr, int); extern int iface_inDelete(struct iface *, struct in_addr); extern int iface_Show(struct cmdargs const *); -extern int iface_SetFlags(struct iface *, int); -extern int iface_ClearFlags(struct iface *, int); +extern int iface_SetFlags(const char *, int); +extern int iface_ClearFlags(const char *, int); extern void iface_Destroy(struct iface *); extern void iface_ParseHdr(struct ifa_msghdr *, struct sockaddr *[RTAX_MAX]);