/* UDP receive buffer size */
#define RIP_UDP_RCV_BUF 41600
-/* privileges global */
-extern struct zebra_privs_t ripd_privs;
-
/* RIP Structure. */
struct rip *rip = NULL;
/* If nexthop address matches local configured address then it is
invalid nexthop. */
- RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
+ FOR_ALL_INTERFACES (vrf, ifp) {
for (ALL_LIST_ELEMENTS_RO(ifp->connected, cnode, ifc)) {
p = ifc->address;
memset(&newinfo, 0, sizeof(newinfo));
newinfo.type = ZEBRA_ROUTE_RIP;
newinfo.sub_type = RIP_ROUTE_RTE;
- newinfo.nexthop = rte->nexthop;
+ newinfo.nh.gate.ipv4 = rte->nexthop;
newinfo.from = from->sin_addr;
- newinfo.ifindex = ifp->ifindex;
+ newinfo.nh.ifindex = ifp->ifindex;
+ newinfo.nh.type = NEXTHOP_TYPE_IPV4_IFINDEX;
newinfo.metric = rte->metric;
newinfo.metric_out = rte->metric; /* XXX */
newinfo.tag = ntohs(rte->tag); /* XXX */
rp = route_node_get(rip->table, (struct prefix *)&p);
newinfo.rp = rp;
- newinfo.nexthop = *nexthop;
+ newinfo.nh.gate.ipv4 = *nexthop;
+ newinfo.nh.type = NEXTHOP_TYPE_IPV4;
newinfo.metric = rte->metric;
newinfo.tag = ntohs(rte->tag);
newinfo.distance = rip_distance_apply(&newinfo);
break;
if (IPV4_ADDR_SAME(&rinfo->from, &from->sin_addr)
- && IPV4_ADDR_SAME(&rinfo->nexthop, nexthop))
+ && IPV4_ADDR_SAME(&rinfo->nh.gate.ipv4, nexthop))
break;
if (!listnextnode(node)) {
/* Only routes directly connected to an interface
* (nexthop == 0)
* may have a valid NULL distance */
- if (rinfo->nexthop.s_addr != 0)
+ if (rinfo->nh.gate.ipv4.s_addr != 0)
old_dist = old_dist
? old_dist
: ZEBRA_RIP_DISTANCE_DEFAULT;
If this datagram is from the same router as the existing
route, reinitialize the timeout. */
same = (IPV4_ADDR_SAME(&rinfo->from, &from->sin_addr)
- && (rinfo->ifindex == ifp->ifindex));
+ && (rinfo->nh.ifindex == ifp->ifindex));
old_dist = rinfo->distance ? rinfo->distance
: ZEBRA_RIP_DISTANCE_DEFAULT;
/* Add redistributed route to RIP table. */
void rip_redistribute_add(int type, int sub_type, struct prefix_ipv4 *p,
- ifindex_t ifindex, struct in_addr *nexthop,
+ struct nexthop *nh,
unsigned int metric, unsigned char distance,
route_tag_t tag)
{
memset(&newinfo, 0, sizeof(struct rip_info));
newinfo.type = type;
newinfo.sub_type = sub_type;
- newinfo.ifindex = ifindex;
newinfo.metric = 1;
newinfo.external_metric = metric;
newinfo.distance = distance;
if (tag <= UINT16_MAX) /* RIP only supports 16 bit tags */
newinfo.tag = tag;
newinfo.rp = rp;
- if (nexthop)
- newinfo.nexthop = *nexthop;
+ newinfo.nh = *nh;
if ((list = rp->info) != NULL && listcount(list) != 0) {
rinfo = listgetdata(listhead(list));
}
}
- rinfo = rip_ecmp_replace(&newinfo);
+ (void)rip_ecmp_replace(&newinfo);
route_unlock_node(rp);
} else
- rinfo = rip_ecmp_add(&newinfo);
+ (void)rip_ecmp_add(&newinfo);
if (IS_RIP_DEBUG_EVENT) {
- if (!nexthop)
- zlog_debug(
- "Redistribute new prefix %s/%d on the interface %s",
- inet_ntoa(p->prefix), p->prefixlen,
- ifindex2ifname(ifindex, VRF_DEFAULT));
- else
- zlog_debug(
- "Redistribute new prefix %s/%d with nexthop %s on the interface %s",
- inet_ntoa(p->prefix), p->prefixlen,
- inet_ntoa(rinfo->nexthop),
- ifindex2ifname(ifindex, VRF_DEFAULT));
+ zlog_debug(
+ "Redistribute new prefix %s/%d",
+ inet_ntoa(p->prefix), p->prefixlen);
}
rip_event(RIP_TRIGGERED_UPDATE, 0);
rinfo = listgetdata(listhead(list));
if (rinfo != NULL && rinfo->type == type
&& rinfo->sub_type == sub_type
- && rinfo->ifindex == ifindex) {
+ && rinfo->nh.ifindex == ifindex) {
/* Perform poisoned reverse. */
rinfo->metric = RIP_METRIC_INFINITY;
RIP_TIMER_ON(rinfo->t_garbage_collect,
if (IS_RIP_DEBUG_EVENT)
zlog_debug(
- "Poisone %s/%d on the interface %s with an "
+ "Poison %s/%d on the interface %s with an "
"infinity metric [delete]",
inet_ntoa(p->prefix),
p->prefixlen,
for (ALL_LIST_ELEMENTS_RO(list, listnode,
tmp_rinfo))
if (tmp_rinfo->type == ZEBRA_ROUTE_RIP
- && tmp_rinfo->ifindex
+ && tmp_rinfo->nh.ifindex
== ifc->ifp->ifindex) {
suppress = 1;
break;
* to avoid an IGP multi-level recursive look-up.
* see (4.4)
*/
- if (rinfo->ifindex == ifc->ifp->ifindex)
- rinfo->nexthop_out = rinfo->nexthop;
+ if (rinfo->nh.ifindex == ifc->ifp->ifindex)
+ rinfo->nexthop_out = rinfo->nh.gate.ipv4;
/* Interface route-map */
if (ri->routemap[RIP_FILTER_OUT]) {
for (ALL_LIST_ELEMENTS_RO(list, listnode,
tmp_rinfo))
if (tmp_rinfo->type == ZEBRA_ROUTE_RIP
- && tmp_rinfo->ifindex
+ && tmp_rinfo->nh.ifindex
== ifc->ifp->ifindex)
rinfo->metric_out =
RIP_METRIC_INFINITY;
struct prefix *p;
/* Send RIP update to each interface. */
- RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
+ FOR_ALL_INTERFACES (vrf, ifp) {
if (if_is_loopback(ifp))
continue;
"Poisone %s/%d on the interface %s with an infinity metric [withdraw]",
inet_ntoa(p->prefix),
p->prefixlen,
- ifindex2ifname(rinfo->ifindex,
- VRF_DEFAULT));
+ ifindex2ifname(
+ rinfo->nh.ifindex,
+ VRF_DEFAULT));
}
rip_event(RIP_TRIGGERED_UPDATE, 0);
{
int idx_ipv4_prefixlen = 1;
int ret;
+ struct nexthop nh;
struct prefix_ipv4 p;
struct route_node *node;
+ memset(&nh, 0, sizeof(nh));
+ nh.type = NEXTHOP_TYPE_IPV4;
+
ret = str2prefix_ipv4(argv[idx_ipv4_prefixlen]->arg, &p);
if (ret < 0) {
vty_out(vty, "Malformed address\n");
node->info = (void *)1;
- rip_redistribute_add(ZEBRA_ROUTE_RIP, RIP_ROUTE_STATIC, &p, 0, NULL, 0,
+ rip_redistribute_add(ZEBRA_ROUTE_RIP, RIP_ROUTE_STATIC, &p, &nh, 0,
0, 0);
return CMD_SUCCESS;
if (len > 0)
vty_out(vty, "%*s", len, " ");
- if (rinfo->nexthop.s_addr)
+ switch(rinfo->nh.type) {
+ case NEXTHOP_TYPE_IPV4:
+ case NEXTHOP_TYPE_IPV4_IFINDEX:
vty_out(vty, "%-20s %2d ",
- inet_ntoa(rinfo->nexthop),
+ inet_ntoa(rinfo->nh.gate.ipv4),
rinfo->metric);
- else
+ break;
+ case NEXTHOP_TYPE_IFINDEX:
vty_out(vty,
"0.0.0.0 %2d ",
rinfo->metric);
+ break;
+ case NEXTHOP_TYPE_BLACKHOLE:
+ vty_out(vty,
+ "blackhole %2d ",
+ rinfo->metric);
+ break;
+ case NEXTHOP_TYPE_IPV6:
+ case NEXTHOP_TYPE_IPV6_IFINDEX:
+ vty_out(vty,
+ "V6 Address Hidden %2d ",
+ rinfo->metric);
+ break;
+ }
/* Route which exist in kernel routing table. */
if ((rinfo->type == ZEBRA_ROUTE_RIP)
vty_out(vty, " Interface Send Recv Key-chain\n");
- RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
+ FOR_ALL_INTERFACES (vrf, ifp) {
ri = ifp->info;
if (!ri->running)
{
int found_passive = 0;
- RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
+ FOR_ALL_INTERFACES (vrf, ifp) {
ri = ifp->info;
if ((ri->enable_network || ri->enable_interface)
struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
struct interface *ifp;
- RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
+ FOR_ALL_INTERFACES (vrf, ifp)
rip_distribute_update_interface(ifp);
}
/* ARGSUSED */
struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
struct interface *ifp;
- RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
+ FOR_ALL_INTERFACES (vrf, ifp)
rip_if_rmap_update_interface(ifp);
rip_routemap_update_redistribute();