[prev in list] [next in list] [prev in thread] [next in thread]
List: quagga-dev
Subject: [quagga-dev 5555] [PATCH 11/11] Clean up ip ospf area command.
From: Joakim Tjernlund <Joakim.Tjernlund () transmode ! se>
Date: 2008-07-02 13:51:39
Message-ID: 1215006699-12383-12-git-send-email-Joakim.Tjernlund () transmode ! se
[Download RAW message or body]
Signed-off-by: Joakim Tjernlund <Joakim.Tjernlund@transmode.se>
---
ospfd/ospfd.c | 172 ++++++++++++++++++++++----------------------------------
1 files changed, 68 insertions(+), 104 deletions(-)
diff --git a/ospfd/ospfd.c b/ospfd/ospfd.c
index 563cf2a..9dc17c2 100644
--- a/ospfd/ospfd.c
+++ b/ospfd/ospfd.c
@@ -715,6 +715,67 @@ ospf_network_new (struct in_addr area_id, int format)
return new;
}
+void add_ospf_interface(struct ospf *ospf, struct interface *ifp,
+ struct ospf_area *area, struct connected *co)
+{
+ struct ospf_interface *oi;
+
+ oi = ospf_if_new (ospf, ifp, co->address);
+ oi->connected = co;
+
+ oi->area = area;
+
+ oi->params = ospf_lookup_if_params (ifp, oi->address->u.prefix4);
+ oi->output_cost = ospf_if_get_output_cost (oi);
+
+ /* Add pseudo neighbor. */
+ ospf_nbr_add_self (oi);
+
+ /* Relate ospf interface to ospf instance. */
+ oi->ospf = ospf;
+
+ /* update network type as interface flag */
+ /* If network type is specified previously,
+ skip network type setting. */
+ oi->type = IF_DEF_PARAMS (ifp)->type;
+
+ ospf_area_add_if (oi->area, oi);
+
+ /* if router_id is not configured, dont bring up
+ * interfaces.
+ * ospf_router_id_update() will call ospf_if_update
+ * whenever r-id is configured instead.
+ */
+ if ((ospf->router_id.s_addr != 0)
+ && if_is_operative (ifp))
+ ospf_if_up (oi);
+}
+
+void update_redistributed(struct ospf *ospf, int add_to_ospf)
+{
+ struct route_node *rn;
+ struct external_info *ei;
+
+ if (ospf_is_type_redistributed (ZEBRA_ROUTE_CONNECT))
+ if (EXTERNAL_INFO (ZEBRA_ROUTE_CONNECT))
+ for (rn = route_top (EXTERNAL_INFO (ZEBRA_ROUTE_CONNECT));
+ rn; rn = route_next (rn))
+ if ((ei = rn->info) != NULL)
+ if (add_to_ospf)
+ {
+ if (ospf_external_info_find_lsa (ospf, &ei->p))
+ if (!ospf_distribute_check_connected (ospf, ei))
+ ospf_external_lsa_flush (ospf, ei->type, &ei->p,
+ ei->ifindex /*, ei->nexthop */);
+ }
+ else
+ {
+ if (!ospf_external_info_find_lsa (ospf, &ei->p))
+ if (ospf_distribute_check_connected (ospf, ei))
+ ospf_external_lsa_originate (ospf, ei);
+ }
+}
+
void
ospf_network_free (struct ospf *ospf, struct ospf_network *network)
{
@@ -748,16 +809,7 @@ ospf_network_set (struct ospf *ospf, struct prefix_ipv4 *p,
ospf_network_run (ospf, (struct prefix *)p, area);
/* Update connected redistribute. */
- if (ospf_is_type_redistributed (ZEBRA_ROUTE_CONNECT))
- if (EXTERNAL_INFO (ZEBRA_ROUTE_CONNECT))
- for (rn = route_top (EXTERNAL_INFO (ZEBRA_ROUTE_CONNECT));
- rn; rn = route_next (rn))
- if ((ei = rn->info) != NULL)
- if (ospf_external_info_find_lsa (ospf, &ei->p))
- if (!ospf_distribute_check_connected (ospf, ei))
- ospf_external_lsa_flush (ospf, ei->type, &ei->p,
- ei->ifindex /*, ei->nexthop */);
-
+ update_redistributed(ospf, 1); /* interfaces possibly added */
ospf_area_check_free (ospf, area_id);
return 1;
@@ -786,15 +838,7 @@ ospf_network_unset (struct ospf *ospf, struct prefix_ipv4 *p,
ospf_if_update (ospf);
/* Update connected redistribute. */
- if (ospf_is_type_redistributed (ZEBRA_ROUTE_CONNECT))
- if (EXTERNAL_INFO (ZEBRA_ROUTE_CONNECT))
- for (rn = route_top (EXTERNAL_INFO (ZEBRA_ROUTE_CONNECT));
- rn; rn = route_next (rn))
- if ((ei = rn->info) != NULL)
- if (!ospf_external_info_find_lsa (ospf, &ei->p))
- if (ospf_distribute_check_connected (ospf, ei))
- ospf_external_lsa_originate (ospf, ei);
-
+ update_redistributed(ospf, 0); /* interfaces possibly removed */
return 1;
}
@@ -835,50 +879,12 @@ ospf_interface_set (struct ospf *ospf, struct interface *ifp,
}
else
{ /* This should be in a function */
- oi = ospf_if_new (ospf, ifp, co->address);
- oi->connected = co;
-
- oi->area = area;
-
- oi->params = ospf_lookup_if_params (ifp, oi->address->u.prefix4);
- oi->output_cost = ospf_if_get_output_cost (oi);
-
- /* Add pseudo neighbor. */
- ospf_nbr_add_self (oi);
-
- /* Relate ospf interface to ospf instance. */
- oi->ospf = ospf;
-
- /* update network type as interface flag */
- /* If network type is specified previously,
- skip network type setting. */
- oi->type = IF_DEF_PARAMS (ifp)->type;
-
- ospf_area_add_if (oi->area, oi);
-
- /* if router_id is not configured, dont bring up
- * interfaces.
- * ospf_router_id_update() will call ospf_if_update
- * whenever r-id is configured instead.
- */
- if ((ospf->router_id.s_addr != 0)
- && if_is_operative (ifp))
- ospf_if_up (oi);
+ add_ospf_interface(ospf, ifp, area, co);
}
}
/* Update connected redistribute. */
- /* This should be in a function */
- if (ospf_is_type_redistributed (ZEBRA_ROUTE_CONNECT))
- if (EXTERNAL_INFO (ZEBRA_ROUTE_CONNECT))
- for (rn = route_top (EXTERNAL_INFO (ZEBRA_ROUTE_CONNECT));
- rn; rn = route_next (rn))
- if ((ei = rn->info) != NULL)
- if (ospf_external_info_find_lsa (ospf, &ei->p))
- if (!ospf_distribute_check_connected (ospf, ei))
- ospf_external_lsa_flush (ospf, ei->type, &ei->p,
- ei->ifindex /*, ei->nexthop */);
-
+ update_redistributed(ospf, 1); /* interface possibly added */
ospf_area_check_free (ospf, area_id);
return 1;
@@ -901,15 +907,7 @@ ospf_interface_unset (struct ospf *ospf, struct interface *ifp)
ospf_if_update (ospf);
/* Update connected redistribute. */
- if (ospf_is_type_redistributed (ZEBRA_ROUTE_CONNECT))
- if (EXTERNAL_INFO (ZEBRA_ROUTE_CONNECT))
- for (rn = route_top (EXTERNAL_INFO (ZEBRA_ROUTE_CONNECT));
- rn; rn = route_next (rn))
- if ((ei = rn->info) != NULL)
- if (!ospf_external_info_find_lsa (ospf, &ei->p))
- if (ospf_distribute_check_connected (ospf, ei))
- ospf_external_lsa_originate (ospf, ei);
-
+ update_redistributed(ospf, 0); /* interface possibly removed */
return 1;
}
@@ -998,49 +996,15 @@ ospf_network_run (struct ospf *ospf, struct prefix *p, struct ospf_area *area)
then create socket and join multicast group. */
for (ALL_LIST_ELEMENTS_RO (ifp->connected, cnode, co))
{
- struct prefix *addr;
-
if (CHECK_FLAG(co->flags,ZEBRA_IFA_SECONDARY))
continue;
- addr = CONNECTED_ID(co);
-
if (p->family == co->address->family
&& ! ospf_if_table_lookup(ifp, co->address)
&& ospf_network_match_iface(co,p))
{
- struct ospf_interface *oi;
-
- oi = ospf_if_new (ospf, ifp, co->address);
- oi->connected = co;
-
- oi->area = area;
-
- oi->params = ospf_lookup_if_params (ifp, oi->address->u.prefix4);
- oi->output_cost = ospf_if_get_output_cost (oi);
-
- /* Add pseudo neighbor. */
- ospf_nbr_add_self (oi);
-
- /* Relate ospf interface to ospf instance. */
- oi->ospf = ospf;
-
- /* update network type as interface flag */
- /* If network type is specified previously,
- skip network type setting. */
- oi->type = IF_DEF_PARAMS (ifp)->type;
-
- ospf_area_add_if (oi->area, oi);
-
- /* if router_id is not configured, dont bring up
- * interfaces.
- * ospf_router_id_update() will call ospf_if_update
- * whenever r-id is configured instead.
- */
- if ((ospf->router_id.s_addr != 0)
- && if_is_operative (ifp))
- ospf_if_up (oi);
- }
+ add_ospf_interface(ospf, ifp, area, co);
+ }
}
}
}
--
1.5.5.4
_______________________________________________
Quagga-dev mailing list
Quagga-dev@lists.quagga.net
http://lists.quagga.net/mailman/listinfo/quagga-dev
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic