diff options
| author | Donald Sharp <sharpd@cumulusnetworks.com> | 2015-05-19 17:47:24 -0700 |
|---|---|---|
| committer | Donald Sharp <sharpd@cumulusnetworks.com> | 2015-05-19 17:47:24 -0700 |
| commit | c52ef59fedc4ce81afc842990980c8384d6dfce3 (patch) | |
| tree | 116d33d4320e53fc8d96ee5b5893fd7b98c04c8f /zebra/zebra_rib.c | |
| parent | b5d58c32bb74cf2fa0aa43a07396b06765d54ac0 (diff) | |
zebra-set-src-routemap.patch
Honor setting source via route map and pushing that to the kernel.
With recursive routes, the ability to set the source IP address of a route
via a routemap has been broken. This patch fixes that.
To allow route map to set a source and then to unapply the route map and
have the source be taken out, I've introduced a new field in the nexthop
data structure called rmap_src. This field is zero'd before invoking the
route map apply function.
Today, no protocol daemon specifies the src in its route update to zebra.
If that happens, I didn't want to stomp on it and so have left the src
field intact instead of reusing that for the routemap to play with.
Signed-off-by: Dinesh G Dutt <ddutt@cumulusnetworks.com>
Diffstat (limited to 'zebra/zebra_rib.c')
| -rw-r--r-- | zebra/zebra_rib.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c index a9f31b1a06..cd9f7005cc 100644 --- a/zebra/zebra_rib.c +++ b/zebra/zebra_rib.c @@ -1184,6 +1184,9 @@ nexthop_active_check (struct route_node *rn, struct rib *rib, if (!family) family = info->afi; + memset(&nexthop->rmap_src.ipv6, 0, sizeof(union g_addr)); + /* It'll get set if required inside */ + ret = zebra_route_map_check(family, rib->type, &rn->p, nexthop); if (ret == RMAP_DENYMATCH) { @@ -1195,6 +1198,7 @@ nexthop_active_check (struct route_node *rn, struct rib *rib, } UNSET_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE); } + return CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE); } @@ -1211,6 +1215,7 @@ static int nexthop_active_update (struct route_node *rn, struct rib *rib, int set) { struct nexthop *nexthop; + union g_addr prev_src; unsigned int prev_active, prev_index, new_active, old_num_nh; old_num_nh = rib->nexthop_active_num; @@ -1220,12 +1225,18 @@ nexthop_active_update (struct route_node *rn, struct rib *rib, int set) for (nexthop = rib->nexthop; nexthop; nexthop = nexthop->next) { + /* No protocol daemon provides src and so we're skipping tracking it */ + prev_src = nexthop->rmap_src; prev_active = CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE); prev_index = nexthop->ifindex; if ((new_active = nexthop_active_check (rn, rib, nexthop, set))) rib->nexthop_active_num++; + /* Don't allow src setting on IPv6 addr for now */ if (prev_active != new_active || - prev_index != nexthop->ifindex) + prev_index != nexthop->ifindex || + ((nexthop->type >= NEXTHOP_TYPE_IFINDEX && + nexthop->type < NEXTHOP_TYPE_IPV6) && + prev_src.ipv4.s_addr != nexthop->rmap_src.ipv4.s_addr)) { SET_FLAG (rib->flags, ZEBRA_FLAG_CHANGED); SET_FLAG (rib->status, RIB_ENTRY_NEXTHOPS_CHANGED); |
