2002-12-13 21:15:29 +01:00
|
|
|
/*
|
2004-05-18 20:57:06 +02:00
|
|
|
* Copyright (C) 2003 Yasuhiro Ohara
|
2002-12-13 21:15:29 +01:00
|
|
|
*
|
|
|
|
* This file is part of GNU Zebra.
|
|
|
|
*
|
|
|
|
* GNU Zebra is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License as published by the
|
|
|
|
* Free Software Foundation; either version 2, or (at your option) any
|
|
|
|
* later version.
|
|
|
|
*
|
|
|
|
* GNU Zebra is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* General Public License for more details.
|
|
|
|
*
|
2017-05-13 10:25:29 +02:00
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; see the file COPYING; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
2002-12-13 21:15:29 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <zebra.h>
|
|
|
|
|
|
|
|
#include "log.h"
|
|
|
|
#include "memory.h"
|
|
|
|
#include "prefix.h"
|
|
|
|
#include "command.h"
|
|
|
|
#include "vty.h"
|
|
|
|
#include "routemap.h"
|
|
|
|
#include "table.h"
|
|
|
|
#include "plist.h"
|
|
|
|
#include "thread.h"
|
2004-05-18 20:57:06 +02:00
|
|
|
#include "linklist.h"
|
2020-10-30 08:42:34 +01:00
|
|
|
#include "lib/northbound_cli.h"
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
#include "ospf6_proto.h"
|
|
|
|
#include "ospf6_lsa.h"
|
|
|
|
#include "ospf6_lsdb.h"
|
|
|
|
#include "ospf6_route.h"
|
2002-12-13 21:15:29 +01:00
|
|
|
#include "ospf6_zebra.h"
|
2004-08-15 07:52:07 +02:00
|
|
|
#include "ospf6_message.h"
|
2021-02-10 07:44:44 +01:00
|
|
|
#include "ospf6_spf.h"
|
2004-08-15 07:52:07 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
#include "ospf6_top.h"
|
2021-05-05 22:19:01 +02:00
|
|
|
#include "ospf6d.h"
|
2004-05-18 20:57:06 +02:00
|
|
|
#include "ospf6_area.h"
|
2004-08-15 07:52:07 +02:00
|
|
|
#include "ospf6_interface.h"
|
|
|
|
#include "ospf6_neighbor.h"
|
2004-05-18 20:57:06 +02:00
|
|
|
#include "ospf6_asbr.h"
|
2020-10-08 07:38:43 +02:00
|
|
|
#include "ospf6_abr.h"
|
2004-05-18 20:57:06 +02:00
|
|
|
#include "ospf6_intra.h"
|
2004-08-15 07:52:07 +02:00
|
|
|
#include "ospf6_flood.h"
|
2021-09-07 00:52:32 +02:00
|
|
|
#include "ospf6_nssa.h"
|
2004-08-04 22:02:13 +02:00
|
|
|
#include "ospf6d.h"
|
2021-03-25 12:29:51 +01:00
|
|
|
#include "ospf6_spf.h"
|
|
|
|
#include "ospf6_nssa.h"
|
2021-07-02 18:01:32 +02:00
|
|
|
#include "ospf6_gr.h"
|
2020-09-28 07:25:10 +02:00
|
|
|
#include "lib/json.h"
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2021-03-22 19:31:56 +01:00
|
|
|
DEFINE_MTYPE_STATIC(OSPF6D, OSPF6_EXTERNAL_INFO, "OSPF6 ext. info");
|
|
|
|
DEFINE_MTYPE_STATIC(OSPF6D, OSPF6_DIST_ARGS, "OSPF6 Distribute arguments");
|
|
|
|
DEFINE_MTYPE_STATIC(OSPF6D, OSPF6_REDISTRIBUTE, "OSPF6 Redistribute arguments");
|
2021-05-28 11:33:03 +02:00
|
|
|
DEFINE_MTYPE_STATIC(OSPF6D, OSPF6_EXTERNAL_RT_AGGR, "OSPF6 ASBR Summarisation");
|
2021-03-22 19:31:56 +01:00
|
|
|
|
2021-06-22 15:09:28 +02:00
|
|
|
static void ospf6_asbr_redistribute_set(struct ospf6 *ospf6, int type);
|
2020-11-09 16:51:29 +01:00
|
|
|
static void ospf6_asbr_redistribute_unset(struct ospf6 *ospf6,
|
|
|
|
struct ospf6_redist *red, int type);
|
2020-05-05 15:18:15 +02:00
|
|
|
|
2021-02-10 05:53:46 +01:00
|
|
|
#ifndef VTYSH_EXTRACT_PL
|
|
|
|
#include "ospf6d/ospf6_asbr_clippy.c"
|
|
|
|
#endif
|
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
unsigned char conf_debug_ospf6_asbr = 0;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2005-10-01 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
* zebra.h: Declare new functions zebra_route_string() and
zebra_route_char().
* log.c: (zroute_lookup,zebra_route_string,zebra_route_char) New
functions to map zebra route numbers to strings.
* zebra_vty.c: (route_type_str) Remove obsolete function: use new
library function zebra_route_string() instead. Note that there
are a few differences: for IPv6 routes, we now get "ripng" and
"ospf6" instead of the old behavior ("rip" and "ospf").
(route_type_char) Remove obsolete function: ues new library function
zebra_route_char() instead. Note that there is one difference:
the old function returned 'S' for a ZEBRA_ROUTE_SYSTEM route,
whereas the new one returns 'X'.
(vty_show_ip_route_detail,vty_show_ipv6_route_detail) Replace
route_type_str() with zebra_route_string().
(vty_show_ip_route,vty_show_ipv6_route) Replace route_type_char()
with zebra_route_char().
* bgp_vty.c: (bgp_config_write_redistribute) Use new library function
zebra_route_string instead of a local hard-coded table.
* ospf6_asbr.c: Remove local hard-coded tables zroute_name and
zroute_abname. Change the ZROUTE_NAME macro to use new library
function zebra_route_string(). Remove the ZROUTE_ABNAME macro.
(ospf6_asbr_external_route_show): Replace ZROUTE_ABNAME() with
a call to zebra_route_char(), and be sure to fix the format string,
since we now have a char instead of a char *.
* ospf6_zebra.c: Remove local hard-coded tables zebra_route_name and
zebra_route_abname. Note that the zebra_route_name[] table
contained mixed-case strings, whereas the zebra_route_string()
function returns lower-case strings.
(ospf6_zebra_read_ipv6): Change debug message to use new library
function zebra_route_string() instead of zebra_route_name[].
(show_zebra): Use new library function zebra_route_string() instead
of zebra_route_name[].
* ospf_dump.c: Remove local hard-coded table ospf_redistributed_proto.
(ospf_redist_string) New function implemented using new library
function zebra_route_string(). Note that there are a few differences
in the output that will result: the new function returns strings
that are lower-case, whereas the old table was mixed case. Also,
the old table mapped ZEBRA_ROUTE_OSPF6 to "OSPFv3", whereas the
new function returns "ospf6".
* ospfd.h: Remove extern struct message ospf_redistributed_proto[],
and add extern const char *ospf_redist_string(u_int route_type)
instead.
* ospf_asbr.c: (ospf_external_info_add) In two messages, use
ospf_redist_string instead of LOOKUP(ospf_redistributed_proto).
* ospf_vty.c: Remove local hard-coded table distribute_str.
(config_write_ospf_redistribute,config_write_ospf_distribute): Use
new library function zebra_route_string() instead of distribute_str[].
* ospf_zebra.c: (ospf_redistribute_set,ospf_redistribute_unset,
ospf_redistribute_default_set,ospf_redistribute_check)
In debug messages, use ospf_redist_string() instead of
LOOKUP(ospf_redistributed_proto).
* rip_zebra.c: (config_write_rip_redistribute): Remove local hard-coded
table str[]. Replace str[] with calls to new library function
zebra_route_string().
* ripd.c: Remove local hard-coded table route_info[].
(show_ip_rip) Replace uses of str[] with calls to new library
functions zebra_route_char and zebra_route_string.
* ripng_zebra.c: (ripng_redistribute_write) Remove local hard-coded
table str[]. Replace str[i] with new library function
zebra_route_string(i).
* ripngd.c: Remove local hard-coded table route_info[].
(show_ipv6_ripng) Use new library function zebra_route_char() instead
of table route_info[].
2005-10-01 19:38:06 +02:00
|
|
|
#define ZROUTE_NAME(x) zebra_route_string(x)
|
2004-05-18 20:57:06 +02:00
|
|
|
|
2021-07-09 11:47:40 +02:00
|
|
|
/* Originate Type-5 and Type-7 LSA */
|
|
|
|
static struct ospf6_lsa *ospf6_originate_type5_type7_lsas(
|
|
|
|
struct ospf6_route *route,
|
|
|
|
struct ospf6 *ospf6)
|
|
|
|
{
|
|
|
|
struct ospf6_lsa *lsa;
|
|
|
|
struct listnode *lnode;
|
|
|
|
struct ospf6_area *oa = NULL;
|
|
|
|
|
|
|
|
lsa = ospf6_as_external_lsa_originate(route, ospf6);
|
|
|
|
|
|
|
|
for (ALL_LIST_ELEMENTS_RO(ospf6->area_list, lnode, oa)) {
|
|
|
|
if (IS_AREA_NSSA(oa))
|
2021-09-07 00:52:32 +02:00
|
|
|
ospf6_nssa_lsa_originate(route, oa, true);
|
2021-07-09 11:47:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return lsa;
|
|
|
|
}
|
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
/* AS External LSA origination */
|
2021-05-28 11:33:03 +02:00
|
|
|
struct ospf6_lsa *ospf6_as_external_lsa_originate(struct ospf6_route *route,
|
|
|
|
struct ospf6 *ospf6)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
2004-05-18 20:57:06 +02:00
|
|
|
char buffer[OSPF6_MAX_LSASIZE];
|
|
|
|
struct ospf6_lsa_header *lsa_header;
|
2015-05-20 03:29:14 +02:00
|
|
|
struct ospf6_lsa *lsa;
|
2006-05-15 12:47:53 +02:00
|
|
|
struct ospf6_external_info *info = route->route_option;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
struct ospf6_as_external_lsa *as_external_lsa;
|
|
|
|
caddr_t p;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2021-07-02 18:01:32 +02:00
|
|
|
if (ospf6->gr_info.restart_in_progress) {
|
|
|
|
if (IS_DEBUG_OSPF6_GR)
|
|
|
|
zlog_debug(
|
|
|
|
"Graceful Restart in progress, don't originate LSA");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2020-10-18 13:33:54 +02:00
|
|
|
if (IS_OSPF6_DEBUG_ASBR || IS_OSPF6_DEBUG_ORIGINATE(AS_EXTERNAL))
|
|
|
|
zlog_debug("Originate AS-External-LSA for %pFX",
|
|
|
|
&route->prefix);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
/* prepare buffer */
|
|
|
|
memset(buffer, 0, sizeof(buffer));
|
|
|
|
lsa_header = (struct ospf6_lsa_header *)buffer;
|
|
|
|
as_external_lsa = (struct ospf6_as_external_lsa
|
|
|
|
*)((caddr_t)lsa_header
|
|
|
|
+ sizeof(struct ospf6_lsa_header));
|
|
|
|
p = (caddr_t)((caddr_t)as_external_lsa
|
|
|
|
+ sizeof(struct ospf6_as_external_lsa));
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
/* Fill AS-External-LSA */
|
|
|
|
/* Metric type */
|
|
|
|
if (route->path.metric_type == 2)
|
|
|
|
SET_FLAG(as_external_lsa->bits_metric, OSPF6_ASBR_BIT_E);
|
|
|
|
else
|
|
|
|
UNSET_FLAG(as_external_lsa->bits_metric, OSPF6_ASBR_BIT_E);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
/* forwarding address */
|
2006-05-15 12:47:53 +02:00
|
|
|
if (!IN6_IS_ADDR_UNSPECIFIED(&info->forwarding))
|
2004-05-18 20:57:06 +02:00
|
|
|
SET_FLAG(as_external_lsa->bits_metric, OSPF6_ASBR_BIT_F);
|
|
|
|
else
|
|
|
|
UNSET_FLAG(as_external_lsa->bits_metric, OSPF6_ASBR_BIT_F);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
/* external route tag */
|
2016-10-01 06:41:40 +02:00
|
|
|
if (info->tag)
|
|
|
|
SET_FLAG(as_external_lsa->bits_metric, OSPF6_ASBR_BIT_T);
|
|
|
|
else
|
2004-05-18 20:57:06 +02:00
|
|
|
UNSET_FLAG(as_external_lsa->bits_metric, OSPF6_ASBR_BIT_T);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
/* Set metric */
|
|
|
|
OSPF6_ASBR_METRIC_SET(as_external_lsa, route->path.cost);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
/* prefixlen */
|
|
|
|
as_external_lsa->prefix.prefix_length = route->prefix.prefixlen;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
/* PrefixOptions */
|
2021-06-28 15:18:29 +02:00
|
|
|
as_external_lsa->prefix.prefix_options = route->prefix_options;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
/* don't use refer LS-type */
|
|
|
|
as_external_lsa->prefix.prefix_refer_lstype = htons(0);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
/* set Prefix */
|
|
|
|
memcpy(p, &route->prefix.u.prefix6,
|
|
|
|
OSPF6_PREFIX_SPACE(route->prefix.prefixlen));
|
|
|
|
ospf6_prefix_apply_mask(&as_external_lsa->prefix);
|
|
|
|
p += OSPF6_PREFIX_SPACE(route->prefix.prefixlen);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
/* Forwarding address */
|
|
|
|
if (CHECK_FLAG(as_external_lsa->bits_metric, OSPF6_ASBR_BIT_F)) {
|
2006-05-15 12:47:53 +02:00
|
|
|
memcpy(p, &info->forwarding, sizeof(struct in6_addr));
|
2004-05-18 20:57:06 +02:00
|
|
|
p += sizeof(struct in6_addr);
|
|
|
|
}
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
/* External Route Tag */
|
|
|
|
if (CHECK_FLAG(as_external_lsa->bits_metric, OSPF6_ASBR_BIT_T)) {
|
2016-10-01 06:41:40 +02:00
|
|
|
route_tag_t network_order = htonl(info->tag);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2016-10-01 06:41:40 +02:00
|
|
|
memcpy(p, &network_order, sizeof(network_order));
|
|
|
|
p += sizeof(network_order);
|
2004-05-18 20:57:06 +02:00
|
|
|
}
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
/* Fill LSA Header */
|
|
|
|
lsa_header->age = 0;
|
|
|
|
lsa_header->type = htons(OSPF6_LSTYPE_AS_EXTERNAL);
|
2004-08-15 07:52:07 +02:00
|
|
|
lsa_header->id = route->path.origin.id;
|
2004-05-18 20:57:06 +02:00
|
|
|
lsa_header->adv_router = ospf6->router_id;
|
|
|
|
lsa_header->seqnum =
|
2004-08-04 22:02:13 +02:00
|
|
|
ospf6_new_ls_seqnum(lsa_header->type, lsa_header->id,
|
|
|
|
lsa_header->adv_router, ospf6->lsdb);
|
2004-05-18 20:57:06 +02:00
|
|
|
lsa_header->length = htons((caddr_t)p - (caddr_t)lsa_header);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
/* LSA checksum */
|
|
|
|
ospf6_lsa_checksum(lsa_header);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
/* create LSA */
|
|
|
|
lsa = ospf6_lsa_create(lsa_header);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
/* Originate */
|
2004-08-15 07:52:07 +02:00
|
|
|
ospf6_lsa_originate_process(lsa, ospf6);
|
2021-05-28 11:33:03 +02:00
|
|
|
|
|
|
|
return lsa;
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
|
ospf6d: Handle Premature Aging of LSAs
RFC 2328 (14.1) Premature aging of LSAs from
routing domain :
When ospf6d is going away (router going down),
send MAXAGEd self originated LSAs to all
neighbors in routing domain to trigger
Premature aging to remove from resepective LSDBs.
Neighbor Router Reboot:
Upon receiving Self-originate MAXAGEd LSA, simply
discard, Current copy could be non maxaged latest.
For neighbor advertised LSA's (current copy in LSDB)
is set to MAXAGE but received new LSA with Non-MAXAGE
(with current age), discard the current MAXAGE LSA,
Send latest copy of LSA to neighbors and update the
LSDB with new LSA.
When a neighbor transition to FULL, trigger AS-External
LSAs update from external LSDB to new neighbor.
Testing:
R1 ---- DUT --- R5
| \
R2 R3
|
R4
Area 1: R5 and DUT
Area 0: DUT, R1, R2, R3
Area 2: R2 R4
Add IPv6 static routes at R5
Redistribute kernel routes at R5,
Validate routes at R4, redistributed via backbone
to area 2.
Stop n start frr.service at R5 and validated
MAXAGE LSAs then recent age LSAs in Database at DUT-R4.
Validated external routes installed DUT to R4.
Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
2018-01-26 23:53:43 +01:00
|
|
|
int ospf6_orig_as_external_lsa(struct thread *thread)
|
|
|
|
{
|
|
|
|
struct ospf6_interface *oi;
|
|
|
|
struct ospf6_lsa *lsa;
|
|
|
|
uint32_t type, adv_router;
|
|
|
|
|
|
|
|
oi = (struct ospf6_interface *)THREAD_ARG(thread);
|
|
|
|
|
|
|
|
if (oi->state == OSPF6_INTERFACE_DOWN)
|
|
|
|
return 0;
|
2021-05-30 15:46:06 +02:00
|
|
|
if (IS_AREA_NSSA(oi->area))
|
|
|
|
return 0;
|
ospf6d: Handle Premature Aging of LSAs
RFC 2328 (14.1) Premature aging of LSAs from
routing domain :
When ospf6d is going away (router going down),
send MAXAGEd self originated LSAs to all
neighbors in routing domain to trigger
Premature aging to remove from resepective LSDBs.
Neighbor Router Reboot:
Upon receiving Self-originate MAXAGEd LSA, simply
discard, Current copy could be non maxaged latest.
For neighbor advertised LSA's (current copy in LSDB)
is set to MAXAGE but received new LSA with Non-MAXAGE
(with current age), discard the current MAXAGE LSA,
Send latest copy of LSA to neighbors and update the
LSDB with new LSA.
When a neighbor transition to FULL, trigger AS-External
LSAs update from external LSDB to new neighbor.
Testing:
R1 ---- DUT --- R5
| \
R2 R3
|
R4
Area 1: R5 and DUT
Area 0: DUT, R1, R2, R3
Area 2: R2 R4
Add IPv6 static routes at R5
Redistribute kernel routes at R5,
Validate routes at R4, redistributed via backbone
to area 2.
Stop n start frr.service at R5 and validated
MAXAGE LSAs then recent age LSAs in Database at DUT-R4.
Validated external routes installed DUT to R4.
Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
2018-01-26 23:53:43 +01:00
|
|
|
|
|
|
|
type = htons(OSPF6_LSTYPE_AS_EXTERNAL);
|
|
|
|
adv_router = oi->area->ospf6->router_id;
|
2020-10-08 07:38:43 +02:00
|
|
|
for (ALL_LSDB_TYPED_ADVRTR(oi->area->ospf6->lsdb, type, adv_router,
|
|
|
|
lsa)) {
|
ospf6d: Handle Premature Aging of LSAs
RFC 2328 (14.1) Premature aging of LSAs from
routing domain :
When ospf6d is going away (router going down),
send MAXAGEd self originated LSAs to all
neighbors in routing domain to trigger
Premature aging to remove from resepective LSDBs.
Neighbor Router Reboot:
Upon receiving Self-originate MAXAGEd LSA, simply
discard, Current copy could be non maxaged latest.
For neighbor advertised LSA's (current copy in LSDB)
is set to MAXAGE but received new LSA with Non-MAXAGE
(with current age), discard the current MAXAGE LSA,
Send latest copy of LSA to neighbors and update the
LSDB with new LSA.
When a neighbor transition to FULL, trigger AS-External
LSAs update from external LSDB to new neighbor.
Testing:
R1 ---- DUT --- R5
| \
R2 R3
|
R4
Area 1: R5 and DUT
Area 0: DUT, R1, R2, R3
Area 2: R2 R4
Add IPv6 static routes at R5
Redistribute kernel routes at R5,
Validate routes at R4, redistributed via backbone
to area 2.
Stop n start frr.service at R5 and validated
MAXAGE LSAs then recent age LSAs in Database at DUT-R4.
Validated external routes installed DUT to R4.
Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
2018-01-26 23:53:43 +01:00
|
|
|
if (IS_OSPF6_DEBUG_ASBR)
|
|
|
|
zlog_debug(
|
|
|
|
"%s: Send update of AS-External LSA %s seq 0x%x",
|
2020-03-06 15:23:22 +01:00
|
|
|
__func__, lsa->name,
|
ospf6d: Handle Premature Aging of LSAs
RFC 2328 (14.1) Premature aging of LSAs from
routing domain :
When ospf6d is going away (router going down),
send MAXAGEd self originated LSAs to all
neighbors in routing domain to trigger
Premature aging to remove from resepective LSDBs.
Neighbor Router Reboot:
Upon receiving Self-originate MAXAGEd LSA, simply
discard, Current copy could be non maxaged latest.
For neighbor advertised LSA's (current copy in LSDB)
is set to MAXAGE but received new LSA with Non-MAXAGE
(with current age), discard the current MAXAGE LSA,
Send latest copy of LSA to neighbors and update the
LSDB with new LSA.
When a neighbor transition to FULL, trigger AS-External
LSAs update from external LSDB to new neighbor.
Testing:
R1 ---- DUT --- R5
| \
R2 R3
|
R4
Area 1: R5 and DUT
Area 0: DUT, R1, R2, R3
Area 2: R2 R4
Add IPv6 static routes at R5
Redistribute kernel routes at R5,
Validate routes at R4, redistributed via backbone
to area 2.
Stop n start frr.service at R5 and validated
MAXAGE LSAs then recent age LSAs in Database at DUT-R4.
Validated external routes installed DUT to R4.
Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
2018-01-26 23:53:43 +01:00
|
|
|
ntohl(lsa->header->seqnum));
|
|
|
|
|
|
|
|
ospf6_flood_interface(NULL, lsa, oi);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-10-01 06:41:40 +02:00
|
|
|
static route_tag_t ospf6_as_external_lsa_get_tag(struct ospf6_lsa *lsa)
|
|
|
|
{
|
|
|
|
struct ospf6_as_external_lsa *external;
|
|
|
|
ptrdiff_t tag_offset;
|
|
|
|
route_tag_t network_order;
|
|
|
|
|
|
|
|
if (!lsa)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
external = (struct ospf6_as_external_lsa *)OSPF6_LSA_HEADER_END(
|
|
|
|
lsa->header);
|
|
|
|
|
|
|
|
if (!CHECK_FLAG(external->bits_metric, OSPF6_ASBR_BIT_T))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
tag_offset = sizeof(*external)
|
|
|
|
+ OSPF6_PREFIX_SPACE(external->prefix.prefix_length);
|
|
|
|
if (CHECK_FLAG(external->bits_metric, OSPF6_ASBR_BIT_F))
|
|
|
|
tag_offset += sizeof(struct in6_addr);
|
|
|
|
|
|
|
|
memcpy(&network_order, (caddr_t)external + tag_offset,
|
|
|
|
sizeof(network_order));
|
|
|
|
return ntohl(network_order);
|
|
|
|
}
|
2014-06-04 06:53:35 +02:00
|
|
|
|
2017-12-07 03:20:48 +01:00
|
|
|
void ospf6_asbr_update_route_ecmp_path(struct ospf6_route *old,
|
2020-10-08 07:38:43 +02:00
|
|
|
struct ospf6_route *route,
|
|
|
|
struct ospf6 *ospf6)
|
2017-12-07 03:20:48 +01:00
|
|
|
{
|
2021-01-31 14:52:44 +01:00
|
|
|
struct ospf6_route *old_route, *next_route;
|
2017-12-07 03:20:48 +01:00
|
|
|
struct ospf6_path *ecmp_path, *o_path = NULL;
|
2018-02-15 04:02:11 +01:00
|
|
|
struct listnode *anode, *anext;
|
2017-12-07 03:20:48 +01:00
|
|
|
struct listnode *nnode, *rnode, *rnext;
|
|
|
|
struct ospf6_nexthop *nh, *rnh;
|
|
|
|
bool route_found = false;
|
|
|
|
|
2018-02-15 04:02:11 +01:00
|
|
|
/* check for old entry match with new route origin,
|
|
|
|
* delete old entry.
|
|
|
|
*/
|
2021-01-31 14:52:44 +01:00
|
|
|
for (old_route = old; old_route; old_route = next_route) {
|
2018-02-15 04:02:11 +01:00
|
|
|
bool route_updated = false;
|
|
|
|
|
2021-01-31 14:52:44 +01:00
|
|
|
next_route = old_route->next;
|
|
|
|
|
2021-05-19 13:11:03 +02:00
|
|
|
/* The route linked-list is grouped in batches of prefix.
|
|
|
|
* If the new prefix is not the same as the one of interest
|
|
|
|
* then we have walked over the end of the batch and so we
|
|
|
|
* should break rather than continuing unnecessarily.
|
|
|
|
*/
|
|
|
|
if (!ospf6_route_is_same(old_route, route))
|
|
|
|
break;
|
|
|
|
if (old_route->path.type != route->path.type)
|
2018-02-15 04:02:11 +01:00
|
|
|
continue;
|
|
|
|
|
|
|
|
/* Current and New route has same origin,
|
|
|
|
* delete old entry.
|
|
|
|
*/
|
|
|
|
for (ALL_LIST_ELEMENTS(old_route->paths, anode, anext,
|
|
|
|
o_path)) {
|
|
|
|
/* Check old route path and route has same
|
|
|
|
* origin.
|
|
|
|
*/
|
|
|
|
if (o_path->area_id != route->path.area_id
|
2021-09-30 19:28:11 +02:00
|
|
|
|| !ospf6_ls_origin_same(o_path, &route->path))
|
2018-02-15 04:02:11 +01:00
|
|
|
continue;
|
|
|
|
|
|
|
|
/* Cost is not same then delete current path */
|
|
|
|
if ((o_path->cost == route->path.cost)
|
|
|
|
&& (o_path->u.cost_e2 == route->path.u.cost_e2))
|
|
|
|
continue;
|
2017-12-07 03:20:48 +01:00
|
|
|
|
|
|
|
if (IS_OSPF6_DEBUG_EXAMIN(AS_EXTERNAL)) {
|
2018-02-15 04:02:11 +01:00
|
|
|
zlog_debug(
|
2020-03-27 13:38:25 +01:00
|
|
|
"%s: route %pFX cost old %u new %u is not same, replace route",
|
|
|
|
__func__, &old_route->prefix, o_path->cost,
|
2018-02-15 04:02:11 +01:00
|
|
|
route->path.cost);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Remove selected current rout path's nh from
|
|
|
|
* effective nh list.
|
|
|
|
*/
|
|
|
|
for (ALL_LIST_ELEMENTS_RO(o_path->nh_list, nnode, nh)) {
|
|
|
|
for (ALL_LIST_ELEMENTS(old_route->nh_list,
|
|
|
|
rnode, rnext, rnh)) {
|
|
|
|
if (!ospf6_nexthop_is_same(rnh, nh))
|
|
|
|
continue;
|
|
|
|
listnode_delete(old_route->nh_list,
|
|
|
|
rnh);
|
|
|
|
ospf6_nexthop_delete(rnh);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
listnode_delete(old_route->paths, o_path);
|
|
|
|
ospf6_path_free(o_path);
|
2018-05-02 01:34:31 +02:00
|
|
|
route_updated = true;
|
2018-02-15 04:02:11 +01:00
|
|
|
|
|
|
|
/* Current route's path (adv_router info) is similar
|
|
|
|
* to route being added.
|
|
|
|
* Replace current route's path with paths list head.
|
|
|
|
* Update FIB with effective NHs.
|
|
|
|
*/
|
|
|
|
if (listcount(old_route->paths)) {
|
2018-05-02 01:34:31 +02:00
|
|
|
for (ALL_LIST_ELEMENTS(old_route->paths,
|
|
|
|
anode, anext, o_path)) {
|
|
|
|
ospf6_merge_nexthops(
|
|
|
|
old_route->nh_list,
|
|
|
|
o_path->nh_list);
|
|
|
|
}
|
|
|
|
/* Update RIB/FIB with effective
|
|
|
|
* nh_list
|
|
|
|
*/
|
|
|
|
if (ospf6->route_table->hook_add)
|
2020-10-08 07:38:43 +02:00
|
|
|
(*ospf6->route_table->hook_add)(
|
2020-11-20 02:13:52 +01:00
|
|
|
old_route);
|
2018-05-02 01:34:31 +02:00
|
|
|
|
2018-02-15 04:02:11 +01:00
|
|
|
if (old_route->path.origin.id
|
|
|
|
== route->path.origin.id
|
|
|
|
&& old_route->path.origin.adv_router
|
|
|
|
== route->path.origin
|
|
|
|
.adv_router) {
|
|
|
|
struct ospf6_path *h_path;
|
|
|
|
|
|
|
|
h_path = (struct ospf6_path *)
|
|
|
|
listgetdata(listhead(
|
|
|
|
old_route->paths));
|
|
|
|
old_route->path.origin.type =
|
|
|
|
h_path->origin.type;
|
|
|
|
old_route->path.origin.id =
|
|
|
|
h_path->origin.id;
|
|
|
|
old_route->path.origin.adv_router =
|
|
|
|
h_path->origin.adv_router;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (IS_OSPF6_DEBUG_EXAMIN(AS_EXTERNAL)) {
|
|
|
|
zlog_debug(
|
2020-03-27 13:38:25 +01:00
|
|
|
"%s: route %pFX old cost %u new cost %u, delete old entry.",
|
|
|
|
__func__, &old_route->prefix,
|
2018-02-15 04:02:11 +01:00
|
|
|
old_route->path.cost,
|
|
|
|
route->path.cost);
|
|
|
|
}
|
2021-01-31 14:52:44 +01:00
|
|
|
if (old == old_route)
|
|
|
|
old = next_route;
|
2018-02-15 04:02:11 +01:00
|
|
|
ospf6_route_remove(old_route,
|
2020-11-20 02:13:52 +01:00
|
|
|
ospf6->route_table);
|
2018-02-15 04:02:11 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (route_updated)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Add new route */
|
|
|
|
for (old_route = old; old_route; old_route = old_route->next) {
|
|
|
|
|
2021-05-19 13:11:03 +02:00
|
|
|
/* The route linked-list is grouped in batches of prefix.
|
|
|
|
* If the new prefix is not the same as the one of interest
|
|
|
|
* then we have walked over the end of the batch and so we
|
|
|
|
* should break rather than continuing unnecessarily.
|
2018-02-15 04:02:11 +01:00
|
|
|
*/
|
2021-05-19 13:11:03 +02:00
|
|
|
if (!ospf6_route_is_same(old_route, route))
|
|
|
|
break;
|
|
|
|
if (old_route->path.type != route->path.type)
|
2018-02-15 04:02:11 +01:00
|
|
|
continue;
|
|
|
|
|
|
|
|
/* Old Route and New Route have Equal Cost, Merge NHs */
|
|
|
|
if ((old_route->path.cost == route->path.cost)
|
|
|
|
&& (old_route->path.u.cost_e2 == route->path.u.cost_e2)) {
|
|
|
|
|
|
|
|
if (IS_OSPF6_DEBUG_EXAMIN(AS_EXTERNAL)) {
|
|
|
|
zlog_debug(
|
2020-03-27 13:38:25 +01:00
|
|
|
"%s: old route %pFX path cost %u e2 %u",
|
|
|
|
__func__, &old_route->prefix,
|
|
|
|
old_route->path.cost,
|
2018-02-15 04:02:11 +01:00
|
|
|
old_route->path.u.cost_e2);
|
2017-12-07 03:20:48 +01:00
|
|
|
}
|
|
|
|
route_found = true;
|
|
|
|
/* check if this path exists already in
|
|
|
|
* route->paths list, if so, replace nh_list
|
|
|
|
* from asbr_entry.
|
|
|
|
*/
|
|
|
|
for (ALL_LIST_ELEMENTS_RO(old_route->paths, anode,
|
|
|
|
o_path)) {
|
2018-02-15 04:02:11 +01:00
|
|
|
if (o_path->area_id == route->path.area_id
|
2021-09-30 19:28:11 +02:00
|
|
|
&& ospf6_ls_origin_same(o_path, &route->path))
|
2017-12-07 03:20:48 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
/* If path is not found in old_route paths's list,
|
|
|
|
* add a new path to route paths list and merge
|
|
|
|
* nexthops in route->path->nh_list.
|
|
|
|
* Otherwise replace existing path's nh_list.
|
|
|
|
*/
|
|
|
|
if (o_path == NULL) {
|
|
|
|
ecmp_path = ospf6_path_dup(&route->path);
|
|
|
|
|
|
|
|
/* Add a nh_list to new ecmp path */
|
|
|
|
ospf6_copy_nexthops(ecmp_path->nh_list,
|
|
|
|
route->nh_list);
|
|
|
|
|
|
|
|
/* Add the new path to route's path list */
|
|
|
|
listnode_add_sort(old_route->paths, ecmp_path);
|
|
|
|
|
|
|
|
if (IS_OSPF6_DEBUG_EXAMIN(AS_EXTERNAL)) {
|
2018-02-15 04:02:11 +01:00
|
|
|
zlog_debug(
|
2020-10-18 13:33:54 +02:00
|
|
|
"%s: route %pFX another path added with nh %u, effective paths %u nh %u",
|
|
|
|
__func__, &route->prefix,
|
2017-12-07 03:20:48 +01:00
|
|
|
listcount(ecmp_path->nh_list),
|
2020-03-06 15:23:22 +01:00
|
|
|
old_route->paths ? listcount(
|
|
|
|
old_route->paths)
|
|
|
|
: 0,
|
2018-02-15 04:02:11 +01:00
|
|
|
listcount(old_route->nh_list));
|
2017-12-07 03:20:48 +01:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
list_delete_all_node(o_path->nh_list);
|
|
|
|
ospf6_copy_nexthops(o_path->nh_list,
|
|
|
|
route->nh_list);
|
2018-05-02 01:34:31 +02:00
|
|
|
}
|
2017-12-07 03:20:48 +01:00
|
|
|
|
2018-05-02 01:34:31 +02:00
|
|
|
/* Reset nexthop lists, rebuild from brouter table
|
|
|
|
* for each adv. router.
|
|
|
|
*/
|
|
|
|
list_delete_all_node(old_route->nh_list);
|
2017-12-07 03:20:48 +01:00
|
|
|
|
2018-05-02 01:34:31 +02:00
|
|
|
for (ALL_LIST_ELEMENTS_RO(old_route->paths, anode,
|
|
|
|
o_path)) {
|
|
|
|
struct ospf6_route *asbr_entry;
|
|
|
|
|
|
|
|
asbr_entry = ospf6_route_lookup(
|
|
|
|
&o_path->ls_prefix,
|
|
|
|
ospf6->brouter_table);
|
|
|
|
if (asbr_entry == NULL) {
|
2020-10-18 13:33:54 +02:00
|
|
|
if (IS_OSPF6_DEBUG_EXAMIN(AS_EXTERNAL))
|
2020-03-06 15:23:22 +01:00
|
|
|
zlog_debug(
|
2020-10-18 13:33:54 +02:00
|
|
|
"%s: ls_prfix %pFX asbr_entry not found.",
|
|
|
|
__func__,
|
|
|
|
&old_route->prefix);
|
2018-05-02 01:34:31 +02:00
|
|
|
continue;
|
2017-12-07 03:20:48 +01:00
|
|
|
}
|
2018-05-02 01:34:31 +02:00
|
|
|
ospf6_route_merge_nexthops(old_route,
|
|
|
|
asbr_entry);
|
|
|
|
}
|
2017-12-07 03:20:48 +01:00
|
|
|
|
2020-10-18 13:33:54 +02:00
|
|
|
if (IS_OSPF6_DEBUG_EXAMIN(AS_EXTERNAL))
|
2020-03-06 15:23:22 +01:00
|
|
|
zlog_debug(
|
2020-10-18 13:33:54 +02:00
|
|
|
"%s: route %pFX with effective paths %u nh %u",
|
|
|
|
__func__, &route->prefix,
|
2020-03-06 15:23:22 +01:00
|
|
|
old_route->paths
|
|
|
|
? listcount(old_route->paths)
|
|
|
|
: 0,
|
|
|
|
old_route->nh_list
|
|
|
|
? listcount(old_route->nh_list)
|
|
|
|
: 0);
|
2018-05-02 01:34:31 +02:00
|
|
|
|
|
|
|
/* Update RIB/FIB */
|
|
|
|
if (ospf6->route_table->hook_add)
|
2020-11-20 02:13:52 +01:00
|
|
|
(*ospf6->route_table->hook_add)(old_route);
|
2018-05-02 01:34:31 +02:00
|
|
|
|
2017-12-07 03:20:48 +01:00
|
|
|
/* Delete the new route its info added to existing
|
|
|
|
* route.
|
|
|
|
*/
|
|
|
|
ospf6_route_delete(route);
|
2018-02-15 04:02:11 +01:00
|
|
|
|
2017-12-07 03:20:48 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!route_found) {
|
|
|
|
/* Add new route to existing node in ospf6 route table. */
|
2020-11-20 02:13:52 +01:00
|
|
|
ospf6_route_add(route, ospf6->route_table);
|
2017-12-07 03:20:48 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-25 12:29:51 +01:00
|
|
|
/* Check if the forwarding address is local address */
|
|
|
|
static int ospf6_ase_forward_address_check(struct ospf6 *ospf6,
|
|
|
|
struct in6_addr *fwd_addr)
|
|
|
|
{
|
|
|
|
struct listnode *anode, *node, *cnode;
|
|
|
|
struct ospf6_interface *oi;
|
|
|
|
struct ospf6_area *oa;
|
|
|
|
struct interface *ifp;
|
|
|
|
struct connected *c;
|
|
|
|
|
|
|
|
for (ALL_LIST_ELEMENTS_RO(ospf6->area_list, anode, oa)) {
|
|
|
|
for (ALL_LIST_ELEMENTS_RO(oa->if_list, node, oi)) {
|
|
|
|
if (!if_is_operative(oi->interface)
|
|
|
|
|| oi->type == OSPF_IFTYPE_VIRTUALLINK)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
ifp = oi->interface;
|
|
|
|
for (ALL_LIST_ELEMENTS_RO(ifp->connected, cnode, c)) {
|
|
|
|
if (IPV6_ADDR_SAME(&c->address->u.prefix6,
|
|
|
|
fwd_addr))
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2020-11-20 04:01:55 +01:00
|
|
|
void ospf6_asbr_lsa_add(struct ospf6_lsa *lsa)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
2004-05-18 20:57:06 +02:00
|
|
|
struct ospf6_as_external_lsa *external;
|
|
|
|
struct prefix asbr_id;
|
2021-03-25 12:29:51 +01:00
|
|
|
struct ospf6_route *asbr_entry, *route, *old = NULL;
|
2017-12-07 03:20:48 +01:00
|
|
|
struct ospf6_path *path;
|
2020-11-20 04:01:55 +01:00
|
|
|
struct ospf6 *ospf6;
|
2021-03-25 12:29:51 +01:00
|
|
|
int type;
|
|
|
|
struct ospf6_area *oa = NULL;
|
|
|
|
struct prefix fwd_addr;
|
|
|
|
ptrdiff_t offset;
|
|
|
|
|
|
|
|
type = ntohs(lsa->header->type);
|
|
|
|
oa = lsa->lsdb->data;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
external = (struct ospf6_as_external_lsa *)OSPF6_LSA_HEADER_END(
|
|
|
|
lsa->header);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2004-09-01 23:36:14 +02:00
|
|
|
if (IS_OSPF6_DEBUG_EXAMIN(AS_EXTERNAL))
|
2004-12-24 07:00:11 +01:00
|
|
|
zlog_debug("Calculate AS-External route for %s", lsa->name);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2020-11-20 04:01:55 +01:00
|
|
|
ospf6 = ospf6_get_by_lsdb(lsa);
|
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
if (lsa->header->adv_router == ospf6->router_id) {
|
2004-09-01 23:36:14 +02:00
|
|
|
if (IS_OSPF6_DEBUG_EXAMIN(AS_EXTERNAL))
|
2004-12-24 07:00:11 +01:00
|
|
|
zlog_debug("Ignore self-originated AS-External-LSA");
|
2004-05-18 20:57:06 +02:00
|
|
|
return;
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2013-10-23 02:42:18 +02:00
|
|
|
if (OSPF6_ASBR_METRIC(external) == OSPF_LS_INFINITY) {
|
2004-09-01 23:36:14 +02:00
|
|
|
if (IS_OSPF6_DEBUG_EXAMIN(AS_EXTERNAL))
|
2004-12-24 07:00:11 +01:00
|
|
|
zlog_debug("Ignore LSA with LSInfinity Metric");
|
2004-05-18 20:57:06 +02:00
|
|
|
return;
|
|
|
|
}
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2013-08-25 05:03:31 +02:00
|
|
|
if (CHECK_FLAG(external->prefix.prefix_options,
|
|
|
|
OSPF6_PREFIX_OPTION_NU)) {
|
|
|
|
if (IS_OSPF6_DEBUG_EXAMIN(AS_EXTERNAL))
|
|
|
|
zlog_debug("Ignore LSA with NU bit set Metric");
|
|
|
|
return;
|
|
|
|
}
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2004-08-25 11:10:37 +02:00
|
|
|
ospf6_linkstate_prefix(lsa->header->adv_router, htonl(0), &asbr_id);
|
2004-08-15 07:52:07 +02:00
|
|
|
asbr_entry = ospf6_route_lookup(&asbr_id, ospf6->brouter_table);
|
2021-03-25 12:29:51 +01:00
|
|
|
if (asbr_entry == NULL) {
|
2020-10-18 13:33:54 +02:00
|
|
|
if (IS_OSPF6_DEBUG_EXAMIN(AS_EXTERNAL))
|
|
|
|
zlog_debug("ASBR entry not found: %pFX", &asbr_id);
|
2004-05-18 20:57:06 +02:00
|
|
|
return;
|
2021-03-25 12:29:51 +01:00
|
|
|
} else {
|
|
|
|
/* The router advertising external LSA can be ASBR or ABR */
|
|
|
|
if (!CHECK_FLAG(asbr_entry->path.router_bits,
|
|
|
|
OSPF6_ROUTER_BIT_E)) {
|
|
|
|
if (IS_OSPF6_DEBUG_EXAMIN(AS_EXTERNAL))
|
|
|
|
zlog_debug(
|
|
|
|
"External bit reset ASBR route entry : %pFX",
|
|
|
|
&asbr_id);
|
|
|
|
return;
|
|
|
|
}
|
2021-08-23 23:22:20 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* RFC 3101 - Section 2.5:
|
|
|
|
* "For a Type-7 LSA the matching routing table entry must
|
|
|
|
* specify an intra-area path through the LSA's originating
|
|
|
|
* NSSA".
|
|
|
|
*/
|
|
|
|
if (ntohs(lsa->header->type) == OSPF6_LSTYPE_TYPE_7
|
|
|
|
&& (asbr_entry->path.area_id != oa->area_id
|
|
|
|
|| asbr_entry->path.type != OSPF6_PATH_TYPE_INTRA)) {
|
|
|
|
if (IS_OSPF6_DEBUG_EXAMIN(AS_EXTERNAL))
|
|
|
|
zlog_debug(
|
|
|
|
"Intra-area route to NSSA ASBR not found: %pFX",
|
|
|
|
&asbr_id);
|
|
|
|
return;
|
|
|
|
}
|
2021-03-25 12:29:51 +01:00
|
|
|
}
|
|
|
|
|
2021-08-24 22:35:21 +02:00
|
|
|
/*
|
|
|
|
* RFC 3101 - Section 2.5:
|
|
|
|
* "If the destination is a Type-7 default route (destination ID =
|
|
|
|
* DefaultDestination) and one of the following is true, then do
|
|
|
|
* nothing with this LSA and consider the next in the list:
|
|
|
|
*
|
|
|
|
* o The calculating router is a border router and the LSA has
|
|
|
|
* its P-bit clear. Appendix E describes a technique
|
|
|
|
* whereby an NSSA border router installs a Type-7 default
|
|
|
|
* LSA without propagating it.
|
|
|
|
*
|
|
|
|
* o The calculating router is a border router and is
|
|
|
|
* suppressing the import of summary routes as Type-3
|
|
|
|
* summary-LSAs".
|
|
|
|
*/
|
|
|
|
if (ntohs(lsa->header->type) == OSPF6_LSTYPE_TYPE_7
|
|
|
|
&& external->prefix.prefix_length == 0
|
|
|
|
&& CHECK_FLAG(ospf6->flag, OSPF6_FLAG_ABR)
|
|
|
|
&& (CHECK_FLAG(external->prefix.prefix_options,
|
|
|
|
OSPF6_PREFIX_OPTION_P)
|
|
|
|
|| oa->no_summary)) {
|
|
|
|
if (IS_OSPF6_DEBUG_EXAMIN(AS_EXTERNAL))
|
|
|
|
zlog_debug("Skipping Type-7 default route");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-03-25 12:29:51 +01:00
|
|
|
/* Check the forwarding address */
|
|
|
|
if (CHECK_FLAG(external->bits_metric, OSPF6_ASBR_BIT_F)) {
|
|
|
|
offset = sizeof(*external)
|
|
|
|
+ OSPF6_PREFIX_SPACE(external->prefix.prefix_length);
|
|
|
|
memset(&fwd_addr, 0, sizeof(struct prefix));
|
|
|
|
fwd_addr.family = AF_INET6;
|
2021-07-01 16:39:04 +02:00
|
|
|
fwd_addr.prefixlen = IPV6_MAX_BITLEN;
|
2021-03-25 12:29:51 +01:00
|
|
|
memcpy(&fwd_addr.u.prefix6, (caddr_t)external + offset,
|
|
|
|
sizeof(struct in6_addr));
|
|
|
|
|
|
|
|
if (!IN6_IS_ADDR_UNSPECIFIED(&fwd_addr.u.prefix6)) {
|
|
|
|
if (!ospf6_ase_forward_address_check(
|
|
|
|
ospf6, &fwd_addr.u.prefix6)) {
|
|
|
|
if (IS_OSPF6_DEBUG_EXAMIN(AS_EXTERNAL))
|
|
|
|
zlog_debug(
|
|
|
|
"Fwd address %pFX is local address",
|
|
|
|
&fwd_addr);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Find the forwarding entry */
|
|
|
|
asbr_entry = ospf6_route_lookup_bestmatch(
|
|
|
|
&fwd_addr, ospf6->route_table);
|
|
|
|
if (asbr_entry == NULL) {
|
|
|
|
if (IS_OSPF6_DEBUG_EXAMIN(AS_EXTERNAL))
|
|
|
|
zlog_debug(
|
|
|
|
"Fwd address not found: %pFX",
|
|
|
|
&fwd_addr);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2004-05-18 20:57:06 +02:00
|
|
|
}
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2021-07-15 17:47:36 +02:00
|
|
|
route = ospf6_route_create(ospf6);
|
2004-05-18 20:57:06 +02:00
|
|
|
route->type = OSPF6_DEST_TYPE_NETWORK;
|
|
|
|
route->prefix.family = AF_INET6;
|
|
|
|
route->prefix.prefixlen = external->prefix.prefix_length;
|
2018-06-27 11:47:57 +02:00
|
|
|
ospf6_prefix_in6_addr(&route->prefix.u.prefix6, external,
|
|
|
|
&external->prefix);
|
2021-06-28 15:18:29 +02:00
|
|
|
route->prefix_options = external->prefix.prefix_options;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
route->path.area_id = asbr_entry->path.area_id;
|
|
|
|
route->path.origin.type = lsa->header->type;
|
|
|
|
route->path.origin.id = lsa->header->id;
|
|
|
|
route->path.origin.adv_router = lsa->header->adv_router;
|
2018-05-02 01:34:31 +02:00
|
|
|
memcpy(&route->path.ls_prefix, &asbr_id, sizeof(struct prefix));
|
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
if (CHECK_FLAG(external->bits_metric, OSPF6_ASBR_BIT_E)) {
|
|
|
|
route->path.type = OSPF6_PATH_TYPE_EXTERNAL2;
|
|
|
|
route->path.metric_type = 2;
|
|
|
|
route->path.cost = asbr_entry->path.cost;
|
2015-05-20 03:03:39 +02:00
|
|
|
route->path.u.cost_e2 = OSPF6_ASBR_METRIC(external);
|
2004-05-18 20:57:06 +02:00
|
|
|
} else {
|
|
|
|
route->path.type = OSPF6_PATH_TYPE_EXTERNAL1;
|
|
|
|
route->path.metric_type = 1;
|
|
|
|
route->path.cost =
|
|
|
|
asbr_entry->path.cost + OSPF6_ASBR_METRIC(external);
|
2015-05-20 03:03:39 +02:00
|
|
|
route->path.u.cost_e2 = 0;
|
2004-05-18 20:57:06 +02:00
|
|
|
}
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2016-10-01 06:41:40 +02:00
|
|
|
route->path.tag = ospf6_as_external_lsa_get_tag(lsa);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2015-05-20 03:03:39 +02:00
|
|
|
ospf6_route_copy_nexthops(route, asbr_entry);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2017-12-07 03:20:48 +01:00
|
|
|
path = ospf6_path_dup(&route->path);
|
|
|
|
ospf6_copy_nexthops(path->nh_list, asbr_entry->nh_list);
|
|
|
|
listnode_add_sort(route->paths, path);
|
|
|
|
|
|
|
|
|
2020-10-18 13:33:54 +02:00
|
|
|
if (IS_OSPF6_DEBUG_EXAMIN(AS_EXTERNAL))
|
|
|
|
zlog_debug(
|
2021-03-25 12:29:51 +01:00
|
|
|
"%s: %s %u route add %pFX cost %u(%u) nh %u", __func__,
|
|
|
|
(type == OSPF6_LSTYPE_AS_EXTERNAL) ? "AS-External"
|
|
|
|
: "NSSA",
|
2020-10-18 13:33:54 +02:00
|
|
|
(route->path.type == OSPF6_PATH_TYPE_EXTERNAL1) ? 1 : 2,
|
|
|
|
&route->prefix, route->path.cost, route->path.u.cost_e2,
|
|
|
|
listcount(route->nh_list));
|
2017-12-07 03:20:48 +01:00
|
|
|
|
2021-03-25 12:29:51 +01:00
|
|
|
if (type == OSPF6_LSTYPE_AS_EXTERNAL)
|
|
|
|
old = ospf6_route_lookup(&route->prefix, ospf6->route_table);
|
|
|
|
else if (type == OSPF6_LSTYPE_TYPE_7)
|
|
|
|
old = ospf6_route_lookup(&route->prefix, oa->route_table);
|
2017-12-07 03:20:48 +01:00
|
|
|
if (!old) {
|
2021-03-25 12:29:51 +01:00
|
|
|
if (IS_OSPF6_DEBUG_EXAMIN(AS_EXTERNAL))
|
2021-03-25 16:43:26 +01:00
|
|
|
zlog_debug("%s: Adding new route", __func__);
|
2017-12-07 03:20:48 +01:00
|
|
|
/* Add the new route to ospf6 instance route table. */
|
2021-03-25 12:29:51 +01:00
|
|
|
if (type == OSPF6_LSTYPE_AS_EXTERNAL)
|
|
|
|
ospf6_route_add(route, ospf6->route_table);
|
|
|
|
/* Add the route to the area route table */
|
|
|
|
else if (type == OSPF6_LSTYPE_TYPE_7) {
|
|
|
|
ospf6_route_add(route, oa->route_table);
|
|
|
|
}
|
2017-12-07 03:20:48 +01:00
|
|
|
} else {
|
|
|
|
/* RFC 2328 16.4 (6)
|
|
|
|
* ECMP: Keep new equal preference path in current
|
|
|
|
* route's path list, update zebra with new effective
|
|
|
|
* list along with addition of ECMP path.
|
|
|
|
*/
|
2021-03-25 12:29:51 +01:00
|
|
|
if (IS_OSPF6_DEBUG_EXAMIN(AS_EXTERNAL))
|
|
|
|
zlog_debug("%s : old route %pFX cost %u(%u) nh %u",
|
|
|
|
__func__, &route->prefix, route->path.cost,
|
|
|
|
route->path.u.cost_e2,
|
|
|
|
listcount(route->nh_list));
|
2020-10-08 07:38:43 +02:00
|
|
|
ospf6_asbr_update_route_ecmp_path(old, route, ospf6);
|
2004-05-18 20:57:06 +02:00
|
|
|
}
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
|
2018-02-15 04:02:11 +01:00
|
|
|
void ospf6_asbr_lsa_remove(struct ospf6_lsa *lsa,
|
|
|
|
struct ospf6_route *asbr_entry)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
2004-05-18 20:57:06 +02:00
|
|
|
struct ospf6_as_external_lsa *external;
|
|
|
|
struct prefix prefix;
|
2018-02-15 04:02:11 +01:00
|
|
|
struct ospf6_route *route, *nroute, *route_to_del;
|
2020-10-08 07:38:43 +02:00
|
|
|
struct ospf6_area *oa = NULL;
|
|
|
|
struct ospf6 *ospf6;
|
2021-03-25 16:43:26 +01:00
|
|
|
int type;
|
|
|
|
bool debug = false;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
external = (struct ospf6_as_external_lsa *)OSPF6_LSA_HEADER_END(
|
|
|
|
lsa->header);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2021-03-25 16:43:26 +01:00
|
|
|
if (IS_OSPF6_DEBUG_EXAMIN(AS_EXTERNAL) || (IS_OSPF6_DEBUG_NSSA))
|
|
|
|
debug = true;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2020-10-08 07:38:43 +02:00
|
|
|
ospf6 = ospf6_get_by_lsdb(lsa);
|
2021-03-25 16:43:26 +01:00
|
|
|
type = ntohs(lsa->header->type);
|
2020-10-08 07:38:43 +02:00
|
|
|
|
2021-03-25 16:43:26 +01:00
|
|
|
if (type == OSPF6_LSTYPE_TYPE_7) {
|
|
|
|
if (debug)
|
|
|
|
zlog_debug("%s: Withdraw Type 7 route for %s",
|
|
|
|
__func__, lsa->name);
|
|
|
|
oa = lsa->lsdb->data;
|
|
|
|
} else {
|
|
|
|
if (debug)
|
|
|
|
zlog_debug("%s: Withdraw AS-External route for %s",
|
|
|
|
__func__, lsa->name);
|
|
|
|
|
2021-06-10 13:59:06 +02:00
|
|
|
if (ospf6_check_and_set_router_abr(ospf6))
|
2021-03-25 16:43:26 +01:00
|
|
|
oa = ospf6->backbone;
|
|
|
|
else
|
2021-07-06 13:31:21 +02:00
|
|
|
oa = listnode_head(ospf6->area_list);
|
2021-03-25 16:43:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (oa == NULL) {
|
|
|
|
if (debug)
|
|
|
|
zlog_debug("%s: Invalid area", __func__);
|
2020-10-08 07:38:43 +02:00
|
|
|
return;
|
2021-03-25 16:43:26 +01:00
|
|
|
}
|
2020-10-08 07:38:43 +02:00
|
|
|
|
|
|
|
if (lsa->header->adv_router == oa->ospf6->router_id) {
|
2021-03-25 16:43:26 +01:00
|
|
|
if (debug)
|
2004-12-24 07:00:11 +01:00
|
|
|
zlog_debug("Ignore self-originated AS-External-LSA");
|
2004-05-18 20:57:06 +02:00
|
|
|
return;
|
|
|
|
}
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2021-07-15 17:47:36 +02:00
|
|
|
route_to_del = ospf6_route_create(ospf6);
|
2018-02-15 04:02:11 +01:00
|
|
|
route_to_del->type = OSPF6_DEST_TYPE_NETWORK;
|
|
|
|
route_to_del->prefix.family = AF_INET6;
|
|
|
|
route_to_del->prefix.prefixlen = external->prefix.prefix_length;
|
2018-06-27 11:47:57 +02:00
|
|
|
ospf6_prefix_in6_addr(&route_to_del->prefix.u.prefix6, external,
|
2018-02-15 04:02:11 +01:00
|
|
|
&external->prefix);
|
|
|
|
|
|
|
|
route_to_del->path.origin.type = lsa->header->type;
|
|
|
|
route_to_del->path.origin.id = lsa->header->id;
|
|
|
|
route_to_del->path.origin.adv_router = lsa->header->adv_router;
|
|
|
|
|
|
|
|
if (asbr_entry) {
|
|
|
|
route_to_del->path.area_id = asbr_entry->path.area_id;
|
|
|
|
if (CHECK_FLAG(external->bits_metric, OSPF6_ASBR_BIT_E)) {
|
|
|
|
route_to_del->path.type = OSPF6_PATH_TYPE_EXTERNAL2;
|
|
|
|
route_to_del->path.metric_type = 2;
|
|
|
|
route_to_del->path.cost = asbr_entry->path.cost;
|
|
|
|
route_to_del->path.u.cost_e2 =
|
|
|
|
OSPF6_ASBR_METRIC(external);
|
|
|
|
} else {
|
|
|
|
route_to_del->path.type = OSPF6_PATH_TYPE_EXTERNAL1;
|
|
|
|
route_to_del->path.metric_type = 1;
|
|
|
|
route_to_del->path.cost = asbr_entry->path.cost
|
|
|
|
+ OSPF6_ASBR_METRIC(external);
|
|
|
|
route_to_del->path.u.cost_e2 = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
memset(&prefix, 0, sizeof(struct prefix));
|
|
|
|
prefix.family = AF_INET6;
|
|
|
|
prefix.prefixlen = external->prefix.prefix_length;
|
2018-06-27 11:47:57 +02:00
|
|
|
ospf6_prefix_in6_addr(&prefix.u.prefix6, external, &external->prefix);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2021-03-25 16:43:26 +01:00
|
|
|
if (type == OSPF6_LSTYPE_TYPE_7)
|
|
|
|
route = ospf6_route_lookup(&prefix, oa->route_table);
|
|
|
|
else
|
|
|
|
route = ospf6_route_lookup(&prefix, oa->ospf6->route_table);
|
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
if (route == NULL) {
|
2021-03-25 16:43:26 +01:00
|
|
|
if (debug)
|
2020-03-27 13:38:25 +01:00
|
|
|
zlog_debug("AS-External route %pFX not found", &prefix);
|
2018-03-21 00:12:20 +01:00
|
|
|
ospf6_route_delete(route_to_del);
|
2004-05-18 20:57:06 +02:00
|
|
|
return;
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2021-03-25 16:43:26 +01:00
|
|
|
if (debug)
|
2018-02-15 04:02:11 +01:00
|
|
|
zlog_debug(
|
2020-03-27 13:38:25 +01:00
|
|
|
"%s: Current route %pFX cost %u e2 %u, route to del cost %u e2 %u",
|
|
|
|
__func__, &prefix, route->path.cost, route->path.u.cost_e2,
|
2020-03-06 15:23:22 +01:00
|
|
|
route_to_del->path.cost, route_to_del->path.u.cost_e2);
|
2018-02-15 04:02:11 +01:00
|
|
|
|
|
|
|
for (ospf6_route_lock(route);
|
|
|
|
route && ospf6_route_is_prefix(&prefix, route); route = nroute) {
|
2015-05-20 03:03:53 +02:00
|
|
|
nroute = ospf6_route_next(route);
|
2018-02-15 04:02:11 +01:00
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
if (route->type != OSPF6_DEST_TYPE_NETWORK)
|
|
|
|
continue;
|
2017-12-07 03:20:48 +01:00
|
|
|
|
2018-02-15 04:02:11 +01:00
|
|
|
/* Route has multiple ECMP paths, remove matching
|
|
|
|
* path. Update current route's effective nh list
|
|
|
|
* after removal of one of the path.
|
2017-12-07 03:20:48 +01:00
|
|
|
*/
|
|
|
|
if (listcount(route->paths) > 1) {
|
|
|
|
struct listnode *anode, *anext;
|
|
|
|
struct listnode *nnode, *rnode, *rnext;
|
|
|
|
struct ospf6_nexthop *nh, *rnh;
|
|
|
|
struct ospf6_path *o_path;
|
|
|
|
bool nh_updated = false;
|
|
|
|
|
|
|
|
/* Iterate all paths of route to find maching with LSA
|
|
|
|
* remove from route path list. If route->path is same,
|
|
|
|
* replace from paths list.
|
|
|
|
*/
|
|
|
|
for (ALL_LIST_ELEMENTS(route->paths, anode, anext,
|
|
|
|
o_path)) {
|
2018-02-15 04:02:11 +01:00
|
|
|
if ((o_path->origin.type != lsa->header->type)
|
|
|
|
|| (o_path->origin.adv_router
|
|
|
|
!= lsa->header->adv_router)
|
|
|
|
|| (o_path->origin.id != lsa->header->id))
|
2017-12-07 03:20:48 +01:00
|
|
|
continue;
|
2018-02-15 04:02:11 +01:00
|
|
|
|
|
|
|
/* Compare LSA cost with current
|
|
|
|
* route info.
|
|
|
|
*/
|
2021-08-04 13:53:10 +02:00
|
|
|
if (asbr_entry
|
2018-02-15 04:02:11 +01:00
|
|
|
&& (o_path->cost != route_to_del->path.cost
|
|
|
|
|| o_path->u.cost_e2
|
|
|
|
!= route_to_del->path.u
|
|
|
|
.cost_e2)) {
|
|
|
|
if (IS_OSPF6_DEBUG_EXAMIN(
|
|
|
|
AS_EXTERNAL)) {
|
|
|
|
zlog_debug(
|
2020-03-27 13:38:25 +01:00
|
|
|
"%s: route %pFX to delete is not same, cost %u del cost %u. skip",
|
|
|
|
__func__, &prefix,
|
2020-03-06 15:23:22 +01:00
|
|
|
route->path.cost,
|
2018-02-15 04:02:11 +01:00
|
|
|
route_to_del->path
|
|
|
|
.cost);
|
|
|
|
}
|
2017-12-07 03:20:48 +01:00
|
|
|
continue;
|
2018-02-15 04:02:11 +01:00
|
|
|
}
|
2017-12-07 03:20:48 +01:00
|
|
|
|
2021-03-25 16:43:26 +01:00
|
|
|
if (debug) {
|
2017-12-07 03:20:48 +01:00
|
|
|
zlog_debug(
|
2020-03-27 13:38:25 +01:00
|
|
|
"%s: route %pFX path found with cost %u nh %u to remove.",
|
|
|
|
__func__, &prefix, route->path.cost,
|
2017-12-07 03:20:48 +01:00
|
|
|
listcount(o_path->nh_list));
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Remove found path's nh_list from
|
|
|
|
* the route's nh_list.
|
|
|
|
*/
|
|
|
|
for (ALL_LIST_ELEMENTS_RO(o_path->nh_list,
|
|
|
|
nnode, nh)) {
|
|
|
|
for (ALL_LIST_ELEMENTS(route->nh_list,
|
|
|
|
rnode, rnext,
|
|
|
|
rnh)) {
|
|
|
|
if (!ospf6_nexthop_is_same(rnh,
|
|
|
|
nh))
|
|
|
|
continue;
|
|
|
|
listnode_delete(route->nh_list,
|
|
|
|
rnh);
|
|
|
|
ospf6_nexthop_delete(rnh);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* Delete the path from route's path list */
|
|
|
|
listnode_delete(route->paths, o_path);
|
|
|
|
ospf6_path_free(o_path);
|
|
|
|
nh_updated = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nh_updated) {
|
|
|
|
/* Iterate all paths and merge nexthop,
|
|
|
|
* unlesss any of the nexthop similar to
|
|
|
|
* ones deleted as part of path deletion.
|
|
|
|
*/
|
|
|
|
|
|
|
|
for (ALL_LIST_ELEMENTS(route->paths, anode,
|
|
|
|
anext, o_path)) {
|
|
|
|
ospf6_merge_nexthops(route->nh_list,
|
|
|
|
o_path->nh_list);
|
|
|
|
}
|
|
|
|
|
2021-03-25 16:43:26 +01:00
|
|
|
if (debug) {
|
2017-12-07 03:20:48 +01:00
|
|
|
zlog_debug(
|
2020-03-27 13:38:25 +01:00
|
|
|
"%s: AS-External %u route %pFX update paths %u nh %u",
|
2020-03-06 15:23:22 +01:00
|
|
|
__func__,
|
2017-12-07 03:20:48 +01:00
|
|
|
(route->path.type
|
|
|
|
== OSPF6_PATH_TYPE_EXTERNAL1)
|
|
|
|
? 1
|
|
|
|
: 2,
|
2020-03-27 13:38:25 +01:00
|
|
|
&route->prefix, listcount(route->paths),
|
2020-03-06 15:23:22 +01:00
|
|
|
route->nh_list ? listcount(
|
|
|
|
route->nh_list)
|
|
|
|
: 0);
|
2017-12-07 03:20:48 +01:00
|
|
|
}
|
|
|
|
|
2018-04-19 21:26:20 +02:00
|
|
|
if (listcount(route->paths)) {
|
|
|
|
/* Update RIB/FIB with effective
|
|
|
|
* nh_list
|
|
|
|
*/
|
2020-10-08 07:38:43 +02:00
|
|
|
if (oa->ospf6->route_table->hook_add)
|
|
|
|
(*oa->ospf6->route_table
|
2020-11-20 02:13:52 +01:00
|
|
|
->hook_add)(route);
|
2017-12-07 03:20:48 +01:00
|
|
|
|
2018-04-19 21:26:20 +02:00
|
|
|
/* route's primary path is similar
|
|
|
|
* to LSA, replace route's primary
|
|
|
|
* path with route's paths list head.
|
|
|
|
*/
|
|
|
|
if ((route->path.origin.id ==
|
|
|
|
lsa->header->id) &&
|
|
|
|
(route->path.origin.adv_router
|
|
|
|
== lsa->header->adv_router)) {
|
|
|
|
struct ospf6_path *h_path;
|
2017-12-07 03:20:48 +01:00
|
|
|
|
2018-04-19 21:26:20 +02:00
|
|
|
h_path = (struct ospf6_path *)
|
2017-12-07 03:20:48 +01:00
|
|
|
listgetdata(
|
|
|
|
listhead(route->paths));
|
2018-04-19 21:26:20 +02:00
|
|
|
route->path.origin.type =
|
|
|
|
h_path->origin.type;
|
|
|
|
route->path.origin.id =
|
|
|
|
h_path->origin.id;
|
|
|
|
route->path.origin.adv_router =
|
2017-12-07 03:20:48 +01:00
|
|
|
h_path->origin.adv_router;
|
2018-04-19 21:26:20 +02:00
|
|
|
}
|
|
|
|
} else {
|
2021-03-25 16:43:26 +01:00
|
|
|
if (type == OSPF6_LSTYPE_TYPE_7)
|
|
|
|
ospf6_route_remove(
|
|
|
|
route, oa->route_table);
|
|
|
|
else
|
|
|
|
ospf6_route_remove(
|
|
|
|
route,
|
|
|
|
oa->ospf6->route_table);
|
2017-12-07 03:20:48 +01:00
|
|
|
}
|
|
|
|
}
|
2004-05-18 20:57:06 +02:00
|
|
|
continue;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2017-12-07 03:20:48 +01:00
|
|
|
} else {
|
2018-02-15 04:02:11 +01:00
|
|
|
/* Compare LSA origin and cost with current route info.
|
|
|
|
* if any check fails skip del this route node.
|
|
|
|
*/
|
|
|
|
if (asbr_entry
|
|
|
|
&& (!ospf6_route_is_same_origin(route, route_to_del)
|
|
|
|
|| (route->path.type != route_to_del->path.type)
|
|
|
|
|| (route->path.cost != route_to_del->path.cost)
|
|
|
|
|| (route->path.u.cost_e2
|
|
|
|
!= route_to_del->path.u.cost_e2))) {
|
2021-03-25 16:43:26 +01:00
|
|
|
if (debug) {
|
2018-02-15 04:02:11 +01:00
|
|
|
zlog_debug(
|
2020-03-27 13:38:25 +01:00
|
|
|
"%s: route %pFX to delete is not same, cost %u del cost %u. skip",
|
|
|
|
__func__, &prefix, route->path.cost,
|
2018-02-15 04:02:11 +01:00
|
|
|
route_to_del->path.cost);
|
|
|
|
}
|
2017-12-07 03:20:48 +01:00
|
|
|
continue;
|
2018-02-15 04:02:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if ((route->path.origin.type != lsa->header->type)
|
|
|
|
|| (route->path.origin.adv_router
|
|
|
|
!= lsa->header->adv_router)
|
|
|
|
|| (route->path.origin.id != lsa->header->id))
|
2017-12-07 03:20:48 +01:00
|
|
|
continue;
|
|
|
|
}
|
2021-03-25 16:43:26 +01:00
|
|
|
if (debug) {
|
2017-12-07 03:20:48 +01:00
|
|
|
zlog_debug(
|
2020-03-27 13:38:25 +01:00
|
|
|
"%s: AS-External %u route remove %pFX cost %u(%u) nh %u",
|
2020-03-06 15:23:22 +01:00
|
|
|
__func__,
|
2017-12-07 03:20:48 +01:00
|
|
|
route->path.type == OSPF6_PATH_TYPE_EXTERNAL1
|
|
|
|
? 1
|
|
|
|
: 2,
|
2020-03-27 13:38:25 +01:00
|
|
|
&route->prefix, route->path.cost, route->path.u.cost_e2,
|
2017-12-07 03:20:48 +01:00
|
|
|
listcount(route->nh_list));
|
2004-05-18 20:57:06 +02:00
|
|
|
}
|
2021-03-25 16:43:26 +01:00
|
|
|
if (type == OSPF6_LSTYPE_TYPE_7)
|
|
|
|
ospf6_route_remove(route, oa->route_table);
|
|
|
|
else
|
|
|
|
ospf6_route_remove(route, oa->ospf6->route_table);
|
2004-05-18 20:57:06 +02:00
|
|
|
}
|
2013-03-20 11:50:09 +01:00
|
|
|
if (route != NULL)
|
|
|
|
ospf6_route_unlock(route);
|
2018-02-15 04:02:11 +01:00
|
|
|
|
|
|
|
ospf6_route_delete(route_to_del);
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
|
2020-10-08 07:38:43 +02:00
|
|
|
void ospf6_asbr_lsentry_add(struct ospf6_route *asbr_entry, struct ospf6 *ospf6)
|
2004-05-18 20:57:06 +02:00
|
|
|
{
|
|
|
|
struct ospf6_lsa *lsa;
|
2018-03-27 21:13:34 +02:00
|
|
|
uint16_t type;
|
|
|
|
uint32_t router;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2006-05-15 12:39:30 +02:00
|
|
|
if (!CHECK_FLAG(asbr_entry->flag, OSPF6_ROUTE_BEST)) {
|
|
|
|
char buf[16];
|
|
|
|
inet_ntop(AF_INET, &ADV_ROUTER_IN_PREFIX(&asbr_entry->prefix),
|
|
|
|
buf, sizeof(buf));
|
|
|
|
zlog_info("ignore non-best path: lsentry %s add", buf);
|
|
|
|
return;
|
2004-05-18 20:57:06 +02:00
|
|
|
}
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
type = htons(OSPF6_LSTYPE_AS_EXTERNAL);
|
|
|
|
router = ospf6_linkstate_prefix_adv_router(&asbr_entry->prefix);
|
2017-07-07 17:23:30 +02:00
|
|
|
for (ALL_LSDB_TYPED_ADVRTR(ospf6->lsdb, type, router, lsa)) {
|
2004-05-18 20:57:06 +02:00
|
|
|
if (!OSPF6_LSA_IS_MAXAGE(lsa))
|
2020-11-20 04:01:55 +01:00
|
|
|
ospf6_asbr_lsa_add(lsa);
|
2004-05-18 20:57:06 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-08 07:38:43 +02:00
|
|
|
void ospf6_asbr_lsentry_remove(struct ospf6_route *asbr_entry,
|
|
|
|
struct ospf6 *ospf6)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
2004-05-18 20:57:06 +02:00
|
|
|
struct ospf6_lsa *lsa;
|
2018-03-27 21:13:34 +02:00
|
|
|
uint16_t type;
|
|
|
|
uint32_t router;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
type = htons(OSPF6_LSTYPE_AS_EXTERNAL);
|
|
|
|
router = ospf6_linkstate_prefix_adv_router(&asbr_entry->prefix);
|
2017-07-07 17:23:30 +02:00
|
|
|
for (ALL_LSDB_TYPED_ADVRTR(ospf6->lsdb, type, router, lsa))
|
2018-02-15 04:02:11 +01:00
|
|
|
ospf6_asbr_lsa_remove(lsa, asbr_entry);
|
2004-05-18 20:57:06 +02:00
|
|
|
}
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
|
|
|
|
/* redistribute function */
|
2020-11-09 16:51:29 +01:00
|
|
|
static void ospf6_asbr_routemap_set(struct ospf6_redist *red,
|
|
|
|
const char *mapname)
|
2004-05-18 20:57:06 +02:00
|
|
|
{
|
2020-11-09 16:51:29 +01:00
|
|
|
if (ROUTEMAP_NAME(red)) {
|
|
|
|
route_map_counter_decrement(ROUTEMAP(red));
|
|
|
|
free(ROUTEMAP_NAME(red));
|
2019-02-04 14:16:25 +01:00
|
|
|
}
|
2020-11-09 16:51:29 +01:00
|
|
|
|
|
|
|
ROUTEMAP_NAME(red) = strdup(mapname);
|
|
|
|
ROUTEMAP(red) = route_map_lookup_by_name(mapname);
|
|
|
|
route_map_counter_increment(ROUTEMAP(red));
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
|
2020-11-09 16:51:29 +01:00
|
|
|
static void ospf6_asbr_routemap_unset(struct ospf6_redist *red)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
2020-11-09 16:51:29 +01:00
|
|
|
if (ROUTEMAP_NAME(red))
|
|
|
|
free(ROUTEMAP_NAME(red));
|
2019-02-04 14:16:25 +01:00
|
|
|
|
2020-11-09 16:51:29 +01:00
|
|
|
route_map_counter_decrement(ROUTEMAP(red));
|
2019-02-04 14:16:25 +01:00
|
|
|
|
2020-11-09 16:51:29 +01:00
|
|
|
ROUTEMAP_NAME(red) = NULL;
|
|
|
|
ROUTEMAP(red) = NULL;
|
2004-05-18 20:57:06 +02:00
|
|
|
}
|
|
|
|
|
2018-01-25 04:02:19 +01:00
|
|
|
static int ospf6_asbr_routemap_update_timer(struct thread *thread)
|
|
|
|
{
|
2021-06-30 08:13:19 +02:00
|
|
|
struct ospf6 *ospf6 = THREAD_ARG(thread);
|
2020-11-09 16:51:29 +01:00
|
|
|
struct ospf6_redist *red;
|
2021-06-30 08:13:19 +02:00
|
|
|
int type;
|
2018-01-25 04:02:19 +01:00
|
|
|
|
2021-06-30 08:13:19 +02:00
|
|
|
for (type = 0; type < ZEBRA_ROUTE_MAX; type++) {
|
|
|
|
red = ospf6_redist_lookup(ospf6, type, 0);
|
2020-11-09 16:51:29 +01:00
|
|
|
|
2021-06-30 08:13:19 +02:00
|
|
|
if (!red)
|
|
|
|
continue;
|
2018-01-25 04:02:19 +01:00
|
|
|
|
2021-06-30 08:13:19 +02:00
|
|
|
if (!CHECK_FLAG(red->flag, OSPF6_IS_RMAP_CHANGED))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (ROUTEMAP_NAME(red))
|
|
|
|
ROUTEMAP(red) =
|
|
|
|
route_map_lookup_by_name(ROUTEMAP_NAME(red));
|
|
|
|
|
|
|
|
if (ROUTEMAP(red)) {
|
|
|
|
if (IS_OSPF6_DEBUG_ASBR)
|
|
|
|
zlog_debug(
|
|
|
|
"%s: route-map %s update, reset redist %s",
|
|
|
|
__func__, ROUTEMAP_NAME(red),
|
|
|
|
ZROUTE_NAME(type));
|
|
|
|
|
|
|
|
ospf6_zebra_no_redistribute(type, ospf6->vrf_id);
|
|
|
|
ospf6_zebra_redistribute(type, ospf6->vrf_id);
|
|
|
|
}
|
|
|
|
|
|
|
|
UNSET_FLAG(red->flag, OSPF6_IS_RMAP_CHANGED);
|
2018-01-25 04:02:19 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2021-06-30 08:13:19 +02:00
|
|
|
void ospf6_asbr_distribute_list_update(struct ospf6 *ospf6,
|
|
|
|
struct ospf6_redist *red)
|
2018-01-25 04:02:19 +01:00
|
|
|
{
|
2021-06-30 08:13:19 +02:00
|
|
|
SET_FLAG(red->flag, OSPF6_IS_RMAP_CHANGED);
|
2018-01-25 04:02:19 +01:00
|
|
|
|
|
|
|
if (ospf6->t_distribute_update)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (IS_OSPF6_DEBUG_ASBR)
|
2021-06-30 08:13:19 +02:00
|
|
|
zlog_debug("%s: trigger redistribute reset thread", __func__);
|
2018-01-25 04:02:19 +01:00
|
|
|
|
2021-06-30 08:13:19 +02:00
|
|
|
thread_add_timer_msec(master, ospf6_asbr_routemap_update_timer, ospf6,
|
2020-04-08 07:57:15 +02:00
|
|
|
OSPF_MIN_LS_INTERVAL,
|
2018-01-25 04:02:19 +01:00
|
|
|
&ospf6->t_distribute_update);
|
|
|
|
}
|
|
|
|
|
2021-03-25 12:29:51 +01:00
|
|
|
void ospf6_asbr_routemap_update(const char *mapname)
|
2004-05-18 20:57:06 +02:00
|
|
|
{
|
|
|
|
int type;
|
2020-10-08 07:38:43 +02:00
|
|
|
struct listnode *node, *nnode;
|
|
|
|
struct ospf6 *ospf6 = NULL;
|
2020-11-09 16:51:29 +01:00
|
|
|
struct ospf6_redist *red;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2020-10-08 07:38:43 +02:00
|
|
|
if (om6 == NULL)
|
2002-12-13 21:15:29 +01:00
|
|
|
return;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2020-10-08 07:38:43 +02:00
|
|
|
for (ALL_LIST_ELEMENTS(om6->ospf6, node, nnode, ospf6)) {
|
|
|
|
for (type = 0; type < ZEBRA_ROUTE_MAX; type++) {
|
2020-11-09 16:51:29 +01:00
|
|
|
red = ospf6_redist_lookup(ospf6, type, 0);
|
|
|
|
if (!red || (ROUTEMAP_NAME(red) == NULL))
|
2020-11-02 17:24:21 +01:00
|
|
|
continue;
|
2020-11-09 16:51:29 +01:00
|
|
|
ROUTEMAP(red) =
|
|
|
|
route_map_lookup_by_name(ROUTEMAP_NAME(red));
|
2017-12-28 20:12:35 +01:00
|
|
|
|
2020-11-09 16:51:29 +01:00
|
|
|
if (mapname == NULL
|
|
|
|
|| strcmp(ROUTEMAP_NAME(red), mapname))
|
2020-11-02 17:24:21 +01:00
|
|
|
continue;
|
2020-11-09 16:51:29 +01:00
|
|
|
if (ROUTEMAP(red)) {
|
2020-11-02 17:24:21 +01:00
|
|
|
if (IS_OSPF6_DEBUG_ASBR)
|
|
|
|
zlog_debug(
|
2020-05-05 15:18:15 +02:00
|
|
|
"%s: route-map %s update, reset redist %s",
|
2020-11-02 17:24:21 +01:00
|
|
|
__func__,
|
|
|
|
mapname,
|
|
|
|
ZROUTE_NAME(
|
|
|
|
type));
|
2019-02-04 14:16:25 +01:00
|
|
|
|
2020-11-09 16:51:29 +01:00
|
|
|
route_map_counter_increment(ROUTEMAP(red));
|
2021-06-30 08:13:19 +02:00
|
|
|
ospf6_asbr_distribute_list_update(ospf6, red);
|
2020-11-02 17:24:21 +01:00
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* if the mapname matches a
|
|
|
|
* route-map on ospf6 but the
|
|
|
|
* map doesn't exist, it is
|
|
|
|
* being deleted. flush and then
|
|
|
|
* readvertise
|
|
|
|
*/
|
|
|
|
if (IS_OSPF6_DEBUG_ASBR)
|
|
|
|
zlog_debug(
|
2020-05-05 15:18:15 +02:00
|
|
|
"%s: route-map %s deleted, reset redist %s",
|
2020-11-02 17:24:21 +01:00
|
|
|
__func__,
|
|
|
|
mapname,
|
|
|
|
ZROUTE_NAME(
|
|
|
|
type));
|
2020-11-09 16:51:29 +01:00
|
|
|
ospf6_asbr_redistribute_unset(ospf6, red, type);
|
|
|
|
ospf6_asbr_routemap_set(red, mapname);
|
2021-06-22 15:09:28 +02:00
|
|
|
ospf6_asbr_redistribute_set(ospf6, type);
|
2017-12-28 20:12:35 +01:00
|
|
|
}
|
2020-10-08 07:38:43 +02:00
|
|
|
}
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-09 05:19:55 +02:00
|
|
|
static void ospf6_asbr_routemap_event(const char *name)
|
2018-01-25 04:02:19 +01:00
|
|
|
{
|
|
|
|
int type;
|
2020-10-08 07:38:43 +02:00
|
|
|
struct listnode *node, *nnode;
|
|
|
|
struct ospf6 *ospf6;
|
2020-11-09 16:51:29 +01:00
|
|
|
struct ospf6_redist *red;
|
2018-01-25 04:02:19 +01:00
|
|
|
|
2020-10-08 07:38:43 +02:00
|
|
|
if (om6 == NULL)
|
2018-01-25 04:02:19 +01:00
|
|
|
return;
|
2020-10-08 07:38:43 +02:00
|
|
|
for (ALL_LIST_ELEMENTS(om6->ospf6, node, nnode, ospf6)) {
|
|
|
|
for (type = 0; type < ZEBRA_ROUTE_MAX; type++) {
|
2020-11-09 16:51:29 +01:00
|
|
|
red = ospf6_redist_lookup(ospf6, type, 0);
|
|
|
|
if (red && ROUTEMAP_NAME(red)
|
|
|
|
&& (strcmp(ROUTEMAP_NAME(red), name) == 0))
|
2021-06-30 08:13:19 +02:00
|
|
|
ospf6_asbr_distribute_list_update(ospf6, red);
|
2018-01-25 04:02:19 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
int ospf6_asbr_is_asbr(struct ospf6 *o)
|
|
|
|
{
|
2021-03-25 12:29:51 +01:00
|
|
|
return (o->external_table->count || IS_OSPF6_ASBR(o));
|
2004-05-18 20:57:06 +02:00
|
|
|
}
|
|
|
|
|
2020-11-09 16:51:29 +01:00
|
|
|
struct ospf6_redist *ospf6_redist_lookup(struct ospf6 *ospf6, int type,
|
|
|
|
unsigned short instance)
|
|
|
|
{
|
|
|
|
struct list *red_list;
|
|
|
|
struct listnode *node;
|
|
|
|
struct ospf6_redist *red;
|
|
|
|
|
|
|
|
red_list = ospf6->redist[type];
|
|
|
|
if (!red_list)
|
|
|
|
return (NULL);
|
|
|
|
|
|
|
|
for (ALL_LIST_ELEMENTS_RO(red_list, node, red))
|
|
|
|
if (red->instance == instance)
|
|
|
|
return red;
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct ospf6_redist *ospf6_redist_add(struct ospf6 *ospf6, int type,
|
|
|
|
uint8_t instance)
|
|
|
|
{
|
|
|
|
struct ospf6_redist *red;
|
|
|
|
|
|
|
|
red = ospf6_redist_lookup(ospf6, type, instance);
|
|
|
|
if (red)
|
|
|
|
return red;
|
|
|
|
|
|
|
|
if (!ospf6->redist[type])
|
|
|
|
ospf6->redist[type] = list_new();
|
|
|
|
|
|
|
|
red = XCALLOC(MTYPE_OSPF6_REDISTRIBUTE, sizeof(struct ospf6_redist));
|
|
|
|
red->instance = instance;
|
2021-05-24 12:44:12 +02:00
|
|
|
red->dmetric.type = -1;
|
|
|
|
red->dmetric.value = -1;
|
2020-11-09 16:51:29 +01:00
|
|
|
ROUTEMAP_NAME(red) = NULL;
|
|
|
|
ROUTEMAP(red) = NULL;
|
|
|
|
|
|
|
|
listnode_add(ospf6->redist[type], red);
|
2021-02-10 07:44:44 +01:00
|
|
|
ospf6->redistribute++;
|
2020-11-09 16:51:29 +01:00
|
|
|
|
|
|
|
return red;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ospf6_redist_del(struct ospf6 *ospf6, struct ospf6_redist *red,
|
|
|
|
int type)
|
|
|
|
{
|
|
|
|
if (red) {
|
|
|
|
listnode_delete(ospf6->redist[type], red);
|
|
|
|
if (!ospf6->redist[type]->count) {
|
|
|
|
list_delete(&ospf6->redist[type]);
|
|
|
|
}
|
|
|
|
XFREE(MTYPE_OSPF6_REDISTRIBUTE, red);
|
2021-02-10 07:44:44 +01:00
|
|
|
ospf6->redistribute--;
|
2020-11-09 16:51:29 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-25 12:29:51 +01:00
|
|
|
/*Set the status of the ospf instance to ASBR based on the status parameter,
|
|
|
|
* rechedule SPF calculation, originate router LSA*/
|
|
|
|
void ospf6_asbr_status_update(struct ospf6 *ospf6, int status)
|
|
|
|
{
|
|
|
|
struct listnode *lnode, *lnnode;
|
|
|
|
struct ospf6_area *oa;
|
|
|
|
|
|
|
|
zlog_info("ASBR[%s:Status:%d]: Update", ospf6->name, status);
|
|
|
|
|
|
|
|
if (status) {
|
|
|
|
if (IS_OSPF6_ASBR(ospf6)) {
|
|
|
|
zlog_info("ASBR[%s:Status:%d]: Already ASBR",
|
|
|
|
ospf6->name, status);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
SET_FLAG(ospf6->flag, OSPF6_FLAG_ASBR);
|
|
|
|
} else {
|
|
|
|
if (!IS_OSPF6_ASBR(ospf6)) {
|
|
|
|
zlog_info("ASBR[%s:Status:%d]: Already non ASBR",
|
|
|
|
ospf6->name, status);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
UNSET_FLAG(ospf6->flag, OSPF6_FLAG_ASBR);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Transition from/to status ASBR, schedule timer. */
|
|
|
|
ospf6_spf_schedule(ospf6, OSPF6_SPF_FLAGS_ASBR_STATUS_CHANGE);
|
|
|
|
|
|
|
|
/* Reoriginate router LSA for all areas */
|
|
|
|
for (ALL_LIST_ELEMENTS(ospf6->area_list, lnode, lnnode, oa))
|
|
|
|
OSPF6_ROUTER_LSA_SCHEDULE(oa);
|
|
|
|
}
|
|
|
|
|
2021-06-22 15:09:28 +02:00
|
|
|
static void ospf6_asbr_redistribute_set(struct ospf6 *ospf6, int type)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
2021-06-22 15:09:28 +02:00
|
|
|
ospf6_zebra_redistribute(type, ospf6->vrf_id);
|
2021-03-25 12:29:51 +01:00
|
|
|
|
|
|
|
ospf6_asbr_status_update(ospf6, ++ospf6->redist_count);
|
2004-05-18 20:57:06 +02:00
|
|
|
}
|
|
|
|
|
2020-11-09 16:51:29 +01:00
|
|
|
static void ospf6_asbr_redistribute_unset(struct ospf6 *ospf6,
|
|
|
|
struct ospf6_redist *red, int type)
|
2004-05-18 20:57:06 +02:00
|
|
|
{
|
|
|
|
struct ospf6_route *route;
|
2002-12-13 21:15:29 +01:00
|
|
|
struct ospf6_external_info *info;
|
2020-10-08 07:38:43 +02:00
|
|
|
|
2020-11-09 16:51:29 +01:00
|
|
|
ospf6_zebra_no_redistribute(type, ospf6->vrf_id);
|
2004-05-18 20:57:06 +02:00
|
|
|
|
|
|
|
for (route = ospf6_route_head(ospf6->external_table); route;
|
|
|
|
route = ospf6_route_next(route)) {
|
|
|
|
info = route->route_option;
|
|
|
|
if (info->type != type)
|
|
|
|
continue;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2020-10-08 07:38:43 +02:00
|
|
|
ospf6_asbr_redistribute_remove(info->type, 0, &route->prefix,
|
|
|
|
ospf6);
|
2004-05-18 20:57:06 +02:00
|
|
|
}
|
2013-03-08 21:47:35 +01:00
|
|
|
|
2020-11-09 16:51:29 +01:00
|
|
|
ospf6_asbr_routemap_unset(red);
|
2021-03-25 12:29:51 +01:00
|
|
|
ospf6_asbr_status_update(ospf6, --ospf6->redist_count);
|
2004-05-18 20:57:06 +02:00
|
|
|
}
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2015-05-20 03:03:40 +02:00
|
|
|
/* When an area is unstubified, flood all the external LSAs in the area */
|
|
|
|
void ospf6_asbr_send_externals_to_area(struct ospf6_area *oa)
|
|
|
|
{
|
2020-08-17 14:25:12 +02:00
|
|
|
struct ospf6_lsa *lsa, *lsanext;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2020-08-17 14:25:12 +02:00
|
|
|
for (ALL_LSDB(oa->ospf6->lsdb, lsa, lsanext)) {
|
2015-05-20 03:03:40 +02:00
|
|
|
if (ntohs(lsa->header->type) == OSPF6_LSTYPE_AS_EXTERNAL) {
|
2021-03-25 18:44:50 +01:00
|
|
|
if (IS_OSPF6_DEBUG_ASBR)
|
|
|
|
zlog_debug("%s: Flooding AS-External LSA %s",
|
|
|
|
__func__, lsa->name);
|
|
|
|
|
2015-05-20 03:03:40 +02:00
|
|
|
ospf6_flood_area(NULL, lsa, oa);
|
2017-07-17 14:03:14 +02:00
|
|
|
}
|
2015-05-20 03:03:40 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-02 22:40:56 +01:00
|
|
|
/* When an area is stubified, remove all the external LSAs in the area */
|
|
|
|
void ospf6_asbr_remove_externals_from_area(struct ospf6_area *oa)
|
|
|
|
{
|
|
|
|
struct ospf6_lsa *lsa, *lsanext;
|
|
|
|
struct listnode *node, *nnode;
|
|
|
|
struct ospf6_area *area;
|
|
|
|
struct ospf6 *ospf6 = oa->ospf6;
|
2021-03-16 21:08:59 +01:00
|
|
|
const struct route_node *iterend;
|
2021-03-02 22:40:56 +01:00
|
|
|
|
2021-08-18 23:40:07 +02:00
|
|
|
/* skip if router is in other non-stub/non-NSSA areas */
|
2021-03-02 22:40:56 +01:00
|
|
|
for (ALL_LIST_ELEMENTS(ospf6->area_list, node, nnode, area))
|
2021-08-18 23:40:07 +02:00
|
|
|
if (!IS_AREA_STUB(area) && !IS_AREA_NSSA(area))
|
2021-03-02 22:40:56 +01:00
|
|
|
return;
|
|
|
|
|
|
|
|
/* if router is only in a stub area then purge AS-External LSAs */
|
2021-03-16 21:08:59 +01:00
|
|
|
iterend = ospf6_lsdb_head(ospf6->lsdb, 0, 0, 0, &lsa);
|
|
|
|
while (lsa != NULL) {
|
2021-03-29 19:33:07 +02:00
|
|
|
assert(lsa->lock > 1);
|
2021-03-16 21:08:59 +01:00
|
|
|
lsanext = ospf6_lsdb_next(iterend, lsa);
|
2021-03-02 22:40:56 +01:00
|
|
|
if (ntohs(lsa->header->type) == OSPF6_LSTYPE_AS_EXTERNAL)
|
|
|
|
ospf6_lsdb_remove(lsa, ospf6->lsdb);
|
2021-03-16 21:08:59 +01:00
|
|
|
lsa = lsanext;
|
2021-03-02 22:40:56 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-28 11:33:03 +02:00
|
|
|
static struct ospf6_external_aggr_rt *
|
|
|
|
ospf6_external_aggr_match(struct ospf6 *ospf6, struct prefix *p)
|
|
|
|
{
|
|
|
|
struct route_node *node;
|
|
|
|
|
2021-07-14 19:55:43 +02:00
|
|
|
node = route_node_match(ospf6->rt_aggr_tbl, p);
|
|
|
|
if (node == NULL)
|
|
|
|
return NULL;
|
2021-05-28 11:33:03 +02:00
|
|
|
|
2021-07-14 19:55:43 +02:00
|
|
|
if (IS_OSPF6_DEBUG_AGGR) {
|
|
|
|
struct ospf6_external_aggr_rt *ag = node->info;
|
|
|
|
zlog_debug("%s: Matching aggregator found.prefix: %pFX Aggregator %pFX",
|
|
|
|
__func__,
|
|
|
|
p,
|
|
|
|
&ag->p);
|
2021-05-28 11:33:03 +02:00
|
|
|
}
|
2021-07-14 19:55:43 +02:00
|
|
|
|
|
|
|
route_unlock_node(node);
|
|
|
|
|
|
|
|
return node->info;
|
2021-05-28 11:33:03 +02:00
|
|
|
}
|
|
|
|
|
2016-01-18 11:12:10 +01:00
|
|
|
void ospf6_asbr_redistribute_add(int type, ifindex_t ifindex,
|
2018-03-27 21:13:34 +02:00
|
|
|
struct prefix *prefix,
|
|
|
|
unsigned int nexthop_num,
|
2020-10-08 07:38:43 +02:00
|
|
|
struct in6_addr *nexthop, route_tag_t tag,
|
|
|
|
struct ospf6 *ospf6)
|
2004-05-18 20:57:06 +02:00
|
|
|
{
|
lib: Introducing a 3rd state for route-map match cmd: RMAP_NOOP
Introducing a 3rd state for route_map_apply library function: RMAP_NOOP
Traditionally route map MATCH rule apis were designed to return
a binary response, consisting of either RMAP_MATCH or RMAP_NOMATCH.
(Route-map SET rule apis return RMAP_OKAY or RMAP_ERROR).
Depending on this response, the following statemachine decided the
course of action:
State1:
If match cmd returns RMAP_MATCH then, keep existing behaviour.
If routemap type is PERMIT, execute set cmds or call cmds if applicable,
otherwise PERMIT!
Else If routemap type is DENY, we DENYMATCH right away
State2:
If match cmd returns RMAP_NOMATCH, continue on to next route-map. If there
are no other rules or if all the rules return RMAP_NOMATCH, return DENYMATCH
We require a 3rd state because of the following situation:
The issue - what if, the rule api needs to abort or ignore a rule?:
"match evpn vni xx" route-map filter can be applied to incoming routes
regardless of whether the tunnel type is vxlan or mpls.
This rule should be N/A for mpls based evpn route, but applicable to only
vxlan based evpn route.
Also, this rule should be applicable for routes with VNI label only, and
not for routes without labels. For example, type 3 and type 4 EVPN routes
do not have labels, so, this match cmd should let them through.
Today, the filter produces either a match or nomatch response regardless of
whether it is mpls/vxlan, resulting in either permitting or denying the
route.. So an mpls evpn route may get filtered out incorrectly.
Eg: "route-map RM1 permit 10 ; match evpn vni 20" or
"route-map RM2 deny 20 ; match vni 20"
With the introduction of the 3rd state, we can abort this rule check safely.
How? The rules api can now return RMAP_NOOP to indicate
that it encountered an invalid check, and needs to abort just that rule,
but continue with other rules.
As a result we have a 3rd state:
State3:
If match cmd returned RMAP_NOOP
Then, proceed to other route-map, otherwise if there are no more
rules or if all the rules return RMAP_NOOP, then, return RMAP_PERMITMATCH.
Signed-off-by: Lakshman Krishnamoorthy <lkrishnamoor@vmware.com>
2019-06-19 23:04:36 +02:00
|
|
|
route_map_result_t ret;
|
2004-05-18 20:57:06 +02:00
|
|
|
struct ospf6_route troute;
|
|
|
|
struct ospf6_external_info tinfo;
|
|
|
|
struct ospf6_route *route, *match;
|
|
|
|
struct ospf6_external_info *info;
|
|
|
|
struct prefix prefix_id;
|
|
|
|
struct route_node *node;
|
2020-10-18 13:33:54 +02:00
|
|
|
char ibuf[16];
|
2020-11-09 16:51:29 +01:00
|
|
|
struct ospf6_redist *red;
|
|
|
|
|
|
|
|
red = ospf6_redist_lookup(ospf6, type, 0);
|
|
|
|
|
|
|
|
if (!red)
|
|
|
|
return;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2021-02-10 05:53:46 +01:00
|
|
|
if ((type != DEFAULT_ROUTE)
|
|
|
|
&& !ospf6_zebra_is_redistribute(type, ospf6->vrf_id))
|
2004-05-18 20:57:06 +02:00
|
|
|
return;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2017-10-08 23:14:55 +02:00
|
|
|
memset(&troute, 0, sizeof(troute));
|
|
|
|
memset(&tinfo, 0, sizeof(tinfo));
|
|
|
|
|
2020-10-18 13:33:54 +02:00
|
|
|
if (IS_OSPF6_DEBUG_ASBR)
|
2021-09-08 18:13:19 +02:00
|
|
|
zlog_debug("Redistribute %pFX (%s)", prefix,
|
|
|
|
type == DEFAULT_ROUTE
|
|
|
|
? "default-information-originate"
|
|
|
|
: ZROUTE_NAME(type));
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
/* if route-map was specified but not found, do not advertise */
|
2020-11-09 16:51:29 +01:00
|
|
|
if (ROUTEMAP_NAME(red)) {
|
|
|
|
if (ROUTEMAP(red) == NULL)
|
2004-09-29 02:26:19 +02:00
|
|
|
ospf6_asbr_routemap_update(NULL);
|
2020-11-09 16:51:29 +01:00
|
|
|
if (ROUTEMAP(red) == NULL) {
|
2004-05-18 20:57:06 +02:00
|
|
|
zlog_warn(
|
|
|
|
"route-map \"%s\" not found, suppress redistributing",
|
2020-11-09 16:51:29 +01:00
|
|
|
ROUTEMAP_NAME(red));
|
2004-05-18 20:57:06 +02:00
|
|
|
return;
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
}
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
/* apply route-map */
|
2020-11-09 16:51:29 +01:00
|
|
|
if (ROUTEMAP(red)) {
|
2004-05-18 20:57:06 +02:00
|
|
|
troute.route_option = &tinfo;
|
2011-11-16 11:22:03 +01:00
|
|
|
tinfo.ifindex = ifindex;
|
2016-10-01 06:41:40 +02:00
|
|
|
tinfo.tag = tag;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2020-11-09 16:51:29 +01:00
|
|
|
ret = route_map_apply(ROUTEMAP(red), prefix, &troute);
|
2005-08-10 17:46:11 +02:00
|
|
|
if (ret == RMAP_DENYMATCH) {
|
2004-05-18 20:57:06 +02:00
|
|
|
if (IS_OSPF6_DEBUG_ASBR)
|
2004-12-24 07:00:11 +01:00
|
|
|
zlog_debug("Denied by route-map \"%s\"",
|
2020-11-09 16:51:29 +01:00
|
|
|
ROUTEMAP_NAME(red));
|
2020-10-08 07:38:43 +02:00
|
|
|
ospf6_asbr_redistribute_remove(type, ifindex, prefix,
|
|
|
|
ospf6);
|
2004-05-18 20:57:06 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
match = ospf6_route_lookup(prefix, ospf6->external_table);
|
|
|
|
if (match) {
|
|
|
|
info = match->route_option;
|
|
|
|
/* copy result of route-map */
|
2020-11-09 16:51:29 +01:00
|
|
|
if (ROUTEMAP(red)) {
|
2004-05-18 20:57:06 +02:00
|
|
|
if (troute.path.metric_type)
|
|
|
|
match->path.metric_type =
|
|
|
|
troute.path.metric_type;
|
2021-06-02 14:45:18 +02:00
|
|
|
else
|
|
|
|
match->path.metric_type =
|
|
|
|
metric_type(ospf6, type, 0);
|
2004-05-18 20:57:06 +02:00
|
|
|
if (troute.path.cost)
|
|
|
|
match->path.cost = troute.path.cost;
|
2021-06-02 14:45:18 +02:00
|
|
|
else
|
|
|
|
match->path.cost = metric_value(ospf6, type, 0);
|
2021-05-28 11:33:03 +02:00
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
if (!IN6_IS_ADDR_UNSPECIFIED(&tinfo.forwarding))
|
|
|
|
memcpy(&info->forwarding, &tinfo.forwarding,
|
|
|
|
sizeof(struct in6_addr));
|
2016-10-01 06:41:40 +02:00
|
|
|
info->tag = tinfo.tag;
|
|
|
|
} else {
|
2021-02-10 08:28:52 +01:00
|
|
|
/* If there is no route-map, simply update the tag and
|
|
|
|
* metric fields
|
|
|
|
*/
|
|
|
|
match->path.metric_type = metric_type(ospf6, type, 0);
|
|
|
|
match->path.cost = metric_value(ospf6, type, 0);
|
2016-10-01 06:41:40 +02:00
|
|
|
info->tag = tag;
|
2004-05-18 20:57:06 +02:00
|
|
|
}
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
info->type = type;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
if (nexthop_num && nexthop)
|
2015-05-20 03:03:39 +02:00
|
|
|
ospf6_route_add_nexthop(match, ifindex, nexthop);
|
|
|
|
else
|
|
|
|
ospf6_route_add_nexthop(match, ifindex, NULL);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
/* create/update binding in external_id_table */
|
|
|
|
prefix_id.family = AF_INET;
|
2021-07-01 17:05:11 +02:00
|
|
|
prefix_id.prefixlen = IPV4_MAX_BITLEN;
|
2004-05-18 20:57:06 +02:00
|
|
|
prefix_id.u.prefix4.s_addr = htonl(info->id);
|
|
|
|
node = route_node_get(ospf6->external_id_table, &prefix_id);
|
|
|
|
node->info = match;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
if (IS_OSPF6_DEBUG_ASBR) {
|
|
|
|
inet_ntop(AF_INET, &prefix_id.u.prefix4, ibuf,
|
|
|
|
sizeof(ibuf));
|
2018-01-25 04:02:19 +01:00
|
|
|
zlog_debug(
|
2020-10-18 13:33:54 +02:00
|
|
|
"Advertise as AS-External Id:%s prefix %pFX metric %u",
|
|
|
|
ibuf, prefix, match->path.metric_type);
|
2004-05-18 20:57:06 +02:00
|
|
|
}
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2004-08-19 08:56:53 +02:00
|
|
|
match->path.origin.id = htonl(info->id);
|
2021-05-28 11:33:03 +02:00
|
|
|
ospf6_handle_external_lsa_origination(ospf6, match, prefix);
|
|
|
|
|
2021-02-10 07:44:44 +01:00
|
|
|
ospf6_asbr_status_update(ospf6, ospf6->redistribute);
|
2021-03-25 12:29:51 +01:00
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
return;
|
|
|
|
}
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
/* create new entry */
|
2021-07-15 17:47:36 +02:00
|
|
|
route = ospf6_route_create(ospf6);
|
2004-05-18 20:57:06 +02:00
|
|
|
route->type = OSPF6_DEST_TYPE_NETWORK;
|
2021-05-24 13:30:26 +02:00
|
|
|
prefix_copy(&route->prefix, prefix);
|
2021-07-15 17:47:36 +02:00
|
|
|
route->ospf6 = ospf6;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
info = (struct ospf6_external_info *)XCALLOC(
|
2008-08-18 23:13:29 +02:00
|
|
|
MTYPE_OSPF6_EXTERNAL_INFO, sizeof(struct ospf6_external_info));
|
2004-05-18 20:57:06 +02:00
|
|
|
route->route_option = info;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
/* copy result of route-map */
|
2020-11-09 16:51:29 +01:00
|
|
|
if (ROUTEMAP(red)) {
|
2004-05-18 20:57:06 +02:00
|
|
|
if (troute.path.metric_type)
|
|
|
|
route->path.metric_type = troute.path.metric_type;
|
2021-06-02 14:45:18 +02:00
|
|
|
else
|
|
|
|
route->path.metric_type = metric_type(ospf6, type, 0);
|
2004-05-18 20:57:06 +02:00
|
|
|
if (troute.path.cost)
|
|
|
|
route->path.cost = troute.path.cost;
|
2021-06-02 14:45:18 +02:00
|
|
|
else
|
|
|
|
route->path.cost = metric_value(ospf6, type, 0);
|
2004-05-18 20:57:06 +02:00
|
|
|
if (!IN6_IS_ADDR_UNSPECIFIED(&tinfo.forwarding))
|
|
|
|
memcpy(&info->forwarding, &tinfo.forwarding,
|
|
|
|
sizeof(struct in6_addr));
|
2016-10-01 06:41:40 +02:00
|
|
|
info->tag = tinfo.tag;
|
|
|
|
} else {
|
2021-02-10 08:28:52 +01:00
|
|
|
/* If there is no route-map, simply update the tag and metric
|
|
|
|
* fields
|
|
|
|
*/
|
|
|
|
route->path.metric_type = metric_type(ospf6, type, 0);
|
|
|
|
route->path.cost = metric_value(ospf6, type, 0);
|
2016-10-01 06:41:40 +02:00
|
|
|
info->tag = tag;
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
info->type = type;
|
|
|
|
if (nexthop_num && nexthop)
|
2015-05-20 03:03:39 +02:00
|
|
|
ospf6_route_add_nexthop(route, ifindex, nexthop);
|
|
|
|
else
|
|
|
|
ospf6_route_add_nexthop(route, ifindex, NULL);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2020-11-20 02:13:52 +01:00
|
|
|
route = ospf6_route_add(route, ospf6->external_table);
|
2021-05-28 11:33:03 +02:00
|
|
|
ospf6_handle_external_lsa_origination(ospf6, route, prefix);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2021-02-10 07:44:44 +01:00
|
|
|
ospf6_asbr_status_update(ospf6, ospf6->redistribute);
|
2021-05-28 11:33:03 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ospf6_asbr_external_lsa_remove_by_id(struct ospf6 *ospf6,
|
|
|
|
uint32_t id)
|
|
|
|
{
|
|
|
|
struct ospf6_lsa *lsa;
|
|
|
|
|
|
|
|
lsa = ospf6_lsdb_lookup(htons(OSPF6_LSTYPE_AS_EXTERNAL),
|
|
|
|
htonl(id), ospf6->router_id, ospf6->lsdb);
|
|
|
|
if (!lsa)
|
|
|
|
return;
|
|
|
|
|
|
|
|
ospf6_external_lsa_purge(ospf6, lsa);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
ospf6_link_route_to_aggr(struct ospf6_external_aggr_rt *aggr,
|
|
|
|
struct ospf6_route *rt)
|
|
|
|
{
|
|
|
|
hash_get(aggr->match_extnl_hash, rt, hash_alloc_intern);
|
|
|
|
rt->aggr_route = aggr;
|
|
|
|
}
|
|
|
|
|
2021-07-14 11:07:37 +02:00
|
|
|
static void
|
|
|
|
ospf6_asbr_summary_remove_lsa_and_route(struct ospf6 *ospf6,
|
|
|
|
struct ospf6_external_aggr_rt *aggr)
|
|
|
|
{
|
|
|
|
|
|
|
|
/* Send a Max age LSA if it is already originated.*/
|
|
|
|
if (!CHECK_FLAG(aggr->aggrflags, OSPF6_EXTERNAL_AGGRT_ORIGINATED))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (IS_OSPF6_DEBUG_AGGR)
|
|
|
|
zlog_debug("%s: Flushing Aggregate route (%pFX)",
|
|
|
|
__func__,
|
|
|
|
&aggr->p);
|
|
|
|
|
|
|
|
ospf6_asbr_external_lsa_remove_by_id(ospf6, aggr->id);
|
|
|
|
|
|
|
|
if (aggr->route) {
|
|
|
|
if (IS_OSPF6_DEBUG_AGGR)
|
|
|
|
zlog_debug(
|
|
|
|
"%s: Remove the blackhole route",
|
|
|
|
__func__);
|
|
|
|
ospf6_zebra_route_update_remove(aggr->route, ospf6);
|
|
|
|
ospf6_route_delete(aggr->route);
|
|
|
|
aggr->route = NULL;
|
2021-03-25 12:29:51 +01:00
|
|
|
}
|
2021-07-14 11:07:37 +02:00
|
|
|
|
|
|
|
aggr->id = 0;
|
|
|
|
/* Unset the Origination flag */
|
|
|
|
UNSET_FLAG(aggr->aggrflags, OSPF6_EXTERNAL_AGGRT_ORIGINATED);
|
|
|
|
}
|
|
|
|
|
2021-05-28 11:33:03 +02:00
|
|
|
static void
|
2021-07-09 11:47:40 +02:00
|
|
|
ospf6_unlink_route_from_aggr(struct ospf6 *ospf6,
|
|
|
|
struct ospf6_external_aggr_rt *aggr,
|
|
|
|
struct ospf6_route *rt)
|
2021-05-28 11:33:03 +02:00
|
|
|
{
|
|
|
|
if (IS_OSPF6_DEBUG_AGGR)
|
|
|
|
zlog_debug("%s: Unlinking external route(%pFX) from aggregator(%pFX), external route count:%ld",
|
|
|
|
__func__,
|
|
|
|
&rt->prefix,
|
|
|
|
&aggr->p,
|
|
|
|
OSPF6_EXTERNAL_RT_COUNT(aggr));
|
|
|
|
|
|
|
|
hash_release(aggr->match_extnl_hash, rt);
|
|
|
|
rt->aggr_route = NULL;
|
|
|
|
|
|
|
|
/* Flush the aggregate route if matching
|
|
|
|
* external route count becomes zero.
|
|
|
|
*/
|
2021-07-14 11:07:37 +02:00
|
|
|
if (!OSPF6_EXTERNAL_RT_COUNT(aggr))
|
|
|
|
ospf6_asbr_summary_remove_lsa_and_route(ospf6, aggr);
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
|
2016-01-18 11:12:10 +01:00
|
|
|
void ospf6_asbr_redistribute_remove(int type, ifindex_t ifindex,
|
2020-10-08 07:38:43 +02:00
|
|
|
struct prefix *prefix, struct ospf6 *ospf6)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
2004-05-18 20:57:06 +02:00
|
|
|
struct ospf6_route *match;
|
|
|
|
struct ospf6_external_info *info = NULL;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
match = ospf6_route_lookup(prefix, ospf6->external_table);
|
|
|
|
if (match == NULL) {
|
2020-10-18 13:33:54 +02:00
|
|
|
if (IS_OSPF6_DEBUG_ASBR)
|
|
|
|
zlog_debug("No such route %pFX to withdraw", prefix);
|
2004-05-18 20:57:06 +02:00
|
|
|
return;
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
info = match->route_option;
|
|
|
|
assert(info);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
if (info->type != type) {
|
2020-10-18 13:33:54 +02:00
|
|
|
if (IS_OSPF6_DEBUG_ASBR)
|
|
|
|
zlog_debug("Original protocol mismatch: %pFX", prefix);
|
2004-05-18 20:57:06 +02:00
|
|
|
return;
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2021-05-28 11:33:03 +02:00
|
|
|
/* This means aggregation on this route was not done, hence remove LSA
|
|
|
|
* if any originated for this prefix
|
|
|
|
*/
|
|
|
|
if (!match->aggr_route)
|
|
|
|
ospf6_asbr_external_lsa_remove_by_id(ospf6, info->id);
|
|
|
|
else
|
|
|
|
ospf6_unlink_route_from_aggr(ospf6, match->aggr_route, match);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2021-07-09 11:47:40 +02:00
|
|
|
if (IS_OSPF6_DEBUG_ASBR)
|
|
|
|
zlog_debug("Removing route from external table %pFX",
|
|
|
|
prefix);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2020-11-20 02:13:52 +01:00
|
|
|
ospf6_route_remove(match, ospf6->external_table);
|
2004-05-18 20:57:06 +02:00
|
|
|
XFREE(MTYPE_OSPF6_EXTERNAL_INFO, info);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2021-02-10 07:44:44 +01:00
|
|
|
ospf6_asbr_status_update(ospf6, ospf6->redistribute);
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
|
2021-08-26 18:10:41 +02:00
|
|
|
DEFPY (ospf6_redistribute,
|
2004-05-18 20:57:06 +02:00
|
|
|
ospf6_redistribute_cmd,
|
2021-08-26 18:10:41 +02:00
|
|
|
"redistribute " FRR_REDIST_STR_OSPF6D "[{metric (0-16777214)|metric-type (1-2)$metric_type|route-map WORD$rmap_str}]",
|
2004-05-18 20:57:06 +02:00
|
|
|
"Redistribute\n"
|
2016-12-20 18:31:42 +01:00
|
|
|
FRR_REDIST_HELP_STR_OSPF6D
|
2021-08-26 18:10:41 +02:00
|
|
|
"Metric for redistributed routes\n"
|
|
|
|
"OSPF default metric\n"
|
|
|
|
"OSPF exterior metric type for redistributed routes\n"
|
|
|
|
"Set OSPF External Type 1/2 metrics\n"
|
2004-05-18 20:57:06 +02:00
|
|
|
"Route map reference\n"
|
2016-10-18 01:36:21 +02:00
|
|
|
"Route map name\n")
|
2004-05-18 20:57:06 +02:00
|
|
|
{
|
2009-09-16 01:52:42 +02:00
|
|
|
int type;
|
2020-11-09 16:51:29 +01:00
|
|
|
struct ospf6_redist *red;
|
2021-08-26 18:10:41 +02:00
|
|
|
int idx_protocol = 1;
|
|
|
|
char *proto = argv[idx_protocol]->text;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2020-10-08 07:38:43 +02:00
|
|
|
VTY_DECLVAR_CONTEXT(ospf6, ospf6);
|
2020-09-01 10:31:49 +02:00
|
|
|
|
2016-12-16 06:39:44 +01:00
|
|
|
type = proto_redistnum(AFI_IP6, proto);
|
|
|
|
if (type < 0)
|
2017-07-13 21:56:08 +02:00
|
|
|
return CMD_WARNING_CONFIG_FAILED;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2021-08-26 18:10:41 +02:00
|
|
|
if (!metric_str)
|
|
|
|
metric = -1;
|
|
|
|
if (!metric_type_str)
|
|
|
|
metric_type = -1;
|
|
|
|
|
2021-06-22 15:12:41 +02:00
|
|
|
red = ospf6_redist_lookup(ospf6, type, 0);
|
2021-08-19 11:34:47 +02:00
|
|
|
if (!red) {
|
2021-06-22 15:12:41 +02:00
|
|
|
red = ospf6_redist_add(ospf6, type, 0);
|
2021-08-19 11:34:47 +02:00
|
|
|
} else {
|
2021-08-26 18:10:41 +02:00
|
|
|
/* Check if nothing has changed. */
|
|
|
|
if (red->dmetric.value == metric
|
|
|
|
&& red->dmetric.type == metric_type
|
|
|
|
&& ((!ROUTEMAP_NAME(red) && !rmap_str)
|
|
|
|
|| (ROUTEMAP_NAME(red) && rmap_str
|
|
|
|
&& strmatch(ROUTEMAP_NAME(red), rmap_str))))
|
2021-08-19 11:34:47 +02:00
|
|
|
return CMD_SUCCESS;
|
|
|
|
|
2021-06-22 15:12:41 +02:00
|
|
|
ospf6_asbr_redistribute_unset(ospf6, red, type);
|
2021-08-19 11:34:47 +02:00
|
|
|
}
|
2020-11-09 16:51:29 +01:00
|
|
|
|
2021-08-26 18:10:41 +02:00
|
|
|
red->dmetric.value = metric;
|
|
|
|
red->dmetric.type = metric_type;
|
|
|
|
if (rmap_str)
|
|
|
|
ospf6_asbr_routemap_set(red, rmap_str);
|
|
|
|
else
|
|
|
|
ospf6_asbr_routemap_unset(red);
|
2021-06-22 15:09:28 +02:00
|
|
|
ospf6_asbr_redistribute_set(ospf6, type);
|
2020-11-09 16:51:29 +01:00
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
return CMD_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
DEFUN (no_ospf6_redistribute,
|
|
|
|
no_ospf6_redistribute_cmd,
|
2021-08-26 18:10:41 +02:00
|
|
|
"no redistribute " FRR_REDIST_STR_OSPF6D "[{metric (0-16777214)|metric-type (1-2)|route-map WORD}]",
|
2004-05-18 20:57:06 +02:00
|
|
|
NO_STR
|
|
|
|
"Redistribute\n"
|
2016-12-20 18:31:42 +01:00
|
|
|
FRR_REDIST_HELP_STR_OSPF6D
|
2021-08-26 18:10:41 +02:00
|
|
|
"Metric for redistributed routes\n"
|
|
|
|
"OSPF default metric\n"
|
|
|
|
"OSPF exterior metric type for redistributed routes\n"
|
|
|
|
"Set OSPF External Type 1/2 metrics\n"
|
2016-09-30 03:27:05 +02:00
|
|
|
"Route map reference\n"
|
|
|
|
"Route map name\n")
|
2004-05-18 20:57:06 +02:00
|
|
|
{
|
2009-09-16 01:52:42 +02:00
|
|
|
int type;
|
2020-11-09 16:51:29 +01:00
|
|
|
struct ospf6_redist *red;
|
2021-08-26 18:10:41 +02:00
|
|
|
int idx_protocol = 2;
|
|
|
|
char *proto = argv[idx_protocol]->text;
|
2009-09-16 01:52:42 +02:00
|
|
|
|
2020-10-08 07:38:43 +02:00
|
|
|
VTY_DECLVAR_CONTEXT(ospf6, ospf6);
|
|
|
|
|
2016-12-16 06:39:44 +01:00
|
|
|
type = proto_redistnum(AFI_IP6, proto);
|
|
|
|
if (type < 0)
|
2017-07-13 21:56:08 +02:00
|
|
|
return CMD_WARNING_CONFIG_FAILED;
|
2003-05-25 23:39:29 +02:00
|
|
|
|
2020-11-09 16:51:29 +01:00
|
|
|
red = ospf6_redist_lookup(ospf6, type, 0);
|
|
|
|
if (!red)
|
|
|
|
return CMD_SUCCESS;
|
|
|
|
|
|
|
|
ospf6_asbr_redistribute_unset(ospf6, red, type);
|
|
|
|
ospf6_redist_del(ospf6, red, type);
|
2003-05-25 23:39:29 +02:00
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
return CMD_SUCCESS;
|
|
|
|
}
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2020-10-08 07:38:43 +02:00
|
|
|
int ospf6_redistribute_config_write(struct vty *vty, struct ospf6 *ospf6)
|
2004-05-18 20:57:06 +02:00
|
|
|
{
|
|
|
|
int type;
|
2020-11-09 16:51:29 +01:00
|
|
|
struct ospf6_redist *red;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
for (type = 0; type < ZEBRA_ROUTE_MAX; type++) {
|
2020-11-09 16:51:29 +01:00
|
|
|
red = ospf6_redist_lookup(ospf6, type, 0);
|
|
|
|
if (!red)
|
2004-05-18 20:57:06 +02:00
|
|
|
continue;
|
2020-11-09 16:51:29 +01:00
|
|
|
if (type == ZEBRA_ROUTE_OSPF6)
|
2004-05-18 20:57:06 +02:00
|
|
|
continue;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2021-08-26 18:10:41 +02:00
|
|
|
vty_out(vty, " redistribute %s", ZROUTE_NAME(type));
|
|
|
|
if (red->dmetric.value >= 0)
|
|
|
|
vty_out(vty, " metric %d", red->dmetric.value);
|
2021-09-07 00:51:46 +02:00
|
|
|
if (red->dmetric.type == 1)
|
2021-08-26 18:10:41 +02:00
|
|
|
vty_out(vty, " metric-type 1");
|
2020-11-09 16:51:29 +01:00
|
|
|
if (ROUTEMAP_NAME(red))
|
2021-08-26 18:10:41 +02:00
|
|
|
vty_out(vty, " route-map %s", ROUTEMAP_NAME(red));
|
|
|
|
vty_out(vty, "\n");
|
2004-05-18 20:57:06 +02:00
|
|
|
}
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-09-28 07:25:10 +02:00
|
|
|
static void ospf6_redistribute_show_config(struct vty *vty, struct ospf6 *ospf6,
|
|
|
|
json_object *json_array,
|
|
|
|
json_object *json, bool use_json)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
2004-05-18 20:57:06 +02:00
|
|
|
int type;
|
|
|
|
int nroute[ZEBRA_ROUTE_MAX];
|
|
|
|
int total;
|
|
|
|
struct ospf6_route *route;
|
|
|
|
struct ospf6_external_info *info;
|
2020-09-28 07:25:10 +02:00
|
|
|
json_object *json_route;
|
2020-11-09 16:51:29 +01:00
|
|
|
struct ospf6_redist *red;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
total = 0;
|
2021-01-24 13:48:22 +01:00
|
|
|
memset(nroute, 0, sizeof(nroute));
|
2004-05-18 20:57:06 +02:00
|
|
|
for (route = ospf6_route_head(ospf6->external_table); route;
|
2017-07-13 19:50:33 +02:00
|
|
|
route = ospf6_route_next(route)) {
|
|
|
|
info = route->route_option;
|
2017-07-13 19:42:42 +02:00
|
|
|
nroute[info->type]++;
|
|
|
|
total++;
|
2004-05-18 20:57:06 +02:00
|
|
|
}
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2021-01-24 13:48:22 +01:00
|
|
|
if (!use_json)
|
2020-09-28 07:25:10 +02:00
|
|
|
vty_out(vty, "Redistributing External Routes from:\n");
|
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
for (type = 0; type < ZEBRA_ROUTE_MAX; type++) {
|
2021-01-24 13:48:22 +01:00
|
|
|
|
2020-11-09 16:51:29 +01:00
|
|
|
red = ospf6_redist_lookup(ospf6, type, 0);
|
|
|
|
|
|
|
|
if (!red)
|
2004-05-18 20:57:06 +02:00
|
|
|
continue;
|
2020-11-09 16:51:29 +01:00
|
|
|
if (type == ZEBRA_ROUTE_OSPF6)
|
2004-05-18 20:57:06 +02:00
|
|
|
continue;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2020-09-28 07:25:10 +02:00
|
|
|
if (use_json) {
|
2021-01-24 13:48:22 +01:00
|
|
|
json_route = json_object_new_object();
|
2020-09-28 07:25:10 +02:00
|
|
|
json_object_string_add(json_route, "routeType",
|
|
|
|
ZROUTE_NAME(type));
|
|
|
|
json_object_int_add(json_route, "numberOfRoutes",
|
|
|
|
nroute[type]);
|
|
|
|
json_object_boolean_add(json_route,
|
|
|
|
"routeMapNamePresent",
|
2020-11-09 16:51:29 +01:00
|
|
|
ROUTEMAP_NAME(red));
|
2020-09-28 07:25:10 +02:00
|
|
|
}
|
|
|
|
|
2020-11-09 16:51:29 +01:00
|
|
|
if (ROUTEMAP_NAME(red)) {
|
2020-09-28 07:25:10 +02:00
|
|
|
if (use_json) {
|
|
|
|
json_object_string_add(json_route,
|
|
|
|
"routeMapName",
|
2020-11-09 16:51:29 +01:00
|
|
|
ROUTEMAP_NAME(red));
|
2020-09-28 07:25:10 +02:00
|
|
|
json_object_boolean_add(json_route,
|
|
|
|
"routeMapFound",
|
2020-11-09 16:51:29 +01:00
|
|
|
ROUTEMAP(red));
|
2020-09-28 07:25:10 +02:00
|
|
|
} else
|
|
|
|
vty_out(vty,
|
|
|
|
" %d: %s with route-map \"%s\"%s\n",
|
|
|
|
nroute[type], ZROUTE_NAME(type),
|
2020-11-09 16:51:29 +01:00
|
|
|
ROUTEMAP_NAME(red),
|
|
|
|
(ROUTEMAP(red) ? ""
|
|
|
|
: " (not found !)"));
|
2020-09-28 07:25:10 +02:00
|
|
|
} else {
|
|
|
|
if (!use_json)
|
|
|
|
vty_out(vty, " %d: %s\n", nroute[type],
|
|
|
|
ZROUTE_NAME(type));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (use_json)
|
|
|
|
json_object_array_add(json_array, json_route);
|
2017-07-17 14:03:14 +02:00
|
|
|
}
|
2020-09-28 07:25:10 +02:00
|
|
|
if (use_json) {
|
|
|
|
json_object_object_add(json, "redistributedRoutes", json_array);
|
|
|
|
json_object_int_add(json, "totalRoutes", total);
|
|
|
|
} else
|
|
|
|
vty_out(vty, "Total %d routes\n", total);
|
2017-07-17 14:03:14 +02:00
|
|
|
}
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2021-02-10 05:53:46 +01:00
|
|
|
static void ospf6_redistribute_default_set(struct ospf6 *ospf6, int originate)
|
|
|
|
{
|
|
|
|
struct prefix_ipv6 p = {};
|
|
|
|
struct in6_addr nexthop = {};
|
|
|
|
int cur_originate = ospf6->default_originate;
|
|
|
|
|
|
|
|
p.family = AF_INET6;
|
|
|
|
p.prefixlen = 0;
|
|
|
|
|
|
|
|
ospf6->default_originate = originate;
|
|
|
|
|
|
|
|
switch (cur_originate) {
|
|
|
|
case DEFAULT_ORIGINATE_NONE:
|
|
|
|
break;
|
|
|
|
case DEFAULT_ORIGINATE_ZEBRA:
|
|
|
|
zclient_redistribute_default(ZEBRA_REDISTRIBUTE_DEFAULT_DELETE,
|
|
|
|
zclient, AFI_IP6, ospf6->vrf_id);
|
|
|
|
ospf6_asbr_redistribute_remove(DEFAULT_ROUTE, 0,
|
|
|
|
(struct prefix *)&p, ospf6);
|
|
|
|
|
|
|
|
break;
|
|
|
|
case DEFAULT_ORIGINATE_ALWAYS:
|
|
|
|
ospf6_asbr_redistribute_remove(DEFAULT_ROUTE, 0,
|
|
|
|
(struct prefix *)&p, ospf6);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (originate) {
|
|
|
|
case DEFAULT_ORIGINATE_NONE:
|
|
|
|
break;
|
|
|
|
case DEFAULT_ORIGINATE_ZEBRA:
|
|
|
|
zclient_redistribute_default(ZEBRA_REDISTRIBUTE_DEFAULT_ADD,
|
|
|
|
zclient, AFI_IP6, ospf6->vrf_id);
|
|
|
|
|
|
|
|
break;
|
|
|
|
case DEFAULT_ORIGINATE_ALWAYS:
|
|
|
|
ospf6_asbr_redistribute_add(DEFAULT_ROUTE, 0,
|
|
|
|
(struct prefix *)&p, 0, &nexthop, 0,
|
|
|
|
ospf6);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Default Route originate. */
|
|
|
|
DEFPY (ospf6_default_route_originate,
|
|
|
|
ospf6_default_route_originate_cmd,
|
|
|
|
"default-information originate [{always$always|metric (0-16777214)$mval|metric-type (1-2)$mtype|route-map WORD$rtmap}]",
|
|
|
|
"Control distribution of default route\n"
|
|
|
|
"Distribute a default route\n"
|
|
|
|
"Always advertise default route\n"
|
|
|
|
"OSPFv3 default metric\n"
|
|
|
|
"OSPFv3 metric\n"
|
|
|
|
"OSPFv3 metric type for default routes\n"
|
|
|
|
"Set OSPFv3 External Type 1/2 metrics\n"
|
|
|
|
"Route map reference\n"
|
|
|
|
"Pointer to route-map entries\n")
|
|
|
|
{
|
|
|
|
int default_originate = DEFAULT_ORIGINATE_ZEBRA;
|
|
|
|
struct ospf6_redist *red;
|
|
|
|
bool sameRtmap = false;
|
|
|
|
|
|
|
|
VTY_DECLVAR_CONTEXT(ospf6, ospf6);
|
|
|
|
|
|
|
|
int cur_originate = ospf6->default_originate;
|
|
|
|
|
|
|
|
red = ospf6_redist_add(ospf6, DEFAULT_ROUTE, 0);
|
|
|
|
|
|
|
|
if (always != NULL)
|
|
|
|
default_originate = DEFAULT_ORIGINATE_ALWAYS;
|
|
|
|
|
|
|
|
if (mval_str == NULL)
|
|
|
|
mval = -1;
|
|
|
|
|
|
|
|
if (mtype_str == NULL)
|
|
|
|
mtype = -1;
|
|
|
|
|
|
|
|
/* To check ,if user is providing same route map */
|
|
|
|
if ((rtmap == ROUTEMAP_NAME(red))
|
|
|
|
|| (rtmap && ROUTEMAP_NAME(red)
|
|
|
|
&& (strcmp(rtmap, ROUTEMAP_NAME(red)) == 0)))
|
|
|
|
sameRtmap = true;
|
|
|
|
|
|
|
|
/* Don't allow if the same lsa is aleardy originated. */
|
|
|
|
if ((sameRtmap) && (red->dmetric.type == mtype)
|
|
|
|
&& (red->dmetric.value == mval)
|
|
|
|
&& (cur_originate == default_originate))
|
|
|
|
return CMD_SUCCESS;
|
|
|
|
|
|
|
|
/* Updating Metric details */
|
|
|
|
red->dmetric.type = mtype;
|
|
|
|
red->dmetric.value = mval;
|
|
|
|
|
|
|
|
/* updating route map details */
|
|
|
|
if (rtmap)
|
|
|
|
ospf6_asbr_routemap_set(red, rtmap);
|
|
|
|
else
|
|
|
|
ospf6_asbr_routemap_unset(red);
|
|
|
|
|
|
|
|
ospf6_redistribute_default_set(ospf6, default_originate);
|
|
|
|
return CMD_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
DEFPY (no_ospf6_default_information_originate,
|
|
|
|
no_ospf6_default_information_originate_cmd,
|
|
|
|
"no default-information originate [{always|metric (0-16777214)|metric-type (1-2)|route-map WORD}]",
|
|
|
|
NO_STR
|
|
|
|
"Control distribution of default information\n"
|
|
|
|
"Distribute a default route\n"
|
|
|
|
"Always advertise default route\n"
|
|
|
|
"OSPFv3 default metric\n"
|
|
|
|
"OSPFv3 metric\n"
|
|
|
|
"OSPFv3 metric type for default routes\n"
|
|
|
|
"Set OSPFv3 External Type 1/2 metrics\n"
|
|
|
|
"Route map reference\n"
|
|
|
|
"Pointer to route-map entries\n")
|
|
|
|
{
|
|
|
|
struct ospf6_redist *red;
|
|
|
|
|
|
|
|
VTY_DECLVAR_CONTEXT(ospf6, ospf6);
|
|
|
|
|
|
|
|
red = ospf6_redist_lookup(ospf6, DEFAULT_ROUTE, 0);
|
|
|
|
if (!red)
|
|
|
|
return CMD_SUCCESS;
|
|
|
|
|
|
|
|
ospf6_asbr_routemap_unset(red);
|
|
|
|
ospf6_redist_del(ospf6, red, DEFAULT_ROUTE);
|
|
|
|
|
|
|
|
ospf6_redistribute_default_set(ospf6, DEFAULT_ORIGINATE_NONE);
|
|
|
|
return CMD_SUCCESS;
|
|
|
|
}
|
2014-06-04 06:53:35 +02:00
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
/* Routemap Functions */
|
lib: Introducing a 3rd state for route-map match cmd: RMAP_NOOP
Introducing a 3rd state for route_map_apply library function: RMAP_NOOP
Traditionally route map MATCH rule apis were designed to return
a binary response, consisting of either RMAP_MATCH or RMAP_NOMATCH.
(Route-map SET rule apis return RMAP_OKAY or RMAP_ERROR).
Depending on this response, the following statemachine decided the
course of action:
State1:
If match cmd returns RMAP_MATCH then, keep existing behaviour.
If routemap type is PERMIT, execute set cmds or call cmds if applicable,
otherwise PERMIT!
Else If routemap type is DENY, we DENYMATCH right away
State2:
If match cmd returns RMAP_NOMATCH, continue on to next route-map. If there
are no other rules or if all the rules return RMAP_NOMATCH, return DENYMATCH
We require a 3rd state because of the following situation:
The issue - what if, the rule api needs to abort or ignore a rule?:
"match evpn vni xx" route-map filter can be applied to incoming routes
regardless of whether the tunnel type is vxlan or mpls.
This rule should be N/A for mpls based evpn route, but applicable to only
vxlan based evpn route.
Also, this rule should be applicable for routes with VNI label only, and
not for routes without labels. For example, type 3 and type 4 EVPN routes
do not have labels, so, this match cmd should let them through.
Today, the filter produces either a match or nomatch response regardless of
whether it is mpls/vxlan, resulting in either permitting or denying the
route.. So an mpls evpn route may get filtered out incorrectly.
Eg: "route-map RM1 permit 10 ; match evpn vni 20" or
"route-map RM2 deny 20 ; match vni 20"
With the introduction of the 3rd state, we can abort this rule check safely.
How? The rules api can now return RMAP_NOOP to indicate
that it encountered an invalid check, and needs to abort just that rule,
but continue with other rules.
As a result we have a 3rd state:
State3:
If match cmd returned RMAP_NOOP
Then, proceed to other route-map, otherwise if there are no more
rules or if all the rules return RMAP_NOOP, then, return RMAP_PERMITMATCH.
Signed-off-by: Lakshman Krishnamoorthy <lkrishnamoor@vmware.com>
2019-06-19 23:04:36 +02:00
|
|
|
static enum route_map_cmd_result_t
|
2018-07-12 22:05:19 +02:00
|
|
|
ospf6_routemap_rule_match_address_prefixlist(void *rule,
|
|
|
|
const struct prefix *prefix,
|
2020-11-14 01:35:20 +01:00
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
void *object)
|
|
|
|
{
|
|
|
|
struct prefix_list *plist;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
plist = prefix_list_lookup(AFI_IP6, (char *)rule);
|
|
|
|
if (plist == NULL)
|
|
|
|
return RMAP_NOMATCH;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
return (prefix_list_apply(plist, prefix) == PREFIX_DENY ? RMAP_NOMATCH
|
|
|
|
: RMAP_MATCH);
|
|
|
|
}
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2008-08-15 14:45:30 +02:00
|
|
|
static void *
|
2004-10-10 14:54:58 +02:00
|
|
|
ospf6_routemap_rule_match_address_prefixlist_compile(const char *arg)
|
2004-05-18 20:57:06 +02:00
|
|
|
{
|
|
|
|
return XSTRDUP(MTYPE_ROUTE_MAP_COMPILED, arg);
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
static void ospf6_routemap_rule_match_address_prefixlist_free(void *rule)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
2004-05-18 20:57:06 +02:00
|
|
|
XFREE(MTYPE_ROUTE_MAP_COMPILED, rule);
|
|
|
|
}
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2019-11-20 17:20:58 +01:00
|
|
|
static const struct route_map_rule_cmd
|
|
|
|
ospf6_routemap_rule_match_address_prefixlist_cmd = {
|
2004-05-18 20:57:06 +02:00
|
|
|
"ipv6 address prefix-list",
|
|
|
|
ospf6_routemap_rule_match_address_prefixlist,
|
|
|
|
ospf6_routemap_rule_match_address_prefixlist_compile,
|
|
|
|
ospf6_routemap_rule_match_address_prefixlist_free,
|
|
|
|
};
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2011-11-16 11:22:03 +01:00
|
|
|
/* `match interface IFNAME' */
|
|
|
|
/* Match function should return 1 if match is success else return
|
|
|
|
zero. */
|
lib: Introducing a 3rd state for route-map match cmd: RMAP_NOOP
Introducing a 3rd state for route_map_apply library function: RMAP_NOOP
Traditionally route map MATCH rule apis were designed to return
a binary response, consisting of either RMAP_MATCH or RMAP_NOMATCH.
(Route-map SET rule apis return RMAP_OKAY or RMAP_ERROR).
Depending on this response, the following statemachine decided the
course of action:
State1:
If match cmd returns RMAP_MATCH then, keep existing behaviour.
If routemap type is PERMIT, execute set cmds or call cmds if applicable,
otherwise PERMIT!
Else If routemap type is DENY, we DENYMATCH right away
State2:
If match cmd returns RMAP_NOMATCH, continue on to next route-map. If there
are no other rules or if all the rules return RMAP_NOMATCH, return DENYMATCH
We require a 3rd state because of the following situation:
The issue - what if, the rule api needs to abort or ignore a rule?:
"match evpn vni xx" route-map filter can be applied to incoming routes
regardless of whether the tunnel type is vxlan or mpls.
This rule should be N/A for mpls based evpn route, but applicable to only
vxlan based evpn route.
Also, this rule should be applicable for routes with VNI label only, and
not for routes without labels. For example, type 3 and type 4 EVPN routes
do not have labels, so, this match cmd should let them through.
Today, the filter produces either a match or nomatch response regardless of
whether it is mpls/vxlan, resulting in either permitting or denying the
route.. So an mpls evpn route may get filtered out incorrectly.
Eg: "route-map RM1 permit 10 ; match evpn vni 20" or
"route-map RM2 deny 20 ; match vni 20"
With the introduction of the 3rd state, we can abort this rule check safely.
How? The rules api can now return RMAP_NOOP to indicate
that it encountered an invalid check, and needs to abort just that rule,
but continue with other rules.
As a result we have a 3rd state:
State3:
If match cmd returned RMAP_NOOP
Then, proceed to other route-map, otherwise if there are no more
rules or if all the rules return RMAP_NOOP, then, return RMAP_PERMITMATCH.
Signed-off-by: Lakshman Krishnamoorthy <lkrishnamoor@vmware.com>
2019-06-19 23:04:36 +02:00
|
|
|
static enum route_map_cmd_result_t
|
2018-07-12 22:05:19 +02:00
|
|
|
ospf6_routemap_rule_match_interface(void *rule, const struct prefix *prefix,
|
2020-11-14 01:35:20 +01:00
|
|
|
void *object)
|
2011-11-16 11:22:03 +01:00
|
|
|
{
|
|
|
|
struct interface *ifp;
|
|
|
|
struct ospf6_external_info *ei;
|
|
|
|
|
2020-11-14 01:35:20 +01:00
|
|
|
ei = ((struct ospf6_route *)object)->route_option;
|
|
|
|
ifp = if_lookup_by_name_all_vrf((char *)rule);
|
2011-11-16 11:22:03 +01:00
|
|
|
|
2020-11-14 01:35:20 +01:00
|
|
|
if (ifp != NULL && ei->ifindex == ifp->ifindex)
|
|
|
|
return RMAP_MATCH;
|
2011-11-16 11:22:03 +01:00
|
|
|
|
|
|
|
return RMAP_NOMATCH;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Route map `interface' match statement. `arg' should be
|
|
|
|
interface name. */
|
|
|
|
static void *ospf6_routemap_rule_match_interface_compile(const char *arg)
|
|
|
|
{
|
|
|
|
return XSTRDUP(MTYPE_ROUTE_MAP_COMPILED, arg);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Free route map's compiled `interface' value. */
|
|
|
|
static void ospf6_routemap_rule_match_interface_free(void *rule)
|
|
|
|
{
|
|
|
|
XFREE(MTYPE_ROUTE_MAP_COMPILED, rule);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Route map commands for interface matching. */
|
2019-11-20 17:20:58 +01:00
|
|
|
static const struct route_map_rule_cmd
|
|
|
|
ospf6_routemap_rule_match_interface_cmd = {
|
|
|
|
"interface",
|
|
|
|
ospf6_routemap_rule_match_interface,
|
2011-11-16 11:22:03 +01:00
|
|
|
ospf6_routemap_rule_match_interface_compile,
|
2019-11-20 17:20:58 +01:00
|
|
|
ospf6_routemap_rule_match_interface_free
|
|
|
|
};
|
2011-11-16 11:22:03 +01:00
|
|
|
|
2016-10-01 06:41:40 +02:00
|
|
|
/* Match function for matching route tags */
|
lib: Introducing a 3rd state for route-map match cmd: RMAP_NOOP
Introducing a 3rd state for route_map_apply library function: RMAP_NOOP
Traditionally route map MATCH rule apis were designed to return
a binary response, consisting of either RMAP_MATCH or RMAP_NOMATCH.
(Route-map SET rule apis return RMAP_OKAY or RMAP_ERROR).
Depending on this response, the following statemachine decided the
course of action:
State1:
If match cmd returns RMAP_MATCH then, keep existing behaviour.
If routemap type is PERMIT, execute set cmds or call cmds if applicable,
otherwise PERMIT!
Else If routemap type is DENY, we DENYMATCH right away
State2:
If match cmd returns RMAP_NOMATCH, continue on to next route-map. If there
are no other rules or if all the rules return RMAP_NOMATCH, return DENYMATCH
We require a 3rd state because of the following situation:
The issue - what if, the rule api needs to abort or ignore a rule?:
"match evpn vni xx" route-map filter can be applied to incoming routes
regardless of whether the tunnel type is vxlan or mpls.
This rule should be N/A for mpls based evpn route, but applicable to only
vxlan based evpn route.
Also, this rule should be applicable for routes with VNI label only, and
not for routes without labels. For example, type 3 and type 4 EVPN routes
do not have labels, so, this match cmd should let them through.
Today, the filter produces either a match or nomatch response regardless of
whether it is mpls/vxlan, resulting in either permitting or denying the
route.. So an mpls evpn route may get filtered out incorrectly.
Eg: "route-map RM1 permit 10 ; match evpn vni 20" or
"route-map RM2 deny 20 ; match vni 20"
With the introduction of the 3rd state, we can abort this rule check safely.
How? The rules api can now return RMAP_NOOP to indicate
that it encountered an invalid check, and needs to abort just that rule,
but continue with other rules.
As a result we have a 3rd state:
State3:
If match cmd returned RMAP_NOOP
Then, proceed to other route-map, otherwise if there are no more
rules or if all the rules return RMAP_NOOP, then, return RMAP_PERMITMATCH.
Signed-off-by: Lakshman Krishnamoorthy <lkrishnamoor@vmware.com>
2019-06-19 23:04:36 +02:00
|
|
|
static enum route_map_cmd_result_t
|
2020-11-14 01:35:20 +01:00
|
|
|
ospf6_routemap_rule_match_tag(void *rule, const struct prefix *p, void *object)
|
2016-10-01 06:41:40 +02:00
|
|
|
{
|
|
|
|
route_tag_t *tag = rule;
|
|
|
|
struct ospf6_route *route = object;
|
|
|
|
struct ospf6_external_info *info = route->route_option;
|
|
|
|
|
2020-11-14 01:35:20 +01:00
|
|
|
if (info->tag == *tag)
|
2016-10-01 06:41:40 +02:00
|
|
|
return RMAP_MATCH;
|
|
|
|
|
|
|
|
return RMAP_NOMATCH;
|
|
|
|
}
|
|
|
|
|
2019-11-20 17:20:58 +01:00
|
|
|
static const struct route_map_rule_cmd
|
|
|
|
ospf6_routemap_rule_match_tag_cmd = {
|
|
|
|
"tag",
|
|
|
|
ospf6_routemap_rule_match_tag,
|
|
|
|
route_map_rule_tag_compile,
|
2016-10-01 06:41:40 +02:00
|
|
|
route_map_rule_tag_free,
|
|
|
|
};
|
|
|
|
|
lib: Introducing a 3rd state for route-map match cmd: RMAP_NOOP
Introducing a 3rd state for route_map_apply library function: RMAP_NOOP
Traditionally route map MATCH rule apis were designed to return
a binary response, consisting of either RMAP_MATCH or RMAP_NOMATCH.
(Route-map SET rule apis return RMAP_OKAY or RMAP_ERROR).
Depending on this response, the following statemachine decided the
course of action:
State1:
If match cmd returns RMAP_MATCH then, keep existing behaviour.
If routemap type is PERMIT, execute set cmds or call cmds if applicable,
otherwise PERMIT!
Else If routemap type is DENY, we DENYMATCH right away
State2:
If match cmd returns RMAP_NOMATCH, continue on to next route-map. If there
are no other rules or if all the rules return RMAP_NOMATCH, return DENYMATCH
We require a 3rd state because of the following situation:
The issue - what if, the rule api needs to abort or ignore a rule?:
"match evpn vni xx" route-map filter can be applied to incoming routes
regardless of whether the tunnel type is vxlan or mpls.
This rule should be N/A for mpls based evpn route, but applicable to only
vxlan based evpn route.
Also, this rule should be applicable for routes with VNI label only, and
not for routes without labels. For example, type 3 and type 4 EVPN routes
do not have labels, so, this match cmd should let them through.
Today, the filter produces either a match or nomatch response regardless of
whether it is mpls/vxlan, resulting in either permitting or denying the
route.. So an mpls evpn route may get filtered out incorrectly.
Eg: "route-map RM1 permit 10 ; match evpn vni 20" or
"route-map RM2 deny 20 ; match vni 20"
With the introduction of the 3rd state, we can abort this rule check safely.
How? The rules api can now return RMAP_NOOP to indicate
that it encountered an invalid check, and needs to abort just that rule,
but continue with other rules.
As a result we have a 3rd state:
State3:
If match cmd returned RMAP_NOOP
Then, proceed to other route-map, otherwise if there are no more
rules or if all the rules return RMAP_NOOP, then, return RMAP_PERMITMATCH.
Signed-off-by: Lakshman Krishnamoorthy <lkrishnamoor@vmware.com>
2019-06-19 23:04:36 +02:00
|
|
|
static enum route_map_cmd_result_t
|
2018-07-12 22:05:19 +02:00
|
|
|
ospf6_routemap_rule_set_metric_type(void *rule, const struct prefix *prefix,
|
2020-11-14 01:35:20 +01:00
|
|
|
void *object)
|
2004-05-18 20:57:06 +02:00
|
|
|
{
|
|
|
|
char *metric_type = rule;
|
|
|
|
struct ospf6_route *route = object;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
if (strcmp(metric_type, "type-2") == 0)
|
|
|
|
route->path.metric_type = 2;
|
2002-12-13 21:15:29 +01:00
|
|
|
else
|
2004-05-18 20:57:06 +02:00
|
|
|
route->path.metric_type = 1;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
return RMAP_OKAY;
|
|
|
|
}
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2004-10-10 14:54:58 +02:00
|
|
|
static void *ospf6_routemap_rule_set_metric_type_compile(const char *arg)
|
2004-05-18 20:57:06 +02:00
|
|
|
{
|
|
|
|
if (strcmp(arg, "type-2") && strcmp(arg, "type-1"))
|
|
|
|
return NULL;
|
|
|
|
return XSTRDUP(MTYPE_ROUTE_MAP_COMPILED, arg);
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
static void ospf6_routemap_rule_set_metric_type_free(void *rule)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
2004-05-18 20:57:06 +02:00
|
|
|
XFREE(MTYPE_ROUTE_MAP_COMPILED, rule);
|
|
|
|
}
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2019-11-20 17:20:58 +01:00
|
|
|
static const struct route_map_rule_cmd
|
|
|
|
ospf6_routemap_rule_set_metric_type_cmd = {
|
|
|
|
"metric-type",
|
|
|
|
ospf6_routemap_rule_set_metric_type,
|
2004-05-18 20:57:06 +02:00
|
|
|
ospf6_routemap_rule_set_metric_type_compile,
|
|
|
|
ospf6_routemap_rule_set_metric_type_free,
|
|
|
|
};
|
2002-12-13 21:15:29 +01:00
|
|
|
|
lib: Introducing a 3rd state for route-map match cmd: RMAP_NOOP
Introducing a 3rd state for route_map_apply library function: RMAP_NOOP
Traditionally route map MATCH rule apis were designed to return
a binary response, consisting of either RMAP_MATCH or RMAP_NOMATCH.
(Route-map SET rule apis return RMAP_OKAY or RMAP_ERROR).
Depending on this response, the following statemachine decided the
course of action:
State1:
If match cmd returns RMAP_MATCH then, keep existing behaviour.
If routemap type is PERMIT, execute set cmds or call cmds if applicable,
otherwise PERMIT!
Else If routemap type is DENY, we DENYMATCH right away
State2:
If match cmd returns RMAP_NOMATCH, continue on to next route-map. If there
are no other rules or if all the rules return RMAP_NOMATCH, return DENYMATCH
We require a 3rd state because of the following situation:
The issue - what if, the rule api needs to abort or ignore a rule?:
"match evpn vni xx" route-map filter can be applied to incoming routes
regardless of whether the tunnel type is vxlan or mpls.
This rule should be N/A for mpls based evpn route, but applicable to only
vxlan based evpn route.
Also, this rule should be applicable for routes with VNI label only, and
not for routes without labels. For example, type 3 and type 4 EVPN routes
do not have labels, so, this match cmd should let them through.
Today, the filter produces either a match or nomatch response regardless of
whether it is mpls/vxlan, resulting in either permitting or denying the
route.. So an mpls evpn route may get filtered out incorrectly.
Eg: "route-map RM1 permit 10 ; match evpn vni 20" or
"route-map RM2 deny 20 ; match vni 20"
With the introduction of the 3rd state, we can abort this rule check safely.
How? The rules api can now return RMAP_NOOP to indicate
that it encountered an invalid check, and needs to abort just that rule,
but continue with other rules.
As a result we have a 3rd state:
State3:
If match cmd returned RMAP_NOOP
Then, proceed to other route-map, otherwise if there are no more
rules or if all the rules return RMAP_NOOP, then, return RMAP_PERMITMATCH.
Signed-off-by: Lakshman Krishnamoorthy <lkrishnamoor@vmware.com>
2019-06-19 23:04:36 +02:00
|
|
|
static enum route_map_cmd_result_t
|
2018-07-12 22:05:19 +02:00
|
|
|
ospf6_routemap_rule_set_metric(void *rule, const struct prefix *prefix,
|
2020-11-14 01:35:20 +01:00
|
|
|
void *object)
|
2004-05-18 20:57:06 +02:00
|
|
|
{
|
|
|
|
char *metric = rule;
|
|
|
|
struct ospf6_route *route = object;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
route->path.cost = atoi(metric);
|
|
|
|
return RMAP_OKAY;
|
|
|
|
}
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2004-10-10 14:54:58 +02:00
|
|
|
static void *ospf6_routemap_rule_set_metric_compile(const char *arg)
|
2004-05-18 20:57:06 +02:00
|
|
|
{
|
2018-03-27 21:13:34 +02:00
|
|
|
uint32_t metric;
|
2004-05-18 20:57:06 +02:00
|
|
|
char *endp;
|
|
|
|
metric = strtoul(arg, &endp, 0);
|
2013-10-23 02:42:18 +02:00
|
|
|
if (metric > OSPF_LS_INFINITY || *endp != '\0')
|
2004-05-18 20:57:06 +02:00
|
|
|
return NULL;
|
|
|
|
return XSTRDUP(MTYPE_ROUTE_MAP_COMPILED, arg);
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
static void ospf6_routemap_rule_set_metric_free(void *rule)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
2004-05-18 20:57:06 +02:00
|
|
|
XFREE(MTYPE_ROUTE_MAP_COMPILED, rule);
|
|
|
|
}
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2019-11-20 17:20:58 +01:00
|
|
|
static const struct route_map_rule_cmd
|
|
|
|
ospf6_routemap_rule_set_metric_cmd = {
|
|
|
|
"metric",
|
|
|
|
ospf6_routemap_rule_set_metric,
|
2004-05-18 20:57:06 +02:00
|
|
|
ospf6_routemap_rule_set_metric_compile,
|
|
|
|
ospf6_routemap_rule_set_metric_free,
|
|
|
|
};
|
2002-12-13 21:15:29 +01:00
|
|
|
|
lib: Introducing a 3rd state for route-map match cmd: RMAP_NOOP
Introducing a 3rd state for route_map_apply library function: RMAP_NOOP
Traditionally route map MATCH rule apis were designed to return
a binary response, consisting of either RMAP_MATCH or RMAP_NOMATCH.
(Route-map SET rule apis return RMAP_OKAY or RMAP_ERROR).
Depending on this response, the following statemachine decided the
course of action:
State1:
If match cmd returns RMAP_MATCH then, keep existing behaviour.
If routemap type is PERMIT, execute set cmds or call cmds if applicable,
otherwise PERMIT!
Else If routemap type is DENY, we DENYMATCH right away
State2:
If match cmd returns RMAP_NOMATCH, continue on to next route-map. If there
are no other rules or if all the rules return RMAP_NOMATCH, return DENYMATCH
We require a 3rd state because of the following situation:
The issue - what if, the rule api needs to abort or ignore a rule?:
"match evpn vni xx" route-map filter can be applied to incoming routes
regardless of whether the tunnel type is vxlan or mpls.
This rule should be N/A for mpls based evpn route, but applicable to only
vxlan based evpn route.
Also, this rule should be applicable for routes with VNI label only, and
not for routes without labels. For example, type 3 and type 4 EVPN routes
do not have labels, so, this match cmd should let them through.
Today, the filter produces either a match or nomatch response regardless of
whether it is mpls/vxlan, resulting in either permitting or denying the
route.. So an mpls evpn route may get filtered out incorrectly.
Eg: "route-map RM1 permit 10 ; match evpn vni 20" or
"route-map RM2 deny 20 ; match vni 20"
With the introduction of the 3rd state, we can abort this rule check safely.
How? The rules api can now return RMAP_NOOP to indicate
that it encountered an invalid check, and needs to abort just that rule,
but continue with other rules.
As a result we have a 3rd state:
State3:
If match cmd returned RMAP_NOOP
Then, proceed to other route-map, otherwise if there are no more
rules or if all the rules return RMAP_NOOP, then, return RMAP_PERMITMATCH.
Signed-off-by: Lakshman Krishnamoorthy <lkrishnamoor@vmware.com>
2019-06-19 23:04:36 +02:00
|
|
|
static enum route_map_cmd_result_t
|
2018-07-12 22:05:19 +02:00
|
|
|
ospf6_routemap_rule_set_forwarding(void *rule, const struct prefix *prefix,
|
2020-11-14 01:35:20 +01:00
|
|
|
void *object)
|
2004-05-18 20:57:06 +02:00
|
|
|
{
|
|
|
|
char *forwarding = rule;
|
|
|
|
struct ospf6_route *route = object;
|
|
|
|
struct ospf6_external_info *info = route->route_option;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
if (inet_pton(AF_INET6, forwarding, &info->forwarding) != 1) {
|
|
|
|
memset(&info->forwarding, 0, sizeof(struct in6_addr));
|
|
|
|
return RMAP_ERROR;
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
return RMAP_OKAY;
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
|
2004-10-10 14:54:58 +02:00
|
|
|
static void *ospf6_routemap_rule_set_forwarding_compile(const char *arg)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
2004-05-18 20:57:06 +02:00
|
|
|
struct in6_addr a;
|
|
|
|
if (inet_pton(AF_INET6, arg, &a) != 1)
|
|
|
|
return NULL;
|
|
|
|
return XSTRDUP(MTYPE_ROUTE_MAP_COMPILED, arg);
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
static void ospf6_routemap_rule_set_forwarding_free(void *rule)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
2004-05-18 20:57:06 +02:00
|
|
|
XFREE(MTYPE_ROUTE_MAP_COMPILED, rule);
|
|
|
|
}
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2019-11-20 17:20:58 +01:00
|
|
|
static const struct route_map_rule_cmd
|
|
|
|
ospf6_routemap_rule_set_forwarding_cmd = {
|
|
|
|
"forwarding-address",
|
|
|
|
ospf6_routemap_rule_set_forwarding,
|
2004-05-18 20:57:06 +02:00
|
|
|
ospf6_routemap_rule_set_forwarding_compile,
|
|
|
|
ospf6_routemap_rule_set_forwarding_free,
|
|
|
|
};
|
2002-12-13 21:15:29 +01:00
|
|
|
|
lib: Introducing a 3rd state for route-map match cmd: RMAP_NOOP
Introducing a 3rd state for route_map_apply library function: RMAP_NOOP
Traditionally route map MATCH rule apis were designed to return
a binary response, consisting of either RMAP_MATCH or RMAP_NOMATCH.
(Route-map SET rule apis return RMAP_OKAY or RMAP_ERROR).
Depending on this response, the following statemachine decided the
course of action:
State1:
If match cmd returns RMAP_MATCH then, keep existing behaviour.
If routemap type is PERMIT, execute set cmds or call cmds if applicable,
otherwise PERMIT!
Else If routemap type is DENY, we DENYMATCH right away
State2:
If match cmd returns RMAP_NOMATCH, continue on to next route-map. If there
are no other rules or if all the rules return RMAP_NOMATCH, return DENYMATCH
We require a 3rd state because of the following situation:
The issue - what if, the rule api needs to abort or ignore a rule?:
"match evpn vni xx" route-map filter can be applied to incoming routes
regardless of whether the tunnel type is vxlan or mpls.
This rule should be N/A for mpls based evpn route, but applicable to only
vxlan based evpn route.
Also, this rule should be applicable for routes with VNI label only, and
not for routes without labels. For example, type 3 and type 4 EVPN routes
do not have labels, so, this match cmd should let them through.
Today, the filter produces either a match or nomatch response regardless of
whether it is mpls/vxlan, resulting in either permitting or denying the
route.. So an mpls evpn route may get filtered out incorrectly.
Eg: "route-map RM1 permit 10 ; match evpn vni 20" or
"route-map RM2 deny 20 ; match vni 20"
With the introduction of the 3rd state, we can abort this rule check safely.
How? The rules api can now return RMAP_NOOP to indicate
that it encountered an invalid check, and needs to abort just that rule,
but continue with other rules.
As a result we have a 3rd state:
State3:
If match cmd returned RMAP_NOOP
Then, proceed to other route-map, otherwise if there are no more
rules or if all the rules return RMAP_NOOP, then, return RMAP_PERMITMATCH.
Signed-off-by: Lakshman Krishnamoorthy <lkrishnamoor@vmware.com>
2019-06-19 23:04:36 +02:00
|
|
|
static enum route_map_cmd_result_t
|
2020-11-14 01:35:20 +01:00
|
|
|
ospf6_routemap_rule_set_tag(void *rule, const struct prefix *p, void *object)
|
2016-10-01 06:41:40 +02:00
|
|
|
{
|
|
|
|
route_tag_t *tag = rule;
|
|
|
|
struct ospf6_route *route = object;
|
|
|
|
struct ospf6_external_info *info = route->route_option;
|
|
|
|
|
|
|
|
info->tag = *tag;
|
|
|
|
return RMAP_OKAY;
|
|
|
|
}
|
|
|
|
|
2020-10-30 08:42:34 +01:00
|
|
|
static const struct route_map_rule_cmd ospf6_routemap_rule_set_tag_cmd = {
|
2019-11-20 17:20:58 +01:00
|
|
|
"tag",
|
|
|
|
ospf6_routemap_rule_set_tag,
|
|
|
|
route_map_rule_tag_compile,
|
2016-10-01 06:41:40 +02:00
|
|
|
route_map_rule_tag_free,
|
|
|
|
};
|
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
/* add "set metric-type" */
|
2020-10-30 08:42:34 +01:00
|
|
|
DEFUN_YANG (ospf6_routemap_set_metric_type, ospf6_routemap_set_metric_type_cmd,
|
|
|
|
"set metric-type <type-1|type-2>",
|
|
|
|
"Set value\n"
|
|
|
|
"Type of metric\n"
|
|
|
|
"OSPF6 external type 1 metric\n"
|
|
|
|
"OSPF6 external type 2 metric\n")
|
2004-05-18 20:57:06 +02:00
|
|
|
{
|
2020-10-30 08:42:34 +01:00
|
|
|
char *ext = argv[2]->text;
|
|
|
|
|
|
|
|
const char *xpath =
|
|
|
|
"./set-action[action='frr-ospf-route-map:metric-type']";
|
|
|
|
char xpath_value[XPATH_MAXLEN];
|
2019-08-27 14:04:43 +02:00
|
|
|
|
2020-10-30 08:42:34 +01:00
|
|
|
nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
|
|
|
|
snprintf(xpath_value, sizeof(xpath_value),
|
|
|
|
"%s/rmap-set-action/frr-ospf-route-map:metric-type", xpath);
|
|
|
|
nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY, ext);
|
|
|
|
return nb_cli_apply_changes(vty, NULL);
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
/* delete "set metric-type" */
|
2020-10-30 08:42:34 +01:00
|
|
|
DEFUN_YANG (ospf6_routemap_no_set_metric_type, ospf6_routemap_no_set_metric_type_cmd,
|
|
|
|
"no set metric-type [<type-1|type-2>]",
|
|
|
|
NO_STR
|
|
|
|
"Set value\n"
|
|
|
|
"Type of metric\n"
|
|
|
|
"OSPF6 external type 1 metric\n"
|
|
|
|
"OSPF6 external type 2 metric\n")
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
2020-10-30 08:42:34 +01:00
|
|
|
const char *xpath =
|
|
|
|
"./set-action[action='frr-ospf-route-map:metric-type']";
|
2019-08-27 14:04:43 +02:00
|
|
|
|
2020-10-30 08:42:34 +01:00
|
|
|
nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
|
|
|
|
return nb_cli_apply_changes(vty, NULL);
|
2004-05-18 20:57:06 +02:00
|
|
|
}
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
/* add "set forwarding-address" */
|
2020-10-30 08:42:34 +01:00
|
|
|
DEFUN_YANG (ospf6_routemap_set_forwarding, ospf6_routemap_set_forwarding_cmd,
|
|
|
|
"set forwarding-address X:X::X:X",
|
|
|
|
"Set value\n"
|
|
|
|
"Forwarding Address\n"
|
|
|
|
"IPv6 Address\n")
|
2004-05-18 20:57:06 +02:00
|
|
|
{
|
2016-09-23 21:56:31 +02:00
|
|
|
int idx_ipv6 = 2;
|
2020-10-30 08:42:34 +01:00
|
|
|
const char *xpath =
|
|
|
|
"./set-action[action='frr-ospf6-route-map:forwarding-address']";
|
|
|
|
char xpath_value[XPATH_MAXLEN];
|
|
|
|
|
|
|
|
nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
|
|
|
|
snprintf(xpath_value, sizeof(xpath_value),
|
|
|
|
"%s/rmap-set-action/frr-ospf6-route-map:ipv6-address", xpath);
|
|
|
|
nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY,
|
|
|
|
argv[idx_ipv6]->arg);
|
|
|
|
return nb_cli_apply_changes(vty, NULL);
|
2004-05-18 20:57:06 +02:00
|
|
|
}
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
/* delete "set forwarding-address" */
|
2020-10-30 08:42:34 +01:00
|
|
|
DEFUN_YANG (ospf6_routemap_no_set_forwarding, ospf6_routemap_no_set_forwarding_cmd,
|
|
|
|
"no set forwarding-address [X:X::X:X]",
|
|
|
|
NO_STR
|
|
|
|
"Set value\n"
|
|
|
|
"Forwarding Address\n"
|
|
|
|
"IPv6 Address\n")
|
2004-05-18 20:57:06 +02:00
|
|
|
{
|
2020-10-30 08:42:34 +01:00
|
|
|
const char *xpath =
|
|
|
|
"./set-action[action='frr-ospf6-route-map:forwarding-address']";
|
2019-08-27 14:04:43 +02:00
|
|
|
|
2020-10-30 08:42:34 +01:00
|
|
|
nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
|
|
|
|
return nb_cli_apply_changes(vty, NULL);
|
2004-05-18 20:57:06 +02:00
|
|
|
}
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2008-08-15 14:45:30 +02:00
|
|
|
static void ospf6_routemap_init(void)
|
2004-05-18 20:57:06 +02:00
|
|
|
{
|
|
|
|
route_map_init();
|
2016-10-19 16:55:01 +02:00
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
route_map_add_hook(ospf6_asbr_routemap_update);
|
|
|
|
route_map_delete_hook(ospf6_asbr_routemap_update);
|
2018-01-25 04:02:19 +01:00
|
|
|
route_map_event_hook(ospf6_asbr_routemap_event);
|
2004-05-18 20:57:06 +02:00
|
|
|
|
2016-10-06 21:56:13 +02:00
|
|
|
route_map_set_metric_hook(generic_set_add);
|
|
|
|
route_map_no_set_metric_hook(generic_set_delete);
|
|
|
|
|
2021-05-26 16:03:51 +02:00
|
|
|
route_map_set_tag_hook(generic_set_add);
|
|
|
|
route_map_no_set_tag_hook(generic_set_delete);
|
|
|
|
|
2017-05-03 20:39:21 +02:00
|
|
|
route_map_match_tag_hook(generic_match_add);
|
|
|
|
route_map_no_match_tag_hook(generic_match_delete);
|
|
|
|
|
|
|
|
route_map_match_ipv6_address_prefix_list_hook(generic_match_add);
|
|
|
|
route_map_no_match_ipv6_address_prefix_list_hook(generic_match_delete);
|
|
|
|
|
|
|
|
route_map_match_interface_hook(generic_match_add);
|
|
|
|
route_map_no_match_interface_hook(generic_match_delete);
|
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
route_map_install_match(
|
|
|
|
&ospf6_routemap_rule_match_address_prefixlist_cmd);
|
2011-11-16 11:22:03 +01:00
|
|
|
route_map_install_match(&ospf6_routemap_rule_match_interface_cmd);
|
2016-10-01 06:41:40 +02:00
|
|
|
route_map_install_match(&ospf6_routemap_rule_match_tag_cmd);
|
2011-11-16 11:22:03 +01:00
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
route_map_install_set(&ospf6_routemap_rule_set_metric_type_cmd);
|
|
|
|
route_map_install_set(&ospf6_routemap_rule_set_metric_cmd);
|
|
|
|
route_map_install_set(&ospf6_routemap_rule_set_forwarding_cmd);
|
2016-10-01 06:41:40 +02:00
|
|
|
route_map_install_set(&ospf6_routemap_rule_set_tag_cmd);
|
2004-05-18 20:57:06 +02:00
|
|
|
|
|
|
|
/* ASE Metric Type (e.g. Type-1/Type-2) */
|
|
|
|
install_element(RMAP_NODE, &ospf6_routemap_set_metric_type_cmd);
|
|
|
|
install_element(RMAP_NODE, &ospf6_routemap_no_set_metric_type_cmd);
|
|
|
|
|
|
|
|
/* ASE Metric */
|
|
|
|
install_element(RMAP_NODE, &ospf6_routemap_set_forwarding_cmd);
|
|
|
|
install_element(RMAP_NODE, &ospf6_routemap_no_set_forwarding_cmd);
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
|
2014-06-04 06:53:35 +02:00
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
/* Display functions */
|
2013-08-25 05:03:23 +02:00
|
|
|
static char *ospf6_as_external_lsa_get_prefix_str(struct ospf6_lsa *lsa,
|
|
|
|
char *buf, int buflen,
|
|
|
|
int pos)
|
|
|
|
{
|
|
|
|
struct ospf6_as_external_lsa *external;
|
|
|
|
struct in6_addr in6;
|
|
|
|
int prefix_length = 0;
|
2021-02-08 04:39:42 +01:00
|
|
|
char tbuf[16];
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2013-08-25 05:03:23 +02:00
|
|
|
if (lsa) {
|
|
|
|
external = (struct ospf6_as_external_lsa *)OSPF6_LSA_HEADER_END(
|
|
|
|
lsa->header);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2013-08-25 05:03:23 +02:00
|
|
|
if (pos == 0) {
|
2018-06-27 11:47:57 +02:00
|
|
|
ospf6_prefix_in6_addr(&in6, external,
|
|
|
|
&external->prefix);
|
2013-08-25 05:03:23 +02:00
|
|
|
prefix_length = external->prefix.prefix_length;
|
|
|
|
} else {
|
|
|
|
in6 = *((struct in6_addr
|
|
|
|
*)((caddr_t)external
|
|
|
|
+ sizeof(struct
|
|
|
|
ospf6_as_external_lsa)
|
|
|
|
+ OSPF6_PREFIX_SPACE(
|
|
|
|
external->prefix
|
|
|
|
.prefix_length)));
|
2017-07-17 14:03:14 +02:00
|
|
|
}
|
|
|
|
if (buf) {
|
2013-08-25 05:03:23 +02:00
|
|
|
inet_ntop(AF_INET6, &in6, buf, buflen);
|
2021-02-08 04:39:42 +01:00
|
|
|
if (prefix_length) {
|
|
|
|
snprintf(tbuf, sizeof(tbuf), "/%d",
|
|
|
|
prefix_length);
|
|
|
|
strlcat(buf, tbuf, buflen);
|
|
|
|
}
|
2017-07-17 14:03:14 +02:00
|
|
|
}
|
2013-08-25 05:03:23 +02:00
|
|
|
}
|
|
|
|
return (buf);
|
|
|
|
}
|
|
|
|
|
2020-12-04 06:54:40 +01:00
|
|
|
static int ospf6_as_external_lsa_show(struct vty *vty, struct ospf6_lsa *lsa,
|
|
|
|
json_object *json_obj, bool use_json)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
2004-05-18 20:57:06 +02:00
|
|
|
struct ospf6_as_external_lsa *external;
|
|
|
|
char buf[64];
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
assert(lsa->header);
|
2004-05-18 20:57:06 +02:00
|
|
|
external = (struct ospf6_as_external_lsa *)OSPF6_LSA_HEADER_END(
|
|
|
|
lsa->header);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
/* bits */
|
2004-05-18 20:57:06 +02:00
|
|
|
snprintf(buf, sizeof(buf), "%c%c%c",
|
|
|
|
(CHECK_FLAG(external->bits_metric, OSPF6_ASBR_BIT_E) ? 'E'
|
|
|
|
: '-'),
|
|
|
|
(CHECK_FLAG(external->bits_metric, OSPF6_ASBR_BIT_F) ? 'F'
|
|
|
|
: '-'),
|
|
|
|
(CHECK_FLAG(external->bits_metric, OSPF6_ASBR_BIT_T) ? 'T'
|
|
|
|
: '-'));
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2020-12-04 06:54:40 +01:00
|
|
|
if (use_json) {
|
|
|
|
json_object_string_add(json_obj, "bits", buf);
|
|
|
|
json_object_int_add(json_obj, "metric",
|
|
|
|
(unsigned long)OSPF6_ASBR_METRIC(external));
|
|
|
|
ospf6_prefix_options_printbuf(external->prefix.prefix_options,
|
|
|
|
buf, sizeof(buf));
|
|
|
|
json_object_string_add(json_obj, "prefixOptions", buf);
|
|
|
|
json_object_int_add(
|
|
|
|
json_obj, "referenceLsType",
|
|
|
|
ntohs(external->prefix.prefix_refer_lstype));
|
|
|
|
json_object_string_add(json_obj, "prefix",
|
|
|
|
ospf6_as_external_lsa_get_prefix_str(
|
|
|
|
lsa, buf, sizeof(buf), 0));
|
|
|
|
|
|
|
|
/* Forwarding-Address */
|
|
|
|
json_object_boolean_add(
|
|
|
|
json_obj, "forwardingAddressPresent",
|
|
|
|
CHECK_FLAG(external->bits_metric, OSPF6_ASBR_BIT_F));
|
|
|
|
if (CHECK_FLAG(external->bits_metric, OSPF6_ASBR_BIT_F))
|
|
|
|
json_object_string_add(
|
|
|
|
json_obj, "forwardingAddress",
|
|
|
|
ospf6_as_external_lsa_get_prefix_str(
|
|
|
|
lsa, buf, sizeof(buf), 1));
|
|
|
|
|
|
|
|
/* Tag */
|
|
|
|
json_object_boolean_add(
|
|
|
|
json_obj, "tagPresent",
|
|
|
|
CHECK_FLAG(external->bits_metric, OSPF6_ASBR_BIT_T));
|
|
|
|
if (CHECK_FLAG(external->bits_metric, OSPF6_ASBR_BIT_T))
|
|
|
|
json_object_int_add(json_obj, "tag",
|
|
|
|
ospf6_as_external_lsa_get_tag(lsa));
|
|
|
|
} else {
|
|
|
|
vty_out(vty, " Bits: %s\n", buf);
|
|
|
|
vty_out(vty, " Metric: %5lu\n",
|
|
|
|
(unsigned long)OSPF6_ASBR_METRIC(external));
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2020-12-04 06:54:40 +01:00
|
|
|
ospf6_prefix_options_printbuf(external->prefix.prefix_options,
|
|
|
|
buf, sizeof(buf));
|
|
|
|
vty_out(vty, " Prefix Options: %s\n", buf);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2020-12-04 06:54:40 +01:00
|
|
|
vty_out(vty, " Referenced LSType: %d\n",
|
|
|
|
ntohs(external->prefix.prefix_refer_lstype));
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2020-12-04 06:54:40 +01:00
|
|
|
vty_out(vty, " Prefix: %s\n",
|
2017-07-13 19:42:42 +02:00
|
|
|
ospf6_as_external_lsa_get_prefix_str(lsa, buf,
|
2020-12-04 06:54:40 +01:00
|
|
|
sizeof(buf), 0));
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2020-12-04 06:54:40 +01:00
|
|
|
/* Forwarding-Address */
|
|
|
|
if (CHECK_FLAG(external->bits_metric, OSPF6_ASBR_BIT_F)) {
|
|
|
|
vty_out(vty, " Forwarding-Address: %s\n",
|
|
|
|
ospf6_as_external_lsa_get_prefix_str(
|
|
|
|
lsa, buf, sizeof(buf), 1));
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Tag */
|
|
|
|
if (CHECK_FLAG(external->bits_metric, OSPF6_ASBR_BIT_T)) {
|
|
|
|
vty_out(vty, " Tag: %" ROUTE_TAG_PRI "\n",
|
|
|
|
ospf6_as_external_lsa_get_tag(lsa));
|
|
|
|
}
|
2016-10-01 06:41:40 +02:00
|
|
|
}
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
static void ospf6_asbr_external_route_show(struct vty *vty,
|
2020-09-28 07:25:10 +02:00
|
|
|
struct ospf6_route *route,
|
|
|
|
json_object *json_array,
|
|
|
|
bool use_json)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
2004-05-18 20:57:06 +02:00
|
|
|
struct ospf6_external_info *info = route->route_option;
|
2020-09-28 07:25:10 +02:00
|
|
|
char prefix[PREFIX2STR_BUFFER], id[16], forwarding[64];
|
2018-03-27 21:13:34 +02:00
|
|
|
uint32_t tmp_id;
|
2020-09-28 07:25:10 +02:00
|
|
|
json_object *json_route;
|
|
|
|
char route_type[2];
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2020-09-28 07:25:10 +02:00
|
|
|
prefix2str(&route->prefix, prefix, sizeof(prefix));
|
2004-05-18 20:57:06 +02:00
|
|
|
tmp_id = ntohl(info->id);
|
|
|
|
inet_ntop(AF_INET, &tmp_id, id, sizeof(id));
|
|
|
|
if (!IN6_IS_ADDR_UNSPECIFIED(&info->forwarding))
|
|
|
|
inet_ntop(AF_INET6, &info->forwarding, forwarding,
|
|
|
|
sizeof(forwarding));
|
|
|
|
else
|
|
|
|
snprintf(forwarding, sizeof(forwarding), ":: (ifindex %d)",
|
2015-05-20 03:03:39 +02:00
|
|
|
ospf6_route_get_first_nh_index(route));
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2020-09-28 07:25:10 +02:00
|
|
|
if (use_json) {
|
|
|
|
json_route = json_object_new_object();
|
|
|
|
snprintf(route_type, sizeof(route_type), "%c",
|
|
|
|
zebra_route_char(info->type));
|
|
|
|
json_object_string_add(json_route, "routeType", route_type);
|
|
|
|
json_object_string_add(json_route, "destination", prefix);
|
|
|
|
json_object_string_add(json_route, "id", id);
|
|
|
|
json_object_int_add(json_route, "metricType",
|
|
|
|
route->path.metric_type);
|
|
|
|
json_object_int_add(
|
|
|
|
json_route, "routeCost",
|
|
|
|
(unsigned long)(route->path.metric_type == 2
|
|
|
|
? route->path.u.cost_e2
|
|
|
|
: route->path.cost));
|
|
|
|
json_object_string_add(json_route, "forwarding", forwarding);
|
|
|
|
|
|
|
|
json_object_array_add(json_array, json_route);
|
|
|
|
} else
|
|
|
|
|
|
|
|
vty_out(vty, "%c %-32pFX %-15s type-%d %5lu %s\n",
|
|
|
|
zebra_route_char(info->type), &route->prefix, id,
|
|
|
|
route->path.metric_type,
|
|
|
|
(unsigned long)(route->path.metric_type == 2
|
|
|
|
? route->path.u.cost_e2
|
|
|
|
: route->path.cost),
|
|
|
|
forwarding);
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
|
2021-05-05 22:19:01 +02:00
|
|
|
DEFUN(show_ipv6_ospf6_redistribute, show_ipv6_ospf6_redistribute_cmd,
|
|
|
|
"show ipv6 ospf6 [vrf <NAME|all>] redistribute [json]",
|
|
|
|
SHOW_STR IP6_STR OSPF6_STR VRF_CMD_HELP_STR
|
|
|
|
"All VRFs\n"
|
|
|
|
"redistributing External information\n" JSON_STR)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
2004-05-18 20:57:06 +02:00
|
|
|
struct ospf6_route *route;
|
2020-10-08 07:38:43 +02:00
|
|
|
struct ospf6 *ospf6 = NULL;
|
2020-09-28 07:25:10 +02:00
|
|
|
json_object *json = NULL;
|
|
|
|
bool uj = use_json(argc, argv);
|
2021-05-05 22:19:01 +02:00
|
|
|
struct listnode *node;
|
|
|
|
const char *vrf_name = NULL;
|
|
|
|
bool all_vrf = false;
|
|
|
|
int idx_vrf = 0;
|
|
|
|
|
2020-09-28 07:25:10 +02:00
|
|
|
json_object *json_array_routes = NULL;
|
|
|
|
json_object *json_array_redistribute = NULL;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2021-05-05 22:19:01 +02:00
|
|
|
OSPF6_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf);
|
2015-05-20 03:03:41 +02:00
|
|
|
|
2020-09-28 07:25:10 +02:00
|
|
|
if (uj) {
|
|
|
|
json = json_object_new_object();
|
|
|
|
json_array_routes = json_object_new_array();
|
|
|
|
json_array_redistribute = json_object_new_array();
|
|
|
|
}
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2021-05-05 22:19:01 +02:00
|
|
|
for (ALL_LIST_ELEMENTS_RO(om6->ospf6, node, ospf6)) {
|
|
|
|
if (all_vrf
|
|
|
|
|| ((ospf6->name == NULL && vrf_name == NULL)
|
|
|
|
|| (ospf6->name && vrf_name
|
|
|
|
&& strcmp(ospf6->name, vrf_name) == 0))) {
|
|
|
|
ospf6_redistribute_show_config(
|
|
|
|
vty, ospf6, json_array_redistribute, json, uj);
|
|
|
|
|
|
|
|
for (route = ospf6_route_head(ospf6->external_table);
|
|
|
|
route; route = ospf6_route_next(route)) {
|
|
|
|
ospf6_asbr_external_route_show(
|
|
|
|
vty, route, json_array_routes, uj);
|
|
|
|
}
|
2004-05-18 20:57:06 +02:00
|
|
|
|
2021-05-05 22:19:01 +02:00
|
|
|
if (uj) {
|
|
|
|
json_object_object_add(json, "routes",
|
|
|
|
json_array_routes);
|
|
|
|
vty_out(vty, "%s\n",
|
|
|
|
json_object_to_json_string_ext(
|
|
|
|
json, JSON_C_TO_STRING_PRETTY));
|
|
|
|
json_object_free(json);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!all_vrf)
|
|
|
|
break;
|
|
|
|
}
|
2020-09-28 07:25:10 +02:00
|
|
|
}
|
2021-05-05 22:19:01 +02:00
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
return CMD_SUCCESS;
|
2002-12-13 21:15:29 +01:00
|
|
|
}
|
|
|
|
|
2020-03-31 13:55:17 +02:00
|
|
|
static struct ospf6_lsa_handler as_external_handler = {
|
2017-10-08 18:20:12 +02:00
|
|
|
.lh_type = OSPF6_LSTYPE_AS_EXTERNAL,
|
|
|
|
.lh_name = "AS-External",
|
|
|
|
.lh_short_name = "ASE",
|
|
|
|
.lh_show = ospf6_as_external_lsa_show,
|
|
|
|
.lh_get_prefix_str = ospf6_as_external_lsa_get_prefix_str,
|
|
|
|
.lh_debug = 0};
|
2004-05-18 20:57:06 +02:00
|
|
|
|
2021-03-25 12:29:51 +01:00
|
|
|
static struct ospf6_lsa_handler nssa_external_handler = {
|
|
|
|
.lh_type = OSPF6_LSTYPE_TYPE_7,
|
|
|
|
.lh_name = "NSSA",
|
|
|
|
.lh_short_name = "Type7",
|
|
|
|
.lh_show = ospf6_as_external_lsa_show,
|
|
|
|
.lh_get_prefix_str = ospf6_as_external_lsa_get_prefix_str,
|
|
|
|
.lh_debug = 0};
|
|
|
|
|
2008-08-15 14:45:30 +02:00
|
|
|
void ospf6_asbr_init(void)
|
2002-12-13 21:15:29 +01:00
|
|
|
{
|
2004-05-18 20:57:06 +02:00
|
|
|
ospf6_routemap_init();
|
|
|
|
|
2004-08-15 07:52:07 +02:00
|
|
|
ospf6_install_lsa_handler(&as_external_handler);
|
2021-03-25 12:29:51 +01:00
|
|
|
ospf6_install_lsa_handler(&nssa_external_handler);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
install_element(VIEW_NODE, &show_ipv6_ospf6_redistribute_cmd);
|
|
|
|
|
2021-02-10 05:53:46 +01:00
|
|
|
install_element(OSPF6_NODE, &ospf6_default_route_originate_cmd);
|
|
|
|
install_element(OSPF6_NODE,
|
|
|
|
&no_ospf6_default_information_originate_cmd);
|
2002-12-13 21:15:29 +01:00
|
|
|
install_element(OSPF6_NODE, &ospf6_redistribute_cmd);
|
|
|
|
install_element(OSPF6_NODE, &no_ospf6_redistribute_cmd);
|
|
|
|
}
|
|
|
|
|
2021-05-03 13:46:41 +02:00
|
|
|
void ospf6_asbr_redistribute_disable(struct ospf6 *ospf6)
|
2013-03-08 21:47:35 +01:00
|
|
|
{
|
|
|
|
int type;
|
2020-11-09 16:51:29 +01:00
|
|
|
struct ospf6_redist *red;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2021-07-02 18:38:11 +02:00
|
|
|
for (type = 0; type < ZEBRA_ROUTE_MAX; type++) {
|
2020-11-09 16:51:29 +01:00
|
|
|
red = ospf6_redist_lookup(ospf6, type, 0);
|
|
|
|
if (!red)
|
|
|
|
continue;
|
2021-07-02 18:38:11 +02:00
|
|
|
if (type == ZEBRA_ROUTE_OSPF6)
|
2013-03-08 21:47:35 +01:00
|
|
|
continue;
|
2021-05-07 16:05:40 +02:00
|
|
|
ospf6_asbr_redistribute_unset(ospf6, red, type);
|
|
|
|
ospf6_redist_del(ospf6, red, type);
|
2013-03-08 21:47:35 +01:00
|
|
|
}
|
2021-07-02 18:38:11 +02:00
|
|
|
red = ospf6_redist_lookup(ospf6, DEFAULT_ROUTE, 0);
|
|
|
|
if (red) {
|
|
|
|
ospf6_asbr_routemap_unset(red);
|
|
|
|
ospf6_redist_del(ospf6, red, type);
|
|
|
|
ospf6_redistribute_default_set(ospf6, DEFAULT_ORIGINATE_NONE);
|
|
|
|
}
|
2013-03-08 21:47:35 +01:00
|
|
|
}
|
|
|
|
|
2021-05-03 13:46:41 +02:00
|
|
|
void ospf6_asbr_redistribute_reset(struct ospf6 *ospf6)
|
|
|
|
{
|
|
|
|
int type;
|
|
|
|
struct ospf6_redist *red;
|
|
|
|
char buf[RMAP_NAME_MAXLEN];
|
|
|
|
|
|
|
|
for (type = 0; type <= ZEBRA_ROUTE_MAX; type++) {
|
|
|
|
buf[0] = '\0';
|
|
|
|
if (type == ZEBRA_ROUTE_OSPF6)
|
|
|
|
continue;
|
|
|
|
red = ospf6_redist_lookup(ospf6, type, 0);
|
|
|
|
if (!red)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (type == DEFAULT_ROUTE) {
|
|
|
|
ospf6_redistribute_default_set(
|
|
|
|
ospf6, ospf6->default_originate);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (ROUTEMAP_NAME(red))
|
|
|
|
strlcpy(buf, ROUTEMAP_NAME(red), sizeof(buf));
|
|
|
|
|
|
|
|
ospf6_asbr_redistribute_unset(ospf6, red, type);
|
|
|
|
if (buf[0])
|
|
|
|
ospf6_asbr_routemap_set(red, buf);
|
|
|
|
ospf6_asbr_redistribute_set(ospf6, type);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-11-10 22:01:41 +01:00
|
|
|
void ospf6_asbr_terminate(void)
|
|
|
|
{
|
2018-01-25 04:02:19 +01:00
|
|
|
/* Cleanup route maps */
|
2010-11-10 22:01:41 +01:00
|
|
|
route_map_finish();
|
|
|
|
}
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2004-05-18 20:57:06 +02:00
|
|
|
DEFUN (debug_ospf6_asbr,
|
|
|
|
debug_ospf6_asbr_cmd,
|
|
|
|
"debug ospf6 asbr",
|
|
|
|
DEBUG_STR
|
|
|
|
OSPF6_STR
|
|
|
|
"Debug OSPFv3 ASBR function\n"
|
|
|
|
)
|
|
|
|
{
|
|
|
|
OSPF6_DEBUG_ASBR_ON();
|
|
|
|
return CMD_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
DEFUN (no_debug_ospf6_asbr,
|
|
|
|
no_debug_ospf6_asbr_cmd,
|
|
|
|
"no debug ospf6 asbr",
|
|
|
|
NO_STR
|
|
|
|
DEBUG_STR
|
|
|
|
OSPF6_STR
|
|
|
|
"Debug OSPFv3 ASBR function\n"
|
|
|
|
)
|
|
|
|
{
|
|
|
|
OSPF6_DEBUG_ASBR_OFF();
|
|
|
|
return CMD_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
int config_write_ospf6_debug_asbr(struct vty *vty)
|
|
|
|
{
|
|
|
|
if (IS_OSPF6_DEBUG_ASBR)
|
2017-07-13 19:12:39 +02:00
|
|
|
vty_out(vty, "debug ospf6 asbr\n");
|
2004-05-18 20:57:06 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2021-07-07 15:20:01 +02:00
|
|
|
static void ospf6_default_originate_write(struct vty *vty, struct ospf6 *o)
|
2021-02-10 05:53:46 +01:00
|
|
|
{
|
|
|
|
struct ospf6_redist *red;
|
|
|
|
|
2021-07-07 15:20:01 +02:00
|
|
|
vty_out(vty, " default-information originate");
|
|
|
|
if (o->default_originate == DEFAULT_ORIGINATE_ALWAYS)
|
|
|
|
vty_out(vty, " always");
|
2021-02-10 05:53:46 +01:00
|
|
|
|
2021-07-07 15:20:01 +02:00
|
|
|
red = ospf6_redist_lookup(o, DEFAULT_ROUTE, 0);
|
|
|
|
if (red == NULL) {
|
|
|
|
vty_out(vty, "\n");
|
|
|
|
return;
|
2021-02-10 05:53:46 +01:00
|
|
|
}
|
2021-07-07 15:20:01 +02:00
|
|
|
|
|
|
|
if (red->dmetric.value >= 0)
|
|
|
|
vty_out(vty, " metric %d", red->dmetric.value);
|
|
|
|
|
|
|
|
if (red->dmetric.type >= 0)
|
|
|
|
vty_out(vty, " metric-type %d", red->dmetric.type);
|
|
|
|
|
|
|
|
if (ROUTEMAP_NAME(red))
|
|
|
|
vty_out(vty, " route-map %s", ROUTEMAP_NAME(red));
|
|
|
|
|
|
|
|
vty_out(vty, "\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
int ospf6_distribute_config_write(struct vty *vty, struct ospf6 *o)
|
|
|
|
{
|
|
|
|
if (o == NULL)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
/* Print default originate configuration. */
|
|
|
|
if (o->default_originate != DEFAULT_ORIGINATE_NONE)
|
|
|
|
ospf6_default_originate_write(vty, o);
|
|
|
|
|
2021-02-10 05:53:46 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-01-24 10:12:36 +01:00
|
|
|
void install_element_ospf6_debug_asbr(void)
|
2016-09-25 05:00:04 +02:00
|
|
|
{
|
|
|
|
install_element(ENABLE_NODE, &debug_ospf6_asbr_cmd);
|
|
|
|
install_element(ENABLE_NODE, &no_debug_ospf6_asbr_cmd);
|
|
|
|
install_element(CONFIG_NODE, &debug_ospf6_asbr_cmd);
|
|
|
|
install_element(CONFIG_NODE, &no_debug_ospf6_asbr_cmd);
|
|
|
|
}
|
2021-05-28 11:33:03 +02:00
|
|
|
|
|
|
|
/* ASBR Summarisation */
|
2021-07-14 11:07:37 +02:00
|
|
|
void ospf6_fill_aggr_route_details(struct ospf6 *ospf6,
|
|
|
|
struct ospf6_external_aggr_rt *aggr)
|
|
|
|
{
|
|
|
|
struct ospf6_route *rt_aggr = aggr->route;
|
|
|
|
struct ospf6_external_info *ei_aggr = rt_aggr->route_option;
|
|
|
|
|
|
|
|
rt_aggr->prefix = aggr->p;
|
|
|
|
ei_aggr->tag = aggr->tag;
|
|
|
|
ei_aggr->type = 0;
|
|
|
|
ei_aggr->id = aggr->id;
|
|
|
|
|
|
|
|
/* When metric is not configured, apply the default metric */
|
|
|
|
rt_aggr->path.cost = ((aggr->metric == -1) ?
|
|
|
|
DEFAULT_DEFAULT_METRIC
|
|
|
|
: (unsigned int)(aggr->metric));
|
|
|
|
rt_aggr->path.metric_type = aggr->mtype;
|
|
|
|
|
|
|
|
rt_aggr->path.origin.id = htonl(aggr->id);
|
|
|
|
}
|
|
|
|
|
2021-08-09 13:24:32 +02:00
|
|
|
static void
|
|
|
|
ospf6_summary_add_aggr_route_and_blackhole(struct ospf6 *ospf6,
|
|
|
|
struct ospf6_external_aggr_rt *aggr)
|
|
|
|
{
|
|
|
|
struct ospf6_route *rt_aggr;
|
|
|
|
struct ospf6_external_info *info;
|
|
|
|
|
|
|
|
/* Create summary route and save it. */
|
|
|
|
rt_aggr = ospf6_route_create(ospf6);
|
|
|
|
rt_aggr->type = OSPF6_DEST_TYPE_NETWORK;
|
|
|
|
/* Needed to install route while calling zebra api */
|
|
|
|
SET_FLAG(rt_aggr->flag, OSPF6_ROUTE_BEST);
|
|
|
|
|
|
|
|
info = XCALLOC(MTYPE_OSPF6_EXTERNAL_INFO, sizeof(*info));
|
|
|
|
rt_aggr->route_option = info;
|
|
|
|
aggr->route = rt_aggr;
|
|
|
|
|
|
|
|
/* Prepare the external_info for aggregator
|
|
|
|
* Fill all the details which will get advertised
|
|
|
|
*/
|
|
|
|
ospf6_fill_aggr_route_details(ospf6, aggr);
|
|
|
|
|
|
|
|
/* Add next-hop to Null interface. */
|
|
|
|
ospf6_add_route_nexthop_blackhole(rt_aggr);
|
|
|
|
|
|
|
|
ospf6_zebra_route_update_add(rt_aggr, ospf6);
|
|
|
|
}
|
|
|
|
|
2021-05-28 11:33:03 +02:00
|
|
|
static void ospf6_originate_new_aggr_lsa(struct ospf6 *ospf6,
|
2021-07-14 11:07:37 +02:00
|
|
|
struct ospf6_external_aggr_rt *aggr)
|
2021-05-28 11:33:03 +02:00
|
|
|
{
|
|
|
|
struct prefix prefix_id;
|
|
|
|
struct route_node *node;
|
|
|
|
struct ospf6_lsa *lsa = NULL;
|
|
|
|
|
|
|
|
if (IS_OSPF6_DEBUG_AGGR)
|
|
|
|
zlog_debug("%s: Originate new aggregate route(%pFX)", __func__,
|
|
|
|
&aggr->p);
|
|
|
|
|
|
|
|
aggr->id = ospf6->external_id++;
|
2021-08-09 13:24:32 +02:00
|
|
|
|
2021-05-28 11:33:03 +02:00
|
|
|
/* create/update binding in external_id_table */
|
|
|
|
prefix_id.family = AF_INET;
|
|
|
|
prefix_id.prefixlen = 32;
|
|
|
|
prefix_id.u.prefix4.s_addr = htonl(aggr->id);
|
|
|
|
node = route_node_get(ospf6->external_id_table, &prefix_id);
|
|
|
|
node->info = aggr;
|
|
|
|
|
|
|
|
if (IS_OSPF6_DEBUG_AGGR)
|
|
|
|
zlog_debug(
|
|
|
|
"Advertise AS-External Id:%pI4 prefix %pFX metric %u",
|
2021-07-14 11:07:37 +02:00
|
|
|
&prefix_id.u.prefix4, &aggr->p, aggr->metric);
|
2021-05-28 11:33:03 +02:00
|
|
|
|
2021-08-09 13:24:32 +02:00
|
|
|
ospf6_summary_add_aggr_route_and_blackhole(ospf6, aggr);
|
2021-05-28 11:33:03 +02:00
|
|
|
|
|
|
|
/* Originate summary LSA */
|
2021-08-09 13:24:32 +02:00
|
|
|
lsa = ospf6_originate_type5_type7_lsas(aggr->route, ospf6);
|
2021-05-28 11:33:03 +02:00
|
|
|
if (lsa) {
|
|
|
|
if (IS_OSPF6_DEBUG_AGGR)
|
|
|
|
zlog_debug("%s: Set the origination bit for aggregator",
|
|
|
|
__func__);
|
|
|
|
SET_FLAG(aggr->aggrflags, OSPF6_EXTERNAL_AGGRT_ORIGINATED);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
ospf6_aggr_handle_advertise_change(struct ospf6 *ospf6,
|
|
|
|
struct ospf6_external_aggr_rt *aggr)
|
|
|
|
{
|
|
|
|
/* Check if advertise option modified. */
|
|
|
|
if (CHECK_FLAG(aggr->aggrflags, OSPF6_EXTERNAL_AGGRT_NO_ADVERTISE)) {
|
|
|
|
if (IS_OSPF6_DEBUG_AGGR)
|
|
|
|
zlog_debug("%s: Don't originate the summary address,It is configured to not-advertise.",
|
|
|
|
__func__);
|
2021-07-14 11:07:37 +02:00
|
|
|
ospf6_asbr_summary_remove_lsa_and_route(ospf6, aggr);
|
2021-05-28 11:33:03 +02:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* There are no routes present under this aggregation config, hence
|
2021-07-09 11:47:40 +02:00
|
|
|
* nothing to originate here
|
|
|
|
*/
|
2021-05-28 11:33:03 +02:00
|
|
|
if (OSPF6_EXTERNAL_RT_COUNT(aggr) == 0) {
|
|
|
|
if (IS_OSPF6_DEBUG_AGGR)
|
|
|
|
zlog_debug("%s: No routes present under this aggregation",
|
|
|
|
__func__);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!CHECK_FLAG(aggr->aggrflags, OSPF6_EXTERNAL_AGGRT_ORIGINATED)) {
|
|
|
|
if (IS_OSPF6_DEBUG_AGGR)
|
|
|
|
zlog_debug("%s: Now it is advertisable",
|
|
|
|
__func__);
|
|
|
|
|
2021-07-14 11:07:37 +02:00
|
|
|
ospf6_originate_new_aggr_lsa(ospf6, aggr);
|
2021-05-28 11:33:03 +02:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
ospf6_originate_summary_lsa(struct ospf6 *ospf6,
|
2021-07-14 19:55:43 +02:00
|
|
|
struct ospf6_external_aggr_rt *aggr,
|
|
|
|
struct ospf6_route *rt)
|
2021-05-28 11:33:03 +02:00
|
|
|
{
|
|
|
|
struct ospf6_lsa *lsa = NULL, *aggr_lsa = NULL;
|
2021-07-14 11:07:37 +02:00
|
|
|
struct ospf6_external_info *info = NULL;
|
2021-05-28 11:33:03 +02:00
|
|
|
struct ospf6_external_aggr_rt *old_aggr;
|
|
|
|
struct ospf6_as_external_lsa *external;
|
2021-07-14 11:07:37 +02:00
|
|
|
struct ospf6_route *rt_aggr = NULL;
|
2021-05-28 11:33:03 +02:00
|
|
|
route_tag_t tag = 0;
|
|
|
|
unsigned int metric = 0;
|
|
|
|
int mtype;
|
|
|
|
|
|
|
|
if (IS_OSPF6_DEBUG_AGGR)
|
|
|
|
zlog_debug("%s: Prepare to originate Summary route(%pFX)",
|
|
|
|
__func__, &aggr->p);
|
|
|
|
|
|
|
|
/* This case to handle when the overlapping aggregator address
|
|
|
|
* is available. Best match will be considered.So need to delink
|
|
|
|
* from old aggregator and link to the new aggr.
|
|
|
|
*/
|
|
|
|
if (rt->aggr_route) {
|
|
|
|
if (rt->aggr_route != aggr) {
|
|
|
|
old_aggr = rt->aggr_route;
|
|
|
|
ospf6_unlink_route_from_aggr(ospf6, old_aggr, rt);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Add the external route to hash table */
|
|
|
|
ospf6_link_route_to_aggr(aggr, rt);
|
|
|
|
|
|
|
|
/* The key for ID field is a running number and not prefix */
|
|
|
|
info = rt->route_option;
|
|
|
|
assert(info);
|
2021-08-09 13:24:32 +02:00
|
|
|
if (info->id)
|
2021-05-28 11:33:03 +02:00
|
|
|
lsa = ospf6_lsdb_lookup(htons(OSPF6_LSTYPE_AS_EXTERNAL),
|
2021-07-09 11:47:40 +02:00
|
|
|
htonl(info->id), ospf6->router_id,
|
|
|
|
ospf6->lsdb);
|
2021-05-28 11:33:03 +02:00
|
|
|
|
|
|
|
aggr_lsa = ospf6_lsdb_lookup(htons(OSPF6_LSTYPE_AS_EXTERNAL),
|
|
|
|
htonl(aggr->id), ospf6->router_id, ospf6->lsdb);
|
|
|
|
|
|
|
|
if (IS_OSPF6_DEBUG_AGGR)
|
|
|
|
zlog_debug("%s: Aggr LSA ID: %d flags %x.",
|
|
|
|
__func__, aggr->id, aggr->aggrflags);
|
|
|
|
/* Dont originate external LSA,
|
|
|
|
* If it is configured not to advertise.
|
|
|
|
*/
|
|
|
|
if (CHECK_FLAG(aggr->aggrflags, OSPF6_EXTERNAL_AGGRT_NO_ADVERTISE)) {
|
|
|
|
/* If it is already originated as external LSA,
|
|
|
|
* But, it is configured not to advertise then
|
|
|
|
* flush the originated external lsa.
|
|
|
|
*/
|
|
|
|
if (lsa) {
|
|
|
|
if (IS_OSPF6_DEBUG_AGGR)
|
|
|
|
zlog_debug("%s: Purge the external LSA %s.",
|
|
|
|
__func__, lsa->name);
|
|
|
|
ospf6_external_lsa_purge(ospf6, lsa);
|
|
|
|
info->id = 0;
|
|
|
|
rt->path.origin.id = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (aggr_lsa) {
|
|
|
|
if (IS_OSPF6_DEBUG_AGGR)
|
|
|
|
zlog_debug("%s: Purge the aggr external LSA %s.",
|
|
|
|
__func__, lsa->name);
|
2021-07-14 11:07:37 +02:00
|
|
|
ospf6_asbr_summary_remove_lsa_and_route(ospf6, aggr);
|
2021-05-28 11:33:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
UNSET_FLAG(aggr->aggrflags, OSPF6_EXTERNAL_AGGRT_ORIGINATED);
|
|
|
|
|
|
|
|
if (IS_OSPF6_DEBUG_AGGR)
|
|
|
|
zlog_debug("%s: Don't originate the summary address,It is configured to not-advertise.",
|
|
|
|
__func__);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Summary route already originated,
|
|
|
|
* So, Do nothing.
|
|
|
|
*/
|
|
|
|
if (CHECK_FLAG(aggr->aggrflags, OSPF6_EXTERNAL_AGGRT_ORIGINATED)) {
|
|
|
|
if (!aggr_lsa) {
|
|
|
|
zlog_warn(
|
|
|
|
"%s: Could not refresh/originate %pFX",
|
|
|
|
__func__,
|
|
|
|
&aggr->p);
|
|
|
|
/* Remove the assert later */
|
|
|
|
assert(aggr_lsa);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-07-09 11:47:40 +02:00
|
|
|
external = (struct ospf6_as_external_lsa *)OSPF6_LSA_HEADER_END
|
|
|
|
(aggr_lsa->header);
|
2021-05-28 11:33:03 +02:00
|
|
|
metric = (unsigned long)OSPF6_ASBR_METRIC(external);
|
|
|
|
tag = ospf6_as_external_lsa_get_tag(aggr_lsa);
|
2021-07-09 11:47:40 +02:00
|
|
|
mtype = CHECK_FLAG(external->bits_metric,
|
|
|
|
OSPF6_ASBR_BIT_E) ? 2 : 1;
|
2021-05-28 11:33:03 +02:00
|
|
|
|
2021-07-14 11:07:37 +02:00
|
|
|
/* Prepare the external_info for aggregator */
|
|
|
|
ospf6_fill_aggr_route_details(ospf6, aggr);
|
|
|
|
rt_aggr = aggr->route;
|
2021-05-28 11:33:03 +02:00
|
|
|
/* If tag/metric/metric-type modified , then re-originate the
|
|
|
|
* route with modified tag/metric/metric-type details.
|
|
|
|
*/
|
2021-07-14 11:07:37 +02:00
|
|
|
if ((tag != aggr->tag)
|
|
|
|
|| (metric != (unsigned int)rt_aggr->path.cost)
|
2021-05-28 11:33:03 +02:00
|
|
|
|| (mtype != aggr->mtype)) {
|
|
|
|
|
|
|
|
if (IS_OSPF6_DEBUG_AGGR)
|
|
|
|
zlog_debug(
|
|
|
|
"%s: Routetag(old:%d new:%d)/Metric(o:%u,n:%u)/mtype(o:%d n:%d) modified,So refresh the summary route.(%pFX)",
|
2021-07-14 11:07:37 +02:00
|
|
|
__func__, tag, aggr->tag,
|
2021-05-28 11:33:03 +02:00
|
|
|
metric,
|
|
|
|
aggr->metric,
|
|
|
|
mtype, aggr->mtype,
|
|
|
|
&aggr->p);
|
|
|
|
|
2021-07-14 11:07:37 +02:00
|
|
|
aggr_lsa = ospf6_originate_type5_type7_lsas(aggr->route,
|
2021-07-09 11:47:40 +02:00
|
|
|
ospf6);
|
2021-05-28 11:33:03 +02:00
|
|
|
if (aggr_lsa)
|
|
|
|
SET_FLAG(aggr->aggrflags,
|
|
|
|
OSPF6_EXTERNAL_AGGRT_ORIGINATED);
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If the external route prefix same as aggregate route
|
|
|
|
* and if external route is already originated as TYPE-5
|
2021-08-09 13:24:32 +02:00
|
|
|
* then just update the aggr info and remove the route info
|
2021-05-28 11:33:03 +02:00
|
|
|
*/
|
2021-07-14 19:55:43 +02:00
|
|
|
if (lsa && prefix_same(&aggr->p, &rt->prefix)) {
|
2021-05-28 11:33:03 +02:00
|
|
|
if (IS_OSPF6_DEBUG_AGGR)
|
2021-08-09 13:24:32 +02:00
|
|
|
zlog_debug(
|
|
|
|
"%s: Route prefix is same as aggr so no need to re-originate LSA(%pFX)",
|
|
|
|
__PRETTY_FUNCTION__, &aggr->p);
|
2021-05-28 11:33:03 +02:00
|
|
|
|
|
|
|
aggr->id = info->id;
|
2021-08-09 13:24:32 +02:00
|
|
|
info->id = 0;
|
|
|
|
rt->path.origin.id = 0;
|
|
|
|
|
|
|
|
ospf6_summary_add_aggr_route_and_blackhole(ospf6, aggr);
|
|
|
|
|
2021-05-28 11:33:03 +02:00
|
|
|
SET_FLAG(aggr->aggrflags, OSPF6_EXTERNAL_AGGRT_ORIGINATED);
|
2021-08-09 13:24:32 +02:00
|
|
|
|
2021-05-28 11:33:03 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-07-14 11:07:37 +02:00
|
|
|
ospf6_originate_new_aggr_lsa(ospf6, aggr);
|
2021-05-28 11:33:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void ospf6_aggr_handle_external_info(void *data)
|
|
|
|
{
|
|
|
|
struct ospf6_route *rt = (struct ospf6_route *)data;
|
|
|
|
struct ospf6_external_aggr_rt *aggr = NULL;
|
|
|
|
struct ospf6_lsa *lsa = NULL;
|
|
|
|
struct ospf6_external_info *info;
|
|
|
|
struct ospf6 *ospf6 = NULL;
|
|
|
|
struct prefix prefix_id;
|
|
|
|
struct route_node *node;
|
|
|
|
|
|
|
|
rt->aggr_route = NULL;
|
|
|
|
|
|
|
|
rt->to_be_processed = true;
|
|
|
|
|
|
|
|
if (IS_OSPF6_DEBUG_ASBR || IS_OSPF6_DEBUG_ORIGINATE(AS_EXTERNAL))
|
|
|
|
zlog_debug("%s: Handle external route for origination/refresh (%pFX)",
|
|
|
|
__func__,
|
|
|
|
&rt->prefix);
|
|
|
|
|
2021-07-20 07:25:10 +02:00
|
|
|
ospf6 = rt->ospf6;
|
2021-05-28 11:33:03 +02:00
|
|
|
assert(ospf6);
|
|
|
|
|
|
|
|
aggr = ospf6_external_aggr_match(ospf6,
|
|
|
|
&rt->prefix);
|
|
|
|
if (aggr) {
|
|
|
|
ospf6_originate_summary_lsa(ospf6, aggr, rt);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
info = rt->route_option;
|
|
|
|
if (info->id) {
|
|
|
|
lsa = ospf6_lsdb_lookup(htons(OSPF6_LSTYPE_AS_EXTERNAL),
|
2021-07-09 11:47:40 +02:00
|
|
|
htonl(info->id), ospf6->router_id,
|
|
|
|
ospf6->lsdb);
|
2021-05-28 11:33:03 +02:00
|
|
|
if (lsa) {
|
|
|
|
if (IS_OSPF6_DEBUG_AGGR)
|
2021-07-09 11:47:40 +02:00
|
|
|
zlog_debug("%s: LSA found, refresh it",
|
|
|
|
__func__);
|
2021-05-28 11:33:03 +02:00
|
|
|
THREAD_OFF(lsa->refresh);
|
|
|
|
thread_add_event(master, ospf6_lsa_refresh, lsa, 0,
|
|
|
|
&lsa->refresh);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
info->id = ospf6->external_id++;
|
|
|
|
rt->path.origin.id = htonl(info->id);
|
|
|
|
|
|
|
|
/* create/update binding in external_id_table */
|
|
|
|
prefix_id.family = AF_INET;
|
|
|
|
prefix_id.prefixlen = 32;
|
|
|
|
prefix_id.u.prefix4.s_addr = htonl(info->id);
|
|
|
|
node = route_node_get(ospf6->external_id_table, &prefix_id);
|
|
|
|
node->info = rt;
|
|
|
|
|
2021-07-09 11:47:40 +02:00
|
|
|
(void)ospf6_originate_type5_type7_lsas(rt, ospf6);
|
2021-05-28 11:33:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
ospf6_asbr_summary_config_delete(struct ospf6 *ospf6, struct route_node *rn)
|
|
|
|
{
|
|
|
|
struct ospf6_external_aggr_rt *aggr = rn->info;
|
|
|
|
|
|
|
|
if (IS_OSPF6_DEBUG_AGGR)
|
|
|
|
zlog_debug("%s: Deleting Aggregate route (%pFX)",
|
|
|
|
__func__,
|
|
|
|
&aggr->p);
|
|
|
|
|
2021-07-14 11:07:37 +02:00
|
|
|
ospf6_asbr_summary_remove_lsa_and_route(ospf6, aggr);
|
2021-05-28 11:33:03 +02:00
|
|
|
|
|
|
|
rn->info = NULL;
|
|
|
|
route_unlock_node(rn);
|
|
|
|
}
|
|
|
|
|
2021-07-14 19:55:43 +02:00
|
|
|
static int
|
|
|
|
ospf6_handle_external_aggr_modify(struct ospf6 *ospf6,
|
|
|
|
struct ospf6_external_aggr_rt *aggr)
|
2021-05-28 11:33:03 +02:00
|
|
|
{
|
2021-07-14 19:55:43 +02:00
|
|
|
struct ospf6_lsa *lsa = NULL;
|
|
|
|
struct ospf6_as_external_lsa *asel = NULL;
|
|
|
|
struct ospf6_route *rt_aggr;
|
2021-05-28 11:33:03 +02:00
|
|
|
unsigned int metric = 0;
|
2021-07-14 19:55:43 +02:00
|
|
|
route_tag_t tag = 0;
|
2021-05-28 11:33:03 +02:00
|
|
|
int mtype;
|
|
|
|
|
2021-07-14 19:55:43 +02:00
|
|
|
lsa = ospf6_lsdb_lookup(
|
|
|
|
htons(OSPF6_LSTYPE_AS_EXTERNAL),
|
|
|
|
htonl(aggr->id), ospf6->router_id,
|
|
|
|
ospf6->lsdb);
|
|
|
|
if (!lsa) {
|
|
|
|
zlog_warn(
|
|
|
|
"%s: Could not refresh/originate %pFX",
|
|
|
|
__func__,
|
|
|
|
&aggr->p);
|
|
|
|
|
|
|
|
return OSPF6_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
asel = (struct ospf6_as_external_lsa *)
|
|
|
|
OSPF6_LSA_HEADER_END(lsa->header);
|
|
|
|
metric = (unsigned long)OSPF6_ASBR_METRIC(asel);
|
|
|
|
tag = ospf6_as_external_lsa_get_tag(lsa);
|
|
|
|
mtype = CHECK_FLAG(asel->bits_metric,
|
|
|
|
OSPF6_ASBR_BIT_E) ? 2 : 1;
|
|
|
|
|
|
|
|
/* Fill all the details for advertisement */
|
|
|
|
ospf6_fill_aggr_route_details(ospf6, aggr);
|
|
|
|
rt_aggr = aggr->route;
|
|
|
|
/* If tag/metric/metric-type modified , then
|
|
|
|
* re-originate the route with modified
|
|
|
|
* tag/metric/metric-type details.
|
|
|
|
*/
|
|
|
|
if ((tag != aggr->tag)
|
|
|
|
|| (metric
|
|
|
|
!= (unsigned int)rt_aggr->path.cost)
|
|
|
|
|| (mtype
|
|
|
|
!= aggr->mtype)) {
|
|
|
|
if (IS_OSPF6_DEBUG_AGGR)
|
|
|
|
zlog_debug(
|
|
|
|
"%s: Changed tag(old:%d new:%d)/metric(o:%u n:%d)/mtype(o:%d n:%d),So refresh the summary route.(%pFX)",
|
|
|
|
__func__, tag,
|
|
|
|
aggr->tag,
|
|
|
|
metric,
|
|
|
|
(unsigned int)rt_aggr->path.cost,
|
|
|
|
mtype, aggr->mtype,
|
|
|
|
&aggr->p);
|
|
|
|
|
|
|
|
(void)ospf6_originate_type5_type7_lsas(
|
|
|
|
aggr->route,
|
|
|
|
ospf6);
|
|
|
|
}
|
|
|
|
|
|
|
|
return OSPF6_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ospf6_handle_external_aggr_update(struct ospf6 *ospf6)
|
|
|
|
{
|
|
|
|
struct route_node *rn = NULL;
|
|
|
|
int ret;
|
|
|
|
|
2021-05-28 11:33:03 +02:00
|
|
|
if (IS_OSPF6_DEBUG_AGGR)
|
|
|
|
zlog_debug("%s: Process modified aggregators.", __func__);
|
|
|
|
|
|
|
|
for (rn = route_top(ospf6->rt_aggr_tbl); rn; rn = route_next(rn)) {
|
|
|
|
struct ospf6_external_aggr_rt *aggr;
|
|
|
|
|
|
|
|
if (!rn->info)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
aggr = rn->info;
|
|
|
|
|
|
|
|
if (aggr->action == OSPF6_ROUTE_AGGR_DEL) {
|
|
|
|
aggr->action = OSPF6_ROUTE_AGGR_NONE;
|
|
|
|
ospf6_asbr_summary_config_delete(ospf6, rn);
|
|
|
|
|
|
|
|
if (OSPF6_EXTERNAL_RT_COUNT(aggr))
|
|
|
|
hash_clean(aggr->match_extnl_hash,
|
2021-07-14 19:55:43 +02:00
|
|
|
ospf6_aggr_handle_external_info);
|
2021-05-28 11:33:03 +02:00
|
|
|
|
|
|
|
hash_free(aggr->match_extnl_hash);
|
|
|
|
XFREE(MTYPE_OSPF6_EXTERNAL_RT_AGGR, aggr);
|
|
|
|
|
|
|
|
} else if (aggr->action == OSPF6_ROUTE_AGGR_MODIFY) {
|
|
|
|
|
|
|
|
aggr->action = OSPF6_ROUTE_AGGR_NONE;
|
|
|
|
|
|
|
|
/* Check if tag/metric/metric-type modified */
|
|
|
|
if (CHECK_FLAG(aggr->aggrflags,
|
|
|
|
OSPF6_EXTERNAL_AGGRT_ORIGINATED)
|
|
|
|
&& !CHECK_FLAG(aggr->aggrflags,
|
|
|
|
OSPF6_EXTERNAL_AGGRT_NO_ADVERTISE)) {
|
|
|
|
|
2021-07-14 19:55:43 +02:00
|
|
|
ret = ospf6_handle_external_aggr_modify(ospf6,
|
|
|
|
aggr);
|
|
|
|
if (ret == OSPF6_FAILURE)
|
2021-05-28 11:33:03 +02:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Advertise option modified ?
|
|
|
|
* If so, handled it here.
|
|
|
|
*/
|
|
|
|
ospf6_aggr_handle_advertise_change(ospf6, aggr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ospf6_aggr_unlink_external_info(void *data)
|
|
|
|
{
|
|
|
|
struct ospf6_route *rt = (struct ospf6_route *)data;
|
|
|
|
|
|
|
|
rt->aggr_route = NULL;
|
|
|
|
|
|
|
|
rt->to_be_processed = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ospf6_external_aggregator_free(struct ospf6_external_aggr_rt *aggr)
|
|
|
|
{
|
|
|
|
if (OSPF6_EXTERNAL_RT_COUNT(aggr))
|
|
|
|
hash_clean(aggr->match_extnl_hash,
|
2021-07-14 19:55:43 +02:00
|
|
|
ospf6_aggr_unlink_external_info);
|
2021-05-28 11:33:03 +02:00
|
|
|
|
|
|
|
if (IS_OSPF6_DEBUG_AGGR)
|
|
|
|
zlog_debug("%s: Release the aggregator Address(%pFX)",
|
|
|
|
__func__,
|
|
|
|
&aggr->p);
|
|
|
|
|
|
|
|
hash_free(aggr->match_extnl_hash);
|
|
|
|
aggr->match_extnl_hash = NULL;
|
|
|
|
|
|
|
|
XFREE(MTYPE_OSPF6_EXTERNAL_RT_AGGR, aggr);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
ospf6_delete_all_marked_aggregators(struct ospf6 *ospf6)
|
|
|
|
{
|
|
|
|
struct route_node *rn = NULL;
|
|
|
|
struct ospf6_external_aggr_rt *aggr;
|
|
|
|
|
|
|
|
/* Loop through all the aggregators, Delete all aggregators
|
|
|
|
* which are marked as DELETE. Set action to NONE for remaining
|
|
|
|
* aggregators
|
|
|
|
*/
|
2021-07-14 19:55:43 +02:00
|
|
|
for (rn = route_top(ospf6->rt_aggr_tbl); rn; rn = route_next(rn)) {
|
|
|
|
if (!rn->info)
|
|
|
|
continue;
|
2021-05-28 11:33:03 +02:00
|
|
|
|
2021-07-14 19:55:43 +02:00
|
|
|
aggr = rn->info;
|
|
|
|
|
|
|
|
if (aggr->action != OSPF6_ROUTE_AGGR_DEL) {
|
|
|
|
aggr->action = OSPF6_ROUTE_AGGR_NONE;
|
|
|
|
continue;
|
2021-05-28 11:33:03 +02:00
|
|
|
}
|
2021-07-14 19:55:43 +02:00
|
|
|
ospf6_asbr_summary_config_delete(ospf6, rn);
|
|
|
|
ospf6_external_aggregator_free(aggr);
|
|
|
|
}
|
2021-05-28 11:33:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void ospf6_handle_exnl_rt_after_aggr_del(struct ospf6 *ospf6,
|
|
|
|
struct ospf6_route *rt)
|
|
|
|
{
|
|
|
|
struct ospf6_lsa *lsa;
|
|
|
|
|
|
|
|
/* Process only marked external routes.
|
|
|
|
* These routes were part of a deleted
|
|
|
|
* aggregator.So, originate now.
|
|
|
|
*/
|
|
|
|
if (!rt->to_be_processed)
|
|
|
|
return;
|
|
|
|
|
|
|
|
rt->to_be_processed = false;
|
|
|
|
|
|
|
|
lsa = ospf6_find_external_lsa(ospf6, &rt->prefix);
|
|
|
|
|
|
|
|
if (lsa) {
|
|
|
|
THREAD_OFF(lsa->refresh);
|
|
|
|
thread_add_event(master, ospf6_lsa_refresh, lsa, 0,
|
|
|
|
&lsa->refresh);
|
2021-07-09 11:47:40 +02:00
|
|
|
} else {
|
2021-05-28 11:33:03 +02:00
|
|
|
if (IS_OSPF6_DEBUG_AGGR)
|
|
|
|
zlog_debug("%s: Originate external route(%pFX)",
|
|
|
|
__func__,
|
|
|
|
&rt->prefix);
|
|
|
|
|
2021-07-09 11:47:40 +02:00
|
|
|
(void)ospf6_originate_type5_type7_lsas(rt, ospf6);
|
2021-05-28 11:33:03 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ospf6_handle_aggregated_exnl_rt(struct ospf6 *ospf6,
|
|
|
|
struct ospf6_external_aggr_rt *aggr,
|
|
|
|
struct ospf6_route *rt)
|
|
|
|
{
|
|
|
|
struct ospf6_lsa *lsa;
|
|
|
|
struct ospf6_as_external_lsa *ext_lsa;
|
|
|
|
struct ospf6_external_info *info;
|
|
|
|
|
|
|
|
/* Handling the case where the external route prefix
|
|
|
|
* and aggegate prefix is same
|
|
|
|
* If same dont flush the originated external LSA.
|
|
|
|
*/
|
2021-07-14 19:55:43 +02:00
|
|
|
if (prefix_same(&aggr->p, &rt->prefix)) {
|
2021-05-28 11:33:03 +02:00
|
|
|
if (IS_OSPF6_DEBUG_AGGR)
|
|
|
|
zlog_debug("%s: External Route prefix same as Aggregator(%pFX), so dont flush.",
|
|
|
|
__func__,
|
|
|
|
&rt->prefix);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
info = rt->route_option;
|
|
|
|
assert(info);
|
|
|
|
|
|
|
|
lsa = ospf6_lsdb_lookup(htons(OSPF6_LSTYPE_AS_EXTERNAL),
|
|
|
|
htonl(info->id), ospf6->router_id, ospf6->lsdb);
|
|
|
|
if (lsa) {
|
|
|
|
ext_lsa = (struct ospf6_as_external_lsa
|
|
|
|
*)((char *)(lsa->header)
|
|
|
|
+ sizeof(struct ospf6_lsa_header));
|
|
|
|
|
|
|
|
if (rt->prefix.prefixlen != ext_lsa->prefix.prefix_length)
|
|
|
|
return;
|
|
|
|
|
|
|
|
ospf6_external_lsa_purge(ospf6, lsa);
|
|
|
|
|
|
|
|
/* Resetting the ID of route */
|
|
|
|
rt->path.origin.id = 0;
|
|
|
|
info->id = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
ospf6_handle_external_aggr_add(struct ospf6 *ospf6)
|
|
|
|
{
|
|
|
|
struct ospf6_route *rt = NULL;
|
|
|
|
struct ospf6_external_info *ei = NULL;
|
|
|
|
struct ospf6_external_aggr_rt *aggr;
|
|
|
|
|
|
|
|
/* Delete all the aggregators which are marked as
|
|
|
|
* OSPF6_ROUTE_AGGR_DEL.
|
|
|
|
*/
|
|
|
|
ospf6_delete_all_marked_aggregators(ospf6);
|
|
|
|
|
2021-07-09 11:47:40 +02:00
|
|
|
for (rt = ospf6_route_head(ospf6->external_table); rt;
|
|
|
|
rt = ospf6_route_next(rt)) {
|
2021-05-28 11:33:03 +02:00
|
|
|
ei = rt->route_option;
|
2021-07-14 19:55:43 +02:00
|
|
|
if (ei == NULL)
|
|
|
|
continue;
|
2021-05-28 11:33:03 +02:00
|
|
|
|
2021-07-14 19:55:43 +02:00
|
|
|
if (is_default_prefix(&rt->prefix))
|
|
|
|
continue;
|
2021-05-28 11:33:03 +02:00
|
|
|
|
2021-07-14 19:55:43 +02:00
|
|
|
aggr = ospf6_external_aggr_match(ospf6,
|
|
|
|
&rt->prefix);
|
2021-05-28 11:33:03 +02:00
|
|
|
|
2021-07-14 19:55:43 +02:00
|
|
|
/* If matching aggregator found, Add
|
|
|
|
* the external route refrenace to the
|
|
|
|
* aggregator and originate the aggr
|
|
|
|
* route if it is advertisable.
|
|
|
|
* flush the external LSA if it is
|
|
|
|
* already originated for this external
|
|
|
|
* prefix.
|
|
|
|
*/
|
|
|
|
if (aggr) {
|
|
|
|
ospf6_originate_summary_lsa(ospf6, aggr, rt);
|
2021-05-28 11:33:03 +02:00
|
|
|
|
2021-07-14 19:55:43 +02:00
|
|
|
/* All aggregated external rts
|
|
|
|
* are handled here.
|
2021-05-28 11:33:03 +02:00
|
|
|
*/
|
2021-07-14 19:55:43 +02:00
|
|
|
ospf6_handle_aggregated_exnl_rt(
|
|
|
|
ospf6, aggr, rt);
|
|
|
|
continue;
|
2021-05-28 11:33:03 +02:00
|
|
|
}
|
2021-07-14 19:55:43 +02:00
|
|
|
|
|
|
|
/* External routes which are only out
|
|
|
|
* of aggregation will be handled here.
|
|
|
|
*/
|
|
|
|
ospf6_handle_exnl_rt_after_aggr_del(
|
|
|
|
ospf6, rt);
|
2021-05-28 11:33:03 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int ospf6_asbr_summary_process(struct thread *thread)
|
|
|
|
{
|
|
|
|
struct ospf6 *ospf6 = THREAD_ARG(thread);
|
|
|
|
int operation = 0;
|
|
|
|
|
|
|
|
operation = ospf6->aggr_action;
|
|
|
|
|
|
|
|
if (IS_OSPF6_DEBUG_AGGR)
|
|
|
|
zlog_debug("%s: operation:%d",
|
|
|
|
__func__,
|
|
|
|
operation);
|
|
|
|
|
|
|
|
switch (operation) {
|
|
|
|
case OSPF6_ROUTE_AGGR_ADD:
|
|
|
|
ospf6_handle_external_aggr_add(ospf6);
|
|
|
|
break;
|
|
|
|
case OSPF6_ROUTE_AGGR_DEL:
|
|
|
|
case OSPF6_ROUTE_AGGR_MODIFY:
|
|
|
|
ospf6_handle_external_aggr_update(ospf6);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return OSPF6_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
ospf6_start_asbr_summary_delay_timer(struct ospf6 *ospf6,
|
|
|
|
struct ospf6_external_aggr_rt *aggr,
|
|
|
|
ospf6_aggr_action_t operation)
|
|
|
|
{
|
|
|
|
aggr->action = operation;
|
|
|
|
|
|
|
|
if (ospf6->t_external_aggr) {
|
|
|
|
if (ospf6->aggr_action == OSPF6_ROUTE_AGGR_ADD) {
|
|
|
|
|
|
|
|
if (IS_OSPF6_DEBUG_AGGR)
|
|
|
|
zlog_debug("%s: Not required to restart timer,set is already added.",
|
|
|
|
__func__);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (operation == OSPF6_ROUTE_AGGR_ADD) {
|
|
|
|
if (IS_OSPF6_DEBUG_AGGR)
|
|
|
|
zlog_debug("%s, Restarting Aggregator delay timer.",
|
|
|
|
__func__);
|
|
|
|
THREAD_OFF(ospf6->t_external_aggr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (IS_OSPF6_DEBUG_AGGR)
|
|
|
|
zlog_debug("%s: Start Aggregator delay timer %d(in seconds).",
|
|
|
|
__func__, ospf6->aggr_delay_interval);
|
|
|
|
|
|
|
|
ospf6->aggr_action = operation;
|
|
|
|
thread_add_timer(master,
|
|
|
|
ospf6_asbr_summary_process,
|
|
|
|
ospf6, ospf6->aggr_delay_interval,
|
|
|
|
&ospf6->t_external_aggr);
|
|
|
|
}
|
|
|
|
|
|
|
|
int ospf6_asbr_external_rt_advertise(struct ospf6 *ospf6,
|
|
|
|
struct prefix *p)
|
|
|
|
{
|
|
|
|
struct route_node *rn;
|
|
|
|
struct ospf6_external_aggr_rt *aggr;
|
|
|
|
|
2021-07-14 19:55:43 +02:00
|
|
|
rn = route_node_lookup(ospf6->rt_aggr_tbl, p);
|
2021-05-28 11:33:03 +02:00
|
|
|
if (!rn)
|
|
|
|
return OSPF6_INVALID;
|
|
|
|
|
|
|
|
aggr = rn->info;
|
|
|
|
|
|
|
|
route_unlock_node(rn);
|
|
|
|
|
|
|
|
if (!CHECK_FLAG(aggr->aggrflags, OSPF6_EXTERNAL_AGGRT_NO_ADVERTISE))
|
|
|
|
return OSPF6_INVALID;
|
|
|
|
|
|
|
|
UNSET_FLAG(aggr->aggrflags, OSPF6_EXTERNAL_AGGRT_NO_ADVERTISE);
|
|
|
|
|
|
|
|
if (!OSPF6_EXTERNAL_RT_COUNT(aggr))
|
|
|
|
return OSPF6_SUCCESS;
|
|
|
|
|
2021-07-09 11:47:40 +02:00
|
|
|
ospf6_start_asbr_summary_delay_timer(ospf6, aggr,
|
|
|
|
OSPF6_ROUTE_AGGR_MODIFY);
|
2021-05-28 11:33:03 +02:00
|
|
|
|
|
|
|
return OSPF6_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
int ospf6_external_aggr_delay_timer_set(struct ospf6 *ospf6,
|
|
|
|
unsigned int interval)
|
|
|
|
{
|
|
|
|
ospf6->aggr_delay_interval = interval;
|
|
|
|
|
|
|
|
return OSPF6_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static unsigned int ospf6_external_rt_hash_key(const void *data)
|
|
|
|
{
|
|
|
|
const struct ospf6_route *rt = data;
|
|
|
|
unsigned int key = 0;
|
|
|
|
|
|
|
|
key = prefix_hash_key(&rt->prefix);
|
|
|
|
return key;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool ospf6_external_rt_hash_cmp(const void *d1, const void *d2)
|
|
|
|
{
|
|
|
|
const struct ospf6_route *rt1 = d1;
|
|
|
|
const struct ospf6_route *rt2 = d2;
|
|
|
|
|
2021-07-14 19:55:43 +02:00
|
|
|
return prefix_same(&rt1->prefix, &rt2->prefix);
|
2021-05-28 11:33:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static struct ospf6_external_aggr_rt *
|
|
|
|
ospf6_external_aggr_new(struct prefix *p)
|
|
|
|
{
|
|
|
|
struct ospf6_external_aggr_rt *aggr;
|
|
|
|
|
2021-07-14 19:55:43 +02:00
|
|
|
aggr = XCALLOC(MTYPE_OSPF6_EXTERNAL_RT_AGGR,
|
|
|
|
sizeof(struct ospf6_external_aggr_rt));
|
2021-05-28 11:33:03 +02:00
|
|
|
|
|
|
|
prefix_copy(&aggr->p, p);
|
|
|
|
aggr->metric = -1;
|
|
|
|
aggr->mtype = DEFAULT_METRIC_TYPE;
|
|
|
|
aggr->match_extnl_hash = hash_create(ospf6_external_rt_hash_key,
|
|
|
|
ospf6_external_rt_hash_cmp,
|
|
|
|
"Ospf6 external route hash");
|
|
|
|
return aggr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ospf6_external_aggr_add(struct ospf6 *ospf6,
|
|
|
|
struct ospf6_external_aggr_rt *aggr)
|
|
|
|
{
|
|
|
|
struct route_node *rn;
|
|
|
|
|
|
|
|
if (IS_OSPF6_DEBUG_AGGR)
|
|
|
|
zlog_debug("%s: Adding Aggregate route to Aggr table (%pFX)",
|
|
|
|
__func__,
|
|
|
|
&aggr->p);
|
|
|
|
|
2021-07-14 19:55:43 +02:00
|
|
|
rn = route_node_get(ospf6->rt_aggr_tbl, &aggr->p);
|
2021-05-28 11:33:03 +02:00
|
|
|
if (rn->info)
|
|
|
|
route_unlock_node(rn);
|
|
|
|
else
|
|
|
|
rn->info = aggr;
|
|
|
|
}
|
|
|
|
|
|
|
|
int ospf6_asbr_external_rt_no_advertise(struct ospf6 *ospf6,
|
|
|
|
struct prefix *p)
|
|
|
|
{
|
|
|
|
struct ospf6_external_aggr_rt *aggr;
|
|
|
|
route_tag_t tag = 0;
|
|
|
|
|
|
|
|
aggr = ospf6_external_aggr_config_lookup(ospf6, p);
|
|
|
|
if (aggr) {
|
|
|
|
if (CHECK_FLAG(aggr->aggrflags,
|
|
|
|
OSPF6_EXTERNAL_AGGRT_NO_ADVERTISE))
|
|
|
|
return OSPF6_SUCCESS;
|
|
|
|
|
|
|
|
SET_FLAG(aggr->aggrflags, OSPF6_EXTERNAL_AGGRT_NO_ADVERTISE);
|
|
|
|
|
|
|
|
aggr->tag = tag;
|
|
|
|
aggr->metric = -1;
|
|
|
|
|
|
|
|
if (!OSPF6_EXTERNAL_RT_COUNT(aggr))
|
|
|
|
return OSPF6_SUCCESS;
|
|
|
|
|
|
|
|
ospf6_start_asbr_summary_delay_timer(ospf6, aggr,
|
|
|
|
OSPF6_ROUTE_AGGR_MODIFY);
|
|
|
|
} else {
|
|
|
|
aggr = ospf6_external_aggr_new(p);
|
|
|
|
|
|
|
|
if (!aggr)
|
|
|
|
return OSPF6_FAILURE;
|
|
|
|
|
|
|
|
SET_FLAG(aggr->aggrflags, OSPF6_EXTERNAL_AGGRT_NO_ADVERTISE);
|
|
|
|
ospf6_external_aggr_add(ospf6, aggr);
|
|
|
|
ospf6_start_asbr_summary_delay_timer(ospf6, aggr,
|
|
|
|
OSPF6_ROUTE_AGGR_ADD);
|
|
|
|
}
|
|
|
|
|
|
|
|
return OSPF6_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct ospf6_external_aggr_rt *
|
|
|
|
ospf6_external_aggr_config_lookup(struct ospf6 *ospf6, struct prefix *p)
|
|
|
|
{
|
|
|
|
struct route_node *rn;
|
|
|
|
|
2021-07-14 19:55:43 +02:00
|
|
|
rn = route_node_lookup(ospf6->rt_aggr_tbl, p);
|
2021-05-28 11:33:03 +02:00
|
|
|
if (rn) {
|
|
|
|
route_unlock_node(rn);
|
|
|
|
return rn->info;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int ospf6_external_aggr_config_set(struct ospf6 *ospf6, struct prefix *p,
|
|
|
|
route_tag_t tag, int metric, int mtype)
|
|
|
|
{
|
|
|
|
struct ospf6_external_aggr_rt *aggregator;
|
|
|
|
|
|
|
|
aggregator = ospf6_external_aggr_config_lookup(ospf6, p);
|
|
|
|
|
|
|
|
if (aggregator) {
|
|
|
|
if (CHECK_FLAG(aggregator->aggrflags,
|
|
|
|
OSPF6_EXTERNAL_AGGRT_NO_ADVERTISE))
|
|
|
|
UNSET_FLAG(aggregator->aggrflags,
|
|
|
|
OSPF6_EXTERNAL_AGGRT_NO_ADVERTISE);
|
|
|
|
else if ((aggregator->tag == tag)
|
|
|
|
&& (aggregator->metric == metric)
|
|
|
|
&& (aggregator->mtype == mtype))
|
|
|
|
return OSPF6_SUCCESS;
|
|
|
|
|
|
|
|
aggregator->tag = tag;
|
|
|
|
aggregator->metric = metric;
|
|
|
|
aggregator->mtype = mtype;
|
|
|
|
|
|
|
|
ospf6_start_asbr_summary_delay_timer(ospf6, aggregator,
|
|
|
|
OSPF6_ROUTE_AGGR_MODIFY);
|
|
|
|
} else {
|
|
|
|
aggregator = ospf6_external_aggr_new(p);
|
|
|
|
if (!aggregator)
|
|
|
|
return OSPF6_FAILURE;
|
|
|
|
|
|
|
|
aggregator->tag = tag;
|
|
|
|
aggregator->metric = metric;
|
|
|
|
aggregator->mtype = mtype;
|
|
|
|
|
|
|
|
ospf6_external_aggr_add(ospf6, aggregator);
|
|
|
|
ospf6_start_asbr_summary_delay_timer(ospf6, aggregator,
|
|
|
|
OSPF6_ROUTE_AGGR_ADD);
|
|
|
|
}
|
|
|
|
|
|
|
|
return OSPF6_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
int ospf6_external_aggr_config_unset(struct ospf6 *ospf6,
|
|
|
|
struct prefix *p)
|
|
|
|
{
|
|
|
|
struct route_node *rn;
|
|
|
|
struct ospf6_external_aggr_rt *aggr;
|
|
|
|
|
2021-07-14 19:55:43 +02:00
|
|
|
rn = route_node_lookup(ospf6->rt_aggr_tbl, p);
|
2021-05-28 11:33:03 +02:00
|
|
|
if (!rn)
|
|
|
|
return OSPF6_INVALID;
|
|
|
|
|
|
|
|
aggr = rn->info;
|
|
|
|
|
|
|
|
route_unlock_node(rn);
|
|
|
|
|
|
|
|
if (!OSPF6_EXTERNAL_RT_COUNT(aggr)) {
|
|
|
|
ospf6_asbr_summary_config_delete(ospf6, rn);
|
|
|
|
ospf6_external_aggregator_free(aggr);
|
|
|
|
return OSPF6_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
ospf6_start_asbr_summary_delay_timer(ospf6, aggr,
|
|
|
|
OSPF6_ROUTE_AGGR_DEL);
|
|
|
|
|
|
|
|
return OSPF6_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ospf6_handle_external_lsa_origination(struct ospf6 *ospf6,
|
|
|
|
struct ospf6_route *rt,
|
|
|
|
struct prefix *p)
|
|
|
|
{
|
|
|
|
|
|
|
|
struct ospf6_external_aggr_rt *aggr;
|
|
|
|
struct ospf6_external_info *info;
|
|
|
|
struct prefix prefix_id;
|
|
|
|
struct route_node *node;
|
|
|
|
|
|
|
|
if (!is_default_prefix(p)) {
|
|
|
|
aggr = ospf6_external_aggr_match(ospf6,
|
|
|
|
p);
|
|
|
|
|
|
|
|
if (aggr) {
|
|
|
|
|
|
|
|
if (IS_OSPF6_DEBUG_AGGR)
|
|
|
|
zlog_debug("%s: Send Aggregate LSA (%pFX)",
|
|
|
|
__func__,
|
|
|
|
&aggr->p);
|
|
|
|
|
|
|
|
ospf6_originate_summary_lsa(
|
|
|
|
ospf6, aggr, rt);
|
|
|
|
|
|
|
|
/* Handling the case where the
|
|
|
|
* external route prefix
|
|
|
|
* and aggegate prefix is same
|
|
|
|
* If same dont flush the
|
|
|
|
* originated
|
|
|
|
* external LSA.
|
|
|
|
*/
|
|
|
|
ospf6_handle_aggregated_exnl_rt(
|
|
|
|
ospf6, aggr, rt);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
info = rt->route_option;
|
|
|
|
|
|
|
|
/* When the info->id = 0, it means it is being originated for the
|
|
|
|
* first time.
|
|
|
|
*/
|
|
|
|
if (!info->id) {
|
|
|
|
info->id = ospf6->external_id++;
|
|
|
|
|
|
|
|
/* create/update binding in external_id_table */
|
|
|
|
prefix_id.family = AF_INET;
|
|
|
|
prefix_id.prefixlen = 32;
|
|
|
|
prefix_id.u.prefix4.s_addr = htonl(info->id);
|
|
|
|
node = route_node_get(ospf6->external_id_table, &prefix_id);
|
|
|
|
node->info = rt;
|
|
|
|
|
2021-07-09 11:47:40 +02:00
|
|
|
} else {
|
2021-05-28 11:33:03 +02:00
|
|
|
prefix_id.family = AF_INET;
|
|
|
|
prefix_id.prefixlen = 32;
|
|
|
|
prefix_id.u.prefix4.s_addr = htonl(info->id);
|
|
|
|
}
|
|
|
|
|
|
|
|
rt->path.origin.id = htonl(info->id);
|
|
|
|
|
|
|
|
if (IS_OSPF6_DEBUG_ASBR) {
|
2021-07-09 11:47:40 +02:00
|
|
|
zlog_debug("Advertise new AS-External Id:%pI4 prefix %pFX metric %u",
|
|
|
|
&prefix_id.u.prefix4, p, rt->path.metric_type);
|
2021-05-28 11:33:03 +02:00
|
|
|
}
|
|
|
|
|
2021-07-09 11:47:40 +02:00
|
|
|
ospf6_originate_type5_type7_lsas(rt, ospf6);
|
2021-05-28 11:33:03 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void ospf6_unset_all_aggr_flag(struct ospf6 *ospf6)
|
|
|
|
{
|
|
|
|
struct route_node *rn = NULL;
|
|
|
|
struct ospf6_external_aggr_rt *aggr;
|
|
|
|
|
|
|
|
if (IS_OSPF6_DEBUG_AGGR)
|
|
|
|
zlog_debug("Unset the origination bit for all aggregator");
|
|
|
|
|
|
|
|
/* Resetting the running external ID counter so that the origination
|
2021-07-09 11:47:40 +02:00
|
|
|
* of external LSAs starts from the beginning 0.0.0.1
|
|
|
|
*/
|
2021-05-28 11:33:03 +02:00
|
|
|
ospf6->external_id = OSPF6_EXT_INIT_LS_ID;
|
|
|
|
|
|
|
|
for (rn = route_top(ospf6->rt_aggr_tbl); rn; rn = route_next(rn)) {
|
|
|
|
if (!rn->info)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
aggr = rn->info;
|
|
|
|
|
|
|
|
UNSET_FLAG(aggr->aggrflags, OSPF6_EXTERNAL_AGGRT_ORIGINATED);
|
|
|
|
}
|
|
|
|
}
|