summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrenato <renato@openbsd.org>2016-05-23 18:44:47 +0000
committerrenato <renato@openbsd.org>2016-05-23 18:44:47 +0000
commite5099c8bab9bd76dba661cdfc8a1f5d9bee1cd66 (patch)
tree12bb60b585fede268e13b9c95baed16d6b006096
parentUse SO_BINDANY before binding sockets to the transport-address. (diff)
downloadwireguard-openbsd-e5099c8bab9bd76dba661cdfc8a1f5d9bee1cd66.tar.xz
wireguard-openbsd-e5099c8bab9bd76dba661cdfc8a1f5d9bee1cd66.zip
Simplify label allocation.
Whenever we lose a route, unset the local label. If the same route is learned again later, allocate a new label for it. No need to be economic with labels, it's not worth the added complexity.
-rw-r--r--usr.sbin/ldpd/lde_lib.c30
1 files changed, 7 insertions, 23 deletions
diff --git a/usr.sbin/ldpd/lde_lib.c b/usr.sbin/ldpd/lde_lib.c
index 133a819c24a..1f63fa48608 100644
--- a/usr.sbin/ldpd/lde_lib.c
+++ b/usr.sbin/ldpd/lde_lib.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lde_lib.c,v 1.51 2016/05/23 18:32:24 renato Exp $ */
+/* $OpenBSD: lde_lib.c,v 1.52 2016/05/23 18:44:47 renato Exp $ */
/*
* Copyright (c) 2009 Michele Marchetto <michele@openbsd.org>
@@ -327,28 +327,11 @@ lde_kernel_insert(struct fec *fec, struct in_addr nexthop, int connected,
if (fn->fec.type == FEC_TYPE_PWID)
fn->data = data;
- if (LIST_EMPTY(&fn->nexthops)) {
- if (fn->local_label == NO_LABEL) {
- if (connected)
- fn->local_label = egress_label(fn->fec.type);
- else
- fn->local_label = lde_assign_label();
- } else {
- /* Handle local label changes */
- if (connected &&
- fn->local_label < MPLS_LABEL_RESERVED_MAX) {
- /* explicit withdraw of the previous label */
- lde_send_labelwithdraw_all(fn, NO_LABEL);
- fn->local_label = egress_label(fn->fec.type);
- }
-
- if (!connected &&
- fn->local_label < MPLS_LABEL_RESERVED_MAX) {
- /* explicit withdraw of the previous label */
- lde_send_labelwithdraw_all(fn, NO_LABEL);
- fn->local_label = lde_assign_label();
- }
- }
+ if (fn->local_label == NO_LABEL) {
+ if (connected)
+ fn->local_label = egress_label(fn->fec.type);
+ else
+ fn->local_label = lde_assign_label();
/* FEC.1: perform lsr label distribution procedure */
RB_FOREACH(ln, nbr_tree, &lde_nbrs)
@@ -402,6 +385,7 @@ lde_kernel_remove(struct fec *fec, struct in_addr nexthop)
fec_nh_del(fnh);
if (LIST_EMPTY(&fn->nexthops)) {
lde_send_labelwithdraw_all(fn, NO_LABEL);
+ fn->local_label = NO_LABEL;
if (fn->fec.type == FEC_TYPE_PWID)
fn->data = NULL;
}