summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpaul <paul>2003-10-15 21:14:20 +0000
committerpaul <paul>2003-10-15 21:14:20 +0000
commit20916fba5c5aac8146d780a849083ca88f804511 (patch)
tree86a741c2e1f534c6fa66269b56896661540d8702
parentcccf8af8963e0f9cb862def616316288cabd0e47 (diff)
2003-10-15 Paul Jakma <paul@dishone.st>
* ospfd/ospf_interface: (ospf_if_lookup_table) new function to lookup oi for a given prefix in a given interfaces table of oi's. (ospf_if_new) use ospf_if_lookup_table to deal with zebra reporting new interface multiple times. NB: This patch is a complete plaster-band of a hack. First, why is zebra reporting interface events multiple times? Second, why does ospfd maintain so many damn lists and tables relating to oi's - these should be reconciled into one or two tables.
-rw-r--r--ospfd/ospf_interface.c28
1 files changed, 24 insertions, 4 deletions
diff --git a/ospfd/ospf_interface.c b/ospfd/ospf_interface.c
index 067d551d..4be81995 100644
--- a/ospfd/ospf_interface.c
+++ b/ospfd/ospf_interface.c
@@ -125,6 +125,21 @@ ospf_if_reset_variables (struct ospf_interface *oi)
oi->v_ls_ack = 1;
}
+/* lookup oi for specified prefix/ifp */
+struct ospf_interface *
+ospf_if_table_lookup (struct interface *ifp, struct prefix *prefix)
+{
+ struct prefix p;
+ struct route_node rn;
+
+ p = *prefix;
+
+ rn = route_node_get (IF_OIFS (ifp), &p));
+ /* route_node_get implicitely locks */
+ route_node_unlock (rn);
+ return (struct ospf_interface *) rn->info;
+}
+
void
ospf_add_to_if (struct interface *ifp, struct ospf_interface *oi)
{
@@ -138,7 +153,7 @@ ospf_add_to_if (struct interface *ifp, struct ospf_interface *oi)
/* rn->info should either be NULL or equal to this oi
* as route_node_get may return an existing node
*/
- assert (! rn->info || rn->info == oi);
+ assert (!rn->info || rn->info == oi);
rn->info = oi;
}
@@ -164,9 +179,14 @@ ospf_if_new (struct ospf *ospf, struct interface *ifp, struct prefix *p)
{
struct ospf_interface *oi;
- oi = XCALLOC (MTYPE_OSPF_IF, sizeof (struct ospf_interface));
- memset (oi, 0, sizeof (struct ospf_interface));
-
+ if ((oi = ospf_if_table_lookup (ifp, p)) == NULL)
+ {
+ oi = XCALLOC (MTYPE_OSPF_IF, sizeof (struct ospf_interface));
+ memset (oi, 0, sizeof (struct ospf_interface));
+ }
+ else
+ return oi;
+
/* Set zebra interface pointer. */
oi->ifp = ifp;
oi->address = p;