diff options
author | Michele Marchetto <michele@cvs.openbsd.org> | 2009-07-08 18:59:30 +0000 |
---|---|---|
committer | Michele Marchetto <michele@cvs.openbsd.org> | 2009-07-08 18:59:30 +0000 |
commit | 1a838fcea6c58b59fc1f2b532cbd5e8fd30c7ab9 (patch) | |
tree | d1f98d0211dd27b7694ef7c5c8b837b09cef5eeb /usr.sbin/ldpd | |
parent | 51eb81e3c3167978214bdd81a76722772aaaa3a6 (diff) |
Detect nexthop change.
React installing the label associated with the new nexthop
in the kernel routing table.
ok claudio@
Diffstat (limited to 'usr.sbin/ldpd')
-rw-r--r-- | usr.sbin/ldpd/lde.c | 4 | ||||
-rw-r--r-- | usr.sbin/ldpd/lde.h | 4 | ||||
-rw-r--r-- | usr.sbin/ldpd/lde_lib.c | 35 |
3 files changed, 34 insertions, 9 deletions
diff --git a/usr.sbin/ldpd/lde.c b/usr.sbin/ldpd/lde.c index 70388472227..913300bcd12 100644 --- a/usr.sbin/ldpd/lde.c +++ b/usr.sbin/ldpd/lde.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lde.c,v 1.3 2009/06/06 08:09:43 pyr Exp $ */ +/* $OpenBSD: lde.c,v 1.4 2009/07/08 18:59:29 michele Exp $ */ /* * Copyright (c) 2004, 2005 Claudio Jeker <claudio@openbsd.org> @@ -381,7 +381,7 @@ lde_dispatch_parent(int fd, short event, void *bula) } memcpy(&rr, imsg.data, sizeof(rr)); - lde_insert(&rr.kr); + lde_kernel_insert(&rr.kr); break; case IMSG_NETWORK_DEL: diff --git a/usr.sbin/ldpd/lde.h b/usr.sbin/ldpd/lde.h index 8023e6d6a32..a338ee9d33c 100644 --- a/usr.sbin/ldpd/lde.h +++ b/usr.sbin/ldpd/lde.h @@ -1,4 +1,4 @@ -/* $OpenBSD: lde.h,v 1.3 2009/06/19 17:10:09 michele Exp $ */ +/* $OpenBSD: lde.h,v 1.4 2009/07/08 18:59:29 michele Exp $ */ /* * Copyright (c) 2004, 2005 Esben Norby <norby@openbsd.org> @@ -122,7 +122,7 @@ int route_start_timeout(struct rt_node *); void route_start_garbage(struct rt_node *); void rt_dump(pid_t); void rt_snap(u_int32_t); -void lde_insert(struct kroute *); +void lde_kernel_insert(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 cc6b4bdfe22..a6a71d53614 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.3 2009/06/19 17:10:09 michele Exp $ */ +/* $OpenBSD: lde_lib.c,v 1.4 2009/07/08 18:59:29 michele Exp $ */ /* * Copyright (c) 2009 Michele Marchetto <michele@openbsd.org> @@ -162,7 +162,7 @@ lde_assign_label() } void -lde_insert(struct kroute *kr) +lde_kernel_insert(struct kroute *kr) { struct rt_node *rn; struct rt_label *rl; @@ -181,8 +181,35 @@ lde_insert(struct kroute *kr) rt_insert(rn); } - if (rn->present) + if (rn->present) { + if (kr->nexthop.s_addr == rn->nexthop.s_addr) + return; + + /* The nexthop has changed, change also the label associated + with prefix */ + rn->remote_label = 0; + rn->nexthop.s_addr = kr->nexthop.s_addr; + + if ((ldeconf->mode & MODE_RET_LIBERAL) == 0) { + /* XXX: we support just liberal retention for now */ + return; + } + + TAILQ_FOREACH(rl, &rn->labels_list, entry) { + addr = lde_address_find(rl->nexthop, &rn->nexthop); + if (addr != NULL) { + rn->remote_label = + htonl(rl->label << MPLS_LABEL_OFFSET); + break; + } + } + + log_debug("lde_kernel_insert: prefix %s, changing label to %u", + inet_ntoa(rn->prefix), rl->label); + + lde_send_change_klabel(rn); return; + } rn->present = 1; rn->nexthop.s_addr = kr->nexthop.s_addr; @@ -201,8 +228,6 @@ lde_insert(struct kroute *kr) if (addr != NULL) { rn->remote_label = htonl(rl->label << MPLS_LABEL_OFFSET); - TAILQ_REMOVE(&rn->labels_list, rl, entry); - free(rl); break; } } |