diff options
Diffstat (limited to 'zebra/zebra_rib.c')
-rw-r--r-- | zebra/zebra_rib.c | 42 |
1 files changed, 30 insertions, 12 deletions
diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c index af04adaa4..7caa793f2 100644 --- a/zebra/zebra_rib.c +++ b/zebra/zebra_rib.c @@ -2303,6 +2303,10 @@ static_install_ipv4 (struct prefix *p, struct static_ipv4 *si) if (rib) { + /* if tag value changed , update old value in RIB */ + if (rib->tag != si->tag) + rib->tag = si->tag; + /* Same distance static route is there. Update it with new nexthop. */ route_unlock_node (rn); @@ -2330,6 +2334,7 @@ static_install_ipv4 (struct prefix *p, struct static_ipv4 *si) rib->metric = 0; rib->table = zebrad.rtm_table_default; rib->nexthop_num = 0; + rib->tag = si->tag; switch (si->type) { @@ -2393,7 +2398,8 @@ static_uninstall_ipv4 (struct prefix *p, struct static_ipv4 *si) if (CHECK_FLAG (rib->status, RIB_ENTRY_REMOVED)) continue; - if (rib->type == ZEBRA_ROUTE_STATIC && rib->distance == si->distance) + if (rib->type == ZEBRA_ROUTE_STATIC && rib->distance == si->distance && + rib->tag == si->tag) break; } @@ -2433,7 +2439,7 @@ static_uninstall_ipv4 (struct prefix *p, struct static_ipv4 *si) /* Add static route into static route configuration. */ int static_add_ipv4 (struct prefix *p, struct in_addr *gate, const char *ifname, - u_char flags, u_char distance, u_int32_t vrf_id) + u_char flags, u_short tag, u_char distance, u_int32_t vrf_id) { u_char type = 0; struct route_node *rn; @@ -2466,7 +2472,7 @@ static_add_ipv4 (struct prefix *p, struct in_addr *gate, const char *ifname, && (! gate || IPV4_ADDR_SAME (gate, &si->gate.ipv4)) && (! ifname || strcmp (ifname, si->gate.ifname) == 0)) { - if (distance == si->distance) + if ((distance == si->distance) && (tag == si->tag)) { route_unlock_node (rn); return 0; @@ -2476,9 +2482,9 @@ static_add_ipv4 (struct prefix *p, struct in_addr *gate, const char *ifname, } } - /* Distance changed. */ + /* Distance or tag changed. */ if (update) - static_delete_ipv4 (p, gate, ifname, update->distance, vrf_id); + static_delete_ipv4 (p, gate, ifname, update->tag, update->distance, vrf_id); /* Make new static route structure. */ si = XCALLOC (MTYPE_STATIC_IPV4, sizeof (struct static_ipv4)); @@ -2486,6 +2492,7 @@ static_add_ipv4 (struct prefix *p, struct in_addr *gate, const char *ifname, si->type = type; si->distance = distance; si->flags = flags; + si->tag = tag; if (gate) si->gate.ipv4 = *gate; @@ -2528,7 +2535,7 @@ static_add_ipv4 (struct prefix *p, struct in_addr *gate, const char *ifname, /* Delete static route from static route configuration. */ int static_delete_ipv4 (struct prefix *p, struct in_addr *gate, const char *ifname, - u_char distance, u_int32_t vrf_id) + u_short tag, u_char distance, u_int32_t vrf_id) { u_char type = 0; struct route_node *rn; @@ -2557,7 +2564,8 @@ static_delete_ipv4 (struct prefix *p, struct in_addr *gate, const char *ifname, for (si = rn->info; si; si = si->next) if (type == si->type && (! gate || IPV4_ADDR_SAME (gate, &si->gate.ipv4)) - && (! ifname || strcmp (ifname, si->gate.ifname) == 0)) + && (! ifname || strcmp (ifname, si->gate.ifname) == 0) + && (! tag || (tag == si->tag))) break; /* Can't find static route. */ @@ -2972,6 +2980,10 @@ static_install_ipv6 (struct prefix *p, struct static_ipv6 *si) if (rib) { + /* if tag value changed , update old value in RIB */ + if (rib->tag != si->tag) + rib->tag = si->tag; + /* Same distance static route is there. Update it with new nexthop. */ route_unlock_node (rn); @@ -3000,6 +3012,7 @@ static_install_ipv6 (struct prefix *p, struct static_ipv6 *si) rib->metric = 0; rib->table = zebrad.rtm_table_default; rib->nexthop_num = 0; + rib->tag = si->tag; switch (si->type) { @@ -3064,7 +3077,8 @@ static_uninstall_ipv6 (struct prefix *p, struct static_ipv6 *si) if (CHECK_FLAG (rib->status, RIB_ENTRY_REMOVED)) continue; - if (rib->type == ZEBRA_ROUTE_STATIC && rib->distance == si->distance) + if (rib->type == ZEBRA_ROUTE_STATIC && rib->distance == si->distance && + rib->tag == si->tag) break; } @@ -3106,8 +3120,8 @@ static_uninstall_ipv6 (struct prefix *p, struct static_ipv6 *si) /* Add static route into static route configuration. */ int static_add_ipv6 (struct prefix *p, u_char type, struct in6_addr *gate, - const char *ifname, u_char flags, u_char distance, - u_int32_t vrf_id) + const char *ifname, u_char flags, u_short tag, + u_char distance, u_int32_t vrf_id) { struct route_node *rn; struct static_ipv6 *si; @@ -3136,6 +3150,7 @@ static_add_ipv6 (struct prefix *p, u_char type, struct in6_addr *gate, { if (distance == si->distance && type == si->type + && tag == si->tag && (! gate || IPV6_ADDR_SAME (gate, &si->ipv6)) && (! ifname || strcmp (ifname, si->ifname) == 0)) { @@ -3150,6 +3165,7 @@ static_add_ipv6 (struct prefix *p, u_char type, struct in6_addr *gate, si->type = type; si->distance = distance; si->flags = flags; + si->tag = tag; switch (type) { @@ -3194,7 +3210,8 @@ static_add_ipv6 (struct prefix *p, u_char type, struct in6_addr *gate, /* Delete static route from static route configuration. */ int static_delete_ipv6 (struct prefix *p, u_char type, struct in6_addr *gate, - const char *ifname, u_char distance, u_int32_t vrf_id) + const char *ifname, u_short tag, u_char distance, + u_int32_t vrf_id) { struct route_node *rn; struct static_ipv6 *si; @@ -3215,7 +3232,8 @@ static_delete_ipv6 (struct prefix *p, u_char type, struct in6_addr *gate, if (distance == si->distance && type == si->type && (! gate || IPV6_ADDR_SAME (gate, &si->ipv6)) - && (! ifname || strcmp (ifname, si->ifname) == 0)) + && (! ifname || strcmp (ifname, si->ifname) == 0) + && (! tag || (tag == si->tag))) break; /* Can't find static route. */ |