isisd: Update TE to new Link State Edge key

Following the modification of the edge key in link state database
this patch updates the isis_te.c file to replace the old uint64_t edge key by
the new ls_edge_key structure.

Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>
This commit is contained in:
Olivier Dugeon 2023-03-01 12:24:46 +01:00
parent dad17a2195
commit 7564fcb8f9

View File

@ -657,7 +657,7 @@ static struct ls_edge *get_edge(struct ls_ted *ted, struct ls_attributes *attr)
{ {
struct ls_edge *edge; struct ls_edge *edge;
struct ls_standard *std; struct ls_standard *std;
uint64_t key = 0; struct ls_edge_key key;
/* Check parameters */ /* Check parameters */
if (!ted || !attr) if (!ted || !attr)
@ -666,19 +666,22 @@ static struct ls_edge *get_edge(struct ls_ted *ted, struct ls_attributes *attr)
std = &attr->standard; std = &attr->standard;
/* Compute keys in function of local address (IPv4/v6) or identifier */ /* Compute keys in function of local address (IPv4/v6) or identifier */
if (CHECK_FLAG(attr->flags, LS_ATTR_LOCAL_ADDR)) if (CHECK_FLAG(attr->flags, LS_ATTR_LOCAL_ADDR)) {
key = ((uint64_t)ntohl(std->local.s_addr)) & 0xffffffff; key.family = AF_INET;
else if (CHECK_FLAG(attr->flags, LS_ATTR_LOCAL_ADDR6)) IPV4_ADDR_COPY(&key.k.addr, &std->local);
key = ((uint64_t)ntohl(std->local6.s6_addr32[2]) << 32 } else if (CHECK_FLAG(attr->flags, LS_ATTR_LOCAL_ADDR6)) {
| (uint64_t)ntohl(std->local6.s6_addr32[3])); key.family = AF_INET6;
else if (CHECK_FLAG(attr->flags, LS_ATTR_LOCAL_ID)) IPV6_ADDR_COPY(&key.k.addr6, &std->local6);
key = ((uint64_t)std->remote_id << 32) } else if (CHECK_FLAG(attr->flags, LS_ATTR_LOCAL_ID)) {
| (((uint64_t)std->local_id) & 0xffffffff); key.family = AF_LOCAL;
else key.k.link_id = (((uint64_t)std->local_id) & 0xffffffff) |
key = 0; ((uint64_t)std->remote_id << 32);
} else {
key.family = AF_UNSPEC;
}
/* Stop here if we don't got a valid key */ /* Stop here if we don't got a valid key */
if (key == 0) if (key.family == AF_UNSPEC)
return NULL; return NULL;
/* Get corresponding Edge by key from Link State Data Base */ /* Get corresponding Edge by key from Link State Data Base */
@ -697,18 +700,17 @@ static struct ls_edge *get_edge(struct ls_ted *ted, struct ls_attributes *attr)
} }
if (CHECK_FLAG(edge->attributes->flags, LS_ATTR_LOCAL_ADDR)) if (CHECK_FLAG(edge->attributes->flags, LS_ATTR_LOCAL_ADDR))
te_debug(" |- %s Edge (%" PRIu64 te_debug(" |- %s Edge (%pI4) from Extended Reach. %pI4",
") from Extended Reach. %pI4", edge->status == NEW ? "Create" : "Found",
edge->status == NEW ? "Create" : "Found", edge->key, &edge->key.k.addr, &attr->standard.local);
&attr->standard.local);
else if (CHECK_FLAG(edge->attributes->flags, LS_ATTR_LOCAL_ADDR6)) else if (CHECK_FLAG(edge->attributes->flags, LS_ATTR_LOCAL_ADDR6))
te_debug(" |- %s Edge (%" PRIu64 te_debug(" |- %s Edge (%pI6) from Extended Reach. %pI6",
") from Extended Reach. %pI6", edge->status == NEW ? "Create" : "Found",
edge->status == NEW ? "Create" : "Found", edge->key, &edge->key.k.addr6, &attr->standard.local6);
&attr->standard.local6);
else else
te_debug(" |- %s Edge (%" PRIu64 ")", te_debug(" |- %s Edge (%" PRIu64 ")",
edge->status == NEW ? "Create" : "Found", edge->key); edge->status == NEW ? "Create" : "Found",
edge->key.k.link_id);
return edge; return edge;
} }
@ -950,8 +952,21 @@ static int lsp_to_edge_cb(const uint8_t *id, uint32_t metric, bool old_metric,
} }
/* Try to update remote Link from remote address or reachability ID */ /* Try to update remote Link from remote address or reachability ID */
te_debug(" |- Link Edge (%" PRIu64 ") to destination vertex (%s)", if (edge->key.family == AF_INET)
edge->key, print_sys_hostname(id)); te_debug(" |- Link Edge (%pI4) to destination vertex (%s)",
&edge->key.k.addr, print_sys_hostname(id));
else if (edge->key.family == AF_INET6)
te_debug(" |- Link Edge (%pI6) to destination vertex (%s)",
&edge->key.k.addr6, print_sys_hostname(id));
else if (edge->key.family == AF_LOCAL)
te_debug(" |- Link Edge (%" PRIu64
") to destination vertex (%s)",
edge->key.k.link_id, print_sys_hostname(id));
else
te_debug(
" |- Link Edge (Unknown) to destination vertex (%s)",
print_sys_hostname(id));
dst = ls_find_edge_by_destination(args->ted, edge->attributes); dst = ls_find_edge_by_destination(args->ted, edge->attributes);
if (dst) { if (dst) {
/* Attach remote link if not set */ /* Attach remote link if not set */
@ -1741,7 +1756,7 @@ static int show_ted(struct vty *vty, struct cmd_token *argv[], int argc,
struct ls_vertex *vertex; struct ls_vertex *vertex;
struct ls_edge *edge; struct ls_edge *edge;
struct ls_subnet *subnet; struct ls_subnet *subnet;
uint64_t key; struct ls_edge_key key;
bool detail = false; bool detail = false;
bool uj = use_json(argc, argv); bool uj = use_json(argc, argv);
json_object *json = NULL; json_object *json = NULL;
@ -1795,7 +1810,8 @@ static int show_ted(struct vty *vty, struct cmd_token *argv[], int argc,
return CMD_WARNING_CONFIG_FAILED; return CMD_WARNING_CONFIG_FAILED;
} }
/* Get the Edge from the Link State Database */ /* Get the Edge from the Link State Database */
key = ((uint64_t)ntohl(ip_addr.s_addr)) & 0xffffffff; key.family = AF_INET;
IPV4_ADDR_COPY(&key.k.addr, &ip_addr);
edge = ls_find_edge_by_key(ted, key); edge = ls_find_edge_by_key(ted, key);
if (!edge) { if (!edge) {
vty_out(vty, "No edge found for ID %pI4\n", vty_out(vty, "No edge found for ID %pI4\n",
@ -1810,8 +1826,8 @@ static int show_ted(struct vty *vty, struct cmd_token *argv[], int argc,
return CMD_WARNING_CONFIG_FAILED; return CMD_WARNING_CONFIG_FAILED;
} }
/* Get the Edge from the Link State Database */ /* Get the Edge from the Link State Database */
key = (uint64_t)ntohl(ip6_addr.s6_addr32[3]) key.family = AF_INET6;
| ((uint64_t)ntohl(ip6_addr.s6_addr32[2]) << 32); IPV6_ADDR_COPY(&key.k.addr6, &ip6_addr);
edge = ls_find_edge_by_key(ted, key); edge = ls_find_edge_by_key(ted, key);
if (!edge) { if (!edge) {
vty_out(vty, "No edge found for ID %pI6\n", vty_out(vty, "No edge found for ID %pI6\n",