diff options
-rw-r--r-- | doc/developer/zebra.rst | 2 | ||||
-rw-r--r-- | lib/log.c | 2 | ||||
-rw-r--r-- | lib/zclient.h | 2 | ||||
-rw-r--r-- | pimd/pim_zlookup.c | 29 | ||||
-rw-r--r-- | zebra/zapi_msg.c | 47 |
5 files changed, 50 insertions, 32 deletions
diff --git a/doc/developer/zebra.rst b/doc/developer/zebra.rst index d51cbc9a1..cef53f1cb 100644 --- a/doc/developer/zebra.rst +++ b/doc/developer/zebra.rst @@ -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 | +------------------------------------+-------+ @@ -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), diff --git a/lib/zclient.h b/lib/zclient.h index 7e1283d83..78eb73c53 100644 --- a/lib/zclient.h +++ b/lib/zclient.h @@ -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, diff --git a/pimd/pim_zlookup.c b/pimd/pim_zlookup.c index c3f0b4443..79969ce9f 100644 --- a/pimd/pim_zlookup.c +++ b/pimd/pim_zlookup.c @@ -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)); diff --git a/zebra/zapi_msg.c b/zebra/zapi_msg.c index fd475e4ce..e996f6c95 100644 --- a/zebra/zapi_msg.c +++ b/zebra/zapi_msg.c @@ -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_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; + } - 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); + 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, |