diff options
| author | Donald Sharp <sharpd@cumulusnetworks.com> | 2019-09-11 13:35:32 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-09-11 13:35:32 -0400 |
| commit | fa0ebe5a8a27fde0ecaf9f52c6621368c785ad8c (patch) | |
| tree | 9c431baf7a953e5caa567362b833a7c6970213b4 /staticd/static_zebra.c | |
| parent | e25352de4a340c42ab4b26959e5d63f24a7358c9 (diff) | |
| parent | b1ab2876fa8d02fbb84feafde8e321456409ec1a (diff) | |
Merge pull request #4302 from rgirada/fix_pim_upstream
staticd: static route config should get fail if nexthop configured as its local connected ip.
Diffstat (limited to 'staticd/static_zebra.c')
| -rw-r--r-- | staticd/static_zebra.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/staticd/static_zebra.c b/staticd/static_zebra.c index 27605da63f..1965c2968e 100644 --- a/staticd/static_zebra.c +++ b/staticd/static_zebra.c @@ -200,6 +200,25 @@ struct static_nht_data { uint8_t nh_num; }; +/* API to check whether the configured nexthop address is + * one of its local connected address or not. + */ +static bool +static_nexthop_is_local(vrf_id_t vrfid, struct prefix *addr, int family) +{ + if (family == AF_INET) { + if (if_lookup_exact_address(&addr->u.prefix4, + AF_INET, + vrfid)) + return true; + } else if (family == AF_INET6) { + if (if_lookup_exact_address(&addr->u.prefix6, + AF_INET6, + vrfid)) + return true; + } + return false; +} static int static_zebra_nexthop_update(ZAPI_CALLBACK_ARGS) { struct static_nht_data *nhtd, lookup; @@ -214,6 +233,12 @@ static int static_zebra_nexthop_update(ZAPI_CALLBACK_ARGS) if (nhr.prefix.family == AF_INET6) afi = AFI_IP6; + if (nhr.type == ZEBRA_ROUTE_CONNECT) { + if (static_nexthop_is_local(vrf_id, &nhr.prefix, + nhr.prefix.family)) + nhr.nexthop_num = 0; + } + memset(&lookup, 0, sizeof(lookup)); lookup.nh = &nhr.prefix; lookup.nh_vrf_id = vrf_id; |
