mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-13 17:40:04 +00:00
lib: Modifications to route-map NB
This commit introduces the changes to the library route-map north-bound callback implementation in order to align it to the modified yang definitions. Signed-off-by: NaveenThanikachalam <nthanikachal@vmware.com> Signed-off-by: Sarita Patra <saritap@vmware.com>
This commit is contained in:
parent
b702f42445
commit
d5d737a2df
296
lib/routemap.c
296
lib/routemap.c
@ -87,112 +87,126 @@ struct route_map_match_set_hooks rmap_match_set_hook;
|
||||
|
||||
/* match interface */
|
||||
void route_map_match_interface_hook(int (*func)(
|
||||
struct vty *vty, struct route_map_index *index, const char *command,
|
||||
const char *arg, route_map_event_t type))
|
||||
struct route_map_index *index, const char *command,
|
||||
const char *arg, route_map_event_t type,
|
||||
char *errmsg, size_t errmsg_len))
|
||||
{
|
||||
rmap_match_set_hook.match_interface = func;
|
||||
}
|
||||
|
||||
/* no match interface */
|
||||
void route_map_no_match_interface_hook(int (*func)(
|
||||
struct vty *vty, struct route_map_index *index, const char *command,
|
||||
const char *arg, route_map_event_t type))
|
||||
struct route_map_index *index, const char *command,
|
||||
const char *arg, route_map_event_t type,
|
||||
char *errmsg, size_t errmsg_len))
|
||||
{
|
||||
rmap_match_set_hook.no_match_interface = func;
|
||||
}
|
||||
|
||||
/* match ip address */
|
||||
void route_map_match_ip_address_hook(int (*func)(
|
||||
struct vty *vty, struct route_map_index *index, const char *command,
|
||||
const char *arg, route_map_event_t type))
|
||||
struct route_map_index *index, const char *command,
|
||||
const char *arg, route_map_event_t type,
|
||||
char *errmsg, size_t errmsg_len))
|
||||
{
|
||||
rmap_match_set_hook.match_ip_address = func;
|
||||
}
|
||||
|
||||
/* no match ip address */
|
||||
void route_map_no_match_ip_address_hook(int (*func)(
|
||||
struct vty *vty, struct route_map_index *index, const char *command,
|
||||
const char *arg, route_map_event_t type))
|
||||
struct route_map_index *index, const char *command,
|
||||
const char *arg, route_map_event_t type,
|
||||
char *errmsg, size_t errmsg_len))
|
||||
{
|
||||
rmap_match_set_hook.no_match_ip_address = func;
|
||||
}
|
||||
|
||||
/* match ip address prefix list */
|
||||
void route_map_match_ip_address_prefix_list_hook(int (*func)(
|
||||
struct vty *vty, struct route_map_index *index, const char *command,
|
||||
const char *arg, route_map_event_t type))
|
||||
struct route_map_index *index, const char *command,
|
||||
const char *arg, route_map_event_t type,
|
||||
char *errmsg, size_t errmsg_len))
|
||||
{
|
||||
rmap_match_set_hook.match_ip_address_prefix_list = func;
|
||||
}
|
||||
|
||||
/* no match ip address prefix list */
|
||||
void route_map_no_match_ip_address_prefix_list_hook(int (*func)(
|
||||
struct vty *vty, struct route_map_index *index, const char *command,
|
||||
const char *arg, route_map_event_t type))
|
||||
struct route_map_index *index, const char *command,
|
||||
const char *arg, route_map_event_t type,
|
||||
char *errmsg, size_t errmsg_len))
|
||||
{
|
||||
rmap_match_set_hook.no_match_ip_address_prefix_list = func;
|
||||
}
|
||||
|
||||
/* match ip next hop */
|
||||
void route_map_match_ip_next_hop_hook(int (*func)(
|
||||
struct vty *vty, struct route_map_index *index, const char *command,
|
||||
const char *arg, route_map_event_t type))
|
||||
struct route_map_index *index, const char *command,
|
||||
const char *arg, route_map_event_t type,
|
||||
char *errmsg, size_t errmsg_len))
|
||||
{
|
||||
rmap_match_set_hook.match_ip_next_hop = func;
|
||||
}
|
||||
|
||||
/* no match ip next hop */
|
||||
void route_map_no_match_ip_next_hop_hook(int (*func)(
|
||||
struct vty *vty, struct route_map_index *index, const char *command,
|
||||
const char *arg, route_map_event_t type))
|
||||
struct route_map_index *index, const char *command,
|
||||
const char *arg, route_map_event_t type,
|
||||
char *errmsg, size_t errmsg_len))
|
||||
{
|
||||
rmap_match_set_hook.no_match_ip_next_hop = func;
|
||||
}
|
||||
|
||||
/* match ip next hop prefix list */
|
||||
void route_map_match_ip_next_hop_prefix_list_hook(int (*func)(
|
||||
struct vty *vty, struct route_map_index *index, const char *command,
|
||||
const char *arg, route_map_event_t type))
|
||||
struct route_map_index *index, const char *command,
|
||||
const char *arg, route_map_event_t type,
|
||||
char *errmsg, size_t errmsg_len))
|
||||
{
|
||||
rmap_match_set_hook.match_ip_next_hop_prefix_list = func;
|
||||
}
|
||||
|
||||
/* no match ip next hop prefix list */
|
||||
void route_map_no_match_ip_next_hop_prefix_list_hook(int (*func)(
|
||||
struct vty *vty, struct route_map_index *index, const char *command,
|
||||
const char *arg, route_map_event_t type))
|
||||
struct route_map_index *index, const char *command,
|
||||
const char *arg, route_map_event_t type,
|
||||
char *errmsg, size_t errmsg_len))
|
||||
{
|
||||
rmap_match_set_hook.no_match_ip_next_hop_prefix_list = func;
|
||||
}
|
||||
|
||||
/* match ip next-hop type */
|
||||
void route_map_match_ip_next_hop_type_hook(int (*func)(
|
||||
struct vty *vty, struct route_map_index *index, const char *command,
|
||||
const char *arg, route_map_event_t type))
|
||||
struct route_map_index *index, const char *command,
|
||||
const char *arg, route_map_event_t type,
|
||||
char *errmsg, size_t errmsg_len))
|
||||
{
|
||||
rmap_match_set_hook.match_ip_next_hop_type = func;
|
||||
}
|
||||
|
||||
/* no match ip next-hop type */
|
||||
void route_map_no_match_ip_next_hop_type_hook(int (*func)(
|
||||
struct vty *vty, struct route_map_index *index, const char *command,
|
||||
const char *arg, route_map_event_t type))
|
||||
struct route_map_index *index, const char *command,
|
||||
const char *arg, route_map_event_t type,
|
||||
char *errmsg, size_t errmsg_len))
|
||||
{
|
||||
rmap_match_set_hook.no_match_ip_next_hop_type = func;
|
||||
}
|
||||
|
||||
/* match ipv6 address */
|
||||
void route_map_match_ipv6_address_hook(int (*func)(
|
||||
struct vty *vty, struct route_map_index *index, const char *command,
|
||||
const char *arg, route_map_event_t type))
|
||||
struct route_map_index *index, const char *command,
|
||||
const char *arg, route_map_event_t type,
|
||||
char *errmsg, size_t errmsg_len))
|
||||
{
|
||||
rmap_match_set_hook.match_ipv6_address = func;
|
||||
}
|
||||
|
||||
/* no match ipv6 address */
|
||||
void route_map_no_match_ipv6_address_hook(int (*func)(
|
||||
struct vty *vty, struct route_map_index *index, const char *command,
|
||||
const char *arg, route_map_event_t type))
|
||||
struct route_map_index *index, const char *command,
|
||||
const char *arg, route_map_event_t type,
|
||||
char *errmsg, size_t errmsg_len))
|
||||
{
|
||||
rmap_match_set_hook.no_match_ipv6_address = func;
|
||||
}
|
||||
@ -200,178 +214,183 @@ void route_map_no_match_ipv6_address_hook(int (*func)(
|
||||
|
||||
/* match ipv6 address prefix list */
|
||||
void route_map_match_ipv6_address_prefix_list_hook(int (*func)(
|
||||
struct vty *vty, struct route_map_index *index, const char *command,
|
||||
const char *arg, route_map_event_t type))
|
||||
struct route_map_index *index, const char *command,
|
||||
const char *arg, route_map_event_t type,
|
||||
char *errmsg, size_t errmsg_len))
|
||||
{
|
||||
rmap_match_set_hook.match_ipv6_address_prefix_list = func;
|
||||
}
|
||||
|
||||
/* no match ipv6 address prefix list */
|
||||
void route_map_no_match_ipv6_address_prefix_list_hook(int (*func)(
|
||||
struct vty *vty, struct route_map_index *index, const char *command,
|
||||
const char *arg, route_map_event_t type))
|
||||
struct route_map_index *index, const char *command,
|
||||
const char *arg, route_map_event_t type,
|
||||
char *errmsg, size_t errmsg_len))
|
||||
{
|
||||
rmap_match_set_hook.no_match_ipv6_address_prefix_list = func;
|
||||
}
|
||||
|
||||
/* match ipv6 next-hop type */
|
||||
void route_map_match_ipv6_next_hop_type_hook(int (*func)(
|
||||
struct vty *vty, struct route_map_index *index, const char *command,
|
||||
const char *arg, route_map_event_t type))
|
||||
struct route_map_index *index, const char *command,
|
||||
const char *arg, route_map_event_t type,
|
||||
char *errmsg, size_t errmsg_len))
|
||||
{
|
||||
rmap_match_set_hook.match_ipv6_next_hop_type = func;
|
||||
}
|
||||
|
||||
/* no match ipv6 next-hop type */
|
||||
void route_map_no_match_ipv6_next_hop_type_hook(int (*func)(
|
||||
struct vty *vty, struct route_map_index *index, const char *command,
|
||||
const char *arg, route_map_event_t type))
|
||||
struct route_map_index *index, const char *command,
|
||||
const char *arg, route_map_event_t type,
|
||||
char *errmsg, size_t errmsg_len))
|
||||
{
|
||||
rmap_match_set_hook.no_match_ipv6_next_hop_type = func;
|
||||
}
|
||||
|
||||
/* match metric */
|
||||
void route_map_match_metric_hook(int (*func)(
|
||||
struct vty *vty, struct route_map_index *index, const char *command,
|
||||
const char *arg, route_map_event_t type))
|
||||
struct route_map_index *index, const char *command,
|
||||
const char *arg, route_map_event_t type,
|
||||
char *errmsg, size_t errmsg_len))
|
||||
{
|
||||
rmap_match_set_hook.match_metric = func;
|
||||
}
|
||||
|
||||
/* no match metric */
|
||||
void route_map_no_match_metric_hook(int (*func)(
|
||||
struct vty *vty, struct route_map_index *index, const char *command,
|
||||
const char *arg, route_map_event_t type))
|
||||
struct route_map_index *index, const char *command,
|
||||
const char *arg, route_map_event_t type,
|
||||
char *errmsg, size_t errmsg_len))
|
||||
{
|
||||
rmap_match_set_hook.no_match_metric = func;
|
||||
}
|
||||
|
||||
/* match tag */
|
||||
void route_map_match_tag_hook(int (*func)(struct vty *vty,
|
||||
struct route_map_index *index,
|
||||
void route_map_match_tag_hook(int (*func)(struct route_map_index *index,
|
||||
const char *command, const char *arg,
|
||||
route_map_event_t type))
|
||||
route_map_event_t type,
|
||||
char *errmsg, size_t errmsg_len))
|
||||
{
|
||||
rmap_match_set_hook.match_tag = func;
|
||||
}
|
||||
|
||||
/* no match tag */
|
||||
void route_map_no_match_tag_hook(int (*func)(
|
||||
struct vty *vty, struct route_map_index *index, const char *command,
|
||||
const char *arg, route_map_event_t type))
|
||||
struct route_map_index *index, const char *command,
|
||||
const char *arg, route_map_event_t type,
|
||||
char *errmsg, size_t errmsg_len))
|
||||
{
|
||||
rmap_match_set_hook.no_match_tag = func;
|
||||
}
|
||||
|
||||
/* set sr-te color */
|
||||
void route_map_set_srte_color_hook(int (*func)(struct vty *vty,
|
||||
struct route_map_index *index,
|
||||
void route_map_set_srte_color_hook(int (*func)(struct route_map_index *index,
|
||||
const char *command,
|
||||
const char *arg))
|
||||
const char *arg,
|
||||
char *errmsg, size_t errmsg_len))
|
||||
{
|
||||
rmap_match_set_hook.set_srte_color = func;
|
||||
}
|
||||
|
||||
/* no set sr-te color */
|
||||
void route_map_no_set_srte_color_hook(int (*func)(struct vty *vty,
|
||||
struct route_map_index *index,
|
||||
void route_map_no_set_srte_color_hook(int (*func)(struct route_map_index *index,
|
||||
const char *command,
|
||||
const char *arg))
|
||||
const char *arg,
|
||||
char *errmsg, size_t errmsg_len))
|
||||
{
|
||||
rmap_match_set_hook.no_set_srte_color = func;
|
||||
}
|
||||
|
||||
/* set ip nexthop */
|
||||
void route_map_set_ip_nexthop_hook(int (*func)(struct vty *vty,
|
||||
struct route_map_index *index,
|
||||
void route_map_set_ip_nexthop_hook(int (*func)(struct route_map_index *index,
|
||||
const char *command,
|
||||
const char *arg))
|
||||
const char *arg,
|
||||
char *errmsg, size_t errmsg_len))
|
||||
{
|
||||
rmap_match_set_hook.set_ip_nexthop = func;
|
||||
}
|
||||
|
||||
/* no set ip nexthop */
|
||||
void route_map_no_set_ip_nexthop_hook(int (*func)(struct vty *vty,
|
||||
struct route_map_index *index,
|
||||
void route_map_no_set_ip_nexthop_hook(int (*func)(struct route_map_index *index,
|
||||
const char *command,
|
||||
const char *arg))
|
||||
const char *arg,
|
||||
char *errmsg,
|
||||
size_t errmsg_len))
|
||||
{
|
||||
rmap_match_set_hook.no_set_ip_nexthop = func;
|
||||
}
|
||||
|
||||
/* set ipv6 nexthop local */
|
||||
void route_map_set_ipv6_nexthop_local_hook(
|
||||
int (*func)(struct vty *vty, struct route_map_index *index,
|
||||
const char *command, const char *arg))
|
||||
int (*func)(struct route_map_index *index,
|
||||
const char *command, const char *arg,
|
||||
char *errmsg, size_t errmsg_len))
|
||||
{
|
||||
rmap_match_set_hook.set_ipv6_nexthop_local = func;
|
||||
}
|
||||
|
||||
/* no set ipv6 nexthop local */
|
||||
void route_map_no_set_ipv6_nexthop_local_hook(
|
||||
int (*func)(struct vty *vty, struct route_map_index *index,
|
||||
const char *command, const char *arg))
|
||||
int (*func)(struct route_map_index *index,
|
||||
const char *command, const char *arg,
|
||||
char *errmsg, size_t errmsg_len))
|
||||
{
|
||||
rmap_match_set_hook.no_set_ipv6_nexthop_local = func;
|
||||
}
|
||||
|
||||
/* set metric */
|
||||
void route_map_set_metric_hook(int (*func)(struct vty *vty,
|
||||
struct route_map_index *index,
|
||||
void route_map_set_metric_hook(int (*func)(struct route_map_index *index,
|
||||
const char *command,
|
||||
const char *arg))
|
||||
const char *arg,
|
||||
char *errmsg, size_t errmsg_len))
|
||||
{
|
||||
rmap_match_set_hook.set_metric = func;
|
||||
}
|
||||
|
||||
/* no set metric */
|
||||
void route_map_no_set_metric_hook(int (*func)(struct vty *vty,
|
||||
struct route_map_index *index,
|
||||
void route_map_no_set_metric_hook(int (*func)(struct route_map_index *index,
|
||||
const char *command,
|
||||
const char *arg))
|
||||
const char *arg,
|
||||
char *errmsg, size_t errmsg_len))
|
||||
{
|
||||
rmap_match_set_hook.no_set_metric = func;
|
||||
}
|
||||
|
||||
/* set tag */
|
||||
void route_map_set_tag_hook(int (*func)(struct vty *vty,
|
||||
struct route_map_index *index,
|
||||
const char *command, const char *arg))
|
||||
void route_map_set_tag_hook(int (*func)(struct route_map_index *index,
|
||||
const char *command, const char *arg,
|
||||
char *errmsg, size_t errmsg_len))
|
||||
{
|
||||
rmap_match_set_hook.set_tag = func;
|
||||
}
|
||||
|
||||
/* no set tag */
|
||||
void route_map_no_set_tag_hook(int (*func)(struct vty *vty,
|
||||
struct route_map_index *index,
|
||||
void route_map_no_set_tag_hook(int (*func)(struct route_map_index *index,
|
||||
const char *command,
|
||||
const char *arg))
|
||||
const char *arg,
|
||||
char *errmsg, size_t errmsg_len))
|
||||
{
|
||||
rmap_match_set_hook.no_set_tag = func;
|
||||
}
|
||||
|
||||
int generic_match_add(struct vty *vty, struct route_map_index *index,
|
||||
int generic_match_add(struct route_map_index *index,
|
||||
const char *command, const char *arg,
|
||||
route_map_event_t type)
|
||||
route_map_event_t type,
|
||||
char *errmsg, size_t errmsg_len)
|
||||
{
|
||||
enum rmap_compile_rets ret;
|
||||
|
||||
ret = route_map_add_match(index, command, arg, type);
|
||||
switch (ret) {
|
||||
case RMAP_RULE_MISSING:
|
||||
if (vty)
|
||||
vty_out(vty, "%% [%s] Can't find rule.\n",
|
||||
frr_protonameinst);
|
||||
else
|
||||
zlog_warn("Can't find rule: %s", command);
|
||||
snprintf(errmsg, errmsg_len, "%% [%s] Can't find rule.",
|
||||
frr_protonameinst);
|
||||
return CMD_WARNING_CONFIG_FAILED;
|
||||
case RMAP_COMPILE_ERROR:
|
||||
if (vty)
|
||||
vty_out(vty,
|
||||
"%% [%s] Argument form is unsupported or malformed.\n",
|
||||
frr_protonameinst);
|
||||
else
|
||||
zlog_warn("Argument form is unsupported or malformed: %s %s", command, arg);
|
||||
snprintf(errmsg, errmsg_len,
|
||||
"%% [%s] Argument form is unsupported or malformed.",
|
||||
frr_protonameinst);
|
||||
return CMD_WARNING_CONFIG_FAILED;
|
||||
case RMAP_COMPILE_SUCCESS:
|
||||
/*
|
||||
@ -383,9 +402,10 @@ int generic_match_add(struct vty *vty, struct route_map_index *index,
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
int generic_match_delete(struct vty *vty, struct route_map_index *index,
|
||||
int generic_match_delete(struct route_map_index *index,
|
||||
const char *command, const char *arg,
|
||||
route_map_event_t type)
|
||||
route_map_event_t type,
|
||||
char *errmsg, size_t errmsg_len)
|
||||
{
|
||||
enum rmap_compile_rets ret;
|
||||
int retval = CMD_SUCCESS;
|
||||
@ -409,20 +429,14 @@ int generic_match_delete(struct vty *vty, struct route_map_index *index,
|
||||
ret = route_map_delete_match(index, command, dep_name, type);
|
||||
switch (ret) {
|
||||
case RMAP_RULE_MISSING:
|
||||
if (vty)
|
||||
vty_out(vty, "%% [%s] Can't find rule.\n",
|
||||
frr_protonameinst);
|
||||
else
|
||||
zlog_warn("Can't find rule: %s", command);
|
||||
snprintf(errmsg, errmsg_len, "%% [%s] Can't find rule.",
|
||||
frr_protonameinst);
|
||||
retval = CMD_WARNING_CONFIG_FAILED;
|
||||
break;
|
||||
case RMAP_COMPILE_ERROR:
|
||||
if (vty)
|
||||
vty_out(vty,
|
||||
"%% [%s] Argument form is unsupported or malformed.\n",
|
||||
frr_protonameinst);
|
||||
else
|
||||
zlog_warn("Argument form is unsupported or malformed: %s %s", command, arg);
|
||||
snprintf(errmsg, errmsg_len,
|
||||
"%% [%s] Argument form is unsupported or malformed.",
|
||||
frr_protonameinst);
|
||||
retval = CMD_WARNING_CONFIG_FAILED;
|
||||
break;
|
||||
case RMAP_COMPILE_SUCCESS:
|
||||
@ -438,26 +452,22 @@ int generic_match_delete(struct vty *vty, struct route_map_index *index,
|
||||
return retval;
|
||||
}
|
||||
|
||||
int generic_set_add(struct vty *vty, struct route_map_index *index,
|
||||
const char *command, const char *arg)
|
||||
int generic_set_add(struct route_map_index *index,
|
||||
const char *command, const char *arg,
|
||||
char *errmsg, size_t errmsg_len)
|
||||
{
|
||||
enum rmap_compile_rets ret;
|
||||
|
||||
ret = route_map_add_set(index, command, arg);
|
||||
switch (ret) {
|
||||
case RMAP_RULE_MISSING:
|
||||
if (vty)
|
||||
vty_out(vty, "%% [%s] Can't find rule.\n", frr_protonameinst);
|
||||
else
|
||||
zlog_warn("Can't find rule: %s", command);
|
||||
snprintf(errmsg, errmsg_len,
|
||||
"%% [%s] Can't find rule.", frr_protonameinst);
|
||||
return CMD_WARNING_CONFIG_FAILED;
|
||||
case RMAP_COMPILE_ERROR:
|
||||
if (vty)
|
||||
vty_out(vty,
|
||||
"%% [%s] Argument form is unsupported or malformed.\n",
|
||||
frr_protonameinst);
|
||||
else
|
||||
zlog_warn("Argument form is unsupported or malformed: %s %s", command, arg);
|
||||
snprintf(errmsg, errmsg_len,
|
||||
"%% [%s] Argument form is unsupported or malformed.",
|
||||
frr_protonameinst);
|
||||
return CMD_WARNING_CONFIG_FAILED;
|
||||
case RMAP_COMPILE_SUCCESS:
|
||||
break;
|
||||
@ -466,26 +476,22 @@ int generic_set_add(struct vty *vty, struct route_map_index *index,
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
int generic_set_delete(struct vty *vty, struct route_map_index *index,
|
||||
const char *command, const char *arg)
|
||||
int generic_set_delete(struct route_map_index *index,
|
||||
const char *command, const char *arg,
|
||||
char *errmsg, size_t errmsg_len)
|
||||
{
|
||||
enum rmap_compile_rets ret;
|
||||
|
||||
ret = route_map_delete_set(index, command, arg);
|
||||
switch (ret) {
|
||||
case RMAP_RULE_MISSING:
|
||||
if (vty)
|
||||
vty_out(vty, "%% [%s] Can't find rule.\n", frr_protonameinst);
|
||||
else
|
||||
zlog_warn("Can't find rule: %s", command);
|
||||
snprintf(errmsg, errmsg_len, "%% [%s] Can't find rule.",
|
||||
frr_protonameinst);
|
||||
return CMD_WARNING_CONFIG_FAILED;
|
||||
case RMAP_COMPILE_ERROR:
|
||||
if (vty)
|
||||
vty_out(vty,
|
||||
"%% [%s] Argument form is unsupported or malformed.\n",
|
||||
frr_protonameinst);
|
||||
else
|
||||
zlog_warn("Argument form is unsupported or malformed: %s %s", command, arg);
|
||||
snprintf(errmsg, errmsg_len,
|
||||
"%% [%s] Argument form is unsupported or malformed.",
|
||||
frr_protonameinst);
|
||||
return CMD_WARNING_CONFIG_FAILED;
|
||||
case RMAP_COMPILE_SUCCESS:
|
||||
break;
|
||||
@ -2627,47 +2633,6 @@ static unsigned int route_map_dep_data_hash_make_key(const void *p)
|
||||
return string_hash_make(dep_data->rname);
|
||||
}
|
||||
|
||||
DEFUN (set_srte_color,
|
||||
set_srte_color_cmd,
|
||||
"set sr-te color [(1-4294967295)]",
|
||||
SET_STR
|
||||
SRTE_STR
|
||||
SRTE_COLOR_STR
|
||||
"Color of the SR-TE Policies to match with\n")
|
||||
{
|
||||
VTY_DECLVAR_CONTEXT(route_map_index, index);
|
||||
int idx = 0;
|
||||
char *arg = argv_find(argv, argc, "(1-4294967295)", &idx)
|
||||
? argv[idx]->arg
|
||||
: NULL;
|
||||
|
||||
if (rmap_match_set_hook.set_srte_color)
|
||||
return rmap_match_set_hook.set_srte_color(vty, index,
|
||||
"sr-te color", arg);
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
DEFUN (no_set_srte_color,
|
||||
no_set_srte_color_cmd,
|
||||
"no set sr-te color [(1-4294967295)]",
|
||||
NO_STR
|
||||
SET_STR
|
||||
SRTE_STR
|
||||
SRTE_COLOR_STR
|
||||
"Color of the SR-TE Policies to match with\n")
|
||||
{
|
||||
VTY_DECLVAR_CONTEXT(route_map_index, index);
|
||||
int idx = 0;
|
||||
char *arg = argv_find(argv, argc, "(1-4294967295)", &idx)
|
||||
? argv[idx]->arg
|
||||
: NULL;
|
||||
|
||||
if (rmap_match_set_hook.no_set_srte_color)
|
||||
return rmap_match_set_hook.no_set_srte_color(
|
||||
vty, index, "sr-te color", arg);
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
static void *route_map_dep_hash_alloc(void *p)
|
||||
{
|
||||
char *dep_name = (char *)p;
|
||||
@ -3279,8 +3244,5 @@ void route_map_init(void)
|
||||
install_element(RMAP_NODE, &routemap_optimization_cmd);
|
||||
install_element(RMAP_NODE, &no_routemap_optimization_cmd);
|
||||
|
||||
install_element(RMAP_NODE, &set_srte_color_cmd);
|
||||
install_element(RMAP_NODE, &no_set_srte_color_cmd);
|
||||
|
||||
install_element(ENABLE_NODE, &show_route_map_pfx_tbl_cmd);
|
||||
}
|
||||
|
529
lib/routemap.h
529
lib/routemap.h
@ -229,6 +229,144 @@ struct route_map {
|
||||
};
|
||||
DECLARE_QOBJ_TYPE(route_map);
|
||||
|
||||
/* Route-map match conditions */
|
||||
#define IS_MATCH_INTERFACE(C) \
|
||||
(strmatch(C, "frr-route-map:interface"))
|
||||
#define IS_MATCH_IPv4_ADDRESS_LIST(C) \
|
||||
(strmatch(C, "frr-route-map:ipv4-address-list"))
|
||||
#define IS_MATCH_IPv6_ADDRESS_LIST(C) \
|
||||
(strmatch(C, "frr-route-map:ipv6-address-list"))
|
||||
#define IS_MATCH_IPv4_NEXTHOP_LIST(C) \
|
||||
(strmatch(C, "frr-route-map:ipv4-next-hop-list"))
|
||||
#define IS_MATCH_IPv4_PREFIX_LIST(C) \
|
||||
(strmatch(C, "frr-route-map:ipv4-prefix-list"))
|
||||
#define IS_MATCH_IPv6_PREFIX_LIST(C) \
|
||||
(strmatch(C, "frr-route-map:ipv6-prefix-list"))
|
||||
#define IS_MATCH_IPv4_NEXTHOP_PREFIX_LIST(C) \
|
||||
(strmatch(C, "frr-route-map:ipv4-next-hop-prefix-list"))
|
||||
#define IS_MATCH_IPv4_NEXTHOP_TYPE(C) \
|
||||
(strmatch(C, "frr-route-map:ipv4-next-hop-type"))
|
||||
#define IS_MATCH_IPv6_NEXTHOP_TYPE(C) \
|
||||
(strmatch(C, "frr-route-map:ipv6-next-hop-type"))
|
||||
#define IS_MATCH_METRIC(C) \
|
||||
(strmatch(C, "frr-route-map:match-metric"))
|
||||
#define IS_MATCH_TAG(C) (strmatch(C, "frr-route-map:match-tag"))
|
||||
/* Zebra route-map match conditions */
|
||||
#define IS_MATCH_IPv4_PREFIX_LEN(C) \
|
||||
(strmatch(C, "frr-zebra-route-map:ipv4-prefix-length"))
|
||||
#define IS_MATCH_IPv6_PREFIX_LEN(C) \
|
||||
(strmatch(C, "frr-zebra-route-map:ipv6-prefix-length"))
|
||||
#define IS_MATCH_IPv4_NH_PREFIX_LEN(C) \
|
||||
(strmatch(C, "frr-zebra-route-map:ipv4-next-hop-prefix-length"))
|
||||
#define IS_MATCH_SRC_PROTO(C) \
|
||||
(strmatch(C, "frr-zebra-route-map:source-protocol"))
|
||||
#define IS_MATCH_SRC_INSTANCE(C) \
|
||||
(strmatch(C, "frr-zebra-route-map:source-instance"))
|
||||
/* BGP route-map match conditions */
|
||||
#define IS_MATCH_LOCAL_PREF(C) \
|
||||
(strmatch(C, "frr-bgp-route-map:match-local-preference"))
|
||||
#define IS_MATCH_ORIGIN(C) \
|
||||
(strmatch(C, "frr-bgp-route-map:match-origin"))
|
||||
#define IS_MATCH_RPKI(C) (strmatch(C, "frr-bgp-route-map:rpki"))
|
||||
#define IS_MATCH_PROBABILITY(C) \
|
||||
(strmatch(C, "frr-bgp-route-map:probability"))
|
||||
#define IS_MATCH_SRC_VRF(C) \
|
||||
(strmatch(C, "frr-bgp-route-map:source-vrf"))
|
||||
#define IS_MATCH_PEER(C) (strmatch(C, "frr-bgp-route-map:peer"))
|
||||
#define IS_MATCH_AS_LIST(C) \
|
||||
(strmatch(C, "frr-bgp-route-map:as-path-list"))
|
||||
#define IS_MATCH_MAC_LIST(C) \
|
||||
(strmatch(C, "frr-bgp-route-map:mac-address-list"))
|
||||
#define IS_MATCH_EVPN_ROUTE_TYPE(C) \
|
||||
(strmatch(C, "frr-bgp-route-map:evpn-route-type"))
|
||||
#define IS_MATCH_EVPN_DEFAULT_ROUTE(C) \
|
||||
(strmatch(C, "frr-bgp-route-map:evpn-default-route"))
|
||||
#define IS_MATCH_EVPN_VNI(C) \
|
||||
(strmatch(C, "frr-bgp-route-map:evpn-vni"))
|
||||
#define IS_MATCH_EVPN_DEFAULT_ROUTE(C) \
|
||||
(strmatch(C, "frr-bgp-route-map:evpn-default-route"))
|
||||
#define IS_MATCH_EVPN_RD(C) \
|
||||
(strmatch(C, "frr-bgp-route-map:evpn-rd"))
|
||||
#define IS_MATCH_ROUTE_SRC(C) \
|
||||
(strmatch(C, "frr-bgp-route-map:ip-route-source"))
|
||||
#define IS_MATCH_ROUTE_SRC_PL(C) \
|
||||
(strmatch(C, "frr-bgp-route-map:ip-route-source-prefix-list"))
|
||||
#define IS_MATCH_COMMUNITY(C) \
|
||||
(strmatch(C, "frr-bgp-route-map:match-community"))
|
||||
#define IS_MATCH_LCOMMUNITY(C) \
|
||||
(strmatch(C, "frr-bgp-route-map:match-large-community"))
|
||||
#define IS_MATCH_EXTCOMMUNITY(C) \
|
||||
(strmatch(C, "frr-bgp-route-map:match-extcommunity"))
|
||||
#define IS_MATCH_IPV4_NH(C) \
|
||||
(strmatch(C, "frr-bgp-route-map:ipv4-nexthop"))
|
||||
#define IS_MATCH_IPV6_NH(C) \
|
||||
(strmatch(C, "frr-bgp-route-map:ipv6-nexthop"))
|
||||
|
||||
/* Route-map set actions */
|
||||
#define IS_SET_IPv4_NH(A) \
|
||||
(strmatch(A, "frr-route-map:ipv4-next-hop"))
|
||||
#define IS_SET_IPv6_NH(A) \
|
||||
(strmatch(A, "frr-route-map:ipv6-next-hop"))
|
||||
#define IS_SET_METRIC(A) \
|
||||
(strmatch(A, "frr-route-map:set-metric"))
|
||||
#define IS_SET_TAG(A) (strmatch(A, "frr-route-map:set-tag"))
|
||||
#define IS_SET_SR_TE_COLOR(A) \
|
||||
(strmatch(A, "frr-route-map:set-sr-te-color"))
|
||||
/* Zebra route-map set actions */
|
||||
#define IS_SET_SRC(A) \
|
||||
(strmatch(A, "frr-zebra-route-map:src-address"))
|
||||
/* OSPF route-map set actions */
|
||||
#define IS_SET_METRIC_TYPE(A) \
|
||||
(strmatch(A, "frr-ospf-route-map:metric-type"))
|
||||
#define IS_SET_FORWARDING_ADDR(A) \
|
||||
(strmatch(A, "frr-ospf6-route-map:forwarding-address"))
|
||||
/* BGP route-map_set actions */
|
||||
#define IS_SET_WEIGHT(A) \
|
||||
(strmatch(A, "frr-bgp-route-map:weight"))
|
||||
#define IS_SET_TABLE(A) (strmatch(A, "frr-bgp-route-map:table"))
|
||||
#define IS_SET_LOCAL_PREF(A) \
|
||||
(strmatch(A, "frr-bgp-route-map:set-local-preference"))
|
||||
#define IS_SET_LABEL_INDEX(A) \
|
||||
(strmatch(A, "frr-bgp-route-map:label-index"))
|
||||
#define IS_SET_DISTANCE(A) \
|
||||
(strmatch(A, "frr-bgp-route-map:distance"))
|
||||
#define IS_SET_ORIGIN(A) \
|
||||
(strmatch(A, "frr-bgp-route-map:set-origin"))
|
||||
#define IS_SET_ATOMIC_AGGREGATE(A) \
|
||||
(strmatch(A, "frr-bgp-route-map:atomic-aggregate"))
|
||||
#define IS_SET_ORIGINATOR_ID(A) \
|
||||
(strmatch(A, "frr-bgp-route-map:originator-id"))
|
||||
#define IS_SET_COMM_LIST_DEL(A) \
|
||||
(strmatch(A, "frr-bgp-route-map:comm-list-delete"))
|
||||
#define IS_SET_LCOMM_LIST_DEL(A) \
|
||||
(strmatch(A, "frr-bgp-route-map:large-comm-list-delete"))
|
||||
#define IS_SET_LCOMMUNITY(A) \
|
||||
(strmatch(A, "frr-bgp-route-map:set-large-community"))
|
||||
#define IS_SET_COMMUNITY(A) \
|
||||
(strmatch(A, "frr-bgp-route-map:set-community"))
|
||||
#define IS_SET_EXTCOMMUNITY_RT(A) \
|
||||
(strmatch(A, "frr-bgp-route-map:set-extcommunity-rt"))
|
||||
#define IS_SET_EXTCOMMUNITY_SOO(A) \
|
||||
(strmatch(A, "frr-bgp-route-map:set-extcommunity-soo"))
|
||||
#define IS_SET_AGGREGATOR(A) \
|
||||
(strmatch(A, "frr-bgp-route-map:aggregator"))
|
||||
#define IS_SET_AS_PREPEND(A) \
|
||||
(strmatch(A, "frr-bgp-route-map:as-path-prepend"))
|
||||
#define IS_SET_AS_EXCLUDE(A) \
|
||||
(strmatch(A, "frr-bgp-route-map:as-path-exclude"))
|
||||
#define IS_SET_IPV6_NH_GLOBAL(A) \
|
||||
(strmatch(A, "frr-bgp-route-map:ipv6-nexthop-global"))
|
||||
#define IS_SET_IPV6_VPN_NH(A) \
|
||||
(strmatch(A, "frr-bgp-route-map:ipv6-vpn-address"))
|
||||
#define IS_SET_IPV6_PEER_ADDR(A) \
|
||||
(strmatch(A, "frr-bgp-route-map:ipv6-peer-address"))
|
||||
#define IS_SET_IPV6_PREFER_GLOBAL(A) \
|
||||
(strmatch(A, "frr-bgp-route-map:ipv6-prefer-global"))
|
||||
#define IS_SET_IPV4_VPN_NH(A) \
|
||||
(strmatch(A, "frr-bgp-route-map:ipv4-vpn-address"))
|
||||
#define IS_SET_BGP_IPV4_NH(A) \
|
||||
(strmatch(A, "frr-bgp-route-map:set-ipv4-nexthop"))
|
||||
|
||||
/* Prototypes. */
|
||||
extern void route_map_init(void);
|
||||
|
||||
@ -310,150 +448,186 @@ extern void
|
||||
route_map_notify_pentry_dependencies(const char *affected_name,
|
||||
struct prefix_list_entry *pentry,
|
||||
route_map_event_t event);
|
||||
extern int generic_match_add(struct vty *vty, struct route_map_index *index,
|
||||
extern int generic_match_add(struct route_map_index *index,
|
||||
const char *command, const char *arg,
|
||||
route_map_event_t type);
|
||||
|
||||
extern int generic_match_delete(struct vty *vty, struct route_map_index *index,
|
||||
route_map_event_t type,
|
||||
char *errmsg, size_t errmsg_len);
|
||||
extern int generic_match_delete(struct route_map_index *index,
|
||||
const char *command, const char *arg,
|
||||
route_map_event_t type);
|
||||
extern int generic_set_add(struct vty *vty, struct route_map_index *index,
|
||||
const char *command, const char *arg);
|
||||
extern int generic_set_delete(struct vty *vty, struct route_map_index *index,
|
||||
const char *command, const char *arg);
|
||||
route_map_event_t type,
|
||||
char *errmsg, size_t errmsg_len);
|
||||
|
||||
extern int generic_set_add(struct route_map_index *index,
|
||||
const char *command, const char *arg,
|
||||
char *errmsg, size_t errmsg_len);
|
||||
extern int generic_set_delete(struct route_map_index *index,
|
||||
const char *command, const char *arg,
|
||||
char *errmsg, size_t errmsg_len);
|
||||
|
||||
|
||||
/* match interface */
|
||||
extern void route_map_match_interface_hook(int (*func)(
|
||||
struct vty *vty, struct route_map_index *index, const char *command,
|
||||
const char *arg, route_map_event_t type));
|
||||
struct route_map_index *index, const char *command,
|
||||
const char *arg, route_map_event_t type,
|
||||
char *errmsg, size_t errmsg_len));
|
||||
/* no match interface */
|
||||
extern void route_map_no_match_interface_hook(int (*func)(
|
||||
struct vty *vty, struct route_map_index *index, const char *command,
|
||||
const char *arg, route_map_event_t type));
|
||||
struct route_map_index *index, const char *command,
|
||||
const char *arg, route_map_event_t type,
|
||||
char *errmsg, size_t errmsg_len));
|
||||
/* match ip address */
|
||||
extern void route_map_match_ip_address_hook(int (*func)(
|
||||
struct vty *vty, struct route_map_index *index, const char *command,
|
||||
const char *arg, route_map_event_t type));
|
||||
struct route_map_index *index, const char *command,
|
||||
const char *arg, route_map_event_t type,
|
||||
char *errmsg, size_t errmsg_len));
|
||||
/* no match ip address */
|
||||
extern void route_map_no_match_ip_address_hook(int (*func)(
|
||||
struct vty *vty, struct route_map_index *index, const char *command,
|
||||
const char *arg, route_map_event_t type));
|
||||
struct route_map_index *index, const char *command,
|
||||
const char *arg, route_map_event_t type,
|
||||
char *errmsg, size_t errmsg_len));
|
||||
/* match ip address prefix list */
|
||||
extern void route_map_match_ip_address_prefix_list_hook(int (*func)(
|
||||
struct vty *vty, struct route_map_index *index, const char *command,
|
||||
const char *arg, route_map_event_t type));
|
||||
struct route_map_index *index, const char *command,
|
||||
const char *arg, route_map_event_t type,
|
||||
char *errmsg, size_t errmsg_len));
|
||||
/* no match ip address prefix list */
|
||||
extern void route_map_no_match_ip_address_prefix_list_hook(int (*func)(
|
||||
struct vty *vty, struct route_map_index *index, const char *command,
|
||||
const char *arg, route_map_event_t type));
|
||||
struct route_map_index *index, const char *command,
|
||||
const char *arg, route_map_event_t type,
|
||||
char *errmsg, size_t errmsg_len));
|
||||
/* match ip next hop */
|
||||
extern void route_map_match_ip_next_hop_hook(int (*func)(
|
||||
struct vty *vty, struct route_map_index *index, const char *command,
|
||||
const char *arg, route_map_event_t type));
|
||||
struct route_map_index *index, const char *command,
|
||||
const char *arg, route_map_event_t type,
|
||||
char *errmsg, size_t errmsg_len));
|
||||
/* no match ip next hop */
|
||||
extern void route_map_no_match_ip_next_hop_hook(int (*func)(
|
||||
struct vty *vty, struct route_map_index *index, const char *command,
|
||||
const char *arg, route_map_event_t type));
|
||||
struct route_map_index *index, const char *command,
|
||||
const char *arg, route_map_event_t type,
|
||||
char *errmsg, size_t errmsg_len));
|
||||
/* match ip next hop prefix list */
|
||||
extern void route_map_match_ip_next_hop_prefix_list_hook(int (*func)(
|
||||
struct vty *vty, struct route_map_index *index, const char *command,
|
||||
const char *arg, route_map_event_t type));
|
||||
struct route_map_index *index, const char *command,
|
||||
const char *arg, route_map_event_t type,
|
||||
char *errmsg, size_t errmsg_len));
|
||||
/* no match ip next hop prefix list */
|
||||
extern void route_map_no_match_ip_next_hop_prefix_list_hook(int (*func)(
|
||||
struct vty *vty, struct route_map_index *index, const char *command,
|
||||
const char *arg, route_map_event_t type));
|
||||
struct route_map_index *index, const char *command,
|
||||
const char *arg, route_map_event_t type,
|
||||
char *errmsg, size_t errmsg_len));
|
||||
/* match ip next hop type */
|
||||
extern void route_map_match_ip_next_hop_type_hook(int (*func)(
|
||||
struct vty *vty, struct route_map_index *index, const char *command,
|
||||
const char *arg, route_map_event_t type));
|
||||
struct route_map_index *index, const char *command,
|
||||
const char *arg, route_map_event_t type,
|
||||
char *errmsg, size_t errmsg_len));
|
||||
/* no match ip next hop type */
|
||||
extern void route_map_no_match_ip_next_hop_type_hook(int (*func)(
|
||||
struct vty *vty, struct route_map_index *index, const char *command,
|
||||
const char *arg, route_map_event_t type));
|
||||
struct route_map_index *index, const char *command,
|
||||
const char *arg, route_map_event_t type,
|
||||
char *errmsg, size_t errmsg_len));
|
||||
/* match ipv6 address */
|
||||
extern void route_map_match_ipv6_address_hook(int (*func)(
|
||||
struct vty *vty, struct route_map_index *index, const char *command,
|
||||
const char *arg, route_map_event_t type));
|
||||
struct route_map_index *index, const char *command,
|
||||
const char *arg, route_map_event_t type,
|
||||
char *errmsg, size_t errmsg_len));
|
||||
/* no match ipv6 address */
|
||||
extern void route_map_no_match_ipv6_address_hook(int (*func)(
|
||||
struct vty *vty, struct route_map_index *index, const char *command,
|
||||
const char *arg, route_map_event_t type));
|
||||
struct route_map_index *index, const char *command,
|
||||
const char *arg, route_map_event_t type,
|
||||
char *errmsg, size_t errmsg_len));
|
||||
/* match ipv6 address prefix list */
|
||||
extern void route_map_match_ipv6_address_prefix_list_hook(int (*func)(
|
||||
struct vty *vty, struct route_map_index *index, const char *command,
|
||||
const char *arg, route_map_event_t type));
|
||||
struct route_map_index *index, const char *command,
|
||||
const char *arg, route_map_event_t type,
|
||||
char *errmsg, size_t errmsg_len));
|
||||
/* no match ipv6 address prefix list */
|
||||
extern void route_map_no_match_ipv6_address_prefix_list_hook(int (*func)(
|
||||
struct vty *vty, struct route_map_index *index, const char *command,
|
||||
const char *arg, route_map_event_t type));
|
||||
struct route_map_index *index, const char *command,
|
||||
const char *arg, route_map_event_t type,
|
||||
char *errmsg, size_t errmsg_len));
|
||||
/* match ipv6 next-hop type */
|
||||
extern void route_map_match_ipv6_next_hop_type_hook(int (*func)(
|
||||
struct vty *vty, struct route_map_index *index, const char *command,
|
||||
const char *arg, route_map_event_t type));
|
||||
struct route_map_index *index, const char *command,
|
||||
const char *arg, route_map_event_t type,
|
||||
char *errmsg, size_t errmsg_len));
|
||||
/* no match ipv6 next-hop type */
|
||||
extern void route_map_no_match_ipv6_next_hop_type_hook(int (*func)(
|
||||
struct vty *vty, struct route_map_index *index, const char *command,
|
||||
const char *arg, route_map_event_t type));
|
||||
struct route_map_index *index, const char *command,
|
||||
const char *arg, route_map_event_t type,
|
||||
char *errmsg, size_t errmsg_len));
|
||||
/* match metric */
|
||||
extern void route_map_match_metric_hook(int (*func)(
|
||||
struct vty *vty, struct route_map_index *index, const char *command,
|
||||
const char *arg, route_map_event_t type));
|
||||
struct route_map_index *index, const char *command,
|
||||
const char *arg, route_map_event_t type,
|
||||
char *errmsg, size_t errmsg_len));
|
||||
/* no match metric */
|
||||
extern void route_map_no_match_metric_hook(int (*func)(
|
||||
struct vty *vty, struct route_map_index *index, const char *command,
|
||||
const char *arg, route_map_event_t type));
|
||||
struct route_map_index *index, const char *command,
|
||||
const char *arg, route_map_event_t type,
|
||||
char *errmsg, size_t errmsg_len));
|
||||
/* match tag */
|
||||
extern void route_map_match_tag_hook(int (*func)(
|
||||
struct vty *vty, struct route_map_index *index, const char *command,
|
||||
const char *arg, route_map_event_t type));
|
||||
struct route_map_index *index, const char *command,
|
||||
const char *arg, route_map_event_t type,
|
||||
char *errmsg, size_t errmsg_len));
|
||||
/* no match tag */
|
||||
extern void route_map_no_match_tag_hook(int (*func)(
|
||||
struct vty *vty, struct route_map_index *index, const char *command,
|
||||
const char *arg, route_map_event_t type));
|
||||
struct route_map_index *index, const char *command,
|
||||
const char *arg, route_map_event_t type,
|
||||
char *errmsg, size_t errmsg_len));
|
||||
/* set sr-te color */
|
||||
extern void route_map_set_srte_color_hook(
|
||||
int (*func)(struct vty *vty, struct route_map_index *index,
|
||||
const char *command, const char *arg));
|
||||
int (*func)(struct route_map_index *index,
|
||||
const char *command, const char *arg,
|
||||
char *errmsg, size_t errmsg_len));
|
||||
/* no set sr-te color */
|
||||
extern void route_map_no_set_srte_color_hook(
|
||||
int (*func)(struct vty *vty, struct route_map_index *index,
|
||||
const char *command, const char *arg));
|
||||
int (*func)(struct route_map_index *index,
|
||||
const char *command, const char *arg,
|
||||
char *errmsg, size_t errmsg_len));
|
||||
/* set ip nexthop */
|
||||
extern void route_map_set_ip_nexthop_hook(
|
||||
int (*func)(struct vty *vty, struct route_map_index *index,
|
||||
const char *command, const char *arg));
|
||||
int (*func)(struct route_map_index *index,
|
||||
const char *command, const char *arg,
|
||||
char *errmsg, size_t errmsg_len));
|
||||
/* no set ip nexthop */
|
||||
extern void route_map_no_set_ip_nexthop_hook(
|
||||
int (*func)(struct vty *vty, struct route_map_index *index,
|
||||
const char *command, const char *arg));
|
||||
int (*func)(struct route_map_index *index,
|
||||
const char *command, const char *arg,
|
||||
char *errmsg, size_t errmsg_len));
|
||||
/* set ipv6 nexthop local */
|
||||
extern void route_map_set_ipv6_nexthop_local_hook(
|
||||
int (*func)(struct vty *vty, struct route_map_index *index,
|
||||
const char *command, const char *arg));
|
||||
int (*func)(struct route_map_index *index,
|
||||
const char *command, const char *arg,
|
||||
char *errmsg, size_t errmsg_len));
|
||||
/* no set ipv6 nexthop local */
|
||||
extern void route_map_no_set_ipv6_nexthop_local_hook(
|
||||
int (*func)(struct vty *vty, struct route_map_index *index,
|
||||
const char *command, const char *arg));
|
||||
int (*func)(struct route_map_index *index,
|
||||
const char *command, const char *arg,
|
||||
char *errmsg, size_t errmsg_len));
|
||||
/* set metric */
|
||||
extern void route_map_set_metric_hook(int (*func)(struct vty *vty,
|
||||
struct route_map_index *index,
|
||||
extern void route_map_set_metric_hook(int (*func)(struct route_map_index *index,
|
||||
const char *command,
|
||||
const char *arg));
|
||||
const char *arg,
|
||||
char *errmsg,
|
||||
size_t errmsg_len));
|
||||
/* no set metric */
|
||||
extern void route_map_no_set_metric_hook(
|
||||
int (*func)(struct vty *vty, struct route_map_index *index,
|
||||
const char *command, const char *arg));
|
||||
int (*func)(struct route_map_index *index,
|
||||
const char *command, const char *arg,
|
||||
char *errmsg, size_t errmsg_len));
|
||||
/* set tag */
|
||||
extern void route_map_set_tag_hook(int (*func)(struct vty *vty,
|
||||
struct route_map_index *index,
|
||||
extern void route_map_set_tag_hook(int (*func)(struct route_map_index *index,
|
||||
const char *command,
|
||||
const char *arg));
|
||||
const char *arg,
|
||||
char *errmsg,
|
||||
size_t errmsg_len));
|
||||
/* no set tag */
|
||||
extern void route_map_no_set_tag_hook(int (*func)(struct vty *vty,
|
||||
struct route_map_index *index,
|
||||
extern void route_map_no_set_tag_hook(int (*func)(struct route_map_index *index,
|
||||
const char *command,
|
||||
const char *arg));
|
||||
const char *arg,
|
||||
char *errmsg,
|
||||
size_t errmsg_len));
|
||||
|
||||
extern void *route_map_rule_tag_compile(const char *arg);
|
||||
extern void route_map_rule_tag_free(void *rule);
|
||||
@ -467,181 +641,200 @@ extern void route_map_counter_decrement(struct route_map *map);
|
||||
/* Route map hooks data structure. */
|
||||
struct route_map_match_set_hooks {
|
||||
/* match interface */
|
||||
int (*match_interface)(struct vty *vty, struct route_map_index *index,
|
||||
int (*match_interface)(struct route_map_index *index,
|
||||
const char *command, const char *arg,
|
||||
route_map_event_t type);
|
||||
route_map_event_t type,
|
||||
char *errmsg, size_t errmsg_len);
|
||||
|
||||
/* no match interface */
|
||||
int (*no_match_interface)(struct vty *vty,
|
||||
struct route_map_index *index,
|
||||
int (*no_match_interface)(struct route_map_index *index,
|
||||
const char *command, const char *arg,
|
||||
route_map_event_t type);
|
||||
route_map_event_t type,
|
||||
char *errmsg, size_t errmsg_len);
|
||||
|
||||
/* match ip address */
|
||||
int (*match_ip_address)(struct vty *vty, struct route_map_index *index,
|
||||
int (*match_ip_address)(struct route_map_index *index,
|
||||
const char *command, const char *arg,
|
||||
route_map_event_t type);
|
||||
route_map_event_t type,
|
||||
char *errmsg, size_t errmsg_len);
|
||||
|
||||
/* no match ip address */
|
||||
int (*no_match_ip_address)(struct vty *vty,
|
||||
struct route_map_index *index,
|
||||
int (*no_match_ip_address)(struct route_map_index *index,
|
||||
const char *command, const char *arg,
|
||||
route_map_event_t type);
|
||||
route_map_event_t type,
|
||||
char *errmsg, size_t errmsg_len);
|
||||
|
||||
/* match ip address prefix list */
|
||||
int (*match_ip_address_prefix_list)(struct vty *vty,
|
||||
struct route_map_index *index,
|
||||
int (*match_ip_address_prefix_list)(struct route_map_index *index,
|
||||
const char *command,
|
||||
const char *arg,
|
||||
route_map_event_t type);
|
||||
route_map_event_t type,
|
||||
char *errmsg, size_t errmsg_len);
|
||||
|
||||
/* no match ip address prefix list */
|
||||
int (*no_match_ip_address_prefix_list)(struct vty *vty,
|
||||
struct route_map_index *index,
|
||||
int (*no_match_ip_address_prefix_list)(struct route_map_index *index,
|
||||
const char *command,
|
||||
const char *arg,
|
||||
route_map_event_t type);
|
||||
route_map_event_t type,
|
||||
char *errmsg, size_t errmsg_len);
|
||||
|
||||
/* match ip next hop */
|
||||
int (*match_ip_next_hop)(struct vty *vty, struct route_map_index *index,
|
||||
int (*match_ip_next_hop)(struct route_map_index *index,
|
||||
const char *command, const char *arg,
|
||||
route_map_event_t type);
|
||||
route_map_event_t type,
|
||||
char *errmsg, size_t errmsg_len);
|
||||
|
||||
/* no match ip next hop */
|
||||
int (*no_match_ip_next_hop)(struct vty *vty,
|
||||
struct route_map_index *index,
|
||||
int (*no_match_ip_next_hop)(struct route_map_index *index,
|
||||
const char *command, const char *arg,
|
||||
route_map_event_t type);
|
||||
route_map_event_t type,
|
||||
char *errmsg, size_t errmsg_len);
|
||||
|
||||
/* match ip next hop prefix list */
|
||||
int (*match_ip_next_hop_prefix_list)(struct vty *vty,
|
||||
struct route_map_index *index,
|
||||
int (*match_ip_next_hop_prefix_list)(struct route_map_index *index,
|
||||
const char *command,
|
||||
const char *arg,
|
||||
route_map_event_t type);
|
||||
route_map_event_t type,
|
||||
char *errmsg, size_t errmsg_len);
|
||||
|
||||
/* no match ip next hop prefix list */
|
||||
int (*no_match_ip_next_hop_prefix_list)(struct vty *vty,
|
||||
struct route_map_index *index,
|
||||
int (*no_match_ip_next_hop_prefix_list)(struct route_map_index *index,
|
||||
const char *command,
|
||||
const char *arg,
|
||||
route_map_event_t type);
|
||||
route_map_event_t type,
|
||||
char *errmsg,
|
||||
size_t errmsg_len);
|
||||
|
||||
/* match ip next-hop type */
|
||||
int (*match_ip_next_hop_type)(struct vty *vty,
|
||||
struct route_map_index *index,
|
||||
const char *command,
|
||||
const char *arg,
|
||||
route_map_event_t type);
|
||||
int (*match_ip_next_hop_type)(struct route_map_index *index,
|
||||
const char *command,
|
||||
const char *arg,
|
||||
route_map_event_t type,
|
||||
char *errmsg,
|
||||
size_t errmsg_len);
|
||||
|
||||
/* no match ip next-hop type */
|
||||
int (*no_match_ip_next_hop_type)(struct vty *vty,
|
||||
struct route_map_index *index,
|
||||
const char *command,
|
||||
const char *arg,
|
||||
route_map_event_t type);
|
||||
int (*no_match_ip_next_hop_type)(struct route_map_index *index,
|
||||
const char *command,
|
||||
const char *arg,
|
||||
route_map_event_t type,
|
||||
char *errmsg,
|
||||
size_t errmsg_len);
|
||||
|
||||
/* match ipv6 address */
|
||||
int (*match_ipv6_address)(struct vty *vty,
|
||||
struct route_map_index *index,
|
||||
int (*match_ipv6_address)(struct route_map_index *index,
|
||||
const char *command, const char *arg,
|
||||
route_map_event_t type);
|
||||
route_map_event_t type,
|
||||
char *errmsg, size_t errmsg_len);
|
||||
|
||||
/* no match ipv6 address */
|
||||
int (*no_match_ipv6_address)(struct vty *vty,
|
||||
struct route_map_index *index,
|
||||
int (*no_match_ipv6_address)(struct route_map_index *index,
|
||||
const char *command, const char *arg,
|
||||
route_map_event_t type);
|
||||
route_map_event_t type,
|
||||
char *errmsg, size_t errmsg_len);
|
||||
|
||||
|
||||
/* match ipv6 address prefix list */
|
||||
int (*match_ipv6_address_prefix_list)(struct vty *vty,
|
||||
struct route_map_index *index,
|
||||
int (*match_ipv6_address_prefix_list)(struct route_map_index *index,
|
||||
const char *command,
|
||||
const char *arg,
|
||||
route_map_event_t type);
|
||||
route_map_event_t type,
|
||||
char *errmsg, size_t errmsg_len);
|
||||
|
||||
/* no match ipv6 address prefix list */
|
||||
int (*no_match_ipv6_address_prefix_list)(struct vty *vty,
|
||||
struct route_map_index *index,
|
||||
int (*no_match_ipv6_address_prefix_list)(struct route_map_index *index,
|
||||
const char *command,
|
||||
const char *arg,
|
||||
route_map_event_t type);
|
||||
route_map_event_t type,
|
||||
char *errmsg,
|
||||
size_t errmsg_len);
|
||||
|
||||
/* match ipv6 next-hop type */
|
||||
int (*match_ipv6_next_hop_type)(struct vty *vty,
|
||||
struct route_map_index *index,
|
||||
int (*match_ipv6_next_hop_type)(struct route_map_index *index,
|
||||
const char *command,
|
||||
const char *arg,
|
||||
route_map_event_t type);
|
||||
route_map_event_t type,
|
||||
char *errmsg, size_t errmsg_len);
|
||||
|
||||
/* no match ipv6 next-hop type */
|
||||
int (*no_match_ipv6_next_hop_type)(struct vty *vty,
|
||||
struct route_map_index *index,
|
||||
int (*no_match_ipv6_next_hop_type)(struct route_map_index *index,
|
||||
const char *command, const char *arg,
|
||||
route_map_event_t type);
|
||||
route_map_event_t type,
|
||||
char *errmsg, size_t errmsg_len);
|
||||
|
||||
/* match metric */
|
||||
int (*match_metric)(struct vty *vty, struct route_map_index *index,
|
||||
int (*match_metric)(struct route_map_index *index,
|
||||
const char *command, const char *arg,
|
||||
route_map_event_t type);
|
||||
route_map_event_t type,
|
||||
char *errmsg, size_t errmsg_len);
|
||||
|
||||
/* no match metric */
|
||||
int (*no_match_metric)(struct vty *vty, struct route_map_index *index,
|
||||
int (*no_match_metric)(struct route_map_index *index,
|
||||
const char *command, const char *arg,
|
||||
route_map_event_t type);
|
||||
route_map_event_t type,
|
||||
char *errmsg, size_t errmsg_len);
|
||||
|
||||
/* match tag */
|
||||
int (*match_tag)(struct vty *vty, struct route_map_index *index,
|
||||
int (*match_tag)(struct route_map_index *index,
|
||||
const char *command, const char *arg,
|
||||
route_map_event_t type);
|
||||
route_map_event_t type,
|
||||
char *errmsg, size_t errmsg_len);
|
||||
|
||||
/* no match tag */
|
||||
int (*no_match_tag)(struct vty *vty, struct route_map_index *index,
|
||||
int (*no_match_tag)(struct route_map_index *index,
|
||||
const char *command, const char *arg,
|
||||
route_map_event_t type);
|
||||
route_map_event_t type,
|
||||
char *errmsg, size_t errmsg_len);
|
||||
|
||||
/* set sr-te color */
|
||||
int (*set_srte_color)(struct vty *vty, struct route_map_index *index,
|
||||
const char *command, const char *arg);
|
||||
int (*set_srte_color)(struct route_map_index *index,
|
||||
const char *command, const char *arg,
|
||||
char *errmsg, size_t errmsg_len);
|
||||
|
||||
/* no set sr-te color */
|
||||
int (*no_set_srte_color)(struct vty *vty, struct route_map_index *index,
|
||||
const char *command, const char *arg);
|
||||
int (*no_set_srte_color)(struct route_map_index *index,
|
||||
const char *command, const char *arg,
|
||||
char *errmsg, size_t errmsg_len);
|
||||
|
||||
/* set ip nexthop */
|
||||
int (*set_ip_nexthop)(struct vty *vty, struct route_map_index *index,
|
||||
const char *command, const char *arg);
|
||||
int (*set_ip_nexthop)(struct route_map_index *index,
|
||||
const char *command, const char *arg,
|
||||
char *errmsg, size_t errmsg_len);
|
||||
|
||||
/* no set ip nexthop */
|
||||
int (*no_set_ip_nexthop)(struct vty *vty, struct route_map_index *index,
|
||||
const char *command, const char *arg);
|
||||
int (*no_set_ip_nexthop)(struct route_map_index *index,
|
||||
const char *command, const char *arg,
|
||||
char *errmsg, size_t errmsg_len);
|
||||
|
||||
/* set ipv6 nexthop local */
|
||||
int (*set_ipv6_nexthop_local)(struct vty *vty,
|
||||
struct route_map_index *index,
|
||||
const char *command, const char *arg);
|
||||
int (*set_ipv6_nexthop_local)(struct route_map_index *index,
|
||||
const char *command, const char *arg,
|
||||
char *errmsg, size_t errmsg_len);
|
||||
|
||||
/* no set ipv6 nexthop local */
|
||||
int (*no_set_ipv6_nexthop_local)(struct vty *vty,
|
||||
struct route_map_index *index,
|
||||
const char *command, const char *arg);
|
||||
int (*no_set_ipv6_nexthop_local)(struct route_map_index *index,
|
||||
const char *command, const char *arg,
|
||||
char *errmsg, size_t errmsg_len);
|
||||
|
||||
/* set metric */
|
||||
int (*set_metric)(struct vty *vty, struct route_map_index *index,
|
||||
const char *command, const char *arg);
|
||||
int (*set_metric)(struct route_map_index *index,
|
||||
const char *command, const char *arg,
|
||||
char *errmsg, size_t errmsg_len);
|
||||
|
||||
/* no set metric */
|
||||
int (*no_set_metric)(struct vty *vty, struct route_map_index *index,
|
||||
const char *command, const char *arg);
|
||||
int (*no_set_metric)(struct route_map_index *index,
|
||||
const char *command, const char *arg,
|
||||
char *errmsg, size_t errmsg_len);
|
||||
|
||||
/* set tag */
|
||||
int (*set_tag)(struct vty *vty, struct route_map_index *index,
|
||||
const char *command, const char *arg);
|
||||
int (*set_tag)(struct route_map_index *index,
|
||||
const char *command, const char *arg,
|
||||
char *errmsg, size_t errmsg_len);
|
||||
|
||||
/* no set tag */
|
||||
int (*no_set_tag)(struct vty *vty, struct route_map_index *index,
|
||||
const char *command, const char *arg);
|
||||
int (*no_set_tag)(struct route_map_index *index,
|
||||
const char *command, const char *arg,
|
||||
char *errmsg, size_t errmsg_len);
|
||||
};
|
||||
|
||||
extern struct route_map_match_set_hooks rmap_match_set_hook;
|
||||
@ -666,15 +859,13 @@ extern struct route_map_index *route_map_index_get(struct route_map *map,
|
||||
extern void route_map_index_delete(struct route_map_index *index, int notify);
|
||||
|
||||
/* routemap_northbound.c */
|
||||
typedef int (*routemap_match_hook_fun)(struct vty *vty,
|
||||
struct route_map_index *rmi,
|
||||
typedef int (*routemap_match_hook_fun)(struct route_map_index *rmi,
|
||||
const char *command, const char *arg,
|
||||
route_map_event_t event);
|
||||
|
||||
typedef int (*routemap_set_hook_fun)(struct vty *vty,
|
||||
struct route_map_index *rmi,
|
||||
const char *command, const char *arg);
|
||||
|
||||
route_map_event_t event,
|
||||
char *errmsg, size_t errmsg_len);
|
||||
typedef int (*routemap_set_hook_fun)(struct route_map_index *rmi,
|
||||
const char *command, const char *arg,
|
||||
char *errmsg, size_t errmsg_len);
|
||||
struct routemap_hook_context {
|
||||
struct route_map_index *rhc_rmi;
|
||||
const char *rhc_rule;
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -45,8 +45,9 @@ int lib_route_map_entry_match_destroy(struct nb_cb_destroy_args *args)
|
||||
if (rhc->rhc_mhook == NULL)
|
||||
return NB_OK;
|
||||
|
||||
rv = rhc->rhc_mhook(NULL, rhc->rhc_rmi, rhc->rhc_rule, NULL,
|
||||
rhc->rhc_event);
|
||||
rv = rhc->rhc_mhook(rhc->rhc_rmi, rhc->rhc_rule, NULL,
|
||||
rhc->rhc_event,
|
||||
args->errmsg, args->errmsg_len);
|
||||
if (rv != CMD_SUCCESS)
|
||||
return NB_ERR_INCONSISTENCY;
|
||||
|
||||
@ -65,7 +66,8 @@ int lib_route_map_entry_set_destroy(struct nb_cb_destroy_args *args)
|
||||
if (rhc->rhc_shook == NULL)
|
||||
return NB_OK;
|
||||
|
||||
rv = rhc->rhc_shook(NULL, rhc->rhc_rmi, rhc->rhc_rule, NULL);
|
||||
rv = rhc->rhc_shook(rhc->rhc_rmi, rhc->rhc_rule, NULL,
|
||||
args->errmsg, args->errmsg_len);
|
||||
if (rv != CMD_SUCCESS)
|
||||
return NB_ERR_INCONSISTENCY;
|
||||
|
||||
@ -498,9 +500,10 @@ static int lib_route_map_entry_match_condition_interface_modify(
|
||||
rhc->rhc_rule = "interface";
|
||||
rhc->rhc_event = RMAP_EVENT_MATCH_DELETED;
|
||||
|
||||
rv = rmap_match_set_hook.match_interface(NULL, rhc->rhc_rmi,
|
||||
rv = rmap_match_set_hook.match_interface(rhc->rhc_rmi,
|
||||
"interface", ifname,
|
||||
RMAP_EVENT_MATCH_ADDED);
|
||||
RMAP_EVENT_MATCH_ADDED,
|
||||
args->errmsg, args->errmsg_len);
|
||||
if (rv != CMD_SUCCESS) {
|
||||
rhc->rhc_mhook = NULL;
|
||||
return NB_ERR_INCONSISTENCY;
|
||||
@ -523,7 +526,7 @@ static int lib_route_map_entry_match_condition_list_name_modify(
|
||||
{
|
||||
struct routemap_hook_context *rhc;
|
||||
const char *acl;
|
||||
int condition;
|
||||
const char *condition;
|
||||
int rv;
|
||||
|
||||
if (args->event != NB_EV_APPLY)
|
||||
@ -532,19 +535,19 @@ static int lib_route_map_entry_match_condition_list_name_modify(
|
||||
/* Check for hook installation, otherwise we can just stop. */
|
||||
acl = yang_dnode_get_string(args->dnode, NULL);
|
||||
rhc = nb_running_get_entry(args->dnode, NULL, true);
|
||||
condition = yang_dnode_get_enum(args->dnode, "../condition");
|
||||
switch (condition) {
|
||||
case 1: /* ipv4-address-list */
|
||||
condition = yang_dnode_get_string(args->dnode, "../../condition");
|
||||
|
||||
if (IS_MATCH_IPv4_ADDRESS_LIST(condition)) {
|
||||
if (rmap_match_set_hook.match_ip_address == NULL)
|
||||
return NB_OK;
|
||||
rhc->rhc_mhook = rmap_match_set_hook.no_match_ip_address;
|
||||
rhc->rhc_rule = "ip address";
|
||||
rhc->rhc_event = RMAP_EVENT_FILTER_DELETED;
|
||||
rv = rmap_match_set_hook.match_ip_address(
|
||||
NULL, rhc->rhc_rmi, "ip address", acl,
|
||||
RMAP_EVENT_FILTER_ADDED);
|
||||
break;
|
||||
case 2: /* ipv4-prefix-list */
|
||||
rhc->rhc_rmi, "ip address", acl,
|
||||
RMAP_EVENT_FILTER_ADDED,
|
||||
args->errmsg, args->errmsg_len);
|
||||
} else if (IS_MATCH_IPv4_PREFIX_LIST(condition)) {
|
||||
if (rmap_match_set_hook.match_ip_address_prefix_list == NULL)
|
||||
return NB_OK;
|
||||
rhc->rhc_mhook =
|
||||
@ -552,20 +555,20 @@ static int lib_route_map_entry_match_condition_list_name_modify(
|
||||
rhc->rhc_rule = "ip address prefix-list";
|
||||
rhc->rhc_event = RMAP_EVENT_PLIST_DELETED;
|
||||
rv = rmap_match_set_hook.match_ip_address_prefix_list(
|
||||
NULL, rhc->rhc_rmi, "ip address prefix-list", acl,
|
||||
RMAP_EVENT_PLIST_ADDED);
|
||||
break;
|
||||
case 3: /* ipv4-next-hop-list */
|
||||
rhc->rhc_rmi, "ip address prefix-list", acl,
|
||||
RMAP_EVENT_PLIST_ADDED,
|
||||
args->errmsg, args->errmsg_len);
|
||||
} else if (IS_MATCH_IPv4_NEXTHOP_LIST(condition)) {
|
||||
if (rmap_match_set_hook.match_ip_next_hop == NULL)
|
||||
return NB_OK;
|
||||
rhc->rhc_mhook = rmap_match_set_hook.no_match_ip_next_hop;
|
||||
rhc->rhc_rule = "ip next-hop";
|
||||
rhc->rhc_event = RMAP_EVENT_FILTER_DELETED;
|
||||
rv = rmap_match_set_hook.match_ip_next_hop(
|
||||
NULL, rhc->rhc_rmi, "ip next-hop", acl,
|
||||
RMAP_EVENT_FILTER_ADDED);
|
||||
break;
|
||||
case 4: /* ipv4-next-hop-prefix-list */
|
||||
rhc->rhc_rmi, "ip next-hop", acl,
|
||||
RMAP_EVENT_FILTER_ADDED,
|
||||
args->errmsg, args->errmsg_len);
|
||||
} else if (IS_MATCH_IPv4_NEXTHOP_PREFIX_LIST(condition)) {
|
||||
if (rmap_match_set_hook.match_ip_next_hop_prefix_list == NULL)
|
||||
return NB_OK;
|
||||
rhc->rhc_mhook =
|
||||
@ -573,20 +576,20 @@ static int lib_route_map_entry_match_condition_list_name_modify(
|
||||
rhc->rhc_rule = "ip next-hop prefix-list";
|
||||
rhc->rhc_event = RMAP_EVENT_PLIST_DELETED;
|
||||
rv = rmap_match_set_hook.match_ip_next_hop_prefix_list(
|
||||
NULL, rhc->rhc_rmi, "ip next-hop prefix-list", acl,
|
||||
RMAP_EVENT_PLIST_ADDED);
|
||||
break;
|
||||
case 6: /* ipv6-address-list */
|
||||
rhc->rhc_rmi, "ip next-hop prefix-list", acl,
|
||||
RMAP_EVENT_PLIST_ADDED,
|
||||
args->errmsg, args->errmsg_len);
|
||||
} else if (IS_MATCH_IPv6_ADDRESS_LIST(condition)) {
|
||||
if (rmap_match_set_hook.match_ipv6_address == NULL)
|
||||
return NB_OK;
|
||||
rhc->rhc_mhook = rmap_match_set_hook.no_match_ipv6_address;
|
||||
rhc->rhc_rule = "ipv6 address";
|
||||
rhc->rhc_event = RMAP_EVENT_FILTER_DELETED;
|
||||
rv = rmap_match_set_hook.match_ipv6_address(
|
||||
NULL, rhc->rhc_rmi, "ipv6 address", acl,
|
||||
RMAP_EVENT_FILTER_ADDED);
|
||||
break;
|
||||
case 7: /* ipv6-prefix-list */
|
||||
rhc->rhc_rmi, "ipv6 address", acl,
|
||||
RMAP_EVENT_FILTER_ADDED,
|
||||
args->errmsg, args->errmsg_len);
|
||||
} else if (IS_MATCH_IPv6_PREFIX_LIST(condition)) {
|
||||
if (rmap_match_set_hook.match_ipv6_address_prefix_list == NULL)
|
||||
return NB_OK;
|
||||
rhc->rhc_mhook =
|
||||
@ -594,13 +597,12 @@ static int lib_route_map_entry_match_condition_list_name_modify(
|
||||
rhc->rhc_rule = "ipv6 address prefix-list";
|
||||
rhc->rhc_event = RMAP_EVENT_PLIST_DELETED;
|
||||
rv = rmap_match_set_hook.match_ipv6_address_prefix_list(
|
||||
NULL, rhc->rhc_rmi, "ipv6 address prefix-list", acl,
|
||||
RMAP_EVENT_PLIST_ADDED);
|
||||
break;
|
||||
default:
|
||||
rhc->rhc_rmi, "ipv6 address prefix-list", acl,
|
||||
RMAP_EVENT_PLIST_ADDED,
|
||||
args->errmsg, args->errmsg_len);
|
||||
} else
|
||||
rv = CMD_ERR_NO_MATCH;
|
||||
break;
|
||||
}
|
||||
|
||||
if (rv != CMD_SUCCESS) {
|
||||
rhc->rhc_mhook = NULL;
|
||||
return NB_ERR_INCONSISTENCY;
|
||||
@ -642,8 +644,9 @@ static int lib_route_map_entry_match_condition_ipv4_next_hop_type_modify(
|
||||
rhc->rhc_event = RMAP_EVENT_MATCH_DELETED;
|
||||
|
||||
rv = rmap_match_set_hook.match_ip_next_hop_type(
|
||||
NULL, rhc->rhc_rmi, "ip next-hop type", type,
|
||||
RMAP_EVENT_MATCH_ADDED);
|
||||
rhc->rhc_rmi, "ip next-hop type", type,
|
||||
RMAP_EVENT_MATCH_ADDED,
|
||||
args->errmsg, args->errmsg_len);
|
||||
if (rv != CMD_SUCCESS) {
|
||||
rhc->rhc_mhook = NULL;
|
||||
return NB_ERR_INCONSISTENCY;
|
||||
@ -685,8 +688,9 @@ static int lib_route_map_entry_match_condition_ipv6_next_hop_type_modify(
|
||||
rhc->rhc_event = RMAP_EVENT_MATCH_DELETED;
|
||||
|
||||
rv = rmap_match_set_hook.match_ipv6_next_hop_type(
|
||||
NULL, rhc->rhc_rmi, "ipv6 next-hop type", type,
|
||||
RMAP_EVENT_MATCH_ADDED);
|
||||
rhc->rhc_rmi, "ipv6 next-hop type", type,
|
||||
RMAP_EVENT_MATCH_ADDED,
|
||||
args->errmsg, args->errmsg_len);
|
||||
if (rv != CMD_SUCCESS) {
|
||||
rhc->rhc_mhook = NULL;
|
||||
return NB_ERR_INCONSISTENCY;
|
||||
@ -727,8 +731,9 @@ static int lib_route_map_entry_match_condition_metric_modify(
|
||||
rhc->rhc_rule = "metric";
|
||||
rhc->rhc_event = RMAP_EVENT_MATCH_DELETED;
|
||||
|
||||
rv = rmap_match_set_hook.match_metric(NULL, rhc->rhc_rmi, "metric",
|
||||
type, RMAP_EVENT_MATCH_ADDED);
|
||||
rv = rmap_match_set_hook.match_metric(rhc->rhc_rmi, "metric",
|
||||
type, RMAP_EVENT_MATCH_ADDED,
|
||||
args->errmsg, args->errmsg_len);
|
||||
if (rv != CMD_SUCCESS) {
|
||||
rhc->rhc_mhook = NULL;
|
||||
return NB_ERR_INCONSISTENCY;
|
||||
@ -769,8 +774,9 @@ lib_route_map_entry_match_condition_tag_modify(struct nb_cb_modify_args *args)
|
||||
rhc->rhc_rule = "tag";
|
||||
rhc->rhc_event = RMAP_EVENT_MATCH_DELETED;
|
||||
|
||||
rv = rmap_match_set_hook.match_tag(NULL, rhc->rhc_rmi, "tag", tag,
|
||||
RMAP_EVENT_MATCH_ADDED);
|
||||
rv = rmap_match_set_hook.match_tag(rhc->rhc_rmi, "tag", tag,
|
||||
RMAP_EVENT_MATCH_ADDED,
|
||||
args->errmsg, args->errmsg_len);
|
||||
if (rv != CMD_SUCCESS) {
|
||||
rhc->rhc_mhook = NULL;
|
||||
return NB_ERR_INCONSISTENCY;
|
||||
@ -850,8 +856,9 @@ static int lib_route_map_entry_set_action_ipv4_address_modify(
|
||||
rhc->rhc_shook = rmap_match_set_hook.no_set_ip_nexthop;
|
||||
rhc->rhc_rule = "ip next-hop";
|
||||
|
||||
rv = rmap_match_set_hook.set_ip_nexthop(NULL, rhc->rhc_rmi,
|
||||
"ip next-hop", address);
|
||||
rv = rmap_match_set_hook.set_ip_nexthop(rhc->rhc_rmi, "ip next-hop",
|
||||
address,
|
||||
args->errmsg, args->errmsg_len);
|
||||
if (rv != CMD_SUCCESS) {
|
||||
rhc->rhc_shook = NULL;
|
||||
return NB_ERR_INCONSISTENCY;
|
||||
@ -909,7 +916,8 @@ static int lib_route_map_entry_set_action_ipv6_address_modify(
|
||||
rhc->rhc_rule = "ipv6 next-hop local";
|
||||
|
||||
rv = rmap_match_set_hook.set_ipv6_nexthop_local(
|
||||
NULL, rhc->rhc_rmi, "ipv6 next-hop local", address);
|
||||
rhc->rhc_rmi, "ipv6 next-hop local", address,
|
||||
args->errmsg, args->errmsg_len);
|
||||
if (rv != CMD_SUCCESS) {
|
||||
rhc->rhc_shook = NULL;
|
||||
return NB_ERR_INCONSISTENCY;
|
||||
@ -928,7 +936,8 @@ static int lib_route_map_entry_set_action_ipv6_address_destroy(
|
||||
* XPath: /frr-route-map:lib/route-map/entry/set-action/value
|
||||
*/
|
||||
static int set_action_modify(enum nb_event event, const struct lyd_node *dnode,
|
||||
union nb_resource *resource, const char *value)
|
||||
union nb_resource *resource, const char *value,
|
||||
char *errmsg, size_t errmsg_len)
|
||||
{
|
||||
struct routemap_hook_context *rhc;
|
||||
int rv;
|
||||
@ -952,8 +961,10 @@ static int set_action_modify(enum nb_event event, const struct lyd_node *dnode,
|
||||
rhc->rhc_shook = rmap_match_set_hook.no_set_metric;
|
||||
rhc->rhc_rule = "metric";
|
||||
|
||||
rv = rmap_match_set_hook.set_metric(NULL, rhc->rhc_rmi, "metric",
|
||||
value);
|
||||
rv = rmap_match_set_hook.set_metric(rhc->rhc_rmi, "metric",
|
||||
value,
|
||||
errmsg, errmsg_len
|
||||
);
|
||||
if (rv != CMD_SUCCESS) {
|
||||
rhc->rhc_shook = NULL;
|
||||
return NB_ERR_INCONSISTENCY;
|
||||
@ -968,7 +979,7 @@ lib_route_map_entry_set_action_value_modify(struct nb_cb_modify_args *args)
|
||||
const char *metric = yang_dnode_get_string(args->dnode, NULL);
|
||||
|
||||
return set_action_modify(args->event, args->dnode, args->resource,
|
||||
metric);
|
||||
metric, args->errmsg, args->errmsg_len);
|
||||
}
|
||||
|
||||
static int
|
||||
@ -995,7 +1006,8 @@ lib_route_map_entry_set_action_add_metric_modify(struct nb_cb_modify_args *args)
|
||||
snprintf(metric_str, sizeof(metric_str), "+%s",
|
||||
yang_dnode_get_string(args->dnode, NULL));
|
||||
return set_action_modify(args->event, args->dnode, args->resource,
|
||||
metric_str);
|
||||
metric_str,
|
||||
args->errmsg, args->errmsg_len);
|
||||
}
|
||||
|
||||
static int lib_route_map_entry_set_action_add_metric_destroy(
|
||||
@ -1022,7 +1034,8 @@ static int lib_route_map_entry_set_action_subtract_metric_modify(
|
||||
snprintf(metric_str, sizeof(metric_str), "-%s",
|
||||
yang_dnode_get_string(args->dnode, NULL));
|
||||
return set_action_modify(args->event, args->dnode, args->resource,
|
||||
metric_str);
|
||||
metric_str,
|
||||
args->errmsg, args->errmsg_len);
|
||||
}
|
||||
|
||||
static int lib_route_map_entry_set_action_subtract_metric_destroy(
|
||||
@ -1038,7 +1051,8 @@ static int lib_route_map_entry_set_action_use_round_trip_time_modify(
|
||||
struct nb_cb_modify_args *args)
|
||||
{
|
||||
return set_action_modify(args->event, args->dnode, args->resource,
|
||||
"rtt");
|
||||
"rtt",
|
||||
args->errmsg, args->errmsg_len);
|
||||
}
|
||||
|
||||
static int lib_route_map_entry_set_action_use_round_trip_time_destroy(
|
||||
@ -1054,7 +1068,8 @@ static int lib_route_map_entry_set_action_add_round_trip_time_modify(
|
||||
struct nb_cb_modify_args *args)
|
||||
{
|
||||
return set_action_modify(args->event, args->dnode, args->resource,
|
||||
"+rtt");
|
||||
"+rtt",
|
||||
args->errmsg, args->errmsg_len);
|
||||
}
|
||||
|
||||
static int lib_route_map_entry_set_action_add_round_trip_time_destroy(
|
||||
@ -1070,7 +1085,7 @@ static int lib_route_map_entry_set_action_subtract_round_trip_time_modify(
|
||||
struct nb_cb_modify_args *args)
|
||||
{
|
||||
return set_action_modify(args->event, args->dnode, args->resource,
|
||||
"-rtt");
|
||||
"-rtt", args->errmsg, args->errmsg_len);
|
||||
}
|
||||
|
||||
static int lib_route_map_entry_set_action_subtract_round_trip_time_destroy(
|
||||
@ -1109,7 +1124,8 @@ lib_route_map_entry_set_action_tag_modify(struct nb_cb_modify_args *args)
|
||||
rhc->rhc_shook = rmap_match_set_hook.no_set_tag;
|
||||
rhc->rhc_rule = "tag";
|
||||
|
||||
rv = rmap_match_set_hook.set_tag(NULL, rhc->rhc_rmi, "tag", tag);
|
||||
rv = rmap_match_set_hook.set_tag(rhc->rhc_rmi, "tag", tag,
|
||||
args->errmsg, args->errmsg_len);
|
||||
if (rv != CMD_SUCCESS) {
|
||||
rhc->rhc_shook = NULL;
|
||||
return NB_ERR_INCONSISTENCY;
|
||||
@ -1124,6 +1140,52 @@ lib_route_map_entry_set_action_tag_destroy(struct nb_cb_destroy_args *args)
|
||||
return lib_route_map_entry_set_destroy(args);
|
||||
}
|
||||
|
||||
/*
|
||||
* XPath: /frr-route-map:lib/route-map/entry/set-action/policy
|
||||
*/
|
||||
static int
|
||||
lib_route_map_entry_set_action_policy_modify(struct nb_cb_modify_args *args)
|
||||
{
|
||||
struct routemap_hook_context *rhc;
|
||||
const char *policy;
|
||||
int rv;
|
||||
|
||||
/*
|
||||
* NOTE: validate if 'action' is 'tag', currently it is not
|
||||
* necessary because this is the only implemented action. Other
|
||||
* actions might have different validations.
|
||||
*/
|
||||
if (args->event != NB_EV_APPLY)
|
||||
return NB_OK;
|
||||
|
||||
/* Check for hook function. */
|
||||
if (rmap_match_set_hook.set_srte_color == NULL)
|
||||
return NB_OK;
|
||||
|
||||
/* Add configuration. */
|
||||
rhc = nb_running_get_entry(args->dnode, NULL, true);
|
||||
policy = yang_dnode_get_string(args->dnode, NULL);
|
||||
|
||||
/* Set destroy information. */
|
||||
rhc->rhc_shook = rmap_match_set_hook.no_set_tag;
|
||||
rhc->rhc_rule = "sr-te color";
|
||||
|
||||
rv = rmap_match_set_hook.set_tag(rhc->rhc_rmi, "sr-te color", policy,
|
||||
args->errmsg, args->errmsg_len);
|
||||
if (rv != CMD_SUCCESS) {
|
||||
rhc->rhc_shook = NULL;
|
||||
return NB_ERR_INCONSISTENCY;
|
||||
}
|
||||
|
||||
return NB_OK;
|
||||
}
|
||||
|
||||
static int
|
||||
lib_route_map_entry_set_action_policy_destroy(struct nb_cb_destroy_args *args)
|
||||
{
|
||||
return lib_route_map_entry_set_destroy(args);
|
||||
}
|
||||
|
||||
/* clang-format off */
|
||||
const struct frr_yang_module_info frr_route_map_info = {
|
||||
.name = "frr-route-map",
|
||||
@ -1190,42 +1252,42 @@ const struct frr_yang_module_info frr_route_map_info = {
|
||||
}
|
||||
},
|
||||
{
|
||||
.xpath = "/frr-route-map:lib/route-map/entry/match-condition/interface",
|
||||
.xpath = "/frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/interface",
|
||||
.cbs = {
|
||||
.modify = lib_route_map_entry_match_condition_interface_modify,
|
||||
.destroy = lib_route_map_entry_match_condition_interface_destroy,
|
||||
}
|
||||
},
|
||||
{
|
||||
.xpath = "/frr-route-map:lib/route-map/entry/match-condition/list-name",
|
||||
.xpath = "/frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/list-name",
|
||||
.cbs = {
|
||||
.modify = lib_route_map_entry_match_condition_list_name_modify,
|
||||
.destroy = lib_route_map_entry_match_condition_list_name_destroy,
|
||||
}
|
||||
},
|
||||
{
|
||||
.xpath = "/frr-route-map:lib/route-map/entry/match-condition/ipv4-next-hop-type",
|
||||
.xpath = "/frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/ipv4-next-hop-type",
|
||||
.cbs = {
|
||||
.modify = lib_route_map_entry_match_condition_ipv4_next_hop_type_modify,
|
||||
.destroy = lib_route_map_entry_match_condition_ipv4_next_hop_type_destroy,
|
||||
}
|
||||
},
|
||||
{
|
||||
.xpath = "/frr-route-map:lib/route-map/entry/match-condition/ipv6-next-hop-type",
|
||||
.xpath = "/frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/ipv6-next-hop-type",
|
||||
.cbs = {
|
||||
.modify = lib_route_map_entry_match_condition_ipv6_next_hop_type_modify,
|
||||
.destroy = lib_route_map_entry_match_condition_ipv6_next_hop_type_destroy,
|
||||
}
|
||||
},
|
||||
{
|
||||
.xpath = "/frr-route-map:lib/route-map/entry/match-condition/metric",
|
||||
.xpath = "/frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/metric",
|
||||
.cbs = {
|
||||
.modify = lib_route_map_entry_match_condition_metric_modify,
|
||||
.destroy = lib_route_map_entry_match_condition_metric_destroy,
|
||||
}
|
||||
},
|
||||
{
|
||||
.xpath = "/frr-route-map:lib/route-map/entry/match-condition/tag",
|
||||
.xpath = "/frr-route-map:lib/route-map/entry/match-condition/rmap-match-condition/tag",
|
||||
.cbs = {
|
||||
.modify = lib_route_map_entry_match_condition_tag_modify,
|
||||
.destroy = lib_route_map_entry_match_condition_tag_destroy,
|
||||
@ -1240,68 +1302,76 @@ const struct frr_yang_module_info frr_route_map_info = {
|
||||
}
|
||||
},
|
||||
{
|
||||
.xpath = "/frr-route-map:lib/route-map/entry/set-action/ipv4-address",
|
||||
.xpath = "/frr-route-map:lib/route-map/entry/set-action/rmap-set-action/ipv4-address",
|
||||
.cbs = {
|
||||
.modify = lib_route_map_entry_set_action_ipv4_address_modify,
|
||||
.destroy = lib_route_map_entry_set_action_ipv4_address_destroy,
|
||||
}
|
||||
},
|
||||
{
|
||||
.xpath = "/frr-route-map:lib/route-map/entry/set-action/ipv6-address",
|
||||
.xpath = "/frr-route-map:lib/route-map/entry/set-action/rmap-set-action/ipv6-address",
|
||||
.cbs = {
|
||||
.modify = lib_route_map_entry_set_action_ipv6_address_modify,
|
||||
.destroy = lib_route_map_entry_set_action_ipv6_address_destroy,
|
||||
}
|
||||
},
|
||||
{
|
||||
.xpath = "/frr-route-map:lib/route-map/entry/set-action/value",
|
||||
.xpath = "/frr-route-map:lib/route-map/entry/set-action/rmap-set-action/value",
|
||||
.cbs = {
|
||||
.modify = lib_route_map_entry_set_action_value_modify,
|
||||
.destroy = lib_route_map_entry_set_action_value_destroy,
|
||||
}
|
||||
},
|
||||
{
|
||||
.xpath = "/frr-route-map:lib/route-map/entry/set-action/add-metric",
|
||||
.xpath = "/frr-route-map:lib/route-map/entry/set-action/rmap-set-action/add-metric",
|
||||
.cbs = {
|
||||
.modify = lib_route_map_entry_set_action_add_metric_modify,
|
||||
.destroy = lib_route_map_entry_set_action_add_metric_destroy,
|
||||
}
|
||||
},
|
||||
{
|
||||
.xpath = "/frr-route-map:lib/route-map/entry/set-action/subtract-metric",
|
||||
.xpath = "/frr-route-map:lib/route-map/entry/set-action/rmap-set-action/subtract-metric",
|
||||
.cbs = {
|
||||
.modify = lib_route_map_entry_set_action_subtract_metric_modify,
|
||||
.destroy = lib_route_map_entry_set_action_subtract_metric_destroy,
|
||||
}
|
||||
},
|
||||
{
|
||||
.xpath = "/frr-route-map:lib/route-map/entry/set-action/use-round-trip-time",
|
||||
.xpath = "/frr-route-map:lib/route-map/entry/set-action/rmap-set-action/use-round-trip-time",
|
||||
.cbs = {
|
||||
.modify = lib_route_map_entry_set_action_use_round_trip_time_modify,
|
||||
.destroy = lib_route_map_entry_set_action_use_round_trip_time_destroy,
|
||||
}
|
||||
},
|
||||
{
|
||||
.xpath = "/frr-route-map:lib/route-map/entry/set-action/add-round-trip-time",
|
||||
.xpath = "/frr-route-map:lib/route-map/entry/set-action/rmap-set-action/add-round-trip-time",
|
||||
.cbs = {
|
||||
.modify = lib_route_map_entry_set_action_add_round_trip_time_modify,
|
||||
.destroy = lib_route_map_entry_set_action_add_round_trip_time_destroy,
|
||||
}
|
||||
},
|
||||
{
|
||||
.xpath = "/frr-route-map:lib/route-map/entry/set-action/subtract-round-trip-time",
|
||||
.xpath = "/frr-route-map:lib/route-map/entry/set-action/rmap-set-action/subtract-round-trip-time",
|
||||
.cbs = {
|
||||
.modify = lib_route_map_entry_set_action_subtract_round_trip_time_modify,
|
||||
.destroy = lib_route_map_entry_set_action_subtract_round_trip_time_destroy,
|
||||
}
|
||||
},
|
||||
{
|
||||
.xpath = "/frr-route-map:lib/route-map/entry/set-action/tag",
|
||||
.xpath = "/frr-route-map:lib/route-map/entry/set-action/rmap-set-action/tag",
|
||||
.cbs = {
|
||||
.modify = lib_route_map_entry_set_action_tag_modify,
|
||||
.destroy = lib_route_map_entry_set_action_tag_destroy,
|
||||
}
|
||||
},
|
||||
{
|
||||
.xpath = "/frr-route-map:lib/route-map/entry/set-action/rmap-set-action/policy",
|
||||
.cbs = {
|
||||
.modify = lib_route_map_entry_set_action_policy_modify,
|
||||
.destroy = lib_route_map_entry_set_action_policy_destroy,
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
.xpath = NULL,
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user