X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=ldpd%2Fl2vpn.c;h=b234e3ebe34f1ba3f78c8de03fd957fca911a031;hb=b0a89c27ad2e7f980d6bf9c78c6ff6a5cfe058c7;hp=9bad503b9c815f47a4294cdcff48d97394ae69ac;hpb=e1768e0a6e2cecc15ab9fe122e607942d07a46c8;p=mirror_frr.git diff --git a/ldpd/l2vpn.c b/ldpd/l2vpn.c index 9bad503b9..b234e3ebe 100644 --- a/ldpd/l2vpn.c +++ b/ldpd/l2vpn.c @@ -76,16 +76,21 @@ l2vpn_del(struct l2vpn *l2vpn) struct l2vpn_if *lif; struct l2vpn_pw *pw; - while ((lif = RB_ROOT(l2vpn_if_head, &l2vpn->if_tree)) != NULL) { + while (!RB_EMPTY(l2vpn_if_head, &l2vpn->if_tree)) { + lif = RB_ROOT(l2vpn_if_head, &l2vpn->if_tree); + RB_REMOVE(l2vpn_if_head, &l2vpn->if_tree, lif); free(lif); } - while ((pw = RB_ROOT(l2vpn_pw_head, &l2vpn->pw_tree)) != NULL) { + while (!RB_EMPTY(l2vpn_pw_head, &l2vpn->pw_tree)) { + pw = RB_ROOT(l2vpn_pw_head, &l2vpn->pw_tree); + RB_REMOVE(l2vpn_pw_head, &l2vpn->pw_tree, pw); free(pw); } - while ((pw = RB_ROOT(l2vpn_pw_head, - &l2vpn->pw_inactive_tree)) != NULL) { + while (!RB_EMPTY(l2vpn_pw_head, &l2vpn->pw_inactive_tree)) { + pw = RB_ROOT(l2vpn_pw_head, &l2vpn->pw_inactive_tree); + RB_REMOVE(l2vpn_pw_head, &l2vpn->pw_inactive_tree, pw); free(pw); } @@ -114,7 +119,7 @@ l2vpn_exit(struct l2vpn *l2vpn) static __inline int l2vpn_if_compare(const struct l2vpn_if *a, const struct l2vpn_if *b) { - return (strcmp(a->ifname, b->ifname)); + return if_cmp_name_func(a->ifname, b->ifname); } struct l2vpn_if * @@ -177,7 +182,7 @@ l2vpn_if_update(struct l2vpn_if *lif) static __inline int l2vpn_pw_compare(const struct l2vpn_pw *a, const struct l2vpn_pw *b) { - return (strcmp(a->ifname, b->ifname)); + return if_cmp_name_func(a->ifname, b->ifname); } struct l2vpn_pw * @@ -239,13 +244,13 @@ l2vpn_pw_init(struct l2vpn_pw *pw) l2vpn_pw_reset(pw); + pw2zpw(pw, &zpw); + lde_imsg_compose_parent(IMSG_KPW_ADD, 0, &zpw, sizeof(zpw)); + l2vpn_pw_fec(pw, &fec); lde_kernel_insert(&fec, AF_INET, (union ldpd_addr*)&pw->lsr_id, 0, 0, - 0, (void *)pw); + 0, 0, (void *)pw); lde_kernel_update(&fec); - - pw2zpw(pw, &zpw); - lde_imsg_compose_parent(IMSG_KPW_ADD, 0, &zpw, sizeof(zpw)); } void @@ -255,7 +260,7 @@ l2vpn_pw_exit(struct l2vpn_pw *pw) struct zapi_pw zpw; l2vpn_pw_fec(pw, &fec); - lde_kernel_remove(&fec, AF_INET, (union ldpd_addr*)&pw->lsr_id, 0, 0); + lde_kernel_remove(&fec, AF_INET, (union ldpd_addr*)&pw->lsr_id, 0, 0, 0); lde_kernel_update(&fec); pw2zpw(pw, &zpw); @@ -295,17 +300,26 @@ int l2vpn_pw_ok(struct l2vpn_pw *pw, struct fec_nh *fnh) { /* check for a remote label */ - if (fnh->remote_label == NO_LABEL) + if (fnh->remote_label == NO_LABEL) { + log_warnx("%s: pseudowire %s: no remote label", __func__, + pw->ifname); return (0); + } /* MTUs must match */ - if (pw->l2vpn->mtu != pw->remote_mtu) + if (pw->l2vpn->mtu != pw->remote_mtu) { + log_warnx("%s: pseudowire %s: MTU mismatch detected", __func__, + pw->ifname); return (0); + } /* check pw status if applicable */ if ((pw->flags & F_PW_STATUSTLV) && - pw->remote_status != PW_FORWARDING) + pw->remote_status != PW_FORWARDING) { + log_warnx("%s: pseudowire %s: remote end is down", __func__, + pw->ifname); return (0); + } return (1); } @@ -419,7 +433,7 @@ l2vpn_recv_pw_status(struct lde_nbr *ln, struct notify_msg *nm) if (pw == NULL) return; - fnh = fec_nh_find(fn, AF_INET, (union ldpd_addr *)&ln->id, 0, 0); + fnh = fec_nh_find(fn, AF_INET, (union ldpd_addr *)&ln->id, 0, 0, 0); if (fnh == NULL) return; @@ -468,7 +482,7 @@ l2vpn_recv_pw_status_wcard(struct lde_nbr *ln, struct notify_msg *nm) } fnh = fec_nh_find(fn, AF_INET, (union ldpd_addr *)&ln->id, - 0, 0); + 0, 0, 0); if (fnh == NULL) continue; @@ -550,7 +564,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;