summaryrefslogtreecommitdiff
path: root/usr.sbin/ppp
diff options
context:
space:
mode:
authorbrian <brian@cvs.openbsd.org>2001-03-28 09:52:57 +0000
committerbrian <brian@cvs.openbsd.org>2001-03-28 09:52:57 +0000
commitf7770c2424cbcd302cb2b5dc1276ddbdc24fa8f0 (patch)
treed874eb923787dc33e76cb7336424d5fa9a8462d1 /usr.sbin/ppp
parente84f8dd4dbe4b26b7bd3fc8b02651f15fef3444f (diff)
Bring the netgraph PPPoE interface UP if required (only applies to FreeBSD)
Diffstat (limited to 'usr.sbin/ppp')
-rw-r--r--usr.sbin/ppp/ppp/bundle.c6
-rw-r--r--usr.sbin/ppp/ppp/ether.c23
-rw-r--r--usr.sbin/ppp/ppp/iface.c14
-rw-r--r--usr.sbin/ppp/ppp/iface.h6
4 files changed, 32 insertions, 17 deletions
diff --git a/usr.sbin/ppp/ppp/bundle.c b/usr.sbin/ppp/ppp/bundle.c
index c00c8fc3498..c703e7a487b 100644
--- a/usr.sbin/ppp/ppp/bundle.c
+++ b/usr.sbin/ppp/ppp/bundle.c
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $OpenBSD: bundle.c,v 1.54 2001/03/24 01:05:58 brian Exp $
+ * $OpenBSD: bundle.c,v 1.55 2001/03/28 09:52:54 brian Exp $
*/
#include <sys/param.h>
@@ -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/ppp/ether.c b/usr.sbin/ppp/ppp/ether.c
index 34f832c3f38..0de2b7afe18 100644
--- a/usr.sbin/ppp/ppp/ether.c
+++ b/usr.sbin/ppp/ppp/ether.c
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $OpenBSD: ether.c,v 1.8 2001/03/24 01:05:59 brian Exp $
+ * $OpenBSD: ether.c,v 1.9 2001/03/28 09:52:54 brian Exp $
*/
#include <sys/param.h>
@@ -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;
}
diff --git a/usr.sbin/ppp/ppp/iface.c b/usr.sbin/ppp/ppp/iface.c
index 86bcfea1aff..55a992608cf 100644
--- a/usr.sbin/ppp/ppp/iface.c
+++ b/usr.sbin/ppp/ppp/iface.c
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $OpenBSD: iface.c,v 1.13 2001/03/25 01:38:13 brian Exp $
+ * $OpenBSD: iface.c,v 1.14 2001/03/28 09:52:56 brian Exp $
*/
#include <sys/param.h>
@@ -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/ppp/iface.h b/usr.sbin/ppp/ppp/iface.h
index dcf0268f495..16b2e55f8bf 100644
--- a/usr.sbin/ppp/ppp/iface.h
+++ b/usr.sbin/ppp/ppp/iface.h
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $OpenBSD: iface.h,v 1.5 2000/02/27 01:38:26 brian Exp $
+ * $OpenBSD: iface.h,v 1.6 2001/03/28 09:52:56 brian Exp $
*/
struct ifa_msghdr;
@@ -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]);