summaryrefslogtreecommitdiffstats
path: root/ripngd
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@cumulusnetworks.com>2020-03-22 04:37:24 +0100
committerDonald Sharp <sharpd@cumulusnetworks.com>2020-03-24 12:51:41 +0100
commit26a3ffd60e437e66a0762c4f399eebf19ad84a4a (patch)
treef95029ad2fb8347f4d2171320eacfffb5af6e484 /ripngd
parentbgpd: Rework code to use `const struct prefix` (diff)
downloadfrr-26a3ffd60e437e66a0762c4f399eebf19ad84a4a.tar.xz
frr-26a3ffd60e437e66a0762c4f399eebf19ad84a4a.zip
bgpd, lib, ripngd: Add agg_node_get_prefix
Modify code to use lookup function agg_node_get_prefix() as the abstraction layer. When we rework bgp_node to bgp_dest this will allow us to greatly limit the amount of work needed to do that. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Diffstat (limited to 'ripngd')
-rw-r--r--ripngd/ripng_interface.c9
-rw-r--r--ripngd/ripng_nb_state.c5
-rw-r--r--ripngd/ripng_zebra.c18
-rw-r--r--ripngd/ripngd.c30
4 files changed, 25 insertions, 37 deletions
diff --git a/ripngd/ripng_interface.c b/ripngd/ripng_interface.c
index 6a30c07d9..25d9ed2b9 100644
--- a/ripngd/ripng_interface.c
+++ b/ripngd/ripng_interface.c
@@ -867,17 +867,12 @@ int ripng_network_write(struct vty *vty, struct ripng *ripng)
unsigned int i;
const char *ifname;
struct agg_node *node;
- char buf[BUFSIZ];
/* Write enable network. */
for (node = agg_route_top(ripng->enable_network); node;
node = agg_route_next(node))
- if (node->info) {
- struct prefix *p = &node->p;
- vty_out(vty, " %s/%d\n",
- inet_ntop(p->family, &p->u.prefix, buf, BUFSIZ),
- p->prefixlen);
- }
+ if (node->info)
+ vty_out(vty, " %pRN\n", node);
/* Write enable interface. */
for (i = 0; i < vector_active(ripng->enable_if); i++)
diff --git a/ripngd/ripng_nb_state.c b/ripngd/ripng_nb_state.c
index 167077ea2..75dec3cb3 100644
--- a/ripngd/ripng_nb_state.c
+++ b/ripngd/ripng_nb_state.c
@@ -158,7 +158,8 @@ int ripngd_instance_state_routes_route_get_keys(const void *list_entry,
const struct agg_node *rn = list_entry;
keys->num = 1;
- (void)prefix2str(&rn->p, keys->key[0], sizeof(keys->key[0]));
+ (void)prefix2str(agg_node_get_prefix(rn), keys->key[0],
+ sizeof(keys->key[0]));
return NB_OK;
}
@@ -191,7 +192,7 @@ ripngd_instance_state_routes_route_prefix_get_elem(const char *xpath,
const struct agg_node *rn = list_entry;
const struct ripng_info *rinfo = listnode_head(rn->info);
- return yang_data_new_ipv6p(xpath, &rinfo->rp->p);
+ return yang_data_new_ipv6p(xpath, agg_node_get_prefix(rinfo->rp));
}
/*
diff --git a/ripngd/ripng_zebra.c b/ripngd/ripng_zebra.c
index f9bd56d1d..baf7f0096 100644
--- a/ripngd/ripng_zebra.c
+++ b/ripngd/ripng_zebra.c
@@ -46,12 +46,13 @@ static void ripng_zebra_ipv6_send(struct ripng *ripng, struct agg_node *rp,
struct listnode *listnode = NULL;
struct ripng_info *rinfo = NULL;
int count = 0;
+ const struct prefix *p = agg_node_get_prefix(rp);
memset(&api, 0, sizeof(api));
api.vrf_id = ripng->vrf->vrf_id;
api.type = ZEBRA_ROUTE_RIPNG;
api.safi = SAFI_UNICAST;
- api.prefix = rp->p;
+ api.prefix = *p;
SET_FLAG(api.message, ZAPI_MESSAGE_NEXTHOP);
for (ALL_LIST_ELEMENTS_RO(list, listnode, rinfo)) {
@@ -85,18 +86,17 @@ static void ripng_zebra_ipv6_send(struct ripng *ripng, struct agg_node *rp,
if (IS_RIPNG_DEBUG_ZEBRA) {
if (ripng->ecmp)
- zlog_debug("%s: %s/%d nexthops %d",
+ zlog_debug("%s: %pRN nexthops %d",
(cmd == ZEBRA_ROUTE_ADD)
? "Install into zebra"
: "Delete from zebra",
- inet6_ntoa(rp->p.u.prefix6), rp->p.prefixlen,
- count);
+ rp, count);
else
- zlog_debug(
- "%s: %s/%d",
- (cmd == ZEBRA_ROUTE_ADD) ? "Install into zebra"
- : "Delete from zebra",
- inet6_ntoa(rp->p.u.prefix6), rp->p.prefixlen);
+ zlog_debug("%s: %pRN",
+ (cmd == ZEBRA_ROUTE_ADD)
+ ? "Install into zebra"
+ : "Delete from zebra",
+ rp);
}
}
diff --git a/ripngd/ripngd.c b/ripngd/ripngd.c
index bb33abdb2..1ea006abd 100644
--- a/ripngd/ripngd.c
+++ b/ripngd/ripngd.c
@@ -1087,7 +1087,8 @@ void ripng_redistribute_withdraw(struct ripng *ripng, int type)
if (IS_RIPNG_DEBUG_EVENT) {
struct prefix_ipv6 *p =
- (struct prefix_ipv6 *)&rp->p;
+ (struct prefix_ipv6 *)
+ agg_node_get_prefix(rp);
zlog_debug(
"Poisone %s/%d on the interface %s [withdraw]",
@@ -1619,7 +1620,7 @@ void ripng_output_process(struct interface *ifp, struct sockaddr_in6 *to,
* following
* information.
*/
- p = (struct prefix_ipv6 *)&rp->p;
+ p = (struct prefix_ipv6 *)agg_node_get_prefix(rp);
rinfo->metric_out = rinfo->metric;
rinfo->tag_out = rinfo->tag;
memset(&rinfo->nexthop_out, 0,
@@ -1761,7 +1762,7 @@ void ripng_output_process(struct interface *ifp, struct sockaddr_in6 *to,
* following
* information.
*/
- p = (struct prefix_ipv6 *)&rp->p;
+ p = (struct prefix_ipv6 *)agg_node_get_prefix(rp);
aggregate->metric_set = 0;
aggregate->metric_out = aggregate->metric;
aggregate->tag_out = aggregate->tag;
@@ -2053,7 +2054,6 @@ DEFUN (show_ipv6_ripng,
struct agg_node *rp;
struct ripng_info *rinfo;
struct ripng_aggregate *aggregate;
- struct prefix_ipv6 *p;
struct list *list = NULL;
struct listnode *listnode = NULL;
int len;
@@ -2085,15 +2085,11 @@ DEFUN (show_ipv6_ripng,
for (rp = agg_route_top(ripng->table); rp; rp = agg_route_next(rp)) {
if ((aggregate = rp->aggregate) != NULL) {
- p = (struct prefix_ipv6 *)&rp->p;
-
#ifdef DEBUG
- vty_out(vty, "R(a) %d/%d %s/%d ", aggregate->count,
- aggregate->suppress, inet6_ntoa(p->prefix),
- p->prefixlen);
+ vty_out(vty, "R(a) %d/%d %pRN ", aggregate->count,
+ aggregate->suppress, rp);
#else
- vty_out(vty, "R(a) %s/%d ", inet6_ntoa(p->prefix),
- p->prefixlen);
+ vty_out(vty, "R(a) %pRN ", rp);
#endif /* DEBUG */
vty_out(vty, "\n");
vty_out(vty, "%*s", 18, " ");
@@ -2105,19 +2101,15 @@ DEFUN (show_ipv6_ripng,
if ((list = rp->info) != NULL)
for (ALL_LIST_ELEMENTS_RO(list, listnode, rinfo)) {
- p = (struct prefix_ipv6 *)&rp->p;
-
#ifdef DEBUG
- vty_out(vty, "%c(%s) 0/%d %s/%d ",
+ vty_out(vty, "%c(%s) 0/%d %pRN ",
zebra_route_char(rinfo->type),
ripng_route_subtype_print(rinfo),
- rinfo->suppress, inet6_ntoa(p->prefix),
- p->prefixlen);
+ rinfo->suppress, rp);
#else
- vty_out(vty, "%c(%s) %s/%d ",
+ vty_out(vty, "%c(%s) %pRN ",
zebra_route_char(rinfo->type),
- ripng_route_subtype_print(rinfo),
- inet6_ntoa(p->prefix), p->prefixlen);
+ ripng_route_subtype_print(rinfo), rp);
#endif /* DEBUG */
vty_out(vty, "\n");
vty_out(vty, "%*s", 18, " ");