summaryrefslogtreecommitdiff
path: root/usr.sbin/ldpd/parse.y
diff options
context:
space:
mode:
Diffstat (limited to 'usr.sbin/ldpd/parse.y')
-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);