X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=zebra%2Fzebra_pw.c;h=fb9a40fe3d857e8d4325031c6eecff2d1be223ec;hb=2569910bb6e5c00ececc60ed15b182e14a88cb9d;hp=ce9f19c3cc22f26b471a9eacdb28c64bbbbb9c2d;hpb=8972cae0fd5401cbb135faf934f03c26c6122855;p=mirror_frr.git diff --git a/zebra/zebra_pw.c b/zebra/zebra_pw.c index ce9f19c3c..fb9a40fe3 100644 --- a/zebra/zebra_pw.c +++ b/zebra/zebra_pw.c @@ -28,6 +28,7 @@ #include "zebra/debug.h" #include "zebra/rib.h" #include "zebra/zserv.h" +#include "zebra/zapi_msg.h" #include "zebra/zebra_rnh.h" #include "zebra/zebra_vrf.h" #include "zebra/zebra_pw.h" @@ -73,7 +74,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; @@ -247,8 +248,8 @@ static int zebra_pw_check_reachability(struct zebra_pw *pw) &pw->nexthop, NULL); if (!re) { if (IS_ZEBRA_DEBUG_PW) - zlog_warn("%s: no route found for %s", __func__, - pw->ifname); + zlog_debug("%s: no route found for %s", __func__, + pw->ifname); return -1; } @@ -256,11 +257,11 @@ 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->nexthop, nexthop)) { + for (ALL_NEXTHOPS(re->ng, nexthop)) { if (!nexthop->nh_label) { if (IS_ZEBRA_DEBUG_PW) - zlog_warn("%s: unlabeled route for %s", - __func__, pw->ifname); + zlog_debug("%s: unlabeled route for %s", + __func__, pw->ifname); return -1; } } @@ -268,49 +269,53 @@ static int zebra_pw_check_reachability(struct zebra_pw *pw) return 0; } -void zebra_pw_client_close(struct zserv *client) +static int zebra_pw_client_close(struct zserv *client) { struct vrf *vrf; struct zebra_vrf *zvrf; struct zebra_pw *pw, *tmp; - RB_FOREACH(vrf, vrf_id_head, &vrfs_by_id) - { + RB_FOREACH (vrf, vrf_id_head, &vrfs_by_id) { zvrf = vrf->info; - RB_FOREACH_SAFE(pw, zebra_pw_head, &zvrf->pseudowires, tmp) - { + RB_FOREACH_SAFE (pw, zebra_pw_head, &zvrf->pseudowires, tmp) { if (pw->client != client) continue; zebra_pw_del(zvrf, pw); } } + + return 0; } void zebra_pw_init(struct zebra_vrf *zvrf) { RB_INIT(zebra_pw_head, &zvrf->pseudowires); RB_INIT(zebra_static_pw_head, &zvrf->static_pseudowires); + + hook_register(zserv_client_close, zebra_pw_client_close); } void zebra_pw_exit(struct zebra_vrf *zvrf) { struct zebra_pw *pw; - while ((pw = RB_ROOT(zebra_pw_head, &zvrf->pseudowires)) != NULL) + while (!RB_EMPTY(zebra_pw_head, &zvrf->pseudowires)) { + pw = RB_ROOT(zebra_pw_head, &zvrf->pseudowires); + zebra_pw_del(zvrf, pw); + } } DEFUN_NOSH (pseudowire_if, pseudowire_if_cmd, - "[no] pseudowire IFNAME", - NO_STR + "pseudowire IFNAME", "Static pseudowire configuration\n" "Pseudowire name\n") { struct zebra_vrf *zvrf; struct zebra_pw *pw; - int idx = 0; const char *ifname; + int idx = 0; zvrf = vrf_info_lookup(VRF_DEFAULT); if (!zvrf) @@ -318,19 +323,13 @@ DEFUN_NOSH (pseudowire_if, argv_find(argv, argc, "IFNAME", &idx); ifname = argv[idx]->arg; + pw = zebra_pw_find(zvrf, ifname); if (pw && pw->protocol != ZEBRA_ROUTE_STATIC) { vty_out(vty, "%% Pseudowire is not static\n"); return CMD_WARNING; } - if (argv_find(argv, argc, "no", &idx)) { - if (!pw) - return CMD_SUCCESS; - zebra_pw_del(zvrf, pw); - return CMD_SUCCESS; - } - if (!pw) pw = zebra_pw_add(zvrf, ifname, ZEBRA_ROUTE_STATIC, NULL); VTY_PUSH_CONTEXT(PW_NODE, pw); @@ -338,6 +337,37 @@ DEFUN_NOSH (pseudowire_if, return CMD_SUCCESS; } +DEFUN (no_pseudowire_if, + no_pseudowire_if_cmd, + "no pseudowire IFNAME", + NO_STR + "Static pseudowire configuration\n" + "Pseudowire name\n") +{ + struct zebra_vrf *zvrf; + struct zebra_pw *pw; + const char *ifname; + int idx = 0; + + zvrf = vrf_info_lookup(VRF_DEFAULT); + if (!zvrf) + return CMD_WARNING; + + argv_find(argv, argc, "IFNAME", &idx); + ifname = argv[idx]->arg; + + pw = zebra_pw_find(zvrf, ifname); + if (pw) { + if (pw->protocol != ZEBRA_ROUTE_STATIC) { + vty_out(vty, "%% Pseudowire is not static\n"); + return CMD_WARNING; + } + zebra_pw_del(zvrf, pw); + } + + return CMD_SUCCESS; +} + DEFUN (pseudowire_labels, pseudowire_labels_cmd, "[no] mpls label local (16-1048575) remote (16-1048575)", @@ -438,7 +468,7 @@ DEFUN (show_pseudowires, "show mpls pseudowires", SHOW_STR MPLS_STR - "Pseudowires") + "Pseudowires\n") { struct zebra_vrf *zvrf; struct zebra_pw *pw; @@ -450,8 +480,7 @@ DEFUN (show_pseudowires, vty_out(vty, "%-16s %-24s %-12s %-8s %-10s\n", "Interface", "Neighbor", "Labels", "Protocol", "Status"); - RB_FOREACH(pw, zebra_pw_head, &zvrf->pseudowires) - { + RB_FOREACH (pw, zebra_pw_head, &zvrf->pseudowires) { char buf_nbr[INET6_ADDRSTRLEN]; char buf_labels[64]; @@ -486,8 +515,7 @@ static int zebra_pw_config(struct vty *vty) if (!zvrf) return 0; - RB_FOREACH(pw, zebra_static_pw_head, &zvrf->static_pseudowires) - { + RB_FOREACH (pw, zebra_static_pw_head, &zvrf->static_pseudowires) { vty_out(vty, "pseudowire %s\n", pw->ifname); if (pw->local_label != MPLS_NO_LABEL && pw->remote_label != MPLS_NO_LABEL) @@ -527,6 +555,7 @@ void zebra_pw_vty_init(void) install_default(PW_NODE); install_element(CONFIG_NODE, &pseudowire_if_cmd); + install_element(CONFIG_NODE, &no_pseudowire_if_cmd); install_element(PW_NODE, &pseudowire_labels_cmd); install_element(PW_NODE, &pseudowire_neighbor_cmd); install_element(PW_NODE, &pseudowire_control_word_cmd);