summaryrefslogtreecommitdiff
path: root/usr.sbin/ldpd
diff options
context:
space:
mode:
authorMichele Marchetto <michele@cvs.openbsd.org>2009-09-28 09:48:47 +0000
committerMichele Marchetto <michele@cvs.openbsd.org>2009-09-28 09:48:47 +0000
commitc78baa5089cacd1d34ee1a8f76a8224c59c2aa6c (patch)
tree22584262af86344cadb050ee52d5d79aab032af6 /usr.sbin/ldpd
parentdd3b5c104c98aeb98ed009a467cbc53745b7ecbe (diff)
When a route is deleted, ldpd should remove labels associated with it from
lfib (the kernel lib) but not from the lib. These could be used later on when the route come back. ok claudio@
Diffstat (limited to 'usr.sbin/ldpd')
-rw-r--r--usr.sbin/ldpd/kroute.c17
-rw-r--r--usr.sbin/ldpd/lde.c21
-rw-r--r--usr.sbin/ldpd/lde.h3
-rw-r--r--usr.sbin/ldpd/lde_lib.c35
-rw-r--r--usr.sbin/ldpd/ldpd.h3
5 files changed, 49 insertions, 30 deletions
diff --git a/usr.sbin/ldpd/kroute.c b/usr.sbin/ldpd/kroute.c
index 0e8b50be5f1..2c20f48e54e 100644
--- a/usr.sbin/ldpd/kroute.c
+++ b/usr.sbin/ldpd/kroute.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kroute.c,v 1.4 2009/08/06 09:07:49 michele Exp $ */
+/* $OpenBSD: kroute.c,v 1.5 2009/09/28 09:48:46 michele Exp $ */
/*
* Copyright (c) 2009 Michele Marchetto <michele@openbsd.org>
@@ -412,7 +412,7 @@ kr_redist_remove(struct kroute_node *kn)
rr.kr = kn->r;
if (kn == NULL) {
- main_imsg_compose_lde(IMSG_NETWORK_DEL, 0, &rr,
+ main_imsg_compose_lde(IMSG_NETWORK_DEL, 0, &rr.kr,
sizeof(struct rroute));
}
}
@@ -484,7 +484,7 @@ kr_redistribute(struct kroute_node *kh)
sizeof(struct rroute));
} else {
rr.kr = kh->r;
- main_imsg_compose_lde(IMSG_NETWORK_DEL, 0, &rr,
+ main_imsg_compose_lde(IMSG_NETWORK_DEL, 0, &rr.kr,
sizeof(struct rroute));
}
}
@@ -1530,14 +1530,15 @@ dispatch_rtmsg(void)
continue;
if (!(kr->r.flags & F_KERNEL))
continue;
- /*
- * last route is getting removed request the
- * ldp route from the RDE to insert instead
- */
+
if (kr->r.flags & F_LDPD_INSERTED) {
- main_imsg_compose_lde(IMSG_KROUTE_GET, 0,
+ main_imsg_compose_lde(IMSG_NETWORK_DEL, 0,
&kr->r, sizeof(struct kroute));
+
+ send_rtlabelmsg(kr_state.fd, RTM_DELETE,
+ &kr->r, AF_MPLS);
}
+
if (kroute_remove(kr) == -1)
return (-1);
break;
diff --git a/usr.sbin/ldpd/lde.c b/usr.sbin/ldpd/lde.c
index f9756334754..521d7076356 100644
--- a/usr.sbin/ldpd/lde.c
+++ b/usr.sbin/ldpd/lde.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lde.c,v 1.5 2009/08/01 13:30:55 michele Exp $ */
+/* $OpenBSD: lde.c,v 1.6 2009/09/28 09:48:46 michele Exp $ */
/*
* Copyright (c) 2004, 2005 Claudio Jeker <claudio@openbsd.org>
@@ -385,15 +385,6 @@ lde_dispatch_parent(int fd, short event, void *bula)
break;
case IMSG_NETWORK_DEL:
- if (imsg.hdr.len != IMSG_HEADER_SIZE + sizeof(rr)) {
- log_warnx("lde_dispatch_parent: "
- "wrong imsg len");
- break;
- }
- memcpy(&rr, imsg.data, sizeof(rr));
-
- break;
- case IMSG_KROUTE_GET:
if (imsg.hdr.len != IMSG_HEADER_SIZE + sizeof(kr)) {
log_warnx("lde_dispatch_parent: "
"wrong imsg len");
@@ -401,14 +392,8 @@ lde_dispatch_parent(int fd, short event, void *bula)
}
memcpy(&kr, imsg.data, sizeof(kr));
-/* if ((rn = rt_find(kr.prefix.s_addr, kr.prefixlen,
- DT_NET)) != NULL)
- lde_send_change_kroute(rn);
- else*/
- /* should not happen */
- imsg_compose_event(iev_main,
- IMSG_KLABEL_DELETE, 0,
- 0, -1, &kr, sizeof(kr));
+ lde_kernel_remove(&kr);
+
break;
case IMSG_RECONF_CONF:
if ((nconf = malloc(sizeof(struct ldpd_conf))) ==
diff --git a/usr.sbin/ldpd/lde.h b/usr.sbin/ldpd/lde.h
index a338ee9d33c..e93079bd4eb 100644
--- a/usr.sbin/ldpd/lde.h
+++ b/usr.sbin/ldpd/lde.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: lde.h,v 1.4 2009/07/08 18:59:29 michele Exp $ */
+/* $OpenBSD: lde.h,v 1.5 2009/09/28 09:48:46 michele Exp $ */
/*
* Copyright (c) 2004, 2005 Esben Norby <norby@openbsd.org>
@@ -123,6 +123,7 @@ void route_start_garbage(struct rt_node *);
void rt_dump(pid_t);
void rt_snap(u_int32_t);
void lde_kernel_insert(struct kroute *);
+void lde_kernel_remove(struct kroute *);
void lde_check_mapping(struct map *, struct lde_nbr *);
void lde_check_request(struct map *, struct lde_nbr *);
diff --git a/usr.sbin/ldpd/lde_lib.c b/usr.sbin/ldpd/lde_lib.c
index cb9bfaf0d93..a6022a83dd5 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.5 2009/08/02 16:19:17 michele Exp $ */
+/* $OpenBSD: lde_lib.c,v 1.6 2009/09/28 09:48:46 michele Exp $ */
/*
* Copyright (c) 2009 Michele Marchetto <michele@openbsd.org>
@@ -253,6 +253,39 @@ lde_kernel_insert(struct kroute *kr)
}
void
+lde_kernel_remove(struct kroute *kr)
+{
+ struct rt_node *rn;
+ struct rt_label *rl;
+ struct lde_nbr *ln;
+
+ rn = rt_find(kr->prefix.s_addr, kr->prefixlen);
+ if (rn == NULL)
+ return;
+
+ if (ldeconf->mode & MODE_RET_LIBERAL) {
+ rl = calloc(1, sizeof(*rl));
+ if (rl == NULL)
+ fatal("lde_kernel_remove");
+
+ rl->label = rn->remote_label;
+
+ ln = lde_find_address(rn->nexthop);
+ if (ln == NULL)
+ fatalx("lde_kernel_remove: unable to find neighbor");
+
+ rl->nexthop = ln;
+
+ TAILQ_INSERT_TAIL(&rn->labels_list, rl, entry);
+ }
+
+ /* XXX */
+ rn->remote_label = 0;
+ rn->nexthop.s_addr = INADDR_ANY;
+ rn->present = 0;
+}
+
+void
lde_check_mapping(struct map *map, struct lde_nbr *ln)
{
struct rt_node *rn;
diff --git a/usr.sbin/ldpd/ldpd.h b/usr.sbin/ldpd/ldpd.h
index a11a559e420..3f8eb00f3ce 100644
--- a/usr.sbin/ldpd/ldpd.h
+++ b/usr.sbin/ldpd/ldpd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ldpd.h,v 1.6 2009/08/02 16:19:17 michele Exp $ */
+/* $OpenBSD: ldpd.h,v 1.7 2009/09/28 09:48:46 michele Exp $ */
/*
* Copyright (c) 2009 Michele Marchetto <michele@openbsd.org>
@@ -80,7 +80,6 @@ enum imsg_type {
IMSG_KLABEL_INSERT,
IMSG_KLABEL_CHANGE,
IMSG_KLABEL_DELETE,
- IMSG_KROUTE_GET,
IMSG_IFINFO,
IMSG_LABEL_MAPPING,
IMSG_LABEL_MAPPING_FULL,