]> git.proxmox.com Git - mirror_frr.git/blobdiff - ldpd/l2vpn.c
Merge pull request #12798 from donaldsharp/rib_match_multicast
[mirror_frr.git] / ldpd / l2vpn.c
index b234e3ebe34f1ba3f78c8de03fd957fca911a031..4664b1f894a81a7d0dc4c7443930b6a299ea573d 100644 (file)
@@ -1,3 +1,4 @@
+// SPDX-License-Identifier: ISC
 /*     $OpenBSD$ */
 
 /*
@@ -5,18 +6,6 @@
  * Copyright (c) 2009 Michele Marchetto <michele@openbsd.org>
  * Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org>
  * Copyright (c) 2004, 2005, 2008 Esben Norby <norby@openbsd.org>
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
 #include <zebra.h>
@@ -294,6 +283,16 @@ l2vpn_pw_reset(struct l2vpn_pw *pw)
                pw->flags |= F_PW_STATUSTLV;
        else
                pw->flags &= ~F_PW_STATUSTLV;
+
+       if (pw->flags & F_PW_STATUSTLV_CONF) {
+               struct fec_node         *fn;
+               struct fec fec;
+               l2vpn_pw_fec(pw, &fec);
+               fn = (struct fec_node *)fec_find(&ft, &fec);
+               if (fn)
+                       pw->remote_status = fn->pw_remote_status;
+       }
+
 }
 
 int
@@ -303,6 +302,7 @@ l2vpn_pw_ok(struct l2vpn_pw *pw, struct fec_nh *fnh)
        if (fnh->remote_label == NO_LABEL) {
                log_warnx("%s: pseudowire %s: no remote label", __func__,
                          pw->ifname);
+               pw->reason = F_PW_NO_REMOTE_LABEL;
                return (0);
        }
 
@@ -310,6 +310,7 @@ l2vpn_pw_ok(struct l2vpn_pw *pw, struct fec_nh *fnh)
        if (pw->l2vpn->mtu != pw->remote_mtu) {
                log_warnx("%s: pseudowire %s: MTU mismatch detected", __func__,
                          pw->ifname);
+               pw->reason = F_PW_MTU_MISMATCH;
                return (0);
        }
 
@@ -318,9 +319,11 @@ l2vpn_pw_ok(struct l2vpn_pw *pw, struct fec_nh *fnh)
            pw->remote_status != PW_FORWARDING) {
                log_warnx("%s: pseudowire %s: remote end is down", __func__,
                          pw->ifname);
+               pw->reason = F_PW_REMOTE_NOT_FWD;
                return (0);
        }
 
+       pw->reason = F_PW_NO_ERR;
        return (1);
 }
 
@@ -429,6 +432,8 @@ l2vpn_recv_pw_status(struct lde_nbr *ln, struct notify_msg *nm)
                /* unknown fec */
                return;
 
+       fn->pw_remote_status = nm->pw_status;
+
        pw = (struct l2vpn_pw *) fn->data;
        if (pw == NULL)
                return;
@@ -517,10 +522,13 @@ l2vpn_pw_status_update(struct zapi_pw_status *zpw)
                return (1);
        }
 
-       if (zpw->status == PW_STATUS_UP)
+       if (zpw->status == PW_FORWARDING) {
                local_status = PW_FORWARDING;
-       else
-               local_status = PW_NOT_FORWARDING;
+               pw->reason = F_PW_NO_ERR;
+       } else {
+               local_status = zpw->status;
+               pw->reason = F_PW_LOCAL_NOT_FWD;
+       }
 
        /* local status didn't change */
        if (pw->local_status == local_status)
@@ -564,10 +572,11 @@ l2vpn_pw_ctl(pid_t pid)
                            sizeof(pwctl.ifname));
                        pwctl.pwid = pw->pwid;
                        pwctl.lsr_id = pw->lsr_id;
+                       pwctl.status = PW_NOT_FORWARDING;
                        if (pw->enabled &&
                            pw->local_status == PW_FORWARDING &&
                            pw->remote_status == PW_FORWARDING)
-                               pwctl.status = 1;
+                               pwctl.status = PW_FORWARDING;
 
                        lde_imsg_compose_ldpe(IMSG_CTL_SHOW_L2VPN_PW, 0,
                            pid, &pwctl, sizeof(pwctl));
@@ -604,6 +613,7 @@ l2vpn_binding_ctl(pid_t pid)
                        pwctl.local_ifmtu = pw->l2vpn->mtu;
                        pwctl.local_cword = (pw->flags & F_PW_CWORD_CONF) ?
                            1 : 0;
+                       pwctl.reason = pw->reason;
                } else
                        pwctl.local_label = NO_LABEL;