diff options
author | 2016-05-23 15:47:24 +0000 | |
---|---|---|
committer | 2016-05-23 15:47:24 +0000 | |
commit | 33f6ccfe85c312709ab5d1d6d46956575772999e (patch) | |
tree | c5f20c713171febdfd67da31b3d6669912da3890 | |
parent | Support Airprime/Sierra AirCard 313U, Netgear/Sierra AirCard 770S (diff) | |
download | wireguard-openbsd-33f6ccfe85c312709ab5d1d6d46956575772999e.tar.xz wireguard-openbsd-33f6ccfe85c312709ab5d1d6d46956575772999e.zip |
Move some code around.
This patch doesn't introduce any logical change.
-rw-r--r-- | usr.sbin/ldpd/adjacency.c | 77 | ||||
-rw-r--r-- | usr.sbin/ldpd/interface.c | 111 | ||||
-rw-r--r-- | usr.sbin/ldpd/l2vpn.c | 12 | ||||
-rw-r--r-- | usr.sbin/ldpd/lde.c | 69 | ||||
-rw-r--r-- | usr.sbin/ldpd/ldp.h | 8 | ||||
-rw-r--r-- | usr.sbin/ldpd/ldpd.c | 12 | ||||
-rw-r--r-- | usr.sbin/ldpd/ldpe.c | 81 | ||||
-rw-r--r-- | usr.sbin/ldpd/ldpe.h | 11 | ||||
-rw-r--r-- | usr.sbin/ldpd/log.c | 22 | ||||
-rw-r--r-- | usr.sbin/ldpd/neighbor.c | 18 | ||||
-rw-r--r-- | usr.sbin/ldpd/packet.c | 66 | ||||
-rw-r--r-- | usr.sbin/ldpd/printconf.c | 40 |
12 files changed, 316 insertions, 211 deletions
diff --git a/usr.sbin/ldpd/adjacency.c b/usr.sbin/ldpd/adjacency.c index a95aa60135d..f8df2cecffa 100644 --- a/usr.sbin/ldpd/adjacency.c +++ b/usr.sbin/ldpd/adjacency.c @@ -1,4 +1,4 @@ -/* $OpenBSD: adjacency.c,v 1.8 2016/05/23 15:14:07 renato Exp $ */ +/* $OpenBSD: adjacency.c,v 1.9 2016/05/23 15:47:24 renato Exp $ */ /* * Copyright (c) 2009 Michele Marchetto <michele@openbsd.org> @@ -34,7 +34,6 @@ extern struct ldpd_conf *leconf; void adj_itimer(int, short, void *); -char *print_hello_src(struct hello_source *); void tnbr_hello_timer(int, short, void *); void tnbr_start_hello_timer(struct tnbr *); @@ -46,7 +45,7 @@ adj_new(struct nbr *nbr, struct hello_source *source, struct in_addr addr) struct adj *adj; log_debug("%s: LSR ID %s, %s", __func__, inet_ntoa(nbr->id), - print_hello_src(source)); + log_hello_src(source)); if ((adj = calloc(1, sizeof(*adj))) == NULL) fatal(__func__); @@ -76,7 +75,7 @@ void adj_del(struct adj *adj) { log_debug("%s: LSR ID %s, %s", __func__, inet_ntoa(adj->nbr->id), - print_hello_src(&adj->source)); + log_hello_src(&adj->source)); adj_stop_itimer(adj); @@ -114,25 +113,6 @@ adj_find(struct nbr *nbr, struct hello_source *source) return (NULL); } -char * -print_hello_src(struct hello_source *src) -{ - static char buffer[64]; - - switch (src->type) { - case HELLO_LINK: - snprintf(buffer, sizeof(buffer), "iface %s", - src->link.iface->name); - break; - case HELLO_TARGETED: - snprintf(buffer, sizeof(buffer), "source %s", - inet_ntoa(src->target->addr)); - break; - } - - return (buffer); -} - /* adjacency timers */ /* ARGSUSED */ @@ -209,6 +189,18 @@ tnbr_del(struct tnbr *tnbr) } struct tnbr * +tnbr_find(struct ldpd_conf *xconf, struct in_addr addr) +{ + struct tnbr *tnbr; + + LIST_FOREACH(tnbr, &xconf->tnbr_list, entry) + if (addr.s_addr == tnbr->addr.s_addr) + return (tnbr); + + return (NULL); +} + +struct tnbr * tnbr_check(struct tnbr *tnbr) { if (!(tnbr->flags & (F_TNBR_CONFIGURED|F_TNBR_DYNAMIC)) && @@ -231,18 +223,6 @@ tnbr_init(struct ldpd_conf *xconf, struct tnbr *tnbr) tnbr_start_hello_timer(tnbr); } -struct tnbr * -tnbr_find(struct ldpd_conf *xconf, struct in_addr addr) -{ - struct tnbr *tnbr; - - LIST_FOREACH(tnbr, &xconf->tnbr_list, entry) - if (addr.s_addr == tnbr->addr.s_addr) - return (tnbr); - - return (NULL); -} - /* target neighbors timers */ /* ARGSUSED */ @@ -302,30 +282,3 @@ adj_to_ctl(struct adj *adj) return (&actl); } - -void -ldpe_adj_ctl(struct ctl_conn *c) -{ - struct adj *adj; - struct iface *iface; - struct tnbr *tnbr; - struct ctl_adj *actl; - - /* basic discovery mechanism */ - LIST_FOREACH(iface, &leconf->iface_list, entry) - LIST_FOREACH(adj, &iface->adj_list, iface_entry) { - actl = adj_to_ctl(adj); - imsg_compose_event(&c->iev, IMSG_CTL_SHOW_DISCOVERY, - 0, 0, -1, actl, sizeof(struct ctl_adj)); - } - - /* extended discovery mechanism */ - LIST_FOREACH(tnbr, &leconf->tnbr_list, entry) - if (tnbr->adj) { - actl = adj_to_ctl(tnbr->adj); - imsg_compose_event(&c->iev, IMSG_CTL_SHOW_DISCOVERY, - 0, 0, -1, actl, sizeof(struct ctl_adj)); - } - - imsg_compose_event(&c->iev, IMSG_CTL_END, 0, 0, -1, NULL, 0); -} diff --git a/usr.sbin/ldpd/interface.c b/usr.sbin/ldpd/interface.c index abaf4e93573..6f989d25814 100644 --- a/usr.sbin/ldpd/interface.c +++ b/usr.sbin/ldpd/interface.c @@ -1,4 +1,4 @@ -/* $OpenBSD: interface.c,v 1.27 2016/05/23 15:14:07 renato Exp $ */ +/* $OpenBSD: interface.c,v 1.28 2016/05/23 15:47:24 renato Exp $ */ /* * Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org> @@ -144,42 +144,61 @@ if_addr_lookup(struct if_addr_head *addr_list, struct kaddr *kaddr) return (NULL); } -/* timers */ -/* ARGSUSED */ void -if_hello_timer(int fd, short event, void *arg) +if_addr_add(struct kaddr *ka) { - struct iface *iface = arg; - struct timeval tv; + struct iface *iface; + struct if_addr *if_addr; + struct nbr *nbr; - send_hello(HELLO_LINK, iface, NULL); + if (if_addr_lookup(&global.addr_list, ka) == NULL) { + if_addr = if_addr_new(ka); - /* reschedule hello_timer */ - timerclear(&tv); - tv.tv_sec = iface->hello_interval; - if (evtimer_add(&iface->hello_timer, &tv) == -1) - fatal(__func__); -} - -void -if_start_hello_timer(struct iface *iface) -{ - struct timeval tv; + LIST_INSERT_HEAD(&global.addr_list, if_addr, entry); + RB_FOREACH(nbr, nbr_id_head, &nbrs_by_id) { + if (nbr->state != NBR_STA_OPER) + continue; - send_hello(HELLO_LINK, iface, NULL); + send_address(nbr, if_addr); + } + } - timerclear(&tv); - tv.tv_sec = iface->hello_interval; - if (evtimer_add(&iface->hello_timer, &tv) == -1) - fatal(__func__); + iface = if_lookup(leconf, ka->ifindex); + if (iface && + if_addr_lookup(&iface->addr_list, ka) == NULL) { + if_addr = if_addr_new(ka); + LIST_INSERT_HEAD(&iface->addr_list, if_addr, entry); + if_update(iface); + } } void -if_stop_hello_timer(struct iface *iface) +if_addr_del(struct kaddr *ka) { - if (evtimer_pending(&iface->hello_timer, NULL) && - evtimer_del(&iface->hello_timer) == -1) - fatal(__func__); + struct iface *iface; + struct if_addr *if_addr; + struct nbr *nbr; + + iface = if_lookup(leconf, ka->ifindex); + if (iface) { + if_addr = if_addr_lookup(&iface->addr_list, ka); + if (if_addr) { + LIST_REMOVE(if_addr, entry); + free(if_addr); + if_update(iface); + } + } + + if_addr = if_addr_lookup(&global.addr_list, ka); + if (if_addr) { + RB_FOREACH(nbr, nbr_id_head, &nbrs_by_id) { + if (nbr->state != NBR_STA_OPER) + continue; + send_address_withdraw(nbr, if_addr); + } + LIST_REMOVE(if_addr, entry); + free(if_addr); + } } int @@ -250,6 +269,44 @@ if_update(struct iface *iface) return (ret); } +/* timers */ +/* ARGSUSED */ +void +if_hello_timer(int fd, short event, void *arg) +{ + struct iface *iface = arg; + struct timeval tv; + + send_hello(HELLO_LINK, iface, NULL); + + /* reschedule hello_timer */ + timerclear(&tv); + tv.tv_sec = iface->hello_interval; + if (evtimer_add(&iface->hello_timer, &tv) == -1) + fatal(__func__); +} + +void +if_start_hello_timer(struct iface *iface) +{ + struct timeval tv; + + send_hello(HELLO_LINK, iface, NULL); + + timerclear(&tv); + tv.tv_sec = iface->hello_interval; + if (evtimer_add(&iface->hello_timer, &tv) == -1) + fatal(__func__); +} + +void +if_stop_hello_timer(struct iface *iface) +{ + if (evtimer_pending(&iface->hello_timer, NULL) && + evtimer_del(&iface->hello_timer) == -1) + fatal(__func__); +} + struct ctl_iface * if_to_ctl(struct iface *iface) { diff --git a/usr.sbin/ldpd/l2vpn.c b/usr.sbin/ldpd/l2vpn.c index b93523c7779..281bc117227 100644 --- a/usr.sbin/ldpd/l2vpn.c +++ b/usr.sbin/ldpd/l2vpn.c @@ -1,4 +1,4 @@ -/* $OpenBSD: l2vpn.c,v 1.1 2015/07/21 04:52:29 renato Exp $ */ +/* $OpenBSD: l2vpn.c,v 1.2 2016/05/23 15:47:24 renato Exp $ */ /* * Copyright (c) 2015 Renato Westphal <renato@openbsd.org> @@ -159,7 +159,7 @@ l2vpn_pw_find(struct l2vpn *l2vpn, unsigned int ifindex) } void -l2vpn_pw_del(struct l2vpn_pw *pw) +l2vpn_pw_init(struct l2vpn_pw *pw) { struct fec fec; @@ -167,12 +167,11 @@ l2vpn_pw_del(struct l2vpn_pw *pw) return; l2vpn_pw_fec(pw, &fec); - lde_kernel_remove(&fec, pw->addr); - free(pw); + lde_kernel_insert(&fec, pw->addr, 0, (void *)pw); } void -l2vpn_pw_init(struct l2vpn_pw *pw) +l2vpn_pw_del(struct l2vpn_pw *pw) { struct fec fec; @@ -180,7 +179,8 @@ l2vpn_pw_init(struct l2vpn_pw *pw) return; l2vpn_pw_fec(pw, &fec); - lde_kernel_insert(&fec, pw->addr, 0, (void *)pw); + lde_kernel_remove(&fec, pw->addr); + free(pw); } void diff --git a/usr.sbin/ldpd/lde.c b/usr.sbin/ldpd/lde.c index 2877d21ef87..909a7a9c942 100644 --- a/usr.sbin/ldpd/lde.c +++ b/usr.sbin/ldpd/lde.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lde.c,v 1.41 2016/05/23 15:14:07 renato Exp $ */ +/* $OpenBSD: lde.c,v 1.42 2016/05/23 15:47:24 renato Exp $ */ /* * Copyright (c) 2004, 2005 Claudio Jeker <claudio@openbsd.org> @@ -926,6 +926,16 @@ lde_nbr_del(struct lde_nbr *nbr) free(nbr); } +struct lde_nbr * +lde_nbr_find(uint32_t peerid) +{ + struct lde_nbr n; + + n.peerid = peerid; + + return (RB_FIND(nbr_tree, &lde_nbrs, &n)); +} + void lde_nbr_clear(void) { @@ -1042,6 +1052,37 @@ lde_wdraw_del(struct lde_nbr *ln, struct lde_wdraw *lw) free(lw); } +void +lde_change_egress_label(int was_implicit) +{ + struct lde_nbr *ln; + struct fec *f; + struct fec_node *fn; + int count = 0; + + /* explicit withdraw */ + if (was_implicit) + lde_send_labelwithdraw_all(NULL, MPLS_LABEL_IMPLNULL); + else + lde_send_labelwithdraw_all(NULL, MPLS_LABEL_IPV4NULL); + + /* update label of connected prefixes */ + RB_FOREACH(ln, nbr_tree, &lde_nbrs) { + RB_FOREACH(f, fec_tree, &ft) { + fn = (struct fec_node *)f; + if (fn->local_label > MPLS_LABEL_RESERVED_MAX) + continue; + + fn->local_label = egress_label(fn->fec.type); + lde_send_labelmapping(ln, fn, 0); + count++; + } + if (count > 0) + lde_imsg_compose_ldpe(IMSG_MAPPING_ADD_END, + ln->peerid, 0, NULL, 0); + } +} + int lde_address_add(struct lde_nbr *lr, struct in_addr *addr) { @@ -1062,19 +1103,6 @@ lde_address_add(struct lde_nbr *lr, struct in_addr *addr) return (0); } -struct lde_nbr_address * -lde_address_find(struct lde_nbr *lr, struct in_addr *addr) -{ - struct lde_nbr_address *address = NULL; - - TAILQ_FOREACH(address, &lr->addr_list, entry) { - if (address->addr.s_addr == addr->s_addr) - return (address); - } - - return (NULL); -} - int lde_address_del(struct lde_nbr *lr, struct in_addr *addr) { @@ -1093,6 +1121,19 @@ lde_address_del(struct lde_nbr *lr, struct in_addr *addr) return (0); } +struct lde_nbr_address * +lde_address_find(struct lde_nbr *lr, struct in_addr *addr) +{ + struct lde_nbr_address *address = NULL; + + TAILQ_FOREACH(address, &lr->addr_list, entry) { + if (address->addr.s_addr == addr->s_addr) + return (address); + } + + return (NULL); +} + void lde_address_list_free(struct lde_nbr *nbr) { diff --git a/usr.sbin/ldpd/ldp.h b/usr.sbin/ldpd/ldp.h index a0830380124..341e90705c4 100644 --- a/usr.sbin/ldpd/ldp.h +++ b/usr.sbin/ldpd/ldp.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ldp.h,v 1.19 2015/07/21 04:52:29 renato Exp $ */ +/* $OpenBSD: ldp.h,v 1.20 2016/05/23 15:47:24 renato Exp $ */ /* * Copyright (c) 2009 Michele Marchetto <michele@openbsd.org> @@ -125,9 +125,6 @@ struct ldp_msg { #define UNKNOWN_FLAG 0x8000 #define FORWARD_FLAG 0xc000 -#define TARGETED_HELLO 0x8000 -#define REQUEST_TARG_HELLO 0x4000 - struct hello_prms_tlv { u_int16_t type; u_int16_t length; @@ -135,6 +132,9 @@ struct hello_prms_tlv { u_int16_t flags; }; +#define TARGETED_HELLO 0x8000 +#define REQUEST_TARG_HELLO 0x4000 + struct hello_prms_opt4_tlv { u_int16_t type; u_int16_t length; diff --git a/usr.sbin/ldpd/ldpd.c b/usr.sbin/ldpd/ldpd.c index 81d9cc5792c..b3bd573d1c7 100644 --- a/usr.sbin/ldpd/ldpd.c +++ b/usr.sbin/ldpd/ldpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ldpd.c,v 1.31 2016/05/23 15:43:11 renato Exp $ */ +/* $OpenBSD: ldpd.c,v 1.32 2016/05/23 15:47:24 renato Exp $ */ /* * Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org> @@ -479,6 +479,16 @@ main_imsg_compose_lde(int type, pid_t pid, void *data, u_int16_t datalen) imsg_compose_event(iev_lde, type, 0, pid, -1, data, datalen); } +int +ldp_sendboth(enum imsg_type type, void *buf, uint16_t len) +{ + if (imsg_compose_event(iev_ldpe, type, 0, 0, -1, buf, len) == -1) + return (-1); + if (imsg_compose_event(iev_lde, type, 0, 0, -1, buf, len) == -1) + return (-1); + return (0); +} + void imsg_event_add(struct imsgev *iev) { diff --git a/usr.sbin/ldpd/ldpe.c b/usr.sbin/ldpd/ldpe.c index bd1ff57ee8e..dad8e55c80f 100644 --- a/usr.sbin/ldpd/ldpe.c +++ b/usr.sbin/ldpd/ldpe.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ldpe.c,v 1.46 2016/05/23 15:43:11 renato Exp $ */ +/* $OpenBSD: ldpe.c,v 1.47 2016/05/23 15:47:24 renato Exp $ */ /* * Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org> @@ -43,9 +43,6 @@ #include "control.h" #include "log.h" -extern struct nbr_id_head nbrs_by_id; -RB_PROTOTYPE(nbr_id_head, nbr, id_tree, nbr_id_compare) - void ldpe_sig_handler(int, short, void *); void ldpe_shutdown(void); @@ -346,11 +343,8 @@ ldpe_dispatch_main(int fd, short event, void *bula) struct imsgev *iev = bula; struct imsgbuf *ibuf = &iev->ibuf; struct iface *iface = NULL; - struct if_addr *if_addr = NULL; struct kif *kif; - struct kaddr *ka; int n, shut = 0; - struct nbr *nbr; if (event & EV_READ) { if ((n = imsg_read(ibuf)) == -1 && errno != EAGAIN) @@ -680,6 +674,63 @@ ldpe_router_id(void) } void +ldpe_iface_ctl(struct ctl_conn *c, unsigned int idx) +{ + struct iface *iface; + struct ctl_iface *ictl; + + LIST_FOREACH(iface, &leconf->iface_list, entry) { + if (idx == 0 || idx == iface->ifindex) { + ictl = if_to_ctl(iface); + imsg_compose_event(&c->iev, + IMSG_CTL_SHOW_INTERFACE, + 0, 0, -1, ictl, sizeof(struct ctl_iface)); + } + } +} + +void +ldpe_adj_ctl(struct ctl_conn *c) +{ + struct adj *adj; + struct iface *iface; + struct tnbr *tnbr; + struct ctl_adj *actl; + + /* basic discovery mechanism */ + LIST_FOREACH(iface, &leconf->iface_list, entry) + LIST_FOREACH(adj, &iface->adj_list, iface_entry) { + actl = adj_to_ctl(adj); + imsg_compose_event(&c->iev, IMSG_CTL_SHOW_DISCOVERY, + 0, 0, -1, actl, sizeof(struct ctl_adj)); + } + + /* extended discovery mechanism */ + LIST_FOREACH(tnbr, &leconf->tnbr_list, entry) + if (tnbr->adj) { + actl = adj_to_ctl(tnbr->adj); + imsg_compose_event(&c->iev, IMSG_CTL_SHOW_DISCOVERY, + 0, 0, -1, actl, sizeof(struct ctl_adj)); + } + + imsg_compose_event(&c->iev, IMSG_CTL_END, 0, 0, -1, NULL, 0); +} + +void +ldpe_nbr_ctl(struct ctl_conn *c) +{ + struct nbr *nbr; + struct ctl_nbr *nctl; + + RB_FOREACH(nbr, nbr_pid_head, &nbrs_by_pid) { + nctl = nbr_to_ctl(nbr); + imsg_compose_event(&c->iev, IMSG_CTL_SHOW_NBR, 0, 0, -1, nctl, + sizeof(struct ctl_nbr)); + } + imsg_compose_event(&c->iev, IMSG_CTL_END, 0, 0, -1, NULL, 0); +} + +void mapping_list_add(struct mapping_head *mh, struct map *map) { struct mapping_entry *me; @@ -702,19 +753,3 @@ mapping_list_clr(struct mapping_head *mh) free(me); } } - -void -ldpe_iface_ctl(struct ctl_conn *c, unsigned int idx) -{ - struct iface *iface; - struct ctl_iface *ictl; - - LIST_FOREACH(iface, &leconf->iface_list, entry) { - if (idx == 0 || idx == iface->ifindex) { - ictl = if_to_ctl(iface); - imsg_compose_event(&c->iev, - IMSG_CTL_SHOW_INTERFACE, - 0, 0, -1, ictl, sizeof(struct ctl_iface)); - } - } -} diff --git a/usr.sbin/ldpd/ldpe.h b/usr.sbin/ldpd/ldpe.h index 53661c29293..72b36978cdd 100644 --- a/usr.sbin/ldpd/ldpe.h +++ b/usr.sbin/ldpd/ldpe.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ldpe.h,v 1.44 2016/05/23 15:43:11 renato Exp $ */ +/* $OpenBSD: ldpe.h,v 1.45 2016/05/23 15:47:24 renato Exp $ */ /* * Copyright (c) 2004, 2005, 2008 Esben Norby <norby@openbsd.org> @@ -169,6 +169,8 @@ void if_init(struct ldpd_conf *, struct iface *); struct iface *if_lookup(struct ldpd_conf *, u_short); struct if_addr *if_addr_new(struct kaddr *); struct if_addr *if_addr_lookup(struct if_addr_head *, struct kaddr *); +void if_addr_add(struct kaddr *); +void if_addr_del(struct kaddr *); struct ctl_iface *if_to_ctl(struct iface *); @@ -195,7 +197,6 @@ void tnbr_init(struct ldpd_conf *, struct tnbr *); struct tnbr *tnbr_find(struct ldpd_conf *, struct in_addr); struct ctl_adj *adj_to_ctl(struct adj *); -void ldpe_adj_ctl(struct ctl_conn *); /* neighbor.c */ struct nbr *nbr_new(struct in_addr, struct in_addr); @@ -226,7 +227,11 @@ struct nbr_params *nbr_params_new(struct in_addr); struct nbr_params *nbr_params_find(struct ldpd_conf *, struct in_addr); struct ctl_nbr *nbr_to_ctl(struct nbr *); -void ldpe_nbr_ctl(struct ctl_conn *); + +extern struct nbr_id_head nbrs_by_id; +RB_PROTOTYPE(nbr_id_head, nbr, id_tree, nbr_id_compare) +extern struct nbr_pid_head nbrs_by_pid; +RB_PROTOTYPE(nbr_pid_head, nbr, pid_tree, nbr_pid_compare) /* packet.c */ int gen_ldp_hdr(struct ibuf *, u_int16_t); diff --git a/usr.sbin/ldpd/log.c b/usr.sbin/ldpd/log.c index bca642bd070..7a6d096f87d 100644 --- a/usr.sbin/ldpd/log.c +++ b/usr.sbin/ldpd/log.c @@ -1,4 +1,4 @@ -/* $OpenBSD: log.c,v 1.17 2016/05/23 15:26:35 renato Exp $ */ +/* $OpenBSD: log.c,v 1.18 2016/05/23 15:47:24 renato Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -30,6 +30,7 @@ #include <unistd.h> #include "ldpd.h" +#include "ldpe.h" #include "lde.h" #include "log.h" @@ -315,6 +316,25 @@ pw_type_name(u_int16_t pw_type) } } +char * +log_hello_src(const struct hello_source *src) +{ + static char buffer[64]; + + switch (src->type) { + case HELLO_LINK: + snprintf(buffer, sizeof(buffer), "iface %s", + src->link.iface->name); + break; + case HELLO_TARGETED: + snprintf(buffer, sizeof(buffer), "source %s", + inet_ntoa(src->target->addr)); + break; + } + + return (buffer); +} + const char * log_map(struct map *map) { diff --git a/usr.sbin/ldpd/neighbor.c b/usr.sbin/ldpd/neighbor.c index 189968286a1..03f9ae3615f 100644 --- a/usr.sbin/ldpd/neighbor.c +++ b/usr.sbin/ldpd/neighbor.c @@ -1,4 +1,4 @@ -/* $OpenBSD: neighbor.c,v 1.55 2016/05/23 15:43:11 renato Exp $ */ +/* $OpenBSD: neighbor.c,v 1.56 2016/05/23 15:47:24 renato Exp $ */ /* * Copyright (c) 2009 Michele Marchetto <michele@openbsd.org> @@ -50,10 +50,8 @@ static __inline int nbr_id_compare(struct nbr *, struct nbr *); static __inline int nbr_pid_compare(struct nbr *, struct nbr *); RB_HEAD(nbr_id_head, nbr); -RB_PROTOTYPE(nbr_id_head, nbr, id_tree, nbr_id_compare) RB_GENERATE(nbr_id_head, nbr, id_tree, nbr_id_compare) RB_HEAD(nbr_pid_head, nbr); -RB_PROTOTYPE(nbr_pid_head, nbr, pid_tree, nbr_pid_compare) RB_GENERATE(nbr_pid_head, nbr, pid_tree, nbr_pid_compare) static __inline int @@ -629,17 +627,3 @@ nbr_to_ctl(struct nbr *nbr) return (&nctl); } - -void -ldpe_nbr_ctl(struct ctl_conn *c) -{ - struct nbr *nbr; - struct ctl_nbr *nctl; - - RB_FOREACH(nbr, nbr_pid_head, &nbrs_by_pid) { - nctl = nbr_to_ctl(nbr); - imsg_compose_event(&c->iev, IMSG_CTL_SHOW_NBR, 0, 0, -1, nctl, - sizeof(struct ctl_nbr)); - } - imsg_compose_event(&c->iev, IMSG_CTL_END, 0, 0, -1, NULL, 0); -} diff --git a/usr.sbin/ldpd/packet.c b/usr.sbin/ldpd/packet.c index feb39c40343..6621438a5d0 100644 --- a/usr.sbin/ldpd/packet.c +++ b/usr.sbin/ldpd/packet.c @@ -1,4 +1,4 @@ -/* $OpenBSD: packet.c,v 1.44 2016/05/23 15:43:11 renato Exp $ */ +/* $OpenBSD: packet.c,v 1.45 2016/05/23 15:47:24 renato Exp $ */ /* * Copyright (c) 2009 Michele Marchetto <michele@openbsd.org> @@ -231,38 +231,6 @@ disc_find_iface(unsigned int ifindex, struct in_addr src) return (NULL); } -struct tcp_conn * -tcp_new(int fd, struct nbr *nbr) -{ - struct tcp_conn *tcp; - - if ((tcp = calloc(1, sizeof(*tcp))) == NULL) - fatal(__func__); - if ((tcp->rbuf = calloc(1, sizeof(struct ibuf_read))) == NULL) - fatal(__func__); - - if (nbr) - tcp->nbr = nbr; - - tcp->fd = fd; - evbuf_init(&tcp->wbuf, tcp->fd, session_write, tcp); - event_set(&tcp->rev, tcp->fd, EV_READ | EV_PERSIST, session_read, tcp); - event_add(&tcp->rev, NULL); - - return (tcp); -} - -void -tcp_close(struct tcp_conn *tcp) -{ - evbuf_clear(&tcp->wbuf); - event_del(&tcp->rev); - close(tcp->fd); - accept_unpause(); - free(tcp->rbuf); - free(tcp); -} - void session_accept(int fd, short event, void *bula) { @@ -598,3 +566,35 @@ session_get_pdu(struct ibuf_read *r, char **b) return (dlen); } + +struct tcp_conn * +tcp_new(int fd, struct nbr *nbr) +{ + struct tcp_conn *tcp; + + if ((tcp = calloc(1, sizeof(*tcp))) == NULL) + fatal(__func__); + if ((tcp->rbuf = calloc(1, sizeof(struct ibuf_read))) == NULL) + fatal(__func__); + + if (nbr) + tcp->nbr = nbr; + + tcp->fd = fd; + evbuf_init(&tcp->wbuf, tcp->fd, session_write, tcp); + event_set(&tcp->rev, tcp->fd, EV_READ | EV_PERSIST, session_read, tcp); + event_add(&tcp->rev, NULL); + + return (tcp); +} + +void +tcp_close(struct tcp_conn *tcp) +{ + evbuf_clear(&tcp->wbuf); + event_del(&tcp->rev); + close(tcp->fd); + accept_unpause(); + free(tcp->rbuf); + free(tcp); +} diff --git a/usr.sbin/ldpd/printconf.c b/usr.sbin/ldpd/printconf.c index d2f5b7e6b3f..dd6a6b8266c 100644 --- a/usr.sbin/ldpd/printconf.c +++ b/usr.sbin/ldpd/printconf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: printconf.c,v 1.13 2016/05/23 15:43:11 renato Exp $ */ +/* $OpenBSD: printconf.c,v 1.14 2016/05/23 15:47:24 renato Exp $ */ /* * Copyright (c) 2004, 2005, 2008 Esben Norby <norby@openbsd.org> @@ -84,25 +84,6 @@ print_nbrp(struct nbr_params *nbrp) } void -print_pw(struct l2vpn_pw *pw) -{ - printf("\tpseudowire %s {\n", pw->ifname); - if (pw->addr.s_addr != INADDR_ANY) - printf("\t\tneighbor %s\n", inet_ntoa(pw->addr)); - if (pw->pwid != 0) - printf("\t\tpw-id %u\n", pw->pwid); - if (pw->flags & F_PW_STATUSTLV_CONF) - printf("\t\tstatus-tlv yes\n"); - else - printf("\t\tstatus-tlv no\n"); - if (pw->flags & F_PW_CONTROLWORD_CONF) - printf("\t\tcontrol-word yes\n"); - else - printf("\t\tcontrol-word no\n"); - printf("\t}\n"); -} - -void print_l2vpn(struct l2vpn *l2vpn) { struct l2vpn_if *lif; @@ -125,6 +106,25 @@ print_l2vpn(struct l2vpn *l2vpn) } void +print_pw(struct l2vpn_pw *pw) +{ + printf("\tpseudowire %s {\n", pw->ifname); + if (pw->addr.s_addr != INADDR_ANY) + printf("\t\tneighbor %s\n", inet_ntoa(pw->addr)); + if (pw->pwid != 0) + printf("\t\tpw-id %u\n", pw->pwid); + if (pw->flags & F_PW_STATUSTLV_CONF) + printf("\t\tstatus-tlv yes\n"); + else + printf("\t\tstatus-tlv no\n"); + if (pw->flags & F_PW_CONTROLWORD_CONF) + printf("\t\tcontrol-word yes\n"); + else + printf("\t\tcontrol-word no\n"); + printf("\t}\n"); +} + +void print_config(struct ldpd_conf *conf) { struct iface *iface; |