summaryrefslogtreecommitdiffstats
path: root/pimd
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@cumulusnetwroks.com>2016-09-02 16:43:26 +0200
committerDonald Sharp <sharpd@cumulusnetworks.com>2016-12-22 02:26:08 +0100
commit84a35fdf064bc0881e23354f10e605433e6e65da (patch)
tree4bee10380940fe21caf8836a4cb643e7810f6b12 /pimd
parentpimd: Allow interfaces to be unnumbered. (diff)
downloadfrr-84a35fdf064bc0881e23354f10e605433e6e65da.tar.xz
frr-84a35fdf064bc0881e23354f10e605433e6e65da.zip
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>
Diffstat (limited to 'pimd')
-rw-r--r--pimd/pim_zlookup.c25
1 files changed, 8 insertions, 17 deletions
diff --git a/pimd/pim_zlookup.c b/pimd/pim_zlookup.c
index aed2a8a2c..7234790fa 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;