Merge pull request #10593 from donaldsharp/rip_cleanup

ripd: Cleanup ripd.c indentation levels and comments
This commit is contained in:
Russ White 2022-02-22 11:30:36 -05:00 committed by GitHub
commit af768d506f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -224,8 +224,10 @@ struct rip_info *rip_ecmp_replace(struct rip *rip, struct rip_info *rinfo_new)
rip_zebra_ipv4_delete(rip, rp); rip_zebra_ipv4_delete(rip, rp);
/* Re-use the first entry, and delete the others. */ /* Re-use the first entry, and delete the others. */
for (ALL_LIST_ELEMENTS(list, node, nextnode, tmp_rinfo)) for (ALL_LIST_ELEMENTS(list, node, nextnode, tmp_rinfo)) {
if (tmp_rinfo != rinfo) { if (tmp_rinfo == rinfo)
continue;
RIP_TIMER_OFF(tmp_rinfo->t_timeout); RIP_TIMER_OFF(tmp_rinfo->t_timeout);
RIP_TIMER_OFF(tmp_rinfo->t_garbage_collect); RIP_TIMER_OFF(tmp_rinfo->t_garbage_collect);
list_delete_node(list, node); list_delete_node(list, node);
@ -332,37 +334,33 @@ static int rip_filter(int rip_distribute, struct prefix_ipv4 *p,
const char *inout = rip_distribute == RIP_FILTER_OUT ? "out" : "in"; const char *inout = rip_distribute == RIP_FILTER_OUT ? "out" : "in";
/* Input distribute-list filtering. */ /* Input distribute-list filtering. */
if (ri->list[rip_distribute]) { if (ri->list[rip_distribute] &&
if (access_list_apply(ri->list[rip_distribute], access_list_apply(ri->list[rip_distribute], (struct prefix *)p) ==
(struct prefix *)p) FILTER_DENY) {
== FILTER_DENY) {
if (IS_RIP_DEBUG_PACKET) if (IS_RIP_DEBUG_PACKET)
zlog_debug("%pFX filtered by distribute %s", p, zlog_debug("%pFX filtered by distribute %s", p, inout);
inout);
return -1; return -1;
} }
}
if (ri->prefix[rip_distribute]) { if (ri->prefix[rip_distribute] &&
if (prefix_list_apply(ri->prefix[rip_distribute], prefix_list_apply(ri->prefix[rip_distribute], (struct prefix *)p) ==
(struct prefix *)p) PREFIX_DENY) {
== PREFIX_DENY) {
if (IS_RIP_DEBUG_PACKET) if (IS_RIP_DEBUG_PACKET)
zlog_debug("%pFX filtered by prefix-list %s", p, zlog_debug("%pFX filtered by prefix-list %s", p, inout);
inout);
return -1; return -1;
} }
}
/* All interface filter check. */ /* All interface filter check. */
dist = distribute_lookup(ri->rip->distribute_ctx, NULL); dist = distribute_lookup(ri->rip->distribute_ctx, NULL);
if (dist) { if (!dist)
return 0;
if (dist->list[distribute]) { if (dist->list[distribute]) {
alist = access_list_lookup(AFI_IP, alist = access_list_lookup(AFI_IP, dist->list[distribute]);
dist->list[distribute]);
if (alist) { if (alist) {
if (access_list_apply(alist, (struct prefix *)p) if (access_list_apply(alist, (struct prefix *)p) ==
== FILTER_DENY) { FILTER_DENY) {
if (IS_RIP_DEBUG_PACKET) if (IS_RIP_DEBUG_PACKET)
zlog_debug( zlog_debug(
"%pFX filtered by distribute %s", "%pFX filtered by distribute %s",
@ -372,12 +370,11 @@ static int rip_filter(int rip_distribute, struct prefix_ipv4 *p,
} }
} }
if (dist->prefix[distribute]) { if (dist->prefix[distribute]) {
plist = prefix_list_lookup(AFI_IP, plist = prefix_list_lookup(AFI_IP, dist->prefix[distribute]);
dist->prefix[distribute]);
if (plist) { if (plist) {
if (prefix_list_apply(plist, (struct prefix *)p) if (prefix_list_apply(plist, (struct prefix *)p) ==
== PREFIX_DENY) { PREFIX_DENY) {
if (IS_RIP_DEBUG_PACKET) if (IS_RIP_DEBUG_PACKET)
zlog_debug( zlog_debug(
"%pFX filtered by prefix-list %s", "%pFX filtered by prefix-list %s",
@ -386,7 +383,7 @@ static int rip_filter(int rip_distribute, struct prefix_ipv4 *p,
} }
} }
} }
}
return 0; return 0;
} }
@ -532,7 +529,9 @@ static void rip_rte_process(struct rte *rte, struct sockaddr_in *from,
&& IPV4_ADDR_SAME(&rinfo->nh.gate.ipv4, nexthop)) && IPV4_ADDR_SAME(&rinfo->nh.gate.ipv4, nexthop))
break; break;
if (!listnextnode(node)) { if (listnextnode(node))
continue;
/* Not found in the list */ /* Not found in the list */
if (rte->metric > rinfo->metric) { if (rte->metric > rinfo->metric) {
@ -550,8 +549,7 @@ static void rip_rte_process(struct rte *rte, struct sockaddr_in *from,
/* Metrics are same. We compare the distances. /* Metrics are same. We compare the distances.
*/ */
old_dist = rinfo->distance old_dist = rinfo->distance ? rinfo->distance
? rinfo->distance
: ZEBRA_RIP_DISTANCE_DEFAULT; : ZEBRA_RIP_DISTANCE_DEFAULT;
if (new_dist > old_dist) { if (new_dist > old_dist) {
@ -572,7 +570,6 @@ static void rip_rte_process(struct rte *rte, struct sockaddr_in *from,
* the new route is added in the ECMP list in * the new route is added in the ECMP list in
* below. */ * below. */
} }
}
if (rinfo) { if (rinfo) {
/* Local static route. */ /* Local static route. */
@ -1278,15 +1275,14 @@ static void rip_response_process(struct rip_packet *packet, int size,
} }
/* For RIPv1, there won't be a valid netmask. /* For RIPv1, there won't be a valid netmask.
* This is a best guess at the masks. If everyone was using old
This is a best guess at the masks. If everyone was using old * Ciscos before the 'ip subnet zero' option, it would be almost
Ciscos before the 'ip subnet zero' option, it would be almost * right too :-)
right too :-) *
* Cisco summarize ripv1 advertisements to the classful boundary
Cisco summarize ripv1 advertisements to the classful boundary * (/16 for class B's) except when the RIP packet does to inside
(/16 for class B's) except when the RIP packet does to inside * the classful network in question.
the classful network in question. */ */
if ((packet->version == RIPv1 if ((packet->version == RIPv1
&& rte->prefix.s_addr != INADDR_ANY) && rte->prefix.s_addr != INADDR_ANY)
|| (packet->version == RIPv2 || (packet->version == RIPv2
@ -1467,19 +1463,16 @@ static int rip_send_packet(uint8_t *buf, int size, struct sockaddr_in *to,
if (CHECK_FLAG(ifc->flags, ZEBRA_IFA_SECONDARY)) { if (CHECK_FLAG(ifc->flags, ZEBRA_IFA_SECONDARY)) {
/* /*
* ZEBRA_IFA_SECONDARY is set on linux when an interface is * ZEBRA_IFA_SECONDARY is set on linux when an interface is
* configured * configured with multiple addresses on the same
* with multiple addresses on the same subnet: the first address * subnet: the first address on the subnet is configured
* on the subnet is configured "primary", and all subsequent * "primary", and all subsequent addresses on that subnet
* addresses * are treated as "secondary" addresses. In order to avoid
* on that subnet are treated as "secondary" addresses. * routing-table bloat on other rip listeners, we do not send
* In order to avoid routing-table bloat on other rip listeners, * out RIP packets with ZEBRA_IFA_SECONDARY source addrs.
* we do not send out RIP packets with ZEBRA_IFA_SECONDARY
* source addrs.
* XXX Since Linux is the only system for which the * XXX Since Linux is the only system for which the
* ZEBRA_IFA_SECONDARY * ZEBRA_IFA_SECONDARY flag is set, we would end up
* flag is set, we would end up sending a packet for a * sending a packet for a "secondary" source address on
* "secondary" * non-linux systems.
* source address on non-linux systems.
*/ */
if (IS_RIP_DEBUG_PACKET) if (IS_RIP_DEBUG_PACKET)
zlog_debug("duplicate dropped"); zlog_debug("duplicate dropped");
@ -2123,15 +2116,21 @@ void rip_output_process(struct connected *ifc, struct sockaddr_in *to,
subnetted = 1; subnetted = 1;
} }
for (rp = route_top(rip->table); rp; rp = route_next(rp)) for (rp = route_top(rip->table); rp; rp = route_next(rp)) {
if ((list = rp->info) != NULL && listcount(list) != 0) { list = rp->info;
rinfo = listgetdata(listhead(list));
/* For RIPv1, if we are subnetted, output subnets in our
* network */
/* that have the same mask as the output "interface".
* For other */
/* networks, only the classfull version is output. */
if (list == NULL)
continue;
if (listcount(list) == 0)
continue;
rinfo = listgetdata(listhead(list));
/*
* For RIPv1, if we are subnetted, output subnets in our
* network that have the same mask as the output "interface".
* For other networks, only the classfull version is output.
*/
if (version == RIPv1) { if (version == RIPv1) {
p = (struct prefix_ipv4 *)&rp->p; p = (struct prefix_ipv4 *)&rp->p;
@ -2140,22 +2139,19 @@ void rip_output_process(struct connected *ifc, struct sockaddr_in *to,
"RIPv1 mask check, %pFX considered for output", "RIPv1 mask check, %pFX considered for output",
&rp->p); &rp->p);
if (subnetted if (subnetted &&
&& prefix_match( prefix_match((struct prefix *)&ifaddrclass,
(struct prefix *)&ifaddrclass,
&rp->p)) { &rp->p)) {
if ((ifc->address->prefixlen if ((ifc->address->prefixlen !=
!= rp->p.prefixlen) rp->p.prefixlen) &&
&& (rp->p.prefixlen (rp->p.prefixlen != IPV4_MAX_BITLEN))
!= IPV4_MAX_BITLEN))
continue; continue;
} else { } else {
memcpy(&classfull, &rp->p, memcpy(&classfull, &rp->p,
sizeof(struct prefix_ipv4)); sizeof(struct prefix_ipv4));
apply_classful_mask_ipv4(&classfull); apply_classful_mask_ipv4(&classfull);
if (rp->p.u.prefix4.s_addr != INADDR_ANY if (rp->p.u.prefix4.s_addr != INADDR_ANY &&
&& classfull.prefixlen classfull.prefixlen != rp->p.prefixlen)
!= rp->p.prefixlen)
continue; continue;
} }
if (IS_RIP_DEBUG_PACKET) if (IS_RIP_DEBUG_PACKET)
@ -2171,50 +2167,39 @@ void rip_output_process(struct connected *ifc, struct sockaddr_in *to,
continue; continue;
/* Changed route only output. */ /* Changed route only output. */
if (route_type == rip_changed_route if (route_type == rip_changed_route &&
&& (!(rinfo->flags & RIP_RTF_CHANGED))) (!(rinfo->flags & RIP_RTF_CHANGED)))
continue; continue;
/* Split horizon. */ /* Split horizon. */
/* if (split_horizon == rip_split_horizon) */
if (ri->split_horizon == RIP_SPLIT_HORIZON) { if (ri->split_horizon == RIP_SPLIT_HORIZON) {
/* /*
* We perform split horizon for RIP and * We perform split horizon for RIP and connected
* connected route. * route. For rip routes, we want to suppress the
* For rip routes, we want to suppress the route * route if we would end up sending the route back on
* if we would * the interface that we learned it from, with a
* end up sending the route back on the * higher metric. For connected routes, we suppress
* interface that we * the route if the prefix is a subset of the source
* learned it from, with a higher metric. For * address that we are going to use for the packet
* connected routes, * (in order to handle the case when multiple subnets
* we suppress the route if the prefix is a * are configured on the same interface).
* subset of the
* source address that we are going to use for
* the packet
* (in order to handle the case when multiple
* subnets are
* configured on the same interface).
*/ */
int suppress = 0; int suppress = 0;
struct rip_info *tmp_rinfo = NULL; struct rip_info *tmp_rinfo = NULL;
struct connected *tmp_ifc = NULL; struct connected *tmp_ifc = NULL;
for (ALL_LIST_ELEMENTS_RO(list, listnode, for (ALL_LIST_ELEMENTS_RO(list, listnode, tmp_rinfo))
tmp_rinfo)) if (tmp_rinfo->type == ZEBRA_ROUTE_RIP &&
if (tmp_rinfo->type == ZEBRA_ROUTE_RIP tmp_rinfo->nh.ifindex ==
&& tmp_rinfo->nh.ifindex ifc->ifp->ifindex) {
== ifc->ifp->ifindex) {
suppress = 1; suppress = 1;
break; break;
} }
if (!suppress if (!suppress && rinfo->type == ZEBRA_ROUTE_CONNECT) {
&& rinfo->type == ZEBRA_ROUTE_CONNECT) { for (ALL_LIST_ELEMENTS_RO(ifc->ifp->connected,
for (ALL_LIST_ELEMENTS_RO(
ifc->ifp->connected,
listnode, tmp_ifc)) listnode, tmp_ifc))
if (prefix_match( if (prefix_match((struct prefix *)p,
(struct prefix *)p,
tmp_ifc->address)) { tmp_ifc->address)) {
suppress = 1; suppress = 1;
break; break;
@ -2232,22 +2217,18 @@ void rip_output_process(struct connected *ifc, struct sockaddr_in *to,
rinfo->tag_out = rinfo->tag; rinfo->tag_out = rinfo->tag;
rinfo->ifindex_out = ifc->ifp->ifindex; rinfo->ifindex_out = ifc->ifp->ifindex;
/* In order to avoid some local loops, /* In order to avoid some local loops, if the RIP route has
* if the RIP route has a nexthop via this interface, * a nexthop via this interface, keep the nexthop, otherwise
* keep the nexthop, * set it to 0. The nexthop should not be propagated beyond
* otherwise set it to 0. The nexthop should not be * the local broadcast/multicast area in order to avoid an
* propagated * IGP multi-level recursive look-up. see (4.4)
* beyond the local broadcast/multicast area in order
* to avoid an IGP multi-level recursive look-up.
* see (4.4)
*/ */
if (rinfo->nh.ifindex == ifc->ifp->ifindex) if (rinfo->nh.ifindex == ifc->ifp->ifindex)
rinfo->nexthop_out = rinfo->nh.gate.ipv4; rinfo->nexthop_out = rinfo->nh.gate.ipv4;
/* Interface route-map */ /* Interface route-map */
if (ri->routemap[RIP_FILTER_OUT]) { if (ri->routemap[RIP_FILTER_OUT]) {
ret = route_map_apply( ret = route_map_apply(ri->routemap[RIP_FILTER_OUT],
ri->routemap[RIP_FILTER_OUT],
(struct prefix *)p, rinfo); (struct prefix *)p, rinfo);
if (ret == RMAP_DENYMATCH) { if (ret == RMAP_DENYMATCH) {
@ -2260,8 +2241,8 @@ void rip_output_process(struct connected *ifc, struct sockaddr_in *to,
} }
/* Apply redistribute route map - continue, if deny */ /* Apply redistribute route map - continue, if deny */
if (rip->redist[rinfo->type].route_map.name if (rip->redist[rinfo->type].route_map.name &&
&& rinfo->sub_type != RIP_ROUTE_INTERFACE) { rinfo->sub_type != RIP_ROUTE_INTERFACE) {
ret = route_map_apply( ret = route_map_apply(
rip->redist[rinfo->type].route_map.map, rip->redist[rinfo->type].route_map.map,
(struct prefix *)p, rinfo); (struct prefix *)p, rinfo);
@ -2278,21 +2259,18 @@ void rip_output_process(struct connected *ifc, struct sockaddr_in *to,
/* When route-map does not set metric. */ /* When route-map does not set metric. */
if (!rinfo->metric_set) { if (!rinfo->metric_set) {
/* If redistribute metric is set. */ /* If redistribute metric is set. */
if (rip->redist[rinfo->type].metric_config if (rip->redist[rinfo->type].metric_config &&
&& rinfo->metric != RIP_METRIC_INFINITY) { rinfo->metric != RIP_METRIC_INFINITY) {
rinfo->metric_out = rinfo->metric_out =
rip->redist[rinfo->type].metric; rip->redist[rinfo->type].metric;
} else { } else {
/* If the route is not connected or /* If the route is not connected or localy
localy generated * generated one, use default-metric value
one, use default-metric value*/ */
if (rinfo->type != ZEBRA_ROUTE_RIP if (rinfo->type != ZEBRA_ROUTE_RIP &&
&& rinfo->type rinfo->type != ZEBRA_ROUTE_CONNECT &&
!= ZEBRA_ROUTE_CONNECT rinfo->metric != RIP_METRIC_INFINITY)
&& rinfo->metric rinfo->metric_out = rip->default_metric;
!= RIP_METRIC_INFINITY)
rinfo->metric_out =
rip->default_metric;
} }
} }
@ -2307,43 +2285,31 @@ void rip_output_process(struct connected *ifc, struct sockaddr_in *to,
/* Perform split-horizon with poisoned reverse /* Perform split-horizon with poisoned reverse
* for RIP and connected routes. * for RIP and connected routes.
**/ **/
if (ri->split_horizon if (ri->split_horizon == RIP_SPLIT_HORIZON_POISONED_REVERSE) {
== RIP_SPLIT_HORIZON_POISONED_REVERSE) {
/* /*
* We perform split horizon for RIP and * We perform split horizon for RIP and connected
* connected route. * route. For rip routes, we want to suppress the
* For rip routes, we want to suppress the route * route if we would end up sending the route back
* if we would * on the interface that we learned it from, with a
* end up sending the route back on the * higher metric. For connected routes, we suppress
* interface that we * the route if the prefix is a subset of the source
* learned it from, with a higher metric. For * address that we are going to use for the packet
* connected routes,
* we suppress the route if the prefix is a
* subset of the
* source address that we are going to use for
* the packet
* (in order to handle the case when multiple * (in order to handle the case when multiple
* subnets are * subnets are configured on the same interface).
* configured on the same interface).
*/ */
struct rip_info *tmp_rinfo = NULL; struct rip_info *tmp_rinfo = NULL;
struct connected *tmp_ifc = NULL; struct connected *tmp_ifc = NULL;
for (ALL_LIST_ELEMENTS_RO(list, listnode, for (ALL_LIST_ELEMENTS_RO(list, listnode, tmp_rinfo))
tmp_rinfo)) if (tmp_rinfo->type == ZEBRA_ROUTE_RIP &&
if (tmp_rinfo->type == ZEBRA_ROUTE_RIP tmp_rinfo->nh.ifindex == ifc->ifp->ifindex)
&& tmp_rinfo->nh.ifindex rinfo->metric_out = RIP_METRIC_INFINITY;
== ifc->ifp->ifindex)
rinfo->metric_out =
RIP_METRIC_INFINITY;
if (rinfo->metric_out != RIP_METRIC_INFINITY if (rinfo->metric_out != RIP_METRIC_INFINITY &&
&& rinfo->type == ZEBRA_ROUTE_CONNECT) { rinfo->type == ZEBRA_ROUTE_CONNECT) {
for (ALL_LIST_ELEMENTS_RO( for (ALL_LIST_ELEMENTS_RO(ifc->ifp->connected,
ifc->ifp->connected,
listnode, tmp_ifc)) listnode, tmp_ifc))
if (prefix_match( if (prefix_match((struct prefix *)p,
(struct prefix *)p,
tmp_ifc->address)) { tmp_ifc->address)) {
rinfo->metric_out = rinfo->metric_out =
RIP_METRIC_INFINITY; RIP_METRIC_INFINITY;
@ -2359,8 +2325,8 @@ void rip_output_process(struct connected *ifc, struct sockaddr_in *to,
stream_putw(s, 0); stream_putw(s, 0);
/* auth header for !v1 && !no_auth */ /* auth header for !v1 && !no_auth */
if ((ri->auth_type != RIP_NO_AUTH) if ((ri->auth_type != RIP_NO_AUTH) &&
&& (version != RIPv1)) (version != RIPv1))
doff = rip_auth_header_write( doff = rip_auth_header_write(
s, ri, key, auth_str, s, ri, key, auth_str,
RIP_AUTH_SIMPLE_SIZE); RIP_AUTH_SIMPLE_SIZE);
@ -2369,20 +2335,17 @@ void rip_output_process(struct connected *ifc, struct sockaddr_in *to,
/* Write RTE to the stream. */ /* Write RTE to the stream. */
num = rip_write_rte(num, s, p, version, rinfo); num = rip_write_rte(num, s, p, version, rinfo);
if (num == rtemax) { if (num == rtemax) {
if (version == RIPv2 if (version == RIPv2 && ri->auth_type == RIP_AUTH_MD5)
&& ri->auth_type == RIP_AUTH_MD5)
rip_auth_md5_set(s, ri, doff, auth_str, rip_auth_md5_set(s, ri, doff, auth_str,
RIP_AUTH_SIMPLE_SIZE); RIP_AUTH_SIMPLE_SIZE);
ret = rip_send_packet(STREAM_DATA(s), ret = rip_send_packet(STREAM_DATA(s),
stream_get_endp(s), to, stream_get_endp(s), to, ifc);
ifc);
if (ret >= 0 && IS_RIP_DEBUG_SEND) if (ret >= 0 && IS_RIP_DEBUG_SEND)
rip_packet_dump((struct rip_packet *) rip_packet_dump(
STREAM_DATA(s), (struct rip_packet *)STREAM_DATA(s),
stream_get_endp(s), stream_get_endp(s), "SEND");
"SEND");
num = 0; num = 0;
stream_reset(s); stream_reset(s);
} }
@ -2482,41 +2445,39 @@ static void rip_update_process(struct rip *rip, int route_type)
if (ri->passive) if (ri->passive)
continue; continue;
if (ri->running) { if (!ri->running)
continue;
/* /*
* If there is no version configuration in the * If there is no version configuration in the
* interface, * interface, use rip's version setting.
* use rip's version setting.
*/ */
int vsend = ((ri->ri_send == RI_RIP_UNSPEC) int vsend = ((ri->ri_send == RI_RIP_UNSPEC) ? rip->version_send
? rip->version_send
: ri->ri_send); : ri->ri_send);
if (IS_RIP_DEBUG_EVENT) if (IS_RIP_DEBUG_EVENT)
zlog_debug("SEND UPDATE to %s ifindex %d", zlog_debug("SEND UPDATE to %s ifindex %d", ifp->name,
ifp->name, ifp->ifindex); ifp->ifindex);
/* send update on each connected network */ /* send update on each connected network */
for (ALL_LIST_ELEMENTS(ifp->connected, ifnode, ifnnode, for (ALL_LIST_ELEMENTS(ifp->connected, ifnode, ifnnode,
connected)) { connected)) {
if (connected->address->family == AF_INET) { if (connected->address->family == AF_INET) {
if (vsend & RIPv1) if (vsend & RIPv1)
rip_update_interface( rip_update_interface(connected, RIPv1,
connected, RIPv1,
route_type); route_type);
if ((vsend & RIPv2) if ((vsend & RIPv2) && if_is_multicast(ifp))
&& if_is_multicast(ifp)) rip_update_interface(connected, RIPv2,
rip_update_interface(
connected, RIPv2,
route_type); route_type);
} }
} }
} }
}
/* RIP send updates to each neighbor. */ /* RIP send updates to each neighbor. */
for (rp = route_top(rip->neighbor); rp; rp = route_next(rp)) for (rp = route_top(rip->neighbor); rp; rp = route_next(rp)) {
if (rp->info != NULL) { if (rp->info == NULL)
continue;
p = &rp->p; p = &rp->p;
connected = if_lookup_address(&p->u.prefix4, AF_INET, connected = if_lookup_address(&p->u.prefix4, AF_INET,
@ -2569,15 +2530,19 @@ static void rip_clear_changed_flag(struct rip *rip)
struct list *list = NULL; struct list *list = NULL;
struct listnode *listnode = NULL; struct listnode *listnode = NULL;
for (rp = route_top(rip->table); rp; rp = route_next(rp)) for (rp = route_top(rip->table); rp; rp = route_next(rp)) {
if ((list = rp->info) != NULL) list = rp->info;
if (list == NULL)
continue;
for (ALL_LIST_ELEMENTS_RO(list, listnode, rinfo)) { for (ALL_LIST_ELEMENTS_RO(list, listnode, rinfo)) {
UNSET_FLAG(rinfo->flags, RIP_RTF_CHANGED); UNSET_FLAG(rinfo->flags, RIP_RTF_CHANGED);
/* This flag can be set only on the first entry. /* This flag can be set only on the first entry. */
*/
break; break;
} }
} }
}
/* Triggered update interval timer. */ /* Triggered update interval timer. */
static int rip_triggered_interval(struct thread *t) static int rip_triggered_interval(struct thread *t)
@ -2632,35 +2597,40 @@ void rip_redistribute_withdraw(struct rip *rip, int type)
struct rip_info *rinfo = NULL; struct rip_info *rinfo = NULL;
struct list *list = NULL; struct list *list = NULL;
for (rp = route_top(rip->table); rp; rp = route_next(rp)) for (rp = route_top(rip->table); rp; rp = route_next(rp)) {
if ((list = rp->info) != NULL) { list = rp->info;
if (list == NULL)
continue;
rinfo = listgetdata(listhead(list)); rinfo = listgetdata(listhead(list));
if (rinfo->type == type
&& rinfo->sub_type != RIP_ROUTE_INTERFACE) { if (rinfo->type != type)
continue;
if (rinfo->sub_type == RIP_ROUTE_INTERFACE)
continue;
/* Perform poisoned reverse. */ /* Perform poisoned reverse. */
rinfo->metric = RIP_METRIC_INFINITY; rinfo->metric = RIP_METRIC_INFINITY;
RIP_TIMER_ON(rinfo->t_garbage_collect, RIP_TIMER_ON(rinfo->t_garbage_collect, rip_garbage_collect,
rip_garbage_collect,
rip->garbage_time); rip->garbage_time);
RIP_TIMER_OFF(rinfo->t_timeout); RIP_TIMER_OFF(rinfo->t_timeout);
rinfo->flags |= RIP_RTF_CHANGED; rinfo->flags |= RIP_RTF_CHANGED;
if (IS_RIP_DEBUG_EVENT) { if (IS_RIP_DEBUG_EVENT) {
struct prefix_ipv4 *p = struct prefix_ipv4 *p = (struct prefix_ipv4 *)&rp->p;
(struct prefix_ipv4 *)&rp->p;
zlog_debug( zlog_debug(
"Poisone %pFX on the interface %s with an infinity metric [withdraw]", "Poisone %pFX on the interface %s with an infinity metric [withdraw]",
p, p,
ifindex2ifname( ifindex2ifname(rinfo->nh.ifindex,
rinfo->nh.ifindex,
rip->vrf->vrf_id)); rip->vrf->vrf_id));
} }
rip_event(rip, RIP_TRIGGERED_UPDATE, 0); rip_event(rip, RIP_TRIGGERED_UPDATE, 0);
} }
} }
}
struct rip *rip_lookup_by_vrf_id(vrf_id_t vrf_id) struct rip *rip_lookup_by_vrf_id(vrf_id_t vrf_id)
{ {
@ -2916,18 +2886,19 @@ static void rip_distance_show(struct vty *vty, struct rip *rip)
vty_out(vty, " Distance: (default is %u)\n", vty_out(vty, " Distance: (default is %u)\n",
rip->distance ? rip->distance : ZEBRA_RIP_DISTANCE_DEFAULT); rip->distance ? rip->distance : ZEBRA_RIP_DISTANCE_DEFAULT);
for (rn = route_top(rip->distance_table); rn; rn = route_next(rn)) for (rn = route_top(rip->distance_table); rn; rn = route_next(rn)) {
if ((rdistance = rn->info) != NULL) { rdistance = rn->info;
if (rdistance == NULL)
continue;
if (header) { if (header) {
vty_out(vty, vty_out(vty, " Address Distance List\n");
" Address Distance List\n");
header = 0; header = 0;
} }
snprintfrr(buf, sizeof(buf), "%pFX", &rn->p); snprintfrr(buf, sizeof(buf), "%pFX", &rn->p);
vty_out(vty, " %-20s %4d %s\n", buf, vty_out(vty, " %-20s %4d %s\n", buf, rdistance->distance,
rdistance->distance, rdistance->access_list ? rdistance->access_list : "");
rdistance->access_list ? rdistance->access_list
: "");
} }
} }
@ -2939,18 +2910,25 @@ void rip_ecmp_disable(struct rip *rip)
struct list *list; struct list *list;
struct listnode *node, *nextnode; struct listnode *node, *nextnode;
for (rp = route_top(rip->table); rp; rp = route_next(rp)) for (rp = route_top(rip->table); rp; rp = route_next(rp)) {
if ((list = rp->info) != NULL && listcount(list) > 1) { list = rp->info;
if (!list)
continue;
if (listcount(list) == 0)
continue;
rinfo = listgetdata(listhead(list)); rinfo = listgetdata(listhead(list));
if (!rip_route_rte(rinfo)) if (!rip_route_rte(rinfo))
continue; continue;
/* Drop all other entries, except the first one. */ /* Drop all other entries, except the first one. */
for (ALL_LIST_ELEMENTS(list, node, nextnode, tmp_rinfo)) for (ALL_LIST_ELEMENTS(list, node, nextnode, tmp_rinfo)) {
if (tmp_rinfo != rinfo) { if (tmp_rinfo == rinfo)
continue;
RIP_TIMER_OFF(tmp_rinfo->t_timeout); RIP_TIMER_OFF(tmp_rinfo->t_timeout);
RIP_TIMER_OFF( RIP_TIMER_OFF(tmp_rinfo->t_garbage_collect);
tmp_rinfo->t_garbage_collect);
list_delete_node(list, node); list_delete_node(list, node);
rip_info_free(tmp_rinfo); rip_info_free(tmp_rinfo);
} }
@ -3044,13 +3022,16 @@ DEFUN (show_ip_rip,
" (i) - interface\n\n" " (i) - interface\n\n"
" Network Next Hop Metric From Tag Time\n"); " Network Next Hop Metric From Tag Time\n");
for (np = route_top(rip->table); np; np = route_next(np)) for (np = route_top(rip->table); np; np = route_next(np)) {
if ((list = np->info) != NULL) list = np->info;
if (!list)
continue;
for (ALL_LIST_ELEMENTS_RO(list, listnode, rinfo)) { for (ALL_LIST_ELEMENTS_RO(list, listnode, rinfo)) {
int len; int len;
len = vty_out( len = vty_out(vty, "%c(%s) %pFX",
vty, "%c(%s) %pFX",
/* np->lock, For debugging. */ /* np->lock, For debugging. */
zebra_route_char(rinfo->type), zebra_route_char(rinfo->type),
rip_route_type_print(rinfo->sub_type), rip_route_type_print(rinfo->sub_type),
@ -3065,37 +3046,31 @@ DEFUN (show_ip_rip,
case NEXTHOP_TYPE_IPV4: case NEXTHOP_TYPE_IPV4:
case NEXTHOP_TYPE_IPV4_IFINDEX: case NEXTHOP_TYPE_IPV4_IFINDEX:
vty_out(vty, "%-20pI4 %2d ", vty_out(vty, "%-20pI4 %2d ",
&rinfo->nh.gate.ipv4, &rinfo->nh.gate.ipv4, rinfo->metric);
rinfo->metric);
break; break;
case NEXTHOP_TYPE_IFINDEX: case NEXTHOP_TYPE_IFINDEX:
vty_out(vty, vty_out(vty, "0.0.0.0 %2d ",
"0.0.0.0 %2d ",
rinfo->metric); rinfo->metric);
break; break;
case NEXTHOP_TYPE_BLACKHOLE: case NEXTHOP_TYPE_BLACKHOLE:
vty_out(vty, vty_out(vty, "blackhole %2d ",
"blackhole %2d ",
rinfo->metric); rinfo->metric);
break; break;
case NEXTHOP_TYPE_IPV6: case NEXTHOP_TYPE_IPV6:
case NEXTHOP_TYPE_IPV6_IFINDEX: case NEXTHOP_TYPE_IPV6_IFINDEX:
vty_out(vty, vty_out(vty, "V6 Address Hidden %2d ",
"V6 Address Hidden %2d ",
rinfo->metric); rinfo->metric);
break; break;
} }
/* Route which exist in kernel routing table. */ /* Route which exist in kernel routing table. */
if ((rinfo->type == ZEBRA_ROUTE_RIP) if ((rinfo->type == ZEBRA_ROUTE_RIP) &&
&& (rinfo->sub_type == RIP_ROUTE_RTE)) { (rinfo->sub_type == RIP_ROUTE_RTE)) {
vty_out(vty, "%-15pI4 ", vty_out(vty, "%-15pI4 ", &rinfo->from);
&rinfo->from);
vty_out(vty, "%3" ROUTE_TAG_PRI " ", vty_out(vty, "%3" ROUTE_TAG_PRI " ",
(route_tag_t)rinfo->tag); (route_tag_t)rinfo->tag);
rip_vty_out_uptime(vty, rinfo); rip_vty_out_uptime(vty, rinfo);
} else if (rinfo->metric } else if (rinfo->metric == RIP_METRIC_INFINITY) {
== RIP_METRIC_INFINITY) {
vty_out(vty, "self "); vty_out(vty, "self ");
vty_out(vty, "%3" ROUTE_TAG_PRI " ", vty_out(vty, "%3" ROUTE_TAG_PRI " ",
(route_tag_t)rinfo->tag); (route_tag_t)rinfo->tag);
@ -3104,22 +3079,20 @@ DEFUN (show_ip_rip,
if (rinfo->external_metric) { if (rinfo->external_metric) {
len = vty_out( len = vty_out(
vty, "self (%s:%d)", vty, "self (%s:%d)",
zebra_route_string( zebra_route_string(rinfo->type),
rinfo->type),
rinfo->external_metric); rinfo->external_metric);
len = 16 - len; len = 16 - len;
if (len > 0) if (len > 0)
vty_out(vty, "%*s", len, vty_out(vty, "%*s", len, " ");
" ");
} else } else
vty_out(vty, vty_out(vty, "self ");
"self ");
vty_out(vty, "%3" ROUTE_TAG_PRI, vty_out(vty, "%3" ROUTE_TAG_PRI,
(route_tag_t)rinfo->tag); (route_tag_t)rinfo->tag);
} }
vty_out(vty, "\n"); vty_out(vty, "\n");
} }
}
return CMD_SUCCESS; return CMD_SUCCESS;
} }
@ -3219,22 +3192,19 @@ DEFUN (show_ip_rip_status,
vty_out(vty, " Routing for Networks:\n"); vty_out(vty, " Routing for Networks:\n");
rip_show_network_config(vty, rip); rip_show_network_config(vty, rip);
{
int found_passive = 0; int found_passive = 0;
FOR_ALL_INTERFACES (rip->vrf, ifp) { FOR_ALL_INTERFACES (rip->vrf, ifp) {
ri = ifp->info; ri = ifp->info;
if ((ri->enable_network || ri->enable_interface) if ((ri->enable_network || ri->enable_interface) &&
&& ri->passive) { ri->passive) {
if (!found_passive) { if (!found_passive) {
vty_out(vty, vty_out(vty, " Passive Interface(s):\n");
" Passive Interface(s):\n");
found_passive = 1; found_passive = 1;
} }
vty_out(vty, " %s\n", ifp->name); vty_out(vty, " %s\n", ifp->name);
} }
} }
}
vty_out(vty, " Routing Information Sources:\n"); vty_out(vty, " Routing Information Sources:\n");
vty_out(vty, vty_out(vty,