From 78d3e257707a0d932f70486b436250487d58b8c9 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Tue, 31 May 2016 21:27:48 -0400 Subject: [PATCH] pimd: Allow command zclient to find it's data pim has two zclient sockets to zebra. One is used exclusively to do mrib lookups. The other is to do the normal day to day communication between pim and zebra. With the change to the zebra api to send up all data to all sockets this caused the mrib lookup socket to accumulate data in between mrib lookups. So if at some point in time we get upcoming data but no mrib lookups modify the code to find the mrib lookup it is looking for. Long term we need to figure something else out but this change will get us moving forward again. Signed-off-by: Donald Sharp Reviewed-by: Daniel Walton --- pimd/pim_zlookup.c | 53 ++++++++++++++++++++++------------------------ 1 file changed, 25 insertions(+), 28 deletions(-) diff --git a/pimd/pim_zlookup.c b/pimd/pim_zlookup.c index bec625ab56..aa2f7eb4cf 100644 --- a/pimd/pim_zlookup.c +++ b/pimd/pim_zlookup.c @@ -154,7 +154,7 @@ static int zclient_read_nexthop(struct zclient *zlookup, u_char marker; u_char version; vrf_id_t vrf_id; - uint16_t command; + uint16_t command = 0; struct in_addr raddr; uint8_t distance; uint32_t metric; @@ -170,36 +170,33 @@ static int zclient_read_nexthop(struct zclient *zlookup, } s = zlookup->ibuf; - stream_reset(s); - err = zclient_read_header (s, zlookup->sock, &length, &marker, &version, - &vrf_id, &command); - if (err < 0) { - zlog_err("%s %s: zclient_read_header() failed", - __FILE__, __PRETTY_FUNCTION__); - zclient_lookup_failed(zlookup); - return -1; - } + while (command != ZEBRA_IPV4_NEXTHOP_LOOKUP_MRIB) + { + stream_reset(s); + err = zclient_read_header (s, zlookup->sock, &length, &marker, &version, + &vrf_id, &command); + if (err < 0) { + zlog_err("%s %s: zclient_read_header() failed", + __FILE__, __PRETTY_FUNCTION__); + zclient_lookup_failed(zlookup); + return -1; + } - if (length < MIN_LEN) { - zlog_err("%s %s: failure reading zclient lookup socket: len=%d < MIN_LEN=%d", - __FILE__, __PRETTY_FUNCTION__, length, MIN_LEN); - zclient_lookup_failed(zlookup); - return -2; - } + if (length < MIN_LEN) { + zlog_err("%s %s: failure reading zclient lookup socket: len=%d < MIN_LEN=%d", + __FILE__, __PRETTY_FUNCTION__, length, MIN_LEN); + zclient_lookup_failed(zlookup); + return -2; + } - if (version != ZSERV_VERSION || marker != ZEBRA_HEADER_MARKER) { - zlog_err("%s: socket %d version mismatch, marker %d, version %d", - __func__, zlookup->sock, marker, version); - zclient_lookup_failed(zlookup); - return -4; - } - - if (command != ZEBRA_IPV4_NEXTHOP_LOOKUP_MRIB) { - zlog_err("%s: socket %d command mismatch: %d", - __func__, zlookup->sock, command); - return -5; - } + if (version != ZSERV_VERSION || marker != ZEBRA_HEADER_MARKER) { + zlog_err("%s: socket %d version mismatch, marker %d, version %d", + __func__, zlookup->sock, marker, version); + zclient_lookup_failed(zlookup); + return -4; + } + } raddr.s_addr = stream_get_ipv4(s); -- 2.39.5