summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrenato <renato@openbsd.org>2016-05-23 16:35:37 +0000
committerrenato <renato@openbsd.org>2016-05-23 16:35:37 +0000
commit56dfb329155dadc347158f602a894de58efb5b72 (patch)
tree2c88b2ebbab84b1197fdcb91390e14046685c650
parentMinor adjustments in l2vpn code. (diff)
downloadwireguard-openbsd-56dfb329155dadc347158f602a894de58efb5b72.tar.xz
wireguard-openbsd-56dfb329155dadc347158f602a894de58efb5b72.zip
Do not accept incomplete pseudowires in the configuration.
There's no point on keeping in the config something that can not be used, it just adds unnecessary complexity. Also, it's better to warn the user that there's something wrong rather than play nice and ignore the problem.
-rw-r--r--usr.sbin/ldpd/l2vpn.c14
-rw-r--r--usr.sbin/ldpd/parse.y12
-rw-r--r--usr.sbin/ldpd/printconf.c8
3 files changed, 15 insertions, 19 deletions
diff --git a/usr.sbin/ldpd/l2vpn.c b/usr.sbin/ldpd/l2vpn.c
index 7396e953199..6af68e29f9c 100644
--- a/usr.sbin/ldpd/l2vpn.c
+++ b/usr.sbin/ldpd/l2vpn.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: l2vpn.c,v 1.5 2016/05/23 16:33:32 renato Exp $ */
+/* $OpenBSD: l2vpn.c,v 1.6 2016/05/23 16:35:37 renato Exp $ */
/*
* Copyright (c) 2015 Renato Westphal <renato@openbsd.org>
@@ -160,9 +160,6 @@ l2vpn_pw_init(struct l2vpn_pw *pw)
{
struct fec fec;
- if (pw->pwid == 0 || pw->addr.s_addr == INADDR_ANY)
- return;
-
l2vpn_pw_fec(pw, &fec);
lde_kernel_insert(&fec, pw->addr, 0, (void *)pw);
}
@@ -172,9 +169,6 @@ l2vpn_pw_del(struct l2vpn_pw *pw)
{
struct fec fec;
- if (pw->pwid == 0 || pw->addr.s_addr == INADDR_ANY)
- return;
-
l2vpn_pw_fec(pw, &fec);
lde_kernel_remove(&fec, pw->addr);
free(pw);
@@ -471,9 +465,6 @@ ldpe_l2vpn_pw_init(struct l2vpn_pw *pw)
{
struct tnbr *tnbr;
- if (pw->pwid == 0 || pw->addr.s_addr == INADDR_ANY)
- return;
-
tnbr = tnbr_find(leconf, pw->addr);
if (tnbr->discovery_fd == 0)
tnbr_init(leconf, tnbr);
@@ -484,9 +475,6 @@ ldpe_l2vpn_pw_exit(struct l2vpn_pw *pw)
{
struct tnbr *tnbr;
- if (pw->pwid == 0 || pw->addr.s_addr == INADDR_ANY)
- return;
-
tnbr = tnbr_find(leconf, pw->addr);
if (tnbr) {
tnbr->pw_count--;
diff --git a/usr.sbin/ldpd/parse.y b/usr.sbin/ldpd/parse.y
index fbab8c23f46..a771ab8f46a 100644
--- a/usr.sbin/ldpd/parse.y
+++ b/usr.sbin/ldpd/parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.y,v 1.40 2016/05/23 16:20:59 renato Exp $ */
+/* $OpenBSD: parse.y,v 1.41 2016/05/23 16:35:37 renato Exp $ */
/*
* Copyright (c) 2004, 2005, 2008 Esben Norby <norby@openbsd.org>
@@ -402,6 +402,16 @@ pseudowire : PSEUDOWIRE STRING {
struct l2vpn *l;
struct l2vpn_pw *p;
+ /* check for errors */
+ if (pw->pwid == 0) {
+ yyerror("missing pseudowire id");
+ YYERROR;
+ }
+ if (pw->addr.s_addr == INADDR_ANY) {
+ yyerror("missing pseudowore neighbor");
+ YYERROR;
+ }
+
LIST_FOREACH(l, &conf->l2vpn_list, entry)
LIST_FOREACH(p, &l->pw_list, entry)
if (pw != p &&
diff --git a/usr.sbin/ldpd/printconf.c b/usr.sbin/ldpd/printconf.c
index 51c420168a9..69cc730b55a 100644
--- a/usr.sbin/ldpd/printconf.c
+++ b/usr.sbin/ldpd/printconf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: printconf.c,v 1.16 2016/05/23 16:18:51 renato Exp $ */
+/* $OpenBSD: printconf.c,v 1.17 2016/05/23 16:35:37 renato Exp $ */
/*
* Copyright (c) 2004, 2005, 2008 Esben Norby <norby@openbsd.org>
@@ -109,10 +109,8 @@ void
print_pw(struct l2vpn_pw *pw)
{
printf("\tpseudowire %s {\n", pw->ifname);
- if (pw->addr.s_addr != INADDR_ANY)
- printf("\t\tneighbor %s\n", inet_ntoa(pw->addr));
- if (pw->pwid != 0)
- printf("\t\tpw-id %u\n", pw->pwid);
+ printf("\t\tneighbor %s\n", inet_ntoa(pw->addr));
+ printf("\t\tpw-id %u\n", pw->pwid);
if (pw->flags & F_PW_STATUSTLV_CONF)
printf("\t\tstatus-tlv yes\n");
else