]> git.proxmox.com Git - mirror_frr.git/blobdiff - bgpd/bgp_zebra.c
Merge pull request #2804 from kssoman/bgp_fix
[mirror_frr.git] / bgpd / bgp_zebra.c
index 714f6791c14c2bed7ee435395817b42ef73900d5..f42c16c1c1d46a85d99fe9116f086e02ef0dfbb0 100644 (file)
@@ -44,6 +44,7 @@
 #include "bgpd/bgp_zebra.h"
 #include "bgpd/bgp_fsm.h"
 #include "bgpd/bgp_debug.h"
+#include "bgpd/bgp_errors.h"
 #include "bgpd/bgp_mpath.h"
 #include "bgpd/bgp_nexthop.h"
 #include "bgpd/bgp_nht.h"
@@ -1016,7 +1017,7 @@ static int bgp_zebra_tm_connect(struct thread *t)
                ret = tm_table_manager_connect(zclient);
        }
        if (ret < 0) {
-               zlog_warn("Error connecting to table manager!");
+               zlog_info("Error connecting to table manager!");
                bgp_tm_status_connected = false;
        } else {
                if (!bgp_tm_status_connected)
@@ -1077,7 +1078,8 @@ int bgp_zebra_get_table_range(uint32_t chunk_size,
                return -1;
        ret = tm_get_table_chunk(zclient, chunk_size, start, end);
        if (ret < 0) {
-               zlog_err("BGP: Error getting table chunk %u", chunk_size);
+               flog_err(BGP_ERR_TABLE_CHUNK,
+                         "BGP: Error getting table chunk %u", chunk_size);
                return -1;
        }
        zlog_info("BGP: Table Manager returns range from chunk %u is [%u %u]",
@@ -1574,8 +1576,14 @@ static void bgp_redist_del(struct bgp *bgp, afi_t afi, uint8_t type,
 
 /* Other routes redistribution into BGP. */
 int bgp_redistribute_set(struct bgp *bgp, afi_t afi, int type,
-                        unsigned short instance)
+                        unsigned short instance, bool changed)
 {
+       /* If redistribute options are changed call
+        * bgp_redistribute_unreg() to reset the option and withdraw
+        * the routes
+        */
+       if (changed)
+               bgp_redistribute_unreg(bgp, afi, type, instance);
 
        /* Return if already redistribute flag is set. */
        if (instance) {
@@ -1998,7 +2006,7 @@ static int ipset_notify_owner(int command, struct zclient *zclient,
        bgp_pbim = bgp_pbr_match_ipset_lookup(vrf_id, unique);
        if (!bgp_pbim) {
                if (BGP_DEBUG(zebra, ZEBRA))
-                       zlog_debug("%s: Fail to look BGP match ( %u %u)",
+                       zlog_debug("%s: Fail to look BGP match ( %u, ID %u)",
                                   __PRETTY_FUNCTION__, note, unique);
                return 0;
        }
@@ -2048,7 +2056,7 @@ static int ipset_entry_notify_owner(int command, struct zclient *zclient,
                                                     unique);
        if (!bgp_pbime) {
                if (BGP_DEBUG(zebra, ZEBRA))
-                       zlog_debug("%s: Fail to look BGP match entry (%u %u)",
+                       zlog_debug("%s: Fail to look BGP match entry (%u, ID %u)",
                                   __PRETTY_FUNCTION__, note, unique);
                return 0;
        }
@@ -2074,7 +2082,9 @@ static int ipset_entry_notify_owner(int command, struct zclient *zclient,
                        /* link bgp_info to bpme */
                        bgp_info = (struct bgp_info *)bgp_pbime->bgp_info;
                        extra = bgp_info_extra_get(bgp_info);
-                       extra->bgp_fs_pbr = (void *)bgp_pbime;
+                       if (extra->bgp_fs_pbr == NULL)
+                               extra->bgp_fs_pbr = list_new();
+                       listnode_add(extra->bgp_fs_pbr, bgp_pbime);
                }
                break;
        case ZAPI_IPSET_ENTRY_FAIL_REMOVE:
@@ -2379,9 +2389,10 @@ static int bgp_zebra_process_local_macip(int command, struct zclient *zclient,
        ipa_len = stream_getl(s);
        if (ipa_len != 0 && ipa_len != IPV4_MAX_BYTELEN
            && ipa_len != IPV6_MAX_BYTELEN) {
-               zlog_err("%u:Recv MACIP %s with invalid IP addr length %d",
-                        vrf_id, (command == ZEBRA_MACIP_ADD) ? "Add" : "Del",
-                        ipa_len);
+               flog_err(BGP_ERR_MACIP_LEN,
+                         "%u:Recv MACIP %s with invalid IP addr length %d",
+                         vrf_id, (command == ZEBRA_MACIP_ADD) ? "Add" : "Del",
+                         ipa_len);
                return -1;
        }
 
@@ -2471,11 +2482,13 @@ static void bgp_zebra_process_label_chunk(
        STREAM_GETL(s, last);
 
        if (zclient->redist_default != proto) {
-               zlog_err("Got LM msg with wrong proto %u", proto);
+               flog_err(BGP_ERR_LM_ERROR, "Got LM msg with wrong proto %u",
+                         proto);
                return;
        }
        if (zclient->instance != instance) {
-               zlog_err("Got LM msg with wrong instance %u", proto);
+               flog_err(BGP_ERR_LM_ERROR, "Got LM msg with wrong instance %u",
+                         proto);
                return;
        }
 
@@ -2483,8 +2496,8 @@ static void bgp_zebra_process_label_chunk(
                first < MPLS_LABEL_UNRESERVED_MIN ||
                last > MPLS_LABEL_UNRESERVED_MAX) {
 
-               zlog_err("%s: Invalid Label chunk: %u - %u",
-                       __func__, first, last);
+               flog_err(BGP_ERR_LM_ERROR, "%s: Invalid Label chunk: %u - %u",
+                         __func__, first, last);
                return;
        }
        if (BGP_DEBUG(zebra, ZEBRA)) {
@@ -2587,9 +2600,10 @@ void bgp_send_pbr_ipset_match(struct bgp_pbr_match *pbrim, bool install)
        if (pbrim->install_in_progress)
                return;
        if (BGP_DEBUG(zebra, ZEBRA))
-               zlog_debug("%s: name %s type %d %d",
+               zlog_debug("%s: name %s type %d %d, ID %u",
                           __PRETTY_FUNCTION__,
-                          pbrim->ipset_name, pbrim->type, install);
+                          pbrim->ipset_name, pbrim->type,
+                          install, pbrim->unique);
        s = zclient->obuf;
        stream_reset(s);
 
@@ -2615,9 +2629,9 @@ void bgp_send_pbr_ipset_entry_match(struct bgp_pbr_match_entry *pbrime,
        if (pbrime->install_in_progress)
                return;
        if (BGP_DEBUG(zebra, ZEBRA))
-               zlog_debug("%s: name %s %d %d", __PRETTY_FUNCTION__,
+               zlog_debug("%s: name %s %d %d, ID %u", __PRETTY_FUNCTION__,
                           pbrime->backpointer->ipset_name,
-                          pbrime->unique, install);
+                          pbrime->unique, install, pbrime->unique);
        s = zclient->obuf;
        stream_reset(s);
 
@@ -2682,9 +2696,10 @@ void bgp_send_pbr_iptable(struct bgp_pbr_action *pba,
        if (pbm->install_iptable_in_progress)
                return;
        if (BGP_DEBUG(zebra, ZEBRA))
-               zlog_debug("%s: name %s type %d mark %d %d",
+               zlog_debug("%s: name %s type %d mark %d %d, ID %u",
                           __PRETTY_FUNCTION__, pbm->ipset_name,
-                          pbm->type, pba->fwmark, install);
+                          pbm->type, pba->fwmark, install,
+                          pbm->unique2);
        s = zclient->obuf;
        stream_reset(s);