sharpd: allow sharpd to install non-recursive routes

Add a config option so that sharpd can install routes without
the ALLOW_RECURSION flag, matching IGP behavior.
The default remains 'recursion'.

Signed-off-by: Mark Stapp <mjs@labn.net>
This commit is contained in:
Mark Stapp 2023-06-28 15:31:23 -04:00
parent bb58cad150
commit 89ff272d38
2 changed files with 9 additions and 4 deletions

View file

@ -179,7 +179,7 @@ DEFPY (install_routes,
<nexthop <A.B.C.D$nexthop4|X:X::X:X$nexthop6>|\ <nexthop <A.B.C.D$nexthop4|X:X::X:X$nexthop6>|\
nexthop-group NHGNAME$nexthop_group>\ nexthop-group NHGNAME$nexthop_group>\
[backup$backup <A.B.C.D$backup_nexthop4|X:X::X:X$backup_nexthop6>] \ [backup$backup <A.B.C.D$backup_nexthop4|X:X::X:X$backup_nexthop6>] \
(1-1000000)$routes [instance (0-255)$instance] [repeat (2-1000)$rpt] [opaque WORD]", (1-1000000)$routes [instance (0-255)$instance] [repeat (2-1000)$rpt] [opaque WORD] [no-recurse$norecurse]",
"Sharp routing Protocol\n" "Sharp routing Protocol\n"
"install some routes\n" "install some routes\n"
"Routes to install\n" "Routes to install\n"
@ -201,7 +201,8 @@ DEFPY (install_routes,
"Should we repeat this command\n" "Should we repeat this command\n"
"How many times to repeat this command\n" "How many times to repeat this command\n"
"What opaque data to send down\n" "What opaque data to send down\n"
"The opaque data\n") "The opaque data\n"
"No recursive nexthops\n")
{ {
struct vrf *vrf; struct vrf *vrf;
struct prefix prefix; struct prefix prefix;
@ -210,6 +211,7 @@ DEFPY (install_routes,
sg.r.total_routes = routes; sg.r.total_routes = routes;
sg.r.installed_routes = 0; sg.r.installed_routes = 0;
sg.r.flags = 0;
if (rpt >= 2) if (rpt >= 2)
sg.r.repeat = rpt * 2; sg.r.repeat = rpt * 2;
@ -317,12 +319,16 @@ DEFPY (install_routes,
else else
sg.r.opaque[0] = '\0'; sg.r.opaque[0] = '\0';
/* Default is to ask for recursive nexthop resolution */
if (norecurse == NULL)
SET_FLAG(sg.r.flags, ZEBRA_FLAG_ALLOW_RECURSION);
sg.r.inst = instance; sg.r.inst = instance;
sg.r.vrf_id = vrf->vrf_id; sg.r.vrf_id = vrf->vrf_id;
rts = routes; rts = routes;
sharp_install_routes_helper(&prefix, sg.r.vrf_id, sg.r.inst, nhgid, sharp_install_routes_helper(&prefix, sg.r.vrf_id, sg.r.inst, nhgid,
&sg.r.nhop_group, &sg.r.backup_nhop_group, &sg.r.nhop_group, &sg.r.backup_nhop_group,
rts, 0, sg.r.opaque); rts, sg.r.flags, sg.r.opaque);
return CMD_SUCCESS; return CMD_SUCCESS;
} }

View file

@ -247,7 +247,6 @@ static bool route_add(const struct prefix *p, vrf_id_t vrf_id, uint8_t instance,
memcpy(&api.prefix, p, sizeof(*p)); memcpy(&api.prefix, p, sizeof(*p));
api.flags = flags; api.flags = flags;
SET_FLAG(api.flags, ZEBRA_FLAG_ALLOW_RECURSION);
SET_FLAG(api.message, ZAPI_MESSAGE_NEXTHOP); SET_FLAG(api.message, ZAPI_MESSAGE_NEXTHOP);
/* Only send via ID if nhgroup has been successfully installed */ /* Only send via ID if nhgroup has been successfully installed */