mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-06-16 08:26:39 +00:00
ospf6d: properly update prefix list references
Register add/delete hooks with the prefix list code to properly change ospf6_area's prefix list in/out pointers. There are 2 other uncached uses of prefix lists in the ASBR route-map code and the interface code; these should probably be cached too. (To be fixed another day...) Fixes: #453 Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
This commit is contained in:
parent
6bd2b3608d
commit
427f8e61bb
@ -122,6 +122,14 @@ const char *prefix_list_name(struct prefix_list *plist)
|
|||||||
return plist->name;
|
return plist->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
afi_t prefix_list_afi(struct prefix_list *plist)
|
||||||
|
{
|
||||||
|
if (plist->master == &prefix_master_ipv4
|
||||||
|
|| plist->master == &prefix_master_orf_v4)
|
||||||
|
return AFI_IP;
|
||||||
|
return AFI_IP6;
|
||||||
|
}
|
||||||
|
|
||||||
/* Lookup prefix_list from list of prefix_list by name. */
|
/* Lookup prefix_list from list of prefix_list by name. */
|
||||||
static struct prefix_list *prefix_list_lookup_do(afi_t afi, int orf,
|
static struct prefix_list *prefix_list_lookup_do(afi_t afi, int orf,
|
||||||
const char *name)
|
const char *name)
|
||||||
|
@ -48,6 +48,7 @@ extern void prefix_list_add_hook(void (*func)(struct prefix_list *));
|
|||||||
extern void prefix_list_delete_hook(void (*func)(struct prefix_list *));
|
extern void prefix_list_delete_hook(void (*func)(struct prefix_list *));
|
||||||
|
|
||||||
extern const char *prefix_list_name(struct prefix_list *);
|
extern const char *prefix_list_name(struct prefix_list *);
|
||||||
|
extern afi_t prefix_list_afi(struct prefix_list *);
|
||||||
extern struct prefix_list *prefix_list_lookup(afi_t, const char *);
|
extern struct prefix_list *prefix_list_lookup(afi_t, const char *);
|
||||||
extern enum prefix_list_type prefix_list_apply(struct prefix_list *, void *);
|
extern enum prefix_list_type prefix_list_apply(struct prefix_list *, void *);
|
||||||
|
|
||||||
|
@ -386,27 +386,20 @@ int ospf6_abr_originate_summary_to_area(struct ospf6_route *route,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Check filter-list */
|
/* Check filter-list */
|
||||||
if (PREFIX_NAME_OUT(area)) {
|
if (PREFIX_LIST_OUT(area))
|
||||||
if (PREFIX_LIST_OUT(area) == NULL)
|
if (prefix_list_apply(PREFIX_LIST_OUT(area), &route->prefix)
|
||||||
PREFIX_LIST_OUT(area) = prefix_list_lookup(
|
!= PREFIX_PERMIT) {
|
||||||
AFI_IP6, PREFIX_NAME_OUT(area));
|
if (is_debug) {
|
||||||
|
inet_ntop(AF_INET,
|
||||||
if (PREFIX_LIST_OUT(area))
|
&(ADV_ROUTER_IN_PREFIX(
|
||||||
if (prefix_list_apply(PREFIX_LIST_OUT(area),
|
&route->prefix)),
|
||||||
&route->prefix)
|
buf, sizeof(buf));
|
||||||
!= PREFIX_PERMIT) {
|
zlog_debug(
|
||||||
if (is_debug) {
|
"prefix %s was denied by filter-list out",
|
||||||
inet_ntop(AF_INET,
|
buf);
|
||||||
&(ADV_ROUTER_IN_PREFIX(
|
|
||||||
&route->prefix)),
|
|
||||||
buf, sizeof(buf));
|
|
||||||
zlog_debug(
|
|
||||||
"prefix %s was denied by filter-list out",
|
|
||||||
buf);
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
}
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* the route is going to be originated. store it in area's summary_table
|
/* the route is going to be originated. store it in area's summary_table
|
||||||
*/
|
*/
|
||||||
@ -873,22 +866,16 @@ void ospf6_abr_examin_summary(struct ospf6_lsa *lsa, struct ospf6_area *oa)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Check input prefix-list */
|
/* Check input prefix-list */
|
||||||
if (PREFIX_NAME_IN(oa)) {
|
if (PREFIX_LIST_IN(oa))
|
||||||
if (PREFIX_LIST_IN(oa) == NULL)
|
if (prefix_list_apply(PREFIX_LIST_IN(oa), &prefix)
|
||||||
PREFIX_LIST_IN(oa) =
|
!= PREFIX_PERMIT) {
|
||||||
prefix_list_lookup(AFI_IP6, PREFIX_NAME_IN(oa));
|
if (is_debug)
|
||||||
|
zlog_debug(
|
||||||
if (PREFIX_LIST_IN(oa))
|
"Prefix was denied by prefix-list");
|
||||||
if (prefix_list_apply(PREFIX_LIST_IN(oa), &prefix)
|
if (old)
|
||||||
!= PREFIX_PERMIT) {
|
ospf6_route_remove(old, table);
|
||||||
if (is_debug)
|
return;
|
||||||
zlog_debug(
|
}
|
||||||
"Prefix was denied by prefix-list");
|
|
||||||
if (old)
|
|
||||||
ospf6_route_remove(old, table);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (5),(6): the path preference is handled by the sorting
|
/* (5),(6): the path preference is handled by the sorting
|
||||||
in the routing table. Always install the path by substituting
|
in the routing table. Always install the path by substituting
|
||||||
|
@ -45,6 +45,8 @@
|
|||||||
#include "ospf6_asbr.h"
|
#include "ospf6_asbr.h"
|
||||||
#include "ospf6d.h"
|
#include "ospf6d.h"
|
||||||
|
|
||||||
|
DEFINE_MTYPE_STATIC(OSPF6D, OSPF6_PLISTNAME, "Prefix list name")
|
||||||
|
|
||||||
int ospf6_area_cmp(void *va, void *vb)
|
int ospf6_area_cmp(void *va, void *vb)
|
||||||
{
|
{
|
||||||
struct ospf6_area *oa = (struct ospf6_area *)va;
|
struct ospf6_area *oa = (struct ospf6_area *)va;
|
||||||
@ -579,17 +581,15 @@ DEFUN (area_filter_list,
|
|||||||
plist = prefix_list_lookup(AFI_IP6, plistname);
|
plist = prefix_list_lookup(AFI_IP6, plistname);
|
||||||
if (strmatch(inout, "in")) {
|
if (strmatch(inout, "in")) {
|
||||||
PREFIX_LIST_IN(area) = plist;
|
PREFIX_LIST_IN(area) = plist;
|
||||||
if (PREFIX_NAME_IN(area))
|
XFREE(MTYPE_OSPF6_PLISTNAME, PREFIX_NAME_IN(area));
|
||||||
free(PREFIX_NAME_IN(area));
|
PREFIX_NAME_IN(area) = XSTRDUP(MTYPE_OSPF6_PLISTNAME,
|
||||||
|
plistname);
|
||||||
PREFIX_NAME_IN(area) = strdup(plistname);
|
|
||||||
ospf6_abr_reimport(area);
|
ospf6_abr_reimport(area);
|
||||||
} else {
|
} else {
|
||||||
PREFIX_LIST_OUT(area) = plist;
|
PREFIX_LIST_OUT(area) = plist;
|
||||||
if (PREFIX_NAME_OUT(area))
|
XFREE(MTYPE_OSPF6_PLISTNAME, PREFIX_NAME_OUT(area));
|
||||||
free(PREFIX_NAME_OUT(area));
|
PREFIX_NAME_OUT(area) = XSTRDUP(MTYPE_OSPF6_PLISTNAME,
|
||||||
|
plistname);
|
||||||
PREFIX_NAME_OUT(area) = strdup(plistname);
|
|
||||||
ospf6_abr_enable_area(area);
|
ospf6_abr_enable_area(area);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -622,27 +622,34 @@ DEFUN (no_area_filter_list,
|
|||||||
return CMD_SUCCESS;
|
return CMD_SUCCESS;
|
||||||
|
|
||||||
PREFIX_LIST_IN(area) = NULL;
|
PREFIX_LIST_IN(area) = NULL;
|
||||||
if (PREFIX_NAME_IN(area))
|
XFREE(MTYPE_OSPF6_PLISTNAME, PREFIX_NAME_IN(area));
|
||||||
free(PREFIX_NAME_IN(area));
|
|
||||||
|
|
||||||
PREFIX_NAME_IN(area) = NULL;
|
|
||||||
ospf6_abr_reimport(area);
|
ospf6_abr_reimport(area);
|
||||||
} else {
|
} else {
|
||||||
if (PREFIX_NAME_OUT(area))
|
if (PREFIX_NAME_OUT(area))
|
||||||
if (!strmatch(PREFIX_NAME_OUT(area), plistname))
|
if (!strmatch(PREFIX_NAME_OUT(area), plistname))
|
||||||
return CMD_SUCCESS;
|
return CMD_SUCCESS;
|
||||||
|
|
||||||
PREFIX_LIST_OUT(area) = NULL;
|
XFREE(MTYPE_OSPF6_PLISTNAME, PREFIX_NAME_OUT(area));
|
||||||
if (PREFIX_NAME_OUT(area))
|
|
||||||
free(PREFIX_NAME_OUT(area));
|
|
||||||
|
|
||||||
PREFIX_NAME_OUT(area) = NULL;
|
|
||||||
ospf6_abr_enable_area(area);
|
ospf6_abr_enable_area(area);
|
||||||
}
|
}
|
||||||
|
|
||||||
return CMD_SUCCESS;
|
return CMD_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ospf6_area_plist_update(struct prefix_list *plist, int add)
|
||||||
|
{
|
||||||
|
struct ospf6_area *oa;
|
||||||
|
struct listnode *n;
|
||||||
|
const char *name = prefix_list_name(plist);
|
||||||
|
|
||||||
|
for (ALL_LIST_ELEMENTS_RO(ospf6->area_list, n, oa)) {
|
||||||
|
if (!strcmp(PREFIX_NAME_IN(oa), name))
|
||||||
|
PREFIX_LIST_IN(oa) = add ? plist : NULL;
|
||||||
|
if (!strcmp(PREFIX_NAME_OUT(oa), name))
|
||||||
|
PREFIX_LIST_OUT(oa) = add ? plist : NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
DEFUN (area_import_list,
|
DEFUN (area_import_list,
|
||||||
area_import_list_cmd,
|
area_import_list_cmd,
|
||||||
"area A.B.C.D import-list NAME",
|
"area A.B.C.D import-list NAME",
|
||||||
|
@ -122,6 +122,7 @@ extern void ospf6_area_disable(struct ospf6_area *);
|
|||||||
|
|
||||||
extern void ospf6_area_show(struct vty *, struct ospf6_area *);
|
extern void ospf6_area_show(struct vty *, struct ospf6_area *);
|
||||||
|
|
||||||
|
extern void ospf6_area_plist_update(struct prefix_list *plist, int add);
|
||||||
extern void ospf6_area_config_write(struct vty *vty);
|
extern void ospf6_area_config_write(struct vty *vty);
|
||||||
extern void ospf6_area_init(void);
|
extern void ospf6_area_init(void);
|
||||||
|
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
#include "linklist.h"
|
#include "linklist.h"
|
||||||
#include "vty.h"
|
#include "vty.h"
|
||||||
#include "command.h"
|
#include "command.h"
|
||||||
|
#include "plist.h"
|
||||||
|
|
||||||
#include "ospf6_proto.h"
|
#include "ospf6_proto.h"
|
||||||
#include "ospf6_network.h"
|
#include "ospf6_network.h"
|
||||||
@ -1139,6 +1140,20 @@ DEFUN (show_ipv6_ospf6_linkstate_detail,
|
|||||||
return CMD_SUCCESS;
|
return CMD_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void ospf6_plist_add(struct prefix_list *plist)
|
||||||
|
{
|
||||||
|
if (prefix_list_afi(plist) != AFI_IP6)
|
||||||
|
return;
|
||||||
|
ospf6_area_plist_update(plist, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ospf6_plist_del(struct prefix_list *plist)
|
||||||
|
{
|
||||||
|
if (prefix_list_afi(plist) != AFI_IP6)
|
||||||
|
return;
|
||||||
|
ospf6_area_plist_update(plist, 0);
|
||||||
|
}
|
||||||
|
|
||||||
/* Install ospf related commands. */
|
/* Install ospf related commands. */
|
||||||
void ospf6_init(void)
|
void ospf6_init(void)
|
||||||
{
|
{
|
||||||
@ -1154,6 +1169,9 @@ void ospf6_init(void)
|
|||||||
ospf6_asbr_init();
|
ospf6_asbr_init();
|
||||||
ospf6_abr_init();
|
ospf6_abr_init();
|
||||||
|
|
||||||
|
prefix_list_add_hook(ospf6_plist_add);
|
||||||
|
prefix_list_delete_hook(ospf6_plist_del);
|
||||||
|
|
||||||
ospf6_bfd_init();
|
ospf6_bfd_init();
|
||||||
install_node(&debug_node, config_write_ospf6_debug);
|
install_node(&debug_node, config_write_ospf6_debug);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user