zebra, pimd: add AF param on NEXTHOP_LOOKUP_MRIB

By changing this API call to use a `struct ipaddr`, which encodes the
type of IP address with it.  (And rename/remove the `IPV4` from the
command name.)

Also add a comment explaining that this function call is going to be
obsolete in the long run since pimd needs to move to proper MRIB NHT.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
This commit is contained in:
David Lamparter 2022-04-26 14:52:53 +02:00
parent 425fd200c9
commit 34ee41c6c9
5 changed files with 50 additions and 32 deletions

View File

@ -250,7 +250,7 @@ Zebra Protocol Commands
+------------------------------------+-------+
| ZEBRA_INTERFACE_DISABLE_RADV | 43 |
+------------------------------------+-------+
| ZEBRA_IPV4_NEXTHOP_LOOKUP_MRIB | 44 |
| ZEBRA_NEXTHOP_LOOKUP_MRIB | 44 |
+------------------------------------+-------+
| ZEBRA_INTERFACE_LINK_PARAMS | 45 |
+------------------------------------+-------+

View File

@ -370,7 +370,7 @@ static const struct zebra_desc_table command_types[] = {
DESC_ENTRY(ZEBRA_BFD_CLIENT_DEREGISTER),
DESC_ENTRY(ZEBRA_INTERFACE_ENABLE_RADV),
DESC_ENTRY(ZEBRA_INTERFACE_DISABLE_RADV),
DESC_ENTRY(ZEBRA_IPV4_NEXTHOP_LOOKUP_MRIB),
DESC_ENTRY(ZEBRA_NEXTHOP_LOOKUP_MRIB),
DESC_ENTRY(ZEBRA_INTERFACE_LINK_PARAMS),
DESC_ENTRY(ZEBRA_MPLS_LABELS_ADD),
DESC_ENTRY(ZEBRA_MPLS_LABELS_DELETE),

View File

@ -143,7 +143,7 @@ typedef enum {
ZEBRA_BFD_CLIENT_DEREGISTER,
ZEBRA_INTERFACE_ENABLE_RADV,
ZEBRA_INTERFACE_DISABLE_RADV,
ZEBRA_IPV4_NEXTHOP_LOOKUP_MRIB,
ZEBRA_NEXTHOP_LOOKUP_MRIB,
ZEBRA_INTERFACE_LINK_PARAMS,
ZEBRA_MPLS_LABELS_ADD,
ZEBRA_MPLS_LABELS_DELETE,

View File

@ -165,7 +165,7 @@ static int zclient_read_nexthop(struct pim_instance *pim,
uint8_t version;
vrf_id_t vrf_id;
uint16_t command = 0;
pim_addr raddr;
struct ipaddr raddr;
uint8_t distance;
uint32_t metric;
int nexthop_num;
@ -177,7 +177,7 @@ static int zclient_read_nexthop(struct pim_instance *pim,
s = zlookup->ibuf;
while (command != ZEBRA_IPV4_NEXTHOP_LOOKUP_MRIB) {
while (command != ZEBRA_NEXTHOP_LOOKUP_MRIB) {
stream_reset(s);
err = zclient_read_header(s, zlookup->sock, &length, &marker,
&version, &vrf_id, &command);
@ -197,13 +197,11 @@ static int zclient_read_nexthop(struct pim_instance *pim,
}
}
#if PIM_IPV == 4
raddr.s_addr = stream_get_ipv4(s);
#else
stream_get(&raddr, s, sizeof(struct in6_addr));
#endif
if (pim_addr_cmp(raddr, addr))
zlog_warn("%s: address mismatch: addr=%pPAs(%s) raddr=%pPAs",
stream_get_ipaddr(s, &raddr);
if (raddr.ipa_type != IPADDR_V4 ||
raddr.ipaddr_v4.s_addr != addr.s_addr)
zlog_warn("%s: address mismatch: addr=%pPA(%s) raddr=%pIA",
__func__, &addr, pim->vrf->name, &raddr);
/* warning only */
@ -308,6 +306,7 @@ static int zclient_lookup_nexthop_once(struct pim_instance *pim,
{
struct stream *s;
int ret;
struct ipaddr ipaddr;
if (PIM_DEBUG_PIM_NHT_DETAIL)
zlog_debug("%s: addr=%pPAs(%s)", __func__, &addr,
@ -329,15 +328,13 @@ static int zclient_lookup_nexthop_once(struct pim_instance *pim,
return -1;
}
ipaddr.ipa_type = IPADDR_V4;
ipaddr.ipaddr_v4 = addr;
s = zlookup->obuf;
stream_reset(s);
zclient_create_header(s, ZEBRA_IPV4_NEXTHOP_LOOKUP_MRIB,
pim->vrf->vrf_id);
#if PIM_IPV == 4
stream_put_in_addr(s, &addr);
#else
stream_write(s, (uint8_t *)&addr, 16);
#endif
zclient_create_header(s, ZEBRA_NEXTHOP_LOOKUP_MRIB, pim->vrf->vrf_id);
stream_put_ipaddr(s, &ipaddr);
stream_putw_at(s, 0, stream_get_endp(s));
ret = writen(zlookup->sock, s->data, stream_get_endp(s));

View File

@ -659,11 +659,18 @@ int zsend_redistribute_route(int cmd, struct zserv *client,
* Modified version of zsend_ipv4_nexthop_lookup(): Query unicast rib if
* nexthop is not found on mrib. Returns both route metric and protocol
* distance.
*
* *XXX* this ZAPI call is slated to be removed at some point in the future
* since MRIB support in PIM is hopelessly broken in its interactions with NHT.
* The plan is to make pimd use NHT to receive URIB and MRIB in parallel and
* make the decision there, which will obsolete this ZAPI op.
* (Otherwise we would need to implement sending NHT updates for the result of
* this "URIB-MRIB-combined" table, but we only decide that here on the fly,
* so it'd be rather complex to do NHT for.)
*/
static int zsend_ipv4_nexthop_lookup_mrib(struct zserv *client,
struct in_addr addr,
struct route_entry *re,
struct zebra_vrf *zvrf)
static int zsend_nexthop_lookup_mrib(struct zserv *client, struct ipaddr *addr,
struct route_entry *re,
struct zebra_vrf *zvrf)
{
struct stream *s;
unsigned long nump;
@ -675,8 +682,8 @@ static int zsend_ipv4_nexthop_lookup_mrib(struct zserv *client,
stream_reset(s);
/* Fill in result. */
zclient_create_header(s, ZEBRA_IPV4_NEXTHOP_LOOKUP_MRIB, zvrf_id(zvrf));
stream_put_in_addr(s, &addr);
zclient_create_header(s, ZEBRA_NEXTHOP_LOOKUP_MRIB, zvrf_id(zvrf));
stream_put_ipaddr(s, addr);
if (re) {
struct nexthop_group *nhg;
@ -2229,14 +2236,28 @@ static void zread_route_del(ZAPI_HANDLER_ARGS)
}
/* MRIB Nexthop lookup for IPv4. */
static void zread_ipv4_nexthop_lookup_mrib(ZAPI_HANDLER_ARGS)
static void zread_nexthop_lookup_mrib(ZAPI_HANDLER_ARGS)
{
struct in_addr addr;
struct route_entry *re;
struct ipaddr addr;
struct route_entry *re = NULL;
STREAM_GET(&addr.s_addr, msg, IPV4_MAX_BYTELEN);
re = rib_match_ipv4_multicast(zvrf_id(zvrf), addr, NULL);
zsend_ipv4_nexthop_lookup_mrib(client, addr, re, zvrf);
STREAM_GET_IPADDR(msg, &addr);
switch (addr.ipa_type) {
case IPADDR_V4:
re = rib_match_ipv4_multicast(zvrf_id(zvrf), addr.ipaddr_v4,
NULL);
break;
case IPADDR_V6:
re = rib_match_ipv6_multicast(zvrf_id(zvrf), addr.ipaddr_v6,
NULL);
break;
case IPADDR_NONE:
/* ??? */
goto stream_failure;
}
zsend_nexthop_lookup_mrib(client, &addr, re, zvrf);
stream_failure:
return;
@ -3685,7 +3706,7 @@ void (*const zserv_handlers[])(ZAPI_HANDLER_ARGS) = {
[ZEBRA_REDISTRIBUTE_DELETE] = zebra_redistribute_delete,
[ZEBRA_REDISTRIBUTE_DEFAULT_ADD] = zebra_redistribute_default_add,
[ZEBRA_REDISTRIBUTE_DEFAULT_DELETE] = zebra_redistribute_default_delete,
[ZEBRA_IPV4_NEXTHOP_LOOKUP_MRIB] = zread_ipv4_nexthop_lookup_mrib,
[ZEBRA_NEXTHOP_LOOKUP_MRIB] = zread_nexthop_lookup_mrib,
[ZEBRA_HELLO] = zread_hello,
[ZEBRA_NEXTHOP_REGISTER] = zread_rnh_register,
[ZEBRA_NEXTHOP_UNREGISTER] = zread_rnh_unregister,