summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr.sbin/ldpd/kroute.c37
-rw-r--r--usr.sbin/ldpd/ldpd.h3
-rw-r--r--usr.sbin/ldpd/parse.y5
3 files changed, 35 insertions, 10 deletions
diff --git a/usr.sbin/ldpd/kroute.c b/usr.sbin/ldpd/kroute.c
index f04e3de8638..afc1f8f4dd3 100644
--- a/usr.sbin/ldpd/kroute.c
+++ b/usr.sbin/ldpd/kroute.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kroute.c,v 1.68 2019/01/22 09:25:29 krw Exp $ */
+/* $OpenBSD: kroute.c,v 1.69 2019/01/23 08:43:45 dlg Exp $ */
/*
* Copyright (c) 2015, 2016 Renato Westphal <renato@openbsd.org>
@@ -141,6 +141,12 @@ kif_init(void)
if (fetchifs() == -1)
return (-1);
+ if ((kr_state.ioctl_fd = socket(AF_INET,
+ SOCK_DGRAM | SOCK_CLOEXEC | SOCK_NONBLOCK, 0)) == -1) {
+ log_warn("%s: ioctl socket", __func__);
+ return (-1);
+ }
+
return (0);
}
@@ -198,12 +204,6 @@ kr_init(int fs, unsigned int rdomain)
kr_dispatch_msg, NULL);
event_add(&kr_state.ev, NULL);
- if ((kr_state.ioctl_fd = socket(AF_INET,
- SOCK_DGRAM | SOCK_CLOEXEC | SOCK_NONBLOCK, 0)) == -1) {
- log_warn("%s: ioctl socket", __func__);
- return (-1);
- }
-
return (0);
}
@@ -1860,3 +1860,26 @@ kmpw_uninstall(const char *ifname)
return (0);
}
+
+int
+kmpw_find(const char *ifname)
+{
+ struct ifreq ifr;
+
+ memset(&ifr, 0, sizeof(ifr));
+ if (strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)) >=
+ sizeof(ifr.ifr_name)) {
+ errno = ENAMETOOLONG;
+ return (-1);
+ }
+
+ if (ioctl(kr_state.ioctl_fd, SIOCGPWE3, &ifr) == -1)
+ return (-1);
+
+ if (ifr.ifr_pwe3 != IF_PWE3_ETHERNET) {
+ errno = EPFNOSUPPORT;
+ return (-1);
+ }
+
+ return (0);
+}
diff --git a/usr.sbin/ldpd/ldpd.h b/usr.sbin/ldpd/ldpd.h
index 6d2f15c29e0..468161a3e87 100644
--- a/usr.sbin/ldpd/ldpd.h
+++ b/usr.sbin/ldpd/ldpd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ldpd.h,v 1.89 2019/01/23 02:02:04 dlg Exp $ */
+/* $OpenBSD: ldpd.h,v 1.90 2019/01/23 08:43:45 dlg Exp $ */
/*
* Copyright (c) 2013, 2016 Renato Westphal <renato@openbsd.org>
@@ -569,6 +569,7 @@ struct kif *kif_findname(char *);
void kif_clear(void);
int kmpw_set(struct kpw *);
int kmpw_unset(struct kpw *);
+int kmpw_find(const char *);
/* util.c */
uint8_t mask2prefixlen(in_addr_t);
diff --git a/usr.sbin/ldpd/parse.y b/usr.sbin/ldpd/parse.y
index 1d56b8980ae..733703a4d99 100644
--- a/usr.sbin/ldpd/parse.y
+++ b/usr.sbin/ldpd/parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.y,v 1.69 2019/01/23 03:35:14 dlg Exp $ */
+/* $OpenBSD: parse.y,v 1.70 2019/01/23 08:43:45 dlg Exp $ */
/*
* Copyright (c) 2013, 2015, 2016 Renato Westphal <renato@openbsd.org>
@@ -615,7 +615,8 @@ pseudowire : PSEUDOWIRE STRING {
}
free($2);
- if (kif->if_type != IFT_MPLSTUNNEL) {
+ if (kif->if_type != IFT_MPLSTUNNEL &&
+ kmpw_find(kif->ifname) == -1) {
yyerror("unsupported interface type on "
"interface %s", kif->ifname);
YYERROR;