Skip to content

Commit

Permalink
bgpd: Free epvn_overlay memory on error
Browse files Browse the repository at this point in the history
When parsing EVPN NLRIs, and an error occurred, do no forget to free the memory.

Fixes: 4ace11d ("bgpd: Move evpn_overlay to a pointer")

Signed-off-by: Donatas Abraitis <[email protected]>
  • Loading branch information
ton31337 committed Aug 24, 2024
1 parent 72dfd5a commit 7ce9e3e
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion bgpd/bgp_attr.c
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ static void *evpn_overlay_hash_alloc(void *p)
return p;
}

static void evpn_overlay_free(struct bgp_route_evpn *bre)
void evpn_overlay_free(struct bgp_route_evpn *bre)
{
XFREE(MTYPE_BGP_EVPN_OVERLAY, bre);
}
Expand Down
1 change: 1 addition & 0 deletions bgpd/bgp_attr.h
Original file line number Diff line number Diff line change
Expand Up @@ -646,5 +646,6 @@ bgp_attr_set_vnc_subtlvs(struct attr *attr,
}

extern bool route_matches_soo(struct bgp_path_info *pi, struct ecommunity *soo);
extern void evpn_overlay_free(struct bgp_route_evpn *bre);

#endif /* _QUAGGA_BGP_ATTR_H */
2 changes: 2 additions & 0 deletions bgpd/bgp_evpn.c
Original file line number Diff line number Diff line change
Expand Up @@ -4921,6 +4921,7 @@ static int process_type5_route(struct peer *peer, afi_t afi, safi_t safi,
flog_err(EC_BGP_EVPN_ROUTE_INVALID,
"%u:%s - Rx EVPN Type-5 NLRI with invalid length %d",
peer->bgp->vrf_id, peer->host, psize);
evpn_overlay_free(evpn);
return -1;
}

Expand Down Expand Up @@ -4953,6 +4954,7 @@ static int process_type5_route(struct peer *peer, afi_t afi, safi_t safi,
EC_BGP_EVPN_ROUTE_INVALID,
"%u:%s - Rx EVPN Type-5 NLRI with invalid IP Prefix length %d",
peer->bgp->vrf_id, peer->host, ippfx_len);
evpn_overlay_free(evpn);
return -1;
}
p.prefix.prefix_addr.ip_prefix_length = ippfx_len;
Expand Down

0 comments on commit 7ce9e3e

Please sign in to comment.