frr_preinit(&ldpd_di, argc, argv);
frr_opt_add("LEn:", longopts,
" --ctl_socket Override ctl socket path\n"
- "-n, --instance Instance id\n");
+ " -n, --instance Instance id\n");
while (1) {
int opt;
strlcpy(init.user, ldpd_privs.user, sizeof(init.user));
strlcpy(init.group, ldpd_privs.group, sizeof(init.group));
strlcpy(init.ctl_sock_path, ctl_sock_path, sizeof(init.ctl_sock_path));
- strlcpy(init.zclient_serv_path, zclient_serv_path_get(),
+ strlcpy(init.zclient_serv_path, frr_zclientpath,
sizeof(init.zclient_serv_path));
argc -= optind;
- argv += optind;
if (argc > 0 || (lflag && eflag))
frr_help_exit(1);
if (main_imsg_send_ipc_sockets(&iev_ldpe->ibuf, &iev_lde->ibuf))
fatal("could not establish imsg links");
- main_imsg_compose_both(IMSG_INIT, &init, sizeof(init));
main_imsg_compose_both(IMSG_DEBUG_UPDATE, &ldp_debug,
sizeof(ldp_debug));
+ main_imsg_compose_both(IMSG_INIT, &init, sizeof(init));
main_imsg_send_config(ldpd_conf);
if (ldpd_conf->ipv4.flags & F_LDPD_AF_ENABLED)
pid_t pid;
int status;
+ frr_early_fini();
+
/* close pipes */
msgbuf_clear(&iev_ldpe->ibuf.w);
close(iev_ldpe->ibuf.fd);
vrf_terminate();
access_list_reset();
- cmd_terminate();
- vty_terminate();
ldp_zebra_destroy();
- zprivs_terminate(&ldpd_privs);
- thread_master_free(master);
- closezlog();
+ frr_fini();
exit(0);
}
start_child(enum ldpd_process p, char *argv0, int fd_async, int fd_sync)
{
char *argv[3];
- int argc = 0;
+ int argc = 0, nullfd;
pid_t pid;
switch (pid = fork()) {
return (pid);
}
+ nullfd = open("/dev/null", O_RDONLY | O_NOCTTY);
+ if (nullfd == -1) {
+ zlog_err("%s: failed to open /dev/null: %s", __func__,
+ safe_strerror(errno));
+ } else {
+ dup2(nullfd, 0);
+ dup2(nullfd, 1);
+ dup2(nullfd, 2);
+ close(nullfd);
+ }
+
if (dup2(fd_async, LDPD_FD_ASYNC) == -1)
fatal("cannot setup imsg async fd");
if (dup2(fd_sync, LDPD_FD_SYNC) == -1)
if (kr_delete(imsg.data))
log_warnx("%s: error deleting route", __func__);
break;
- case IMSG_KPWLABEL_CHANGE:
+ case IMSG_KPW_ADD:
+ case IMSG_KPW_DELETE:
+ case IMSG_KPW_SET:
+ case IMSG_KPW_UNSET:
if (imsg.hdr.len - IMSG_HEADER_SIZE !=
- sizeof(struct kpw))
+ sizeof(struct zapi_pw))
fatalx("invalid size of IMSG_KPWLABEL_CHANGE");
- if (kmpw_set(imsg.data))
- log_warnx("%s: error changing pseudowire",
- __func__);
- break;
- case IMSG_KPWLABEL_DELETE:
- if (imsg.hdr.len - IMSG_HEADER_SIZE !=
- sizeof(struct kpw))
- fatalx("invalid size of IMSG_KPWLABEL_DELETE");
- if (kmpw_unset(imsg.data))
- log_warnx("%s: error unsetting pseudowire",
- __func__);
+
+ switch (imsg.hdr.type) {
+ case IMSG_KPW_ADD:
+ if (kmpw_add(imsg.data))
+ log_warnx("%s: error adding "
+ "pseudowire", __func__);
+ break;
+ case IMSG_KPW_DELETE:
+ if (kmpw_del(imsg.data))
+ log_warnx("%s: error deleting "
+ "pseudowire", __func__);
+ break;
+ case IMSG_KPW_SET:
+ if (kmpw_set(imsg.data))
+ log_warnx("%s: error setting "
+ "pseudowire", __func__);
+ break;
+ case IMSG_KPW_UNSET:
+ if (kmpw_unset(imsg.data))
+ log_warnx("%s: error unsetting "
+ "pseudowire", __func__);
+ break;
+ }
break;
case IMSG_ACL_CHECK:
if (imsg.hdr.len != IMSG_HEADER_SIZE +
struct iface *iface;
struct nbr_params *nbrp;
- while ((iface = RB_ROOT(&conf->iface_tree)) != NULL) {
+ while ((iface = RB_ROOT(iface_head, &conf->iface_tree)) != NULL) {
QOBJ_UNREG(iface);
RB_REMOVE(iface_head, &conf->iface_tree, iface);
free(iface);
}
- while ((nbrp = RB_ROOT(&conf->nbrp_tree)) != NULL) {
+ while ((nbrp = RB_ROOT(nbrp_head, &conf->nbrp_tree)) != NULL) {
QOBJ_UNREG(nbrp);
RB_REMOVE(nbrp_head, &conf->nbrp_tree, nbrp);
free(nbrp);
struct l2vpn_if *lif;
struct l2vpn_pw *pw;
- while ((l2vpn = RB_ROOT(&conf->l2vpn_tree)) != NULL) {
- while ((lif = RB_ROOT(&l2vpn->if_tree)) != NULL) {
+ while ((l2vpn = RB_ROOT(l2vpn_head, &conf->l2vpn_tree)) != NULL) {
+ while ((lif = RB_ROOT(l2vpn_if_head,
+ &l2vpn->if_tree)) != NULL) {
QOBJ_UNREG(lif);
RB_REMOVE(l2vpn_if_head, &l2vpn->if_tree, lif);
free(lif);
}
- while ((pw = RB_ROOT(&l2vpn->pw_tree)) != NULL) {
+ while ((pw = RB_ROOT(l2vpn_pw_head, &l2vpn->pw_tree)) != NULL) {
QOBJ_UNREG(pw);
RB_REMOVE(l2vpn_pw_head, &l2vpn->pw_tree, pw);
free(pw);
}
- while ((pw = RB_ROOT(&l2vpn->pw_inactive_tree)) != NULL) {
+ while ((pw = RB_ROOT(l2vpn_pw_head,
+ &l2vpn->pw_inactive_tree)) != NULL) {
QOBJ_UNREG(pw);
RB_REMOVE(l2vpn_pw_head, &l2vpn->pw_inactive_tree, pw);
free(pw);
struct nbr_params *nbrp;
struct l2vpn *l2vpn;
- while ((iface = RB_ROOT(&xconf->iface_tree)) != NULL) {
+ while ((iface = RB_ROOT(iface_head, &xconf->iface_tree)) != NULL) {
RB_REMOVE(iface_head, &xconf->iface_tree, iface);
free(iface);
}
- while ((tnbr = RB_ROOT(&xconf->tnbr_tree)) != NULL) {
+ while ((tnbr = RB_ROOT(tnbr_head, &xconf->tnbr_tree)) != NULL) {
RB_REMOVE(tnbr_head, &xconf->tnbr_tree, tnbr);
free(tnbr);
}
- while ((nbrp = RB_ROOT(&xconf->nbrp_tree)) != NULL) {
+ while ((nbrp = RB_ROOT(nbrp_head, &xconf->nbrp_tree)) != NULL) {
RB_REMOVE(nbrp_head, &xconf->nbrp_tree, nbrp);
free(nbrp);
}
- while ((l2vpn = RB_ROOT(&xconf->l2vpn_tree)) != NULL) {
+ while ((l2vpn = RB_ROOT(l2vpn_head, &xconf->l2vpn_tree)) != NULL) {
RB_REMOVE(l2vpn_head, &xconf->l2vpn_tree, l2vpn);
l2vpn_del(l2vpn);
}
if ((l2vpn = l2vpn_find(conf, xl->name)) == NULL) {
COPY(l2vpn, xl);
RB_INSERT(l2vpn_head, &conf->l2vpn_tree, l2vpn);
- RB_INIT(&l2vpn->if_tree);
- RB_INIT(&l2vpn->pw_tree);
- RB_INIT(&l2vpn->pw_inactive_tree);
+ RB_INIT(l2vpn_if_head, &l2vpn->if_tree);
+ RB_INIT(l2vpn_pw_head, &l2vpn->pw_tree);
+ RB_INIT(l2vpn_pw_head, &l2vpn->pw_inactive_tree);
switch (ldpd_process) {
case PROC_LDE_ENGINE:
if (xconf == NULL)
fatal(NULL);
- RB_INIT(&xconf->iface_tree);
- RB_INIT(&xconf->tnbr_tree);
- RB_INIT(&xconf->nbrp_tree);
- RB_INIT(&xconf->l2vpn_tree);
+ RB_INIT(iface_head, &xconf->iface_tree);
+ RB_INIT(tnbr_head, &xconf->tnbr_tree);
+ RB_INIT(nbrp_head, &xconf->nbrp_tree);
+ RB_INIT(l2vpn_head, &xconf->l2vpn_tree);
/* set default values */
ldp_config_reset(xconf);