]> git.puffer.fish Git - mirror/frr.git/commitdiff
bgpd: Allow NULL to be passed in for ecommunity_free
authorDonald Sharp <sharpd@nvidia.com>
Mon, 2 Nov 2020 16:20:32 +0000 (11:20 -0500)
committerDonald Sharp <sharpd@nvidia.com>
Sun, 15 Nov 2020 14:39:25 +0000 (09:39 -0500)
Allow some cleanup of if statements to just make
ecommunity_free() check this.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
bgpd/bgp_attr.c
bgpd/bgp_ecommunity.c
bgpd/bgp_ecommunity.h

index b94e24e870b2029146c9c80beb5a93658237224b..a804968605bc4aca1e75ef68f1ca36f265ea9664 100644 (file)
@@ -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);
index de3757aebb3f6c6ab4d0ca97fcfd5f0cf10d8718..74cbf3a80a9d9b8e0961889db5be94a5fb8b0006 100644 (file)
@@ -327,6 +327,9 @@ void ecommunity_unintern(struct ecommunity **ecom)
 {
        struct ecommunity *ret;
 
+       if (!*ecom)
+               return;
+
        if ((*ecom)->refcnt)
                (*ecom)->refcnt--;
 
index e9c52287f1e52e5c4b5880b6a8cf4c18c280caf9..6318e7edb1e3081994048a72636ad8aed9de662d 100644 (file)
@@ -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,