static void rip_apply_address_add(struct connected *ifc)
{
struct prefix_ipv4 address;
+ struct nexthop nh;
struct prefix *p;
if (!rip)
p = ifc->address;
memset(&address, 0, sizeof(address));
+ memset(&nh, 0, sizeof(nh));
+
address.family = p->family;
address.prefix = p->u.prefix4;
address.prefixlen = p->prefixlen;
apply_mask_ipv4(&address);
+ nh.ifindex = ifc->ifp->ifindex;
+ nh.type = NEXTHOP_TYPE_IFINDEX;
+
/* Check if this interface is RIP enabled or not
or Check if this address's prefix is RIP enabled */
if ((rip_enable_if_lookup(ifc->ifp->name) >= 0)
|| (rip_enable_network_lookup2(ifc) >= 0))
rip_redistribute_add(ZEBRA_ROUTE_CONNECT, RIP_ROUTE_INTERFACE,
- &address, ifc->ifp->ifindex, NULL, 0, 0,
- 0);
+ &address, &nh, 0, 0, 0);
}
int rip_interface_address_add(int command, struct zclient *zclient,
struct listnode *node, *nnode;
struct connected *connected;
struct prefix_ipv4 address;
+ struct nexthop nh;
+
+ memset(&nh, 0, sizeof(nh));
for (ALL_LIST_ELEMENTS(ifp->connected, node, nnode, connected)) {
struct prefix *p;
address.prefixlen = p->prefixlen;
apply_mask_ipv4(&address);
+ nh.ifindex = connected->ifp->ifindex;
+ nh.type = NEXTHOP_TYPE_IFINDEX;
if (set) {
/* Check once more wether this prefix is within a
* "network IF_OR_PREF" one */
rip_redistribute_add(
ZEBRA_ROUTE_CONNECT,
RIP_ROUTE_INTERFACE, &address,
- connected->ifp->ifindex, NULL, 0, 0, 0);
+ &nh, 0, 0, 0);
} else {
rip_redistribute_delete(ZEBRA_ROUTE_CONNECT,
RIP_ROUTE_INTERFACE, &address,
rip_redistribute_add(
ZEBRA_ROUTE_CONNECT,
RIP_ROUTE_REDISTRIBUTE, &address,
- connected->ifp->ifindex, NULL, 0, 0, 0);
+ &nh, 0, 0, 0);
}
}
}
zebra_size_t length, vrf_id_t vrf_id)
{
struct zapi_route api;
- struct in_addr nexthop;
- unsigned long ifindex;
+ struct nexthop nh;
if (!rip)
return 0;
if (zapi_route_decode(zclient->ibuf, &api) < 0)
return -1;
- nexthop = api.nexthops[0].gate.ipv4;
- ifindex = api.nexthops[0].ifindex;
+ memset(&nh, 0, sizeof(nh));
+ nh.type = api.nexthops[0].type;
+ nh.gate.ipv4 = api.nexthops[0].gate.ipv4;
+ nh.ifindex = api.nexthops[0].ifindex;
/* Then fetch IPv4 prefixes. */
if (command == ZEBRA_REDISTRIBUTE_ROUTE_ADD)
rip_redistribute_add(api.type, RIP_ROUTE_REDISTRIBUTE,
- (struct prefix_ipv4 *)&api.prefix, ifindex,
- &nexthop, api.metric, api.distance,
+ (struct prefix_ipv4 *)&api.prefix, &nh,
+ api.metric, api.distance,
api.tag);
else if (command == ZEBRA_REDISTRIBUTE_ROUTE_DEL)
rip_redistribute_delete(api.type, RIP_ROUTE_REDISTRIBUTE,
(struct prefix_ipv4 *)&api.prefix,
- ifindex);
+ nh.ifindex);
return 0;
}
"Distribute a default route\n")
{
struct prefix_ipv4 p;
+ struct nexthop nh;
if (!rip->default_information) {
memset(&p, 0, sizeof(struct prefix_ipv4));
+ memset(&nh, 0, sizeof(nh));
+
p.family = AF_INET;
+ nh.type = NEXTHOP_TYPE_IPV4;
rip->default_information = 1;
- rip_redistribute_add(ZEBRA_ROUTE_RIP, RIP_ROUTE_DEFAULT, &p, 0,
- NULL, 0, 0, 0);
+ rip_redistribute_add(ZEBRA_ROUTE_RIP, RIP_ROUTE_DEFAULT, &p,
+ &nh, 0, 0, 0);
}
return CMD_SUCCESS;
/* 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.nh.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.nh.gate.ipv4 = *nexthop;
+ newinfo.nh = *nh;
if ((list = rp->info) != NULL && listcount(list) != 0) {
rinfo = listgetdata(listhead(list));
rinfo = 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->nh.gate.ipv4),
- ifindex2ifname(ifindex, VRF_DEFAULT));
+ zlog_debug(
+ "Redistribute new prefix %s/%d",
+ inet_ntoa(p->prefix), p->prefixlen);
}
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->nh.gate.ipv4.s_addr)
+ switch(rinfo->nh.type) {
+ case NEXTHOP_TYPE_IPV4:
+ case NEXTHOP_TYPE_IPV4_IFINDEX:
vty_out(vty, "%-20s %2d ",
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)
extern int rip_neighbor_lookup(struct sockaddr_in *);
extern int rip_redistribute_check(int);
-extern void rip_redistribute_add(int, int, struct prefix_ipv4 *, ifindex_t,
- struct in_addr *, unsigned int, unsigned char,
- route_tag_t);
+extern void rip_redistribute_add(int type, int sub_type,
+ struct prefix_ipv4 *p,
+ struct nexthop *nh,
+ unsigned int metric, unsigned char distance,
+ route_tag_t tag);
extern void rip_redistribute_delete(int, int, struct prefix_ipv4 *, ifindex_t);
extern void rip_redistribute_withdraw(int);
extern void rip_zebra_ipv4_add(struct route_node *);