Bring the PPPoE interface UP if required

Suggested by: archie
This commit is contained in:
Brian Somers 2001-03-28 09:45:27 +00:00
parent f34fa851e0
commit dc744e1949
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=74916
4 changed files with 28 additions and 13 deletions

View File

@ -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

View File

@ -34,6 +34,8 @@
#include <netdb.h>
#include <netgraph.h>
#include <net/ethernet.h>
#include <net/if.h>
#include <net/route.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
#include <netgraph/ng_ether.h>
@ -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]; /* .:<hook> */
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;
}

View File

@ -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

View File

@ -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]);