diff options
author | 2010-07-08 09:41:05 +0000 | |
---|---|---|
committer | 2010-07-08 09:41:05 +0000 | |
commit | 460e740251406e2fc175713cd485ed8c6fece2a0 (patch) | |
tree | 71d0af577721618017febdceca585024eb1f1bb0 | |
parent | minor tweak from Brad; add the word 'chips' after a list of devices (diff) | |
download | wireguard-openbsd-460e740251406e2fc175713cd485ed8c6fece2a0.tar.xz wireguard-openbsd-460e740251406e2fc175713cd485ed8c6fece2a0.zip |
Kill more code in kroute.c that is unneeded in ldpd. ldpd is a bit strange
since it does not care that much about reachability of routes. The idea is
to have diverse LSP in the kernel and the kernel should then decide which
path should be used.
OK michele@
-rw-r--r-- | usr.sbin/ldpd/kroute.c | 83 | ||||
-rw-r--r-- | usr.sbin/ldpd/ldpd.c | 4 | ||||
-rw-r--r-- | usr.sbin/ldpd/ldpd.h | 17 | ||||
-rw-r--r-- | usr.sbin/ldpd/ldpe.c | 15 |
4 files changed, 27 insertions, 92 deletions
diff --git a/usr.sbin/ldpd/kroute.c b/usr.sbin/ldpd/kroute.c index 36aaf1e6ece..5a41668f44f 100644 --- a/usr.sbin/ldpd/kroute.c +++ b/usr.sbin/ldpd/kroute.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kroute.c,v 1.18 2010/06/30 05:27:56 claudio Exp $ */ +/* $OpenBSD: kroute.c,v 1.19 2010/07/08 09:41:05 claudio Exp $ */ /* * Copyright (c) 2009 Michele Marchetto <michele@openbsd.org> @@ -83,7 +83,6 @@ int kif_remove(struct kif_node *); void kif_clear(void); struct kif *kif_update(u_short, int, struct if_data *, struct sockaddr_dl *); -int kif_validate(u_short); struct kroute_node *kroute_match(in_addr_t); @@ -235,12 +234,10 @@ kr_delete_fib(struct kroute_node *kr) if (!(kr->r.flags & F_LDPD_INSERTED)) return (0); - if (kr->r.flags & F_KERNEL) { - /* remove F_LDPD_INSERTED flag, route still exists in kernel */ - kr->r.flags &= ~F_LDPD_INSERTED; - return (0); - } + /* remove F_LDPD_INSERTED flag, route still exists in kernel */ + kr->r.flags &= ~F_LDPD_INSERTED; + /* kill MPLS LSP */ if (send_rtmsg(kr_state.fd, RTM_DELETE, &kr->r, AF_MPLS) == -1) return (-1); @@ -425,18 +422,10 @@ kr_redist_eval(struct kroute *kr) { u_int32_t a; - /* Only static routes are considered for redistribution. */ - if (!(kr->flags & F_KERNEL)) - goto dont_redistribute; - /* Dynamic routes are not redistributable. */ if (kr->flags & F_DYNAMIC) goto dont_redistribute; - /* interface is not up and running so don't announce */ - if (kr->flags & F_DOWN) - goto dont_redistribute; - /* * We consider the loopback net, multicast and experimental addresses * as not redistributable. @@ -595,16 +584,6 @@ kroute_insert(struct kroute_node *kr) } else krm = kr; - if (!(kr->r.flags & F_KERNEL)) { - kr->r.flags &= ~F_DOWN; - return (0); - } - - if (kif_validate(kr->r.ifindex)) - kr->r.flags &= ~F_DOWN; - else - kr->r.flags |= F_DOWN; - kr_redistribute(krm); return (0); } @@ -749,10 +728,6 @@ kif_update(u_short ifindex, int flags, struct if_data *ifd, if ((kif = kif_find(ifindex)) == NULL) { if ((kif = kif_insert(ifindex)) == NULL) return (NULL); - kif->k.nh_reachable = (flags & IFF_UP) && - (LINK_STATE_IS_UP(ifd->ifi_link_state) || - (ifd->ifi_link_state == LINK_STATE_UNKNOWN && - ifd->ifi_type != IFT_CARP)); } kif->k.flags = flags; @@ -774,19 +749,6 @@ kif_update(u_short ifindex, int flags, struct if_data *ifd, return (&kif->k); } -int -kif_validate(u_short ifindex) -{ - struct kif_node *kif; - - if ((kif = kif_find(ifindex)) == NULL) { - log_warnx("interface with index %u not found", ifindex); - return (1); - } - - return (kif->k.nh_reachable); -} - struct kroute_node * kroute_match(in_addr_t key) { @@ -819,7 +781,7 @@ protect_lo(void) } kr->r.prefix.s_addr = htonl(INADDR_LOOPBACK & IN_CLASSA_NET); kr->r.prefixlen = 8; - kr->r.flags = F_KERNEL|F_CONNECTED; + kr->r.flags = F_CONNECTED; kr->r.local_label = NO_LABEL; kr->r.remote_label = NO_LABEL; @@ -886,41 +848,15 @@ void if_change(u_short ifindex, int flags, struct if_data *ifd, struct sockaddr_dl *sdl) { - struct kroute_node *kr, *tkr; struct kif *kif; - u_int8_t reachable; if ((kif = kif_update(ifindex, flags, ifd, sdl)) == NULL) { log_warn("if_change: kif_update(%u)", ifindex); return; } - reachable = (kif->flags & IFF_UP) && - (LINK_STATE_IS_UP(kif->link_state) || - (kif->link_state == LINK_STATE_UNKNOWN && - kif->media_type != IFT_CARP)); - - if (reachable == kif->nh_reachable) - return; /* nothing changed wrt nexthop validity */ - - kif->nh_reachable = reachable; - /* notify ldpe about interface link state */ main_imsg_compose_ldpe(IMSG_IFINFO, 0, kif, sizeof(struct kif)); - - /* update redistribute list */ - RB_FOREACH(kr, kroute_tree, &krt) { - for (tkr = kr; tkr != NULL; tkr = tkr->next) { - if (tkr->r.ifindex == ifindex) { - if (reachable) - tkr->r.flags &= ~F_DOWN; - else - tkr->r.flags |= F_DOWN; - - kr_redistribute(tkr); - } - } - } } void @@ -1272,7 +1208,7 @@ rtmsg_process(char *buf, int len) prefix.s_addr = 0; prefixlen = 0; - flags = F_KERNEL; + flags = 0; nexthop.s_addr = 0; mpath = 0; prio = 0; @@ -1377,11 +1313,6 @@ rtmsg_process(char *buf, int len) kr->r.flags = flags; kr->r.ifindex = ifindex; - if (kif_validate(kr->r.ifindex)) - kr->r.flags &= ~F_DOWN; - else - kr->r.flags |= F_DOWN; - /* just readd, the RDE will care */ kr_redistribute(kr); } else { @@ -1407,8 +1338,6 @@ add: if ((kr = kroute_find(prefix.s_addr, prefixlen, prio)) == NULL) continue; - if (!(kr->r.flags & F_KERNEL)) - continue; /* get the correct route */ okr = kr; if (mpath && diff --git a/usr.sbin/ldpd/ldpd.c b/usr.sbin/ldpd/ldpd.c index d63bcd1ce44..d665152af24 100644 --- a/usr.sbin/ldpd/ldpd.c +++ b/usr.sbin/ldpd/ldpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ldpd.c,v 1.10 2010/06/30 05:21:38 claudio Exp $ */ +/* $OpenBSD: ldpd.c,v 1.11 2010/07/08 09:41:05 claudio Exp $ */ /* * Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org> @@ -463,6 +463,8 @@ main_dispatch_lde(int fd, short event, void *bula) void main_imsg_compose_ldpe(int type, pid_t pid, void *data, u_int16_t datalen) { + if (iev_ldpe == NULL) + return; imsg_compose_event(iev_ldpe, type, 0, pid, -1, data, datalen); } diff --git a/usr.sbin/ldpd/ldpd.h b/usr.sbin/ldpd/ldpd.h index 2aedb6147a0..d218f0a102a 100644 --- a/usr.sbin/ldpd/ldpd.h +++ b/usr.sbin/ldpd/ldpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ldpd.h,v 1.23 2010/06/30 05:21:38 claudio Exp $ */ +/* $OpenBSD: ldpd.h,v 1.24 2010/07/08 09:41:05 claudio Exp $ */ /* * Copyright (c) 2009 Michele Marchetto <michele@openbsd.org> @@ -49,14 +49,12 @@ #define LDPD_FLAG_NO_LFIB_UPDATE 0x0001 #define F_LDPD_INSERTED 0x0001 -#define F_KERNEL 0x0002 -#define F_CONNECTED 0x0004 -#define F_STATIC 0x0008 -#define F_DYNAMIC 0x0010 -#define F_DOWN 0x0020 -#define F_REJECT 0x0040 -#define F_BLACKHOLE 0x0080 -#define F_REDISTRIBUTED 0x0100 +#define F_CONNECTED 0x0002 +#define F_STATIC 0x0004 +#define F_DYNAMIC 0x0008 +#define F_REJECT 0x0010 +#define F_BLACKHOLE 0x0020 +#define F_REDISTRIBUTED 0x0040 struct evbuf { struct msgbuf wbuf; @@ -294,7 +292,6 @@ struct kif { u_short ifindex; u_int8_t media_type; u_int8_t link_state; - u_int8_t nh_reachable; /* for nexthop verification */ }; /* control data structures */ diff --git a/usr.sbin/ldpd/ldpe.c b/usr.sbin/ldpd/ldpe.c index 14a410f38c2..a2b802a0a5b 100644 --- a/usr.sbin/ldpd/ldpe.c +++ b/usr.sbin/ldpd/ldpe.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ldpe.c,v 1.10 2010/05/26 13:56:07 nicm Exp $ */ +/* $OpenBSD: ldpe.c,v 1.11 2010/07/08 09:41:05 claudio Exp $ */ /* * Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org> @@ -282,7 +282,7 @@ ldpe_dispatch_main(int fd, short event, void *bula) struct imsgbuf *ibuf = &iev->ibuf; struct iface *iface = NULL; struct kif *kif; - int n, link_ok, shut = 0; + int n, link_new, link_old, shut = 0; if (event & EV_READ) { if ((n = imsg_read(ibuf)) == -1) @@ -307,17 +307,24 @@ ldpe_dispatch_main(int fd, short event, void *bula) sizeof(struct kif)) fatalx("IFINFO imsg with wrong len"); kif = imsg.data; - link_ok = (kif->flags & IFF_UP) && + link_new = (kif->flags & IFF_UP) && (LINK_STATE_IS_UP(kif->link_state) || (kif->link_state == LINK_STATE_UNKNOWN && kif->media_type != IFT_CARP)); LIST_FOREACH(iface, &leconf->iface_list, entry) { if (kif->ifindex == iface->ifindex) { + link_old = (iface->flags & IFF_UP) && + (LINK_STATE_IS_UP(iface->linkstate) + || (iface->linkstate == + LINK_STATE_UNKNOWN && + iface->media_type != IFT_CARP)); iface->flags = kif->flags; iface->linkstate = kif->link_state; - if (link_ok) { + if (link_new == link_old) + continue; + if (link_new) { if_fsm(iface, IF_EVT_UP); log_warnx("interface %s up", iface->name); |