2023-02-08 13:17:09 +01:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2007-05-04 22:13:20 +02:00
|
|
|
/* zebra routemap.
|
|
|
|
* Copyright (C) 2006 IBM Corporation
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <zebra.h>
|
|
|
|
|
|
|
|
#include "memory.h"
|
|
|
|
#include "prefix.h"
|
|
|
|
#include "rib.h"
|
2016-10-06 21:56:13 +02:00
|
|
|
#include "vty.h"
|
2007-05-04 22:13:20 +02:00
|
|
|
#include "routemap.h"
|
|
|
|
#include "command.h"
|
|
|
|
#include "filter.h"
|
|
|
|
#include "plist.h"
|
2015-05-20 02:40:34 +02:00
|
|
|
#include "nexthop.h"
|
2019-10-08 21:21:26 +02:00
|
|
|
#include "northbound_cli.h"
|
2021-04-21 11:19:39 +02:00
|
|
|
#include "lib/route_types.h"
|
2015-05-22 11:40:04 +02:00
|
|
|
#include "vrf.h"
|
2018-06-19 17:59:53 +02:00
|
|
|
#include "frrstr.h"
|
2007-05-04 22:13:20 +02:00
|
|
|
|
2019-01-11 19:31:46 +01:00
|
|
|
#include "zebra/zebra_router.h"
|
2016-05-11 17:47:02 +02:00
|
|
|
#include "zebra/redistribute.h"
|
2015-05-20 02:40:45 +02:00
|
|
|
#include "zebra/debug.h"
|
2015-05-20 02:47:20 +02:00
|
|
|
#include "zebra/zebra_rnh.h"
|
2015-08-26 14:21:40 +02:00
|
|
|
#include "zebra/zebra_routemap.h"
|
2015-05-20 02:40:45 +02:00
|
|
|
|
2018-10-11 19:48:23 +02:00
|
|
|
#include "zebra/zebra_routemap_clippy.c"
|
|
|
|
|
2018-03-27 21:13:34 +02:00
|
|
|
static uint32_t zebra_rmap_update_timer = ZEBRA_RMAP_DEFAULT_UPDATE_TIMER;
|
2022-03-01 22:18:12 +01:00
|
|
|
static struct event *zebra_t_rmap_update = NULL;
|
2016-05-11 17:47:02 +02:00
|
|
|
char *zebra_import_table_routemap[AFI_MAX][ZEBRA_KERNEL_TABLE_MAX];
|
2015-05-20 02:40:45 +02:00
|
|
|
|
2023-08-11 16:12:06 +02:00
|
|
|
struct zebra_rmap_obj {
|
2015-05-20 02:47:20 +02:00
|
|
|
struct nexthop *nexthop;
|
2023-08-11 17:11:40 +02:00
|
|
|
struct route_entry *re;
|
2018-05-17 16:29:49 +02:00
|
|
|
uint8_t instance;
|
2015-05-20 02:47:20 +02:00
|
|
|
int metric;
|
2016-10-01 20:42:34 +02:00
|
|
|
route_tag_t tag;
|
2015-05-20 02:47:20 +02:00
|
|
|
};
|
|
|
|
|
2018-03-27 21:13:34 +02:00
|
|
|
static void zebra_route_map_set_delay_timer(uint32_t value);
|
2007-05-04 22:13:20 +02:00
|
|
|
|
2015-05-20 03:03:44 +02:00
|
|
|
/* 'match tag TAG'
|
|
|
|
* Match function return 1 if match is success else return 0
|
|
|
|
*/
|
lib: Introducing a 3rd state for route-map match cmd: RMAP_NOOP
Introducing a 3rd state for route_map_apply library function: RMAP_NOOP
Traditionally route map MATCH rule apis were designed to return
a binary response, consisting of either RMAP_MATCH or RMAP_NOMATCH.
(Route-map SET rule apis return RMAP_OKAY or RMAP_ERROR).
Depending on this response, the following statemachine decided the
course of action:
State1:
If match cmd returns RMAP_MATCH then, keep existing behaviour.
If routemap type is PERMIT, execute set cmds or call cmds if applicable,
otherwise PERMIT!
Else If routemap type is DENY, we DENYMATCH right away
State2:
If match cmd returns RMAP_NOMATCH, continue on to next route-map. If there
are no other rules or if all the rules return RMAP_NOMATCH, return DENYMATCH
We require a 3rd state because of the following situation:
The issue - what if, the rule api needs to abort or ignore a rule?:
"match evpn vni xx" route-map filter can be applied to incoming routes
regardless of whether the tunnel type is vxlan or mpls.
This rule should be N/A for mpls based evpn route, but applicable to only
vxlan based evpn route.
Also, this rule should be applicable for routes with VNI label only, and
not for routes without labels. For example, type 3 and type 4 EVPN routes
do not have labels, so, this match cmd should let them through.
Today, the filter produces either a match or nomatch response regardless of
whether it is mpls/vxlan, resulting in either permitting or denying the
route.. So an mpls evpn route may get filtered out incorrectly.
Eg: "route-map RM1 permit 10 ; match evpn vni 20" or
"route-map RM2 deny 20 ; match vni 20"
With the introduction of the 3rd state, we can abort this rule check safely.
How? The rules api can now return RMAP_NOOP to indicate
that it encountered an invalid check, and needs to abort just that rule,
but continue with other rules.
As a result we have a 3rd state:
State3:
If match cmd returned RMAP_NOOP
Then, proceed to other route-map, otherwise if there are no more
rules or if all the rules return RMAP_NOOP, then, return RMAP_PERMITMATCH.
Signed-off-by: Lakshman Krishnamoorthy <lkrishnamoor@vmware.com>
2019-06-19 23:04:36 +02:00
|
|
|
static enum route_map_cmd_result_t
|
2020-11-14 01:35:20 +01:00
|
|
|
route_match_tag(void *rule, const struct prefix *prefix, void *object)
|
2015-05-20 03:03:44 +02:00
|
|
|
{
|
2016-10-01 20:42:34 +02:00
|
|
|
route_tag_t *tag;
|
2023-08-11 16:12:06 +02:00
|
|
|
struct zebra_rmap_obj *rm_data;
|
2015-05-20 03:03:44 +02:00
|
|
|
|
2020-11-14 01:35:20 +01:00
|
|
|
tag = rule;
|
2023-08-11 16:12:06 +02:00
|
|
|
rm_data = object;
|
2020-11-14 01:35:20 +01:00
|
|
|
|
2023-08-11 16:12:06 +02:00
|
|
|
if (rm_data->tag == *tag)
|
2020-11-14 01:35:20 +01:00
|
|
|
return RMAP_MATCH;
|
2015-05-20 03:03:44 +02:00
|
|
|
|
|
|
|
return RMAP_NOMATCH;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Route map commands for tag matching */
|
2019-11-20 17:20:58 +01:00
|
|
|
static const struct route_map_rule_cmd route_match_tag_cmd = {
|
|
|
|
"tag",
|
|
|
|
route_match_tag,
|
|
|
|
route_map_rule_tag_compile,
|
2016-10-01 20:42:34 +02:00
|
|
|
route_map_rule_tag_free,
|
2015-05-20 03:03:44 +02:00
|
|
|
};
|
|
|
|
|
2014-06-04 06:53:35 +02:00
|
|
|
|
2007-05-04 22:13:20 +02:00
|
|
|
/* `match interface IFNAME' */
|
|
|
|
/* Match function return 1 if match is success else return zero. */
|
lib: Introducing a 3rd state for route-map match cmd: RMAP_NOOP
Introducing a 3rd state for route_map_apply library function: RMAP_NOOP
Traditionally route map MATCH rule apis were designed to return
a binary response, consisting of either RMAP_MATCH or RMAP_NOMATCH.
(Route-map SET rule apis return RMAP_OKAY or RMAP_ERROR).
Depending on this response, the following statemachine decided the
course of action:
State1:
If match cmd returns RMAP_MATCH then, keep existing behaviour.
If routemap type is PERMIT, execute set cmds or call cmds if applicable,
otherwise PERMIT!
Else If routemap type is DENY, we DENYMATCH right away
State2:
If match cmd returns RMAP_NOMATCH, continue on to next route-map. If there
are no other rules or if all the rules return RMAP_NOMATCH, return DENYMATCH
We require a 3rd state because of the following situation:
The issue - what if, the rule api needs to abort or ignore a rule?:
"match evpn vni xx" route-map filter can be applied to incoming routes
regardless of whether the tunnel type is vxlan or mpls.
This rule should be N/A for mpls based evpn route, but applicable to only
vxlan based evpn route.
Also, this rule should be applicable for routes with VNI label only, and
not for routes without labels. For example, type 3 and type 4 EVPN routes
do not have labels, so, this match cmd should let them through.
Today, the filter produces either a match or nomatch response regardless of
whether it is mpls/vxlan, resulting in either permitting or denying the
route.. So an mpls evpn route may get filtered out incorrectly.
Eg: "route-map RM1 permit 10 ; match evpn vni 20" or
"route-map RM2 deny 20 ; match vni 20"
With the introduction of the 3rd state, we can abort this rule check safely.
How? The rules api can now return RMAP_NOOP to indicate
that it encountered an invalid check, and needs to abort just that rule,
but continue with other rules.
As a result we have a 3rd state:
State3:
If match cmd returned RMAP_NOOP
Then, proceed to other route-map, otherwise if there are no more
rules or if all the rules return RMAP_NOOP, then, return RMAP_PERMITMATCH.
Signed-off-by: Lakshman Krishnamoorthy <lkrishnamoor@vmware.com>
2019-06-19 23:04:36 +02:00
|
|
|
static enum route_map_cmd_result_t
|
2020-11-14 01:35:20 +01:00
|
|
|
route_match_interface(void *rule, const struct prefix *prefix, void *object)
|
2007-05-04 22:13:20 +02:00
|
|
|
{
|
2023-08-11 16:12:06 +02:00
|
|
|
struct zebra_rmap_obj *rm_data;
|
2007-05-04 22:13:20 +02:00
|
|
|
char *ifname = rule;
|
2016-01-18 11:12:10 +01:00
|
|
|
ifindex_t ifindex;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2020-11-14 01:35:20 +01:00
|
|
|
if (strcasecmp(ifname, "any") == 0)
|
|
|
|
return RMAP_MATCH;
|
2023-08-11 16:12:06 +02:00
|
|
|
rm_data = object;
|
|
|
|
if (!rm_data || !rm_data->nexthop)
|
2020-11-14 01:35:20 +01:00
|
|
|
return RMAP_NOMATCH;
|
2023-08-11 17:06:04 +02:00
|
|
|
ifindex = ifname2ifindex(ifname, rm_data->nexthop->vrf_id);
|
2020-11-14 01:35:20 +01:00
|
|
|
if (ifindex == 0)
|
|
|
|
return RMAP_NOMATCH;
|
2023-08-11 16:12:06 +02:00
|
|
|
if (rm_data->nexthop->ifindex == ifindex)
|
2020-11-14 01:35:20 +01:00
|
|
|
return RMAP_MATCH;
|
|
|
|
|
2015-05-22 11:40:04 +02:00
|
|
|
return RMAP_NOMATCH;
|
2007-05-04 22:13:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Route map `match interface' match statement. `arg' is IFNAME value */
|
|
|
|
static void *route_match_interface_compile(const char *arg)
|
|
|
|
{
|
|
|
|
return XSTRDUP(MTYPE_ROUTE_MAP_COMPILED, arg);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Free route map's compiled `match interface' value. */
|
|
|
|
static void route_match_interface_free(void *rule)
|
|
|
|
{
|
|
|
|
XFREE(MTYPE_ROUTE_MAP_COMPILED, rule);
|
|
|
|
}
|
|
|
|
|
2018-10-11 19:49:34 +02:00
|
|
|
static void show_vrf_proto_rm(struct vty *vty, struct zebra_vrf *zvrf,
|
|
|
|
int af_type)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2019-11-23 02:14:21 +01:00
|
|
|
vty_out(vty, "Protocol : route-map\n");
|
|
|
|
vty_out(vty, "-------------------------------------\n");
|
2018-10-11 19:49:34 +02:00
|
|
|
|
|
|
|
for (i = 0; i < ZEBRA_ROUTE_MAX; i++) {
|
|
|
|
if (PROTO_RM_NAME(zvrf, af_type, i))
|
2019-11-23 02:14:21 +01:00
|
|
|
vty_out(vty, "%-24s : %-10s\n", zebra_route_string(i),
|
2018-10-11 19:49:34 +02:00
|
|
|
PROTO_RM_NAME(zvrf, af_type, i));
|
|
|
|
else
|
2019-11-23 02:14:21 +01:00
|
|
|
vty_out(vty, "%-24s : none\n", zebra_route_string(i));
|
2018-10-11 19:49:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (PROTO_RM_NAME(zvrf, af_type, i))
|
2019-11-23 02:14:21 +01:00
|
|
|
vty_out(vty, "%-24s : %-10s\n", "any",
|
2018-10-11 19:49:34 +02:00
|
|
|
PROTO_RM_NAME(zvrf, af_type, i));
|
|
|
|
else
|
2019-11-23 02:14:21 +01:00
|
|
|
vty_out(vty, "%-24s : none\n", "any");
|
2018-10-11 19:49:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void show_vrf_nht_rm(struct vty *vty, struct zebra_vrf *zvrf,
|
zebra: json support for show ip nht route-map
Changes:
JSON support added for below commands,
- show ip nht route-map vrf all json
- show ip nht route-map vrf <name> json
- show ipv6 nht route-map vrf all json
- show ipv6 nht route-map vrf <name> json
- show ipv6 nht route-map json
- show ip nht route-map json
Testing Done: Unit testing completed.
tor-1# show ip nht route-map vrf default json
{
"afi":"ipv4",
"vrfs":{
"default":{
"protocols":{
"system":"none",
"kernel":"none",
"connected":"connected-policy",
"static":"none",
"rip":"none",
"ripng":"none",
"ospf":"none",
"ospf6":"none",
"isis":"none",
"bgp":"bgp-policy",
"pim":"none",
"eigrp":"none",
"nhrp":"none",
"hsls":"none",
"olsr":"none",
"table":"none",
"ldp":"none",
"vnc":"none",
"vnc-direct":"none",
"vnc-rn":"none",
"bgp-direct":"none",
"bgp-direct-to-nve-groups":"none",
"babel":"none",
"sharp":"none",
"pbr":"none",
"bfd":"none",
"openfabric":"none",
"vrrp":"none",
"zebra":"none",
"frr":"none",
"wildcard":"none",
"any":"none"
}
}
}
}
tor-1# show ip nht route-map vrf all json
{
"afi":"ipv4",
"vrfs":{
"default":{
"protocols":{
"system":"none",
"kernel":"none",
"connected":"connected-policy",
"static":"none",
"rip":"none",
"ripng":"none",
"ospf":"none",
"ospf6":"none",
"isis":"none",
"bgp":"bgp-policy",
"pim":"none",
"eigrp":"none",
"nhrp":"none",
"hsls":"none",
"olsr":"none",
"table":"none",
"ldp":"none",
"vnc":"none",
"vnc-direct":"none",
"vnc-rn":"none",
"bgp-direct":"none",
"bgp-direct-to-nve-groups":"none",
"babel":"none",
"sharp":"none",
"pbr":"none",
"bfd":"none",
"openfabric":"none",
"vrrp":"none",
"zebra":"none",
"frr":"none",
"wildcard":"none",
"any":"none"
}
},
"mgmt":{
"protocols":{
"system":"none",
"kernel":"none",
"connected":"none",
"static":"none",
"rip":"none",
"ripng":"none",
"ospf":"none",
"ospf6":"none",
"isis":"none",
"bgp":"none",
"pim":"none",
"eigrp":"none",
"nhrp":"none",
"hsls":"none",
"olsr":"none",
"table":"none",
"ldp":"none",
"vnc":"none",
"vnc-direct":"none",
"vnc-rn":"none",
"bgp-direct":"none",
"bgp-direct-to-nve-groups":"none",
"babel":"none",
"sharp":"none",
"pbr":"none",
"bfd":"none",
"openfabric":"none",
"vrrp":"none",
"zebra":"none",
"frr":"none",
"wildcard":"none",
"any":"none"
}
},
"sym_1":{
"protocols":{
"system":"none",
"kernel":"none",
"connected":"none",
"static":"none",
"rip":"none",
"ripng":"none",
"ospf":"none",
"ospf6":"none",
"isis":"none",
"bgp":"bgp-policy",
"pim":"none",
"eigrp":"none",
"nhrp":"none",
"hsls":"none",
"olsr":"none",
"table":"none",
"ldp":"none",
"vnc":"none",
"vnc-direct":"none",
"vnc-rn":"none",
"bgp-direct":"none",
"bgp-direct-to-nve-groups":"none",
"babel":"none",
"sharp":"none",
"pbr":"none",
"bfd":"none",
"openfabric":"none",
"vrrp":"none",
"zebra":"none",
"frr":"none",
"wildcard":"none",
"any":"none"
}
}
}
}
tor-1# show ipv6 nht route-map vrf default json
{
"afi":"ipv6",
"vrfs":{
"default":{
"protocols":{
"system":"none",
"kernel":"kernel-policy",
"connected":"connected-policy",
"static":"none",
"rip":"none",
"ripng":"none",
"ospf":"none",
"ospf6":"none",
"isis":"none",
"bgp":"none",
"pim":"none",
"eigrp":"none",
"nhrp":"none",
"hsls":"none",
"olsr":"none",
"table":"none",
"ldp":"none",
"vnc":"none",
"vnc-direct":"none",
"vnc-rn":"none",
"bgp-direct":"none",
"bgp-direct-to-nve-groups":"none",
"babel":"none",
"sharp":"none",
"pbr":"none",
"bfd":"none",
"openfabric":"none",
"vrrp":"none",
"zebra":"none",
"frr":"none",
"wildcard":"none",
"any":"none"
}
}
}
}
Ticket:#3229016
Issue:3229016
Signed-off-by: Sindhu Parvathi Gopinathan <sgopinathan@nvidia.com>
2022-11-08 06:40:13 +01:00
|
|
|
int af_type, json_object *json)
|
2018-10-11 19:49:34 +02:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
zebra: json support for show ip nht route-map
Changes:
JSON support added for below commands,
- show ip nht route-map vrf all json
- show ip nht route-map vrf <name> json
- show ipv6 nht route-map vrf all json
- show ipv6 nht route-map vrf <name> json
- show ipv6 nht route-map json
- show ip nht route-map json
Testing Done: Unit testing completed.
tor-1# show ip nht route-map vrf default json
{
"afi":"ipv4",
"vrfs":{
"default":{
"protocols":{
"system":"none",
"kernel":"none",
"connected":"connected-policy",
"static":"none",
"rip":"none",
"ripng":"none",
"ospf":"none",
"ospf6":"none",
"isis":"none",
"bgp":"bgp-policy",
"pim":"none",
"eigrp":"none",
"nhrp":"none",
"hsls":"none",
"olsr":"none",
"table":"none",
"ldp":"none",
"vnc":"none",
"vnc-direct":"none",
"vnc-rn":"none",
"bgp-direct":"none",
"bgp-direct-to-nve-groups":"none",
"babel":"none",
"sharp":"none",
"pbr":"none",
"bfd":"none",
"openfabric":"none",
"vrrp":"none",
"zebra":"none",
"frr":"none",
"wildcard":"none",
"any":"none"
}
}
}
}
tor-1# show ip nht route-map vrf all json
{
"afi":"ipv4",
"vrfs":{
"default":{
"protocols":{
"system":"none",
"kernel":"none",
"connected":"connected-policy",
"static":"none",
"rip":"none",
"ripng":"none",
"ospf":"none",
"ospf6":"none",
"isis":"none",
"bgp":"bgp-policy",
"pim":"none",
"eigrp":"none",
"nhrp":"none",
"hsls":"none",
"olsr":"none",
"table":"none",
"ldp":"none",
"vnc":"none",
"vnc-direct":"none",
"vnc-rn":"none",
"bgp-direct":"none",
"bgp-direct-to-nve-groups":"none",
"babel":"none",
"sharp":"none",
"pbr":"none",
"bfd":"none",
"openfabric":"none",
"vrrp":"none",
"zebra":"none",
"frr":"none",
"wildcard":"none",
"any":"none"
}
},
"mgmt":{
"protocols":{
"system":"none",
"kernel":"none",
"connected":"none",
"static":"none",
"rip":"none",
"ripng":"none",
"ospf":"none",
"ospf6":"none",
"isis":"none",
"bgp":"none",
"pim":"none",
"eigrp":"none",
"nhrp":"none",
"hsls":"none",
"olsr":"none",
"table":"none",
"ldp":"none",
"vnc":"none",
"vnc-direct":"none",
"vnc-rn":"none",
"bgp-direct":"none",
"bgp-direct-to-nve-groups":"none",
"babel":"none",
"sharp":"none",
"pbr":"none",
"bfd":"none",
"openfabric":"none",
"vrrp":"none",
"zebra":"none",
"frr":"none",
"wildcard":"none",
"any":"none"
}
},
"sym_1":{
"protocols":{
"system":"none",
"kernel":"none",
"connected":"none",
"static":"none",
"rip":"none",
"ripng":"none",
"ospf":"none",
"ospf6":"none",
"isis":"none",
"bgp":"bgp-policy",
"pim":"none",
"eigrp":"none",
"nhrp":"none",
"hsls":"none",
"olsr":"none",
"table":"none",
"ldp":"none",
"vnc":"none",
"vnc-direct":"none",
"vnc-rn":"none",
"bgp-direct":"none",
"bgp-direct-to-nve-groups":"none",
"babel":"none",
"sharp":"none",
"pbr":"none",
"bfd":"none",
"openfabric":"none",
"vrrp":"none",
"zebra":"none",
"frr":"none",
"wildcard":"none",
"any":"none"
}
}
}
}
tor-1# show ipv6 nht route-map vrf default json
{
"afi":"ipv6",
"vrfs":{
"default":{
"protocols":{
"system":"none",
"kernel":"kernel-policy",
"connected":"connected-policy",
"static":"none",
"rip":"none",
"ripng":"none",
"ospf":"none",
"ospf6":"none",
"isis":"none",
"bgp":"none",
"pim":"none",
"eigrp":"none",
"nhrp":"none",
"hsls":"none",
"olsr":"none",
"table":"none",
"ldp":"none",
"vnc":"none",
"vnc-direct":"none",
"vnc-rn":"none",
"bgp-direct":"none",
"bgp-direct-to-nve-groups":"none",
"babel":"none",
"sharp":"none",
"pbr":"none",
"bfd":"none",
"openfabric":"none",
"vrrp":"none",
"zebra":"none",
"frr":"none",
"wildcard":"none",
"any":"none"
}
}
}
}
Ticket:#3229016
Issue:3229016
Signed-off-by: Sindhu Parvathi Gopinathan <sgopinathan@nvidia.com>
2022-11-08 06:40:13 +01:00
|
|
|
if (!json) {
|
|
|
|
vty_out(vty, "Protocol : route-map\n");
|
|
|
|
vty_out(vty, "-------------------------------------\n");
|
|
|
|
}
|
2018-10-11 19:49:34 +02:00
|
|
|
|
|
|
|
for (i = 0; i < ZEBRA_ROUTE_MAX; i++) {
|
zebra: json support for show ip nht route-map
Changes:
JSON support added for below commands,
- show ip nht route-map vrf all json
- show ip nht route-map vrf <name> json
- show ipv6 nht route-map vrf all json
- show ipv6 nht route-map vrf <name> json
- show ipv6 nht route-map json
- show ip nht route-map json
Testing Done: Unit testing completed.
tor-1# show ip nht route-map vrf default json
{
"afi":"ipv4",
"vrfs":{
"default":{
"protocols":{
"system":"none",
"kernel":"none",
"connected":"connected-policy",
"static":"none",
"rip":"none",
"ripng":"none",
"ospf":"none",
"ospf6":"none",
"isis":"none",
"bgp":"bgp-policy",
"pim":"none",
"eigrp":"none",
"nhrp":"none",
"hsls":"none",
"olsr":"none",
"table":"none",
"ldp":"none",
"vnc":"none",
"vnc-direct":"none",
"vnc-rn":"none",
"bgp-direct":"none",
"bgp-direct-to-nve-groups":"none",
"babel":"none",
"sharp":"none",
"pbr":"none",
"bfd":"none",
"openfabric":"none",
"vrrp":"none",
"zebra":"none",
"frr":"none",
"wildcard":"none",
"any":"none"
}
}
}
}
tor-1# show ip nht route-map vrf all json
{
"afi":"ipv4",
"vrfs":{
"default":{
"protocols":{
"system":"none",
"kernel":"none",
"connected":"connected-policy",
"static":"none",
"rip":"none",
"ripng":"none",
"ospf":"none",
"ospf6":"none",
"isis":"none",
"bgp":"bgp-policy",
"pim":"none",
"eigrp":"none",
"nhrp":"none",
"hsls":"none",
"olsr":"none",
"table":"none",
"ldp":"none",
"vnc":"none",
"vnc-direct":"none",
"vnc-rn":"none",
"bgp-direct":"none",
"bgp-direct-to-nve-groups":"none",
"babel":"none",
"sharp":"none",
"pbr":"none",
"bfd":"none",
"openfabric":"none",
"vrrp":"none",
"zebra":"none",
"frr":"none",
"wildcard":"none",
"any":"none"
}
},
"mgmt":{
"protocols":{
"system":"none",
"kernel":"none",
"connected":"none",
"static":"none",
"rip":"none",
"ripng":"none",
"ospf":"none",
"ospf6":"none",
"isis":"none",
"bgp":"none",
"pim":"none",
"eigrp":"none",
"nhrp":"none",
"hsls":"none",
"olsr":"none",
"table":"none",
"ldp":"none",
"vnc":"none",
"vnc-direct":"none",
"vnc-rn":"none",
"bgp-direct":"none",
"bgp-direct-to-nve-groups":"none",
"babel":"none",
"sharp":"none",
"pbr":"none",
"bfd":"none",
"openfabric":"none",
"vrrp":"none",
"zebra":"none",
"frr":"none",
"wildcard":"none",
"any":"none"
}
},
"sym_1":{
"protocols":{
"system":"none",
"kernel":"none",
"connected":"none",
"static":"none",
"rip":"none",
"ripng":"none",
"ospf":"none",
"ospf6":"none",
"isis":"none",
"bgp":"bgp-policy",
"pim":"none",
"eigrp":"none",
"nhrp":"none",
"hsls":"none",
"olsr":"none",
"table":"none",
"ldp":"none",
"vnc":"none",
"vnc-direct":"none",
"vnc-rn":"none",
"bgp-direct":"none",
"bgp-direct-to-nve-groups":"none",
"babel":"none",
"sharp":"none",
"pbr":"none",
"bfd":"none",
"openfabric":"none",
"vrrp":"none",
"zebra":"none",
"frr":"none",
"wildcard":"none",
"any":"none"
}
}
}
}
tor-1# show ipv6 nht route-map vrf default json
{
"afi":"ipv6",
"vrfs":{
"default":{
"protocols":{
"system":"none",
"kernel":"kernel-policy",
"connected":"connected-policy",
"static":"none",
"rip":"none",
"ripng":"none",
"ospf":"none",
"ospf6":"none",
"isis":"none",
"bgp":"none",
"pim":"none",
"eigrp":"none",
"nhrp":"none",
"hsls":"none",
"olsr":"none",
"table":"none",
"ldp":"none",
"vnc":"none",
"vnc-direct":"none",
"vnc-rn":"none",
"bgp-direct":"none",
"bgp-direct-to-nve-groups":"none",
"babel":"none",
"sharp":"none",
"pbr":"none",
"bfd":"none",
"openfabric":"none",
"vrrp":"none",
"zebra":"none",
"frr":"none",
"wildcard":"none",
"any":"none"
}
}
}
}
Ticket:#3229016
Issue:3229016
Signed-off-by: Sindhu Parvathi Gopinathan <sgopinathan@nvidia.com>
2022-11-08 06:40:13 +01:00
|
|
|
if (json) {
|
|
|
|
if (NHT_RM_NAME(zvrf, af_type, i))
|
|
|
|
json_object_string_add(
|
|
|
|
json, zebra_route_string(i),
|
|
|
|
NHT_RM_NAME(zvrf, af_type, i));
|
|
|
|
else
|
|
|
|
json_object_string_add(
|
|
|
|
json, zebra_route_string(i), "none");
|
|
|
|
} else {
|
|
|
|
if (NHT_RM_NAME(zvrf, af_type, i))
|
|
|
|
vty_out(vty, "%-24s : %-10s\n",
|
|
|
|
zebra_route_string(i),
|
|
|
|
NHT_RM_NAME(zvrf, af_type, i));
|
|
|
|
else
|
|
|
|
vty_out(vty, "%-24s : none\n",
|
|
|
|
zebra_route_string(i));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (json) {
|
2018-10-11 19:49:34 +02:00
|
|
|
if (NHT_RM_NAME(zvrf, af_type, i))
|
zebra: json support for show ip nht route-map
Changes:
JSON support added for below commands,
- show ip nht route-map vrf all json
- show ip nht route-map vrf <name> json
- show ipv6 nht route-map vrf all json
- show ipv6 nht route-map vrf <name> json
- show ipv6 nht route-map json
- show ip nht route-map json
Testing Done: Unit testing completed.
tor-1# show ip nht route-map vrf default json
{
"afi":"ipv4",
"vrfs":{
"default":{
"protocols":{
"system":"none",
"kernel":"none",
"connected":"connected-policy",
"static":"none",
"rip":"none",
"ripng":"none",
"ospf":"none",
"ospf6":"none",
"isis":"none",
"bgp":"bgp-policy",
"pim":"none",
"eigrp":"none",
"nhrp":"none",
"hsls":"none",
"olsr":"none",
"table":"none",
"ldp":"none",
"vnc":"none",
"vnc-direct":"none",
"vnc-rn":"none",
"bgp-direct":"none",
"bgp-direct-to-nve-groups":"none",
"babel":"none",
"sharp":"none",
"pbr":"none",
"bfd":"none",
"openfabric":"none",
"vrrp":"none",
"zebra":"none",
"frr":"none",
"wildcard":"none",
"any":"none"
}
}
}
}
tor-1# show ip nht route-map vrf all json
{
"afi":"ipv4",
"vrfs":{
"default":{
"protocols":{
"system":"none",
"kernel":"none",
"connected":"connected-policy",
"static":"none",
"rip":"none",
"ripng":"none",
"ospf":"none",
"ospf6":"none",
"isis":"none",
"bgp":"bgp-policy",
"pim":"none",
"eigrp":"none",
"nhrp":"none",
"hsls":"none",
"olsr":"none",
"table":"none",
"ldp":"none",
"vnc":"none",
"vnc-direct":"none",
"vnc-rn":"none",
"bgp-direct":"none",
"bgp-direct-to-nve-groups":"none",
"babel":"none",
"sharp":"none",
"pbr":"none",
"bfd":"none",
"openfabric":"none",
"vrrp":"none",
"zebra":"none",
"frr":"none",
"wildcard":"none",
"any":"none"
}
},
"mgmt":{
"protocols":{
"system":"none",
"kernel":"none",
"connected":"none",
"static":"none",
"rip":"none",
"ripng":"none",
"ospf":"none",
"ospf6":"none",
"isis":"none",
"bgp":"none",
"pim":"none",
"eigrp":"none",
"nhrp":"none",
"hsls":"none",
"olsr":"none",
"table":"none",
"ldp":"none",
"vnc":"none",
"vnc-direct":"none",
"vnc-rn":"none",
"bgp-direct":"none",
"bgp-direct-to-nve-groups":"none",
"babel":"none",
"sharp":"none",
"pbr":"none",
"bfd":"none",
"openfabric":"none",
"vrrp":"none",
"zebra":"none",
"frr":"none",
"wildcard":"none",
"any":"none"
}
},
"sym_1":{
"protocols":{
"system":"none",
"kernel":"none",
"connected":"none",
"static":"none",
"rip":"none",
"ripng":"none",
"ospf":"none",
"ospf6":"none",
"isis":"none",
"bgp":"bgp-policy",
"pim":"none",
"eigrp":"none",
"nhrp":"none",
"hsls":"none",
"olsr":"none",
"table":"none",
"ldp":"none",
"vnc":"none",
"vnc-direct":"none",
"vnc-rn":"none",
"bgp-direct":"none",
"bgp-direct-to-nve-groups":"none",
"babel":"none",
"sharp":"none",
"pbr":"none",
"bfd":"none",
"openfabric":"none",
"vrrp":"none",
"zebra":"none",
"frr":"none",
"wildcard":"none",
"any":"none"
}
}
}
}
tor-1# show ipv6 nht route-map vrf default json
{
"afi":"ipv6",
"vrfs":{
"default":{
"protocols":{
"system":"none",
"kernel":"kernel-policy",
"connected":"connected-policy",
"static":"none",
"rip":"none",
"ripng":"none",
"ospf":"none",
"ospf6":"none",
"isis":"none",
"bgp":"none",
"pim":"none",
"eigrp":"none",
"nhrp":"none",
"hsls":"none",
"olsr":"none",
"table":"none",
"ldp":"none",
"vnc":"none",
"vnc-direct":"none",
"vnc-rn":"none",
"bgp-direct":"none",
"bgp-direct-to-nve-groups":"none",
"babel":"none",
"sharp":"none",
"pbr":"none",
"bfd":"none",
"openfabric":"none",
"vrrp":"none",
"zebra":"none",
"frr":"none",
"wildcard":"none",
"any":"none"
}
}
}
}
Ticket:#3229016
Issue:3229016
Signed-off-by: Sindhu Parvathi Gopinathan <sgopinathan@nvidia.com>
2022-11-08 06:40:13 +01:00
|
|
|
json_object_string_add(json, "any",
|
|
|
|
NHT_RM_NAME(zvrf, af_type, i));
|
|
|
|
else
|
|
|
|
json_object_string_add(json, "any", "none");
|
|
|
|
} else {
|
|
|
|
if (NHT_RM_NAME(zvrf, af_type, i))
|
|
|
|
vty_out(vty, "%-24s : %-10s\n", "any",
|
2018-10-11 19:49:34 +02:00
|
|
|
NHT_RM_NAME(zvrf, af_type, i));
|
|
|
|
else
|
zebra: json support for show ip nht route-map
Changes:
JSON support added for below commands,
- show ip nht route-map vrf all json
- show ip nht route-map vrf <name> json
- show ipv6 nht route-map vrf all json
- show ipv6 nht route-map vrf <name> json
- show ipv6 nht route-map json
- show ip nht route-map json
Testing Done: Unit testing completed.
tor-1# show ip nht route-map vrf default json
{
"afi":"ipv4",
"vrfs":{
"default":{
"protocols":{
"system":"none",
"kernel":"none",
"connected":"connected-policy",
"static":"none",
"rip":"none",
"ripng":"none",
"ospf":"none",
"ospf6":"none",
"isis":"none",
"bgp":"bgp-policy",
"pim":"none",
"eigrp":"none",
"nhrp":"none",
"hsls":"none",
"olsr":"none",
"table":"none",
"ldp":"none",
"vnc":"none",
"vnc-direct":"none",
"vnc-rn":"none",
"bgp-direct":"none",
"bgp-direct-to-nve-groups":"none",
"babel":"none",
"sharp":"none",
"pbr":"none",
"bfd":"none",
"openfabric":"none",
"vrrp":"none",
"zebra":"none",
"frr":"none",
"wildcard":"none",
"any":"none"
}
}
}
}
tor-1# show ip nht route-map vrf all json
{
"afi":"ipv4",
"vrfs":{
"default":{
"protocols":{
"system":"none",
"kernel":"none",
"connected":"connected-policy",
"static":"none",
"rip":"none",
"ripng":"none",
"ospf":"none",
"ospf6":"none",
"isis":"none",
"bgp":"bgp-policy",
"pim":"none",
"eigrp":"none",
"nhrp":"none",
"hsls":"none",
"olsr":"none",
"table":"none",
"ldp":"none",
"vnc":"none",
"vnc-direct":"none",
"vnc-rn":"none",
"bgp-direct":"none",
"bgp-direct-to-nve-groups":"none",
"babel":"none",
"sharp":"none",
"pbr":"none",
"bfd":"none",
"openfabric":"none",
"vrrp":"none",
"zebra":"none",
"frr":"none",
"wildcard":"none",
"any":"none"
}
},
"mgmt":{
"protocols":{
"system":"none",
"kernel":"none",
"connected":"none",
"static":"none",
"rip":"none",
"ripng":"none",
"ospf":"none",
"ospf6":"none",
"isis":"none",
"bgp":"none",
"pim":"none",
"eigrp":"none",
"nhrp":"none",
"hsls":"none",
"olsr":"none",
"table":"none",
"ldp":"none",
"vnc":"none",
"vnc-direct":"none",
"vnc-rn":"none",
"bgp-direct":"none",
"bgp-direct-to-nve-groups":"none",
"babel":"none",
"sharp":"none",
"pbr":"none",
"bfd":"none",
"openfabric":"none",
"vrrp":"none",
"zebra":"none",
"frr":"none",
"wildcard":"none",
"any":"none"
}
},
"sym_1":{
"protocols":{
"system":"none",
"kernel":"none",
"connected":"none",
"static":"none",
"rip":"none",
"ripng":"none",
"ospf":"none",
"ospf6":"none",
"isis":"none",
"bgp":"bgp-policy",
"pim":"none",
"eigrp":"none",
"nhrp":"none",
"hsls":"none",
"olsr":"none",
"table":"none",
"ldp":"none",
"vnc":"none",
"vnc-direct":"none",
"vnc-rn":"none",
"bgp-direct":"none",
"bgp-direct-to-nve-groups":"none",
"babel":"none",
"sharp":"none",
"pbr":"none",
"bfd":"none",
"openfabric":"none",
"vrrp":"none",
"zebra":"none",
"frr":"none",
"wildcard":"none",
"any":"none"
}
}
}
}
tor-1# show ipv6 nht route-map vrf default json
{
"afi":"ipv6",
"vrfs":{
"default":{
"protocols":{
"system":"none",
"kernel":"kernel-policy",
"connected":"connected-policy",
"static":"none",
"rip":"none",
"ripng":"none",
"ospf":"none",
"ospf6":"none",
"isis":"none",
"bgp":"none",
"pim":"none",
"eigrp":"none",
"nhrp":"none",
"hsls":"none",
"olsr":"none",
"table":"none",
"ldp":"none",
"vnc":"none",
"vnc-direct":"none",
"vnc-rn":"none",
"bgp-direct":"none",
"bgp-direct-to-nve-groups":"none",
"babel":"none",
"sharp":"none",
"pbr":"none",
"bfd":"none",
"openfabric":"none",
"vrrp":"none",
"zebra":"none",
"frr":"none",
"wildcard":"none",
"any":"none"
}
}
}
}
Ticket:#3229016
Issue:3229016
Signed-off-by: Sindhu Parvathi Gopinathan <sgopinathan@nvidia.com>
2022-11-08 06:40:13 +01:00
|
|
|
vty_out(vty, "%-24s : none\n", "any");
|
2018-10-11 19:49:34 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int show_proto_rm(struct vty *vty, int af_type, const char *vrf_all,
|
|
|
|
const char *vrf_name)
|
|
|
|
{
|
|
|
|
struct zebra_vrf *zvrf;
|
|
|
|
|
|
|
|
if (vrf_all) {
|
|
|
|
struct vrf *vrf;
|
|
|
|
|
|
|
|
RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) {
|
|
|
|
zvrf = (struct zebra_vrf *)vrf->info;
|
|
|
|
if (zvrf == NULL)
|
|
|
|
continue;
|
|
|
|
vty_out(vty, "VRF: %s\n", zvrf->vrf->name);
|
|
|
|
show_vrf_proto_rm(vty, zvrf, af_type);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
vrf_id_t vrf_id = VRF_DEFAULT;
|
|
|
|
|
|
|
|
if (vrf_name)
|
|
|
|
VRF_GET_ID(vrf_id, vrf_name, false);
|
|
|
|
|
|
|
|
zvrf = zebra_vrf_lookup_by_id(vrf_id);
|
|
|
|
if (!zvrf)
|
|
|
|
return CMD_SUCCESS;
|
|
|
|
|
|
|
|
vty_out(vty, "VRF: %s\n", zvrf->vrf->name);
|
|
|
|
show_vrf_proto_rm(vty, zvrf, af_type);
|
|
|
|
}
|
|
|
|
|
|
|
|
return CMD_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int show_nht_rm(struct vty *vty, int af_type, const char *vrf_all,
|
zebra: json support for show ip nht route-map
Changes:
JSON support added for below commands,
- show ip nht route-map vrf all json
- show ip nht route-map vrf <name> json
- show ipv6 nht route-map vrf all json
- show ipv6 nht route-map vrf <name> json
- show ipv6 nht route-map json
- show ip nht route-map json
Testing Done: Unit testing completed.
tor-1# show ip nht route-map vrf default json
{
"afi":"ipv4",
"vrfs":{
"default":{
"protocols":{
"system":"none",
"kernel":"none",
"connected":"connected-policy",
"static":"none",
"rip":"none",
"ripng":"none",
"ospf":"none",
"ospf6":"none",
"isis":"none",
"bgp":"bgp-policy",
"pim":"none",
"eigrp":"none",
"nhrp":"none",
"hsls":"none",
"olsr":"none",
"table":"none",
"ldp":"none",
"vnc":"none",
"vnc-direct":"none",
"vnc-rn":"none",
"bgp-direct":"none",
"bgp-direct-to-nve-groups":"none",
"babel":"none",
"sharp":"none",
"pbr":"none",
"bfd":"none",
"openfabric":"none",
"vrrp":"none",
"zebra":"none",
"frr":"none",
"wildcard":"none",
"any":"none"
}
}
}
}
tor-1# show ip nht route-map vrf all json
{
"afi":"ipv4",
"vrfs":{
"default":{
"protocols":{
"system":"none",
"kernel":"none",
"connected":"connected-policy",
"static":"none",
"rip":"none",
"ripng":"none",
"ospf":"none",
"ospf6":"none",
"isis":"none",
"bgp":"bgp-policy",
"pim":"none",
"eigrp":"none",
"nhrp":"none",
"hsls":"none",
"olsr":"none",
"table":"none",
"ldp":"none",
"vnc":"none",
"vnc-direct":"none",
"vnc-rn":"none",
"bgp-direct":"none",
"bgp-direct-to-nve-groups":"none",
"babel":"none",
"sharp":"none",
"pbr":"none",
"bfd":"none",
"openfabric":"none",
"vrrp":"none",
"zebra":"none",
"frr":"none",
"wildcard":"none",
"any":"none"
}
},
"mgmt":{
"protocols":{
"system":"none",
"kernel":"none",
"connected":"none",
"static":"none",
"rip":"none",
"ripng":"none",
"ospf":"none",
"ospf6":"none",
"isis":"none",
"bgp":"none",
"pim":"none",
"eigrp":"none",
"nhrp":"none",
"hsls":"none",
"olsr":"none",
"table":"none",
"ldp":"none",
"vnc":"none",
"vnc-direct":"none",
"vnc-rn":"none",
"bgp-direct":"none",
"bgp-direct-to-nve-groups":"none",
"babel":"none",
"sharp":"none",
"pbr":"none",
"bfd":"none",
"openfabric":"none",
"vrrp":"none",
"zebra":"none",
"frr":"none",
"wildcard":"none",
"any":"none"
}
},
"sym_1":{
"protocols":{
"system":"none",
"kernel":"none",
"connected":"none",
"static":"none",
"rip":"none",
"ripng":"none",
"ospf":"none",
"ospf6":"none",
"isis":"none",
"bgp":"bgp-policy",
"pim":"none",
"eigrp":"none",
"nhrp":"none",
"hsls":"none",
"olsr":"none",
"table":"none",
"ldp":"none",
"vnc":"none",
"vnc-direct":"none",
"vnc-rn":"none",
"bgp-direct":"none",
"bgp-direct-to-nve-groups":"none",
"babel":"none",
"sharp":"none",
"pbr":"none",
"bfd":"none",
"openfabric":"none",
"vrrp":"none",
"zebra":"none",
"frr":"none",
"wildcard":"none",
"any":"none"
}
}
}
}
tor-1# show ipv6 nht route-map vrf default json
{
"afi":"ipv6",
"vrfs":{
"default":{
"protocols":{
"system":"none",
"kernel":"kernel-policy",
"connected":"connected-policy",
"static":"none",
"rip":"none",
"ripng":"none",
"ospf":"none",
"ospf6":"none",
"isis":"none",
"bgp":"none",
"pim":"none",
"eigrp":"none",
"nhrp":"none",
"hsls":"none",
"olsr":"none",
"table":"none",
"ldp":"none",
"vnc":"none",
"vnc-direct":"none",
"vnc-rn":"none",
"bgp-direct":"none",
"bgp-direct-to-nve-groups":"none",
"babel":"none",
"sharp":"none",
"pbr":"none",
"bfd":"none",
"openfabric":"none",
"vrrp":"none",
"zebra":"none",
"frr":"none",
"wildcard":"none",
"any":"none"
}
}
}
}
Ticket:#3229016
Issue:3229016
Signed-off-by: Sindhu Parvathi Gopinathan <sgopinathan@nvidia.com>
2022-11-08 06:40:13 +01:00
|
|
|
const char *vrf_name, bool use_json)
|
2018-10-11 19:49:34 +02:00
|
|
|
{
|
|
|
|
struct zebra_vrf *zvrf;
|
zebra: json support for show ip nht route-map
Changes:
JSON support added for below commands,
- show ip nht route-map vrf all json
- show ip nht route-map vrf <name> json
- show ipv6 nht route-map vrf all json
- show ipv6 nht route-map vrf <name> json
- show ipv6 nht route-map json
- show ip nht route-map json
Testing Done: Unit testing completed.
tor-1# show ip nht route-map vrf default json
{
"afi":"ipv4",
"vrfs":{
"default":{
"protocols":{
"system":"none",
"kernel":"none",
"connected":"connected-policy",
"static":"none",
"rip":"none",
"ripng":"none",
"ospf":"none",
"ospf6":"none",
"isis":"none",
"bgp":"bgp-policy",
"pim":"none",
"eigrp":"none",
"nhrp":"none",
"hsls":"none",
"olsr":"none",
"table":"none",
"ldp":"none",
"vnc":"none",
"vnc-direct":"none",
"vnc-rn":"none",
"bgp-direct":"none",
"bgp-direct-to-nve-groups":"none",
"babel":"none",
"sharp":"none",
"pbr":"none",
"bfd":"none",
"openfabric":"none",
"vrrp":"none",
"zebra":"none",
"frr":"none",
"wildcard":"none",
"any":"none"
}
}
}
}
tor-1# show ip nht route-map vrf all json
{
"afi":"ipv4",
"vrfs":{
"default":{
"protocols":{
"system":"none",
"kernel":"none",
"connected":"connected-policy",
"static":"none",
"rip":"none",
"ripng":"none",
"ospf":"none",
"ospf6":"none",
"isis":"none",
"bgp":"bgp-policy",
"pim":"none",
"eigrp":"none",
"nhrp":"none",
"hsls":"none",
"olsr":"none",
"table":"none",
"ldp":"none",
"vnc":"none",
"vnc-direct":"none",
"vnc-rn":"none",
"bgp-direct":"none",
"bgp-direct-to-nve-groups":"none",
"babel":"none",
"sharp":"none",
"pbr":"none",
"bfd":"none",
"openfabric":"none",
"vrrp":"none",
"zebra":"none",
"frr":"none",
"wildcard":"none",
"any":"none"
}
},
"mgmt":{
"protocols":{
"system":"none",
"kernel":"none",
"connected":"none",
"static":"none",
"rip":"none",
"ripng":"none",
"ospf":"none",
"ospf6":"none",
"isis":"none",
"bgp":"none",
"pim":"none",
"eigrp":"none",
"nhrp":"none",
"hsls":"none",
"olsr":"none",
"table":"none",
"ldp":"none",
"vnc":"none",
"vnc-direct":"none",
"vnc-rn":"none",
"bgp-direct":"none",
"bgp-direct-to-nve-groups":"none",
"babel":"none",
"sharp":"none",
"pbr":"none",
"bfd":"none",
"openfabric":"none",
"vrrp":"none",
"zebra":"none",
"frr":"none",
"wildcard":"none",
"any":"none"
}
},
"sym_1":{
"protocols":{
"system":"none",
"kernel":"none",
"connected":"none",
"static":"none",
"rip":"none",
"ripng":"none",
"ospf":"none",
"ospf6":"none",
"isis":"none",
"bgp":"bgp-policy",
"pim":"none",
"eigrp":"none",
"nhrp":"none",
"hsls":"none",
"olsr":"none",
"table":"none",
"ldp":"none",
"vnc":"none",
"vnc-direct":"none",
"vnc-rn":"none",
"bgp-direct":"none",
"bgp-direct-to-nve-groups":"none",
"babel":"none",
"sharp":"none",
"pbr":"none",
"bfd":"none",
"openfabric":"none",
"vrrp":"none",
"zebra":"none",
"frr":"none",
"wildcard":"none",
"any":"none"
}
}
}
}
tor-1# show ipv6 nht route-map vrf default json
{
"afi":"ipv6",
"vrfs":{
"default":{
"protocols":{
"system":"none",
"kernel":"kernel-policy",
"connected":"connected-policy",
"static":"none",
"rip":"none",
"ripng":"none",
"ospf":"none",
"ospf6":"none",
"isis":"none",
"bgp":"none",
"pim":"none",
"eigrp":"none",
"nhrp":"none",
"hsls":"none",
"olsr":"none",
"table":"none",
"ldp":"none",
"vnc":"none",
"vnc-direct":"none",
"vnc-rn":"none",
"bgp-direct":"none",
"bgp-direct-to-nve-groups":"none",
"babel":"none",
"sharp":"none",
"pbr":"none",
"bfd":"none",
"openfabric":"none",
"vrrp":"none",
"zebra":"none",
"frr":"none",
"wildcard":"none",
"any":"none"
}
}
}
}
Ticket:#3229016
Issue:3229016
Signed-off-by: Sindhu Parvathi Gopinathan <sgopinathan@nvidia.com>
2022-11-08 06:40:13 +01:00
|
|
|
json_object *json = NULL;
|
|
|
|
json_object *json_vrfs = NULL;
|
|
|
|
|
|
|
|
if (use_json) {
|
|
|
|
json = json_object_new_object();
|
|
|
|
json_vrfs = json_object_new_object();
|
|
|
|
json_object_string_add(json, "afi",
|
|
|
|
(af_type == AFI_IP) ? "ipv4" : "ipv6");
|
|
|
|
}
|
2018-10-11 19:49:34 +02:00
|
|
|
|
|
|
|
if (vrf_all) {
|
|
|
|
struct vrf *vrf;
|
|
|
|
|
zebra: json support for show ip nht route-map
Changes:
JSON support added for below commands,
- show ip nht route-map vrf all json
- show ip nht route-map vrf <name> json
- show ipv6 nht route-map vrf all json
- show ipv6 nht route-map vrf <name> json
- show ipv6 nht route-map json
- show ip nht route-map json
Testing Done: Unit testing completed.
tor-1# show ip nht route-map vrf default json
{
"afi":"ipv4",
"vrfs":{
"default":{
"protocols":{
"system":"none",
"kernel":"none",
"connected":"connected-policy",
"static":"none",
"rip":"none",
"ripng":"none",
"ospf":"none",
"ospf6":"none",
"isis":"none",
"bgp":"bgp-policy",
"pim":"none",
"eigrp":"none",
"nhrp":"none",
"hsls":"none",
"olsr":"none",
"table":"none",
"ldp":"none",
"vnc":"none",
"vnc-direct":"none",
"vnc-rn":"none",
"bgp-direct":"none",
"bgp-direct-to-nve-groups":"none",
"babel":"none",
"sharp":"none",
"pbr":"none",
"bfd":"none",
"openfabric":"none",
"vrrp":"none",
"zebra":"none",
"frr":"none",
"wildcard":"none",
"any":"none"
}
}
}
}
tor-1# show ip nht route-map vrf all json
{
"afi":"ipv4",
"vrfs":{
"default":{
"protocols":{
"system":"none",
"kernel":"none",
"connected":"connected-policy",
"static":"none",
"rip":"none",
"ripng":"none",
"ospf":"none",
"ospf6":"none",
"isis":"none",
"bgp":"bgp-policy",
"pim":"none",
"eigrp":"none",
"nhrp":"none",
"hsls":"none",
"olsr":"none",
"table":"none",
"ldp":"none",
"vnc":"none",
"vnc-direct":"none",
"vnc-rn":"none",
"bgp-direct":"none",
"bgp-direct-to-nve-groups":"none",
"babel":"none",
"sharp":"none",
"pbr":"none",
"bfd":"none",
"openfabric":"none",
"vrrp":"none",
"zebra":"none",
"frr":"none",
"wildcard":"none",
"any":"none"
}
},
"mgmt":{
"protocols":{
"system":"none",
"kernel":"none",
"connected":"none",
"static":"none",
"rip":"none",
"ripng":"none",
"ospf":"none",
"ospf6":"none",
"isis":"none",
"bgp":"none",
"pim":"none",
"eigrp":"none",
"nhrp":"none",
"hsls":"none",
"olsr":"none",
"table":"none",
"ldp":"none",
"vnc":"none",
"vnc-direct":"none",
"vnc-rn":"none",
"bgp-direct":"none",
"bgp-direct-to-nve-groups":"none",
"babel":"none",
"sharp":"none",
"pbr":"none",
"bfd":"none",
"openfabric":"none",
"vrrp":"none",
"zebra":"none",
"frr":"none",
"wildcard":"none",
"any":"none"
}
},
"sym_1":{
"protocols":{
"system":"none",
"kernel":"none",
"connected":"none",
"static":"none",
"rip":"none",
"ripng":"none",
"ospf":"none",
"ospf6":"none",
"isis":"none",
"bgp":"bgp-policy",
"pim":"none",
"eigrp":"none",
"nhrp":"none",
"hsls":"none",
"olsr":"none",
"table":"none",
"ldp":"none",
"vnc":"none",
"vnc-direct":"none",
"vnc-rn":"none",
"bgp-direct":"none",
"bgp-direct-to-nve-groups":"none",
"babel":"none",
"sharp":"none",
"pbr":"none",
"bfd":"none",
"openfabric":"none",
"vrrp":"none",
"zebra":"none",
"frr":"none",
"wildcard":"none",
"any":"none"
}
}
}
}
tor-1# show ipv6 nht route-map vrf default json
{
"afi":"ipv6",
"vrfs":{
"default":{
"protocols":{
"system":"none",
"kernel":"kernel-policy",
"connected":"connected-policy",
"static":"none",
"rip":"none",
"ripng":"none",
"ospf":"none",
"ospf6":"none",
"isis":"none",
"bgp":"none",
"pim":"none",
"eigrp":"none",
"nhrp":"none",
"hsls":"none",
"olsr":"none",
"table":"none",
"ldp":"none",
"vnc":"none",
"vnc-direct":"none",
"vnc-rn":"none",
"bgp-direct":"none",
"bgp-direct-to-nve-groups":"none",
"babel":"none",
"sharp":"none",
"pbr":"none",
"bfd":"none",
"openfabric":"none",
"vrrp":"none",
"zebra":"none",
"frr":"none",
"wildcard":"none",
"any":"none"
}
}
}
}
Ticket:#3229016
Issue:3229016
Signed-off-by: Sindhu Parvathi Gopinathan <sgopinathan@nvidia.com>
2022-11-08 06:40:13 +01:00
|
|
|
if (use_json)
|
|
|
|
json_object_object_add(json, "vrfs", json_vrfs);
|
|
|
|
|
2018-10-11 19:49:34 +02:00
|
|
|
RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) {
|
|
|
|
zvrf = (struct zebra_vrf *)vrf->info;
|
|
|
|
if (zvrf == NULL)
|
|
|
|
continue;
|
|
|
|
|
zebra: json support for show ip nht route-map
Changes:
JSON support added for below commands,
- show ip nht route-map vrf all json
- show ip nht route-map vrf <name> json
- show ipv6 nht route-map vrf all json
- show ipv6 nht route-map vrf <name> json
- show ipv6 nht route-map json
- show ip nht route-map json
Testing Done: Unit testing completed.
tor-1# show ip nht route-map vrf default json
{
"afi":"ipv4",
"vrfs":{
"default":{
"protocols":{
"system":"none",
"kernel":"none",
"connected":"connected-policy",
"static":"none",
"rip":"none",
"ripng":"none",
"ospf":"none",
"ospf6":"none",
"isis":"none",
"bgp":"bgp-policy",
"pim":"none",
"eigrp":"none",
"nhrp":"none",
"hsls":"none",
"olsr":"none",
"table":"none",
"ldp":"none",
"vnc":"none",
"vnc-direct":"none",
"vnc-rn":"none",
"bgp-direct":"none",
"bgp-direct-to-nve-groups":"none",
"babel":"none",
"sharp":"none",
"pbr":"none",
"bfd":"none",
"openfabric":"none",
"vrrp":"none",
"zebra":"none",
"frr":"none",
"wildcard":"none",
"any":"none"
}
}
}
}
tor-1# show ip nht route-map vrf all json
{
"afi":"ipv4",
"vrfs":{
"default":{
"protocols":{
"system":"none",
"kernel":"none",
"connected":"connected-policy",
"static":"none",
"rip":"none",
"ripng":"none",
"ospf":"none",
"ospf6":"none",
"isis":"none",
"bgp":"bgp-policy",
"pim":"none",
"eigrp":"none",
"nhrp":"none",
"hsls":"none",
"olsr":"none",
"table":"none",
"ldp":"none",
"vnc":"none",
"vnc-direct":"none",
"vnc-rn":"none",
"bgp-direct":"none",
"bgp-direct-to-nve-groups":"none",
"babel":"none",
"sharp":"none",
"pbr":"none",
"bfd":"none",
"openfabric":"none",
"vrrp":"none",
"zebra":"none",
"frr":"none",
"wildcard":"none",
"any":"none"
}
},
"mgmt":{
"protocols":{
"system":"none",
"kernel":"none",
"connected":"none",
"static":"none",
"rip":"none",
"ripng":"none",
"ospf":"none",
"ospf6":"none",
"isis":"none",
"bgp":"none",
"pim":"none",
"eigrp":"none",
"nhrp":"none",
"hsls":"none",
"olsr":"none",
"table":"none",
"ldp":"none",
"vnc":"none",
"vnc-direct":"none",
"vnc-rn":"none",
"bgp-direct":"none",
"bgp-direct-to-nve-groups":"none",
"babel":"none",
"sharp":"none",
"pbr":"none",
"bfd":"none",
"openfabric":"none",
"vrrp":"none",
"zebra":"none",
"frr":"none",
"wildcard":"none",
"any":"none"
}
},
"sym_1":{
"protocols":{
"system":"none",
"kernel":"none",
"connected":"none",
"static":"none",
"rip":"none",
"ripng":"none",
"ospf":"none",
"ospf6":"none",
"isis":"none",
"bgp":"bgp-policy",
"pim":"none",
"eigrp":"none",
"nhrp":"none",
"hsls":"none",
"olsr":"none",
"table":"none",
"ldp":"none",
"vnc":"none",
"vnc-direct":"none",
"vnc-rn":"none",
"bgp-direct":"none",
"bgp-direct-to-nve-groups":"none",
"babel":"none",
"sharp":"none",
"pbr":"none",
"bfd":"none",
"openfabric":"none",
"vrrp":"none",
"zebra":"none",
"frr":"none",
"wildcard":"none",
"any":"none"
}
}
}
}
tor-1# show ipv6 nht route-map vrf default json
{
"afi":"ipv6",
"vrfs":{
"default":{
"protocols":{
"system":"none",
"kernel":"kernel-policy",
"connected":"connected-policy",
"static":"none",
"rip":"none",
"ripng":"none",
"ospf":"none",
"ospf6":"none",
"isis":"none",
"bgp":"none",
"pim":"none",
"eigrp":"none",
"nhrp":"none",
"hsls":"none",
"olsr":"none",
"table":"none",
"ldp":"none",
"vnc":"none",
"vnc-direct":"none",
"vnc-rn":"none",
"bgp-direct":"none",
"bgp-direct-to-nve-groups":"none",
"babel":"none",
"sharp":"none",
"pbr":"none",
"bfd":"none",
"openfabric":"none",
"vrrp":"none",
"zebra":"none",
"frr":"none",
"wildcard":"none",
"any":"none"
}
}
}
}
Ticket:#3229016
Issue:3229016
Signed-off-by: Sindhu Parvathi Gopinathan <sgopinathan@nvidia.com>
2022-11-08 06:40:13 +01:00
|
|
|
if (use_json) {
|
|
|
|
json_object *json_proto = NULL;
|
|
|
|
json_object *json_vrf = NULL;
|
|
|
|
json_vrf = json_object_new_object();
|
|
|
|
json_object_object_add(
|
|
|
|
json_vrfs, zvrf->vrf->name, json_vrf);
|
|
|
|
json_proto = json_object_new_object();
|
|
|
|
json_object_object_add(json_vrf, "protocols",
|
|
|
|
json_proto);
|
|
|
|
show_vrf_nht_rm(vty, zvrf, af_type, json_proto);
|
|
|
|
} else {
|
|
|
|
vty_out(vty, "VRF: %s\n", zvrf->vrf->name);
|
|
|
|
show_vrf_nht_rm(vty, zvrf, af_type, NULL);
|
|
|
|
}
|
2018-10-11 19:49:34 +02:00
|
|
|
}
|
|
|
|
} else {
|
zebra: json support for show ip nht route-map
Changes:
JSON support added for below commands,
- show ip nht route-map vrf all json
- show ip nht route-map vrf <name> json
- show ipv6 nht route-map vrf all json
- show ipv6 nht route-map vrf <name> json
- show ipv6 nht route-map json
- show ip nht route-map json
Testing Done: Unit testing completed.
tor-1# show ip nht route-map vrf default json
{
"afi":"ipv4",
"vrfs":{
"default":{
"protocols":{
"system":"none",
"kernel":"none",
"connected":"connected-policy",
"static":"none",
"rip":"none",
"ripng":"none",
"ospf":"none",
"ospf6":"none",
"isis":"none",
"bgp":"bgp-policy",
"pim":"none",
"eigrp":"none",
"nhrp":"none",
"hsls":"none",
"olsr":"none",
"table":"none",
"ldp":"none",
"vnc":"none",
"vnc-direct":"none",
"vnc-rn":"none",
"bgp-direct":"none",
"bgp-direct-to-nve-groups":"none",
"babel":"none",
"sharp":"none",
"pbr":"none",
"bfd":"none",
"openfabric":"none",
"vrrp":"none",
"zebra":"none",
"frr":"none",
"wildcard":"none",
"any":"none"
}
}
}
}
tor-1# show ip nht route-map vrf all json
{
"afi":"ipv4",
"vrfs":{
"default":{
"protocols":{
"system":"none",
"kernel":"none",
"connected":"connected-policy",
"static":"none",
"rip":"none",
"ripng":"none",
"ospf":"none",
"ospf6":"none",
"isis":"none",
"bgp":"bgp-policy",
"pim":"none",
"eigrp":"none",
"nhrp":"none",
"hsls":"none",
"olsr":"none",
"table":"none",
"ldp":"none",
"vnc":"none",
"vnc-direct":"none",
"vnc-rn":"none",
"bgp-direct":"none",
"bgp-direct-to-nve-groups":"none",
"babel":"none",
"sharp":"none",
"pbr":"none",
"bfd":"none",
"openfabric":"none",
"vrrp":"none",
"zebra":"none",
"frr":"none",
"wildcard":"none",
"any":"none"
}
},
"mgmt":{
"protocols":{
"system":"none",
"kernel":"none",
"connected":"none",
"static":"none",
"rip":"none",
"ripng":"none",
"ospf":"none",
"ospf6":"none",
"isis":"none",
"bgp":"none",
"pim":"none",
"eigrp":"none",
"nhrp":"none",
"hsls":"none",
"olsr":"none",
"table":"none",
"ldp":"none",
"vnc":"none",
"vnc-direct":"none",
"vnc-rn":"none",
"bgp-direct":"none",
"bgp-direct-to-nve-groups":"none",
"babel":"none",
"sharp":"none",
"pbr":"none",
"bfd":"none",
"openfabric":"none",
"vrrp":"none",
"zebra":"none",
"frr":"none",
"wildcard":"none",
"any":"none"
}
},
"sym_1":{
"protocols":{
"system":"none",
"kernel":"none",
"connected":"none",
"static":"none",
"rip":"none",
"ripng":"none",
"ospf":"none",
"ospf6":"none",
"isis":"none",
"bgp":"bgp-policy",
"pim":"none",
"eigrp":"none",
"nhrp":"none",
"hsls":"none",
"olsr":"none",
"table":"none",
"ldp":"none",
"vnc":"none",
"vnc-direct":"none",
"vnc-rn":"none",
"bgp-direct":"none",
"bgp-direct-to-nve-groups":"none",
"babel":"none",
"sharp":"none",
"pbr":"none",
"bfd":"none",
"openfabric":"none",
"vrrp":"none",
"zebra":"none",
"frr":"none",
"wildcard":"none",
"any":"none"
}
}
}
}
tor-1# show ipv6 nht route-map vrf default json
{
"afi":"ipv6",
"vrfs":{
"default":{
"protocols":{
"system":"none",
"kernel":"kernel-policy",
"connected":"connected-policy",
"static":"none",
"rip":"none",
"ripng":"none",
"ospf":"none",
"ospf6":"none",
"isis":"none",
"bgp":"none",
"pim":"none",
"eigrp":"none",
"nhrp":"none",
"hsls":"none",
"olsr":"none",
"table":"none",
"ldp":"none",
"vnc":"none",
"vnc-direct":"none",
"vnc-rn":"none",
"bgp-direct":"none",
"bgp-direct-to-nve-groups":"none",
"babel":"none",
"sharp":"none",
"pbr":"none",
"bfd":"none",
"openfabric":"none",
"vrrp":"none",
"zebra":"none",
"frr":"none",
"wildcard":"none",
"any":"none"
}
}
}
}
Ticket:#3229016
Issue:3229016
Signed-off-by: Sindhu Parvathi Gopinathan <sgopinathan@nvidia.com>
2022-11-08 06:40:13 +01:00
|
|
|
json_object *json_proto = NULL;
|
|
|
|
json_object *json_vrf = NULL;
|
2018-10-11 19:49:34 +02:00
|
|
|
vrf_id_t vrf_id = VRF_DEFAULT;
|
|
|
|
|
|
|
|
if (vrf_name)
|
|
|
|
VRF_GET_ID(vrf_id, vrf_name, false);
|
|
|
|
|
|
|
|
zvrf = zebra_vrf_lookup_by_id(vrf_id);
|
zebra: json support for show ip nht route-map
Changes:
JSON support added for below commands,
- show ip nht route-map vrf all json
- show ip nht route-map vrf <name> json
- show ipv6 nht route-map vrf all json
- show ipv6 nht route-map vrf <name> json
- show ipv6 nht route-map json
- show ip nht route-map json
Testing Done: Unit testing completed.
tor-1# show ip nht route-map vrf default json
{
"afi":"ipv4",
"vrfs":{
"default":{
"protocols":{
"system":"none",
"kernel":"none",
"connected":"connected-policy",
"static":"none",
"rip":"none",
"ripng":"none",
"ospf":"none",
"ospf6":"none",
"isis":"none",
"bgp":"bgp-policy",
"pim":"none",
"eigrp":"none",
"nhrp":"none",
"hsls":"none",
"olsr":"none",
"table":"none",
"ldp":"none",
"vnc":"none",
"vnc-direct":"none",
"vnc-rn":"none",
"bgp-direct":"none",
"bgp-direct-to-nve-groups":"none",
"babel":"none",
"sharp":"none",
"pbr":"none",
"bfd":"none",
"openfabric":"none",
"vrrp":"none",
"zebra":"none",
"frr":"none",
"wildcard":"none",
"any":"none"
}
}
}
}
tor-1# show ip nht route-map vrf all json
{
"afi":"ipv4",
"vrfs":{
"default":{
"protocols":{
"system":"none",
"kernel":"none",
"connected":"connected-policy",
"static":"none",
"rip":"none",
"ripng":"none",
"ospf":"none",
"ospf6":"none",
"isis":"none",
"bgp":"bgp-policy",
"pim":"none",
"eigrp":"none",
"nhrp":"none",
"hsls":"none",
"olsr":"none",
"table":"none",
"ldp":"none",
"vnc":"none",
"vnc-direct":"none",
"vnc-rn":"none",
"bgp-direct":"none",
"bgp-direct-to-nve-groups":"none",
"babel":"none",
"sharp":"none",
"pbr":"none",
"bfd":"none",
"openfabric":"none",
"vrrp":"none",
"zebra":"none",
"frr":"none",
"wildcard":"none",
"any":"none"
}
},
"mgmt":{
"protocols":{
"system":"none",
"kernel":"none",
"connected":"none",
"static":"none",
"rip":"none",
"ripng":"none",
"ospf":"none",
"ospf6":"none",
"isis":"none",
"bgp":"none",
"pim":"none",
"eigrp":"none",
"nhrp":"none",
"hsls":"none",
"olsr":"none",
"table":"none",
"ldp":"none",
"vnc":"none",
"vnc-direct":"none",
"vnc-rn":"none",
"bgp-direct":"none",
"bgp-direct-to-nve-groups":"none",
"babel":"none",
"sharp":"none",
"pbr":"none",
"bfd":"none",
"openfabric":"none",
"vrrp":"none",
"zebra":"none",
"frr":"none",
"wildcard":"none",
"any":"none"
}
},
"sym_1":{
"protocols":{
"system":"none",
"kernel":"none",
"connected":"none",
"static":"none",
"rip":"none",
"ripng":"none",
"ospf":"none",
"ospf6":"none",
"isis":"none",
"bgp":"bgp-policy",
"pim":"none",
"eigrp":"none",
"nhrp":"none",
"hsls":"none",
"olsr":"none",
"table":"none",
"ldp":"none",
"vnc":"none",
"vnc-direct":"none",
"vnc-rn":"none",
"bgp-direct":"none",
"bgp-direct-to-nve-groups":"none",
"babel":"none",
"sharp":"none",
"pbr":"none",
"bfd":"none",
"openfabric":"none",
"vrrp":"none",
"zebra":"none",
"frr":"none",
"wildcard":"none",
"any":"none"
}
}
}
}
tor-1# show ipv6 nht route-map vrf default json
{
"afi":"ipv6",
"vrfs":{
"default":{
"protocols":{
"system":"none",
"kernel":"kernel-policy",
"connected":"connected-policy",
"static":"none",
"rip":"none",
"ripng":"none",
"ospf":"none",
"ospf6":"none",
"isis":"none",
"bgp":"none",
"pim":"none",
"eigrp":"none",
"nhrp":"none",
"hsls":"none",
"olsr":"none",
"table":"none",
"ldp":"none",
"vnc":"none",
"vnc-direct":"none",
"vnc-rn":"none",
"bgp-direct":"none",
"bgp-direct-to-nve-groups":"none",
"babel":"none",
"sharp":"none",
"pbr":"none",
"bfd":"none",
"openfabric":"none",
"vrrp":"none",
"zebra":"none",
"frr":"none",
"wildcard":"none",
"any":"none"
}
}
}
}
Ticket:#3229016
Issue:3229016
Signed-off-by: Sindhu Parvathi Gopinathan <sgopinathan@nvidia.com>
2022-11-08 06:40:13 +01:00
|
|
|
if (!zvrf) {
|
|
|
|
json_object_free(json);
|
|
|
|
json_object_free(json_vrfs);
|
2018-10-11 19:49:34 +02:00
|
|
|
return CMD_SUCCESS;
|
zebra: json support for show ip nht route-map
Changes:
JSON support added for below commands,
- show ip nht route-map vrf all json
- show ip nht route-map vrf <name> json
- show ipv6 nht route-map vrf all json
- show ipv6 nht route-map vrf <name> json
- show ipv6 nht route-map json
- show ip nht route-map json
Testing Done: Unit testing completed.
tor-1# show ip nht route-map vrf default json
{
"afi":"ipv4",
"vrfs":{
"default":{
"protocols":{
"system":"none",
"kernel":"none",
"connected":"connected-policy",
"static":"none",
"rip":"none",
"ripng":"none",
"ospf":"none",
"ospf6":"none",
"isis":"none",
"bgp":"bgp-policy",
"pim":"none",
"eigrp":"none",
"nhrp":"none",
"hsls":"none",
"olsr":"none",
"table":"none",
"ldp":"none",
"vnc":"none",
"vnc-direct":"none",
"vnc-rn":"none",
"bgp-direct":"none",
"bgp-direct-to-nve-groups":"none",
"babel":"none",
"sharp":"none",
"pbr":"none",
"bfd":"none",
"openfabric":"none",
"vrrp":"none",
"zebra":"none",
"frr":"none",
"wildcard":"none",
"any":"none"
}
}
}
}
tor-1# show ip nht route-map vrf all json
{
"afi":"ipv4",
"vrfs":{
"default":{
"protocols":{
"system":"none",
"kernel":"none",
"connected":"connected-policy",
"static":"none",
"rip":"none",
"ripng":"none",
"ospf":"none",
"ospf6":"none",
"isis":"none",
"bgp":"bgp-policy",
"pim":"none",
"eigrp":"none",
"nhrp":"none",
"hsls":"none",
"olsr":"none",
"table":"none",
"ldp":"none",
"vnc":"none",
"vnc-direct":"none",
"vnc-rn":"none",
"bgp-direct":"none",
"bgp-direct-to-nve-groups":"none",
"babel":"none",
"sharp":"none",
"pbr":"none",
"bfd":"none",
"openfabric":"none",
"vrrp":"none",
"zebra":"none",
"frr":"none",
"wildcard":"none",
"any":"none"
}
},
"mgmt":{
"protocols":{
"system":"none",
"kernel":"none",
"connected":"none",
"static":"none",
"rip":"none",
"ripng":"none",
"ospf":"none",
"ospf6":"none",
"isis":"none",
"bgp":"none",
"pim":"none",
"eigrp":"none",
"nhrp":"none",
"hsls":"none",
"olsr":"none",
"table":"none",
"ldp":"none",
"vnc":"none",
"vnc-direct":"none",
"vnc-rn":"none",
"bgp-direct":"none",
"bgp-direct-to-nve-groups":"none",
"babel":"none",
"sharp":"none",
"pbr":"none",
"bfd":"none",
"openfabric":"none",
"vrrp":"none",
"zebra":"none",
"frr":"none",
"wildcard":"none",
"any":"none"
}
},
"sym_1":{
"protocols":{
"system":"none",
"kernel":"none",
"connected":"none",
"static":"none",
"rip":"none",
"ripng":"none",
"ospf":"none",
"ospf6":"none",
"isis":"none",
"bgp":"bgp-policy",
"pim":"none",
"eigrp":"none",
"nhrp":"none",
"hsls":"none",
"olsr":"none",
"table":"none",
"ldp":"none",
"vnc":"none",
"vnc-direct":"none",
"vnc-rn":"none",
"bgp-direct":"none",
"bgp-direct-to-nve-groups":"none",
"babel":"none",
"sharp":"none",
"pbr":"none",
"bfd":"none",
"openfabric":"none",
"vrrp":"none",
"zebra":"none",
"frr":"none",
"wildcard":"none",
"any":"none"
}
}
}
}
tor-1# show ipv6 nht route-map vrf default json
{
"afi":"ipv6",
"vrfs":{
"default":{
"protocols":{
"system":"none",
"kernel":"kernel-policy",
"connected":"connected-policy",
"static":"none",
"rip":"none",
"ripng":"none",
"ospf":"none",
"ospf6":"none",
"isis":"none",
"bgp":"none",
"pim":"none",
"eigrp":"none",
"nhrp":"none",
"hsls":"none",
"olsr":"none",
"table":"none",
"ldp":"none",
"vnc":"none",
"vnc-direct":"none",
"vnc-rn":"none",
"bgp-direct":"none",
"bgp-direct-to-nve-groups":"none",
"babel":"none",
"sharp":"none",
"pbr":"none",
"bfd":"none",
"openfabric":"none",
"vrrp":"none",
"zebra":"none",
"frr":"none",
"wildcard":"none",
"any":"none"
}
}
}
}
Ticket:#3229016
Issue:3229016
Signed-off-by: Sindhu Parvathi Gopinathan <sgopinathan@nvidia.com>
2022-11-08 06:40:13 +01:00
|
|
|
}
|
2018-10-11 19:49:34 +02:00
|
|
|
|
zebra: json support for show ip nht route-map
Changes:
JSON support added for below commands,
- show ip nht route-map vrf all json
- show ip nht route-map vrf <name> json
- show ipv6 nht route-map vrf all json
- show ipv6 nht route-map vrf <name> json
- show ipv6 nht route-map json
- show ip nht route-map json
Testing Done: Unit testing completed.
tor-1# show ip nht route-map vrf default json
{
"afi":"ipv4",
"vrfs":{
"default":{
"protocols":{
"system":"none",
"kernel":"none",
"connected":"connected-policy",
"static":"none",
"rip":"none",
"ripng":"none",
"ospf":"none",
"ospf6":"none",
"isis":"none",
"bgp":"bgp-policy",
"pim":"none",
"eigrp":"none",
"nhrp":"none",
"hsls":"none",
"olsr":"none",
"table":"none",
"ldp":"none",
"vnc":"none",
"vnc-direct":"none",
"vnc-rn":"none",
"bgp-direct":"none",
"bgp-direct-to-nve-groups":"none",
"babel":"none",
"sharp":"none",
"pbr":"none",
"bfd":"none",
"openfabric":"none",
"vrrp":"none",
"zebra":"none",
"frr":"none",
"wildcard":"none",
"any":"none"
}
}
}
}
tor-1# show ip nht route-map vrf all json
{
"afi":"ipv4",
"vrfs":{
"default":{
"protocols":{
"system":"none",
"kernel":"none",
"connected":"connected-policy",
"static":"none",
"rip":"none",
"ripng":"none",
"ospf":"none",
"ospf6":"none",
"isis":"none",
"bgp":"bgp-policy",
"pim":"none",
"eigrp":"none",
"nhrp":"none",
"hsls":"none",
"olsr":"none",
"table":"none",
"ldp":"none",
"vnc":"none",
"vnc-direct":"none",
"vnc-rn":"none",
"bgp-direct":"none",
"bgp-direct-to-nve-groups":"none",
"babel":"none",
"sharp":"none",
"pbr":"none",
"bfd":"none",
"openfabric":"none",
"vrrp":"none",
"zebra":"none",
"frr":"none",
"wildcard":"none",
"any":"none"
}
},
"mgmt":{
"protocols":{
"system":"none",
"kernel":"none",
"connected":"none",
"static":"none",
"rip":"none",
"ripng":"none",
"ospf":"none",
"ospf6":"none",
"isis":"none",
"bgp":"none",
"pim":"none",
"eigrp":"none",
"nhrp":"none",
"hsls":"none",
"olsr":"none",
"table":"none",
"ldp":"none",
"vnc":"none",
"vnc-direct":"none",
"vnc-rn":"none",
"bgp-direct":"none",
"bgp-direct-to-nve-groups":"none",
"babel":"none",
"sharp":"none",
"pbr":"none",
"bfd":"none",
"openfabric":"none",
"vrrp":"none",
"zebra":"none",
"frr":"none",
"wildcard":"none",
"any":"none"
}
},
"sym_1":{
"protocols":{
"system":"none",
"kernel":"none",
"connected":"none",
"static":"none",
"rip":"none",
"ripng":"none",
"ospf":"none",
"ospf6":"none",
"isis":"none",
"bgp":"bgp-policy",
"pim":"none",
"eigrp":"none",
"nhrp":"none",
"hsls":"none",
"olsr":"none",
"table":"none",
"ldp":"none",
"vnc":"none",
"vnc-direct":"none",
"vnc-rn":"none",
"bgp-direct":"none",
"bgp-direct-to-nve-groups":"none",
"babel":"none",
"sharp":"none",
"pbr":"none",
"bfd":"none",
"openfabric":"none",
"vrrp":"none",
"zebra":"none",
"frr":"none",
"wildcard":"none",
"any":"none"
}
}
}
}
tor-1# show ipv6 nht route-map vrf default json
{
"afi":"ipv6",
"vrfs":{
"default":{
"protocols":{
"system":"none",
"kernel":"kernel-policy",
"connected":"connected-policy",
"static":"none",
"rip":"none",
"ripng":"none",
"ospf":"none",
"ospf6":"none",
"isis":"none",
"bgp":"none",
"pim":"none",
"eigrp":"none",
"nhrp":"none",
"hsls":"none",
"olsr":"none",
"table":"none",
"ldp":"none",
"vnc":"none",
"vnc-direct":"none",
"vnc-rn":"none",
"bgp-direct":"none",
"bgp-direct-to-nve-groups":"none",
"babel":"none",
"sharp":"none",
"pbr":"none",
"bfd":"none",
"openfabric":"none",
"vrrp":"none",
"zebra":"none",
"frr":"none",
"wildcard":"none",
"any":"none"
}
}
}
}
Ticket:#3229016
Issue:3229016
Signed-off-by: Sindhu Parvathi Gopinathan <sgopinathan@nvidia.com>
2022-11-08 06:40:13 +01:00
|
|
|
if (use_json) {
|
|
|
|
json_object_object_add(json, "vrfs", json_vrfs);
|
|
|
|
json_vrf = json_object_new_object();
|
|
|
|
json_object_object_add(json_vrfs, zvrf->vrf->name,
|
|
|
|
json_vrf);
|
|
|
|
json_proto = json_object_new_object();
|
|
|
|
json_object_object_add(json_vrf, "protocols",
|
|
|
|
json_proto);
|
|
|
|
show_vrf_nht_rm(vty, zvrf, af_type, json_proto);
|
|
|
|
} else {
|
|
|
|
vty_out(vty, "VRF: %s\n", zvrf->vrf->name);
|
|
|
|
show_vrf_nht_rm(vty, zvrf, af_type, NULL);
|
|
|
|
}
|
2018-10-11 19:49:34 +02:00
|
|
|
}
|
|
|
|
|
zebra: json support for show ip nht route-map
Changes:
JSON support added for below commands,
- show ip nht route-map vrf all json
- show ip nht route-map vrf <name> json
- show ipv6 nht route-map vrf all json
- show ipv6 nht route-map vrf <name> json
- show ipv6 nht route-map json
- show ip nht route-map json
Testing Done: Unit testing completed.
tor-1# show ip nht route-map vrf default json
{
"afi":"ipv4",
"vrfs":{
"default":{
"protocols":{
"system":"none",
"kernel":"none",
"connected":"connected-policy",
"static":"none",
"rip":"none",
"ripng":"none",
"ospf":"none",
"ospf6":"none",
"isis":"none",
"bgp":"bgp-policy",
"pim":"none",
"eigrp":"none",
"nhrp":"none",
"hsls":"none",
"olsr":"none",
"table":"none",
"ldp":"none",
"vnc":"none",
"vnc-direct":"none",
"vnc-rn":"none",
"bgp-direct":"none",
"bgp-direct-to-nve-groups":"none",
"babel":"none",
"sharp":"none",
"pbr":"none",
"bfd":"none",
"openfabric":"none",
"vrrp":"none",
"zebra":"none",
"frr":"none",
"wildcard":"none",
"any":"none"
}
}
}
}
tor-1# show ip nht route-map vrf all json
{
"afi":"ipv4",
"vrfs":{
"default":{
"protocols":{
"system":"none",
"kernel":"none",
"connected":"connected-policy",
"static":"none",
"rip":"none",
"ripng":"none",
"ospf":"none",
"ospf6":"none",
"isis":"none",
"bgp":"bgp-policy",
"pim":"none",
"eigrp":"none",
"nhrp":"none",
"hsls":"none",
"olsr":"none",
"table":"none",
"ldp":"none",
"vnc":"none",
"vnc-direct":"none",
"vnc-rn":"none",
"bgp-direct":"none",
"bgp-direct-to-nve-groups":"none",
"babel":"none",
"sharp":"none",
"pbr":"none",
"bfd":"none",
"openfabric":"none",
"vrrp":"none",
"zebra":"none",
"frr":"none",
"wildcard":"none",
"any":"none"
}
},
"mgmt":{
"protocols":{
"system":"none",
"kernel":"none",
"connected":"none",
"static":"none",
"rip":"none",
"ripng":"none",
"ospf":"none",
"ospf6":"none",
"isis":"none",
"bgp":"none",
"pim":"none",
"eigrp":"none",
"nhrp":"none",
"hsls":"none",
"olsr":"none",
"table":"none",
"ldp":"none",
"vnc":"none",
"vnc-direct":"none",
"vnc-rn":"none",
"bgp-direct":"none",
"bgp-direct-to-nve-groups":"none",
"babel":"none",
"sharp":"none",
"pbr":"none",
"bfd":"none",
"openfabric":"none",
"vrrp":"none",
"zebra":"none",
"frr":"none",
"wildcard":"none",
"any":"none"
}
},
"sym_1":{
"protocols":{
"system":"none",
"kernel":"none",
"connected":"none",
"static":"none",
"rip":"none",
"ripng":"none",
"ospf":"none",
"ospf6":"none",
"isis":"none",
"bgp":"bgp-policy",
"pim":"none",
"eigrp":"none",
"nhrp":"none",
"hsls":"none",
"olsr":"none",
"table":"none",
"ldp":"none",
"vnc":"none",
"vnc-direct":"none",
"vnc-rn":"none",
"bgp-direct":"none",
"bgp-direct-to-nve-groups":"none",
"babel":"none",
"sharp":"none",
"pbr":"none",
"bfd":"none",
"openfabric":"none",
"vrrp":"none",
"zebra":"none",
"frr":"none",
"wildcard":"none",
"any":"none"
}
}
}
}
tor-1# show ipv6 nht route-map vrf default json
{
"afi":"ipv6",
"vrfs":{
"default":{
"protocols":{
"system":"none",
"kernel":"kernel-policy",
"connected":"connected-policy",
"static":"none",
"rip":"none",
"ripng":"none",
"ospf":"none",
"ospf6":"none",
"isis":"none",
"bgp":"none",
"pim":"none",
"eigrp":"none",
"nhrp":"none",
"hsls":"none",
"olsr":"none",
"table":"none",
"ldp":"none",
"vnc":"none",
"vnc-direct":"none",
"vnc-rn":"none",
"bgp-direct":"none",
"bgp-direct-to-nve-groups":"none",
"babel":"none",
"sharp":"none",
"pbr":"none",
"bfd":"none",
"openfabric":"none",
"vrrp":"none",
"zebra":"none",
"frr":"none",
"wildcard":"none",
"any":"none"
}
}
}
}
Ticket:#3229016
Issue:3229016
Signed-off-by: Sindhu Parvathi Gopinathan <sgopinathan@nvidia.com>
2022-11-08 06:40:13 +01:00
|
|
|
if (use_json)
|
|
|
|
vty_json(vty, json);
|
|
|
|
|
2018-10-11 19:49:34 +02:00
|
|
|
return CMD_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2007-05-04 22:13:20 +02:00
|
|
|
/* Route map commands for interface matching */
|
2019-11-20 17:20:58 +01:00
|
|
|
static const struct route_map_rule_cmd route_match_interface_cmd = {
|
|
|
|
"interface",
|
|
|
|
route_match_interface,
|
|
|
|
route_match_interface_compile,
|
|
|
|
route_match_interface_free
|
|
|
|
};
|
2007-05-04 22:13:20 +02:00
|
|
|
|
2018-10-11 19:48:23 +02:00
|
|
|
static int ip_protocol_rm_add(struct zebra_vrf *zvrf, const char *rmap,
|
|
|
|
int rtype, afi_t afi, safi_t safi)
|
|
|
|
{
|
|
|
|
struct route_table *table;
|
|
|
|
|
|
|
|
if (PROTO_RM_NAME(zvrf, afi, rtype)) {
|
|
|
|
if (strcmp(PROTO_RM_NAME(zvrf, afi, rtype), rmap) == 0)
|
|
|
|
return CMD_SUCCESS;
|
|
|
|
|
|
|
|
XFREE(MTYPE_ROUTE_MAP_NAME, PROTO_RM_NAME(zvrf, afi, rtype));
|
|
|
|
}
|
2019-02-04 14:19:54 +01:00
|
|
|
route_map_counter_decrement(PROTO_RM_MAP(zvrf, afi, rtype));
|
2018-10-11 19:48:23 +02:00
|
|
|
PROTO_RM_NAME(zvrf, afi, rtype) = XSTRDUP(MTYPE_ROUTE_MAP_NAME, rmap);
|
|
|
|
PROTO_RM_MAP(zvrf, afi, rtype) =
|
|
|
|
route_map_lookup_by_name(PROTO_RM_NAME(zvrf, afi, rtype));
|
2019-02-04 14:19:54 +01:00
|
|
|
route_map_counter_increment(PROTO_RM_MAP(zvrf, afi, rtype));
|
2018-10-11 19:48:23 +02:00
|
|
|
|
|
|
|
if (PROTO_RM_MAP(zvrf, afi, rtype)) {
|
|
|
|
|
|
|
|
if (IS_ZEBRA_DEBUG_RIB_DETAILED)
|
|
|
|
zlog_debug(
|
|
|
|
"%u: IPv4 Routemap config for protocol %d scheduling RIB processing",
|
|
|
|
zvrf->vrf->vrf_id, rtype);
|
|
|
|
/* Process routes of interested address-families. */
|
|
|
|
table = zebra_vrf_table(afi, safi, zvrf->vrf->vrf_id);
|
|
|
|
if (table)
|
2020-10-01 15:54:53 +02:00
|
|
|
rib_update_table(table, RIB_UPDATE_RMAP_CHANGE,
|
2020-10-01 17:18:45 +02:00
|
|
|
rtype);
|
2018-10-11 19:48:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return CMD_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int ip_protocol_rm_del(struct zebra_vrf *zvrf, const char *rmap,
|
|
|
|
int rtype, afi_t afi, safi_t safi)
|
|
|
|
{
|
|
|
|
struct route_table *table;
|
|
|
|
|
|
|
|
if (!PROTO_RM_NAME(zvrf, afi, rtype))
|
|
|
|
return CMD_SUCCESS;
|
|
|
|
|
|
|
|
if (!rmap || strcmp(rmap, PROTO_RM_NAME(zvrf, afi, rtype)) == 0) {
|
2019-02-04 14:19:54 +01:00
|
|
|
|
|
|
|
route_map_counter_decrement(PROTO_RM_MAP(zvrf, afi, rtype));
|
2018-10-11 19:48:23 +02:00
|
|
|
if (PROTO_RM_MAP(zvrf, afi, rtype)) {
|
|
|
|
if (IS_ZEBRA_DEBUG_RIB_DETAILED)
|
|
|
|
zlog_debug(
|
|
|
|
"%u: IPv4 Routemap unconfig for protocol %d, scheduling RIB processing",
|
|
|
|
zvrf->vrf->vrf_id, rtype);
|
|
|
|
PROTO_RM_MAP(zvrf, afi, rtype) = NULL;
|
|
|
|
|
|
|
|
/* Process routes of interested address-families. */
|
|
|
|
table = zebra_vrf_table(afi, safi, zvrf->vrf->vrf_id);
|
|
|
|
if (table)
|
2020-10-01 15:54:53 +02:00
|
|
|
rib_update_table(table, RIB_UPDATE_RMAP_CHANGE,
|
2020-10-01 17:18:45 +02:00
|
|
|
rtype);
|
2018-10-11 19:48:23 +02:00
|
|
|
}
|
|
|
|
XFREE(MTYPE_ROUTE_MAP_NAME, PROTO_RM_NAME(zvrf, afi, rtype));
|
|
|
|
}
|
|
|
|
return CMD_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int ip_nht_rm_add(struct zebra_vrf *zvrf, const char *rmap, int rtype,
|
|
|
|
int afi)
|
|
|
|
{
|
|
|
|
|
|
|
|
if (NHT_RM_NAME(zvrf, afi, rtype)) {
|
|
|
|
if (strcmp(NHT_RM_NAME(zvrf, afi, rtype), rmap) == 0)
|
|
|
|
return CMD_SUCCESS;
|
|
|
|
|
|
|
|
XFREE(MTYPE_ROUTE_MAP_NAME, NHT_RM_NAME(zvrf, afi, rtype));
|
|
|
|
}
|
2019-02-04 14:19:54 +01:00
|
|
|
route_map_counter_decrement(NHT_RM_MAP(zvrf, afi, rtype));
|
2018-10-11 19:48:23 +02:00
|
|
|
NHT_RM_NAME(zvrf, afi, rtype) = XSTRDUP(MTYPE_ROUTE_MAP_NAME, rmap);
|
|
|
|
NHT_RM_MAP(zvrf, afi, rtype) =
|
|
|
|
route_map_lookup_by_name(NHT_RM_NAME(zvrf, afi, rtype));
|
2019-02-04 14:19:54 +01:00
|
|
|
route_map_counter_increment(NHT_RM_MAP(zvrf, afi, rtype));
|
2018-10-11 19:48:23 +02:00
|
|
|
|
|
|
|
if (NHT_RM_MAP(zvrf, afi, rtype))
|
2023-07-14 10:08:50 +02:00
|
|
|
zebra_evaluate_rnh(zvrf, afi, 1, NULL, SAFI_UNICAST);
|
2018-10-11 19:48:23 +02:00
|
|
|
|
|
|
|
return CMD_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int ip_nht_rm_del(struct zebra_vrf *zvrf, const char *rmap, int rtype,
|
|
|
|
int afi)
|
|
|
|
{
|
|
|
|
|
|
|
|
if (!NHT_RM_NAME(zvrf, afi, rtype))
|
|
|
|
return CMD_SUCCESS;
|
|
|
|
|
|
|
|
if (!rmap || strcmp(rmap, NHT_RM_NAME(zvrf, afi, rtype)) == 0) {
|
2019-02-04 14:19:54 +01:00
|
|
|
route_map_counter_decrement(NHT_RM_MAP(zvrf, afi, rtype));
|
2018-10-11 19:48:23 +02:00
|
|
|
if (NHT_RM_MAP(zvrf, afi, rtype)) {
|
|
|
|
if (IS_ZEBRA_DEBUG_RIB_DETAILED)
|
|
|
|
zlog_debug(
|
|
|
|
"%u: IPv4 Routemap unconfig for protocol %d, scheduling RIB processing",
|
|
|
|
zvrf->vrf->vrf_id, rtype);
|
|
|
|
NHT_RM_MAP(zvrf, afi, rtype) = NULL;
|
|
|
|
|
2023-07-14 10:08:50 +02:00
|
|
|
zebra_evaluate_rnh(zvrf, afi, 1, NULL, SAFI_UNICAST);
|
2018-10-11 19:48:23 +02:00
|
|
|
}
|
|
|
|
XFREE(MTYPE_ROUTE_MAP_NAME, NHT_RM_NAME(zvrf, afi, rtype));
|
|
|
|
}
|
|
|
|
return CMD_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2020-07-06 17:47:44 +02:00
|
|
|
DEFPY_YANG(
|
2019-10-08 21:21:26 +02:00
|
|
|
match_ip_address_prefix_len, match_ip_address_prefix_len_cmd,
|
|
|
|
"match ip address prefix-len (0-32)$length",
|
|
|
|
MATCH_STR
|
|
|
|
IP_STR
|
|
|
|
"Match prefix length of IP address\n"
|
|
|
|
"Match prefix length of IP address\n"
|
|
|
|
"Prefix length\n")
|
2015-05-20 02:47:20 +02:00
|
|
|
{
|
2020-10-30 08:41:19 +01:00
|
|
|
const char *xpath =
|
|
|
|
"./match-condition[condition='frr-zebra-route-map:ipv4-prefix-length']";
|
2019-10-08 21:21:26 +02:00
|
|
|
char xpath_value[XPATH_MAXLEN];
|
|
|
|
|
|
|
|
nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
|
2020-10-30 08:41:19 +01:00
|
|
|
snprintf(
|
|
|
|
xpath_value, sizeof(xpath_value),
|
|
|
|
"%s/rmap-match-condition/frr-zebra-route-map:ipv4-prefix-length",
|
|
|
|
xpath);
|
2019-10-08 21:21:26 +02:00
|
|
|
nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY, length_str);
|
|
|
|
|
|
|
|
return nb_cli_apply_changes(vty, NULL);
|
2015-05-20 02:47:20 +02:00
|
|
|
}
|
|
|
|
|
2020-07-06 17:47:44 +02:00
|
|
|
DEFPY_YANG(
|
2019-10-08 21:21:26 +02:00
|
|
|
no_match_ip_address_prefix_len, no_match_ip_address_prefix_len_cmd,
|
|
|
|
"no match ip address prefix-len [(0-32)]",
|
|
|
|
NO_STR
|
|
|
|
MATCH_STR
|
|
|
|
IP_STR
|
|
|
|
"Match prefix length of IP address\n"
|
|
|
|
"Match prefix length of IP address\n"
|
|
|
|
"Prefix length\n")
|
2015-05-20 02:47:20 +02:00
|
|
|
{
|
2020-10-30 08:41:19 +01:00
|
|
|
const char *xpath =
|
|
|
|
"./match-condition[condition='frr-zebra-route-map:ipv4-prefix-length']";
|
2019-10-08 21:21:26 +02:00
|
|
|
|
|
|
|
nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
|
|
|
|
|
|
|
|
return nb_cli_apply_changes(vty, NULL);
|
2015-05-20 02:47:20 +02:00
|
|
|
}
|
|
|
|
|
2020-07-06 17:47:44 +02:00
|
|
|
DEFPY_YANG(
|
2019-10-08 21:21:26 +02:00
|
|
|
match_ipv6_address_prefix_len, match_ipv6_address_prefix_len_cmd,
|
|
|
|
"match ipv6 address prefix-len (0-128)$length",
|
|
|
|
MATCH_STR
|
|
|
|
IPV6_STR
|
|
|
|
"Match prefix length of IPv6 address\n"
|
|
|
|
"Match prefix length of IPv6 address\n"
|
|
|
|
"Prefix length\n")
|
2017-11-03 15:33:09 +01:00
|
|
|
{
|
2020-10-30 08:41:19 +01:00
|
|
|
const char *xpath =
|
|
|
|
"./match-condition[condition='frr-zebra-route-map:ipv6-prefix-length']";
|
2019-10-08 21:21:26 +02:00
|
|
|
char xpath_value[XPATH_MAXLEN];
|
|
|
|
|
|
|
|
nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
|
2020-10-30 08:41:19 +01:00
|
|
|
snprintf(
|
|
|
|
xpath_value, sizeof(xpath_value),
|
|
|
|
"%s/rmap-match-condition/frr-zebra-route-map:ipv6-prefix-length",
|
|
|
|
xpath);
|
2019-10-08 21:21:26 +02:00
|
|
|
nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY, length_str);
|
|
|
|
|
|
|
|
return nb_cli_apply_changes(vty, NULL);
|
2017-11-03 15:33:09 +01:00
|
|
|
}
|
|
|
|
|
2020-07-06 17:47:44 +02:00
|
|
|
DEFPY_YANG(
|
2019-10-08 21:21:26 +02:00
|
|
|
no_match_ipv6_address_prefix_len, no_match_ipv6_address_prefix_len_cmd,
|
|
|
|
"no match ipv6 address prefix-len [(0-128)]",
|
|
|
|
NO_STR
|
|
|
|
MATCH_STR
|
|
|
|
IPV6_STR
|
|
|
|
"Match prefix length of IPv6 address\n"
|
|
|
|
"Match prefix length of IPv6 address\n"
|
|
|
|
"Prefix length\n")
|
2017-11-03 15:33:09 +01:00
|
|
|
{
|
2020-10-30 08:41:19 +01:00
|
|
|
const char *xpath =
|
|
|
|
"./match-condition[condition='frr-zebra-route-map:ipv6-prefix-length']";
|
2019-10-08 21:21:26 +02:00
|
|
|
|
|
|
|
nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
|
|
|
|
|
|
|
|
return nb_cli_apply_changes(vty, NULL);
|
2017-11-03 15:33:09 +01:00
|
|
|
}
|
2015-05-20 02:47:20 +02:00
|
|
|
|
2020-07-06 17:47:44 +02:00
|
|
|
DEFPY_YANG(
|
2019-10-08 21:21:26 +02:00
|
|
|
match_ip_nexthop_prefix_len, match_ip_nexthop_prefix_len_cmd,
|
|
|
|
"match ip next-hop prefix-len (0-32)$length",
|
|
|
|
MATCH_STR
|
|
|
|
IP_STR
|
|
|
|
"Match prefixlen of nexthop IP address\n"
|
|
|
|
"Match prefixlen of given nexthop\n"
|
|
|
|
"Prefix length\n")
|
2015-05-20 02:47:20 +02:00
|
|
|
{
|
2019-10-08 21:21:26 +02:00
|
|
|
const char *xpath =
|
2020-10-30 08:41:19 +01:00
|
|
|
"./match-condition[condition='frr-zebra-route-map:ipv4-next-hop-prefix-length']";
|
2019-10-08 21:21:26 +02:00
|
|
|
char xpath_value[XPATH_MAXLEN];
|
|
|
|
|
|
|
|
nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
|
2020-10-30 08:41:19 +01:00
|
|
|
snprintf(
|
|
|
|
xpath_value, sizeof(xpath_value),
|
|
|
|
"%s/rmap-match-condition/frr-zebra-route-map:ipv4-prefix-length",
|
|
|
|
xpath);
|
2019-10-08 21:21:26 +02:00
|
|
|
nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY, length_str);
|
|
|
|
|
|
|
|
return nb_cli_apply_changes(vty, NULL);
|
2015-05-20 02:47:20 +02:00
|
|
|
}
|
|
|
|
|
2020-07-06 17:47:44 +02:00
|
|
|
DEFPY_YANG(
|
2019-10-08 21:21:26 +02:00
|
|
|
no_match_ip_nexthop_prefix_len, no_match_ip_nexthop_prefix_len_cmd,
|
|
|
|
"no match ip next-hop prefix-len [(0-32)]",
|
|
|
|
NO_STR
|
|
|
|
MATCH_STR
|
|
|
|
IP_STR
|
|
|
|
"Match prefixlen of nexthop IP address\n"
|
|
|
|
"Match prefix length of nexthop\n"
|
|
|
|
"Prefix length\n")
|
2015-05-20 02:47:20 +02:00
|
|
|
{
|
2019-10-08 21:21:26 +02:00
|
|
|
const char *xpath =
|
2020-10-30 08:41:19 +01:00
|
|
|
"./match-condition[condition='frr-zebra-route-map:ipv4-next-hop-prefix-length']";
|
2019-10-08 21:21:26 +02:00
|
|
|
|
|
|
|
nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
|
|
|
|
|
|
|
|
return nb_cli_apply_changes(vty, NULL);
|
2015-05-20 02:47:20 +02:00
|
|
|
}
|
|
|
|
|
2020-07-06 17:47:44 +02:00
|
|
|
DEFPY_YANG(
|
2019-10-08 21:21:26 +02:00
|
|
|
match_source_protocol, match_source_protocol_cmd,
|
|
|
|
"match source-protocol " FRR_REDIST_STR_ZEBRA "$proto",
|
|
|
|
MATCH_STR
|
|
|
|
"Match protocol via which the route was learnt\n"
|
|
|
|
FRR_REDIST_HELP_STR_ZEBRA)
|
2015-05-20 02:47:20 +02:00
|
|
|
{
|
2020-10-30 08:41:19 +01:00
|
|
|
const char *xpath =
|
|
|
|
"./match-condition[condition='frr-zebra-route-map:source-protocol']";
|
2019-10-08 21:21:26 +02:00
|
|
|
char xpath_value[XPATH_MAXLEN];
|
2015-05-20 02:47:20 +02:00
|
|
|
|
2019-10-08 21:21:26 +02:00
|
|
|
nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
|
|
|
|
snprintf(xpath_value, sizeof(xpath_value),
|
2020-10-30 08:41:19 +01:00
|
|
|
"%s/rmap-match-condition/frr-zebra-route-map:source-protocol",
|
|
|
|
xpath);
|
2019-10-08 21:21:26 +02:00
|
|
|
nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY, proto);
|
|
|
|
|
|
|
|
return nb_cli_apply_changes(vty, NULL);
|
2015-05-20 02:47:20 +02:00
|
|
|
}
|
|
|
|
|
2020-07-06 17:47:44 +02:00
|
|
|
DEFPY_YANG(
|
2019-10-08 21:21:26 +02:00
|
|
|
no_match_source_protocol, no_match_source_protocol_cmd,
|
|
|
|
"no match source-protocol [" FRR_REDIST_STR_ZEBRA "]",
|
|
|
|
NO_STR
|
|
|
|
MATCH_STR
|
|
|
|
"Match protocol via which the route was learnt\n"
|
|
|
|
FRR_REDIST_HELP_STR_ZEBRA)
|
2015-05-20 02:47:20 +02:00
|
|
|
{
|
2020-10-30 08:41:19 +01:00
|
|
|
const char *xpath =
|
|
|
|
"./match-condition[condition='frr-zebra-route-map:source-protocol']";
|
2019-10-08 21:21:26 +02:00
|
|
|
|
|
|
|
nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
|
|
|
|
|
|
|
|
return nb_cli_apply_changes(vty, NULL);
|
2015-05-20 02:47:20 +02:00
|
|
|
}
|
|
|
|
|
2020-07-06 17:47:44 +02:00
|
|
|
DEFPY_YANG(
|
2019-10-08 21:21:26 +02:00
|
|
|
match_source_instance, match_source_instance_cmd,
|
|
|
|
"match source-instance (0-255)$instance",
|
|
|
|
MATCH_STR
|
|
|
|
"Match the protocol's instance number\n"
|
|
|
|
"The instance number\n")
|
2018-05-17 16:29:49 +02:00
|
|
|
{
|
2020-10-30 08:41:19 +01:00
|
|
|
const char *xpath =
|
|
|
|
"./match-condition[condition='frr-zebra-route-map:source-instance']";
|
2019-10-08 21:21:26 +02:00
|
|
|
char xpath_value[XPATH_MAXLEN];
|
|
|
|
|
|
|
|
nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
|
|
|
|
snprintf(xpath_value, sizeof(xpath_value),
|
2020-10-30 08:41:19 +01:00
|
|
|
"%s/rmap-match-condition/frr-zebra-route-map:source-instance",
|
|
|
|
xpath);
|
2019-10-08 21:21:26 +02:00
|
|
|
nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY, instance_str);
|
2018-05-17 16:29:49 +02:00
|
|
|
|
2019-10-08 21:21:26 +02:00
|
|
|
return nb_cli_apply_changes(vty, NULL);
|
2018-05-17 16:29:49 +02:00
|
|
|
}
|
|
|
|
|
2020-07-06 17:47:44 +02:00
|
|
|
DEFPY_YANG(
|
2019-10-08 21:21:26 +02:00
|
|
|
no_match_source_instance, no_match_source_instance_cmd,
|
|
|
|
"no match source-instance [(0-255)]",
|
|
|
|
NO_STR MATCH_STR
|
|
|
|
"Match the protocol's instance number\n"
|
|
|
|
"The instance number\n")
|
2018-05-17 16:29:49 +02:00
|
|
|
{
|
2020-10-30 08:41:19 +01:00
|
|
|
const char *xpath =
|
|
|
|
"./match-condition[condition='frr-zebra-route-map:source-instance']";
|
2019-10-08 21:21:26 +02:00
|
|
|
|
|
|
|
nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
|
2018-05-17 16:29:49 +02:00
|
|
|
|
2019-10-08 21:21:26 +02:00
|
|
|
return nb_cli_apply_changes(vty, NULL);
|
2018-05-17 16:29:49 +02:00
|
|
|
}
|
|
|
|
|
2007-05-04 22:13:20 +02:00
|
|
|
/* set functions */
|
|
|
|
|
2020-07-06 17:47:44 +02:00
|
|
|
DEFPY_YANG(
|
2019-10-08 21:21:26 +02:00
|
|
|
set_src, set_src_cmd,
|
|
|
|
"set src <A.B.C.D$addrv4|X:X::X:X$addrv6>",
|
|
|
|
SET_STR
|
|
|
|
"src address for route\n"
|
|
|
|
"IPv4 src address\n"
|
|
|
|
"IPv6 src address\n")
|
2007-05-04 22:13:20 +02:00
|
|
|
{
|
2020-10-30 08:41:19 +01:00
|
|
|
const char *xpath =
|
|
|
|
"./set-action[action='frr-zebra-route-map:src-address']";
|
2019-10-08 21:21:26 +02:00
|
|
|
char xpath_value[XPATH_MAXLEN];
|
|
|
|
|
|
|
|
nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
|
|
|
|
if (addrv4_str) {
|
2020-10-30 08:41:19 +01:00
|
|
|
snprintf(
|
|
|
|
xpath_value, sizeof(xpath_value),
|
|
|
|
"%s/rmap-set-action/frr-zebra-route-map:ipv4-src-address",
|
|
|
|
xpath);
|
2019-10-08 21:21:26 +02:00
|
|
|
nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY,
|
|
|
|
addrv4_str);
|
2017-07-17 14:03:14 +02:00
|
|
|
} else {
|
2020-10-30 08:41:19 +01:00
|
|
|
snprintf(
|
|
|
|
xpath_value, sizeof(xpath_value),
|
|
|
|
"%s/rmap-set-action/frr-zebra-route-map:ipv6-src-address",
|
|
|
|
xpath);
|
2019-10-08 21:21:26 +02:00
|
|
|
nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY,
|
|
|
|
addrv6_str);
|
2015-09-16 08:48:00 +02:00
|
|
|
}
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2019-10-08 21:21:26 +02:00
|
|
|
return nb_cli_apply_changes(vty, NULL);
|
2007-05-04 22:13:20 +02:00
|
|
|
}
|
|
|
|
|
2020-07-06 17:47:44 +02:00
|
|
|
DEFPY_YANG(
|
2019-10-08 21:21:26 +02:00
|
|
|
no_set_src, no_set_src_cmd,
|
|
|
|
"no set src [<A.B.C.D|X:X::X:X>]",
|
|
|
|
NO_STR
|
|
|
|
SET_STR
|
|
|
|
"Source address for route\n"
|
|
|
|
"IPv4 address\n"
|
|
|
|
"IPv6 address\n")
|
2007-05-04 22:13:20 +02:00
|
|
|
{
|
2020-10-30 08:41:19 +01:00
|
|
|
const char *xpath =
|
|
|
|
"./set-action[action='frr-zebra-route-map:src-address']";
|
2019-10-08 21:21:26 +02:00
|
|
|
|
|
|
|
nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
|
|
|
|
|
|
|
|
return nb_cli_apply_changes(vty, NULL);
|
2007-05-04 22:13:20 +02:00
|
|
|
}
|
|
|
|
|
2020-10-30 08:41:19 +01:00
|
|
|
DEFUN_YANG (zebra_route_map_timer,
|
2015-05-20 02:40:45 +02:00
|
|
|
zebra_route_map_timer_cmd,
|
2016-09-23 15:47:20 +02:00
|
|
|
"zebra route-map delay-timer (0-600)",
|
2017-10-25 16:52:24 +02:00
|
|
|
ZEBRA_STR
|
2016-11-05 00:03:03 +01:00
|
|
|
"Set route-map parameters\n"
|
2015-05-20 02:47:20 +02:00
|
|
|
"Time to wait before route-map updates are processed\n"
|
2020-10-02 13:46:00 +02:00
|
|
|
"0 means route-map changes are run immediately instead of delaying\n")
|
2015-05-20 02:40:45 +02:00
|
|
|
{
|
2016-09-23 21:26:31 +02:00
|
|
|
int idx_number = 3;
|
2018-03-27 21:13:34 +02:00
|
|
|
uint32_t rmap_delay_timer;
|
2015-05-20 02:40:45 +02:00
|
|
|
|
*: remove VTY_GET_*
CLI validates input tokens, so there's no need to do it in handler
functions anymore.
spatch follows
----------------
@getull@
expression v;
expression str;
@@
<...
- VTY_GET_ULL(..., v, str)
+ v = strtoull (str, NULL, 10)
...>
@getul@
expression v;
expression str;
@@
<...
- VTY_GET_ULONG(..., v, str)
+ v = strtoul (str, NULL, 10)
...>
@getintrange@
expression name;
expression v;
expression str;
@@
<...
- VTY_GET_INTEGER_RANGE(name, v, str, ...)
+ v = strtoul (str, NULL, 10)
...>
@getint@
expression v;
expression str;
@@
<...
- VTY_GET_INTEGER(..., v, str)
+ v = strtoul (str, NULL, 10)
...>
@getv4@
expression v;
expression str;
@@
<...
- VTY_GET_IPV4_ADDRESS(..., v, str)
+ inet_aton (str, &v)
...>
@getv4pfx@
expression v;
expression str;
@@
<...
- VTY_GET_IPV4_PREFIX(..., v, str)
+ str2prefix_ipv4 (str, &v)
...>
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-06-27 20:47:03 +02:00
|
|
|
rmap_delay_timer = strtoul(argv[idx_number]->arg, NULL, 10);
|
2015-05-20 02:40:45 +02:00
|
|
|
zebra_route_map_set_delay_timer(rmap_delay_timer);
|
|
|
|
|
|
|
|
return (CMD_SUCCESS);
|
|
|
|
}
|
|
|
|
|
2020-10-30 08:41:19 +01:00
|
|
|
DEFUN_YANG (no_zebra_route_map_timer,
|
2015-05-20 02:40:45 +02:00
|
|
|
no_zebra_route_map_timer_cmd,
|
2016-09-24 19:42:34 +02:00
|
|
|
"no zebra route-map delay-timer [(0-600)]",
|
2015-05-20 02:40:45 +02:00
|
|
|
NO_STR
|
2017-10-25 16:52:24 +02:00
|
|
|
ZEBRA_STR
|
2016-11-05 00:03:03 +01:00
|
|
|
"Set route-map parameters\n"
|
2016-09-24 19:42:34 +02:00
|
|
|
"Reset delay-timer to default value, 30 secs\n"
|
2020-10-02 13:46:00 +02:00
|
|
|
"0 means route-map changes are run immediately instead of delaying\n")
|
2015-05-20 02:40:45 +02:00
|
|
|
{
|
|
|
|
zebra_route_map_set_delay_timer(ZEBRA_RMAP_DEFAULT_UPDATE_TIMER);
|
|
|
|
|
|
|
|
return (CMD_SUCCESS);
|
|
|
|
}
|
|
|
|
|
2020-07-06 17:47:44 +02:00
|
|
|
DEFPY_YANG (ip_protocol,
|
2015-05-20 02:40:45 +02:00
|
|
|
ip_protocol_cmd,
|
2018-10-11 19:48:23 +02:00
|
|
|
"ip protocol " FRR_IP_PROTOCOL_MAP_STR_ZEBRA
|
|
|
|
" $proto route-map ROUTE-MAP$rmap",
|
2015-05-20 02:47:20 +02:00
|
|
|
IP_STR
|
|
|
|
"Filter routing info exchanged between zebra and protocol\n"
|
2016-12-20 18:31:42 +01:00
|
|
|
FRR_IP_PROTOCOL_MAP_HELP_STR_ZEBRA
|
2016-09-24 19:42:34 +02:00
|
|
|
"Specify route-map\n"
|
2015-05-20 02:40:45 +02:00
|
|
|
"Route map name\n")
|
|
|
|
{
|
2018-10-11 19:48:23 +02:00
|
|
|
int ret, rtype;
|
|
|
|
|
2019-05-11 19:18:29 +02:00
|
|
|
assert(proto);
|
|
|
|
assert(rmap);
|
|
|
|
|
2022-04-28 11:06:20 +02:00
|
|
|
ZEBRA_DECLVAR_CONTEXT_VRF(vrf, zvrf);
|
2018-10-11 19:48:23 +02:00
|
|
|
|
|
|
|
if (!zvrf)
|
|
|
|
return CMD_WARNING;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2016-09-24 19:42:34 +02:00
|
|
|
if (strcasecmp(proto, "any") == 0)
|
2018-10-11 19:48:23 +02:00
|
|
|
rtype = ZEBRA_ROUTE_MAX;
|
2015-05-20 02:40:45 +02:00
|
|
|
else
|
2018-10-11 19:48:23 +02:00
|
|
|
rtype = proto_name2num(proto);
|
|
|
|
if (rtype < 0) {
|
2017-07-13 18:50:29 +02:00
|
|
|
vty_out(vty, "invalid protocol name \"%s\"\n", proto);
|
2017-07-13 21:56:08 +02:00
|
|
|
return CMD_WARNING_CONFIG_FAILED;
|
2015-05-20 02:40:45 +02:00
|
|
|
}
|
|
|
|
|
2018-10-11 19:48:23 +02:00
|
|
|
ret = ip_protocol_rm_add(zvrf, rmap, rtype, AFI_IP, SAFI_UNICAST);
|
2015-10-21 07:37:32 +02:00
|
|
|
|
2018-10-11 19:48:23 +02:00
|
|
|
return ret;
|
2015-05-20 02:40:45 +02:00
|
|
|
}
|
|
|
|
|
2020-07-06 17:47:44 +02:00
|
|
|
DEFPY_YANG (no_ip_protocol,
|
2015-05-20 02:40:45 +02:00
|
|
|
no_ip_protocol_cmd,
|
2018-10-11 19:48:23 +02:00
|
|
|
"no ip protocol " FRR_IP_PROTOCOL_MAP_STR_ZEBRA
|
|
|
|
" $proto [route-map ROUTE-MAP$rmap]",
|
2015-05-20 02:40:45 +02:00
|
|
|
NO_STR
|
2015-05-20 02:47:20 +02:00
|
|
|
IP_STR
|
|
|
|
"Stop filtering routing info between zebra and protocol\n"
|
2016-12-20 18:31:42 +01:00
|
|
|
FRR_IP_PROTOCOL_MAP_HELP_STR_ZEBRA
|
2018-10-11 19:48:23 +02:00
|
|
|
"Specify route-map\n"
|
2016-09-24 19:42:34 +02:00
|
|
|
"Route map name\n")
|
2015-05-20 02:40:45 +02:00
|
|
|
{
|
2018-10-11 19:48:23 +02:00
|
|
|
int ret, rtype;
|
|
|
|
|
2019-05-11 19:18:29 +02:00
|
|
|
assert(proto);
|
|
|
|
|
2022-04-28 11:06:20 +02:00
|
|
|
ZEBRA_DECLVAR_CONTEXT_VRF(vrf, zvrf);
|
2018-10-11 19:48:23 +02:00
|
|
|
|
|
|
|
if (!zvrf)
|
|
|
|
return CMD_WARNING;
|
2015-05-20 02:40:45 +02:00
|
|
|
|
2016-09-24 19:42:34 +02:00
|
|
|
if (strcasecmp(proto, "any") == 0)
|
2018-10-11 19:48:23 +02:00
|
|
|
rtype = ZEBRA_ROUTE_MAX;
|
2015-05-20 02:40:45 +02:00
|
|
|
else
|
2018-10-11 19:48:23 +02:00
|
|
|
rtype = proto_name2num(proto);
|
|
|
|
if (rtype < 0) {
|
2017-07-13 18:50:29 +02:00
|
|
|
vty_out(vty, "invalid protocol name \"%s\"\n", proto);
|
2017-07-13 21:56:08 +02:00
|
|
|
return CMD_WARNING_CONFIG_FAILED;
|
2015-05-20 02:40:45 +02:00
|
|
|
}
|
2016-09-24 19:42:34 +02:00
|
|
|
|
2018-10-11 19:48:23 +02:00
|
|
|
ret = ip_protocol_rm_del(zvrf, rmap, rtype, AFI_IP, SAFI_UNICAST);
|
2015-05-20 02:40:45 +02:00
|
|
|
|
2018-10-11 19:48:23 +02:00
|
|
|
return ret;
|
2015-05-20 02:40:45 +02:00
|
|
|
}
|
|
|
|
|
2020-07-06 17:47:44 +02:00
|
|
|
DEFPY_YANG (show_ip_protocol,
|
2015-05-20 02:40:45 +02:00
|
|
|
show_ip_protocol_cmd,
|
2018-10-11 19:49:34 +02:00
|
|
|
"show ip protocol [vrf <NAME$vrf_name|all$vrf_all>]",
|
|
|
|
SHOW_STR
|
|
|
|
IP_STR
|
|
|
|
"IP protocol filtering status\n"
|
|
|
|
VRF_FULL_CMD_HELP_STR)
|
2015-05-20 02:40:45 +02:00
|
|
|
{
|
2018-10-11 19:49:34 +02:00
|
|
|
int ret = show_proto_rm(vty, AFI_IP, vrf_all, vrf_name);
|
2015-05-20 02:40:45 +02:00
|
|
|
|
2018-10-11 19:49:34 +02:00
|
|
|
return ret;
|
2015-05-20 02:40:45 +02:00
|
|
|
}
|
|
|
|
|
2020-07-06 17:47:44 +02:00
|
|
|
DEFPY_YANG (ipv6_protocol,
|
2015-09-16 08:48:00 +02:00
|
|
|
ipv6_protocol_cmd,
|
2018-10-11 19:48:23 +02:00
|
|
|
"ipv6 protocol " FRR_IP6_PROTOCOL_MAP_STR_ZEBRA
|
|
|
|
" $proto route-map ROUTE-MAP$rmap",
|
2015-09-16 08:48:00 +02:00
|
|
|
IP6_STR
|
|
|
|
"Filter IPv6 routing info exchanged between zebra and protocol\n"
|
2016-12-20 18:31:42 +01:00
|
|
|
FRR_IP6_PROTOCOL_MAP_HELP_STR_ZEBRA
|
2018-10-11 19:48:23 +02:00
|
|
|
"Specify route-map\n"
|
2015-09-16 08:48:00 +02:00
|
|
|
"Route map name\n")
|
|
|
|
{
|
2018-10-11 19:48:23 +02:00
|
|
|
int ret, rtype;
|
|
|
|
|
2019-05-11 19:18:29 +02:00
|
|
|
assert(rmap);
|
|
|
|
assert(proto);
|
|
|
|
|
2022-04-28 11:06:20 +02:00
|
|
|
ZEBRA_DECLVAR_CONTEXT_VRF(vrf, zvrf);
|
2018-10-11 19:48:23 +02:00
|
|
|
|
|
|
|
if (!zvrf)
|
|
|
|
return CMD_WARNING;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2016-09-24 19:42:34 +02:00
|
|
|
if (strcasecmp(proto, "any") == 0)
|
2018-10-11 19:48:23 +02:00
|
|
|
rtype = ZEBRA_ROUTE_MAX;
|
2015-09-16 08:48:00 +02:00
|
|
|
else
|
2018-10-11 19:48:23 +02:00
|
|
|
rtype = proto_name2num(proto);
|
|
|
|
if (rtype < 0) {
|
2017-07-13 18:50:29 +02:00
|
|
|
vty_out(vty, "invalid protocol name \"%s\"\n", proto);
|
2017-07-13 21:56:08 +02:00
|
|
|
return CMD_WARNING_CONFIG_FAILED;
|
2015-09-16 08:48:00 +02:00
|
|
|
}
|
|
|
|
|
2018-10-11 19:48:23 +02:00
|
|
|
ret = ip_protocol_rm_add(zvrf, rmap, rtype, AFI_IP6, SAFI_UNICAST);
|
2015-10-21 07:37:32 +02:00
|
|
|
|
2018-10-11 19:48:23 +02:00
|
|
|
return ret;
|
2015-09-16 08:48:00 +02:00
|
|
|
}
|
|
|
|
|
2020-07-06 17:47:44 +02:00
|
|
|
DEFPY_YANG (no_ipv6_protocol,
|
2015-09-16 08:48:00 +02:00
|
|
|
no_ipv6_protocol_cmd,
|
2018-10-11 19:48:23 +02:00
|
|
|
"no ipv6 protocol " FRR_IP6_PROTOCOL_MAP_STR_ZEBRA
|
|
|
|
" $proto [route-map ROUTE-MAP$rmap]",
|
2015-09-16 08:48:00 +02:00
|
|
|
NO_STR
|
|
|
|
IP6_STR
|
|
|
|
"Stop filtering IPv6 routing info between zebra and protocol\n"
|
2016-12-20 18:31:42 +01:00
|
|
|
FRR_IP6_PROTOCOL_MAP_HELP_STR_ZEBRA
|
2018-10-11 19:48:23 +02:00
|
|
|
"Specify route-map\n"
|
2016-09-24 19:42:34 +02:00
|
|
|
"Route map name\n")
|
2015-09-16 08:48:00 +02:00
|
|
|
{
|
2018-10-11 19:48:23 +02:00
|
|
|
int ret, rtype;
|
|
|
|
|
2019-05-11 19:18:29 +02:00
|
|
|
assert(proto);
|
|
|
|
|
2022-04-28 11:06:20 +02:00
|
|
|
ZEBRA_DECLVAR_CONTEXT_VRF(vrf, zvrf);
|
2018-10-11 19:48:23 +02:00
|
|
|
|
|
|
|
if (!zvrf)
|
|
|
|
return CMD_WARNING;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2016-09-24 19:42:34 +02:00
|
|
|
if (strcasecmp(proto, "any") == 0)
|
2018-10-11 19:48:23 +02:00
|
|
|
rtype = ZEBRA_ROUTE_MAX;
|
2015-09-16 08:48:00 +02:00
|
|
|
else
|
2018-10-11 19:48:23 +02:00
|
|
|
rtype = proto_name2num(proto);
|
|
|
|
if (rtype < 0) {
|
2017-07-13 18:50:29 +02:00
|
|
|
vty_out(vty, "invalid protocol name \"%s\"\n", proto);
|
2017-07-13 21:56:08 +02:00
|
|
|
return CMD_WARNING_CONFIG_FAILED;
|
2015-09-16 08:48:00 +02:00
|
|
|
}
|
2015-10-21 07:37:32 +02:00
|
|
|
|
2018-10-11 19:48:23 +02:00
|
|
|
ret = ip_protocol_rm_del(zvrf, rmap, rtype, AFI_IP6, SAFI_UNICAST);
|
2015-10-21 07:37:32 +02:00
|
|
|
|
2018-10-11 19:48:23 +02:00
|
|
|
return ret;
|
2015-09-16 08:48:00 +02:00
|
|
|
}
|
|
|
|
|
2020-07-06 17:47:44 +02:00
|
|
|
DEFPY_YANG (show_ipv6_protocol,
|
2015-09-16 08:48:00 +02:00
|
|
|
show_ipv6_protocol_cmd,
|
2018-10-11 19:49:34 +02:00
|
|
|
"show ipv6 protocol [vrf <NAME$vrf_name|all$vrf_all>]",
|
|
|
|
SHOW_STR
|
|
|
|
IP6_STR
|
|
|
|
"IPv6 protocol filtering status\n"
|
|
|
|
VRF_FULL_CMD_HELP_STR)
|
2015-09-16 08:48:00 +02:00
|
|
|
{
|
2018-10-11 19:49:34 +02:00
|
|
|
int ret = show_proto_rm(vty, AFI_IP6, vrf_all, vrf_name);
|
2015-09-16 08:48:00 +02:00
|
|
|
|
2018-10-11 19:49:34 +02:00
|
|
|
return ret;
|
2015-09-16 08:48:00 +02:00
|
|
|
}
|
|
|
|
|
2020-07-06 17:47:44 +02:00
|
|
|
DEFPY_YANG (ip_protocol_nht_rmap,
|
2015-05-20 02:47:20 +02:00
|
|
|
ip_protocol_nht_rmap_cmd,
|
2018-10-11 19:48:23 +02:00
|
|
|
"ip nht " FRR_IP_PROTOCOL_MAP_STR_ZEBRA
|
|
|
|
" $proto route-map ROUTE-MAP$rmap",
|
2015-05-20 02:47:20 +02:00
|
|
|
IP_STR
|
|
|
|
"Filter Next Hop tracking route resolution\n"
|
2016-12-20 18:31:42 +01:00
|
|
|
FRR_IP_PROTOCOL_MAP_HELP_STR_ZEBRA
|
2016-09-24 19:42:34 +02:00
|
|
|
"Specify route map\n"
|
2015-05-20 02:47:20 +02:00
|
|
|
"Route map name\n")
|
|
|
|
{
|
2018-10-11 19:48:23 +02:00
|
|
|
|
|
|
|
int ret, rtype;
|
|
|
|
|
2019-05-11 19:18:29 +02:00
|
|
|
assert(proto);
|
|
|
|
assert(rmap);
|
|
|
|
|
2022-04-28 11:06:20 +02:00
|
|
|
ZEBRA_DECLVAR_CONTEXT_VRF(vrf, zvrf);
|
2018-10-11 19:48:23 +02:00
|
|
|
|
|
|
|
if (!zvrf)
|
|
|
|
return CMD_WARNING;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2016-09-24 19:42:34 +02:00
|
|
|
if (strcasecmp(proto, "any") == 0)
|
2018-10-11 19:48:23 +02:00
|
|
|
rtype = ZEBRA_ROUTE_MAX;
|
2015-05-20 02:47:20 +02:00
|
|
|
else
|
2018-10-11 19:48:23 +02:00
|
|
|
rtype = proto_name2num(proto);
|
|
|
|
if (rtype < 0) {
|
2017-07-13 18:50:29 +02:00
|
|
|
vty_out(vty, "invalid protocol name \"%s\"\n", proto);
|
2017-07-13 21:56:08 +02:00
|
|
|
return CMD_WARNING_CONFIG_FAILED;
|
2015-05-20 02:47:20 +02:00
|
|
|
}
|
2018-10-11 19:46:55 +02:00
|
|
|
|
2018-10-11 19:48:23 +02:00
|
|
|
ret = ip_nht_rm_add(zvrf, rmap, rtype, AFI_IP);
|
2015-05-20 02:47:20 +02:00
|
|
|
|
2018-10-11 19:48:23 +02:00
|
|
|
return ret;
|
2015-05-20 02:47:20 +02:00
|
|
|
}
|
|
|
|
|
2020-07-06 17:47:44 +02:00
|
|
|
DEFPY_YANG (no_ip_protocol_nht_rmap,
|
2015-05-20 02:47:20 +02:00
|
|
|
no_ip_protocol_nht_rmap_cmd,
|
2018-10-11 19:48:23 +02:00
|
|
|
"no ip nht " FRR_IP_PROTOCOL_MAP_STR_ZEBRA
|
|
|
|
" $proto route-map [ROUTE-MAP$rmap]",
|
2015-05-20 02:47:20 +02:00
|
|
|
NO_STR
|
|
|
|
IP_STR
|
|
|
|
"Filter Next Hop tracking route resolution\n"
|
2017-01-06 15:58:21 +01:00
|
|
|
FRR_IP_PROTOCOL_MAP_HELP_STR_ZEBRA
|
2016-09-24 19:42:34 +02:00
|
|
|
"Specify route map\n"
|
|
|
|
"Route map name\n")
|
2015-05-20 02:47:20 +02:00
|
|
|
{
|
2018-10-11 19:48:23 +02:00
|
|
|
int ret, rtype;
|
2016-11-17 22:54:36 +01:00
|
|
|
|
2019-05-11 19:18:29 +02:00
|
|
|
assert(proto);
|
|
|
|
|
2022-04-28 11:06:20 +02:00
|
|
|
ZEBRA_DECLVAR_CONTEXT_VRF(vrf, zvrf);
|
2015-05-20 02:47:20 +02:00
|
|
|
|
2018-10-11 19:48:23 +02:00
|
|
|
if (!zvrf)
|
|
|
|
return CMD_WARNING;
|
|
|
|
|
|
|
|
if (strcasecmp(proto, "any") == 0)
|
|
|
|
rtype = ZEBRA_ROUTE_MAX;
|
|
|
|
else
|
|
|
|
rtype = proto_name2num(proto);
|
|
|
|
if (rtype < 0) {
|
2017-07-13 18:50:29 +02:00
|
|
|
vty_out(vty, "invalid protocol name \"%s\"\n", proto);
|
2017-07-13 21:56:08 +02:00
|
|
|
return CMD_WARNING_CONFIG_FAILED;
|
2015-05-20 02:47:20 +02:00
|
|
|
}
|
2016-11-17 22:54:36 +01:00
|
|
|
|
2018-10-11 19:48:23 +02:00
|
|
|
ret = ip_nht_rm_del(zvrf, rmap, rtype, AFI_IP);
|
2015-05-20 02:47:20 +02:00
|
|
|
|
2018-10-11 19:48:23 +02:00
|
|
|
return ret;
|
2015-05-20 02:47:20 +02:00
|
|
|
}
|
|
|
|
|
2020-07-06 17:47:44 +02:00
|
|
|
DEFPY_YANG (show_ip_protocol_nht,
|
2015-05-20 02:47:20 +02:00
|
|
|
show_ip_protocol_nht_cmd,
|
zebra: json support for show ip nht route-map
Changes:
JSON support added for below commands,
- show ip nht route-map vrf all json
- show ip nht route-map vrf <name> json
- show ipv6 nht route-map vrf all json
- show ipv6 nht route-map vrf <name> json
- show ipv6 nht route-map json
- show ip nht route-map json
Testing Done: Unit testing completed.
tor-1# show ip nht route-map vrf default json
{
"afi":"ipv4",
"vrfs":{
"default":{
"protocols":{
"system":"none",
"kernel":"none",
"connected":"connected-policy",
"static":"none",
"rip":"none",
"ripng":"none",
"ospf":"none",
"ospf6":"none",
"isis":"none",
"bgp":"bgp-policy",
"pim":"none",
"eigrp":"none",
"nhrp":"none",
"hsls":"none",
"olsr":"none",
"table":"none",
"ldp":"none",
"vnc":"none",
"vnc-direct":"none",
"vnc-rn":"none",
"bgp-direct":"none",
"bgp-direct-to-nve-groups":"none",
"babel":"none",
"sharp":"none",
"pbr":"none",
"bfd":"none",
"openfabric":"none",
"vrrp":"none",
"zebra":"none",
"frr":"none",
"wildcard":"none",
"any":"none"
}
}
}
}
tor-1# show ip nht route-map vrf all json
{
"afi":"ipv4",
"vrfs":{
"default":{
"protocols":{
"system":"none",
"kernel":"none",
"connected":"connected-policy",
"static":"none",
"rip":"none",
"ripng":"none",
"ospf":"none",
"ospf6":"none",
"isis":"none",
"bgp":"bgp-policy",
"pim":"none",
"eigrp":"none",
"nhrp":"none",
"hsls":"none",
"olsr":"none",
"table":"none",
"ldp":"none",
"vnc":"none",
"vnc-direct":"none",
"vnc-rn":"none",
"bgp-direct":"none",
"bgp-direct-to-nve-groups":"none",
"babel":"none",
"sharp":"none",
"pbr":"none",
"bfd":"none",
"openfabric":"none",
"vrrp":"none",
"zebra":"none",
"frr":"none",
"wildcard":"none",
"any":"none"
}
},
"mgmt":{
"protocols":{
"system":"none",
"kernel":"none",
"connected":"none",
"static":"none",
"rip":"none",
"ripng":"none",
"ospf":"none",
"ospf6":"none",
"isis":"none",
"bgp":"none",
"pim":"none",
"eigrp":"none",
"nhrp":"none",
"hsls":"none",
"olsr":"none",
"table":"none",
"ldp":"none",
"vnc":"none",
"vnc-direct":"none",
"vnc-rn":"none",
"bgp-direct":"none",
"bgp-direct-to-nve-groups":"none",
"babel":"none",
"sharp":"none",
"pbr":"none",
"bfd":"none",
"openfabric":"none",
"vrrp":"none",
"zebra":"none",
"frr":"none",
"wildcard":"none",
"any":"none"
}
},
"sym_1":{
"protocols":{
"system":"none",
"kernel":"none",
"connected":"none",
"static":"none",
"rip":"none",
"ripng":"none",
"ospf":"none",
"ospf6":"none",
"isis":"none",
"bgp":"bgp-policy",
"pim":"none",
"eigrp":"none",
"nhrp":"none",
"hsls":"none",
"olsr":"none",
"table":"none",
"ldp":"none",
"vnc":"none",
"vnc-direct":"none",
"vnc-rn":"none",
"bgp-direct":"none",
"bgp-direct-to-nve-groups":"none",
"babel":"none",
"sharp":"none",
"pbr":"none",
"bfd":"none",
"openfabric":"none",
"vrrp":"none",
"zebra":"none",
"frr":"none",
"wildcard":"none",
"any":"none"
}
}
}
}
tor-1# show ipv6 nht route-map vrf default json
{
"afi":"ipv6",
"vrfs":{
"default":{
"protocols":{
"system":"none",
"kernel":"kernel-policy",
"connected":"connected-policy",
"static":"none",
"rip":"none",
"ripng":"none",
"ospf":"none",
"ospf6":"none",
"isis":"none",
"bgp":"none",
"pim":"none",
"eigrp":"none",
"nhrp":"none",
"hsls":"none",
"olsr":"none",
"table":"none",
"ldp":"none",
"vnc":"none",
"vnc-direct":"none",
"vnc-rn":"none",
"bgp-direct":"none",
"bgp-direct-to-nve-groups":"none",
"babel":"none",
"sharp":"none",
"pbr":"none",
"bfd":"none",
"openfabric":"none",
"vrrp":"none",
"zebra":"none",
"frr":"none",
"wildcard":"none",
"any":"none"
}
}
}
}
Ticket:#3229016
Issue:3229016
Signed-off-by: Sindhu Parvathi Gopinathan <sgopinathan@nvidia.com>
2022-11-08 06:40:13 +01:00
|
|
|
"show ip nht route-map [vrf <NAME$vrf_name|all$vrf_all>] [json]",
|
2016-11-30 00:07:11 +01:00
|
|
|
SHOW_STR
|
|
|
|
IP_STR
|
zebra: json support for show ip nht route-map
Changes:
JSON support added for below commands,
- show ip nht route-map vrf all json
- show ip nht route-map vrf <name> json
- show ipv6 nht route-map vrf all json
- show ipv6 nht route-map vrf <name> json
- show ipv6 nht route-map json
- show ip nht route-map json
Testing Done: Unit testing completed.
tor-1# show ip nht route-map vrf default json
{
"afi":"ipv4",
"vrfs":{
"default":{
"protocols":{
"system":"none",
"kernel":"none",
"connected":"connected-policy",
"static":"none",
"rip":"none",
"ripng":"none",
"ospf":"none",
"ospf6":"none",
"isis":"none",
"bgp":"bgp-policy",
"pim":"none",
"eigrp":"none",
"nhrp":"none",
"hsls":"none",
"olsr":"none",
"table":"none",
"ldp":"none",
"vnc":"none",
"vnc-direct":"none",
"vnc-rn":"none",
"bgp-direct":"none",
"bgp-direct-to-nve-groups":"none",
"babel":"none",
"sharp":"none",
"pbr":"none",
"bfd":"none",
"openfabric":"none",
"vrrp":"none",
"zebra":"none",
"frr":"none",
"wildcard":"none",
"any":"none"
}
}
}
}
tor-1# show ip nht route-map vrf all json
{
"afi":"ipv4",
"vrfs":{
"default":{
"protocols":{
"system":"none",
"kernel":"none",
"connected":"connected-policy",
"static":"none",
"rip":"none",
"ripng":"none",
"ospf":"none",
"ospf6":"none",
"isis":"none",
"bgp":"bgp-policy",
"pim":"none",
"eigrp":"none",
"nhrp":"none",
"hsls":"none",
"olsr":"none",
"table":"none",
"ldp":"none",
"vnc":"none",
"vnc-direct":"none",
"vnc-rn":"none",
"bgp-direct":"none",
"bgp-direct-to-nve-groups":"none",
"babel":"none",
"sharp":"none",
"pbr":"none",
"bfd":"none",
"openfabric":"none",
"vrrp":"none",
"zebra":"none",
"frr":"none",
"wildcard":"none",
"any":"none"
}
},
"mgmt":{
"protocols":{
"system":"none",
"kernel":"none",
"connected":"none",
"static":"none",
"rip":"none",
"ripng":"none",
"ospf":"none",
"ospf6":"none",
"isis":"none",
"bgp":"none",
"pim":"none",
"eigrp":"none",
"nhrp":"none",
"hsls":"none",
"olsr":"none",
"table":"none",
"ldp":"none",
"vnc":"none",
"vnc-direct":"none",
"vnc-rn":"none",
"bgp-direct":"none",
"bgp-direct-to-nve-groups":"none",
"babel":"none",
"sharp":"none",
"pbr":"none",
"bfd":"none",
"openfabric":"none",
"vrrp":"none",
"zebra":"none",
"frr":"none",
"wildcard":"none",
"any":"none"
}
},
"sym_1":{
"protocols":{
"system":"none",
"kernel":"none",
"connected":"none",
"static":"none",
"rip":"none",
"ripng":"none",
"ospf":"none",
"ospf6":"none",
"isis":"none",
"bgp":"bgp-policy",
"pim":"none",
"eigrp":"none",
"nhrp":"none",
"hsls":"none",
"olsr":"none",
"table":"none",
"ldp":"none",
"vnc":"none",
"vnc-direct":"none",
"vnc-rn":"none",
"bgp-direct":"none",
"bgp-direct-to-nve-groups":"none",
"babel":"none",
"sharp":"none",
"pbr":"none",
"bfd":"none",
"openfabric":"none",
"vrrp":"none",
"zebra":"none",
"frr":"none",
"wildcard":"none",
"any":"none"
}
}
}
}
tor-1# show ipv6 nht route-map vrf default json
{
"afi":"ipv6",
"vrfs":{
"default":{
"protocols":{
"system":"none",
"kernel":"kernel-policy",
"connected":"connected-policy",
"static":"none",
"rip":"none",
"ripng":"none",
"ospf":"none",
"ospf6":"none",
"isis":"none",
"bgp":"none",
"pim":"none",
"eigrp":"none",
"nhrp":"none",
"hsls":"none",
"olsr":"none",
"table":"none",
"ldp":"none",
"vnc":"none",
"vnc-direct":"none",
"vnc-rn":"none",
"bgp-direct":"none",
"bgp-direct-to-nve-groups":"none",
"babel":"none",
"sharp":"none",
"pbr":"none",
"bfd":"none",
"openfabric":"none",
"vrrp":"none",
"zebra":"none",
"frr":"none",
"wildcard":"none",
"any":"none"
}
}
}
}
Ticket:#3229016
Issue:3229016
Signed-off-by: Sindhu Parvathi Gopinathan <sgopinathan@nvidia.com>
2022-11-08 06:40:13 +01:00
|
|
|
"IPv4 nexthop tracking table\n"
|
|
|
|
"IPv4 Next Hop tracking filtering status\n"
|
|
|
|
VRF_CMD_HELP_STR
|
|
|
|
"All VRFs\n"
|
|
|
|
JSON_STR)
|
2015-05-20 02:47:20 +02:00
|
|
|
{
|
zebra: json support for show ip nht route-map
Changes:
JSON support added for below commands,
- show ip nht route-map vrf all json
- show ip nht route-map vrf <name> json
- show ipv6 nht route-map vrf all json
- show ipv6 nht route-map vrf <name> json
- show ipv6 nht route-map json
- show ip nht route-map json
Testing Done: Unit testing completed.
tor-1# show ip nht route-map vrf default json
{
"afi":"ipv4",
"vrfs":{
"default":{
"protocols":{
"system":"none",
"kernel":"none",
"connected":"connected-policy",
"static":"none",
"rip":"none",
"ripng":"none",
"ospf":"none",
"ospf6":"none",
"isis":"none",
"bgp":"bgp-policy",
"pim":"none",
"eigrp":"none",
"nhrp":"none",
"hsls":"none",
"olsr":"none",
"table":"none",
"ldp":"none",
"vnc":"none",
"vnc-direct":"none",
"vnc-rn":"none",
"bgp-direct":"none",
"bgp-direct-to-nve-groups":"none",
"babel":"none",
"sharp":"none",
"pbr":"none",
"bfd":"none",
"openfabric":"none",
"vrrp":"none",
"zebra":"none",
"frr":"none",
"wildcard":"none",
"any":"none"
}
}
}
}
tor-1# show ip nht route-map vrf all json
{
"afi":"ipv4",
"vrfs":{
"default":{
"protocols":{
"system":"none",
"kernel":"none",
"connected":"connected-policy",
"static":"none",
"rip":"none",
"ripng":"none",
"ospf":"none",
"ospf6":"none",
"isis":"none",
"bgp":"bgp-policy",
"pim":"none",
"eigrp":"none",
"nhrp":"none",
"hsls":"none",
"olsr":"none",
"table":"none",
"ldp":"none",
"vnc":"none",
"vnc-direct":"none",
"vnc-rn":"none",
"bgp-direct":"none",
"bgp-direct-to-nve-groups":"none",
"babel":"none",
"sharp":"none",
"pbr":"none",
"bfd":"none",
"openfabric":"none",
"vrrp":"none",
"zebra":"none",
"frr":"none",
"wildcard":"none",
"any":"none"
}
},
"mgmt":{
"protocols":{
"system":"none",
"kernel":"none",
"connected":"none",
"static":"none",
"rip":"none",
"ripng":"none",
"ospf":"none",
"ospf6":"none",
"isis":"none",
"bgp":"none",
"pim":"none",
"eigrp":"none",
"nhrp":"none",
"hsls":"none",
"olsr":"none",
"table":"none",
"ldp":"none",
"vnc":"none",
"vnc-direct":"none",
"vnc-rn":"none",
"bgp-direct":"none",
"bgp-direct-to-nve-groups":"none",
"babel":"none",
"sharp":"none",
"pbr":"none",
"bfd":"none",
"openfabric":"none",
"vrrp":"none",
"zebra":"none",
"frr":"none",
"wildcard":"none",
"any":"none"
}
},
"sym_1":{
"protocols":{
"system":"none",
"kernel":"none",
"connected":"none",
"static":"none",
"rip":"none",
"ripng":"none",
"ospf":"none",
"ospf6":"none",
"isis":"none",
"bgp":"bgp-policy",
"pim":"none",
"eigrp":"none",
"nhrp":"none",
"hsls":"none",
"olsr":"none",
"table":"none",
"ldp":"none",
"vnc":"none",
"vnc-direct":"none",
"vnc-rn":"none",
"bgp-direct":"none",
"bgp-direct-to-nve-groups":"none",
"babel":"none",
"sharp":"none",
"pbr":"none",
"bfd":"none",
"openfabric":"none",
"vrrp":"none",
"zebra":"none",
"frr":"none",
"wildcard":"none",
"any":"none"
}
}
}
}
tor-1# show ipv6 nht route-map vrf default json
{
"afi":"ipv6",
"vrfs":{
"default":{
"protocols":{
"system":"none",
"kernel":"kernel-policy",
"connected":"connected-policy",
"static":"none",
"rip":"none",
"ripng":"none",
"ospf":"none",
"ospf6":"none",
"isis":"none",
"bgp":"none",
"pim":"none",
"eigrp":"none",
"nhrp":"none",
"hsls":"none",
"olsr":"none",
"table":"none",
"ldp":"none",
"vnc":"none",
"vnc-direct":"none",
"vnc-rn":"none",
"bgp-direct":"none",
"bgp-direct-to-nve-groups":"none",
"babel":"none",
"sharp":"none",
"pbr":"none",
"bfd":"none",
"openfabric":"none",
"vrrp":"none",
"zebra":"none",
"frr":"none",
"wildcard":"none",
"any":"none"
}
}
}
}
Ticket:#3229016
Issue:3229016
Signed-off-by: Sindhu Parvathi Gopinathan <sgopinathan@nvidia.com>
2022-11-08 06:40:13 +01:00
|
|
|
int ret;
|
|
|
|
bool uj = use_json(argc, argv);
|
|
|
|
|
|
|
|
ret = show_nht_rm(vty, AFI_IP, vrf_all, vrf_name, uj);
|
2015-05-20 02:47:20 +02:00
|
|
|
|
2018-10-11 19:49:34 +02:00
|
|
|
return ret;
|
2015-05-20 02:47:20 +02:00
|
|
|
}
|
|
|
|
|
2020-07-06 17:47:44 +02:00
|
|
|
DEFPY_YANG (ipv6_protocol_nht_rmap,
|
2015-05-20 02:47:20 +02:00
|
|
|
ipv6_protocol_nht_rmap_cmd,
|
2018-10-11 19:48:23 +02:00
|
|
|
"ipv6 nht " FRR_IP6_PROTOCOL_MAP_STR_ZEBRA
|
|
|
|
" $proto route-map ROUTE-MAP$rmap",
|
2015-05-20 02:47:20 +02:00
|
|
|
IP6_STR
|
|
|
|
"Filter Next Hop tracking route resolution\n"
|
2016-12-20 18:31:42 +01:00
|
|
|
FRR_IP6_PROTOCOL_MAP_HELP_STR_ZEBRA
|
2016-09-24 19:42:34 +02:00
|
|
|
"Specify route map\n"
|
2015-05-20 02:47:20 +02:00
|
|
|
"Route map name\n")
|
|
|
|
{
|
2018-10-11 19:48:23 +02:00
|
|
|
int ret, rtype;
|
|
|
|
|
2019-05-11 19:18:29 +02:00
|
|
|
assert(rmap);
|
|
|
|
assert(proto);
|
|
|
|
|
2022-04-28 11:06:20 +02:00
|
|
|
ZEBRA_DECLVAR_CONTEXT_VRF(vrf, zvrf);
|
2018-10-11 19:48:23 +02:00
|
|
|
|
|
|
|
if (!zvrf)
|
|
|
|
return CMD_WARNING;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2016-09-24 19:42:34 +02:00
|
|
|
if (strcasecmp(proto, "any") == 0)
|
2018-10-11 19:48:23 +02:00
|
|
|
rtype = ZEBRA_ROUTE_MAX;
|
2015-05-20 02:47:20 +02:00
|
|
|
else
|
2018-10-11 19:48:23 +02:00
|
|
|
rtype = proto_name2num(proto);
|
|
|
|
if (rtype < 0) {
|
2017-07-13 18:50:29 +02:00
|
|
|
vty_out(vty, "invalid protocol name \"%s\"\n", proto);
|
2017-07-13 21:56:08 +02:00
|
|
|
return CMD_WARNING_CONFIG_FAILED;
|
2015-05-20 02:47:20 +02:00
|
|
|
}
|
2018-10-11 19:46:55 +02:00
|
|
|
|
2018-10-11 19:48:23 +02:00
|
|
|
ret = ip_nht_rm_add(zvrf, rmap, rtype, AFI_IP6);
|
2018-10-11 19:46:55 +02:00
|
|
|
|
2018-10-11 19:48:23 +02:00
|
|
|
return ret;
|
2015-05-20 02:47:20 +02:00
|
|
|
}
|
|
|
|
|
2020-07-06 17:47:44 +02:00
|
|
|
DEFPY_YANG (no_ipv6_protocol_nht_rmap,
|
2015-05-20 02:47:20 +02:00
|
|
|
no_ipv6_protocol_nht_rmap_cmd,
|
2018-10-11 19:48:23 +02:00
|
|
|
"no ipv6 nht " FRR_IP6_PROTOCOL_MAP_STR_ZEBRA
|
|
|
|
" $proto [route-map ROUTE-MAP$rmap]",
|
2015-05-20 02:47:20 +02:00
|
|
|
NO_STR
|
|
|
|
IP6_STR
|
|
|
|
"Filter Next Hop tracking route resolution\n"
|
2017-01-06 15:58:21 +01:00
|
|
|
FRR_IP6_PROTOCOL_MAP_HELP_STR_ZEBRA
|
2016-09-24 19:42:34 +02:00
|
|
|
"Specify route map\n"
|
|
|
|
"Route map name\n")
|
2015-05-20 02:47:20 +02:00
|
|
|
{
|
2018-10-11 19:48:23 +02:00
|
|
|
int ret, rtype;
|
|
|
|
|
2019-05-11 19:18:29 +02:00
|
|
|
assert(proto);
|
|
|
|
|
2022-04-28 11:06:20 +02:00
|
|
|
ZEBRA_DECLVAR_CONTEXT_VRF(vrf, zvrf);
|
2018-10-11 19:48:23 +02:00
|
|
|
|
|
|
|
if (!zvrf)
|
|
|
|
return CMD_WARNING;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2016-09-24 19:42:34 +02:00
|
|
|
if (strcasecmp(proto, "any") == 0)
|
2018-10-11 19:48:23 +02:00
|
|
|
rtype = ZEBRA_ROUTE_MAX;
|
2015-05-20 02:47:20 +02:00
|
|
|
else
|
2018-10-11 19:48:23 +02:00
|
|
|
rtype = proto_name2num(proto);
|
|
|
|
if (rtype < 0) {
|
2017-07-13 18:50:29 +02:00
|
|
|
vty_out(vty, "invalid protocol name \"%s\"\n", proto);
|
2017-07-13 21:56:08 +02:00
|
|
|
return CMD_WARNING_CONFIG_FAILED;
|
2015-05-20 02:47:20 +02:00
|
|
|
}
|
|
|
|
|
2018-10-11 19:48:23 +02:00
|
|
|
ret = ip_nht_rm_del(zvrf, rmap, rtype, AFI_IP6);
|
2015-11-23 19:05:03 +01:00
|
|
|
|
2018-10-11 19:48:23 +02:00
|
|
|
return ret;
|
2015-05-20 02:47:20 +02:00
|
|
|
}
|
|
|
|
|
2020-07-06 17:47:44 +02:00
|
|
|
DEFPY_YANG (show_ipv6_protocol_nht,
|
2015-05-20 02:47:20 +02:00
|
|
|
show_ipv6_protocol_nht_cmd,
|
zebra: json support for show ip nht route-map
Changes:
JSON support added for below commands,
- show ip nht route-map vrf all json
- show ip nht route-map vrf <name> json
- show ipv6 nht route-map vrf all json
- show ipv6 nht route-map vrf <name> json
- show ipv6 nht route-map json
- show ip nht route-map json
Testing Done: Unit testing completed.
tor-1# show ip nht route-map vrf default json
{
"afi":"ipv4",
"vrfs":{
"default":{
"protocols":{
"system":"none",
"kernel":"none",
"connected":"connected-policy",
"static":"none",
"rip":"none",
"ripng":"none",
"ospf":"none",
"ospf6":"none",
"isis":"none",
"bgp":"bgp-policy",
"pim":"none",
"eigrp":"none",
"nhrp":"none",
"hsls":"none",
"olsr":"none",
"table":"none",
"ldp":"none",
"vnc":"none",
"vnc-direct":"none",
"vnc-rn":"none",
"bgp-direct":"none",
"bgp-direct-to-nve-groups":"none",
"babel":"none",
"sharp":"none",
"pbr":"none",
"bfd":"none",
"openfabric":"none",
"vrrp":"none",
"zebra":"none",
"frr":"none",
"wildcard":"none",
"any":"none"
}
}
}
}
tor-1# show ip nht route-map vrf all json
{
"afi":"ipv4",
"vrfs":{
"default":{
"protocols":{
"system":"none",
"kernel":"none",
"connected":"connected-policy",
"static":"none",
"rip":"none",
"ripng":"none",
"ospf":"none",
"ospf6":"none",
"isis":"none",
"bgp":"bgp-policy",
"pim":"none",
"eigrp":"none",
"nhrp":"none",
"hsls":"none",
"olsr":"none",
"table":"none",
"ldp":"none",
"vnc":"none",
"vnc-direct":"none",
"vnc-rn":"none",
"bgp-direct":"none",
"bgp-direct-to-nve-groups":"none",
"babel":"none",
"sharp":"none",
"pbr":"none",
"bfd":"none",
"openfabric":"none",
"vrrp":"none",
"zebra":"none",
"frr":"none",
"wildcard":"none",
"any":"none"
}
},
"mgmt":{
"protocols":{
"system":"none",
"kernel":"none",
"connected":"none",
"static":"none",
"rip":"none",
"ripng":"none",
"ospf":"none",
"ospf6":"none",
"isis":"none",
"bgp":"none",
"pim":"none",
"eigrp":"none",
"nhrp":"none",
"hsls":"none",
"olsr":"none",
"table":"none",
"ldp":"none",
"vnc":"none",
"vnc-direct":"none",
"vnc-rn":"none",
"bgp-direct":"none",
"bgp-direct-to-nve-groups":"none",
"babel":"none",
"sharp":"none",
"pbr":"none",
"bfd":"none",
"openfabric":"none",
"vrrp":"none",
"zebra":"none",
"frr":"none",
"wildcard":"none",
"any":"none"
}
},
"sym_1":{
"protocols":{
"system":"none",
"kernel":"none",
"connected":"none",
"static":"none",
"rip":"none",
"ripng":"none",
"ospf":"none",
"ospf6":"none",
"isis":"none",
"bgp":"bgp-policy",
"pim":"none",
"eigrp":"none",
"nhrp":"none",
"hsls":"none",
"olsr":"none",
"table":"none",
"ldp":"none",
"vnc":"none",
"vnc-direct":"none",
"vnc-rn":"none",
"bgp-direct":"none",
"bgp-direct-to-nve-groups":"none",
"babel":"none",
"sharp":"none",
"pbr":"none",
"bfd":"none",
"openfabric":"none",
"vrrp":"none",
"zebra":"none",
"frr":"none",
"wildcard":"none",
"any":"none"
}
}
}
}
tor-1# show ipv6 nht route-map vrf default json
{
"afi":"ipv6",
"vrfs":{
"default":{
"protocols":{
"system":"none",
"kernel":"kernel-policy",
"connected":"connected-policy",
"static":"none",
"rip":"none",
"ripng":"none",
"ospf":"none",
"ospf6":"none",
"isis":"none",
"bgp":"none",
"pim":"none",
"eigrp":"none",
"nhrp":"none",
"hsls":"none",
"olsr":"none",
"table":"none",
"ldp":"none",
"vnc":"none",
"vnc-direct":"none",
"vnc-rn":"none",
"bgp-direct":"none",
"bgp-direct-to-nve-groups":"none",
"babel":"none",
"sharp":"none",
"pbr":"none",
"bfd":"none",
"openfabric":"none",
"vrrp":"none",
"zebra":"none",
"frr":"none",
"wildcard":"none",
"any":"none"
}
}
}
}
Ticket:#3229016
Issue:3229016
Signed-off-by: Sindhu Parvathi Gopinathan <sgopinathan@nvidia.com>
2022-11-08 06:40:13 +01:00
|
|
|
"show ipv6 nht route-map [vrf <NAME$vrf_name|all$vrf_all>] [json]",
|
2016-11-30 00:07:11 +01:00
|
|
|
SHOW_STR
|
|
|
|
IP6_STR
|
zebra: json support for show ip nht route-map
Changes:
JSON support added for below commands,
- show ip nht route-map vrf all json
- show ip nht route-map vrf <name> json
- show ipv6 nht route-map vrf all json
- show ipv6 nht route-map vrf <name> json
- show ipv6 nht route-map json
- show ip nht route-map json
Testing Done: Unit testing completed.
tor-1# show ip nht route-map vrf default json
{
"afi":"ipv4",
"vrfs":{
"default":{
"protocols":{
"system":"none",
"kernel":"none",
"connected":"connected-policy",
"static":"none",
"rip":"none",
"ripng":"none",
"ospf":"none",
"ospf6":"none",
"isis":"none",
"bgp":"bgp-policy",
"pim":"none",
"eigrp":"none",
"nhrp":"none",
"hsls":"none",
"olsr":"none",
"table":"none",
"ldp":"none",
"vnc":"none",
"vnc-direct":"none",
"vnc-rn":"none",
"bgp-direct":"none",
"bgp-direct-to-nve-groups":"none",
"babel":"none",
"sharp":"none",
"pbr":"none",
"bfd":"none",
"openfabric":"none",
"vrrp":"none",
"zebra":"none",
"frr":"none",
"wildcard":"none",
"any":"none"
}
}
}
}
tor-1# show ip nht route-map vrf all json
{
"afi":"ipv4",
"vrfs":{
"default":{
"protocols":{
"system":"none",
"kernel":"none",
"connected":"connected-policy",
"static":"none",
"rip":"none",
"ripng":"none",
"ospf":"none",
"ospf6":"none",
"isis":"none",
"bgp":"bgp-policy",
"pim":"none",
"eigrp":"none",
"nhrp":"none",
"hsls":"none",
"olsr":"none",
"table":"none",
"ldp":"none",
"vnc":"none",
"vnc-direct":"none",
"vnc-rn":"none",
"bgp-direct":"none",
"bgp-direct-to-nve-groups":"none",
"babel":"none",
"sharp":"none",
"pbr":"none",
"bfd":"none",
"openfabric":"none",
"vrrp":"none",
"zebra":"none",
"frr":"none",
"wildcard":"none",
"any":"none"
}
},
"mgmt":{
"protocols":{
"system":"none",
"kernel":"none",
"connected":"none",
"static":"none",
"rip":"none",
"ripng":"none",
"ospf":"none",
"ospf6":"none",
"isis":"none",
"bgp":"none",
"pim":"none",
"eigrp":"none",
"nhrp":"none",
"hsls":"none",
"olsr":"none",
"table":"none",
"ldp":"none",
"vnc":"none",
"vnc-direct":"none",
"vnc-rn":"none",
"bgp-direct":"none",
"bgp-direct-to-nve-groups":"none",
"babel":"none",
"sharp":"none",
"pbr":"none",
"bfd":"none",
"openfabric":"none",
"vrrp":"none",
"zebra":"none",
"frr":"none",
"wildcard":"none",
"any":"none"
}
},
"sym_1":{
"protocols":{
"system":"none",
"kernel":"none",
"connected":"none",
"static":"none",
"rip":"none",
"ripng":"none",
"ospf":"none",
"ospf6":"none",
"isis":"none",
"bgp":"bgp-policy",
"pim":"none",
"eigrp":"none",
"nhrp":"none",
"hsls":"none",
"olsr":"none",
"table":"none",
"ldp":"none",
"vnc":"none",
"vnc-direct":"none",
"vnc-rn":"none",
"bgp-direct":"none",
"bgp-direct-to-nve-groups":"none",
"babel":"none",
"sharp":"none",
"pbr":"none",
"bfd":"none",
"openfabric":"none",
"vrrp":"none",
"zebra":"none",
"frr":"none",
"wildcard":"none",
"any":"none"
}
}
}
}
tor-1# show ipv6 nht route-map vrf default json
{
"afi":"ipv6",
"vrfs":{
"default":{
"protocols":{
"system":"none",
"kernel":"kernel-policy",
"connected":"connected-policy",
"static":"none",
"rip":"none",
"ripng":"none",
"ospf":"none",
"ospf6":"none",
"isis":"none",
"bgp":"none",
"pim":"none",
"eigrp":"none",
"nhrp":"none",
"hsls":"none",
"olsr":"none",
"table":"none",
"ldp":"none",
"vnc":"none",
"vnc-direct":"none",
"vnc-rn":"none",
"bgp-direct":"none",
"bgp-direct-to-nve-groups":"none",
"babel":"none",
"sharp":"none",
"pbr":"none",
"bfd":"none",
"openfabric":"none",
"vrrp":"none",
"zebra":"none",
"frr":"none",
"wildcard":"none",
"any":"none"
}
}
}
}
Ticket:#3229016
Issue:3229016
Signed-off-by: Sindhu Parvathi Gopinathan <sgopinathan@nvidia.com>
2022-11-08 06:40:13 +01:00
|
|
|
"IPv6 nexthop tracking table\n"
|
|
|
|
"IPv6 Next Hop tracking filtering status\n"
|
|
|
|
VRF_CMD_HELP_STR
|
|
|
|
"All VRFs\n"
|
|
|
|
JSON_STR)
|
2015-05-20 02:47:20 +02:00
|
|
|
{
|
zebra: json support for show ip nht route-map
Changes:
JSON support added for below commands,
- show ip nht route-map vrf all json
- show ip nht route-map vrf <name> json
- show ipv6 nht route-map vrf all json
- show ipv6 nht route-map vrf <name> json
- show ipv6 nht route-map json
- show ip nht route-map json
Testing Done: Unit testing completed.
tor-1# show ip nht route-map vrf default json
{
"afi":"ipv4",
"vrfs":{
"default":{
"protocols":{
"system":"none",
"kernel":"none",
"connected":"connected-policy",
"static":"none",
"rip":"none",
"ripng":"none",
"ospf":"none",
"ospf6":"none",
"isis":"none",
"bgp":"bgp-policy",
"pim":"none",
"eigrp":"none",
"nhrp":"none",
"hsls":"none",
"olsr":"none",
"table":"none",
"ldp":"none",
"vnc":"none",
"vnc-direct":"none",
"vnc-rn":"none",
"bgp-direct":"none",
"bgp-direct-to-nve-groups":"none",
"babel":"none",
"sharp":"none",
"pbr":"none",
"bfd":"none",
"openfabric":"none",
"vrrp":"none",
"zebra":"none",
"frr":"none",
"wildcard":"none",
"any":"none"
}
}
}
}
tor-1# show ip nht route-map vrf all json
{
"afi":"ipv4",
"vrfs":{
"default":{
"protocols":{
"system":"none",
"kernel":"none",
"connected":"connected-policy",
"static":"none",
"rip":"none",
"ripng":"none",
"ospf":"none",
"ospf6":"none",
"isis":"none",
"bgp":"bgp-policy",
"pim":"none",
"eigrp":"none",
"nhrp":"none",
"hsls":"none",
"olsr":"none",
"table":"none",
"ldp":"none",
"vnc":"none",
"vnc-direct":"none",
"vnc-rn":"none",
"bgp-direct":"none",
"bgp-direct-to-nve-groups":"none",
"babel":"none",
"sharp":"none",
"pbr":"none",
"bfd":"none",
"openfabric":"none",
"vrrp":"none",
"zebra":"none",
"frr":"none",
"wildcard":"none",
"any":"none"
}
},
"mgmt":{
"protocols":{
"system":"none",
"kernel":"none",
"connected":"none",
"static":"none",
"rip":"none",
"ripng":"none",
"ospf":"none",
"ospf6":"none",
"isis":"none",
"bgp":"none",
"pim":"none",
"eigrp":"none",
"nhrp":"none",
"hsls":"none",
"olsr":"none",
"table":"none",
"ldp":"none",
"vnc":"none",
"vnc-direct":"none",
"vnc-rn":"none",
"bgp-direct":"none",
"bgp-direct-to-nve-groups":"none",
"babel":"none",
"sharp":"none",
"pbr":"none",
"bfd":"none",
"openfabric":"none",
"vrrp":"none",
"zebra":"none",
"frr":"none",
"wildcard":"none",
"any":"none"
}
},
"sym_1":{
"protocols":{
"system":"none",
"kernel":"none",
"connected":"none",
"static":"none",
"rip":"none",
"ripng":"none",
"ospf":"none",
"ospf6":"none",
"isis":"none",
"bgp":"bgp-policy",
"pim":"none",
"eigrp":"none",
"nhrp":"none",
"hsls":"none",
"olsr":"none",
"table":"none",
"ldp":"none",
"vnc":"none",
"vnc-direct":"none",
"vnc-rn":"none",
"bgp-direct":"none",
"bgp-direct-to-nve-groups":"none",
"babel":"none",
"sharp":"none",
"pbr":"none",
"bfd":"none",
"openfabric":"none",
"vrrp":"none",
"zebra":"none",
"frr":"none",
"wildcard":"none",
"any":"none"
}
}
}
}
tor-1# show ipv6 nht route-map vrf default json
{
"afi":"ipv6",
"vrfs":{
"default":{
"protocols":{
"system":"none",
"kernel":"kernel-policy",
"connected":"connected-policy",
"static":"none",
"rip":"none",
"ripng":"none",
"ospf":"none",
"ospf6":"none",
"isis":"none",
"bgp":"none",
"pim":"none",
"eigrp":"none",
"nhrp":"none",
"hsls":"none",
"olsr":"none",
"table":"none",
"ldp":"none",
"vnc":"none",
"vnc-direct":"none",
"vnc-rn":"none",
"bgp-direct":"none",
"bgp-direct-to-nve-groups":"none",
"babel":"none",
"sharp":"none",
"pbr":"none",
"bfd":"none",
"openfabric":"none",
"vrrp":"none",
"zebra":"none",
"frr":"none",
"wildcard":"none",
"any":"none"
}
}
}
}
Ticket:#3229016
Issue:3229016
Signed-off-by: Sindhu Parvathi Gopinathan <sgopinathan@nvidia.com>
2022-11-08 06:40:13 +01:00
|
|
|
int ret;
|
|
|
|
bool uj = use_json(argc, argv);
|
|
|
|
|
|
|
|
ret = show_nht_rm(vty, AFI_IP6, vrf_all, vrf_name, uj);
|
2015-05-20 02:47:20 +02:00
|
|
|
|
2018-10-11 19:49:34 +02:00
|
|
|
return ret;
|
2015-05-20 02:47:20 +02:00
|
|
|
}
|
|
|
|
|
2007-05-04 22:13:20 +02:00
|
|
|
/*XXXXXXXXXXXXXXXXXXXXXXXXXXXX*/
|
|
|
|
|
|
|
|
/* `match ip next-hop IP_ACCESS_LIST' */
|
|
|
|
|
|
|
|
/* Match function return 1 if match is success else return zero. */
|
lib: Introducing a 3rd state for route-map match cmd: RMAP_NOOP
Introducing a 3rd state for route_map_apply library function: RMAP_NOOP
Traditionally route map MATCH rule apis were designed to return
a binary response, consisting of either RMAP_MATCH or RMAP_NOMATCH.
(Route-map SET rule apis return RMAP_OKAY or RMAP_ERROR).
Depending on this response, the following statemachine decided the
course of action:
State1:
If match cmd returns RMAP_MATCH then, keep existing behaviour.
If routemap type is PERMIT, execute set cmds or call cmds if applicable,
otherwise PERMIT!
Else If routemap type is DENY, we DENYMATCH right away
State2:
If match cmd returns RMAP_NOMATCH, continue on to next route-map. If there
are no other rules or if all the rules return RMAP_NOMATCH, return DENYMATCH
We require a 3rd state because of the following situation:
The issue - what if, the rule api needs to abort or ignore a rule?:
"match evpn vni xx" route-map filter can be applied to incoming routes
regardless of whether the tunnel type is vxlan or mpls.
This rule should be N/A for mpls based evpn route, but applicable to only
vxlan based evpn route.
Also, this rule should be applicable for routes with VNI label only, and
not for routes without labels. For example, type 3 and type 4 EVPN routes
do not have labels, so, this match cmd should let them through.
Today, the filter produces either a match or nomatch response regardless of
whether it is mpls/vxlan, resulting in either permitting or denying the
route.. So an mpls evpn route may get filtered out incorrectly.
Eg: "route-map RM1 permit 10 ; match evpn vni 20" or
"route-map RM2 deny 20 ; match vni 20"
With the introduction of the 3rd state, we can abort this rule check safely.
How? The rules api can now return RMAP_NOOP to indicate
that it encountered an invalid check, and needs to abort just that rule,
but continue with other rules.
As a result we have a 3rd state:
State3:
If match cmd returned RMAP_NOOP
Then, proceed to other route-map, otherwise if there are no more
rules or if all the rules return RMAP_NOOP, then, return RMAP_PERMITMATCH.
Signed-off-by: Lakshman Krishnamoorthy <lkrishnamoor@vmware.com>
2019-06-19 23:04:36 +02:00
|
|
|
static enum route_map_cmd_result_t
|
2020-11-14 01:35:20 +01:00
|
|
|
route_match_ip_next_hop(void *rule, const struct prefix *prefix, void *object)
|
2007-05-04 22:13:20 +02:00
|
|
|
{
|
|
|
|
struct access_list *alist;
|
2023-08-11 16:12:06 +02:00
|
|
|
struct zebra_rmap_obj *rm_data;
|
2007-05-04 22:13:20 +02:00
|
|
|
struct prefix_ipv4 p;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2023-08-11 16:12:06 +02:00
|
|
|
rm_data = object;
|
|
|
|
if (!rm_data)
|
2020-11-14 01:35:20 +01:00
|
|
|
return RMAP_NOMATCH;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2023-08-11 16:12:06 +02:00
|
|
|
switch (rm_data->nexthop->type) {
|
2020-11-14 01:35:20 +01:00
|
|
|
case NEXTHOP_TYPE_IFINDEX:
|
|
|
|
/* Interface routes can't match ip next-hop */
|
|
|
|
return RMAP_NOMATCH;
|
|
|
|
case NEXTHOP_TYPE_IPV4_IFINDEX:
|
|
|
|
case NEXTHOP_TYPE_IPV4:
|
|
|
|
p.family = AF_INET;
|
2023-08-11 16:12:06 +02:00
|
|
|
p.prefix = rm_data->nexthop->gate.ipv4;
|
2020-11-14 01:35:20 +01:00
|
|
|
p.prefixlen = IPV4_MAX_BITLEN;
|
|
|
|
break;
|
2023-01-30 16:05:58 +01:00
|
|
|
case NEXTHOP_TYPE_IPV6:
|
|
|
|
case NEXTHOP_TYPE_IPV6_IFINDEX:
|
|
|
|
case NEXTHOP_TYPE_BLACKHOLE:
|
2020-11-14 01:35:20 +01:00
|
|
|
return RMAP_NOMATCH;
|
2017-07-17 14:03:14 +02:00
|
|
|
}
|
2020-11-14 01:35:20 +01:00
|
|
|
alist = access_list_lookup(AFI_IP, (char *)rule);
|
2023-02-13 15:35:55 +01:00
|
|
|
if (alist == NULL) {
|
2023-02-17 21:02:14 +01:00
|
|
|
if (unlikely(CHECK_FLAG(rmap_debug, DEBUG_ROUTEMAP_DETAIL)))
|
2023-02-13 15:35:55 +01:00
|
|
|
zlog_debug(
|
|
|
|
"%s: Access-List Specified: %s does not exist defaulting to NO_MATCH",
|
|
|
|
__func__, (char *)rule);
|
2020-11-14 01:35:20 +01:00
|
|
|
return RMAP_NOMATCH;
|
2023-02-13 15:35:55 +01:00
|
|
|
}
|
2020-11-14 01:35:20 +01:00
|
|
|
|
|
|
|
return (access_list_apply(alist, &p) == FILTER_DENY ? RMAP_NOMATCH
|
|
|
|
: RMAP_MATCH);
|
2007-05-04 22:13:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Route map `ip next-hop' match statement. `arg' should be
|
|
|
|
access-list name. */
|
|
|
|
static void *route_match_ip_next_hop_compile(const char *arg)
|
|
|
|
{
|
|
|
|
return XSTRDUP(MTYPE_ROUTE_MAP_COMPILED, arg);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Free route map's compiled `. */
|
|
|
|
static void route_match_ip_next_hop_free(void *rule)
|
|
|
|
{
|
|
|
|
XFREE(MTYPE_ROUTE_MAP_COMPILED, rule);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Route map commands for ip next-hop matching. */
|
2019-11-20 17:20:58 +01:00
|
|
|
static const struct route_map_rule_cmd route_match_ip_next_hop_cmd = {
|
|
|
|
"ip next-hop",
|
|
|
|
route_match_ip_next_hop,
|
|
|
|
route_match_ip_next_hop_compile,
|
|
|
|
route_match_ip_next_hop_free
|
|
|
|
};
|
2014-06-04 06:53:35 +02:00
|
|
|
|
2007-05-04 22:13:20 +02:00
|
|
|
/* `match ip next-hop prefix-list PREFIX_LIST' */
|
|
|
|
|
lib: Introducing a 3rd state for route-map match cmd: RMAP_NOOP
Introducing a 3rd state for route_map_apply library function: RMAP_NOOP
Traditionally route map MATCH rule apis were designed to return
a binary response, consisting of either RMAP_MATCH or RMAP_NOMATCH.
(Route-map SET rule apis return RMAP_OKAY or RMAP_ERROR).
Depending on this response, the following statemachine decided the
course of action:
State1:
If match cmd returns RMAP_MATCH then, keep existing behaviour.
If routemap type is PERMIT, execute set cmds or call cmds if applicable,
otherwise PERMIT!
Else If routemap type is DENY, we DENYMATCH right away
State2:
If match cmd returns RMAP_NOMATCH, continue on to next route-map. If there
are no other rules or if all the rules return RMAP_NOMATCH, return DENYMATCH
We require a 3rd state because of the following situation:
The issue - what if, the rule api needs to abort or ignore a rule?:
"match evpn vni xx" route-map filter can be applied to incoming routes
regardless of whether the tunnel type is vxlan or mpls.
This rule should be N/A for mpls based evpn route, but applicable to only
vxlan based evpn route.
Also, this rule should be applicable for routes with VNI label only, and
not for routes without labels. For example, type 3 and type 4 EVPN routes
do not have labels, so, this match cmd should let them through.
Today, the filter produces either a match or nomatch response regardless of
whether it is mpls/vxlan, resulting in either permitting or denying the
route.. So an mpls evpn route may get filtered out incorrectly.
Eg: "route-map RM1 permit 10 ; match evpn vni 20" or
"route-map RM2 deny 20 ; match vni 20"
With the introduction of the 3rd state, we can abort this rule check safely.
How? The rules api can now return RMAP_NOOP to indicate
that it encountered an invalid check, and needs to abort just that rule,
but continue with other rules.
As a result we have a 3rd state:
State3:
If match cmd returned RMAP_NOOP
Then, proceed to other route-map, otherwise if there are no more
rules or if all the rules return RMAP_NOOP, then, return RMAP_PERMITMATCH.
Signed-off-by: Lakshman Krishnamoorthy <lkrishnamoor@vmware.com>
2019-06-19 23:04:36 +02:00
|
|
|
static enum route_map_cmd_result_t
|
2018-07-12 22:05:19 +02:00
|
|
|
route_match_ip_next_hop_prefix_list(void *rule, const struct prefix *prefix,
|
2020-11-14 01:35:20 +01:00
|
|
|
void *object)
|
2007-05-04 22:13:20 +02:00
|
|
|
{
|
|
|
|
struct prefix_list *plist;
|
2023-08-11 16:12:06 +02:00
|
|
|
struct zebra_rmap_obj *rm_data;
|
2007-05-04 22:13:20 +02:00
|
|
|
struct prefix_ipv4 p;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2023-08-11 16:12:06 +02:00
|
|
|
rm_data = (struct zebra_rmap_obj *)object;
|
|
|
|
if (!rm_data)
|
2020-11-14 01:35:20 +01:00
|
|
|
return RMAP_NOMATCH;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2023-08-11 16:12:06 +02:00
|
|
|
switch (rm_data->nexthop->type) {
|
2020-11-14 01:35:20 +01:00
|
|
|
case NEXTHOP_TYPE_IFINDEX:
|
|
|
|
/* Interface routes can't match ip next-hop */
|
|
|
|
return RMAP_NOMATCH;
|
|
|
|
case NEXTHOP_TYPE_IPV4_IFINDEX:
|
|
|
|
case NEXTHOP_TYPE_IPV4:
|
|
|
|
p.family = AF_INET;
|
2023-08-11 16:12:06 +02:00
|
|
|
p.prefix = rm_data->nexthop->gate.ipv4;
|
2020-11-14 01:35:20 +01:00
|
|
|
p.prefixlen = IPV4_MAX_BITLEN;
|
|
|
|
break;
|
2023-01-30 16:05:58 +01:00
|
|
|
case NEXTHOP_TYPE_IPV6:
|
|
|
|
case NEXTHOP_TYPE_IPV6_IFINDEX:
|
|
|
|
case NEXTHOP_TYPE_BLACKHOLE:
|
2020-11-14 01:35:20 +01:00
|
|
|
return RMAP_NOMATCH;
|
2007-05-04 22:13:20 +02:00
|
|
|
}
|
2020-11-14 01:35:20 +01:00
|
|
|
plist = prefix_list_lookup(AFI_IP, (char *)rule);
|
2023-02-13 15:34:38 +01:00
|
|
|
if (plist == NULL) {
|
2023-02-17 21:02:14 +01:00
|
|
|
if (unlikely(CHECK_FLAG(rmap_debug, DEBUG_ROUTEMAP_DETAIL)))
|
2023-02-13 15:34:38 +01:00
|
|
|
zlog_debug(
|
|
|
|
"%s: Prefix List %s specified does not exist defaulting to NO_MATCH",
|
|
|
|
__func__, (char *)rule);
|
2020-11-14 01:35:20 +01:00
|
|
|
return RMAP_NOMATCH;
|
2023-02-13 15:34:38 +01:00
|
|
|
}
|
2020-11-14 01:35:20 +01:00
|
|
|
|
|
|
|
return (prefix_list_apply(plist, &p) == PREFIX_DENY ? RMAP_NOMATCH
|
|
|
|
: RMAP_MATCH);
|
2007-05-04 22:13:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void *route_match_ip_next_hop_prefix_list_compile(const char *arg)
|
|
|
|
{
|
|
|
|
return XSTRDUP(MTYPE_ROUTE_MAP_COMPILED, arg);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void route_match_ip_next_hop_prefix_list_free(void *rule)
|
|
|
|
{
|
|
|
|
XFREE(MTYPE_ROUTE_MAP_COMPILED, rule);
|
|
|
|
}
|
|
|
|
|
2019-11-20 17:20:58 +01:00
|
|
|
static const struct route_map_rule_cmd
|
|
|
|
route_match_ip_next_hop_prefix_list_cmd = {
|
|
|
|
"ip next-hop prefix-list",
|
|
|
|
route_match_ip_next_hop_prefix_list,
|
2007-05-04 22:13:20 +02:00
|
|
|
route_match_ip_next_hop_prefix_list_compile,
|
2019-11-20 17:20:58 +01:00
|
|
|
route_match_ip_next_hop_prefix_list_free
|
|
|
|
};
|
2014-06-04 06:53:35 +02:00
|
|
|
|
2007-05-04 22:13:20 +02:00
|
|
|
/* `match ip address IP_ACCESS_LIST' */
|
|
|
|
|
|
|
|
/* Match function should return 1 if match is success else return
|
|
|
|
zero. */
|
lib: Introducing a 3rd state for route-map match cmd: RMAP_NOOP
Introducing a 3rd state for route_map_apply library function: RMAP_NOOP
Traditionally route map MATCH rule apis were designed to return
a binary response, consisting of either RMAP_MATCH or RMAP_NOMATCH.
(Route-map SET rule apis return RMAP_OKAY or RMAP_ERROR).
Depending on this response, the following statemachine decided the
course of action:
State1:
If match cmd returns RMAP_MATCH then, keep existing behaviour.
If routemap type is PERMIT, execute set cmds or call cmds if applicable,
otherwise PERMIT!
Else If routemap type is DENY, we DENYMATCH right away
State2:
If match cmd returns RMAP_NOMATCH, continue on to next route-map. If there
are no other rules or if all the rules return RMAP_NOMATCH, return DENYMATCH
We require a 3rd state because of the following situation:
The issue - what if, the rule api needs to abort or ignore a rule?:
"match evpn vni xx" route-map filter can be applied to incoming routes
regardless of whether the tunnel type is vxlan or mpls.
This rule should be N/A for mpls based evpn route, but applicable to only
vxlan based evpn route.
Also, this rule should be applicable for routes with VNI label only, and
not for routes without labels. For example, type 3 and type 4 EVPN routes
do not have labels, so, this match cmd should let them through.
Today, the filter produces either a match or nomatch response regardless of
whether it is mpls/vxlan, resulting in either permitting or denying the
route.. So an mpls evpn route may get filtered out incorrectly.
Eg: "route-map RM1 permit 10 ; match evpn vni 20" or
"route-map RM2 deny 20 ; match vni 20"
With the introduction of the 3rd state, we can abort this rule check safely.
How? The rules api can now return RMAP_NOOP to indicate
that it encountered an invalid check, and needs to abort just that rule,
but continue with other rules.
As a result we have a 3rd state:
State3:
If match cmd returned RMAP_NOOP
Then, proceed to other route-map, otherwise if there are no more
rules or if all the rules return RMAP_NOOP, then, return RMAP_PERMITMATCH.
Signed-off-by: Lakshman Krishnamoorthy <lkrishnamoor@vmware.com>
2019-06-19 23:04:36 +02:00
|
|
|
static enum route_map_cmd_result_t
|
|
|
|
route_match_address(afi_t afi, void *rule, const struct prefix *prefix,
|
2020-11-14 01:35:20 +01:00
|
|
|
void *object)
|
2007-05-04 22:13:20 +02:00
|
|
|
{
|
|
|
|
struct access_list *alist;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2020-11-14 01:35:20 +01:00
|
|
|
alist = access_list_lookup(afi, (char *)rule);
|
2023-02-13 15:35:55 +01:00
|
|
|
if (alist == NULL) {
|
2023-02-17 21:02:14 +01:00
|
|
|
if (unlikely(CHECK_FLAG(rmap_debug, DEBUG_ROUTEMAP_DETAIL)))
|
2023-02-13 15:35:55 +01:00
|
|
|
zlog_debug(
|
|
|
|
"%s: Access-List Specified: %s does not exist defaulting to NO_MATCH",
|
|
|
|
__func__, (char *)rule);
|
2020-11-14 01:35:20 +01:00
|
|
|
return RMAP_NOMATCH;
|
2023-02-13 15:35:55 +01:00
|
|
|
}
|
2007-05-04 22:13:20 +02:00
|
|
|
|
2020-11-14 01:35:20 +01:00
|
|
|
return (access_list_apply(alist, prefix) == FILTER_DENY ? RMAP_NOMATCH
|
|
|
|
: RMAP_MATCH);
|
2007-05-04 22:13:20 +02:00
|
|
|
}
|
|
|
|
|
lib: Introducing a 3rd state for route-map match cmd: RMAP_NOOP
Introducing a 3rd state for route_map_apply library function: RMAP_NOOP
Traditionally route map MATCH rule apis were designed to return
a binary response, consisting of either RMAP_MATCH or RMAP_NOMATCH.
(Route-map SET rule apis return RMAP_OKAY or RMAP_ERROR).
Depending on this response, the following statemachine decided the
course of action:
State1:
If match cmd returns RMAP_MATCH then, keep existing behaviour.
If routemap type is PERMIT, execute set cmds or call cmds if applicable,
otherwise PERMIT!
Else If routemap type is DENY, we DENYMATCH right away
State2:
If match cmd returns RMAP_NOMATCH, continue on to next route-map. If there
are no other rules or if all the rules return RMAP_NOMATCH, return DENYMATCH
We require a 3rd state because of the following situation:
The issue - what if, the rule api needs to abort or ignore a rule?:
"match evpn vni xx" route-map filter can be applied to incoming routes
regardless of whether the tunnel type is vxlan or mpls.
This rule should be N/A for mpls based evpn route, but applicable to only
vxlan based evpn route.
Also, this rule should be applicable for routes with VNI label only, and
not for routes without labels. For example, type 3 and type 4 EVPN routes
do not have labels, so, this match cmd should let them through.
Today, the filter produces either a match or nomatch response regardless of
whether it is mpls/vxlan, resulting in either permitting or denying the
route.. So an mpls evpn route may get filtered out incorrectly.
Eg: "route-map RM1 permit 10 ; match evpn vni 20" or
"route-map RM2 deny 20 ; match vni 20"
With the introduction of the 3rd state, we can abort this rule check safely.
How? The rules api can now return RMAP_NOOP to indicate
that it encountered an invalid check, and needs to abort just that rule,
but continue with other rules.
As a result we have a 3rd state:
State3:
If match cmd returned RMAP_NOOP
Then, proceed to other route-map, otherwise if there are no more
rules or if all the rules return RMAP_NOOP, then, return RMAP_PERMITMATCH.
Signed-off-by: Lakshman Krishnamoorthy <lkrishnamoor@vmware.com>
2019-06-19 23:04:36 +02:00
|
|
|
static enum route_map_cmd_result_t
|
2020-11-14 01:35:20 +01:00
|
|
|
route_match_ip_address(void *rule, const struct prefix *prefix, void *object)
|
2018-11-07 01:25:58 +01:00
|
|
|
{
|
2020-11-14 01:35:20 +01:00
|
|
|
return route_match_address(AFI_IP, rule, prefix, object);
|
2018-11-07 01:25:58 +01:00
|
|
|
}
|
|
|
|
|
lib: Introducing a 3rd state for route-map match cmd: RMAP_NOOP
Introducing a 3rd state for route_map_apply library function: RMAP_NOOP
Traditionally route map MATCH rule apis were designed to return
a binary response, consisting of either RMAP_MATCH or RMAP_NOMATCH.
(Route-map SET rule apis return RMAP_OKAY or RMAP_ERROR).
Depending on this response, the following statemachine decided the
course of action:
State1:
If match cmd returns RMAP_MATCH then, keep existing behaviour.
If routemap type is PERMIT, execute set cmds or call cmds if applicable,
otherwise PERMIT!
Else If routemap type is DENY, we DENYMATCH right away
State2:
If match cmd returns RMAP_NOMATCH, continue on to next route-map. If there
are no other rules or if all the rules return RMAP_NOMATCH, return DENYMATCH
We require a 3rd state because of the following situation:
The issue - what if, the rule api needs to abort or ignore a rule?:
"match evpn vni xx" route-map filter can be applied to incoming routes
regardless of whether the tunnel type is vxlan or mpls.
This rule should be N/A for mpls based evpn route, but applicable to only
vxlan based evpn route.
Also, this rule should be applicable for routes with VNI label only, and
not for routes without labels. For example, type 3 and type 4 EVPN routes
do not have labels, so, this match cmd should let them through.
Today, the filter produces either a match or nomatch response regardless of
whether it is mpls/vxlan, resulting in either permitting or denying the
route.. So an mpls evpn route may get filtered out incorrectly.
Eg: "route-map RM1 permit 10 ; match evpn vni 20" or
"route-map RM2 deny 20 ; match vni 20"
With the introduction of the 3rd state, we can abort this rule check safely.
How? The rules api can now return RMAP_NOOP to indicate
that it encountered an invalid check, and needs to abort just that rule,
but continue with other rules.
As a result we have a 3rd state:
State3:
If match cmd returned RMAP_NOOP
Then, proceed to other route-map, otherwise if there are no more
rules or if all the rules return RMAP_NOOP, then, return RMAP_PERMITMATCH.
Signed-off-by: Lakshman Krishnamoorthy <lkrishnamoor@vmware.com>
2019-06-19 23:04:36 +02:00
|
|
|
static enum route_map_cmd_result_t
|
2020-11-14 01:35:20 +01:00
|
|
|
route_match_ipv6_address(void *rule, const struct prefix *prefix, void *object)
|
2018-11-07 01:25:58 +01:00
|
|
|
{
|
2020-11-14 01:35:20 +01:00
|
|
|
return route_match_address(AFI_IP6, rule, prefix, object);
|
2018-11-07 01:25:58 +01:00
|
|
|
}
|
|
|
|
|
2007-05-04 22:13:20 +02:00
|
|
|
/* Route map `ip address' match statement. `arg' should be
|
|
|
|
access-list name. */
|
2018-11-07 01:25:58 +01:00
|
|
|
static void *route_match_address_compile(const char *arg)
|
2007-05-04 22:13:20 +02:00
|
|
|
{
|
|
|
|
return XSTRDUP(MTYPE_ROUTE_MAP_COMPILED, arg);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Free route map's compiled `ip address' value. */
|
2018-11-07 01:25:58 +01:00
|
|
|
static void route_match_address_free(void *rule)
|
2007-05-04 22:13:20 +02:00
|
|
|
{
|
|
|
|
XFREE(MTYPE_ROUTE_MAP_COMPILED, rule);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Route map commands for ip address matching. */
|
2019-11-20 17:20:58 +01:00
|
|
|
static const struct route_map_rule_cmd route_match_ip_address_cmd = {
|
|
|
|
"ip address",
|
|
|
|
route_match_ip_address,
|
|
|
|
route_match_address_compile,
|
|
|
|
route_match_address_free
|
|
|
|
};
|
2018-11-07 01:25:58 +01:00
|
|
|
|
|
|
|
/* Route map commands for ipv6 address matching. */
|
2019-11-20 17:20:58 +01:00
|
|
|
static const struct route_map_rule_cmd route_match_ipv6_address_cmd = {
|
|
|
|
"ipv6 address",
|
|
|
|
route_match_ipv6_address,
|
|
|
|
route_match_address_compile,
|
|
|
|
route_match_address_free
|
|
|
|
};
|
2014-06-04 06:53:35 +02:00
|
|
|
|
2007-05-04 22:13:20 +02:00
|
|
|
/* `match ip address prefix-list PREFIX_LIST' */
|
|
|
|
|
lib: Introducing a 3rd state for route-map match cmd: RMAP_NOOP
Introducing a 3rd state for route_map_apply library function: RMAP_NOOP
Traditionally route map MATCH rule apis were designed to return
a binary response, consisting of either RMAP_MATCH or RMAP_NOMATCH.
(Route-map SET rule apis return RMAP_OKAY or RMAP_ERROR).
Depending on this response, the following statemachine decided the
course of action:
State1:
If match cmd returns RMAP_MATCH then, keep existing behaviour.
If routemap type is PERMIT, execute set cmds or call cmds if applicable,
otherwise PERMIT!
Else If routemap type is DENY, we DENYMATCH right away
State2:
If match cmd returns RMAP_NOMATCH, continue on to next route-map. If there
are no other rules or if all the rules return RMAP_NOMATCH, return DENYMATCH
We require a 3rd state because of the following situation:
The issue - what if, the rule api needs to abort or ignore a rule?:
"match evpn vni xx" route-map filter can be applied to incoming routes
regardless of whether the tunnel type is vxlan or mpls.
This rule should be N/A for mpls based evpn route, but applicable to only
vxlan based evpn route.
Also, this rule should be applicable for routes with VNI label only, and
not for routes without labels. For example, type 3 and type 4 EVPN routes
do not have labels, so, this match cmd should let them through.
Today, the filter produces either a match or nomatch response regardless of
whether it is mpls/vxlan, resulting in either permitting or denying the
route.. So an mpls evpn route may get filtered out incorrectly.
Eg: "route-map RM1 permit 10 ; match evpn vni 20" or
"route-map RM2 deny 20 ; match vni 20"
With the introduction of the 3rd state, we can abort this rule check safely.
How? The rules api can now return RMAP_NOOP to indicate
that it encountered an invalid check, and needs to abort just that rule,
but continue with other rules.
As a result we have a 3rd state:
State3:
If match cmd returned RMAP_NOOP
Then, proceed to other route-map, otherwise if there are no more
rules or if all the rules return RMAP_NOOP, then, return RMAP_PERMITMATCH.
Signed-off-by: Lakshman Krishnamoorthy <lkrishnamoor@vmware.com>
2019-06-19 23:04:36 +02:00
|
|
|
static enum route_map_cmd_result_t
|
2018-08-17 17:53:28 +02:00
|
|
|
route_match_address_prefix_list(void *rule, const struct prefix *prefix,
|
2020-11-14 01:35:20 +01:00
|
|
|
void *object, afi_t afi)
|
2007-05-04 22:13:20 +02:00
|
|
|
{
|
|
|
|
struct prefix_list *plist;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2020-11-14 01:35:20 +01:00
|
|
|
plist = prefix_list_lookup(afi, (char *)rule);
|
2023-02-13 15:34:38 +01:00
|
|
|
if (plist == NULL) {
|
2023-02-17 21:02:14 +01:00
|
|
|
if (unlikely(CHECK_FLAG(rmap_debug, DEBUG_ROUTEMAP_DETAIL)))
|
2023-02-13 15:34:38 +01:00
|
|
|
zlog_debug(
|
|
|
|
"%s: Prefix List %s specified does not exist defaulting to NO_MATCH",
|
|
|
|
__func__, (char *)rule);
|
2020-11-14 01:35:20 +01:00
|
|
|
return RMAP_NOMATCH;
|
2023-02-13 15:34:38 +01:00
|
|
|
}
|
2007-05-04 22:13:20 +02:00
|
|
|
|
2020-11-14 01:35:20 +01:00
|
|
|
return (prefix_list_apply(plist, prefix) == PREFIX_DENY ? RMAP_NOMATCH
|
|
|
|
: RMAP_MATCH);
|
2007-05-04 22:13:20 +02:00
|
|
|
}
|
|
|
|
|
lib: Introducing a 3rd state for route-map match cmd: RMAP_NOOP
Introducing a 3rd state for route_map_apply library function: RMAP_NOOP
Traditionally route map MATCH rule apis were designed to return
a binary response, consisting of either RMAP_MATCH or RMAP_NOMATCH.
(Route-map SET rule apis return RMAP_OKAY or RMAP_ERROR).
Depending on this response, the following statemachine decided the
course of action:
State1:
If match cmd returns RMAP_MATCH then, keep existing behaviour.
If routemap type is PERMIT, execute set cmds or call cmds if applicable,
otherwise PERMIT!
Else If routemap type is DENY, we DENYMATCH right away
State2:
If match cmd returns RMAP_NOMATCH, continue on to next route-map. If there
are no other rules or if all the rules return RMAP_NOMATCH, return DENYMATCH
We require a 3rd state because of the following situation:
The issue - what if, the rule api needs to abort or ignore a rule?:
"match evpn vni xx" route-map filter can be applied to incoming routes
regardless of whether the tunnel type is vxlan or mpls.
This rule should be N/A for mpls based evpn route, but applicable to only
vxlan based evpn route.
Also, this rule should be applicable for routes with VNI label only, and
not for routes without labels. For example, type 3 and type 4 EVPN routes
do not have labels, so, this match cmd should let them through.
Today, the filter produces either a match or nomatch response regardless of
whether it is mpls/vxlan, resulting in either permitting or denying the
route.. So an mpls evpn route may get filtered out incorrectly.
Eg: "route-map RM1 permit 10 ; match evpn vni 20" or
"route-map RM2 deny 20 ; match vni 20"
With the introduction of the 3rd state, we can abort this rule check safely.
How? The rules api can now return RMAP_NOOP to indicate
that it encountered an invalid check, and needs to abort just that rule,
but continue with other rules.
As a result we have a 3rd state:
State3:
If match cmd returned RMAP_NOOP
Then, proceed to other route-map, otherwise if there are no more
rules or if all the rules return RMAP_NOOP, then, return RMAP_PERMITMATCH.
Signed-off-by: Lakshman Krishnamoorthy <lkrishnamoor@vmware.com>
2019-06-19 23:04:36 +02:00
|
|
|
static enum route_map_cmd_result_t
|
2018-08-17 17:53:28 +02:00
|
|
|
route_match_ip_address_prefix_list(void *rule, const struct prefix *prefix,
|
2020-11-14 01:35:20 +01:00
|
|
|
void *object)
|
2018-08-17 17:53:28 +02:00
|
|
|
{
|
2020-11-14 01:35:20 +01:00
|
|
|
return (route_match_address_prefix_list(rule, prefix, object, AFI_IP));
|
2018-08-17 17:53:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void *route_match_address_prefix_list_compile(const char *arg)
|
2007-05-04 22:13:20 +02:00
|
|
|
{
|
|
|
|
return XSTRDUP(MTYPE_ROUTE_MAP_COMPILED, arg);
|
|
|
|
}
|
|
|
|
|
2018-08-17 17:53:28 +02:00
|
|
|
static void route_match_address_prefix_list_free(void *rule)
|
2007-05-04 22:13:20 +02:00
|
|
|
{
|
|
|
|
XFREE(MTYPE_ROUTE_MAP_COMPILED, rule);
|
|
|
|
}
|
|
|
|
|
2019-11-20 17:20:58 +01:00
|
|
|
static const struct route_map_rule_cmd
|
|
|
|
route_match_ip_address_prefix_list_cmd = {
|
|
|
|
"ip address prefix-list",
|
|
|
|
route_match_ip_address_prefix_list,
|
2018-08-17 17:53:28 +02:00
|
|
|
route_match_address_prefix_list_compile,
|
2019-11-20 17:20:58 +01:00
|
|
|
route_match_address_prefix_list_free
|
|
|
|
};
|
2018-08-17 17:53:28 +02:00
|
|
|
|
lib: Introducing a 3rd state for route-map match cmd: RMAP_NOOP
Introducing a 3rd state for route_map_apply library function: RMAP_NOOP
Traditionally route map MATCH rule apis were designed to return
a binary response, consisting of either RMAP_MATCH or RMAP_NOMATCH.
(Route-map SET rule apis return RMAP_OKAY or RMAP_ERROR).
Depending on this response, the following statemachine decided the
course of action:
State1:
If match cmd returns RMAP_MATCH then, keep existing behaviour.
If routemap type is PERMIT, execute set cmds or call cmds if applicable,
otherwise PERMIT!
Else If routemap type is DENY, we DENYMATCH right away
State2:
If match cmd returns RMAP_NOMATCH, continue on to next route-map. If there
are no other rules or if all the rules return RMAP_NOMATCH, return DENYMATCH
We require a 3rd state because of the following situation:
The issue - what if, the rule api needs to abort or ignore a rule?:
"match evpn vni xx" route-map filter can be applied to incoming routes
regardless of whether the tunnel type is vxlan or mpls.
This rule should be N/A for mpls based evpn route, but applicable to only
vxlan based evpn route.
Also, this rule should be applicable for routes with VNI label only, and
not for routes without labels. For example, type 3 and type 4 EVPN routes
do not have labels, so, this match cmd should let them through.
Today, the filter produces either a match or nomatch response regardless of
whether it is mpls/vxlan, resulting in either permitting or denying the
route.. So an mpls evpn route may get filtered out incorrectly.
Eg: "route-map RM1 permit 10 ; match evpn vni 20" or
"route-map RM2 deny 20 ; match vni 20"
With the introduction of the 3rd state, we can abort this rule check safely.
How? The rules api can now return RMAP_NOOP to indicate
that it encountered an invalid check, and needs to abort just that rule,
but continue with other rules.
As a result we have a 3rd state:
State3:
If match cmd returned RMAP_NOOP
Then, proceed to other route-map, otherwise if there are no more
rules or if all the rules return RMAP_NOOP, then, return RMAP_PERMITMATCH.
Signed-off-by: Lakshman Krishnamoorthy <lkrishnamoor@vmware.com>
2019-06-19 23:04:36 +02:00
|
|
|
static enum route_map_cmd_result_t
|
2018-08-17 17:53:28 +02:00
|
|
|
route_match_ipv6_address_prefix_list(void *rule, const struct prefix *prefix,
|
2020-11-14 01:35:20 +01:00
|
|
|
void *object)
|
2018-08-17 17:53:28 +02:00
|
|
|
{
|
2020-11-14 01:35:20 +01:00
|
|
|
return (route_match_address_prefix_list(rule, prefix, object, AFI_IP6));
|
2018-08-17 17:53:28 +02:00
|
|
|
}
|
2007-05-04 22:13:20 +02:00
|
|
|
|
2019-11-20 17:20:58 +01:00
|
|
|
static const struct route_map_rule_cmd
|
|
|
|
route_match_ipv6_address_prefix_list_cmd = {
|
|
|
|
"ipv6 address prefix-list",
|
|
|
|
route_match_ipv6_address_prefix_list,
|
2018-08-17 17:53:28 +02:00
|
|
|
route_match_address_prefix_list_compile,
|
2019-11-20 17:20:58 +01:00
|
|
|
route_match_address_prefix_list_free
|
|
|
|
};
|
2014-06-04 06:53:35 +02:00
|
|
|
|
2019-06-21 17:51:33 +02:00
|
|
|
/* `match ipv6 next-hop type <TYPE>' */
|
|
|
|
|
lib: Introducing a 3rd state for route-map match cmd: RMAP_NOOP
Introducing a 3rd state for route_map_apply library function: RMAP_NOOP
Traditionally route map MATCH rule apis were designed to return
a binary response, consisting of either RMAP_MATCH or RMAP_NOMATCH.
(Route-map SET rule apis return RMAP_OKAY or RMAP_ERROR).
Depending on this response, the following statemachine decided the
course of action:
State1:
If match cmd returns RMAP_MATCH then, keep existing behaviour.
If routemap type is PERMIT, execute set cmds or call cmds if applicable,
otherwise PERMIT!
Else If routemap type is DENY, we DENYMATCH right away
State2:
If match cmd returns RMAP_NOMATCH, continue on to next route-map. If there
are no other rules or if all the rules return RMAP_NOMATCH, return DENYMATCH
We require a 3rd state because of the following situation:
The issue - what if, the rule api needs to abort or ignore a rule?:
"match evpn vni xx" route-map filter can be applied to incoming routes
regardless of whether the tunnel type is vxlan or mpls.
This rule should be N/A for mpls based evpn route, but applicable to only
vxlan based evpn route.
Also, this rule should be applicable for routes with VNI label only, and
not for routes without labels. For example, type 3 and type 4 EVPN routes
do not have labels, so, this match cmd should let them through.
Today, the filter produces either a match or nomatch response regardless of
whether it is mpls/vxlan, resulting in either permitting or denying the
route.. So an mpls evpn route may get filtered out incorrectly.
Eg: "route-map RM1 permit 10 ; match evpn vni 20" or
"route-map RM2 deny 20 ; match vni 20"
With the introduction of the 3rd state, we can abort this rule check safely.
How? The rules api can now return RMAP_NOOP to indicate
that it encountered an invalid check, and needs to abort just that rule,
but continue with other rules.
As a result we have a 3rd state:
State3:
If match cmd returned RMAP_NOOP
Then, proceed to other route-map, otherwise if there are no more
rules or if all the rules return RMAP_NOOP, then, return RMAP_PERMITMATCH.
Signed-off-by: Lakshman Krishnamoorthy <lkrishnamoor@vmware.com>
2019-06-19 23:04:36 +02:00
|
|
|
static enum route_map_cmd_result_t
|
2019-06-21 17:51:33 +02:00
|
|
|
route_match_ipv6_next_hop_type(void *rule, const struct prefix *prefix,
|
2020-11-14 01:35:20 +01:00
|
|
|
void *object)
|
2019-06-21 17:51:33 +02:00
|
|
|
{
|
2023-08-11 16:12:06 +02:00
|
|
|
struct zebra_rmap_obj *rm_data;
|
2019-06-21 17:51:33 +02:00
|
|
|
|
2020-11-14 01:35:20 +01:00
|
|
|
if (prefix->family == AF_INET6) {
|
2023-08-11 16:12:06 +02:00
|
|
|
rm_data = (struct zebra_rmap_obj *)object;
|
|
|
|
if (!rm_data)
|
lib: Introducing a 3rd state for route-map match cmd: RMAP_NOOP
Introducing a 3rd state for route_map_apply library function: RMAP_NOOP
Traditionally route map MATCH rule apis were designed to return
a binary response, consisting of either RMAP_MATCH or RMAP_NOMATCH.
(Route-map SET rule apis return RMAP_OKAY or RMAP_ERROR).
Depending on this response, the following statemachine decided the
course of action:
State1:
If match cmd returns RMAP_MATCH then, keep existing behaviour.
If routemap type is PERMIT, execute set cmds or call cmds if applicable,
otherwise PERMIT!
Else If routemap type is DENY, we DENYMATCH right away
State2:
If match cmd returns RMAP_NOMATCH, continue on to next route-map. If there
are no other rules or if all the rules return RMAP_NOMATCH, return DENYMATCH
We require a 3rd state because of the following situation:
The issue - what if, the rule api needs to abort or ignore a rule?:
"match evpn vni xx" route-map filter can be applied to incoming routes
regardless of whether the tunnel type is vxlan or mpls.
This rule should be N/A for mpls based evpn route, but applicable to only
vxlan based evpn route.
Also, this rule should be applicable for routes with VNI label only, and
not for routes without labels. For example, type 3 and type 4 EVPN routes
do not have labels, so, this match cmd should let them through.
Today, the filter produces either a match or nomatch response regardless of
whether it is mpls/vxlan, resulting in either permitting or denying the
route.. So an mpls evpn route may get filtered out incorrectly.
Eg: "route-map RM1 permit 10 ; match evpn vni 20" or
"route-map RM2 deny 20 ; match vni 20"
With the introduction of the 3rd state, we can abort this rule check safely.
How? The rules api can now return RMAP_NOOP to indicate
that it encountered an invalid check, and needs to abort just that rule,
but continue with other rules.
As a result we have a 3rd state:
State3:
If match cmd returned RMAP_NOOP
Then, proceed to other route-map, otherwise if there are no more
rules or if all the rules return RMAP_NOOP, then, return RMAP_PERMITMATCH.
Signed-off-by: Lakshman Krishnamoorthy <lkrishnamoor@vmware.com>
2019-06-19 23:04:36 +02:00
|
|
|
return RMAP_NOMATCH;
|
2019-06-21 17:51:33 +02:00
|
|
|
|
2023-08-11 16:12:06 +02:00
|
|
|
if (rm_data->nexthop->type == NEXTHOP_TYPE_BLACKHOLE)
|
2019-06-21 17:51:33 +02:00
|
|
|
return RMAP_MATCH;
|
|
|
|
}
|
2020-11-14 01:35:20 +01:00
|
|
|
|
2019-06-21 17:51:33 +02:00
|
|
|
return RMAP_NOMATCH;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void *route_match_ipv6_next_hop_type_compile(const char *arg)
|
|
|
|
{
|
|
|
|
return XSTRDUP(MTYPE_ROUTE_MAP_COMPILED, arg);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void route_match_ipv6_next_hop_type_free(void *rule)
|
|
|
|
{
|
|
|
|
XFREE(MTYPE_ROUTE_MAP_COMPILED, rule);
|
|
|
|
}
|
|
|
|
|
2019-11-20 17:20:58 +01:00
|
|
|
static const struct route_map_rule_cmd
|
|
|
|
route_match_ipv6_next_hop_type_cmd = {
|
|
|
|
"ipv6 next-hop type",
|
|
|
|
route_match_ipv6_next_hop_type,
|
2019-06-21 17:51:33 +02:00
|
|
|
route_match_ipv6_next_hop_type_compile,
|
2019-11-20 17:20:58 +01:00
|
|
|
route_match_ipv6_next_hop_type_free
|
|
|
|
};
|
2019-06-21 17:51:33 +02:00
|
|
|
|
2015-05-20 02:47:20 +02:00
|
|
|
/* `match ip address prefix-len PREFIXLEN' */
|
|
|
|
|
lib: Introducing a 3rd state for route-map match cmd: RMAP_NOOP
Introducing a 3rd state for route_map_apply library function: RMAP_NOOP
Traditionally route map MATCH rule apis were designed to return
a binary response, consisting of either RMAP_MATCH or RMAP_NOMATCH.
(Route-map SET rule apis return RMAP_OKAY or RMAP_ERROR).
Depending on this response, the following statemachine decided the
course of action:
State1:
If match cmd returns RMAP_MATCH then, keep existing behaviour.
If routemap type is PERMIT, execute set cmds or call cmds if applicable,
otherwise PERMIT!
Else If routemap type is DENY, we DENYMATCH right away
State2:
If match cmd returns RMAP_NOMATCH, continue on to next route-map. If there
are no other rules or if all the rules return RMAP_NOMATCH, return DENYMATCH
We require a 3rd state because of the following situation:
The issue - what if, the rule api needs to abort or ignore a rule?:
"match evpn vni xx" route-map filter can be applied to incoming routes
regardless of whether the tunnel type is vxlan or mpls.
This rule should be N/A for mpls based evpn route, but applicable to only
vxlan based evpn route.
Also, this rule should be applicable for routes with VNI label only, and
not for routes without labels. For example, type 3 and type 4 EVPN routes
do not have labels, so, this match cmd should let them through.
Today, the filter produces either a match or nomatch response regardless of
whether it is mpls/vxlan, resulting in either permitting or denying the
route.. So an mpls evpn route may get filtered out incorrectly.
Eg: "route-map RM1 permit 10 ; match evpn vni 20" or
"route-map RM2 deny 20 ; match vni 20"
With the introduction of the 3rd state, we can abort this rule check safely.
How? The rules api can now return RMAP_NOOP to indicate
that it encountered an invalid check, and needs to abort just that rule,
but continue with other rules.
As a result we have a 3rd state:
State3:
If match cmd returned RMAP_NOOP
Then, proceed to other route-map, otherwise if there are no more
rules or if all the rules return RMAP_NOOP, then, return RMAP_PERMITMATCH.
Signed-off-by: Lakshman Krishnamoorthy <lkrishnamoor@vmware.com>
2019-06-19 23:04:36 +02:00
|
|
|
static enum route_map_cmd_result_t
|
2018-07-12 22:05:19 +02:00
|
|
|
route_match_address_prefix_len(void *rule, const struct prefix *prefix,
|
2020-11-14 01:35:20 +01:00
|
|
|
void *object)
|
2015-05-20 02:47:20 +02:00
|
|
|
{
|
2018-03-27 21:13:34 +02:00
|
|
|
uint32_t *prefixlen = (uint32_t *)rule;
|
2015-05-20 02:47:20 +02:00
|
|
|
|
2020-11-14 01:35:20 +01:00
|
|
|
return ((prefix->prefixlen == *prefixlen) ? RMAP_MATCH : RMAP_NOMATCH);
|
2015-05-20 02:47:20 +02:00
|
|
|
}
|
|
|
|
|
2017-11-03 15:33:09 +01:00
|
|
|
static void *route_match_address_prefix_len_compile(const char *arg)
|
2015-05-20 02:47:20 +02:00
|
|
|
{
|
2018-03-27 21:13:34 +02:00
|
|
|
uint32_t *prefix_len;
|
2015-05-20 02:47:20 +02:00
|
|
|
char *endptr = NULL;
|
|
|
|
unsigned long tmpval;
|
|
|
|
|
|
|
|
/* prefix len value shoud be integer. */
|
|
|
|
if (!all_digit(arg))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
errno = 0;
|
|
|
|
tmpval = strtoul(arg, &endptr, 10);
|
|
|
|
if (*endptr != '\0' || errno || tmpval > UINT32_MAX)
|
|
|
|
return NULL;
|
|
|
|
|
2018-03-27 21:13:34 +02:00
|
|
|
prefix_len = XMALLOC(MTYPE_ROUTE_MAP_COMPILED, sizeof(uint32_t));
|
2015-05-20 02:47:20 +02:00
|
|
|
|
|
|
|
*prefix_len = tmpval;
|
|
|
|
return prefix_len;
|
|
|
|
}
|
|
|
|
|
2017-11-03 15:33:09 +01:00
|
|
|
static void route_match_address_prefix_len_free(void *rule)
|
2015-05-20 02:47:20 +02:00
|
|
|
{
|
|
|
|
XFREE(MTYPE_ROUTE_MAP_COMPILED, rule);
|
|
|
|
}
|
|
|
|
|
2019-11-20 17:20:58 +01:00
|
|
|
static const struct route_map_rule_cmd
|
|
|
|
route_match_ip_address_prefix_len_cmd = {
|
|
|
|
"ip address prefix-len",
|
|
|
|
route_match_address_prefix_len,
|
2017-11-03 15:33:09 +01:00
|
|
|
route_match_address_prefix_len_compile,
|
2019-11-20 17:20:58 +01:00
|
|
|
route_match_address_prefix_len_free
|
|
|
|
};
|
2015-05-20 02:47:20 +02:00
|
|
|
|
2019-11-20 17:20:58 +01:00
|
|
|
static const struct route_map_rule_cmd
|
|
|
|
route_match_ipv6_address_prefix_len_cmd = {
|
|
|
|
"ipv6 address prefix-len",
|
|
|
|
route_match_address_prefix_len,
|
2017-11-03 15:33:09 +01:00
|
|
|
route_match_address_prefix_len_compile,
|
2019-11-20 17:20:58 +01:00
|
|
|
route_match_address_prefix_len_free
|
|
|
|
};
|
2015-05-20 02:47:20 +02:00
|
|
|
|
|
|
|
/* `match ip nexthop prefix-len PREFIXLEN' */
|
|
|
|
|
lib: Introducing a 3rd state for route-map match cmd: RMAP_NOOP
Introducing a 3rd state for route_map_apply library function: RMAP_NOOP
Traditionally route map MATCH rule apis were designed to return
a binary response, consisting of either RMAP_MATCH or RMAP_NOMATCH.
(Route-map SET rule apis return RMAP_OKAY or RMAP_ERROR).
Depending on this response, the following statemachine decided the
course of action:
State1:
If match cmd returns RMAP_MATCH then, keep existing behaviour.
If routemap type is PERMIT, execute set cmds or call cmds if applicable,
otherwise PERMIT!
Else If routemap type is DENY, we DENYMATCH right away
State2:
If match cmd returns RMAP_NOMATCH, continue on to next route-map. If there
are no other rules or if all the rules return RMAP_NOMATCH, return DENYMATCH
We require a 3rd state because of the following situation:
The issue - what if, the rule api needs to abort or ignore a rule?:
"match evpn vni xx" route-map filter can be applied to incoming routes
regardless of whether the tunnel type is vxlan or mpls.
This rule should be N/A for mpls based evpn route, but applicable to only
vxlan based evpn route.
Also, this rule should be applicable for routes with VNI label only, and
not for routes without labels. For example, type 3 and type 4 EVPN routes
do not have labels, so, this match cmd should let them through.
Today, the filter produces either a match or nomatch response regardless of
whether it is mpls/vxlan, resulting in either permitting or denying the
route.. So an mpls evpn route may get filtered out incorrectly.
Eg: "route-map RM1 permit 10 ; match evpn vni 20" or
"route-map RM2 deny 20 ; match vni 20"
With the introduction of the 3rd state, we can abort this rule check safely.
How? The rules api can now return RMAP_NOOP to indicate
that it encountered an invalid check, and needs to abort just that rule,
but continue with other rules.
As a result we have a 3rd state:
State3:
If match cmd returned RMAP_NOOP
Then, proceed to other route-map, otherwise if there are no more
rules or if all the rules return RMAP_NOOP, then, return RMAP_PERMITMATCH.
Signed-off-by: Lakshman Krishnamoorthy <lkrishnamoor@vmware.com>
2019-06-19 23:04:36 +02:00
|
|
|
static enum route_map_cmd_result_t
|
2018-07-12 22:05:19 +02:00
|
|
|
route_match_ip_nexthop_prefix_len(void *rule, const struct prefix *prefix,
|
2020-11-14 01:35:20 +01:00
|
|
|
void *object)
|
2015-05-20 02:47:20 +02:00
|
|
|
{
|
2018-03-27 21:13:34 +02:00
|
|
|
uint32_t *prefixlen = (uint32_t *)rule;
|
2023-08-11 16:12:06 +02:00
|
|
|
struct zebra_rmap_obj *rm_data;
|
2015-05-20 02:47:20 +02:00
|
|
|
struct prefix_ipv4 p;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2023-08-11 16:12:06 +02:00
|
|
|
rm_data = (struct zebra_rmap_obj *)object;
|
|
|
|
if (!rm_data || !rm_data->nexthop)
|
2020-11-14 01:35:20 +01:00
|
|
|
return RMAP_NOMATCH;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2023-08-11 16:12:06 +02:00
|
|
|
switch (rm_data->nexthop->type) {
|
2020-11-14 01:35:20 +01:00
|
|
|
case NEXTHOP_TYPE_IFINDEX:
|
|
|
|
/* Interface routes can't match ip next-hop */
|
|
|
|
return RMAP_NOMATCH;
|
|
|
|
case NEXTHOP_TYPE_IPV4_IFINDEX:
|
|
|
|
case NEXTHOP_TYPE_IPV4:
|
|
|
|
p.family = AF_INET;
|
2023-08-11 16:12:06 +02:00
|
|
|
p.prefix = rm_data->nexthop->gate.ipv4;
|
2020-11-14 01:35:20 +01:00
|
|
|
p.prefixlen = IPV4_MAX_BITLEN;
|
|
|
|
break;
|
2023-01-30 16:05:58 +01:00
|
|
|
case NEXTHOP_TYPE_IPV6:
|
|
|
|
case NEXTHOP_TYPE_IPV6_IFINDEX:
|
|
|
|
case NEXTHOP_TYPE_BLACKHOLE:
|
2020-11-14 01:35:20 +01:00
|
|
|
return RMAP_NOMATCH;
|
2015-05-20 02:47:20 +02:00
|
|
|
}
|
2020-11-14 01:35:20 +01:00
|
|
|
return ((p.prefixlen == *prefixlen) ? RMAP_MATCH : RMAP_NOMATCH);
|
2015-05-20 02:47:20 +02:00
|
|
|
}
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2019-11-20 17:20:58 +01:00
|
|
|
static const struct route_map_rule_cmd
|
|
|
|
route_match_ip_nexthop_prefix_len_cmd = {
|
|
|
|
"ip next-hop prefix-len",
|
|
|
|
route_match_ip_nexthop_prefix_len,
|
2017-11-03 15:33:09 +01:00
|
|
|
route_match_address_prefix_len_compile, /* reuse */
|
|
|
|
route_match_address_prefix_len_free /* reuse */
|
2015-05-20 02:47:20 +02:00
|
|
|
};
|
|
|
|
|
2019-06-21 17:51:33 +02:00
|
|
|
/* `match ip next-hop type <blackhole>' */
|
|
|
|
|
lib: Introducing a 3rd state for route-map match cmd: RMAP_NOOP
Introducing a 3rd state for route_map_apply library function: RMAP_NOOP
Traditionally route map MATCH rule apis were designed to return
a binary response, consisting of either RMAP_MATCH or RMAP_NOMATCH.
(Route-map SET rule apis return RMAP_OKAY or RMAP_ERROR).
Depending on this response, the following statemachine decided the
course of action:
State1:
If match cmd returns RMAP_MATCH then, keep existing behaviour.
If routemap type is PERMIT, execute set cmds or call cmds if applicable,
otherwise PERMIT!
Else If routemap type is DENY, we DENYMATCH right away
State2:
If match cmd returns RMAP_NOMATCH, continue on to next route-map. If there
are no other rules or if all the rules return RMAP_NOMATCH, return DENYMATCH
We require a 3rd state because of the following situation:
The issue - what if, the rule api needs to abort or ignore a rule?:
"match evpn vni xx" route-map filter can be applied to incoming routes
regardless of whether the tunnel type is vxlan or mpls.
This rule should be N/A for mpls based evpn route, but applicable to only
vxlan based evpn route.
Also, this rule should be applicable for routes with VNI label only, and
not for routes without labels. For example, type 3 and type 4 EVPN routes
do not have labels, so, this match cmd should let them through.
Today, the filter produces either a match or nomatch response regardless of
whether it is mpls/vxlan, resulting in either permitting or denying the
route.. So an mpls evpn route may get filtered out incorrectly.
Eg: "route-map RM1 permit 10 ; match evpn vni 20" or
"route-map RM2 deny 20 ; match vni 20"
With the introduction of the 3rd state, we can abort this rule check safely.
How? The rules api can now return RMAP_NOOP to indicate
that it encountered an invalid check, and needs to abort just that rule,
but continue with other rules.
As a result we have a 3rd state:
State3:
If match cmd returned RMAP_NOOP
Then, proceed to other route-map, otherwise if there are no more
rules or if all the rules return RMAP_NOOP, then, return RMAP_PERMITMATCH.
Signed-off-by: Lakshman Krishnamoorthy <lkrishnamoor@vmware.com>
2019-06-19 23:04:36 +02:00
|
|
|
static enum route_map_cmd_result_t
|
2019-06-21 17:51:33 +02:00
|
|
|
route_match_ip_next_hop_type(void *rule, const struct prefix *prefix,
|
2020-11-14 01:35:20 +01:00
|
|
|
void *object)
|
2019-06-21 17:51:33 +02:00
|
|
|
{
|
2023-08-11 16:12:06 +02:00
|
|
|
struct zebra_rmap_obj *rm_data;
|
2019-06-21 17:51:33 +02:00
|
|
|
|
2020-11-14 01:35:20 +01:00
|
|
|
if (prefix->family == AF_INET) {
|
2023-08-11 16:12:06 +02:00
|
|
|
rm_data = (struct zebra_rmap_obj *)object;
|
|
|
|
if (!rm_data)
|
lib: Introducing a 3rd state for route-map match cmd: RMAP_NOOP
Introducing a 3rd state for route_map_apply library function: RMAP_NOOP
Traditionally route map MATCH rule apis were designed to return
a binary response, consisting of either RMAP_MATCH or RMAP_NOMATCH.
(Route-map SET rule apis return RMAP_OKAY or RMAP_ERROR).
Depending on this response, the following statemachine decided the
course of action:
State1:
If match cmd returns RMAP_MATCH then, keep existing behaviour.
If routemap type is PERMIT, execute set cmds or call cmds if applicable,
otherwise PERMIT!
Else If routemap type is DENY, we DENYMATCH right away
State2:
If match cmd returns RMAP_NOMATCH, continue on to next route-map. If there
are no other rules or if all the rules return RMAP_NOMATCH, return DENYMATCH
We require a 3rd state because of the following situation:
The issue - what if, the rule api needs to abort or ignore a rule?:
"match evpn vni xx" route-map filter can be applied to incoming routes
regardless of whether the tunnel type is vxlan or mpls.
This rule should be N/A for mpls based evpn route, but applicable to only
vxlan based evpn route.
Also, this rule should be applicable for routes with VNI label only, and
not for routes without labels. For example, type 3 and type 4 EVPN routes
do not have labels, so, this match cmd should let them through.
Today, the filter produces either a match or nomatch response regardless of
whether it is mpls/vxlan, resulting in either permitting or denying the
route.. So an mpls evpn route may get filtered out incorrectly.
Eg: "route-map RM1 permit 10 ; match evpn vni 20" or
"route-map RM2 deny 20 ; match vni 20"
With the introduction of the 3rd state, we can abort this rule check safely.
How? The rules api can now return RMAP_NOOP to indicate
that it encountered an invalid check, and needs to abort just that rule,
but continue with other rules.
As a result we have a 3rd state:
State3:
If match cmd returned RMAP_NOOP
Then, proceed to other route-map, otherwise if there are no more
rules or if all the rules return RMAP_NOOP, then, return RMAP_PERMITMATCH.
Signed-off-by: Lakshman Krishnamoorthy <lkrishnamoor@vmware.com>
2019-06-19 23:04:36 +02:00
|
|
|
return RMAP_NOMATCH;
|
2019-06-21 17:51:33 +02:00
|
|
|
|
2023-08-11 16:12:06 +02:00
|
|
|
if (rm_data->nexthop->type == NEXTHOP_TYPE_BLACKHOLE)
|
2019-06-21 17:51:33 +02:00
|
|
|
return RMAP_MATCH;
|
|
|
|
}
|
2020-11-14 01:35:20 +01:00
|
|
|
|
2019-06-21 17:51:33 +02:00
|
|
|
return RMAP_NOMATCH;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void *route_match_ip_next_hop_type_compile(const char *arg)
|
|
|
|
{
|
|
|
|
return XSTRDUP(MTYPE_ROUTE_MAP_COMPILED, arg);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void route_match_ip_next_hop_type_free(void *rule)
|
|
|
|
{
|
|
|
|
XFREE(MTYPE_ROUTE_MAP_COMPILED, rule);
|
|
|
|
}
|
|
|
|
|
2019-11-20 17:20:58 +01:00
|
|
|
static const struct route_map_rule_cmd
|
|
|
|
route_match_ip_next_hop_type_cmd = {
|
|
|
|
"ip next-hop type",
|
|
|
|
route_match_ip_next_hop_type,
|
2019-06-21 17:51:33 +02:00
|
|
|
route_match_ip_next_hop_type_compile,
|
2019-11-20 17:20:58 +01:00
|
|
|
route_match_ip_next_hop_type_free
|
|
|
|
};
|
2019-06-21 17:51:33 +02:00
|
|
|
|
2015-05-20 02:47:20 +02:00
|
|
|
/* `match source-protocol PROTOCOL' */
|
|
|
|
|
lib: Introducing a 3rd state for route-map match cmd: RMAP_NOOP
Introducing a 3rd state for route_map_apply library function: RMAP_NOOP
Traditionally route map MATCH rule apis were designed to return
a binary response, consisting of either RMAP_MATCH or RMAP_NOMATCH.
(Route-map SET rule apis return RMAP_OKAY or RMAP_ERROR).
Depending on this response, the following statemachine decided the
course of action:
State1:
If match cmd returns RMAP_MATCH then, keep existing behaviour.
If routemap type is PERMIT, execute set cmds or call cmds if applicable,
otherwise PERMIT!
Else If routemap type is DENY, we DENYMATCH right away
State2:
If match cmd returns RMAP_NOMATCH, continue on to next route-map. If there
are no other rules or if all the rules return RMAP_NOMATCH, return DENYMATCH
We require a 3rd state because of the following situation:
The issue - what if, the rule api needs to abort or ignore a rule?:
"match evpn vni xx" route-map filter can be applied to incoming routes
regardless of whether the tunnel type is vxlan or mpls.
This rule should be N/A for mpls based evpn route, but applicable to only
vxlan based evpn route.
Also, this rule should be applicable for routes with VNI label only, and
not for routes without labels. For example, type 3 and type 4 EVPN routes
do not have labels, so, this match cmd should let them through.
Today, the filter produces either a match or nomatch response regardless of
whether it is mpls/vxlan, resulting in either permitting or denying the
route.. So an mpls evpn route may get filtered out incorrectly.
Eg: "route-map RM1 permit 10 ; match evpn vni 20" or
"route-map RM2 deny 20 ; match vni 20"
With the introduction of the 3rd state, we can abort this rule check safely.
How? The rules api can now return RMAP_NOOP to indicate
that it encountered an invalid check, and needs to abort just that rule,
but continue with other rules.
As a result we have a 3rd state:
State3:
If match cmd returned RMAP_NOOP
Then, proceed to other route-map, otherwise if there are no more
rules or if all the rules return RMAP_NOOP, then, return RMAP_PERMITMATCH.
Signed-off-by: Lakshman Krishnamoorthy <lkrishnamoor@vmware.com>
2019-06-19 23:04:36 +02:00
|
|
|
static enum route_map_cmd_result_t
|
2020-11-14 01:35:20 +01:00
|
|
|
route_match_source_protocol(void *rule, const struct prefix *p, void *object)
|
2015-05-20 02:47:20 +02:00
|
|
|
{
|
2023-08-11 17:11:40 +02:00
|
|
|
int32_t *rib_type = (int32_t *)rule;
|
2023-08-11 16:12:06 +02:00
|
|
|
struct zebra_rmap_obj *rm_data;
|
2015-05-20 02:47:20 +02:00
|
|
|
|
2023-08-11 16:12:06 +02:00
|
|
|
rm_data = (struct zebra_rmap_obj *)object;
|
|
|
|
if (!rm_data)
|
2020-11-14 01:35:20 +01:00
|
|
|
return RMAP_NOMATCH;
|
2015-05-20 02:47:20 +02:00
|
|
|
|
2023-08-11 17:11:40 +02:00
|
|
|
return ((rm_data->re->type == *rib_type) ? RMAP_MATCH : RMAP_NOMATCH);
|
2015-05-20 02:47:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void *route_match_source_protocol_compile(const char *arg)
|
|
|
|
{
|
2018-03-27 21:13:34 +02:00
|
|
|
uint32_t *rib_type;
|
2015-05-20 02:47:20 +02:00
|
|
|
int i;
|
|
|
|
|
|
|
|
i = proto_name2num(arg);
|
2018-03-27 21:13:34 +02:00
|
|
|
rib_type = XMALLOC(MTYPE_ROUTE_MAP_COMPILED, sizeof(uint32_t));
|
2015-05-20 02:47:20 +02:00
|
|
|
|
|
|
|
*rib_type = i;
|
|
|
|
|
|
|
|
return rib_type;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void route_match_source_protocol_free(void *rule)
|
|
|
|
{
|
|
|
|
XFREE(MTYPE_ROUTE_MAP_COMPILED, rule);
|
|
|
|
}
|
|
|
|
|
2019-11-20 17:20:58 +01:00
|
|
|
static const struct route_map_rule_cmd route_match_source_protocol_cmd = {
|
|
|
|
"source-protocol",
|
|
|
|
route_match_source_protocol,
|
|
|
|
route_match_source_protocol_compile,
|
|
|
|
route_match_source_protocol_free
|
|
|
|
};
|
2015-05-20 02:47:20 +02:00
|
|
|
|
2018-05-17 16:29:49 +02:00
|
|
|
/* `source-instance` */
|
lib: Introducing a 3rd state for route-map match cmd: RMAP_NOOP
Introducing a 3rd state for route_map_apply library function: RMAP_NOOP
Traditionally route map MATCH rule apis were designed to return
a binary response, consisting of either RMAP_MATCH or RMAP_NOMATCH.
(Route-map SET rule apis return RMAP_OKAY or RMAP_ERROR).
Depending on this response, the following statemachine decided the
course of action:
State1:
If match cmd returns RMAP_MATCH then, keep existing behaviour.
If routemap type is PERMIT, execute set cmds or call cmds if applicable,
otherwise PERMIT!
Else If routemap type is DENY, we DENYMATCH right away
State2:
If match cmd returns RMAP_NOMATCH, continue on to next route-map. If there
are no other rules or if all the rules return RMAP_NOMATCH, return DENYMATCH
We require a 3rd state because of the following situation:
The issue - what if, the rule api needs to abort or ignore a rule?:
"match evpn vni xx" route-map filter can be applied to incoming routes
regardless of whether the tunnel type is vxlan or mpls.
This rule should be N/A for mpls based evpn route, but applicable to only
vxlan based evpn route.
Also, this rule should be applicable for routes with VNI label only, and
not for routes without labels. For example, type 3 and type 4 EVPN routes
do not have labels, so, this match cmd should let them through.
Today, the filter produces either a match or nomatch response regardless of
whether it is mpls/vxlan, resulting in either permitting or denying the
route.. So an mpls evpn route may get filtered out incorrectly.
Eg: "route-map RM1 permit 10 ; match evpn vni 20" or
"route-map RM2 deny 20 ; match vni 20"
With the introduction of the 3rd state, we can abort this rule check safely.
How? The rules api can now return RMAP_NOOP to indicate
that it encountered an invalid check, and needs to abort just that rule,
but continue with other rules.
As a result we have a 3rd state:
State3:
If match cmd returned RMAP_NOOP
Then, proceed to other route-map, otherwise if there are no more
rules or if all the rules return RMAP_NOOP, then, return RMAP_PERMITMATCH.
Signed-off-by: Lakshman Krishnamoorthy <lkrishnamoor@vmware.com>
2019-06-19 23:04:36 +02:00
|
|
|
static enum route_map_cmd_result_t
|
2020-11-14 01:35:20 +01:00
|
|
|
route_match_source_instance(void *rule, const struct prefix *p, void *object)
|
2018-05-17 16:29:49 +02:00
|
|
|
{
|
|
|
|
uint8_t *instance = (uint8_t *)rule;
|
2023-08-11 16:12:06 +02:00
|
|
|
struct zebra_rmap_obj *rm_data;
|
2018-05-17 16:29:49 +02:00
|
|
|
|
2023-08-11 16:12:06 +02:00
|
|
|
rm_data = (struct zebra_rmap_obj *)object;
|
|
|
|
if (!rm_data)
|
lib: Introducing a 3rd state for route-map match cmd: RMAP_NOOP
Introducing a 3rd state for route_map_apply library function: RMAP_NOOP
Traditionally route map MATCH rule apis were designed to return
a binary response, consisting of either RMAP_MATCH or RMAP_NOMATCH.
(Route-map SET rule apis return RMAP_OKAY or RMAP_ERROR).
Depending on this response, the following statemachine decided the
course of action:
State1:
If match cmd returns RMAP_MATCH then, keep existing behaviour.
If routemap type is PERMIT, execute set cmds or call cmds if applicable,
otherwise PERMIT!
Else If routemap type is DENY, we DENYMATCH right away
State2:
If match cmd returns RMAP_NOMATCH, continue on to next route-map. If there
are no other rules or if all the rules return RMAP_NOMATCH, return DENYMATCH
We require a 3rd state because of the following situation:
The issue - what if, the rule api needs to abort or ignore a rule?:
"match evpn vni xx" route-map filter can be applied to incoming routes
regardless of whether the tunnel type is vxlan or mpls.
This rule should be N/A for mpls based evpn route, but applicable to only
vxlan based evpn route.
Also, this rule should be applicable for routes with VNI label only, and
not for routes without labels. For example, type 3 and type 4 EVPN routes
do not have labels, so, this match cmd should let them through.
Today, the filter produces either a match or nomatch response regardless of
whether it is mpls/vxlan, resulting in either permitting or denying the
route.. So an mpls evpn route may get filtered out incorrectly.
Eg: "route-map RM1 permit 10 ; match evpn vni 20" or
"route-map RM2 deny 20 ; match vni 20"
With the introduction of the 3rd state, we can abort this rule check safely.
How? The rules api can now return RMAP_NOOP to indicate
that it encountered an invalid check, and needs to abort just that rule,
but continue with other rules.
As a result we have a 3rd state:
State3:
If match cmd returned RMAP_NOOP
Then, proceed to other route-map, otherwise if there are no more
rules or if all the rules return RMAP_NOOP, then, return RMAP_PERMITMATCH.
Signed-off-by: Lakshman Krishnamoorthy <lkrishnamoor@vmware.com>
2019-06-19 23:04:36 +02:00
|
|
|
return RMAP_NOMATCH;
|
2018-05-17 16:29:49 +02:00
|
|
|
|
2023-08-11 16:12:06 +02:00
|
|
|
return (rm_data->instance == *instance) ? RMAP_MATCH : RMAP_NOMATCH;
|
2018-05-17 16:29:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void *route_match_source_instance_compile(const char *arg)
|
|
|
|
{
|
|
|
|
uint8_t *instance;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
i = atoi(arg);
|
|
|
|
instance = XMALLOC(MTYPE_ROUTE_MAP_COMPILED, sizeof(uint8_t));
|
|
|
|
|
|
|
|
*instance = i;
|
|
|
|
|
|
|
|
return instance;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void route_match_source_instance_free(void *rule)
|
|
|
|
{
|
|
|
|
XFREE(MTYPE_ROUTE_MAP_COMPILED, rule);
|
|
|
|
}
|
|
|
|
|
2019-11-20 17:20:58 +01:00
|
|
|
static const struct route_map_rule_cmd route_match_source_instance_cmd = {
|
|
|
|
"source-instance",
|
|
|
|
route_match_source_instance,
|
|
|
|
route_match_source_instance_compile,
|
|
|
|
route_match_source_instance_free
|
|
|
|
};
|
2018-05-17 16:29:49 +02:00
|
|
|
|
2007-05-04 22:13:20 +02:00
|
|
|
/* `set src A.B.C.D' */
|
|
|
|
|
|
|
|
/* Set src. */
|
lib: Introducing a 3rd state for route-map match cmd: RMAP_NOOP
Introducing a 3rd state for route_map_apply library function: RMAP_NOOP
Traditionally route map MATCH rule apis were designed to return
a binary response, consisting of either RMAP_MATCH or RMAP_NOMATCH.
(Route-map SET rule apis return RMAP_OKAY or RMAP_ERROR).
Depending on this response, the following statemachine decided the
course of action:
State1:
If match cmd returns RMAP_MATCH then, keep existing behaviour.
If routemap type is PERMIT, execute set cmds or call cmds if applicable,
otherwise PERMIT!
Else If routemap type is DENY, we DENYMATCH right away
State2:
If match cmd returns RMAP_NOMATCH, continue on to next route-map. If there
are no other rules or if all the rules return RMAP_NOMATCH, return DENYMATCH
We require a 3rd state because of the following situation:
The issue - what if, the rule api needs to abort or ignore a rule?:
"match evpn vni xx" route-map filter can be applied to incoming routes
regardless of whether the tunnel type is vxlan or mpls.
This rule should be N/A for mpls based evpn route, but applicable to only
vxlan based evpn route.
Also, this rule should be applicable for routes with VNI label only, and
not for routes without labels. For example, type 3 and type 4 EVPN routes
do not have labels, so, this match cmd should let them through.
Today, the filter produces either a match or nomatch response regardless of
whether it is mpls/vxlan, resulting in either permitting or denying the
route.. So an mpls evpn route may get filtered out incorrectly.
Eg: "route-map RM1 permit 10 ; match evpn vni 20" or
"route-map RM2 deny 20 ; match vni 20"
With the introduction of the 3rd state, we can abort this rule check safely.
How? The rules api can now return RMAP_NOOP to indicate
that it encountered an invalid check, and needs to abort just that rule,
but continue with other rules.
As a result we have a 3rd state:
State3:
If match cmd returned RMAP_NOOP
Then, proceed to other route-map, otherwise if there are no more
rules or if all the rules return RMAP_NOOP, then, return RMAP_PERMITMATCH.
Signed-off-by: Lakshman Krishnamoorthy <lkrishnamoor@vmware.com>
2019-06-19 23:04:36 +02:00
|
|
|
static enum route_map_cmd_result_t
|
2020-11-14 01:35:20 +01:00
|
|
|
route_set_src(void *rule, const struct prefix *prefix, void *object)
|
2007-05-04 22:13:20 +02:00
|
|
|
{
|
2023-08-11 16:12:06 +02:00
|
|
|
struct zebra_rmap_obj *rm_data;
|
2015-05-20 02:47:20 +02:00
|
|
|
|
2023-08-11 16:12:06 +02:00
|
|
|
rm_data = (struct zebra_rmap_obj *)object;
|
|
|
|
rm_data->nexthop->rmap_src = *(union g_addr *)rule;
|
2020-11-14 01:35:20 +01:00
|
|
|
|
2007-05-04 22:13:20 +02:00
|
|
|
return RMAP_OKAY;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* set src compilation. */
|
|
|
|
static void *route_set_src_compile(const char *arg)
|
|
|
|
{
|
|
|
|
union g_addr src, *psrc;
|
|
|
|
|
2017-01-13 18:46:58 +01:00
|
|
|
if ((inet_pton(AF_INET6, arg, &src.ipv6) == 1)
|
2018-01-28 00:56:30 +01:00
|
|
|
|| (inet_pton(AF_INET, arg, &src.ipv4) == 1)) {
|
2015-09-16 08:48:00 +02:00
|
|
|
psrc = XMALLOC(MTYPE_ROUTE_MAP_COMPILED, sizeof(union g_addr));
|
|
|
|
*psrc = src;
|
|
|
|
return psrc;
|
|
|
|
}
|
|
|
|
return NULL;
|
2007-05-04 22:13:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Free route map's compiled `set src' value. */
|
|
|
|
static void route_set_src_free(void *rule)
|
|
|
|
{
|
|
|
|
XFREE(MTYPE_ROUTE_MAP_COMPILED, rule);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Set src rule structure. */
|
2019-11-20 17:20:58 +01:00
|
|
|
static const struct route_map_rule_cmd route_set_src_cmd = {
|
|
|
|
"src",
|
|
|
|
route_set_src,
|
|
|
|
route_set_src_compile,
|
|
|
|
route_set_src_free,
|
2007-05-04 22:13:20 +02:00
|
|
|
};
|
|
|
|
|
2018-08-17 17:47:48 +02:00
|
|
|
/* The function checks if the changed routemap specified by parameter rmap
|
|
|
|
* matches the configured protocol routemaps in proto_rm table. If there is
|
|
|
|
* a match then rib_update_table() to process the routes.
|
|
|
|
*/
|
|
|
|
static void zebra_rib_table_rm_update(const char *rmap)
|
|
|
|
{
|
|
|
|
int i = 0;
|
|
|
|
struct route_table *table;
|
2018-10-11 19:44:55 +02:00
|
|
|
struct vrf *vrf = NULL;
|
|
|
|
struct zebra_vrf *zvrf = NULL;
|
2018-08-17 17:47:48 +02:00
|
|
|
char *rmap_name;
|
2019-02-04 14:19:54 +01:00
|
|
|
struct route_map *old = NULL;
|
2018-08-17 17:47:48 +02:00
|
|
|
|
2018-10-11 19:44:55 +02:00
|
|
|
RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) {
|
|
|
|
zvrf = vrf->info;
|
|
|
|
if (!zvrf)
|
|
|
|
continue;
|
|
|
|
for (i = 0; i <= ZEBRA_ROUTE_MAX; i++) {
|
|
|
|
rmap_name = PROTO_RM_NAME(zvrf, AFI_IP, i);
|
|
|
|
if (rmap_name && (strcmp(rmap_name, rmap) == 0)) {
|
|
|
|
if (IS_ZEBRA_DEBUG_EVENT)
|
|
|
|
zlog_debug(
|
|
|
|
"%s : AFI_IP rmap %s, route type %s",
|
|
|
|
__func__, rmap,
|
|
|
|
zebra_route_string(i));
|
|
|
|
|
2019-02-04 14:19:54 +01:00
|
|
|
old = PROTO_RM_MAP(zvrf, AFI_IP, i);
|
|
|
|
|
2018-10-11 19:44:55 +02:00
|
|
|
PROTO_RM_MAP(zvrf, AFI_IP, i) =
|
|
|
|
route_map_lookup_by_name(rmap_name);
|
2019-02-04 14:19:54 +01:00
|
|
|
/* old is NULL. i.e Route map creation event.
|
|
|
|
* So update applied_counter.
|
|
|
|
* If Old is not NULL, i.e It may be routemap
|
|
|
|
* updation or deletion.
|
|
|
|
* So no need to update the counter.
|
|
|
|
*/
|
|
|
|
if (!old)
|
|
|
|
route_map_counter_increment(
|
|
|
|
PROTO_RM_MAP(zvrf, AFI_IP, i));
|
2018-10-11 19:44:55 +02:00
|
|
|
/* There is single rib table for all protocols
|
|
|
|
*/
|
2020-10-01 17:18:45 +02:00
|
|
|
table = zvrf->table[AFI_IP][SAFI_UNICAST];
|
|
|
|
if (table) {
|
|
|
|
rib_update_table(
|
|
|
|
table,
|
|
|
|
RIB_UPDATE_RMAP_CHANGE,
|
|
|
|
i);
|
2018-08-17 17:47:48 +02:00
|
|
|
}
|
|
|
|
}
|
2018-10-11 19:44:55 +02:00
|
|
|
rmap_name = PROTO_RM_NAME(zvrf, AFI_IP6, i);
|
|
|
|
if (rmap_name && (strcmp(rmap_name, rmap) == 0)) {
|
|
|
|
if (IS_ZEBRA_DEBUG_EVENT)
|
|
|
|
zlog_debug(
|
|
|
|
"%s : AFI_IP6 rmap %s, route type %s",
|
|
|
|
__func__, rmap,
|
|
|
|
zebra_route_string(i));
|
|
|
|
|
2019-02-04 14:19:54 +01:00
|
|
|
old = PROTO_RM_MAP(zvrf, AFI_IP6, i);
|
|
|
|
|
2018-10-11 19:44:55 +02:00
|
|
|
PROTO_RM_MAP(zvrf, AFI_IP6, i) =
|
|
|
|
route_map_lookup_by_name(rmap_name);
|
2019-02-04 14:19:54 +01:00
|
|
|
if (!old)
|
|
|
|
route_map_counter_increment(
|
|
|
|
PROTO_RM_MAP(zvrf, AFI_IP6, i));
|
2018-10-11 19:44:55 +02:00
|
|
|
/* There is single rib table for all protocols
|
|
|
|
*/
|
2020-10-01 17:18:45 +02:00
|
|
|
table = zvrf->table[AFI_IP6][SAFI_UNICAST];
|
|
|
|
if (table) {
|
|
|
|
rib_update_table(
|
|
|
|
table,
|
|
|
|
RIB_UPDATE_RMAP_CHANGE,
|
|
|
|
i);
|
2018-08-17 17:47:48 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* The function checks if the changed routemap specified by parameter rmap
|
|
|
|
* matches the configured protocol routemaps in nht_rm table. If there is
|
|
|
|
* a match then zebra_evaluate_rnh() to process the nexthops.
|
|
|
|
*/
|
|
|
|
static void zebra_nht_rm_update(const char *rmap)
|
|
|
|
{
|
|
|
|
int i = 0;
|
2018-10-11 19:44:55 +02:00
|
|
|
struct route_table *table;
|
|
|
|
struct vrf *vrf = NULL;
|
|
|
|
struct zebra_vrf *zvrf = NULL;
|
2018-08-17 17:47:48 +02:00
|
|
|
char *rmap_name;
|
|
|
|
char afi_ip = 0;
|
|
|
|
char afi_ipv6 = 0;
|
2019-02-04 14:19:54 +01:00
|
|
|
struct route_map *old = NULL;
|
2018-08-17 17:47:48 +02:00
|
|
|
|
2018-10-11 19:44:55 +02:00
|
|
|
RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) {
|
|
|
|
zvrf = vrf->info;
|
|
|
|
if (!zvrf)
|
|
|
|
continue;
|
|
|
|
for (i = 0; i <= ZEBRA_ROUTE_MAX; i++) {
|
|
|
|
rmap_name = NHT_RM_NAME(zvrf, AFI_IP, i);
|
|
|
|
if (rmap_name && (strcmp(rmap_name, rmap) == 0)) {
|
|
|
|
if (IS_ZEBRA_DEBUG_EVENT)
|
|
|
|
zlog_debug(
|
|
|
|
"%s : AFI_IP rmap %s, route type %s",
|
|
|
|
__func__, rmap,
|
|
|
|
zebra_route_string(i));
|
|
|
|
|
2019-02-04 14:19:54 +01:00
|
|
|
old = NHT_RM_MAP(zvrf, AFI_IP, i);
|
|
|
|
|
2018-10-11 19:44:55 +02:00
|
|
|
NHT_RM_MAP(zvrf, AFI_IP, i) =
|
|
|
|
route_map_lookup_by_name(rmap_name);
|
2019-02-04 14:19:54 +01:00
|
|
|
if (!old)
|
|
|
|
route_map_counter_increment(
|
|
|
|
NHT_RM_MAP(zvrf, AFI_IP, i));
|
2018-10-11 19:44:55 +02:00
|
|
|
/* There is single rib table for all protocols
|
|
|
|
*/
|
|
|
|
if (afi_ip == 0) {
|
|
|
|
table = zvrf->table[AFI_IP]
|
|
|
|
[SAFI_UNICAST];
|
|
|
|
if (table) {
|
|
|
|
|
|
|
|
afi_ip = 1;
|
|
|
|
|
2021-09-24 22:36:27 +02:00
|
|
|
zebra_evaluate_rnh(
|
|
|
|
zvrf, AFI_IP, 1, NULL,
|
|
|
|
SAFI_UNICAST);
|
2018-10-11 19:44:55 +02:00
|
|
|
}
|
|
|
|
}
|
2018-08-17 17:47:48 +02:00
|
|
|
}
|
2018-10-11 19:44:55 +02:00
|
|
|
|
|
|
|
rmap_name = NHT_RM_NAME(zvrf, AFI_IP6, i);
|
|
|
|
if (rmap_name && (strcmp(rmap_name, rmap) == 0)) {
|
|
|
|
if (IS_ZEBRA_DEBUG_EVENT)
|
|
|
|
zlog_debug(
|
|
|
|
"%s : AFI_IP6 rmap %s, route type %s",
|
|
|
|
__func__, rmap,
|
|
|
|
zebra_route_string(i));
|
|
|
|
|
2019-02-04 14:19:54 +01:00
|
|
|
old = NHT_RM_MAP(zvrf, AFI_IP6, i);
|
|
|
|
|
2018-10-11 19:44:55 +02:00
|
|
|
NHT_RM_MAP(zvrf, AFI_IP6, i) =
|
|
|
|
route_map_lookup_by_name(rmap_name);
|
2019-02-04 14:19:54 +01:00
|
|
|
if (!old)
|
|
|
|
route_map_counter_increment(
|
|
|
|
NHT_RM_MAP(zvrf, AFI_IP6, i));
|
2018-10-11 19:44:55 +02:00
|
|
|
/* There is single rib table for all protocols
|
|
|
|
*/
|
|
|
|
if (afi_ipv6 == 0) {
|
|
|
|
table = zvrf->table[AFI_IP6]
|
|
|
|
[SAFI_UNICAST];
|
|
|
|
if (table) {
|
|
|
|
|
|
|
|
afi_ipv6 = 1;
|
|
|
|
|
2021-09-24 22:36:27 +02:00
|
|
|
zebra_evaluate_rnh(
|
2023-07-14 10:08:50 +02:00
|
|
|
zvrf, AFI_IP6, 1, NULL,
|
2021-09-24 22:36:27 +02:00
|
|
|
SAFI_UNICAST);
|
2018-10-11 19:44:55 +02:00
|
|
|
}
|
|
|
|
}
|
2018-08-17 17:47:48 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-06-20 03:18:33 +02:00
|
|
|
static void zebra_route_map_process_update_cb(char *rmap_name)
|
2018-06-20 03:00:39 +02:00
|
|
|
{
|
|
|
|
if (IS_ZEBRA_DEBUG_EVENT)
|
|
|
|
zlog_debug("Event handler for route-map: %s",
|
|
|
|
rmap_name);
|
2018-08-17 17:47:48 +02:00
|
|
|
zebra_import_table_rm_update(rmap_name);
|
|
|
|
zebra_rib_table_rm_update(rmap_name);
|
|
|
|
zebra_nht_rm_update(rmap_name);
|
2018-06-20 03:00:39 +02:00
|
|
|
}
|
|
|
|
|
2022-03-01 22:18:12 +01:00
|
|
|
static void zebra_route_map_update_timer(struct event *thread)
|
2015-05-20 02:40:45 +02:00
|
|
|
{
|
|
|
|
if (IS_ZEBRA_DEBUG_EVENT)
|
|
|
|
zlog_debug("Event driven route-map update triggered");
|
|
|
|
|
2015-11-20 17:48:32 +01:00
|
|
|
if (IS_ZEBRA_DEBUG_RIB_DETAILED)
|
Zebra: Schedule RIB processing based on trigger event
Currently, when RIB processing is initiated (i.e., by calling rib_update()),
all routes are queued for processing. This is not desirable in all situations
because, sometimes the protocol may have an alternate path. In addition,
with NHT tracking nexthops, there are situations when NHT should be kicked
off first and that can trigger subsequent RIB processing.
This patch addresses this by introducing the notion of a trigger event. This
is only for the situation when the entire RIB is walked. The current triggers
- based on when rib_update() is invoked - are "interface change" and "route-
map change". In the former case, only the relevant routes are walked and
scheduled, in the latter case, currently all routes are scheduled for
processing.
Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
Reviewed-by: Donald Sharp <sharpd@cumulusnetworks.com>
Ticket: CM-7662
Reviewed By: CCR-3905
Note: The initial defect in this area was CM-7420. This was addressed in
2.5.4 with an interim change that only walked static routes upon interface
down. The change was considered a bit risky to do for interface up etc. Also,
this did not address scenarios like CM-7662. The current fix addresses CM-7662.
2015-12-09 01:55:43 +01:00
|
|
|
zlog_debug(
|
|
|
|
"%u: Routemap update-timer fired, scheduling RIB processing",
|
|
|
|
VRF_DEFAULT);
|
2015-10-21 07:37:32 +02:00
|
|
|
|
2018-06-20 03:00:39 +02:00
|
|
|
route_map_walk_update_list(zebra_route_map_process_update_cb);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This code needs to be updated to be:
|
|
|
|
* 1) VRF Aware <sigh>
|
|
|
|
* 2) Route-map aware
|
|
|
|
*/
|
2015-05-20 02:40:45 +02:00
|
|
|
}
|
|
|
|
|
2018-03-27 21:13:34 +02:00
|
|
|
static void zebra_route_map_set_delay_timer(uint32_t value)
|
2015-05-20 02:40:45 +02:00
|
|
|
{
|
|
|
|
zebra_rmap_update_timer = value;
|
|
|
|
if (!value && zebra_t_rmap_update) {
|
|
|
|
/* Event driven route map updates is being disabled */
|
|
|
|
/* But there's a pending timer. Fire it off now */
|
2022-12-25 16:26:52 +01:00
|
|
|
EVENT_OFF(zebra_t_rmap_update);
|
2020-10-09 17:41:21 +02:00
|
|
|
zebra_route_map_update_timer(NULL);
|
2015-05-20 02:40:45 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-16 03:23:38 +01:00
|
|
|
void zebra_routemap_finish(void)
|
|
|
|
{
|
|
|
|
/* Set zebra_rmap_update_timer to 0 so that it wont schedule again */
|
|
|
|
zebra_rmap_update_timer = 0;
|
|
|
|
/* Thread off if any scheduled already */
|
2022-12-25 16:26:52 +01:00
|
|
|
EVENT_OFF(zebra_t_rmap_update);
|
2020-03-16 03:23:38 +01:00
|
|
|
route_map_finish();
|
|
|
|
}
|
|
|
|
|
2018-10-11 19:44:55 +02:00
|
|
|
route_map_result_t
|
2023-08-11 17:11:40 +02:00
|
|
|
zebra_route_map_check(afi_t family, struct route_entry *re, uint8_t instance,
|
2018-10-11 19:44:55 +02:00
|
|
|
const struct prefix *p, struct nexthop *nexthop,
|
|
|
|
struct zebra_vrf *zvrf, route_tag_t tag)
|
2015-05-20 02:40:45 +02:00
|
|
|
{
|
|
|
|
struct route_map *rmap = NULL;
|
2020-11-14 03:06:02 +01:00
|
|
|
char *rm_name;
|
lib: Introducing a 3rd state for route-map match cmd: RMAP_NOOP
Introducing a 3rd state for route_map_apply library function: RMAP_NOOP
Traditionally route map MATCH rule apis were designed to return
a binary response, consisting of either RMAP_MATCH or RMAP_NOMATCH.
(Route-map SET rule apis return RMAP_OKAY or RMAP_ERROR).
Depending on this response, the following statemachine decided the
course of action:
State1:
If match cmd returns RMAP_MATCH then, keep existing behaviour.
If routemap type is PERMIT, execute set cmds or call cmds if applicable,
otherwise PERMIT!
Else If routemap type is DENY, we DENYMATCH right away
State2:
If match cmd returns RMAP_NOMATCH, continue on to next route-map. If there
are no other rules or if all the rules return RMAP_NOMATCH, return DENYMATCH
We require a 3rd state because of the following situation:
The issue - what if, the rule api needs to abort or ignore a rule?:
"match evpn vni xx" route-map filter can be applied to incoming routes
regardless of whether the tunnel type is vxlan or mpls.
This rule should be N/A for mpls based evpn route, but applicable to only
vxlan based evpn route.
Also, this rule should be applicable for routes with VNI label only, and
not for routes without labels. For example, type 3 and type 4 EVPN routes
do not have labels, so, this match cmd should let them through.
Today, the filter produces either a match or nomatch response regardless of
whether it is mpls/vxlan, resulting in either permitting or denying the
route.. So an mpls evpn route may get filtered out incorrectly.
Eg: "route-map RM1 permit 10 ; match evpn vni 20" or
"route-map RM2 deny 20 ; match vni 20"
With the introduction of the 3rd state, we can abort this rule check safely.
How? The rules api can now return RMAP_NOOP to indicate
that it encountered an invalid check, and needs to abort just that rule,
but continue with other rules.
As a result we have a 3rd state:
State3:
If match cmd returned RMAP_NOOP
Then, proceed to other route-map, otherwise if there are no more
rules or if all the rules return RMAP_NOOP, then, return RMAP_PERMITMATCH.
Signed-off-by: Lakshman Krishnamoorthy <lkrishnamoor@vmware.com>
2019-06-19 23:04:36 +02:00
|
|
|
route_map_result_t ret = RMAP_PERMITMATCH;
|
2023-08-11 16:12:06 +02:00
|
|
|
struct zebra_rmap_obj rm_obj;
|
2015-05-20 02:47:20 +02:00
|
|
|
|
2023-08-11 16:12:06 +02:00
|
|
|
rm_obj.nexthop = nexthop;
|
2023-08-11 17:11:40 +02:00
|
|
|
rm_obj.re = re;
|
2023-08-11 16:12:06 +02:00
|
|
|
rm_obj.instance = instance;
|
|
|
|
rm_obj.metric = 0;
|
|
|
|
rm_obj.tag = tag;
|
2015-05-20 02:40:45 +02:00
|
|
|
|
2023-08-11 17:11:40 +02:00
|
|
|
if (re->type >= 0 && re->type < ZEBRA_ROUTE_MAX) {
|
|
|
|
rm_name = PROTO_RM_NAME(zvrf, family, re->type);
|
|
|
|
rmap = PROTO_RM_MAP(zvrf, family, re->type);
|
2020-11-14 03:06:02 +01:00
|
|
|
|
|
|
|
if (rm_name && !rmap)
|
|
|
|
return RMAP_DENYMATCH;
|
|
|
|
}
|
|
|
|
if (!rmap) {
|
|
|
|
rm_name = PROTO_RM_NAME(zvrf, family, ZEBRA_ROUTE_MAX);
|
2018-10-11 19:44:55 +02:00
|
|
|
rmap = PROTO_RM_MAP(zvrf, family, ZEBRA_ROUTE_MAX);
|
2020-11-14 03:06:02 +01:00
|
|
|
|
|
|
|
if (rm_name && !rmap)
|
|
|
|
return RMAP_DENYMATCH;
|
|
|
|
}
|
2015-05-20 02:40:45 +02:00
|
|
|
if (rmap) {
|
2023-08-11 16:12:06 +02:00
|
|
|
ret = route_map_apply(rmap, p, &rm_obj);
|
2015-05-20 02:47:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return (ret);
|
|
|
|
}
|
|
|
|
|
2016-05-11 17:47:02 +02:00
|
|
|
char *zebra_get_import_table_route_map(afi_t afi, uint32_t table)
|
|
|
|
{
|
|
|
|
return zebra_import_table_routemap[afi][table];
|
|
|
|
}
|
|
|
|
|
|
|
|
void zebra_add_import_table_route_map(afi_t afi, const char *rmap_name,
|
|
|
|
uint32_t table)
|
|
|
|
{
|
|
|
|
zebra_import_table_routemap[afi][table] =
|
|
|
|
XSTRDUP(MTYPE_ROUTE_MAP_NAME, rmap_name);
|
|
|
|
}
|
|
|
|
|
|
|
|
void zebra_del_import_table_route_map(afi_t afi, uint32_t table)
|
|
|
|
{
|
|
|
|
XFREE(MTYPE_ROUTE_MAP_NAME, zebra_import_table_routemap[afi][table]);
|
|
|
|
}
|
|
|
|
|
2023-08-11 17:11:40 +02:00
|
|
|
route_map_result_t
|
|
|
|
zebra_import_table_route_map_check(int family, struct route_entry *re,
|
|
|
|
uint8_t instance, const struct prefix *p,
|
|
|
|
struct nexthop *nexthop, route_tag_t tag,
|
|
|
|
const char *rmap_name)
|
2016-05-11 17:47:02 +02:00
|
|
|
{
|
|
|
|
struct route_map *rmap = NULL;
|
2019-06-04 00:36:02 +02:00
|
|
|
route_map_result_t ret = RMAP_DENYMATCH;
|
2023-08-11 16:12:06 +02:00
|
|
|
struct zebra_rmap_obj rm_obj;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2023-08-11 16:12:06 +02:00
|
|
|
rm_obj.nexthop = nexthop;
|
2023-08-11 17:11:40 +02:00
|
|
|
rm_obj.re = re;
|
2023-08-11 16:12:06 +02:00
|
|
|
rm_obj.instance = instance;
|
|
|
|
rm_obj.metric = 0;
|
|
|
|
rm_obj.tag = tag;
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2023-08-11 17:11:40 +02:00
|
|
|
if (re->type >= 0 && re->type < ZEBRA_ROUTE_MAX)
|
2016-05-11 17:47:02 +02:00
|
|
|
rmap = route_map_lookup_by_name(rmap_name);
|
|
|
|
if (rmap) {
|
2023-08-11 16:12:06 +02:00
|
|
|
ret = route_map_apply(rmap, p, &rm_obj);
|
2016-05-11 17:47:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return (ret);
|
|
|
|
}
|
|
|
|
|
2019-01-21 15:30:36 +01:00
|
|
|
route_map_result_t zebra_nht_route_map_check(afi_t afi, int client_proto,
|
2018-07-12 22:05:19 +02:00
|
|
|
const struct prefix *p,
|
2018-10-11 19:44:55 +02:00
|
|
|
struct zebra_vrf *zvrf,
|
2017-06-01 13:26:25 +02:00
|
|
|
struct route_entry *re,
|
|
|
|
struct nexthop *nexthop)
|
2015-05-20 02:47:20 +02:00
|
|
|
{
|
|
|
|
struct route_map *rmap = NULL;
|
lib: Introducing a 3rd state for route-map match cmd: RMAP_NOOP
Introducing a 3rd state for route_map_apply library function: RMAP_NOOP
Traditionally route map MATCH rule apis were designed to return
a binary response, consisting of either RMAP_MATCH or RMAP_NOMATCH.
(Route-map SET rule apis return RMAP_OKAY or RMAP_ERROR).
Depending on this response, the following statemachine decided the
course of action:
State1:
If match cmd returns RMAP_MATCH then, keep existing behaviour.
If routemap type is PERMIT, execute set cmds or call cmds if applicable,
otherwise PERMIT!
Else If routemap type is DENY, we DENYMATCH right away
State2:
If match cmd returns RMAP_NOMATCH, continue on to next route-map. If there
are no other rules or if all the rules return RMAP_NOMATCH, return DENYMATCH
We require a 3rd state because of the following situation:
The issue - what if, the rule api needs to abort or ignore a rule?:
"match evpn vni xx" route-map filter can be applied to incoming routes
regardless of whether the tunnel type is vxlan or mpls.
This rule should be N/A for mpls based evpn route, but applicable to only
vxlan based evpn route.
Also, this rule should be applicable for routes with VNI label only, and
not for routes without labels. For example, type 3 and type 4 EVPN routes
do not have labels, so, this match cmd should let them through.
Today, the filter produces either a match or nomatch response regardless of
whether it is mpls/vxlan, resulting in either permitting or denying the
route.. So an mpls evpn route may get filtered out incorrectly.
Eg: "route-map RM1 permit 10 ; match evpn vni 20" or
"route-map RM2 deny 20 ; match vni 20"
With the introduction of the 3rd state, we can abort this rule check safely.
How? The rules api can now return RMAP_NOOP to indicate
that it encountered an invalid check, and needs to abort just that rule,
but continue with other rules.
As a result we have a 3rd state:
State3:
If match cmd returned RMAP_NOOP
Then, proceed to other route-map, otherwise if there are no more
rules or if all the rules return RMAP_NOOP, then, return RMAP_PERMITMATCH.
Signed-off-by: Lakshman Krishnamoorthy <lkrishnamoor@vmware.com>
2019-06-19 23:04:36 +02:00
|
|
|
route_map_result_t ret = RMAP_PERMITMATCH;
|
2023-08-11 16:12:06 +02:00
|
|
|
struct zebra_rmap_obj rm_obj;
|
2015-05-20 02:47:20 +02:00
|
|
|
|
2023-08-11 16:12:06 +02:00
|
|
|
rm_obj.nexthop = nexthop;
|
2023-08-11 17:11:40 +02:00
|
|
|
rm_obj.re = re;
|
2023-08-11 16:12:06 +02:00
|
|
|
rm_obj.instance = re->instance;
|
|
|
|
rm_obj.metric = re->metric;
|
|
|
|
rm_obj.tag = re->tag;
|
2015-05-20 02:47:20 +02:00
|
|
|
|
|
|
|
if (client_proto >= 0 && client_proto < ZEBRA_ROUTE_MAX)
|
2019-01-21 15:30:36 +01:00
|
|
|
rmap = NHT_RM_MAP(zvrf, afi, client_proto);
|
|
|
|
if (!rmap && NHT_RM_MAP(zvrf, afi, ZEBRA_ROUTE_MAX))
|
|
|
|
rmap = NHT_RM_MAP(zvrf, afi, ZEBRA_ROUTE_MAX);
|
2018-07-12 22:05:19 +02:00
|
|
|
if (rmap)
|
2023-08-11 16:12:06 +02:00
|
|
|
ret = route_map_apply(rmap, p, &rm_obj);
|
2015-05-20 02:40:45 +02:00
|
|
|
|
2018-07-12 22:05:19 +02:00
|
|
|
return ret;
|
2015-05-20 02:40:45 +02:00
|
|
|
}
|
|
|
|
|
2015-05-20 02:47:20 +02:00
|
|
|
static void zebra_route_map_mark_update(const char *rmap_name)
|
2015-05-20 02:40:45 +02:00
|
|
|
{
|
|
|
|
/* rmap_update_timer of 0 means don't do route updates */
|
2021-01-15 22:28:15 +01:00
|
|
|
if (zebra_rmap_update_timer)
|
2022-12-25 16:26:52 +01:00
|
|
|
EVENT_OFF(zebra_t_rmap_update);
|
2021-01-15 22:28:15 +01:00
|
|
|
|
2022-05-20 20:19:08 +02:00
|
|
|
event_add_timer(zrouter.master, zebra_route_map_update_timer, NULL,
|
|
|
|
zebra_rmap_update_timer, &zebra_t_rmap_update);
|
2015-05-20 02:40:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void zebra_route_map_add(const char *rmap_name)
|
|
|
|
{
|
2018-06-20 03:00:39 +02:00
|
|
|
if (route_map_mark_updated(rmap_name) == 0)
|
|
|
|
zebra_route_map_mark_update(rmap_name);
|
|
|
|
|
2015-05-20 02:40:45 +02:00
|
|
|
route_map_notify_dependencies(rmap_name, RMAP_EVENT_MATCH_ADDED);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void zebra_route_map_delete(const char *rmap_name)
|
|
|
|
{
|
2018-06-20 03:00:39 +02:00
|
|
|
if (route_map_mark_updated(rmap_name) == 0)
|
|
|
|
zebra_route_map_mark_update(rmap_name);
|
|
|
|
|
2015-05-20 02:40:45 +02:00
|
|
|
route_map_notify_dependencies(rmap_name, RMAP_EVENT_MATCH_DELETED);
|
|
|
|
}
|
|
|
|
|
2019-05-09 05:19:55 +02:00
|
|
|
static void zebra_route_map_event(const char *rmap_name)
|
2015-05-20 02:40:45 +02:00
|
|
|
{
|
2018-06-20 03:00:39 +02:00
|
|
|
if (route_map_mark_updated(rmap_name) == 0)
|
|
|
|
zebra_route_map_mark_update(rmap_name);
|
|
|
|
|
2015-05-20 02:40:45 +02:00
|
|
|
route_map_notify_dependencies(rmap_name, RMAP_EVENT_MATCH_ADDED);
|
|
|
|
}
|
|
|
|
|
2022-12-09 14:51:34 +01:00
|
|
|
void zebra_routemap_vrf_delete(struct zebra_vrf *zvrf)
|
|
|
|
{
|
|
|
|
afi_t afi;
|
|
|
|
uint8_t type;
|
|
|
|
|
|
|
|
for (afi = AFI_IP; afi < AFI_MAX; afi++) {
|
|
|
|
for (type = 0; type <= ZEBRA_ROUTE_MAX; type++) {
|
|
|
|
if (PROTO_RM_NAME(zvrf, afi, type))
|
|
|
|
XFREE(MTYPE_ROUTE_MAP_NAME,
|
|
|
|
PROTO_RM_NAME(zvrf, afi, type));
|
|
|
|
if (NHT_RM_NAME(zvrf, afi, type))
|
|
|
|
XFREE(MTYPE_ROUTE_MAP_NAME,
|
|
|
|
NHT_RM_NAME(zvrf, afi, type));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-05-20 02:40:45 +02:00
|
|
|
/* ip protocol configuration write function */
|
2018-10-11 19:49:34 +02:00
|
|
|
void zebra_routemap_config_write_protocol(struct vty *vty,
|
|
|
|
struct zebra_vrf *zvrf)
|
2015-05-20 02:40:45 +02:00
|
|
|
{
|
|
|
|
int i;
|
2018-10-11 19:49:34 +02:00
|
|
|
char space[2];
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2018-10-11 19:49:34 +02:00
|
|
|
memset(space, 0, sizeof(space));
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2018-10-11 19:49:34 +02:00
|
|
|
if (zvrf_id(zvrf) != VRF_DEFAULT)
|
2020-04-20 20:12:38 +02:00
|
|
|
snprintf(space, sizeof(space), "%s", " ");
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2018-10-11 19:49:34 +02:00
|
|
|
for (i = 0; i < ZEBRA_ROUTE_MAX; i++) {
|
|
|
|
if (PROTO_RM_NAME(zvrf, AFI_IP, i))
|
|
|
|
vty_out(vty, "%sip protocol %s route-map %s\n", space,
|
|
|
|
zebra_route_string(i),
|
|
|
|
PROTO_RM_NAME(zvrf, AFI_IP, i));
|
|
|
|
|
|
|
|
if (PROTO_RM_NAME(zvrf, AFI_IP6, i))
|
|
|
|
vty_out(vty, "%sipv6 protocol %s route-map %s\n", space,
|
|
|
|
zebra_route_string(i),
|
|
|
|
PROTO_RM_NAME(zvrf, AFI_IP6, i));
|
|
|
|
|
|
|
|
if (NHT_RM_NAME(zvrf, AFI_IP, i))
|
|
|
|
vty_out(vty, "%sip nht %s route-map %s\n", space,
|
|
|
|
zebra_route_string(i),
|
|
|
|
NHT_RM_NAME(zvrf, AFI_IP, i));
|
|
|
|
|
|
|
|
if (NHT_RM_NAME(zvrf, AFI_IP6, i))
|
|
|
|
vty_out(vty, "%sipv6 nht %s route-map %s\n", space,
|
|
|
|
zebra_route_string(i),
|
|
|
|
NHT_RM_NAME(zvrf, AFI_IP6, i));
|
2015-05-20 02:40:45 +02:00
|
|
|
}
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2018-10-11 19:49:34 +02:00
|
|
|
if (PROTO_RM_NAME(zvrf, AFI_IP, ZEBRA_ROUTE_MAX))
|
|
|
|
vty_out(vty, "%sip protocol %s route-map %s\n", space, "any",
|
|
|
|
PROTO_RM_NAME(zvrf, AFI_IP, ZEBRA_ROUTE_MAX));
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2018-10-11 19:49:34 +02:00
|
|
|
if (PROTO_RM_NAME(zvrf, AFI_IP6, ZEBRA_ROUTE_MAX))
|
|
|
|
vty_out(vty, "%sipv6 protocol %s route-map %s\n", space, "any",
|
|
|
|
PROTO_RM_NAME(zvrf, AFI_IP6, ZEBRA_ROUTE_MAX));
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2018-10-11 19:49:34 +02:00
|
|
|
if (NHT_RM_NAME(zvrf, AFI_IP, ZEBRA_ROUTE_MAX))
|
|
|
|
vty_out(vty, "%sip nht %s route-map %s\n", space, "any",
|
|
|
|
NHT_RM_NAME(zvrf, AFI_IP, ZEBRA_ROUTE_MAX));
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2018-10-11 19:49:34 +02:00
|
|
|
if (NHT_RM_NAME(zvrf, AFI_IP6, ZEBRA_ROUTE_MAX))
|
|
|
|
vty_out(vty, "%sipv6 nht %s route-map %s\n", space, "any",
|
|
|
|
NHT_RM_NAME(zvrf, AFI_IP6, ZEBRA_ROUTE_MAX));
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2021-01-06 17:29:43 +01:00
|
|
|
if (zvrf_id(zvrf) == VRF_DEFAULT
|
|
|
|
&& zebra_rmap_update_timer != ZEBRA_RMAP_DEFAULT_UPDATE_TIMER)
|
2017-07-13 17:49:13 +02:00
|
|
|
vty_out(vty, "zebra route-map delay-timer %d\n",
|
2017-06-21 05:10:57 +02:00
|
|
|
zebra_rmap_update_timer);
|
2015-05-20 02:40:45 +02:00
|
|
|
}
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2019-01-24 10:12:36 +01:00
|
|
|
void zebra_route_map_init(void)
|
2007-05-04 22:13:20 +02:00
|
|
|
{
|
2015-05-20 02:40:45 +02:00
|
|
|
install_element(CONFIG_NODE, &ip_protocol_cmd);
|
|
|
|
install_element(CONFIG_NODE, &no_ip_protocol_cmd);
|
2018-10-11 19:48:23 +02:00
|
|
|
install_element(VRF_NODE, &ip_protocol_cmd);
|
|
|
|
install_element(VRF_NODE, &no_ip_protocol_cmd);
|
2015-05-20 02:40:45 +02:00
|
|
|
install_element(VIEW_NODE, &show_ip_protocol_cmd);
|
2015-09-16 08:48:00 +02:00
|
|
|
install_element(CONFIG_NODE, &ipv6_protocol_cmd);
|
|
|
|
install_element(CONFIG_NODE, &no_ipv6_protocol_cmd);
|
2018-10-11 19:48:23 +02:00
|
|
|
install_element(VRF_NODE, &ipv6_protocol_cmd);
|
|
|
|
install_element(VRF_NODE, &no_ipv6_protocol_cmd);
|
2015-09-16 08:48:00 +02:00
|
|
|
install_element(VIEW_NODE, &show_ipv6_protocol_cmd);
|
2015-05-20 02:47:20 +02:00
|
|
|
install_element(CONFIG_NODE, &ip_protocol_nht_rmap_cmd);
|
|
|
|
install_element(CONFIG_NODE, &no_ip_protocol_nht_rmap_cmd);
|
2018-10-11 19:48:23 +02:00
|
|
|
install_element(VRF_NODE, &ip_protocol_nht_rmap_cmd);
|
|
|
|
install_element(VRF_NODE, &no_ip_protocol_nht_rmap_cmd);
|
2015-05-20 02:47:20 +02:00
|
|
|
install_element(VIEW_NODE, &show_ip_protocol_nht_cmd);
|
|
|
|
install_element(CONFIG_NODE, &ipv6_protocol_nht_rmap_cmd);
|
|
|
|
install_element(CONFIG_NODE, &no_ipv6_protocol_nht_rmap_cmd);
|
2018-10-11 19:48:23 +02:00
|
|
|
install_element(VRF_NODE, &ipv6_protocol_nht_rmap_cmd);
|
|
|
|
install_element(VRF_NODE, &no_ipv6_protocol_nht_rmap_cmd);
|
2015-05-20 02:47:20 +02:00
|
|
|
install_element(VIEW_NODE, &show_ipv6_protocol_nht_cmd);
|
2015-05-20 02:40:45 +02:00
|
|
|
install_element(CONFIG_NODE, &zebra_route_map_timer_cmd);
|
|
|
|
install_element(CONFIG_NODE, &no_zebra_route_map_timer_cmd);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2007-05-04 22:13:20 +02:00
|
|
|
route_map_init();
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2015-05-20 02:40:45 +02:00
|
|
|
route_map_add_hook(zebra_route_map_add);
|
|
|
|
route_map_delete_hook(zebra_route_map_delete);
|
|
|
|
route_map_event_hook(zebra_route_map_event);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2016-10-06 21:56:13 +02:00
|
|
|
route_map_match_interface_hook(generic_match_add);
|
|
|
|
route_map_no_match_interface_hook(generic_match_delete);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2016-10-06 21:56:13 +02:00
|
|
|
route_map_match_ip_address_hook(generic_match_add);
|
|
|
|
route_map_no_match_ip_address_hook(generic_match_delete);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2016-10-06 21:56:13 +02:00
|
|
|
route_map_match_ip_address_prefix_list_hook(generic_match_add);
|
|
|
|
route_map_no_match_ip_address_prefix_list_hook(generic_match_delete);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2016-10-06 21:56:13 +02:00
|
|
|
route_map_match_ip_next_hop_hook(generic_match_add);
|
|
|
|
route_map_no_match_ip_next_hop_hook(generic_match_delete);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2016-10-06 21:56:13 +02:00
|
|
|
route_map_match_ip_next_hop_prefix_list_hook(generic_match_add);
|
|
|
|
route_map_no_match_ip_next_hop_prefix_list_hook(generic_match_delete);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2019-06-21 17:51:33 +02:00
|
|
|
route_map_match_ip_next_hop_type_hook(generic_match_add);
|
|
|
|
route_map_no_match_ip_next_hop_type_hook(generic_match_delete);
|
|
|
|
|
2016-10-06 21:56:13 +02:00
|
|
|
route_map_match_tag_hook(generic_match_add);
|
|
|
|
route_map_no_match_tag_hook(generic_match_delete);
|
2017-07-17 14:03:14 +02:00
|
|
|
|
2018-08-17 17:53:28 +02:00
|
|
|
route_map_match_ipv6_address_hook(generic_match_add);
|
|
|
|
route_map_no_match_ipv6_address_hook(generic_match_delete);
|
|
|
|
|
|
|
|
route_map_match_ipv6_address_prefix_list_hook(generic_match_add);
|
|
|
|
route_map_no_match_ipv6_address_prefix_list_hook(generic_match_delete);
|
|
|
|
|
2019-06-21 17:51:33 +02:00
|
|
|
route_map_match_ipv6_next_hop_type_hook(generic_match_add);
|
|
|
|
route_map_no_match_ipv6_next_hop_type_hook(generic_match_delete);
|
|
|
|
|
2015-05-20 03:03:44 +02:00
|
|
|
route_map_install_match(&route_match_tag_cmd);
|
2007-05-04 22:13:20 +02:00
|
|
|
route_map_install_match(&route_match_interface_cmd);
|
|
|
|
route_map_install_match(&route_match_ip_next_hop_cmd);
|
|
|
|
route_map_install_match(&route_match_ip_next_hop_prefix_list_cmd);
|
|
|
|
route_map_install_match(&route_match_ip_address_cmd);
|
2018-11-07 01:25:58 +01:00
|
|
|
route_map_install_match(&route_match_ipv6_address_cmd);
|
2007-05-04 22:13:20 +02:00
|
|
|
route_map_install_match(&route_match_ip_address_prefix_list_cmd);
|
2018-08-17 17:53:28 +02:00
|
|
|
route_map_install_match(&route_match_ipv6_address_prefix_list_cmd);
|
2015-05-20 02:47:20 +02:00
|
|
|
route_map_install_match(&route_match_ip_address_prefix_len_cmd);
|
2017-11-03 15:33:09 +01:00
|
|
|
route_map_install_match(&route_match_ipv6_address_prefix_len_cmd);
|
2015-05-20 02:47:20 +02:00
|
|
|
route_map_install_match(&route_match_ip_nexthop_prefix_len_cmd);
|
2019-06-21 17:51:33 +02:00
|
|
|
route_map_install_match(&route_match_ip_next_hop_type_cmd);
|
|
|
|
route_map_install_match(&route_match_ipv6_next_hop_type_cmd);
|
2015-05-20 02:47:20 +02:00
|
|
|
route_map_install_match(&route_match_source_protocol_cmd);
|
2018-05-17 16:29:49 +02:00
|
|
|
route_map_install_match(&route_match_source_instance_cmd);
|
|
|
|
|
2007-05-04 22:13:20 +02:00
|
|
|
/* */
|
|
|
|
route_map_install_set(&route_set_src_cmd);
|
|
|
|
/* */
|
2015-05-20 02:47:20 +02:00
|
|
|
install_element(RMAP_NODE, &match_ip_nexthop_prefix_len_cmd);
|
|
|
|
install_element(RMAP_NODE, &no_match_ip_nexthop_prefix_len_cmd);
|
|
|
|
install_element(RMAP_NODE, &match_ip_address_prefix_len_cmd);
|
2017-11-03 15:33:09 +01:00
|
|
|
install_element(RMAP_NODE, &match_ipv6_address_prefix_len_cmd);
|
|
|
|
install_element(RMAP_NODE, &no_match_ipv6_address_prefix_len_cmd);
|
2015-05-20 02:47:20 +02:00
|
|
|
install_element(RMAP_NODE, &no_match_ip_address_prefix_len_cmd);
|
|
|
|
install_element(RMAP_NODE, &match_source_protocol_cmd);
|
|
|
|
install_element(RMAP_NODE, &no_match_source_protocol_cmd);
|
2018-05-17 16:29:49 +02:00
|
|
|
install_element(RMAP_NODE, &match_source_instance_cmd);
|
|
|
|
install_element(RMAP_NODE, &no_match_source_instance_cmd);
|
|
|
|
|
2015-05-20 02:47:20 +02:00
|
|
|
/* */
|
2007-05-04 22:13:20 +02:00
|
|
|
install_element(RMAP_NODE, &set_src_cmd);
|
|
|
|
install_element(RMAP_NODE, &no_set_src_cmd);
|
|
|
|
}
|