]> git.proxmox.com Git - mirror_frr.git/blobdiff - bgpd/bgp_clist.c
zebra: fix logging of MPLS labels
[mirror_frr.git] / bgpd / bgp_clist.c
index 13587b35993ad2cc00370243a057ba6b2509bb8c..f3bae9535cc92b12200a6cddec2c3f2ac67f0239 100644 (file)
@@ -25,6 +25,7 @@
 #include "memory.h"
 #include "queue.h"
 #include "filter.h"
+#include "stream.h"
 
 #include "bgpd/bgpd.h"
 #include "bgpd/bgp_community.h"
@@ -355,6 +356,9 @@ static char *community_str_get(struct community *com, int i)
        case COMMUNITY_LOCAL_AS:
                len = strlen(" local-AS");
                break;
+       case COMMUNITY_GSHUT:
+               len = strlen(" graceful-shutdown");
+               break;
        default:
                len = strlen(" 65536:65535");
                break;
@@ -380,6 +384,10 @@ static char *community_str_get(struct community *com, int i)
                strcpy(pnt, "local-AS");
                pnt += strlen("local-AS");
                break;
+       case COMMUNITY_GSHUT:
+               strcpy(pnt, "graceful-shutdown");
+               pnt += strlen("graceful-shutdown");
+               break;
        default:
                as = (comval >> 16) & 0xFFFF;
                val = comval & 0xFFFF;
@@ -450,8 +458,7 @@ static char *lcommunity_str_get(struct lcommunity *lcom, int i)
        u_char *ptr;
        char *pnt;
 
-       ptr = lcom->val;
-       ptr += (i * LCOMMUNITY_SIZE);
+       ptr = lcom->val + (i * LCOMMUNITY_SIZE);
 
        memcpy(&lcomval, ptr, LCOMMUNITY_SIZE);
 
@@ -459,20 +466,10 @@ static char *lcommunity_str_get(struct lcommunity *lcom, int i)
        str = pnt = XMALLOC(MTYPE_LCOMMUNITY_STR, 48);
 
        ptr = (u_char *)lcomval.val;
-       globaladmin = (*ptr++ << 24);
-       globaladmin |= (*ptr++ << 16);
-       globaladmin |= (*ptr++ << 8);
-       globaladmin |= (*ptr++);
-
-       localdata1 = (*ptr++ << 24);
-       localdata1 |= (*ptr++ << 16);
-       localdata1 |= (*ptr++ << 8);
-       localdata1 |= (*ptr++);
-
-       localdata2 = (*ptr++ << 24);
-       localdata2 |= (*ptr++ << 16);
-       localdata2 |= (*ptr++ << 8);
-       localdata2 |= (*ptr++);
+       ptr = ptr_get_be32(ptr, &globaladmin);
+       ptr = ptr_get_be32(ptr, &localdata1);
+       ptr = ptr_get_be32(ptr, &localdata2);
+       (void)ptr; /* consume value */
 
        sprintf(pnt, "%u:%u:%u", globaladmin, localdata1, localdata2);
        pnt += strlen(pnt);
@@ -704,8 +701,7 @@ struct community *community_list_match_delete(struct community *com,
 
        /* Loop over each community value and evaluate each against the
         * community-list.  If we need to delete a community value add its index
-        * to
-        * com_index_to_delete.
+        * to com_index_to_delete.
         */
        for (i = 0; i < com->size; i++) {
                val = community_val_get(com, i);
@@ -906,12 +902,10 @@ struct lcommunity *lcommunity_list_match_delete(struct lcommunity *lcom,
 
        /* Loop over each lcommunity value and evaluate each against the
         * community-list.  If we need to delete a community value add its index
-        * to
-        * com_index_to_delete.
+        * to com_index_to_delete.
         */
-       ptr = lcom->val;
        for (i = 0; i < lcom->size; i++) {
-               ptr += (i * LCOMMUNITY_SIZE);
+               ptr = lcom->val + (i * LCOMMUNITY_SIZE);
                for (entry = list->head; entry; entry = entry->next) {
                        if (entry->any) {
                                if (entry->direct == COMMUNITY_PERMIT) {
@@ -930,7 +924,7 @@ struct lcommunity *lcommunity_list_match_delete(struct lcommunity *lcom,
                                break;
                        }
 
-                       else if ((entry->style == LARGE_COMMUNITY_LIST_STANDARD)
+                       else if ((entry->style == LARGE_COMMUNITY_LIST_EXPANDED)
                                 && lcommunity_regexp_include(entry->reg, lcom,
                                                              i)) {
                                if (entry->direct == COMMUNITY_PERMIT) {
@@ -943,9 +937,8 @@ struct lcommunity *lcommunity_list_match_delete(struct lcommunity *lcom,
        }
 
        /* Delete all of the communities we flagged for deletion */
-       ptr = lcom->val;
        for (i = delete_index - 1; i >= 0; i--) {
-               ptr += (com_index_to_delete[i] * LCOMMUNITY_SIZE);
+               ptr = lcom->val + (com_index_to_delete[i] * LCOMMUNITY_SIZE);
                lcommunity_del_val(lcom, ptr);
        }