diff options
| author | Renato Westphal <renato@opensourcerouting.org> | 2017-02-03 11:09:27 -0200 |
|---|---|---|
| committer | Renato Westphal <renato@opensourcerouting.org> | 2017-02-06 13:05:41 -0200 |
| commit | 8cb1fc4537e2bc44a021c988b4c5d08618975924 (patch) | |
| tree | ddd9e48906f3d622515e1fa37a6fedbe2d4f61ef /ldpd/ldp_zebra.c | |
| parent | f460ecf9a7f35e3ddb5f0d11d6623420c23b22cd (diff) | |
ldpd: update local labels when necessary
ldpd allocates null labels for directly connected routes. If a connected
route is removed (interface goes down) and an IGP learned route takes its
place in the RIB, ldpd must update the local label of the associated FEC
entry with a non-null label. The same applies for the other way around
(an interface goes up and a connected route is selected in favour of an
IGP route). Labels should be dynamic and change when necessary.
Additionally, this patch fixes the processing of route delete messages
from zebra. Route delete messages don't contain any nexthop, meaning that
whenever we receive such messages we must delete all nexthop previously
received.
Based on a patch from Bingen Eguzkitza <bingen@voltanet.io>.
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
Diffstat (limited to 'ldpd/ldp_zebra.c')
| -rw-r--r-- | ldpd/ldp_zebra.c | 46 |
1 files changed, 26 insertions, 20 deletions
diff --git a/ldpd/ldp_zebra.c b/ldpd/ldp_zebra.c index 79c4f5b377..12954b91af 100644 --- a/ldpd/ldp_zebra.c +++ b/ldpd/ldp_zebra.c @@ -353,7 +353,7 @@ ldp_zebra_read_route(int command, struct zclient *zclient, zebra_size_t length, u_char type; u_char message_flags; struct kroute kr; - int nhnum, nhlen; + int nhnum = 0, nhlen; size_t nhmark; memset(&kr, 0, sizeof(kr)); @@ -374,8 +374,6 @@ ldp_zebra_read_route(int command, struct zclient *zclient, zebra_size_t length, stream_getl(s); /* flags, unused */ stream_getw(s); /* instance, unused */ message_flags = stream_getc(s); - if (!CHECK_FLAG(message_flags, ZAPI_MESSAGE_NEXTHOP)) - return (0); switch (command) { case ZEBRA_REDISTRIBUTE_IPV4_ADD: @@ -409,16 +407,35 @@ ldp_zebra_read_route(int command, struct zclient *zclient, zebra_size_t length, return (0); } - nhnum = stream_getc(s); - nhmark = stream_get_getp(s); - stream_set_getp(s, nhmark + nhnum * (nhlen + 5)); + if (CHECK_FLAG(message_flags, ZAPI_MESSAGE_NEXTHOP)) { + nhnum = stream_getc(s); + nhmark = stream_get_getp(s); + stream_set_getp(s, nhmark + nhnum * (nhlen + 5)); + } if (CHECK_FLAG(message_flags, ZAPI_MESSAGE_DISTANCE)) kr.priority = stream_getc(s); if (CHECK_FLAG(message_flags, ZAPI_MESSAGE_METRIC)) stream_getl(s); /* metric, not used */ - stream_set_getp(s, nhmark); + if (CHECK_FLAG(message_flags, ZAPI_MESSAGE_NEXTHOP)) + stream_set_getp(s, nhmark); + + if (nhnum == 0) { + switch (command) { + case ZEBRA_REDISTRIBUTE_IPV4_ADD: + case ZEBRA_REDISTRIBUTE_IPV6_ADD: + return (0); + case ZEBRA_REDISTRIBUTE_IPV4_DEL: + case ZEBRA_REDISTRIBUTE_IPV6_DEL: + debug_zebra_in("route delete %s/%d (%s)", + log_addr(kr.af, &kr.prefix), kr.prefixlen, + zebra_route_string(type)); + break; + default: + fatalx("ldp_zebra_read_route: unknown command"); + } + } /* loop through all the nexthops */ for (; nhnum > 0; nhnum--) { @@ -445,23 +462,12 @@ ldp_zebra_read_route(int command, struct zclient *zclient, zebra_size_t length, main_imsg_compose_lde(IMSG_NETWORK_ADD, 0, &kr, sizeof(kr)); break; - case ZEBRA_REDISTRIBUTE_IPV4_DEL: - case ZEBRA_REDISTRIBUTE_IPV6_DEL: - debug_zebra_in("route delete %s/%d nexthop %s " - "ifindex %u (%s)", log_addr(kr.af, &kr.prefix), - kr.prefixlen, log_addr(kr.af, &kr.nexthop), - kr.ifindex, zebra_route_string(type)); - main_imsg_compose_lde(IMSG_NETWORK_DEL, 0, &kr, - sizeof(kr)); - break; default: - fatalx("ldp_zebra_read_route: unknown command"); + break; } } - if (command == ZEBRA_REDISTRIBUTE_IPV4_ADD || - command == ZEBRA_REDISTRIBUTE_IPV6_ADD) - main_imsg_compose_lde(IMSG_NETWORK_ADD_END, 0, &kr, sizeof(kr)); + main_imsg_compose_lde(IMSG_NETWORK_UPDATE, 0, &kr, sizeof(kr)); return (0); } |
