+// SPDX-License-Identifier: GPL-2.0-or-later
/*
* Copyright (C) 2003 Yasuhiro Ohara
- *
- * This file is part of GNU Zebra.
- *
- * GNU Zebra is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2, or (at your option) any
- * later version.
- *
- * GNU Zebra is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; see the file COPYING; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <zebra.h>
zserv_command_string(command), &prefix,
ospf6->vrf_id);
- if (zclient_send_rnh(zclient, command, &prefix, false, true,
- ospf6->vrf_id)
+ if (zclient_send_rnh(zclient, command, &prefix, SAFI_UNICAST, false,
+ true, ospf6->vrf_id)
== ZCLIENT_SEND_FAILURE)
flog_err(EC_LIB_ZAPI_SOCKET, "%s: zclient_send_rnh() failed",
__func__);
if (!zclient || zclient->sock < 0 || !ospf6)
return 1;
- memset(&api, 0, sizeof(struct zapi_cap));
+ memset(&api, 0, sizeof(api));
api.cap = command;
api.stale_removal_time = stale_time;
api.vrf_id = ospf6->vrf_id;
}
/* If removing is the best path and if there's another path,
- treat this request as add the secondary path */
- if (type == REM && ospf6_route_is_best(request) && request->next
- && ospf6_route_is_same(request, request->next)) {
+ * treat this request as add the secondary path - if there are
+ * nexthops.
+ */
+ if (type == REM && ospf6_route_is_best(request) && request->next &&
+ ospf6_route_is_same(request, request->next) &&
+ ospf6_route_num_nexthops(request->next) > 0) {
if (IS_OSPF6_DEBUG_ZEBRA(SEND))
zlog_debug(
" Best-path removal resulted Secondary addition");
nhcount = ospf6_route_num_nexthops(request);
if (nhcount == 0) {
- if (IS_OSPF6_DEBUG_ZEBRA(SEND))
- zlog_debug(" No nexthop, ignore");
- return;
+ if (type == ADD) {
+ if (IS_OSPF6_DEBUG_ZEBRA(SEND))
+ zlog_debug(" No nexthop, ignore");
+ return;
+ } else if (IS_OSPF6_DEBUG_ZEBRA(SEND))
+ zlog_debug(" No nexthop, rem ok");
}
dest = &request->prefix;
api.type = ZEBRA_ROUTE_OSPF6;
api.safi = SAFI_UNICAST;
api.prefix = *dest;
- SET_FLAG(api.message, ZAPI_MESSAGE_NEXTHOP);
if (nhcount > ospf6->max_multipath) {
if (IS_OSPF6_DEBUG_ZEBRA(SEND))
zlog_debug(
" Nexthop count is greater than configured maximum-path, hence ignore the extra nexthops");
}
+
api.nexthop_num = MIN(nhcount, ospf6->max_multipath);
+ if (api.nexthop_num > 0) {
+ SET_FLAG(api.message, ZAPI_MESSAGE_NEXTHOP);
+ ospf6_route_zebra_copy_nexthops(request, api.nexthops,
+ api.nexthop_num, api.vrf_id);
+ }
- ospf6_route_zebra_copy_nexthops(request, api.nexthops, api.nexthop_num,
- api.vrf_id);
SET_FLAG(api.message, ZAPI_MESSAGE_METRIC);
api.metric = (request->path.metric_type == 2 ? request->path.u.cost_e2
: request->path.cost);