diff options
author | Renato Westphal <renato@opensourcerouting.org> | 2019-02-14 23:00:14 +0100 |
---|---|---|
committer | Renato Westphal <renato@opensourcerouting.org> | 2019-02-14 23:01:30 +0100 |
commit | b43bb64f82f599ec9fec0cb89bd2dd05cb54ab87 (patch) | |
tree | aa47676d1c26ea943dc1752f579b9ad109ad13f6 /lib/nexthop_group.c | |
parent | lib: consolidate nexthop-group deletion in a single place (diff) | |
download | frr-b43bb64f82f599ec9fec0cb89bd2dd05cb54ab87.tar.xz frr-b43bb64f82f599ec9fec0cb89bd2dd05cb54ab87.zip |
lib: change how nexthop groups store nexthop addresses
Use a pointer to a sockunion instead of a full sockunion in the
nexthop_hold structure. This prepares the ground for the next commit,
which will make nexthop addresses optional (in this commit we assume
nh->addr will never be NULL, but this will change).
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
Diffstat (limited to 'lib/nexthop_group.c')
-rw-r--r-- | lib/nexthop_group.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/lib/nexthop_group.c b/lib/nexthop_group.c index 57609b648..4c35d7c96 100644 --- a/lib/nexthop_group.c +++ b/lib/nexthop_group.c @@ -192,7 +192,7 @@ static int nhgl_cmp(struct nexthop_hold *nh1, struct nexthop_hold *nh2) { int ret; - ret = sockunion_cmp(&nh1->addr, &nh2->addr); + ret = sockunion_cmp(nh1->addr, nh2->addr); if (ret) return ret; @@ -211,6 +211,8 @@ static void nhgl_delete(struct nexthop_hold *nh) if (nh->nhvrf_name) XFREE(MTYPE_TMP, nh->nhvrf_name); + sockunion_free(nh->addr); + XFREE(MTYPE_TMP, nh); } @@ -295,7 +297,7 @@ static void nexthop_group_save_nhop(struct nexthop_group_cmd *nhgc, if (intf) nh->intf = XSTRDUP(MTYPE_TMP, intf); - nh->addr = *addr; + nh->addr = sockunion_dup(addr); listnode_add_sort(nhgc->nhg_list, nh); } @@ -310,7 +312,7 @@ static void nexthop_group_unsave_nhop(struct nexthop_group_cmd *nhgc, for (ALL_LIST_ELEMENTS_RO(nhgc->nhg_list, node, nh)) { if (nhgc_cmp_helper(nhvrf_name, nh->nhvrf_name) == 0 && - sockunion_cmp(addr, &nh->addr) == 0 && + sockunion_cmp(addr, nh->addr) == 0 && nhgc_cmp_helper(intf, nh->intf) == 0) break; } @@ -478,7 +480,7 @@ static void nexthop_group_write_nexthop_internal(struct vty *vty, vty_out(vty, "nexthop "); - vty_out(vty, "%s", sockunion2str(&nh->addr, buf, sizeof(buf))); + vty_out(vty, "%s", sockunion2str(nh->addr, buf, sizeof(buf))); if (nh->intf) vty_out(vty, " %s", nh->intf); @@ -522,7 +524,7 @@ void nexthop_group_enable_vrf(struct vrf *vrf) struct nexthop nhop; struct nexthop *nh; - if (!nexthop_group_parse_nexthop(&nhop, &nhh->addr, + if (!nexthop_group_parse_nexthop(&nhop, nhh->addr, nhh->intf, nhh->nhvrf_name)) continue; @@ -558,7 +560,7 @@ void nexthop_group_disable_vrf(struct vrf *vrf) struct nexthop nhop; struct nexthop *nh; - if (!nexthop_group_parse_nexthop(&nhop, &nhh->addr, + if (!nexthop_group_parse_nexthop(&nhop, nhh->addr, nhh->intf, nhh->nhvrf_name)) continue; @@ -596,7 +598,7 @@ void nexthop_group_interface_state_change(struct interface *ifp, struct nexthop nhop; if (!nexthop_group_parse_nexthop( - &nhop, &nhh->addr, nhh->intf, + &nhop, nhh->addr, nhh->intf, nhh->nhvrf_name)) continue; |