diff options
| author | Donald Sharp <sharpd@nvidia.com> | 2020-11-02 11:20:32 -0500 |
|---|---|---|
| committer | Donald Sharp <sharpd@nvidia.com> | 2020-11-15 09:39:25 -0500 |
| commit | df7d4670ea9dd8aa35457abeb5827e074cca7514 (patch) | |
| tree | 871234aa0147e564247db7af2eab13a43fa81890 | |
| parent | cdb8f3e4789d4e8ce15256547cbca57114095295 (diff) | |
bgpd: Allow NULL to be passed in for ecommunity_free
Allow some cleanup of if statements to just make
ecommunity_free() check this.
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
| -rw-r--r-- | bgpd/bgp_attr.c | 8 | ||||
| -rw-r--r-- | bgpd/bgp_ecommunity.c | 3 | ||||
| -rw-r--r-- | bgpd/bgp_ecommunity.h | 2 |
3 files changed, 7 insertions, 6 deletions
diff --git a/bgpd/bgp_attr.c b/bgpd/bgp_attr.c index b94e24e870..a804968605 100644 --- a/bgpd/bgp_attr.c +++ b/bgpd/bgp_attr.c @@ -1045,12 +1045,10 @@ void bgp_attr_unintern_sub(struct attr *attr) community_unintern(&attr->community); UNSET_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_COMMUNITIES)); - if (attr->ecommunity) - ecommunity_unintern(&attr->ecommunity); + ecommunity_unintern(&attr->ecommunity); UNSET_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES)); - if (attr->ipv6_ecommunity) - ecommunity_unintern(&attr->ipv6_ecommunity); + ecommunity_unintern(&attr->ipv6_ecommunity); UNSET_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_IPV6_EXT_COMMUNITIES)); if (attr->lcommunity) @@ -1137,7 +1135,7 @@ void bgp_attr_flush(struct attr *attr) community_free(&attr->community); if (attr->ecommunity && !attr->ecommunity->refcnt) ecommunity_free(&attr->ecommunity); - if (attr->ipv6_ecommunity && !attr->ipv6_ecommunity->refcnt) + if (attr->ipv6_ecommunity && !attr->ecommunity->refcnt) ecommunity_free(&attr->ipv6_ecommunity); if (attr->lcommunity && !attr->lcommunity->refcnt) lcommunity_free(&attr->lcommunity); diff --git a/bgpd/bgp_ecommunity.c b/bgpd/bgp_ecommunity.c index de3757aebb..74cbf3a80a 100644 --- a/bgpd/bgp_ecommunity.c +++ b/bgpd/bgp_ecommunity.c @@ -327,6 +327,9 @@ void ecommunity_unintern(struct ecommunity **ecom) { struct ecommunity *ret; + if (!*ecom) + return; + if ((*ecom)->refcnt) (*ecom)->refcnt--; diff --git a/bgpd/bgp_ecommunity.h b/bgpd/bgp_ecommunity.h index e9c52287f1..6318e7edb1 100644 --- a/bgpd/bgp_ecommunity.h +++ b/bgpd/bgp_ecommunity.h @@ -227,7 +227,7 @@ extern struct ecommunity *ecommunity_merge(struct ecommunity *, extern struct ecommunity *ecommunity_uniq_sort(struct ecommunity *); extern struct ecommunity *ecommunity_intern(struct ecommunity *); extern bool ecommunity_cmp(const void *arg1, const void *arg2); -extern void ecommunity_unintern(struct ecommunity **); +extern void ecommunity_unintern(struct ecommunity **ecommunity); extern unsigned int ecommunity_hash_make(const void *); extern struct ecommunity *ecommunity_str2com(const char *, int, int); extern struct ecommunity *ecommunity_str2com_ipv6(const char *str, int type, |
