diff options
| author | Donald Sharp <sharpd@cumulusnetwroks.com> | 2016-09-02 10:43:26 -0400 |
|---|---|---|
| committer | Donald Sharp <sharpd@cumulusnetworks.com> | 2016-12-21 20:26:08 -0500 |
| commit | 84a35fdf064bc0881e23354f10e605433e6e65da (patch) | |
| tree | 4bee10380940fe21caf8836a4cb643e7810f6b12 | |
| parent | 21391ed8d887a4c5967e73f50018b9433e717a83 (diff) | |
pimd: Fix duplicate code in zlookup
In the nexthop lookup routine, fix the duplicate code
to not check for too many indexes earlier.
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
| -rw-r--r-- | pimd/pim_zlookup.c | 25 |
1 files changed, 8 insertions, 17 deletions
diff --git a/pimd/pim_zlookup.c b/pimd/pim_zlookup.c index aed2a8a2c9..7234790fab 100644 --- a/pimd/pim_zlookup.c +++ b/pimd/pim_zlookup.c @@ -230,18 +230,17 @@ static int zclient_read_nexthop(struct zclient *zlookup, nexthop_type = stream_getc(s); --length; - + if (num_ifindex >= tab_size) { + char addr_str[100]; + pim_inet4_dump("<addr?>", addr, addr_str, sizeof(addr_str)); + zlog_warn("%s %s: found too many nexthop ifindexes (%d > %d) for address %s", + __FILE__, __PRETTY_FUNCTION__, + (num_ifindex + 1), tab_size, addr_str); + return num_ifindex; + } switch (nexthop_type) { case NEXTHOP_TYPE_IFINDEX: case NEXTHOP_TYPE_IPV4_IFINDEX: - if (num_ifindex >= tab_size) { - char addr_str[100]; - pim_inet4_dump("<addr?>", addr, addr_str, sizeof(addr_str)); - zlog_warn("%s %s: found too many nexthop ifindexes (%d > %d) for address %s", - __FILE__, __PRETTY_FUNCTION__, - (num_ifindex + 1), tab_size, addr_str); - return num_ifindex; - } if (nexthop_type == NEXTHOP_TYPE_IPV4_IFINDEX) { if (length < 4) { zlog_err("%s: socket %d short input expecting nexthop IPv4-addr: len=%d", @@ -260,14 +259,6 @@ static int zclient_read_nexthop(struct zclient *zlookup, ++num_ifindex; break; case NEXTHOP_TYPE_IPV4: - if (num_ifindex >= tab_size) { - char addr_str[100]; - pim_inet4_dump("<addr?>", addr, addr_str, sizeof(addr_str)); - zlog_warn("%s %s: found too many nexthop ifindexes (%d > %d) for address %s", - __FILE__, __PRETTY_FUNCTION__, - (num_ifindex + 1), tab_size, addr_str); - return num_ifindex; - } nexthop_tab[num_ifindex].nexthop_addr.s_addr = stream_get_ipv4(s); length -= 4; nexthop_tab[num_ifindex].ifindex = 0; |
