Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zebra: (test)Fix NHLFE entry memory leaks #12

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions isisd/isis_sr.c
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,69 @@ static int sr_local_block_release_label(struct sr_local_block *srlb,
return 0;
}

static bool sr_adj_same_subnet_ipv4(struct in_addr ipv4, struct isis_circuit *circuit)
{
struct listnode *node;
struct prefix_ipv4 *ipv4_adj, *ipv4_circuit;
bool is_same = false;

ipv4_adj = prefix_ipv4_new();
if (!ipv4_adj)
return false;

for (ALL_LIST_ELEMENTS_RO(circuit->ip_addrs, node, ipv4_circuit)) {
ipv4_adj->prefix = ipv4;
ipv4_adj->prefixlen = ipv4_circuit->prefixlen;
if (!prefix_cmp((struct prefix *)ipv4_adj,
(struct prefix *)ipv4_circuit)) {
is_same = true;
break;
}
}

prefix_ipv4_free(&ipv4_adj);

return is_same;
}

static bool sr_adj_same_subnet_ipv6(struct in6_addr *ipv6, struct isis_circuit *circuit)
{
struct listnode *node;
struct prefix_ipv6 *ipv6_adj, *ipv6_circuit;
bool is_same = false;

ipv6_adj = prefix_ipv6_new();
if (!ipv6_adj)
return false;

for (ALL_LIST_ELEMENTS_RO(circuit->ipv6_link, node, ipv6_circuit)) {
IPV6_ADDR_COPY(&ipv6_adj->prefix, ipv6);
ipv6_adj->prefixlen = ipv6_circuit->prefixlen;
if (!prefix_cmp((struct prefix *)ipv6_adj,
(struct prefix *)ipv6_circuit)) {
is_same = true;
break;
}
}

if (is_same)
goto done;

for (ALL_LIST_ELEMENTS_RO(circuit->ipv6_non_link, node, ipv6_circuit)) {
IPV6_ADDR_COPY(&ipv6_adj->prefix, ipv6);
ipv6_adj->prefixlen = ipv6_circuit->prefixlen;
if (!prefix_cmp((struct prefix *)ipv6_adj,
(struct prefix *)ipv6_circuit)) {
is_same = true;
break;
}
}

done:
prefix_ipv6_free(&ipv6_adj);
return is_same;
}

/* --- Segment Routing Adjacency-SID management functions ------------------- */

/**
Expand Down Expand Up @@ -658,12 +721,18 @@ void sr_adj_sid_add_single(struct isis_adjacency *adj, int family, bool backup,
if (!circuit->ip_router || !adj->ipv4_address_count)
return;

if (!sr_adj_same_subnet_ipv4(adj->ipv4_addresses[0], circuit))
return;

nexthop.ipv4 = adj->ipv4_addresses[0];
break;
case AF_INET6:
if (!circuit->ipv6_router || !adj->ll_ipv6_count)
return;

if (!sr_adj_same_subnet_ipv6(&adj->ll_ipv6_addrs[0], circuit))
return;

nexthop.ipv6 = adj->ll_ipv6_addrs[0];
break;
default:
Expand Down
Loading