Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

*: Use a struct prefix *p instead of a struct prefix in functions #13162

Merged
merged 1 commit into from
Apr 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions isisd/isis_te.c
Original file line number Diff line number Diff line change
Expand Up @@ -1077,7 +1077,7 @@ static int lsp_to_subnet_cb(const struct prefix *prefix, uint32_t metric,
prefix_copy(&p, prefix);
else {
/* Remove old subnet if any before prefix adjustment */
subnet = ls_find_subnet(args->ted, *prefix);
subnet = ls_find_subnet(args->ted, prefix);
if (subnet) {
if (args->export) {
subnet->status = DELETE;
Expand All @@ -1092,10 +1092,10 @@ static int lsp_to_subnet_cb(const struct prefix *prefix, uint32_t metric,
}

/* Search existing Subnet in TED ... */
subnet = ls_find_subnet(args->ted, p);
subnet = ls_find_subnet(args->ted, &p);
/* ... and create a new Subnet if not found */
if (!subnet) {
ls_pref = ls_prefix_new(vertex->node->adv, p);
ls_pref = ls_prefix_new(vertex->node->adv, &p);
subnet = ls_subnet_add(args->ted, ls_pref);
/* Stop processing if we are unable to create a new subnet */
if (!subnet)
Expand Down Expand Up @@ -1835,7 +1835,7 @@ static int show_ted(struct vty *vty, struct cmd_token *argv[], int argc,
return CMD_WARNING_CONFIG_FAILED;
}
/* Get the Subnet from the Link State Database */
subnet = ls_find_subnet(ted, pref);
subnet = ls_find_subnet(ted, &pref);
if (!subnet) {
vty_out(vty, "No subnet found for ID %pFX\n",
&pref);
Expand All @@ -1848,7 +1848,7 @@ static int show_ted(struct vty *vty, struct cmd_token *argv[], int argc,
return CMD_WARNING_CONFIG_FAILED;
}
/* Get the Subnet from the Link State Database */
subnet = ls_find_subnet(ted, pref);
subnet = ls_find_subnet(ted, &pref);
if (!subnet) {
vty_out(vty, "No subnet found for ID %pFX\n",
&pref);
Expand Down
13 changes: 7 additions & 6 deletions lib/link_state.c
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ int ls_attributes_same(struct ls_attributes *l1, struct ls_attributes *l2)
/**
* Link State prefix management functions
*/
struct ls_prefix *ls_prefix_new(struct ls_node_id adv, struct prefix p)
struct ls_prefix *ls_prefix_new(struct ls_node_id adv, struct prefix *p)
{
struct ls_prefix *new;

Expand All @@ -342,7 +342,7 @@ struct ls_prefix *ls_prefix_new(struct ls_node_id adv, struct prefix p)

new = XCALLOC(MTYPE_LS_DB, sizeof(struct ls_prefix));
new->adv = adv;
new->pref = p;
new->pref = *p;

return new;
}
Expand Down Expand Up @@ -889,7 +889,7 @@ struct ls_subnet *ls_subnet_update(struct ls_ted *ted, struct ls_prefix *pref)
if (pref == NULL)
return NULL;

old = ls_find_subnet(ted, pref->pref);
old = ls_find_subnet(ted, &pref->pref);
if (old) {
if (!ls_prefix_same(old->ls_pref, pref)) {
ls_prefix_del(old->ls_pref);
Expand Down Expand Up @@ -942,11 +942,12 @@ void ls_subnet_del_all(struct ls_ted *ted, struct ls_subnet *subnet)
ls_subnet_del(ted, subnet);
}

struct ls_subnet *ls_find_subnet(struct ls_ted *ted, const struct prefix prefix)
struct ls_subnet *ls_find_subnet(struct ls_ted *ted,
const struct prefix *prefix)
{
struct ls_subnet subnet = {};

subnet.key = prefix;
subnet.key = *prefix;
return subnets_find(&ted->subnets, &subnet);
}

Expand Down Expand Up @@ -1846,7 +1847,7 @@ struct ls_subnet *ls_msg2subnet(struct ls_ted *ted, struct ls_message *msg,
subnet->status = UPDATE;
break;
case LS_MSG_EVENT_DELETE:
subnet = ls_find_subnet(ted, pref->pref);
subnet = ls_find_subnet(ted, &pref->pref);
if (subnet) {
if (delete)
ls_subnet_del_all(ted, subnet);
Expand Down
4 changes: 2 additions & 2 deletions lib/link_state.h
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ extern int ls_attributes_same(struct ls_attributes *a1,
*
* @return New Link State Prefix
*/
extern struct ls_prefix *ls_prefix_new(struct ls_node_id adv, struct prefix p);
extern struct ls_prefix *ls_prefix_new(struct ls_node_id adv, struct prefix *p);

/**
* Remove Link State Prefix. Data Structure is freed.
Expand Down Expand Up @@ -709,7 +709,7 @@ extern void ls_subnet_del_all(struct ls_ted *ted, struct ls_subnet *subnet);
* @return Subnet if found, NULL otherwise
*/
extern struct ls_subnet *ls_find_subnet(struct ls_ted *ted,
const struct prefix prefix);
const struct prefix *prefix);

/**
* Create a new Link State Data Base.
Expand Down
20 changes: 10 additions & 10 deletions ospfd/ospf_te.c
Original file line number Diff line number Diff line change
Expand Up @@ -1781,7 +1781,7 @@ static void ospf_te_update_link(struct ls_ted *ted, struct ls_vertex *vertex,
* @param metric Standard metric attached to this Edge
*/
static void ospf_te_update_subnet(struct ls_ted *ted, struct ls_vertex *vertex,
struct prefix p, uint8_t metric)
struct prefix *p, uint8_t metric)
{
struct ls_subnet *subnet;
struct ls_prefix *ls_pref;
Expand Down Expand Up @@ -1840,7 +1840,7 @@ static void ospf_te_delete_subnet(struct ls_ted *ted, struct in_addr addr)
p.family = AF_INET;
p.prefixlen = IPV4_MAX_BITLEN;
p.u.prefix4 = addr;
subnet = ls_find_subnet(ted, p);
subnet = ls_find_subnet(ted, &p);

/* Remove subnet if found */
if (subnet) {
Expand Down Expand Up @@ -1933,7 +1933,7 @@ static int ospf_te_parse_router_lsa(struct ls_ted *ted, struct ospf_lsa *lsa)
p.prefixlen = IPV4_MAX_BITLEN;
p.u.prefix4 = rl->link[i].link_data;
metric = ntohs(rl->link[i].metric);
ospf_te_update_subnet(ted, vertex, p, metric);
ospf_te_update_subnet(ted, vertex, &p, metric);
break;
case LSA_LINK_TYPE_STUB:
/* Keep only /32 prefix */
Expand All @@ -1942,7 +1942,7 @@ static int ospf_te_parse_router_lsa(struct ls_ted *ted, struct ospf_lsa *lsa)
p.family = AF_INET;
p.u.prefix4 = rl->link[i].link_id;
metric = ntohs(rl->link[i].metric);
ospf_te_update_subnet(ted, vertex, p, metric);
ospf_te_update_subnet(ted, vertex, &p, metric);
}
break;
default:
Expand Down Expand Up @@ -2074,12 +2074,12 @@ static void ospf_te_update_remote_asbr(struct ls_ted *ted, struct ls_edge *edge)
p.family = AF_INET;
p.prefixlen = IPV4_MAX_BITLEN;
p.u.prefix4 = attr->standard.local;
ospf_te_update_subnet(ted, edge->source, p, attr->standard.te_metric);
ospf_te_update_subnet(ted, edge->source, &p, attr->standard.te_metric);

p.family = AF_INET;
p.prefixlen = IPV4_MAX_BITLEN;
p.u.prefix4 = attr->standard.remote_addr;
ospf_te_update_subnet(ted, vertex, p, attr->standard.te_metric);
ospf_te_update_subnet(ted, vertex, &p, attr->standard.te_metric);

/* Connect Edge to the remote Vertex */
if (edge->destination == NULL) {
Expand Down Expand Up @@ -2625,14 +2625,14 @@ static int ospf_te_parse_ext_pref(struct ls_ted *ted, struct ospf_lsa *lsa)
pref.family = AF_INET;
pref.prefixlen = ext->pref_length;
pref.u.prefix4 = ext->address;
subnet = ls_find_subnet(ted, pref);
subnet = ls_find_subnet(ted, &pref);

/* Create new Link State Prefix if not found */
if (!subnet) {
lnid.origin = OSPFv2;
lnid.id.ip.addr = lsa->data->adv_router;
lnid.id.ip.area_id = lsa->area->area_id;
ls_pref = ls_prefix_new(lnid, pref);
ls_pref = ls_prefix_new(lnid, &pref);
/* and add it to the TED */
subnet = ls_subnet_add(ted, ls_pref);
}
Expand Down Expand Up @@ -2698,7 +2698,7 @@ static int ospf_te_delete_ext_pref(struct ls_ted *ted, struct ospf_lsa *lsa)
pref.family = AF_INET;
pref.prefixlen = ext->pref_length;
pref.u.prefix4 = ext->address;
subnet = ls_find_subnet(ted, pref);
subnet = ls_find_subnet(ted, &pref);

/* Check if there is a corresponding subnet */
if (!subnet)
Expand Down Expand Up @@ -4398,7 +4398,7 @@ DEFUN (show_ip_ospf_mpls_te_db,
return CMD_WARNING_CONFIG_FAILED;
}
/* Get the Subnet from the Link State Database */
subnet = ls_find_subnet(OspfMplsTE.ted, pref);
subnet = ls_find_subnet(OspfMplsTE.ted, &pref);
if (!subnet) {
vty_out(vty, "No subnet found for ID %pFX\n",
&pref);
Expand Down
4 changes: 2 additions & 2 deletions pathd/path_ted.c
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ uint32_t path_ted_query_type_c(struct prefix *prefix, uint8_t algo)
switch (prefix->family) {
case AF_INET:
case AF_INET6:
subnet = ls_find_subnet(ted_state_g.ted, *prefix);
subnet = ls_find_subnet(ted_state_g.ted, prefix);
if (subnet) {
if ((CHECK_FLAG(subnet->ls_pref->flags, LS_PREF_SR))
&& (subnet->ls_pref->sr.algo == algo))
Expand Down Expand Up @@ -298,7 +298,7 @@ uint32_t path_ted_query_type_e(struct prefix *prefix, uint32_t iface_id)
switch (prefix->family) {
case AF_INET:
case AF_INET6:
subnet = ls_find_subnet(ted_state_g.ted, *prefix);
subnet = ls_find_subnet(ted_state_g.ted, prefix);
if (subnet && subnet->vertex
&& subnet->vertex->outgoing_edges) {
/* from the vertex linked in subnet */
Expand Down
2 changes: 1 addition & 1 deletion sharpd/sharp_vty.c
Original file line number Diff line number Diff line change
Expand Up @@ -1059,7 +1059,7 @@ DEFUN (show_sharp_ted,
return CMD_WARNING_CONFIG_FAILED;
}
/* Get the Subnet from the Link State Database */
subnet = ls_find_subnet(sg.ted, pref);
subnet = ls_find_subnet(sg.ted, &pref);
if (!subnet) {
vty_out(vty, "No subnet found for ID %pFX\n",
&pref);
Expand Down