diff options
| author | Renato Westphal <renato@opensourcerouting.org> | 2017-07-27 18:57:37 -0300 |
|---|---|---|
| committer | Renato Westphal <renato@opensourcerouting.org> | 2017-07-27 23:46:41 -0300 |
| commit | 599186ad970b50d689f719dbb8cf527df0089d01 (patch) | |
| tree | 2fc42b310f167e0e12f77849858047088c988afd /zebra/zebra_static.c | |
| parent | c6cef20ba9d317792a9742c3efb728f4aa766dad (diff) | |
zebra: allow fully specified static ipv4 routes
Fully specified routes are useful when you need to ensure that the
nexthop address is reachable through the specified interface.
Addresses Issue #641.
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
Diffstat (limited to 'zebra/zebra_static.c')
| -rw-r--r-- | zebra/zebra_static.c | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/zebra/zebra_static.c b/zebra/zebra_static.c index ae32395161..6cebae997c 100644 --- a/zebra/zebra_static.c +++ b/zebra/zebra_static.c @@ -81,6 +81,10 @@ void static_install_route(afi_t afi, safi_t safi, struct prefix *p, nh_p.u.prefix4 = si->addr.ipv4; zebra_register_rnh_static_nh(si->vrf_id, &nh_p, rn); break; + case STATIC_IPV4_GATEWAY_IFINDEX: + nexthop = route_entry_nexthop_ipv4_ifindex_add( + re, &si->addr.ipv4, NULL, si->ifindex); + break; case STATIC_IFINDEX: nexthop = route_entry_nexthop_ifindex_add(re, si->ifindex); @@ -152,6 +156,10 @@ void static_install_route(afi_t afi, safi_t safi, struct prefix *p, nh_p.u.prefix4 = si->addr.ipv4; zebra_register_rnh_static_nh(si->vrf_id, &nh_p, rn); break; + case STATIC_IPV4_GATEWAY_IFINDEX: + nexthop = route_entry_nexthop_ipv4_ifindex_add( + re, &si->addr.ipv4, NULL, si->ifindex); + break; case STATIC_IFINDEX: nexthop = route_entry_nexthop_ifindex_add(re, si->ifindex); @@ -216,6 +224,11 @@ static int static_nexthop_same(struct nexthop *nexthop, struct static_route *si) && si->type == STATIC_IPV4_GATEWAY && IPV4_ADDR_SAME(&nexthop->gate.ipv4, &si->addr.ipv4)) return 1; + else if (nexthop->type == NEXTHOP_TYPE_IPV4_IFINDEX + && si->type == STATIC_IPV4_GATEWAY_IFINDEX + && IPV4_ADDR_SAME(&nexthop->gate.ipv4, &si->addr.ipv4) + && nexthop->ifindex == si->ifindex) + return 1; else if (nexthop->type == NEXTHOP_TYPE_IFINDEX && si->type == STATIC_IFINDEX && nexthop->ifindex == si->ifindex) @@ -361,12 +374,17 @@ int static_add_route(afi_t afi, safi_t safi, u_char type, struct prefix *p, if (!stable) return -1; - if (!gate && (type == STATIC_IPV4_GATEWAY || type == STATIC_IPV6_GATEWAY - || type == STATIC_IPV6_GATEWAY_IFINDEX)) + if (!gate + && (type == STATIC_IPV4_GATEWAY + || type == STATIC_IPV4_GATEWAY_IFINDEX + || type == STATIC_IPV6_GATEWAY + || type == STATIC_IPV6_GATEWAY_IFINDEX)) return -1; if (!ifindex - && (type == STATIC_IFINDEX || type == STATIC_IPV6_GATEWAY_IFINDEX)) + && (type == STATIC_IFINDEX + || type == STATIC_IPV4_GATEWAY_IFINDEX + || type == STATIC_IPV6_GATEWAY_IFINDEX)) return -1; /* Lookup static route prefix. */ @@ -411,11 +429,10 @@ int static_add_route(afi_t afi, safi_t safi, u_char type, struct prefix *p, switch (type) { case STATIC_IPV4_GATEWAY: + case STATIC_IPV4_GATEWAY_IFINDEX: si->addr.ipv4 = gate->ipv4; break; case STATIC_IPV6_GATEWAY: - si->addr.ipv6 = gate->ipv6; - break; case STATIC_IPV6_GATEWAY_IFINDEX: si->addr.ipv6 = gate->ipv6; break; |
