mirror of
https://github.com/FRRouting/frr.git
synced 2025-04-30 05:27:16 +02:00
lib: enable multiple instance support with distribute lists
Signed-off-by: Christian Hopps <chopps@labn.net>
This commit is contained in:
parent
eba64f79cc
commit
a993b8e9bb
|
@ -710,7 +710,7 @@ DEFUN (babel_distribute_list,
|
|||
if (argv[argc - 1]->type == VARIABLE_TKN)
|
||||
ifname = argv[argc - 1]->arg;
|
||||
|
||||
return distribute_list_parser(prefix, true, argv[2 + prefix]->text,
|
||||
return distribute_list_parser(NULL, prefix, true, argv[2 + prefix]->text,
|
||||
argv[1 + prefix]->arg, ifname);
|
||||
}
|
||||
|
||||
|
@ -731,7 +731,7 @@ DEFUN (babel_no_distribute_list,
|
|||
if (argv[argc - 1]->type == VARIABLE_TKN)
|
||||
ifname = argv[argc - 1]->arg;
|
||||
|
||||
return distribute_list_no_parser(vty, prefix, true,
|
||||
return distribute_list_no_parser(NULL, vty, prefix, true,
|
||||
argv[3 + prefix]->text,
|
||||
argv[2 + prefix]->arg, ifname);
|
||||
}
|
||||
|
@ -753,7 +753,8 @@ DEFUN (babel_ipv6_distribute_list,
|
|||
if (argv[argc - 1]->type == VARIABLE_TKN)
|
||||
ifname = argv[argc - 1]->arg;
|
||||
|
||||
return distribute_list_parser(prefix, false, argv[3 + prefix]->text,
|
||||
return distribute_list_parser(NULL, prefix, false,
|
||||
argv[3 + prefix]->text,
|
||||
argv[2 + prefix]->arg, ifname);
|
||||
}
|
||||
|
||||
|
@ -775,7 +776,7 @@ DEFUN (babel_no_ipv6_distribute_list,
|
|||
if (argv[argc - 1]->type == VARIABLE_TKN)
|
||||
ifname = argv[argc - 1]->arg;
|
||||
|
||||
return distribute_list_no_parser(vty, prefix, false,
|
||||
return distribute_list_no_parser(NULL, vty, prefix, false,
|
||||
argv[4 + prefix]->text,
|
||||
argv[3 + prefix]->arg, ifname);
|
||||
}
|
||||
|
|
|
@ -1123,7 +1123,7 @@ DEFUN (eigrp_distribute_list,
|
|||
if (argv[argc - 1]->type == VARIABLE_TKN)
|
||||
ifname = argv[argc - 1]->arg;
|
||||
|
||||
return distribute_list_parser(prefix, true, argv[2 + prefix]->text,
|
||||
return distribute_list_parser(NULL, prefix, true, argv[2 + prefix]->text,
|
||||
argv[1 + prefix]->arg, ifname);
|
||||
}
|
||||
|
||||
|
@ -1144,14 +1144,14 @@ DEFUN (eigrp_no_distribute_list,
|
|||
if (argv[argc - 1]->type == VARIABLE_TKN)
|
||||
ifname = argv[argc - 1]->arg;
|
||||
|
||||
return distribute_list_no_parser(vty, prefix, true,
|
||||
return distribute_list_no_parser(NULL, vty, prefix, true,
|
||||
argv[3 + prefix]->text,
|
||||
argv[2 + prefix]->arg, ifname);
|
||||
}
|
||||
|
||||
|
||||
/* Route-map init */
|
||||
void eigrp_route_map_init()
|
||||
void eigrp_route_map_init(void)
|
||||
{
|
||||
route_map_init();
|
||||
route_map_init_vty();
|
||||
|
|
|
@ -244,11 +244,13 @@ static enum distribute_type distribute_direction(const char *dir, bool v4)
|
|||
__builtin_unreachable();
|
||||
}
|
||||
|
||||
int distribute_list_parser(bool prefix, bool v4, const char *dir,
|
||||
const char *list, const char *ifname)
|
||||
int distribute_list_parser(struct distribute_ctx *ctx, bool prefix, bool v4,
|
||||
const char *dir, const char *list, const char *ifname)
|
||||
{
|
||||
enum distribute_type type = distribute_direction(dir, v4);
|
||||
struct distribute_ctx *ctx = listnode_head(dist_ctx_list);
|
||||
|
||||
if (!ctx)
|
||||
ctx = listnode_head(dist_ctx_list);
|
||||
|
||||
void (*distfn)(struct distribute_ctx *, const char *,
|
||||
enum distribute_type, const char *) =
|
||||
|
@ -259,14 +261,17 @@ int distribute_list_parser(bool prefix, bool v4, const char *dir,
|
|||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
int distribute_list_no_parser(struct vty *vty, bool prefix, bool v4,
|
||||
const char *dir, const char *list,
|
||||
const char *ifname)
|
||||
|
||||
int distribute_list_no_parser(struct distribute_ctx *ctx, struct vty *vty,
|
||||
bool prefix, bool v4, const char *dir,
|
||||
const char *list, const char *ifname)
|
||||
{
|
||||
enum distribute_type type = distribute_direction(dir, v4);
|
||||
struct distribute_ctx *ctx = listnode_head(dist_ctx_list);
|
||||
int ret;
|
||||
|
||||
if (!ctx)
|
||||
ctx = listnode_head(dist_ctx_list);
|
||||
|
||||
int (*distfn)(struct distribute_ctx *, const char *,
|
||||
enum distribute_type, const char *) =
|
||||
prefix ? &distribute_list_prefix_unset : &distribute_list_unset;
|
||||
|
@ -451,8 +456,7 @@ int config_write_distribute(struct vty *vty,
|
|||
int group_distribute_list_create_helper(
|
||||
struct nb_cb_create_args *args, struct distribute_ctx *ctx)
|
||||
{
|
||||
/* The code currently doesn't require this as it uses a global */
|
||||
/* nb_running_set_entry(args->dnode, ctx); */
|
||||
nb_running_set_entry(args->dnode, ctx);
|
||||
return NB_OK;
|
||||
}
|
||||
|
||||
|
@ -469,23 +473,23 @@ int group_distribute_list_destroy(struct nb_cb_destroy_args *args)
|
|||
static int distribute_list_leaf_update(const struct lyd_node *dnode,
|
||||
int ip_version, bool no)
|
||||
{
|
||||
struct distribute_ctx *ctx;
|
||||
struct lyd_node *dir_node = lyd_parent(dnode);
|
||||
struct lyd_node_inner *list_node = dir_node->parent;
|
||||
struct lyd_node *intf_key = list_node->child;
|
||||
bool ipv4 = ip_version == 4 ? true : false;
|
||||
bool prefix;
|
||||
|
||||
/* The code currently doesn't require this as it uses a global */
|
||||
/* ctx = nb_running_get_entry_non_rec(&list_node->node, NULL, false); */
|
||||
ctx = nb_running_get_entry_non_rec(&list_node->node, NULL, false);
|
||||
|
||||
prefix = dnode->schema->name[0] == 'p' ? true : false;
|
||||
if (no)
|
||||
distribute_list_no_parser(NULL, prefix, ipv4,
|
||||
distribute_list_no_parser(ctx, NULL, prefix, ipv4,
|
||||
dir_node->schema->name,
|
||||
lyd_get_value(dnode),
|
||||
lyd_get_value(intf_key));
|
||||
else
|
||||
distribute_list_parser(prefix, ipv4,
|
||||
distribute_list_parser(ctx, prefix, ipv4,
|
||||
dir_node->schema->name,
|
||||
lyd_get_value(dnode),
|
||||
lyd_get_value(intf_key));
|
||||
|
|
|
@ -70,9 +70,11 @@ extern enum filter_type distribute_apply_in(struct interface *,
|
|||
extern enum filter_type distribute_apply_out(struct interface *,
|
||||
struct prefix *);
|
||||
|
||||
extern int distribute_list_parser(bool prefix, bool v4, const char *dir,
|
||||
const char *list, const char *ifname);
|
||||
extern int distribute_list_no_parser(struct vty *vty, bool prefix, bool v4,
|
||||
extern int distribute_list_parser(struct distribute_ctx *ctx, bool prefix,
|
||||
bool v4, const char *dir, const char *list,
|
||||
const char *ifname);
|
||||
extern int distribute_list_no_parser(struct distribute_ctx *ctx,
|
||||
struct vty *vty, bool prefix, bool v4,
|
||||
const char *dir, const char *list,
|
||||
const char *ifname);
|
||||
|
||||
|
|
|
@ -1144,7 +1144,7 @@ DEFUN (rip_distribute_list,
|
|||
if (argv[argc - 1]->type == VARIABLE_TKN)
|
||||
ifname = argv[argc - 1]->arg;
|
||||
|
||||
return distribute_list_parser(prefix, true, argv[2 + prefix]->text,
|
||||
return distribute_list_parser(NULL, prefix, true, argv[2 + prefix]->text,
|
||||
argv[1 + prefix]->arg, ifname);
|
||||
}
|
||||
|
||||
|
@ -1165,7 +1165,7 @@ DEFUN (rip_no_distribute_list,
|
|||
if (argv[argc - 1]->type == VARIABLE_TKN)
|
||||
ifname = argv[argc - 1]->arg;
|
||||
|
||||
return distribute_list_no_parser(vty, prefix, true,
|
||||
return distribute_list_no_parser(NULL, vty, prefix, true,
|
||||
argv[3 + prefix]->text,
|
||||
argv[2 + prefix]->arg, ifname);
|
||||
}
|
||||
|
|
|
@ -533,7 +533,8 @@ DEFUN (ripng_ipv6_distribute_list,
|
|||
if (argv[argc - 1]->type == VARIABLE_TKN)
|
||||
ifname = argv[argc - 1]->arg;
|
||||
|
||||
return distribute_list_parser(prefix, false, argv[3 + prefix]->text,
|
||||
return distribute_list_parser(NULL, prefix, false,
|
||||
argv[3 + prefix]->text,
|
||||
argv[2 + prefix]->arg, ifname);
|
||||
}
|
||||
|
||||
|
@ -555,7 +556,7 @@ DEFUN (ripng_no_ipv6_distribute_list,
|
|||
if (argv[argc - 1]->type == VARIABLE_TKN)
|
||||
ifname = argv[argc - 1]->arg;
|
||||
|
||||
return distribute_list_no_parser(vty, prefix, false,
|
||||
return distribute_list_no_parser(NULL, vty, prefix, false,
|
||||
argv[4 + prefix]->text,
|
||||
argv[3 + prefix]->arg, ifname);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue