summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@cumulusnetwroks.com>2016-09-02 16:56:29 +0200
committerDonald Sharp <sharpd@cumulusnetworks.com>2016-12-22 02:26:08 +0100
commitba634917bde686ae908f8b59b407d23d4c88c99f (patch)
tree8640ba9eb1b5fe5972f09a4aa0536256b91cd69d
parentpimd: Add pim_addr_dump to facilitate v4 and v6 address dumping (diff)
downloadfrr-ba634917bde686ae908f8b59b407d23d4c88c99f.tar.xz
frr-ba634917bde686ae908f8b59b407d23d4c88c99f.zip
pimd: Switch 'struct in_addr' to 'struct prefix' in pim_zlookup.h
This is setup code to allow us to receive v6 addresses from a nexthop lookup from zebra. This will allow us to work with unnumbered interfaces. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
-rw-r--r--pimd/pim_rpf.c4
-rw-r--r--pimd/pim_zlookup.c18
-rw-r--r--pimd/pim_zlookup.h2
3 files changed, 13 insertions, 11 deletions
diff --git a/pimd/pim_rpf.c b/pimd/pim_rpf.c
index da5f16240..928629b0c 100644
--- a/pimd/pim_rpf.c
+++ b/pimd/pim_rpf.c
@@ -91,7 +91,7 @@ int pim_nexthop_lookup(struct pim_nexthop *nexthop, struct in_addr addr)
if (PIM_DEBUG_ZEBRA) {
char nexthop_str[100];
char addr_str[100];
- pim_inet4_dump("<nexthop?>", nexthop_tab[0].nexthop_addr, nexthop_str, sizeof(nexthop_str));
+ pim_addr_dump("<nexthop?>", &nexthop_tab[0].nexthop_addr, nexthop_str, sizeof(nexthop_str));
pim_inet4_dump("<addr?>", addr, addr_str, sizeof(addr_str));
zlog_debug("%s %s: found nexthop %s for address %s: interface %s ifindex=%d metric=%d pref=%d",
__FILE__, __PRETTY_FUNCTION__,
@@ -103,7 +103,7 @@ int pim_nexthop_lookup(struct pim_nexthop *nexthop, struct in_addr addr)
/* update nextop data */
nexthop->interface = ifp;
- nexthop->mrib_nexthop_addr = nexthop_tab[0].nexthop_addr;
+ nexthop->mrib_nexthop_addr = nexthop_tab[0].nexthop_addr.u.prefix4;
nexthop->mrib_metric_preference = nexthop_tab[0].protocol_distance;
nexthop->mrib_route_metric = nexthop_tab[0].route_metric;
diff --git a/pimd/pim_zlookup.c b/pimd/pim_zlookup.c
index 7234790fa..c2160d8d9 100644
--- a/pimd/pim_zlookup.c
+++ b/pimd/pim_zlookup.c
@@ -241,17 +241,18 @@ static int zclient_read_nexthop(struct zclient *zlookup,
switch (nexthop_type) {
case NEXTHOP_TYPE_IFINDEX:
case NEXTHOP_TYPE_IPV4_IFINDEX:
+ nexthop_tab[num_ifindex].nexthop_addr.family = AF_INET;
if (nexthop_type == NEXTHOP_TYPE_IPV4_IFINDEX) {
if (length < 4) {
zlog_err("%s: socket %d short input expecting nexthop IPv4-addr: len=%d",
__func__, zlookup->sock, length);
return -8;
}
- nexthop_tab[num_ifindex].nexthop_addr.s_addr = stream_get_ipv4(s);
+ nexthop_tab[num_ifindex].nexthop_addr.u.prefix4.s_addr = stream_get_ipv4(s);
length -= 4;
}
else {
- nexthop_tab[num_ifindex].nexthop_addr.s_addr = PIM_NET_INADDR_ANY;
+ nexthop_tab[num_ifindex].nexthop_addr.u.prefix4.s_addr = PIM_NET_INADDR_ANY;
}
nexthop_tab[num_ifindex].ifindex = stream_getl(s);
nexthop_tab[num_ifindex].protocol_distance = distance;
@@ -259,7 +260,8 @@ static int zclient_read_nexthop(struct zclient *zlookup,
++num_ifindex;
break;
case NEXTHOP_TYPE_IPV4:
- nexthop_tab[num_ifindex].nexthop_addr.s_addr = stream_get_ipv4(s);
+ nexthop_tab[num_ifindex].nexthop_addr.family = AF_INET;
+ nexthop_tab[num_ifindex].nexthop_addr.u.prefix4.s_addr = stream_get_ipv4(s);
length -= 4;
nexthop_tab[num_ifindex].ifindex = 0;
nexthop_tab[num_ifindex].protocol_distance = distance;
@@ -268,7 +270,7 @@ static int zclient_read_nexthop(struct zclient *zlookup,
char addr_str[100];
char nexthop_str[100];
pim_inet4_dump("<addr?>", addr, addr_str, sizeof(addr_str));
- pim_inet4_dump("<nexthop?>", nexthop_tab[num_ifindex].nexthop_addr, nexthop_str, sizeof(nexthop_str));
+ pim_addr_dump("<nexthop?>", &nexthop_tab[num_ifindex].nexthop_addr, nexthop_str, sizeof(nexthop_str));
zlog_debug("%s %s: zebra returned recursive nexthop %s for address %s",
__FILE__, __PRETTY_FUNCTION__,
nexthop_str, addr_str);
@@ -354,7 +356,7 @@ zclient_lookup_nexthop (struct pim_zlookup_nexthop nexthop_tab[],
for (lookup = 0; lookup < max_lookup; ++lookup) {
int num_ifindex;
int first_ifindex;
- struct in_addr nexthop_addr;
+ struct prefix nexthop_addr;
num_ifindex = zclient_lookup_nexthop_once(nexthop_tab,
PIM_NEXTHOP_IFINDEX_TAB_SIZE, addr);
@@ -398,7 +400,7 @@ zclient_lookup_nexthop (struct pim_zlookup_nexthop nexthop_tab[],
}
/* use last address as nexthop address */
- nexthop_tab[0].nexthop_addr = addr;
+ nexthop_tab[0].nexthop_addr.u.prefix4 = addr;
/* report original route metric/distance */
nexthop_tab[0].route_metric = route_metric;
@@ -412,7 +414,7 @@ zclient_lookup_nexthop (struct pim_zlookup_nexthop nexthop_tab[],
char addr_str[100];
char nexthop_str[100];
pim_inet4_dump("<addr?>", addr, addr_str, sizeof(addr_str));
- pim_inet4_dump("<nexthop?>", nexthop_addr, nexthop_str, sizeof(nexthop_str));
+ pim_addr_dump("<nexthop?>", &nexthop_addr, nexthop_str, sizeof(nexthop_str));
zlog_debug("%s %s: lookup=%d/%d: zebra returned recursive nexthop %s for address %s dist=%d met=%d",
__FILE__, __PRETTY_FUNCTION__,
lookup, max_lookup, nexthop_str, addr_str,
@@ -420,7 +422,7 @@ zclient_lookup_nexthop (struct pim_zlookup_nexthop nexthop_tab[],
nexthop_tab[0].route_metric);
}
- addr = nexthop_addr; /* use nexthop addr for recursive lookup */
+ addr = nexthop_addr.u.prefix4; /* use nexthop addr for recursive lookup */
} /* for (max_lookup) */
diff --git a/pimd/pim_zlookup.h b/pimd/pim_zlookup.h
index 4dea5750c..ce85c8eba 100644
--- a/pimd/pim_zlookup.h
+++ b/pimd/pim_zlookup.h
@@ -29,7 +29,7 @@
#define PIM_NEXTHOP_LOOKUP_MAX (3) /* max. recursive route lookup */
struct pim_zlookup_nexthop {
- struct in_addr nexthop_addr;
+ struct prefix nexthop_addr;
ifindex_t ifindex;
uint32_t route_metric;
uint8_t protocol_distance;