X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=pimd%2Fpim_zlookup.c;h=6b45313081d9fa75d111bbeba764a16c423d2b25;hb=91d227b7e3cb53ad8fdbcd9d4cff7f0a666918e3;hp=37e2bfbbfd7d7eb5f39a39989791b13a8d29d08c;hpb=ce7b915214a726dd0cdbc59e2c9790ca0bb12be0;p=mirror_frr.git diff --git a/pimd/pim_zlookup.c b/pimd/pim_zlookup.c index 37e2bfbbf..6b4531308 100644 --- a/pimd/pim_zlookup.c +++ b/pimd/pim_zlookup.c @@ -18,7 +18,6 @@ */ #include -#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,24 +219,31 @@ 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); + /* + * Connected route (i.e. no nexthop), use + * address passed in as PIM nexthop. This will + * allow us to work in cases where we are + * trying to find a route for this box. + */ + nexthop_tab[num_ifindex].nexthop_addr.family = AF_INET; + nexthop_tab[num_ifindex].nexthop_addr.prefixlen = + IPV4_MAX_BITLEN; + nexthop_tab[num_ifindex].nexthop_addr.u.prefix4 = + addr; + ++num_ifindex; + break; case NEXTHOP_TYPE_IPV4_IFINDEX: case NEXTHOP_TYPE_IPV4: nexthop_tab[num_ifindex].nexthop_addr.family = AF_INET; - if (nexthop_type == NEXTHOP_TYPE_IPV4_IFINDEX - || nexthop_type == NEXTHOP_TYPE_IPV4) { - nexthop_tab[num_ifindex] - .nexthop_addr.u.prefix4.s_addr = - stream_get_ipv4(s); - } else { - nexthop_tab[num_ifindex] - .nexthop_addr.u.prefix4.s_addr = - PIM_NET_INADDR_ANY; - } + nexthop_tab[num_ifindex].nexthop_addr.u.prefix4.s_addr = + stream_get_ipv4(s); nexthop_tab[num_ifindex].ifindex = stream_getl(s); - nexthop_tab[num_ifindex].protocol_distance = distance; - nexthop_tab[num_ifindex].route_metric = metric; ++num_ifindex; break; case NEXTHOP_TYPE_IPV6_IFINDEX: @@ -257,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; @@ -306,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; @@ -327,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; } @@ -503,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; @@ -522,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; @@ -538,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);