mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-04-30 13:14:46 +00:00
ospfd: Change struct ospf_path *oi to ifindex.
* global: In struct ospf_path, change struct ospf_interface *oi to int ifindex. It is unsafe to reference *oi as an ospf interface can be deleted under your feet. Use a weak reference instead.
This commit is contained in:
parent
bd5403778b
commit
a8ba847ff9
@ -814,15 +814,12 @@ ospf_abr_nexthops_belong_to_area (struct ospf_route *or,
|
|||||||
{
|
{
|
||||||
struct listnode *node, *nnode;
|
struct listnode *node, *nnode;
|
||||||
struct ospf_path *path;
|
struct ospf_path *path;
|
||||||
|
struct ospf_interface *oi;
|
||||||
|
|
||||||
for (ALL_LIST_ELEMENTS (or->paths, node, nnode, path))
|
for (ALL_LIST_ELEMENTS_RO (or->paths, node, path))
|
||||||
{
|
for (ALL_LIST_ELEMENTS_RO (area->oiflist, nnode, oi))
|
||||||
struct ospf_interface *oi = path->oi;
|
if (oi->ifp && oi->ifp->ifindex == path->ifindex)
|
||||||
|
return 1;
|
||||||
if (oi != NULL)
|
|
||||||
if (oi->area == area)
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -135,6 +135,7 @@ ospf_ase_complete_direct_routes (struct ospf_route *ro, struct in_addr nexthop)
|
|||||||
{
|
{
|
||||||
struct listnode *node;
|
struct listnode *node;
|
||||||
struct ospf_path *op;
|
struct ospf_path *op;
|
||||||
|
struct interface *ifp;
|
||||||
|
|
||||||
for (ALL_LIST_ELEMENTS_RO (ro->paths, node, op))
|
for (ALL_LIST_ELEMENTS_RO (ro->paths, node, op))
|
||||||
if (op->nexthop.s_addr == 0)
|
if (op->nexthop.s_addr == 0)
|
||||||
@ -593,7 +594,7 @@ ospf_ase_route_match_same (struct route_table *rt, struct prefix *prefix,
|
|||||||
|
|
||||||
if (! IPV4_ADDR_SAME (&op->nexthop, &newop->nexthop))
|
if (! IPV4_ADDR_SAME (&op->nexthop, &newop->nexthop))
|
||||||
return 0;
|
return 0;
|
||||||
if (op->oi->ifp->ifindex != newop->oi->ifp->ifindex)
|
if (op->ifindex != newop->ifindex)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -165,7 +165,7 @@ ospf_route_match_same (struct route_table *rt, struct prefix_ipv4 *prefix,
|
|||||||
|
|
||||||
if (! IPV4_ADDR_SAME (&op->nexthop, &newop->nexthop))
|
if (! IPV4_ADDR_SAME (&op->nexthop, &newop->nexthop))
|
||||||
return 0;
|
return 0;
|
||||||
if (op->oi->ifp->ifindex != newop->oi->ifp->ifindex)
|
if (op->ifindex != newop->ifindex)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
@ -640,7 +640,7 @@ ospf_intra_add_stub (struct route_table *rt, struct router_lsa_link *link,
|
|||||||
|
|
||||||
path = ospf_path_new ();
|
path = ospf_path_new ();
|
||||||
path->nexthop.s_addr = 0;
|
path->nexthop.s_addr = 0;
|
||||||
path->oi = oi;
|
path->ifindex = oi->ifp->ifindex;
|
||||||
listnode_add (or->paths, path);
|
listnode_add (or->paths, path);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -788,7 +788,8 @@ ospf_path_exist (struct list *plist, struct in_addr nexthop,
|
|||||||
struct ospf_path *path;
|
struct ospf_path *path;
|
||||||
|
|
||||||
for (ALL_LIST_ELEMENTS (plist, node, nnode, path))
|
for (ALL_LIST_ELEMENTS (plist, node, nnode, path))
|
||||||
if (IPV4_ADDR_SAME (&path->nexthop, &nexthop) && path->oi == oi)
|
if (IPV4_ADDR_SAME (&path->nexthop, &nexthop) &&
|
||||||
|
path->ifindex == oi->ifp->ifindex)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -815,7 +816,7 @@ ospf_route_copy_nexthops_from_vertex (struct ospf_route *to,
|
|||||||
{
|
{
|
||||||
path = ospf_path_new ();
|
path = ospf_path_new ();
|
||||||
path->nexthop = nexthop->router;
|
path->nexthop = nexthop->router;
|
||||||
path->oi = nexthop->oi;
|
path->ifindex = nexthop->oi->ifp->ifindex;
|
||||||
listnode_add (to->paths, path);
|
listnode_add (to->paths, path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -834,7 +835,7 @@ ospf_path_lookup (struct list *plist, struct ospf_path *path)
|
|||||||
continue;
|
continue;
|
||||||
if (!IPV4_ADDR_SAME (&op->adv_router, &path->adv_router))
|
if (!IPV4_ADDR_SAME (&op->adv_router, &path->adv_router))
|
||||||
continue;
|
continue;
|
||||||
if (op->oi->ifp->ifindex != path->oi->ifp->ifindex)
|
if (op->ifindex != path->ifindex)
|
||||||
continue;
|
continue;
|
||||||
return op;
|
return op;
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,7 @@ struct ospf_path
|
|||||||
{
|
{
|
||||||
struct in_addr nexthop;
|
struct in_addr nexthop;
|
||||||
struct in_addr adv_router;
|
struct in_addr adv_router;
|
||||||
struct ospf_interface *oi;
|
unsigned int ifindex;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Below is the structure linked to every
|
/* Below is the structure linked to every
|
||||||
|
@ -1077,13 +1077,14 @@ ospf_rtrs_print (struct route_table *rtrs)
|
|||||||
{
|
{
|
||||||
if (IS_DEBUG_OSPF_EVENT)
|
if (IS_DEBUG_OSPF_EVENT)
|
||||||
zlog_debug (" directly attached to %s\r\n",
|
zlog_debug (" directly attached to %s\r\n",
|
||||||
IF_NAME (path->oi));
|
ifindex2ifname (path->ifindex));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (IS_DEBUG_OSPF_EVENT)
|
if (IS_DEBUG_OSPF_EVENT)
|
||||||
zlog_debug (" via %s, %s\r\n",
|
zlog_debug (" via %s, %s\r\n",
|
||||||
inet_ntoa (path->nexthop), IF_NAME (path->oi));
|
inet_ntoa (path->nexthop),
|
||||||
|
ifindex2ifname (path->ifindex));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7138,15 +7138,15 @@ show_ip_ospf_route_network (struct vty *vty, struct route_table *rt)
|
|||||||
if (or->type == OSPF_DESTINATION_NETWORK)
|
if (or->type == OSPF_DESTINATION_NETWORK)
|
||||||
for (ALL_LIST_ELEMENTS (or->paths, pnode, pnnode, path))
|
for (ALL_LIST_ELEMENTS (or->paths, pnode, pnnode, path))
|
||||||
{
|
{
|
||||||
if (path->oi != NULL && ospf_if_exists(path->oi))
|
if (if_lookup_by_index(path->ifindex))
|
||||||
{
|
{
|
||||||
if (path->nexthop.s_addr == 0)
|
if (path->nexthop.s_addr == 0)
|
||||||
vty_out (vty, "%24s directly attached to %s%s",
|
vty_out (vty, "%24s directly attached to %s%s",
|
||||||
"", path->oi->ifp->name, VTY_NEWLINE);
|
"", ifindex2ifname (path->ifindex), VTY_NEWLINE);
|
||||||
else
|
else
|
||||||
vty_out (vty, "%24s via %s, %s%s", "",
|
vty_out (vty, "%24s via %s, %s%s", "",
|
||||||
inet_ntoa (path->nexthop), path->oi->ifp->name,
|
inet_ntoa (path->nexthop),
|
||||||
VTY_NEWLINE);
|
ifindex2ifname (path->ifindex), VTY_NEWLINE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -7188,15 +7188,17 @@ show_ip_ospf_route_router (struct vty *vty, struct route_table *rtrs)
|
|||||||
|
|
||||||
for (ALL_LIST_ELEMENTS_RO (or->paths, pnode, path))
|
for (ALL_LIST_ELEMENTS_RO (or->paths, pnode, path))
|
||||||
{
|
{
|
||||||
if (path->oi != NULL && ospf_if_exists(path->oi))
|
if (if_lookup_by_index(path->ifindex))
|
||||||
{
|
{
|
||||||
if (path->nexthop.s_addr == 0)
|
if (path->nexthop.s_addr == 0)
|
||||||
vty_out (vty, "%24s directly attached to %s%s",
|
vty_out (vty, "%24s directly attached to %s%s",
|
||||||
"", path->oi->ifp->name, VTY_NEWLINE);
|
"", ifindex2ifname (path->ifindex),
|
||||||
|
VTY_NEWLINE);
|
||||||
else
|
else
|
||||||
vty_out (vty, "%24s via %s, %s%s", "",
|
vty_out (vty, "%24s via %s, %s%s", "",
|
||||||
inet_ntoa (path->nexthop),
|
inet_ntoa (path->nexthop),
|
||||||
path->oi->ifp->name, VTY_NEWLINE);
|
ifindex2ifname (path->ifindex),
|
||||||
|
VTY_NEWLINE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -7235,14 +7237,15 @@ show_ip_ospf_route_external (struct vty *vty, struct route_table *rt)
|
|||||||
|
|
||||||
for (ALL_LIST_ELEMENTS (er->paths, pnode, pnnode, path))
|
for (ALL_LIST_ELEMENTS (er->paths, pnode, pnnode, path))
|
||||||
{
|
{
|
||||||
if (path->oi != NULL && ospf_if_exists(path->oi))
|
if (if_lookup_by_index(path->ifindex))
|
||||||
{
|
{
|
||||||
if (path->nexthop.s_addr == 0)
|
if (path->nexthop.s_addr == 0)
|
||||||
vty_out (vty, "%24s directly attached to %s%s",
|
vty_out (vty, "%24s directly attached to %s%s",
|
||||||
"", path->oi->ifp->name, VTY_NEWLINE);
|
"", ifindex2ifname (path->ifindex), VTY_NEWLINE);
|
||||||
else
|
else
|
||||||
vty_out (vty, "%24s via %s, %s%s", "",
|
vty_out (vty, "%24s via %s, %s%s", "",
|
||||||
inet_ntoa (path->nexthop), path->oi->ifp->name,
|
inet_ntoa (path->nexthop),
|
||||||
|
ifindex2ifname (path->ifindex),
|
||||||
VTY_NEWLINE);
|
VTY_NEWLINE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -378,8 +378,8 @@ ospf_zebra_add (struct prefix_ipv4 *p, struct ospf_route *or)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
stream_putc (s, ZEBRA_NEXTHOP_IFINDEX);
|
stream_putc (s, ZEBRA_NEXTHOP_IFINDEX);
|
||||||
if (path->oi)
|
if (path->ifindex)
|
||||||
stream_putl (s, path->oi->ifp->ifindex);
|
stream_putl (s, path->ifindex);
|
||||||
else
|
else
|
||||||
stream_putl (s, 0);
|
stream_putl (s, 0);
|
||||||
}
|
}
|
||||||
@ -439,11 +439,11 @@ ospf_zebra_delete (struct prefix_ipv4 *p, struct ospf_route *or)
|
|||||||
nexthop = &path->nexthop;
|
nexthop = &path->nexthop;
|
||||||
api.nexthop = &nexthop;
|
api.nexthop = &nexthop;
|
||||||
}
|
}
|
||||||
else if (ospf_if_exists(path->oi) && (path->oi->ifp))
|
else if (if_lookup_by_index(path->ifindex))
|
||||||
{
|
{
|
||||||
SET_FLAG (api.message, ZAPI_MESSAGE_NEXTHOP);
|
SET_FLAG (api.message, ZAPI_MESSAGE_NEXTHOP);
|
||||||
api.ifindex_num = 1;
|
api.ifindex_num = 1;
|
||||||
api.ifindex = &path->oi->ifp->ifindex;
|
api.ifindex = &path->ifindex;
|
||||||
}
|
}
|
||||||
else if ( IS_DEBUG_OSPF(zebra,ZEBRA_REDISTRIBUTE) )
|
else if ( IS_DEBUG_OSPF(zebra,ZEBRA_REDISTRIBUTE) )
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user