summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorIgor Ryzhov <iryzhov@nfware.com>2021-11-23 16:45:25 +0300
committerGitHub <noreply@github.com>2021-11-23 16:45:25 +0300
commit4ac61f7a2a6e0c088ff12909e8d130fdcd8d6126 (patch)
treeb811f6451f4f87e9d058c8ca84947df9ff7be6d7 /lib
parent0ecdbedbf95125e358298fd9cc502560a74c0c4a (diff)
parent390cde0afc76172c114ec7802f5a70283766682f (diff)
Merge pull request #10024 from ton31337/feature/match_ipv6_next-hop_access-list
bgpd: match ipv6 next-hop
Diffstat (limited to 'lib')
-rw-r--r--lib/routemap.c16
-rw-r--r--lib/routemap.h27
-rw-r--r--lib/routemap_cli.c5
-rw-r--r--lib/routemap_northbound.c10
4 files changed, 54 insertions, 4 deletions
diff --git a/lib/routemap.c b/lib/routemap.c
index 09da095af4..c4651f39a4 100644
--- a/lib/routemap.c
+++ b/lib/routemap.c
@@ -175,6 +175,22 @@ void route_map_no_match_ip_next_hop_hook(int (*func)(
rmap_match_set_hook.no_match_ip_next_hop = func;
}
+/* match ipv6 next-hop */
+void route_map_match_ipv6_next_hop_hook(int (*func)(
+ struct route_map_index *index, const char *command, const char *arg,
+ route_map_event_t type, char *errmsg, size_t errmsg_len))
+{
+ rmap_match_set_hook.match_ipv6_next_hop = func;
+}
+
+/* no match ipv6 next-hop */
+void route_map_no_match_ipv6_next_hop_hook(int (*func)(
+ struct route_map_index *index, const char *command, const char *arg,
+ route_map_event_t type, char *errmsg, size_t errmsg_len))
+{
+ rmap_match_set_hook.no_match_ipv6_next_hop = func;
+}
+
/* match ip next hop prefix list */
void route_map_match_ip_next_hop_prefix_list_hook(int (*func)(
struct route_map_index *index, const char *command,
diff --git a/lib/routemap.h b/lib/routemap.h
index 7e17e14fa6..675f89ba92 100644
--- a/lib/routemap.h
+++ b/lib/routemap.h
@@ -244,6 +244,8 @@ DECLARE_QOBJ_TYPE(route_map);
(strmatch(C, "frr-route-map:ipv6-address-list"))
#define IS_MATCH_IPv4_NEXTHOP_LIST(C) \
(strmatch(C, "frr-route-map:ipv4-next-hop-list"))
+#define IS_MATCH_IPv6_NEXTHOP_LIST(C) \
+ (strmatch(C, "frr-route-map:ipv6-next-hop-list"))
#define IS_MATCH_IPv4_PREFIX_LIST(C) \
(strmatch(C, "frr-route-map:ipv4-prefix-list"))
#define IS_MATCH_IPv6_PREFIX_LIST(C) \
@@ -555,9 +557,16 @@ extern void route_map_match_ip_next_hop_hook(int (*func)(
char *errmsg, size_t errmsg_len));
/* no match ip next hop */
extern void route_map_no_match_ip_next_hop_hook(int (*func)(
- struct route_map_index *index, const char *command,
- const char *arg, route_map_event_t type,
- char *errmsg, size_t errmsg_len));
+ struct route_map_index *index, const char *command, const char *arg,
+ route_map_event_t type, char *errmsg, size_t errmsg_len));
+/* match ipv6 next hop */
+extern void route_map_match_ipv6_next_hop_hook(int (*func)(
+ struct route_map_index *index, const char *command, const char *arg,
+ route_map_event_t type, char *errmsg, size_t errmsg_len));
+/* no match ipv6 next hop */
+extern void route_map_no_match_ipv6_next_hop_hook(int (*func)(
+ struct route_map_index *index, const char *command, const char *arg,
+ route_map_event_t type, char *errmsg, size_t errmsg_len));
/* match ip next hop prefix list */
extern void route_map_match_ip_next_hop_prefix_list_hook(int (*func)(
struct route_map_index *index, const char *command,
@@ -743,6 +752,18 @@ struct route_map_match_set_hooks {
route_map_event_t type,
char *errmsg, size_t errmsg_len);
+ /* match ipv6 next hop */
+ int (*match_ipv6_next_hop)(struct route_map_index *index,
+ const char *command, const char *arg,
+ route_map_event_t type, char *errmsg,
+ size_t errmsg_len);
+
+ /* no match ipv6 next hop */
+ int (*no_match_ipv6_next_hop)(struct route_map_index *index,
+ const char *command, const char *arg,
+ route_map_event_t type, char *errmsg,
+ size_t errmsg_len);
+
/* match ip next hop prefix list */
int (*match_ip_next_hop_prefix_list)(struct route_map_index *index,
const char *command,
diff --git a/lib/routemap_cli.c b/lib/routemap_cli.c
index f85be05f5e..e26e3a6d2d 100644
--- a/lib/routemap_cli.c
+++ b/lib/routemap_cli.c
@@ -551,6 +551,7 @@ void route_map_condition_show(struct vty *vty, const struct lyd_node *dnode,
yang_dnode_get_string(
dnode, "./rmap-match-condition/interface"));
} else if (IS_MATCH_IPv4_ADDRESS_LIST(condition)
+ || IS_MATCH_IPv6_NEXTHOP_LIST(condition)
|| IS_MATCH_IPv4_NEXTHOP_LIST(condition)) {
acl = NULL;
if ((ln = yang_dnode_get(dnode,
@@ -562,8 +563,10 @@ void route_map_condition_show(struct vty *vty, const struct lyd_node *dnode,
if (IS_MATCH_IPv4_ADDRESS_LIST(condition))
vty_out(vty, " match ip address %s\n", acl);
- else
+ else if (IS_MATCH_IPv4_NEXTHOP_LIST(condition))
vty_out(vty, " match ip next-hop %s\n", acl);
+ else
+ vty_out(vty, " match ipv6 next-hop %s\n", acl);
} else if (IS_MATCH_IPv4_PREFIX_LIST(condition)) {
vty_out(vty, " match ip address prefix-list %s\n",
yang_dnode_get_string(
diff --git a/lib/routemap_northbound.c b/lib/routemap_northbound.c
index 3473ca2aea..7f7bc9f9c4 100644
--- a/lib/routemap_northbound.c
+++ b/lib/routemap_northbound.c
@@ -601,6 +601,16 @@ static int lib_route_map_entry_match_condition_list_name_modify(
rhc->rhc_rmi, "ip next-hop", acl,
RMAP_EVENT_FILTER_ADDED,
args->errmsg, args->errmsg_len);
+ } else if (IS_MATCH_IPv6_NEXTHOP_LIST(condition)) {
+ if (rmap_match_set_hook.match_ipv6_next_hop == NULL)
+ return NB_OK;
+ rhc->rhc_mhook = rmap_match_set_hook.no_match_ipv6_next_hop;
+ rhc->rhc_rule = "ipv6 next-hop";
+ rhc->rhc_event = RMAP_EVENT_FILTER_DELETED;
+ rv = rmap_match_set_hook.match_ipv6_next_hop(
+ rhc->rhc_rmi, "ipv6 next-hop", acl,
+ RMAP_EVENT_FILTER_ADDED, args->errmsg,
+ args->errmsg_len);
} else if (IS_MATCH_IPv4_NEXTHOP_PREFIX_LIST(condition)) {
if (rmap_match_set_hook.match_ip_next_hop_prefix_list == NULL)
return NB_OK;