summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorRenato Westphal <renato@cvs.openbsd.org>2016-06-18 01:33:03 +0000
committerRenato Westphal <renato@cvs.openbsd.org>2016-06-18 01:33:03 +0000
commit078b8590f2ecfd93f4d427ea96a820167a438d00 (patch)
treee96cb54a41a3b82cb186bc0753b241bfa1158324 /usr.sbin
parentd57a14b1bc6f5b1448ed9cec329e48dbfeeffab2 (diff)
Do not allow configuring the same interface for both LDP and VPLS.
Configuring an interface for both LDP signaling and as a member of a VPLS instance doesn't cause any harm as far as ldpd is concerned. But it certainly doesn't make any sense, so it's better to reject the configuration and warn the user instead of ignoring this silently.
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/ldpd/parse.y50
1 files changed, 30 insertions, 20 deletions
diff --git a/usr.sbin/ldpd/parse.y b/usr.sbin/ldpd/parse.y
index a83c5136a29..d332b9ea7f1 100644
--- a/usr.sbin/ldpd/parse.y
+++ b/usr.sbin/ldpd/parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.y,v 1.54 2016/05/23 19:16:00 renato Exp $ */
+/* $OpenBSD: parse.y,v 1.55 2016/06/18 01:33:02 renato Exp $ */
/*
* Copyright (c) 2013, 2015, 2016 Renato Westphal <renato@openbsd.org>
@@ -607,14 +607,6 @@ l2vpnopts : PWTYPE pw_type {
}
free($2);
- if (kif->if_type == IFT_BRIDGE
- || kif->if_type == IFT_LOOP
- || kif->if_type == IFT_CARP) {
- yyerror("unsupported interface type on "
- "interface %s", kif->ifname);
- YYERROR;
- }
-
lif = conf_get_l2vpn_if(l2vpn, kif);
if (lif == NULL)
YYERROR;
@@ -1286,19 +1278,28 @@ static struct iface *
conf_get_if(struct kif *kif)
{
struct iface *i;
-
- LIST_FOREACH(i, &conf->iface_list, entry)
- if (i->ifindex == kif->ifindex)
- return (i);
+ struct l2vpn *l;
if (kif->if_type == IFT_LOOP ||
kif->if_type == IFT_CARP ||
+ kif->if_type == IFT_BRIDGE ||
kif->if_type == IFT_MPLSTUNNEL) {
yyerror("unsupported interface type on interface %s",
kif->ifname);
return (NULL);
}
+ LIST_FOREACH(l, &conf->l2vpn_list, entry)
+ if (l2vpn_if_find(l, kif->ifindex)) {
+ yyerror("interface %s already configured under "
+ "l2vpn %s", kif->ifname, l->name);
+ return (NULL);
+ }
+
+ LIST_FOREACH(i, &conf->iface_list, entry)
+ if (i->ifindex == kif->ifindex)
+ return (i);
+
i = if_new(kif);
LIST_INSERT_HEAD(&conf->iface_list, i, entry);
return (i);
@@ -1362,6 +1363,22 @@ conf_get_l2vpn_if(struct l2vpn *l, struct kif *kif)
struct l2vpn *ltmp;
struct l2vpn_if *f;
+ if (kif->if_type == IFT_LOOP ||
+ kif->if_type == IFT_CARP ||
+ kif->if_type == IFT_BRIDGE ||
+ kif->if_type == IFT_MPLSTUNNEL) {
+ yyerror("unsupported interface type on interface %s",
+ kif->ifname);
+ return (NULL);
+ }
+
+ LIST_FOREACH(ltmp, &conf->l2vpn_list, entry)
+ if (l2vpn_if_find(ltmp, kif->ifindex)) {
+ yyerror("interface %s already configured under "
+ "l2vpn %s", kif->ifname, ltmp->name);
+ return (NULL);
+ }
+
LIST_FOREACH(i, &conf->iface_list, entry) {
if (i->ifindex == kif->ifindex) {
yyerror("interface %s already configured",
@@ -1370,13 +1387,6 @@ conf_get_l2vpn_if(struct l2vpn *l, struct kif *kif)
}
}
- LIST_FOREACH(ltmp, &conf->l2vpn_list, entry)
- if (l2vpn_if_find(ltmp, kif->ifindex)) {
- yyerror("interface %s is already being "
- "used by l2vpn %s", kif->ifname, ltmp->name);
- return (NULL);
- }
-
f = l2vpn_if_new(l, kif);
LIST_INSERT_HEAD(&l2vpn->if_list, f, entry);
return (f);