]> git.proxmox.com Git - mirror_frr.git/blobdiff - zebra/zebra_pw.c
*: move CLI parent data to cmd_node->parent_node
[mirror_frr.git] / zebra / zebra_pw.c
index fb9a40fe3d857e8d4325031c6eecff2d1be223ec..1885401287bae6395ad729e089a9ea67ce11cf52 100644 (file)
@@ -27,7 +27,7 @@
 
 #include "zebra/debug.h"
 #include "zebra/rib.h"
-#include "zebra/zserv.h"
+#include "zebra/zebra_router.h"
 #include "zebra/zapi_msg.h"
 #include "zebra/zebra_rnh.h"
 #include "zebra/zebra_vrf.h"
@@ -42,8 +42,6 @@ DEFINE_HOOK(pw_uninstall, (struct zebra_pw * pw), (pw))
 
 #define MPLS_NO_LABEL MPLS_INVALID_LABEL
 
-extern struct zebra_t zebrad;
-
 static int zebra_pw_enabled(struct zebra_pw *);
 static void zebra_pw_install(struct zebra_pw *);
 static void zebra_pw_uninstall(struct zebra_pw *);
@@ -98,9 +96,10 @@ void zebra_pw_del(struct zebra_vrf *zvrf, struct zebra_pw *pw)
        zebra_deregister_rnh_pseudowire(pw->vrf_id, pw);
 
        /* uninstall */
-       if (pw->status == PW_STATUS_UP)
+       if (pw->status == PW_STATUS_UP) {
                hook_call(pw_uninstall, pw);
-       else if (pw->install_retry_timer)
+               dplane_pw_uninstall(pw);
+       } else if (pw->install_retry_timer)
                THREAD_TIMER_OFF(pw->install_retry_timer);
 
        /* unlink and release memory */
@@ -154,6 +153,7 @@ void zebra_pw_update(struct zebra_pw *pw)
 {
        if (zebra_pw_check_reachability(pw) < 0) {
                zebra_pw_uninstall(pw);
+               zebra_pw_install_failure(pw);
                /* wait for NHT and try again later */
        } else {
                /*
@@ -171,7 +171,8 @@ static void zebra_pw_install(struct zebra_pw *pw)
                           pw->vrf_id, pw->ifname,
                           zebra_route_string(pw->protocol));
 
-       if (hook_call(pw_install, pw)) {
+       hook_call(pw_install, pw);
+       if (dplane_pw_install(pw) == ZEBRA_DPLANE_REQUEST_FAILURE) {
                zebra_pw_install_failure(pw);
                return;
        }
@@ -192,6 +193,7 @@ static void zebra_pw_uninstall(struct zebra_pw *pw)
 
        /* ignore any possible error */
        hook_call(pw_uninstall, pw);
+       dplane_pw_uninstall(pw);
 
        if (zebra_pw_enabled(pw))
                zebra_pw_update_status(pw, PW_STATUS_DOWN);
@@ -213,7 +215,7 @@ void zebra_pw_install_failure(struct zebra_pw *pw)
 
        /* schedule to retry later */
        THREAD_TIMER_OFF(pw->install_retry_timer);
-       thread_add_timer(zebrad.master, zebra_pw_install_retry, pw,
+       thread_add_timer(zrouter.master, zebra_pw_install_retry, pw,
                         PW_INSTALL_RETRY_INTERVAL, &pw->install_retry_timer);
 
        zebra_pw_update_status(pw, PW_STATUS_DOWN);
@@ -257,7 +259,7 @@ static int zebra_pw_check_reachability(struct zebra_pw *pw)
         * Need to ensure that there's a label binding for all nexthops.
         * Otherwise, ECMP for this route could render the pseudowire unusable.
         */
-       for (ALL_NEXTHOPS(re->ng, nexthop)) {
+       for (ALL_NEXTHOPS(re->nhe->nhg, nexthop)) {
                if (!nexthop->nh_label) {
                        if (IS_ZEBRA_DEBUG_PW)
                                zlog_debug("%s: unlabeled route for %s",
@@ -545,13 +547,17 @@ static int zebra_pw_config(struct vty *vty)
        return write;
 }
 
+static int zebra_pw_config(struct vty *vty);
 static struct cmd_node pw_node = {
-       PW_NODE, "%s(config-pw)# ", 1,
+       .node = PW_NODE,
+       .parent_node = CONFIG_NODE,
+       .prompt = "%s(config-pw)# ",
+       .config_write = zebra_pw_config,
 };
 
 void zebra_pw_vty_init(void)
 {
-       install_node(&pw_node, zebra_pw_config);
+       install_node(&pw_node);
        install_default(PW_NODE);
 
        install_element(CONFIG_NODE, &pseudowire_if_cmd);