summaryrefslogtreecommitdiffstats
path: root/ripd
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@cumulusnetworks.com>2017-11-15 15:50:32 +0100
committerDonald Sharp <sharpd@cumulusnetworks.com>2017-11-16 14:45:28 +0100
commitdd127197f9f165c23ced8165b08b66b2509c5da9 (patch)
tree480948182dd1679ccff01ab529f7742672b1b739 /ripd
parentMerge pull request #1444 from fatihusta/patch-1 (diff)
downloadfrr-dd127197f9f165c23ced8165b08b66b2509c5da9.tar.xz
frr-dd127197f9f165c23ced8165b08b66b2509c5da9.zip
ripd: Convert to using 'struct nexthop' for nexthop information
RIP is not using the nexthop data structure and as such when it does not fully understand when it receives some of the more exotic nexthop types what to do with it. This is the start of a series of commits to allow RIP to start understanding and properly displaying information about different nexthop types. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Diffstat (limited to 'ripd')
-rw-r--r--ripd/rip_interface.c2
-rw-r--r--ripd/rip_routemap.c8
-rw-r--r--ripd/rip_zebra.c2
-rw-r--r--ripd/ripd.c39
-rw-r--r--ripd/ripd.h6
5 files changed, 30 insertions, 27 deletions
diff --git a/ripd/rip_interface.c b/ripd/rip_interface.c
index a997ca5f2..184f2f2b8 100644
--- a/ripd/rip_interface.c
+++ b/ripd/rip_interface.c
@@ -559,7 +559,7 @@ int rip_if_down(struct interface *ifp)
if ((list = rp->info) != NULL)
for (ALL_LIST_ELEMENTS(list, listnode, nextnode,
rinfo))
- if (rinfo->ifindex == ifp->ifindex)
+ if (rinfo->nh.ifindex == ifp->ifindex)
rip_ecmp_delete(rinfo);
ri = ifp->info;
diff --git a/ripd/rip_routemap.c b/ripd/rip_routemap.c
index ad9f8cf80..a37effa23 100644
--- a/ripd/rip_routemap.c
+++ b/ripd/rip_routemap.c
@@ -129,7 +129,7 @@ static route_map_result_t route_match_interface(void *rule,
rinfo = object;
if (rinfo->ifindex_out == ifp->ifindex
- || rinfo->ifindex == ifp->ifindex)
+ || rinfo->nh.ifindex == ifp->ifindex)
return RMAP_MATCH;
else
return RMAP_NOMATCH;
@@ -171,7 +171,8 @@ static route_map_result_t route_match_ip_next_hop(void *rule,
rinfo = object;
p.family = AF_INET;
p.prefix =
- (rinfo->nexthop.s_addr) ? rinfo->nexthop : rinfo->from;
+ (rinfo->nh.gate.ipv4.s_addr) ?
+ rinfo->nh.gate.ipv4 : rinfo->from;
p.prefixlen = IPV4_MAX_BITLEN;
alist = access_list_lookup(AFI_IP, (char *)rule);
@@ -217,7 +218,8 @@ route_match_ip_next_hop_prefix_list(void *rule, struct prefix *prefix,
rinfo = object;
p.family = AF_INET;
p.prefix =
- (rinfo->nexthop.s_addr) ? rinfo->nexthop : rinfo->from;
+ (rinfo->nh.gate.ipv4.s_addr) ?
+ rinfo->nh.gate.ipv4 : rinfo->from;
p.prefixlen = IPV4_MAX_BITLEN;
plist = prefix_list_lookup(AFI_IP, (char *)rule);
diff --git a/ripd/rip_zebra.c b/ripd/rip_zebra.c
index 3772f6223..bd46f7e3e 100644
--- a/ripd/rip_zebra.c
+++ b/ripd/rip_zebra.c
@@ -56,7 +56,7 @@ static void rip_zebra_ipv4_send(struct route_node *rp, u_char cmd)
if (count >= MULTIPATH_NUM)
break;
api_nh = &api.nexthops[count];
- api_nh->gate.ipv4 = rinfo->nexthop;
+ api_nh->gate = rinfo->nh.gate;
api_nh->type = NEXTHOP_TYPE_IPV4;
if (cmd == ZEBRA_ROUTE_ADD)
SET_FLAG(rinfo->flags, RIP_RTF_FIB);
diff --git a/ripd/ripd.c b/ripd/ripd.c
index aece5d03c..0415c5ba9 100644
--- a/ripd/ripd.c
+++ b/ripd/ripd.c
@@ -424,9 +424,10 @@ static void rip_rte_process(struct rte *rte, struct sockaddr_in *from,
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 */
@@ -488,7 +489,8 @@ static void rip_rte_process(struct rte *rte, struct sockaddr_in *from,
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);
@@ -505,7 +507,7 @@ static void rip_rte_process(struct rte *rte, struct sockaddr_in *from,
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)) {
@@ -567,7 +569,7 @@ static void rip_rte_process(struct rte *rte, struct sockaddr_in *from,
/* 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;
@@ -602,7 +604,7 @@ static void rip_rte_process(struct rte *rte, struct sockaddr_in *from,
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;
@@ -1480,7 +1482,7 @@ void rip_redistribute_add(int type, int sub_type, struct prefix_ipv4 *p,
memset(&newinfo, 0, sizeof(struct rip_info));
newinfo.type = type;
newinfo.sub_type = sub_type;
- newinfo.ifindex = ifindex;
+ newinfo.nh.ifindex = ifindex;
newinfo.metric = 1;
newinfo.external_metric = metric;
newinfo.distance = distance;
@@ -1488,7 +1490,7 @@ void rip_redistribute_add(int type, int sub_type, struct prefix_ipv4 *p,
newinfo.tag = tag;
newinfo.rp = rp;
if (nexthop)
- newinfo.nexthop = *nexthop;
+ newinfo.nh.gate.ipv4 = *nexthop;
if ((list = rp->info) != NULL && listcount(list) != 0) {
rinfo = listgetdata(listhead(list));
@@ -1527,7 +1529,7 @@ void rip_redistribute_add(int type, int sub_type, struct prefix_ipv4 *p,
zlog_debug(
"Redistribute new prefix %s/%d with nexthop %s on the interface %s",
inet_ntoa(p->prefix), p->prefixlen,
- inet_ntoa(rinfo->nexthop),
+ inet_ntoa(rinfo->nh.gate.ipv4),
ifindex2ifname(ifindex, VRF_DEFAULT));
}
@@ -1554,7 +1556,7 @@ void rip_redistribute_delete(int type, int sub_type, struct prefix_ipv4 *p,
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,
@@ -2201,7 +2203,7 @@ void rip_output_process(struct connected *ifc, struct sockaddr_in *to,
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;
@@ -2233,8 +2235,8 @@ void rip_output_process(struct connected *ifc, struct sockaddr_in *to,
* 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]) {
@@ -2326,7 +2328,7 @@ void rip_output_process(struct connected *ifc, struct sockaddr_in *to,
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;
@@ -2647,8 +2649,9 @@ void rip_redistribute_withdraw(int type)
"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);
@@ -3454,9 +3457,9 @@ DEFUN (show_ip_rip,
if (len > 0)
vty_out(vty, "%*s", len, " ");
- if (rinfo->nexthop.s_addr)
+ if (rinfo->nh.gate.ipv4.s_addr)
vty_out(vty, "%-20s %2d ",
- inet_ntoa(rinfo->nexthop),
+ inet_ntoa(rinfo->nh.gate.ipv4),
rinfo->metric);
else
vty_out(vty,
diff --git a/ripd/ripd.h b/ripd/ripd.h
index ae34ed3f4..a66f506f4 100644
--- a/ripd/ripd.h
+++ b/ripd/ripd.h
@@ -23,6 +23,7 @@
#include "qobj.h"
#include "hook.h"
+#include "nexthop.h"
#include "rip_memory.h"
/* RIP version number. */
@@ -194,12 +195,9 @@ struct rip_info {
int sub_type;
/* RIP nexthop. */
- struct in_addr nexthop;
+ struct nexthop nh;
struct in_addr from;
- /* Which interface does this route come from. */
- ifindex_t ifindex;
-
/* Metric of this route. */
u_int32_t metric;