Skip to content

Commit

Permalink
ospf6d: ASBR Summarisation feature implementation
Browse files Browse the repository at this point in the history
Feature Implementation.
========================
This feature will help in advertising the External LSAs with aggregation.
The commands allow us to tune the advertisement with different parameters
as mentioned in the CLI List below.
It can also help in case we do not want to advertise any prefix with the
no-advertise option.

New CLIs added:
===============
summary-address X:X::X:X/M$prefix [tag (1-4294967295)] [{metric (0-16777215) | metric-type (1-2)}]
no summary-address X:X::X:X/M$prefix [tag (1-4294967295)] [{metric (0-16777215) | metric-type (1-2)}]
summary-address X:X::X:X/M$prefix no-advertise
no summary-address X:X::X:X/M$prefix no-advertise
aggregation timer (5-1800)
no aggregation timer (5-1800)
show ipv6 ospf6 summary-address [detail$detail] [json]
debug ospf6 lsa aggregation

CAT RUN:
========
QE to add test scripts

Signed-Off-by: Mobashshera Rasool <mrassol@vmware.com>
  • Loading branch information
mobash-rasool committed Jul 21, 2021
1 parent 2e69d1e commit 4dc4388
Show file tree
Hide file tree
Showing 12 changed files with 1,725 additions and 52 deletions.
1,139 changes: 1,090 additions & 49 deletions ospf6d/ospf6_asbr.c

Large diffs are not rendered by default.

68 changes: 67 additions & 1 deletion ospf6d/ospf6_asbr.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,52 @@ struct ospf6_external_info {
route_tag_t tag;

ifindex_t ifindex;

};

/* OSPF6 ASBR Summarisation */
typedef enum {
OSPF6_ROUTE_AGGR_NONE = 0,
OSPF6_ROUTE_AGGR_ADD,
OSPF6_ROUTE_AGGR_DEL,
OSPF6_ROUTE_AGGR_MODIFY
}ospf6_aggr_action_t;

#define OSPF6_EXTERNAL_AGGRT_NO_ADVERTISE 0x1
#define OSPF6_EXTERNAL_AGGRT_ORIGINATED 0x2

#define OSPF6_EXTERNAL_RT_COUNT(aggr) \
(((struct ospf6_external_aggr_rt *)aggr)->match_extnl_hash->count)

struct ospf6_external_aggr_rt {
/* range address and masklen */
struct prefix p;

/* use bits for OSPF6_EXTERNAL_AGGRT_NO_ADVERTISE and
* OSPF6_EXTERNAL_AGGRT_ORIGINATED
*/
uint16_t aggrflags;

/* To store external metric-type */
uint8_t mtype;

/* Route tag for summary address */
route_tag_t tag;

/* To store aggregated metric config */
int metric;

/* To Store the LS ID when LSA is originated */
uint32_t id;

/* How many prefixes are using this range */
uint32_t refcount;

/* Action to be done after delay timer expiry */
int action;

/* Hash table of matching external routes */
struct hash *match_extnl_hash;
};

/* AS-External-LSA */
Expand Down Expand Up @@ -110,8 +156,28 @@ extern void ospf6_asbr_distribute_list_update(struct ospf6 *ospf6,
struct ospf6_redist *ospf6_redist_lookup(struct ospf6 *ospf6, int type,
unsigned short instance);
extern void ospf6_asbr_routemap_update(const char *mapname);
extern void ospf6_as_external_lsa_originate(struct ospf6_route *route,
extern struct ospf6_lsa *ospf6_as_external_lsa_originate(struct ospf6_route *route,
struct ospf6 *ospf6);
extern void ospf6_asbr_status_update(struct ospf6 *ospf6, int status);

int ospf6_asbr_external_rt_advertise(struct ospf6 *ospf6,
struct prefix *p);
int ospf6_external_aggr_delay_timer_set(struct ospf6 *ospf6,
unsigned int interval);
int ospf6_asbr_external_rt_no_advertise(struct ospf6 *ospf6,
struct prefix *p);

struct ospf6_external_aggr_rt *
ospf6_external_aggr_config_lookup(struct ospf6 *ospf6, struct prefix *p);

int ospf6_external_aggr_config_set(struct ospf6 *ospf6, struct prefix *p,
route_tag_t tag, int metric, int mtype);

int ospf6_external_aggr_config_unset(struct ospf6 *ospf6,
struct prefix *p);
void ospf6_handle_external_lsa_origination(struct ospf6 *ospf6,
struct ospf6_route *rt,
struct prefix *p);
void ospf6_external_aggregator_free(struct ospf6_external_aggr_rt *aggr);
void ospf6_unset_all_aggr_flag(struct ospf6 *ospf6);
#endif /* OSPF6_ASBR_H */
27 changes: 26 additions & 1 deletion ospf6d/ospf6_flood.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ void ospf6_lsa_originate(struct ospf6_lsa *lsa)
lsdb_self = ospf6_get_scoped_lsdb_self(lsa);
ospf6_lsdb_add(ospf6_lsa_copy(lsa), lsdb_self);

lsa->refresh = NULL;
THREAD_OFF(lsa->refresh);
thread_add_timer(master, ospf6_lsa_refresh, lsa, OSPF_LS_REFRESH_TIME,
&lsa->refresh);

Expand Down Expand Up @@ -139,6 +139,31 @@ void ospf6_lsa_originate_interface(struct ospf6_lsa *lsa,
ospf6_lsa_originate(lsa);
}

void ospf6_remove_id_from_external_id_table(struct ospf6 *ospf6,
uint32_t id)
{
struct prefix prefix_id;
struct route_node *node;

/* remove binding in external_id_table */
prefix_id.family = AF_INET;
prefix_id.prefixlen = 32;
prefix_id.u.prefix4.s_addr = id;
node = route_node_lookup(ospf6->external_id_table, &prefix_id);
assert(node);
node->info = NULL;
route_unlock_node(node); /* to free the lookup lock */
route_unlock_node(node); /* to free the original lock */

}

void ospf6_external_lsa_purge(struct ospf6 *ospf6, struct ospf6_lsa *lsa)
{
ospf6_lsa_purge(lsa);

ospf6_remove_id_from_external_id_table(ospf6, lsa->header->id);
}

void ospf6_lsa_purge(struct ospf6_lsa *lsa)
{
struct ospf6_lsa *self;
Expand Down
3 changes: 3 additions & 0 deletions ospf6d/ospf6_flood.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ extern void ospf6_lsa_originate_area(struct ospf6_lsa *lsa,
struct ospf6_area *oa);
extern void ospf6_lsa_originate_interface(struct ospf6_lsa *lsa,
struct ospf6_interface *oi);
void ospf6_remove_id_from_external_id_table(struct ospf6 *ospf6,
uint32_t id);
void ospf6_external_lsa_purge(struct ospf6 *ospf6, struct ospf6_lsa *lsa);
extern void ospf6_lsa_purge(struct ospf6_lsa *lsa);

extern void ospf6_lsa_purge_multi_ls_id(struct ospf6_area *oa,
Expand Down
35 changes: 35 additions & 0 deletions ospf6d/ospf6_lsa.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@
#include "ospf6_flood.h"
#include "ospf6d.h"

#ifndef VTYSH_EXTRACT_PL
#include "ospf6d/ospf6_lsa_clippy.c"
#endif

DEFINE_MTYPE_STATIC(OSPF6D, OSPF6_LSA, "OSPF6 LSA");
DEFINE_MTYPE_STATIC(OSPF6D, OSPF6_LSA_HEADER, "OSPF6 LSA header");
DEFINE_MTYPE_STATIC(OSPF6D, OSPF6_LSA_SUMMARY, "OSPF6 LSA summary");
Expand Down Expand Up @@ -822,6 +826,8 @@ int ospf6_lsa_expire(struct thread *thread)
if (CHECK_FLAG(lsa->flag, OSPF6_LSA_HEADERONLY))
return 0; /* dbexchange will do something ... */
ospf6 = ospf6_get_by_lsdb(lsa);
assert(ospf6);

/* reinstall lsa */
ospf6_install_lsa(lsa);

Expand Down Expand Up @@ -994,6 +1000,30 @@ static char *ospf6_lsa_handler_name(const struct ospf6_lsa_handler *h)
return buf;
}

DEFPY (debug_ospf6_lsa_aggregation,
debug_ospf6_lsa_aggregation_cmd,
"[no] debug ospf6 lsa aggregation",
NO_STR
DEBUG_STR
OSPF6_STR
"Debug Link State Advertisements (LSAs)\n"
"External LSA Aggregation\n")
{

struct ospf6_lsa_handler *handler;

handler = ospf6_get_lsa_handler(OSPF6_LSTYPE_AS_EXTERNAL);
if (handler == NULL)
return CMD_WARNING_CONFIG_FAILED;

if (no)
UNSET_FLAG(handler->lh_debug, OSPF6_LSA_DEBUG_AGGR);
else
SET_FLAG(handler->lh_debug, OSPF6_LSA_DEBUG_AGGR);

return CMD_SUCCESS;
}

DEFUN (debug_ospf6_lsa_type,
debug_ospf6_lsa_hex_cmd,
"debug ospf6 lsa <router|network|inter-prefix|inter-router|as-external|link|intra-prefix|unknown> [<originate|examine|flooding>]",
Expand Down Expand Up @@ -1105,6 +1135,9 @@ void install_element_ospf6_debug_lsa(void)
install_element(ENABLE_NODE, &no_debug_ospf6_lsa_hex_cmd);
install_element(CONFIG_NODE, &debug_ospf6_lsa_hex_cmd);
install_element(CONFIG_NODE, &no_debug_ospf6_lsa_hex_cmd);

install_element(ENABLE_NODE, &debug_ospf6_lsa_aggregation_cmd);
install_element(CONFIG_NODE, &debug_ospf6_lsa_aggregation_cmd);
}

int config_write_ospf6_debug_lsa(struct vty *vty)
Expand All @@ -1128,6 +1161,8 @@ int config_write_ospf6_debug_lsa(struct vty *vty)
if (CHECK_FLAG(handler->lh_debug, OSPF6_LSA_DEBUG_FLOOD))
vty_out(vty, "debug ospf6 lsa %s flooding\n",
ospf6_lsa_handler_name(handler));
if (CHECK_FLAG(handler->lh_debug, OSPF6_LSA_DEBUG_AGGR))
vty_out(vty, "debug ospf6 lsa aggregation\n");
}

return 0;
Expand Down
4 changes: 4 additions & 0 deletions ospf6d/ospf6_lsa.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#define OSPF6_LSA_DEBUG_ORIGINATE 0x02
#define OSPF6_LSA_DEBUG_EXAMIN 0x04
#define OSPF6_LSA_DEBUG_FLOOD 0x08
#define OSPF6_LSA_DEBUG_AGGR 0x10

/* OSPF LSA Default metric values */
#define DEFAULT_DEFAULT_METRIC 20
Expand All @@ -51,6 +52,8 @@
(ospf6_lstype_debug(type) & OSPF6_LSA_DEBUG_EXAMIN)
#define IS_OSPF6_DEBUG_FLOOD_TYPE(type) \
(ospf6_lstype_debug(type) & OSPF6_LSA_DEBUG_FLOOD)
#define IS_OSPF6_DEBUG_AGGR \
(ospf6_lstype_debug(OSPF6_LSTYPE_AS_EXTERNAL) & OSPF6_LSA_DEBUG_AGGR) \

/* LSA definition */

Expand Down Expand Up @@ -263,4 +266,5 @@ extern void install_element_ospf6_debug_lsa(void);
extern void ospf6_lsa_age_set(struct ospf6_lsa *lsa);
extern void ospf6_flush_self_originated_lsas_now(struct ospf6 *ospf6);
extern struct ospf6 *ospf6_get_by_lsdb(struct ospf6_lsa *lsa);
struct ospf6_lsa *ospf6_find_external_lsa(struct ospf6 *ospf6, struct prefix *p);
#endif /* OSPF6_LSA_H */
23 changes: 23 additions & 0 deletions ospf6d/ospf6_lsdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include "ospf6_proto.h"
#include "ospf6_lsa.h"
#include "ospf6_lsdb.h"
#include "ospf6_asbr.h"
#include "ospf6_route.h"
#include "ospf6d.h"
#include "bitfield.h"
Expand Down Expand Up @@ -194,6 +195,28 @@ struct ospf6_lsa *ospf6_lsdb_lookup(uint16_t type, uint32_t id,
return (struct ospf6_lsa *)node->info;
}

struct ospf6_lsa *ospf6_find_external_lsa(struct ospf6 *ospf6, struct prefix *p)
{
struct ospf6_route *match;
struct ospf6_lsa *lsa;
struct ospf6_external_info *info;

match = ospf6_route_lookup(p, ospf6->external_table);
if (match == NULL) {
if (IS_OSPF6_DEBUG_ASBR)
zlog_debug("No such route %pFX to withdraw", p);

return NULL;
}

info = (struct ospf6_external_info *)(match->route_option);
assert(info);

lsa = ospf6_lsdb_lookup(htons(OSPF6_LSTYPE_AS_EXTERNAL),
htonl(info->id), ospf6->router_id, ospf6->lsdb);
return lsa;
}

struct ospf6_lsa *ospf6_lsdb_lookup_next(uint16_t type, uint32_t id,
uint32_t adv_router,
struct ospf6_lsdb *lsdb)
Expand Down
6 changes: 6 additions & 0 deletions ospf6d/ospf6_route.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,12 @@ struct ospf6_route {

/* nexthop */
struct list *nh_list;

/* points to the summarised route */
struct ospf6_external_aggr_rt *aggr_route;

/* For Aggr routes */
bool to_be_processed;
};

#define OSPF6_DEST_TYPE_NONE 0
Expand Down
Loading

0 comments on commit 4dc4388

Please sign in to comment.