From 0466c356084e0b0a6d305ca4acfec625e31355c3 Mon Sep 17 00:00:00 2001 From: Renato Westphal Date: Wed, 29 Nov 2017 16:22:08 -0200 Subject: [PATCH] zebra, ldpd: fix display of pseudowire status MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit In some circumstances zebra and ldpd would display a pseudowire as UP when in reality it's not (example: MTU mismatch between the two ends). Fix this to avoid confusion. Reported-by: ßingen Signed-off-by: Renato Westphal --- ldpd/l2vpn.c | 3 ++- ldpd/lde.c | 9 +++++++-- ldpd/ldpd.h | 1 + zebra/zebra_pw.c | 2 +- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/ldpd/l2vpn.c b/ldpd/l2vpn.c index 9bb378a11c..33c3d713a3 100644 --- a/ldpd/l2vpn.c +++ b/ldpd/l2vpn.c @@ -549,7 +549,8 @@ l2vpn_pw_ctl(pid_t pid) sizeof(pwctl.ifname)); pwctl.pwid = pw->pwid; pwctl.lsr_id = pw->lsr_id; - if (pw->local_status == PW_FORWARDING && + if (pw->enabled && + pw->local_status == PW_FORWARDING && pw->remote_status == PW_FORWARDING) pwctl.status = 1; diff --git a/ldpd/lde.c b/ldpd/lde.c index 519fcd9d11..e68b7bc22a 100644 --- a/ldpd/lde.c +++ b/ldpd/lde.c @@ -773,11 +773,12 @@ lde_send_change_klabel(struct fec_node *fn, struct fec_nh *fnh) sizeof(kr)); break; case FEC_TYPE_PWID: - if (fn->local_label == NO_LABEL || + pw = (struct l2vpn_pw *) fn->data; + if (!pw || fn->local_label == NO_LABEL || fnh->remote_label == NO_LABEL) return; - pw = (struct l2vpn_pw *) fn->data; + pw->enabled = true; pw2zpw(pw, &zpw); zpw.local_label = fn->local_label; zpw.remote_label = fnh->remote_label; @@ -824,6 +825,10 @@ lde_send_delete_klabel(struct fec_node *fn, struct fec_nh *fnh) break; case FEC_TYPE_PWID: pw = (struct l2vpn_pw *) fn->data; + if (!pw) + return; + + pw->enabled = false; pw2zpw(pw, &zpw); zpw.local_label = fn->local_label; zpw.remote_label = fnh->remote_label; diff --git a/ldpd/ldpd.h b/ldpd/ldpd.h index fd7d5c5729..0c3b271f83 100644 --- a/ldpd/ldpd.h +++ b/ldpd/ldpd.h @@ -410,6 +410,7 @@ struct l2vpn_pw { uint32_t pwid; char ifname[IF_NAMESIZE]; unsigned int ifindex; + bool enabled; uint32_t remote_group; uint16_t remote_mtu; uint32_t local_status; diff --git a/zebra/zebra_pw.c b/zebra/zebra_pw.c index 6e221ec486..39c4e3b1a0 100644 --- a/zebra/zebra_pw.c +++ b/zebra/zebra_pw.c @@ -71,7 +71,7 @@ struct zebra_pw *zebra_pw_add(struct zebra_vrf *zvrf, const char *ifname, pw->protocol = protocol; pw->vrf_id = zvrf_id(zvrf); pw->client = client; - pw->status = PW_STATUS_UP; + pw->status = PW_STATUS_DOWN; pw->local_label = MPLS_NO_LABEL; pw->remote_label = MPLS_NO_LABEL; pw->flags = F_PSEUDOWIRE_CWORD; -- 2.39.5