]> git.proxmox.com Git - mirror_frr.git/blobdiff - pimd/pim_zlookup.c
zebra, lib: fix the ZEBRA_INTERFACE_VRF_UPDATE zapi message
[mirror_frr.git] / pimd / pim_zlookup.c
index 9295b231cb0236ac97cc7428f1d20c32b150d8d2..6b45313081d9fa75d111bbeba764a16c423d2b25 100644 (file)
@@ -18,7 +18,6 @@
  */
 
 #include <zebra.h>
-#include "zebra/rib.h"
 
 #include "log.h"
 #include "prefix.h"
@@ -28,6 +27,7 @@
 #include "thread.h"
 #include "prefix.h"
 #include "vty.h"
+#include "lib_errors.h"
 
 #include "pimd.h"
 #include "pim_iface.h"
@@ -120,9 +120,10 @@ void zclient_lookup_free(void)
 
 void zclient_lookup_new(void)
 {
-       zlookup = zclient_new_notify(master, &zclient_options_default);
+       zlookup = zclient_new(master, &zclient_options_default);
        if (!zlookup) {
-               zlog_err("%s: zclient_new() failure", __PRETTY_FUNCTION__);
+               flog_err(EC_LIB_ZAPI_SOCKET, "%s: zclient_new() failure",
+                        __PRETTY_FUNCTION__);
                return;
        }
 
@@ -168,7 +169,8 @@ static int zclient_read_nexthop(struct pim_instance *pim,
                err = zclient_read_header(s, zlookup->sock, &length, &marker,
                                          &version, &vrf_id, &command);
                if (err < 0) {
-                       zlog_err("%s: zclient_read_header() failed",
+                       flog_err(EC_LIB_ZAPI_MISSMATCH,
+                                "%s: zclient_read_header() failed",
                                 __PRETTY_FUNCTION__);
                        zclient_lookup_failed(zlookup);
                        return -1;
@@ -200,10 +202,12 @@ static int zclient_read_nexthop(struct pim_instance *pim,
        }
 
        for (i = 0; i < nexthop_num; ++i) {
+               vrf_id_t nexthop_vrf_id;
                enum nexthop_types_t nexthop_type;
                struct pim_neighbor *nbr;
                struct prefix p;
 
+               nexthop_vrf_id = stream_getl(s);
                nexthop_type = stream_getc(s);
                if (num_ifindex >= tab_size) {
                        char addr_str[INET_ADDRSTRLEN];
@@ -215,6 +219,9 @@ static int zclient_read_nexthop(struct pim_instance *pim,
                                tab_size, addr_str, pim->vrf->name);
                        return num_ifindex;
                }
+               nexthop_tab[num_ifindex].protocol_distance = distance;
+               nexthop_tab[num_ifindex].route_metric = metric;
+               nexthop_tab[num_ifindex].vrf_id = nexthop_vrf_id;
                switch (nexthop_type) {
                case NEXTHOP_TYPE_IFINDEX:
                        nexthop_tab[num_ifindex].ifindex = stream_getl(s);
@@ -261,12 +268,12 @@ static int zclient_read_nexthop(struct pim_instance *pim,
                                        if_lookup_by_index(
                                                nexthop_tab[num_ifindex]
                                                        .ifindex,
-                                               vrf_id),
+                                               nexthop_vrf_id),
                                        &p);
                        else
                                nbr = pim_neighbor_find_if(if_lookup_by_index(
                                        nexthop_tab[num_ifindex].ifindex,
-                                       vrf_id));
+                                       nexthop_vrf_id));
                        if (nbr) {
                                nexthop_tab[num_ifindex].nexthop_addr.family =
                                        AF_INET;
@@ -276,13 +283,19 @@ static int zclient_read_nexthop(struct pim_instance *pim,
                        }
                        ++num_ifindex;
                        break;
-               case NEXTHOP_TYPE_IPV6:
-               case NEXTHOP_TYPE_BLACKHOLE:
-                       /* ignore */
-                       continue;
+               default:
+                       /* do nothing */
+                       {
+                               char addr_str[INET_ADDRSTRLEN];
+                               pim_inet4_dump("<addr?>", addr, addr_str,
+                                              sizeof(addr_str));
+                               zlog_warn(
+                                       "%s: found non-ifindex nexthop type=%d for address %s(%s)",
+                                       __PRETTY_FUNCTION__, nexthop_type,
+                                       addr_str, pim->vrf->name);
+                       }
+                       break;
                }
-               nexthop_tab[num_ifindex].protocol_distance = distance;
-               nexthop_tab[num_ifindex].route_metric = metric;
        }
 
        return num_ifindex;
@@ -304,14 +317,15 @@ static int zclient_lookup_nexthop_once(struct pim_instance *pim,
 
        /* Check socket. */
        if (zlookup->sock < 0) {
-               zlog_err("%s: zclient lookup socket is not connected",
+               flog_err(EC_LIB_ZAPI_SOCKET,
+                        "%s: zclient lookup socket is not connected",
                         __PRETTY_FUNCTION__);
                zclient_lookup_failed(zlookup);
                return -1;
        }
 
        if (pim->vrf->vrf_id == VRF_UNKNOWN) {
-               zlog_err(
+               zlog_notice(
                        "%s: VRF: %s does not fully exist yet, delaying lookup",
                        __PRETTY_FUNCTION__, pim->vrf->name);
                return -1;
@@ -325,15 +339,17 @@ static int zclient_lookup_nexthop_once(struct pim_instance *pim,
 
        ret = writen(zlookup->sock, s->data, stream_get_endp(s));
        if (ret < 0) {
-               zlog_err(
+               flog_err(
+                       EC_LIB_SOCKET,
                        "%s: writen() failure: %d writing to zclient lookup socket",
                        __PRETTY_FUNCTION__, errno);
                zclient_lookup_failed(zlookup);
                return -2;
        }
        if (ret == 0) {
-               zlog_err("%s: connection closed on zclient lookup socket",
-                        __PRETTY_FUNCTION__);
+               flog_err_sys(EC_LIB_SOCKET,
+                            "%s: connection closed on zclient lookup socket",
+                            __PRETTY_FUNCTION__);
                zclient_lookup_failed(zlookup);
                return -3;
        }
@@ -501,7 +517,8 @@ int pim_zlookup_sg_statistics(struct channel_oil *c_oil)
        count = stream_get_endp(s);
        ret = writen(zlookup->sock, s->data, count);
        if (ret <= 0) {
-               zlog_err(
+               flog_err(
+                       EC_LIB_SOCKET,
                        "%s: writen() failure: %d writing to zclient lookup socket",
                        __PRETTY_FUNCTION__, errno);
                return -1;
@@ -520,7 +537,8 @@ int pim_zlookup_sg_statistics(struct channel_oil *c_oil)
                err = zclient_read_header(s, zlookup->sock, &length, &marker,
                                          &version, &vrf_id, &command);
                if (err < 0) {
-                       zlog_err("%s: zclient_read_header() failed",
+                       flog_err(EC_LIB_ZAPI_MISSMATCH,
+                                "%s: zclient_read_header() failed",
                                 __PRETTY_FUNCTION__);
                        zclient_lookup_failed(zlookup);
                        return -1;
@@ -536,7 +554,8 @@ int pim_zlookup_sg_statistics(struct channel_oil *c_oil)
 
                        more.src = c_oil->oil.mfcc_origin;
                        more.grp = c_oil->oil.mfcc_mcastgrp;
-                       zlog_err(
+                       flog_err(
+                               EC_LIB_ZAPI_MISSMATCH,
                                "%s: Received wrong %s(%s) information requested",
                                __PRETTY_FUNCTION__, pim_str_sg_dump(&more),
                                c_oil->pim->vrf->name);