summaryrefslogtreecommitdiffstats
path: root/ospfd/ospf_lsa.c
diff options
context:
space:
mode:
Diffstat (limited to 'ospfd/ospf_lsa.c')
-rw-r--r--ospfd/ospf_lsa.c346
1 files changed, 175 insertions, 171 deletions
diff --git a/ospfd/ospf_lsa.c b/ospfd/ospf_lsa.c
index 842df49c..45087de9 100644
--- a/ospfd/ospf_lsa.c
+++ b/ospfd/ospf_lsa.c
@@ -50,7 +50,7 @@
#include "ospfd/ospf_ase.h"
#include "ospfd/ospf_zebra.h"
-
+
u_int32_t
get_metric (u_char *metric)
{
@@ -61,7 +61,7 @@ get_metric (u_char *metric)
return m;
}
-
+
struct timeval
tv_adjust (struct timeval a)
{
@@ -159,22 +159,22 @@ ospf_lsa_refresh_delay (struct ospf_lsa *lsa)
return delay;
}
-
+
int
get_age (struct ospf_lsa *lsa)
{
int age;
- age = ntohs (lsa->data->ls_age)
+ age = ntohs (lsa->data->ls_age)
+ tv_floor (tv_sub (recent_relative_time (), lsa->tv_recv));
return age;
}
-
+
/* Fletcher Checksum -- Refer to RFC1008. */
-/* All the offsets are zero-based. The offsets in the RFC1008 are
+/* All the offsets are zero-based. The offsets in the RFC1008 are
one-based. */
u_int16_t
ospf_lsa_checksum (struct lsa_header *lsa)
@@ -183,7 +183,7 @@ ospf_lsa_checksum (struct lsa_header *lsa)
int options_offset = buffer - (u_char *) &lsa->ls_age; /* should be 2 */
/* Skip the AGE field */
- u_int16_t len = ntohs(lsa->length) - options_offset;
+ u_int16_t len = ntohs(lsa->length) - options_offset;
/* Checksum offset starts from "options" field, not the beginning of the
lsa_header struct. The offset is 14, rather than 16. */
@@ -193,7 +193,7 @@ ospf_lsa_checksum (struct lsa_header *lsa)
}
-
+
/* Create OSPF LSA. */
struct ospf_lsa *
ospf_lsa_new ()
@@ -208,7 +208,7 @@ ospf_lsa_new ()
new->tv_recv = recent_relative_time ();
new->tv_orig = new->tv_recv;
new->refresh_list = -1;
-
+
return new;
}
@@ -246,7 +246,7 @@ void
ospf_lsa_free (struct ospf_lsa *lsa)
{
assert (lsa->lock == 0);
-
+
if (IS_DEBUG_OSPF (lsa, LSA))
zlog_debug ("LSA: freed %p", lsa);
@@ -256,7 +256,7 @@ ospf_lsa_free (struct ospf_lsa *lsa)
assert (lsa->refresh_list < 0);
- memset (lsa, 0, sizeof (struct ospf_lsa));
+ memset (lsa, 0, sizeof (struct ospf_lsa));
XFREE (MTYPE_OSPF_LSA, lsa);
}
@@ -275,7 +275,7 @@ ospf_lsa_unlock (struct ospf_lsa **lsa)
/* This is sanity check. */
if (!lsa || !*lsa)
return;
-
+
(*lsa)->lock--;
assert ((*lsa)->lock >= 0);
@@ -329,7 +329,7 @@ ospf_lsa_data_free (struct lsa_header *lsah)
XFREE (MTYPE_OSPF_LSA_DATA, lsah);
}
-
+
/* LSA general functions. */
const char *
@@ -381,7 +381,7 @@ lsa_header_set (struct stream *s, u_char options,
stream_forward_endp (s, OSPF_LSA_HEADER_SIZE);
}
-
+
/* router-LSA related functions. */
/* Get router-LSA flags. */
@@ -419,7 +419,7 @@ router_lsa_flags (struct ospf_area *area)
if (IS_OSPF_ABR (area->ospf))
{
SET_FLAG (flags, ROUTER_LSA_BORDER);
- /* If Area is NSSA and we are both ABR and unconditional translator,
+ /* If Area is NSSA and we are both ABR and unconditional translator,
* set Nt bit to inform other routers.
*/
if ( (area->external_routing == OSPF_AREA_NSSA)
@@ -480,7 +480,7 @@ link_info_set (struct stream *s, struct in_addr id,
if (STREAM_WRITEABLE(s) < OSPF_ROUTER_LSA_LINK_SIZE)
{
size_t ret = OSPF_MAX_LSA_SIZE;
-
+
/* Can we enlarge the stream still? */
if (STREAM_SIZE(s) == OSPF_MAX_LSA_SIZE)
{
@@ -495,7 +495,7 @@ link_info_set (struct stream *s, struct in_addr id,
*/
ret = stream_resize (s, OSPF_MAX_PACKET_SIZE - OSPF_MAX_LSA_SIZE);
}
-
+
if (ret == OSPF_MAX_LSA_SIZE)
{
zlog_warn ("%s: Out of space in LSA stream, left %zd, size %zd",
@@ -503,14 +503,14 @@ link_info_set (struct stream *s, struct in_addr id,
return 0;
}
}
-
+
/* TOS based routing is not supported. */
stream_put_ipv4 (s, id.s_addr); /* Link ID. */
stream_put_ipv4 (s, data.s_addr); /* Link Data. */
stream_putc (s, type); /* Link Type. */
stream_putc (s, tos); /* TOS = 0. */
stream_putw (s, cost); /* Link Cost. */
-
+
return 1;
}
@@ -552,7 +552,7 @@ lsa_link_broadcast_set (struct stream *s, struct ospf_interface *oi)
struct ospf_neighbor *dr;
struct in_addr id, mask;
u_int16_t cost = ospf_link_cost (oi);
-
+
/* Describe Type 3 Link. */
if (oi->state == ISM_Waiting)
{
@@ -585,7 +585,7 @@ static int
lsa_link_loopback_set (struct stream *s, struct ospf_interface *oi)
{
struct in_addr id, mask;
-
+
/* Describe Type 3 Link. */
if (oi->state != ISM_Loopback)
return 0;
@@ -615,7 +615,7 @@ lsa_link_virtuallink_set (struct stream *s, struct ospf_interface *oi)
#define lsa_link_nbma_set(S,O) lsa_link_broadcast_set (S, O)
-/* this function add for support point-to-multipoint ,see rfc2328
+/* this function add for support point-to-multipoint ,see rfc2328
12.4.1.4.*/
/* from "edward rrr" <edward_rrr@hotmail.com>
http://marc.theaimsgroup.com/?l=zebra&m=100739222210507&w=2 */
@@ -649,7 +649,7 @@ lsa_link_ptomp_set (struct stream *s, struct ospf_interface *oi)
zlog_debug ("PointToMultipoint: set link to %s",
inet_ntoa(oi->address->u.prefix4));
}
-
+
return links;
}
@@ -689,7 +689,9 @@ router_lsa_link_set (struct stream *s, struct ospf_area *area)
links += lsa_link_virtuallink_set (s, oi);
break;
case OSPF_IFTYPE_LOOPBACK:
- links += lsa_link_loopback_set (s, oi);
+ links += lsa_link_loopback_set (s, oi);
+ default:
+ break ;
}
}
}
@@ -723,26 +725,26 @@ ospf_router_lsa_body_set (struct stream *s, struct ospf_area *area)
/* Set # of links here. */
stream_putw_at (s, putp, cnt);
}
-
+
static int
ospf_stub_router_timer (struct thread *t)
{
struct ospf_area *area = THREAD_ARG (t);
-
+
area->t_stub_router = NULL;
-
+
SET_FLAG (area->stub_router_state, OSPF_AREA_WAS_START_STUB_ROUTED);
-
+
/* clear stub route state and generate router-lsa refresh, don't
* clobber an administratively set stub-router state though.
*/
if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED))
return 0;
-
+
UNSET_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED);
-
+
ospf_router_lsa_update_area (area);
-
+
return 0;
}
@@ -758,13 +760,13 @@ ospf_stub_router_check (struct ospf_area *area)
SET_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED);
return;
}
-
+
/* not admin-stubbed, check whether startup stubbing is configured and
* whether it's not been done yet
*/
if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_WAS_START_STUB_ROUTED))
return;
-
+
if (area->ospf->stub_router_startup_time == OSPF_STUB_ROUTER_UNCONFIGURED)
{
/* stub-router is hence done forever for this area, even if someone
@@ -773,14 +775,14 @@ ospf_stub_router_check (struct ospf_area *area)
SET_FLAG (area->stub_router_state, OSPF_AREA_WAS_START_STUB_ROUTED);
return;
}
-
+
/* startup stub-router configured and not yet done */
SET_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED);
-
+
OSPF_AREA_TIMER_ON (area->t_stub_router, ospf_stub_router_timer,
area->ospf->stub_router_startup_time);
}
-
+
/* Create new router-LSA. */
static struct ospf_lsa *
ospf_router_lsa_new (struct ospf_area *area)
@@ -794,11 +796,11 @@ ospf_router_lsa_new (struct ospf_area *area)
if (IS_DEBUG_OSPF (lsa, LSA_GENERATE))
zlog_debug ("LSA[Type1]: Create router-LSA instance");
- /* check whether stub-router is desired, and if this is the first
+ /* check whether stub-router is desired, and if this is the first
* router LSA.
*/
ospf_stub_router_check (area);
-
+
/* Create a stream for LSA. */
s = stream_new (OSPF_MAX_LSA_SIZE);
/* Set LSA common header fields. */
@@ -819,7 +821,7 @@ ospf_router_lsa_new (struct ospf_area *area)
zlog_err ("%s: Unable to create new lsa", __func__);
return NULL;
}
-
+
new->area = area;
SET_FLAG (new->flags, OSPF_LSA_SELF | OSPF_LSA_SELF_CHECKED);
@@ -836,7 +838,7 @@ static struct ospf_lsa *
ospf_router_lsa_originate (struct ospf_area *area)
{
struct ospf_lsa *new;
-
+
/* Create new router-LSA instance. */
if ( (new = ospf_router_lsa_new (area)) == NULL)
{
@@ -887,14 +889,14 @@ ospf_router_lsa_refresh (struct ospf_lsa *lsa)
/* Unregister LSA from refresh-list */
ospf_refresher_unregister_lsa (area->ospf, lsa);
-
+
/* Create new router-LSA instance. */
if ( (new = ospf_router_lsa_new (area)) == NULL)
{
zlog_err ("%s: ospf_router_lsa_new returned NULL", __func__);
return NULL;
}
-
+
new->data->ls_seqnum = lsa_seqnum_increment (lsa);
ospf_lsa_install (area->ospf, NULL, new);
@@ -982,7 +984,7 @@ ospf_router_lsa_update (struct ospf *ospf)
return 0;
}
-
+
/* network-LSA related functions. */
/* Originate Network-LSA. */
static void
@@ -1019,7 +1021,7 @@ ospf_network_lsa_new (struct ospf_interface *oi)
the router does not originate network-LSA (see RFC 12.4.2) */
if (oi->full_nbrs == 0)
return NULL;
-
+
if (IS_DEBUG_OSPF (lsa, LSA_GENERATE))
zlog_debug ("LSA[Type2]: Create network-LSA instance");
@@ -1043,7 +1045,7 @@ ospf_network_lsa_new (struct ospf_interface *oi)
zlog_err ("%s: ospf_lsa_new returned NULL", __func__);
return NULL;
}
-
+
new->area = oi->area;
SET_FLAG (new->flags, OSPF_LSA_SELF | OSPF_LSA_SELF_CHECKED);
@@ -1051,7 +1053,7 @@ ospf_network_lsa_new (struct ospf_interface *oi)
new->data = ospf_lsa_data_new (length);
memcpy (new->data, lsah, length);
stream_free (s);
-
+
/* Remember prior network LSA sequence numbers, even if we stop
* originating one for this oi, to try avoid re-originating LSAs with a
* prior sequence number, and thus speed up adjency forming & convergence.
@@ -1067,7 +1069,7 @@ ospf_network_lsa_new (struct ospf_interface *oi)
ospf_if_update_params (oi->ifp, oi->address->u.prefix4);
}
oip->network_lsa_seqnum = new->data->ls_seqnum;
-
+
return new;
}
@@ -1076,13 +1078,13 @@ void
ospf_network_lsa_update (struct ospf_interface *oi)
{
struct ospf_lsa *new;
-
+
if (oi->network_lsa_self != NULL)
{
ospf_lsa_refresh (oi->ospf, oi->network_lsa_self);
return;
}
-
+
/* Create new network-LSA instance. */
new = ospf_network_lsa_new (oi);
if (new == NULL)
@@ -1114,9 +1116,9 @@ ospf_network_lsa_refresh (struct ospf_lsa *lsa)
struct ospf_lsa *new, *new2;
struct ospf_if_params *oip;
struct ospf_interface *oi;
-
+
assert (lsa->data);
-
+
/* Retrieve the oi for the network LSA */
oi = ospf_if_lookup_by_local_addr (area->ospf, NULL, lsa->data->id);
if (oi == NULL)
@@ -1135,20 +1137,20 @@ ospf_network_lsa_refresh (struct ospf_lsa *lsa)
/* Unregister LSA from refresh-list */
ospf_refresher_unregister_lsa (area->ospf, lsa);
-
+
/* Create new network-LSA instance. */
new = ospf_network_lsa_new (oi);
if (new == NULL)
return NULL;
-
+
oip = ospf_lookup_if_params (oi->ifp, oi->address->u.prefix4);
assert (oip != NULL);
oip->network_lsa_seqnum = new->data->ls_seqnum = lsa_seqnum_increment (lsa);
new2 = ospf_lsa_install (area->ospf, oi, new);
-
+
assert (new2 == new);
-
+
/* Flood LSA through aera. */
ospf_flood_through_area (area, NULL, new);
@@ -1161,7 +1163,7 @@ ospf_network_lsa_refresh (struct ospf_lsa *lsa)
return new;
}
-
+
static void
stream_put_ospf_metric (struct stream *s, u_int32_t metric_value)
{
@@ -1244,12 +1246,12 @@ ospf_summary_lsa_new (struct ospf_area *area, struct prefix *p,
/* Originate Summary-LSA. */
struct ospf_lsa *
-ospf_summary_lsa_originate (struct prefix_ipv4 *p, u_int32_t metric,
+ospf_summary_lsa_originate (struct prefix_ipv4 *p, u_int32_t metric,
struct ospf_area *area)
{
struct ospf_lsa *new;
struct in_addr id;
-
+
id = ospf_lsa_unique_id (area->ospf, area->lsdb, OSPF_SUMMARY_LSA, p);
if (id.s_addr == 0xffffffff)
@@ -1260,7 +1262,7 @@ ospf_summary_lsa_originate (struct prefix_ipv4 *p, u_int32_t metric,
OSPF_SUMMARY_LSA);
return NULL;
}
-
+
/* Create new summary-LSA instance. */
if ( !(new = ospf_summary_lsa_new (area, (struct prefix *) p, metric, id)))
return NULL;
@@ -1290,7 +1292,7 @@ ospf_summary_lsa_refresh (struct ospf *ospf, struct ospf_lsa *lsa)
struct ospf_lsa *new;
struct summary_lsa *sl;
struct prefix p;
-
+
/* Sanity check. */
assert (lsa->data);
@@ -1298,14 +1300,14 @@ ospf_summary_lsa_refresh (struct ospf *ospf, struct ospf_lsa *lsa)
p.prefixlen = ip_masklen (sl->mask);
new = ospf_summary_lsa_new (lsa->area, &p, GET_METRIC (sl->metric),
sl->header.id);
-
+
if (!new)
return NULL;
-
+
new->data->ls_seqnum = lsa_seqnum_increment (lsa);
ospf_lsa_install (ospf, NULL, new);
-
+
/* Flood LSA through AS. */
ospf_flood_through_area (new->area, NULL, new);
@@ -1316,11 +1318,11 @@ ospf_summary_lsa_refresh (struct ospf *ospf, struct ospf_lsa *lsa)
new->data->type, inet_ntoa (new->data->id));
ospf_lsa_header_dump (new->data);
}
-
+
return new;
}
-
+
/* summary-ASBR-LSA related functions. */
static void
ospf_summary_asbr_lsa_body_set (struct stream *s, struct prefix *p,
@@ -1390,12 +1392,12 @@ ospf_summary_asbr_lsa_new (struct ospf_area *area, struct prefix *p,
/* Originate summary-ASBR-LSA. */
struct ospf_lsa *
-ospf_summary_asbr_lsa_originate (struct prefix_ipv4 *p, u_int32_t metric,
+ospf_summary_asbr_lsa_originate (struct prefix_ipv4 *p, u_int32_t metric,
struct ospf_area *area)
{
struct ospf_lsa *new;
struct in_addr id;
-
+
id = ospf_lsa_unique_id (area->ospf, area->lsdb, OSPF_ASBR_SUMMARY_LSA, p);
if (id.s_addr == 0xffffffff)
@@ -1406,7 +1408,7 @@ ospf_summary_asbr_lsa_originate (struct prefix_ipv4 *p, u_int32_t metric,
OSPF_ASBR_SUMMARY_LSA);
return NULL;
}
-
+
/* Create new summary-LSA instance. */
new = ospf_summary_asbr_lsa_new (area, (struct prefix *) p, metric, id);
if (!new)
@@ -1414,7 +1416,7 @@ ospf_summary_asbr_lsa_originate (struct prefix_ipv4 *p, u_int32_t metric,
/* Install LSA to LSDB. */
new = ospf_lsa_install (area->ospf, NULL, new);
-
+
/* Update LSA origination count. */
area->ospf->lsa_originate_count++;
@@ -1447,11 +1449,11 @@ ospf_summary_asbr_lsa_refresh (struct ospf *ospf, struct ospf_lsa *lsa)
sl->header.id);
if (!new)
return NULL;
-
+
new->data->ls_seqnum = lsa_seqnum_increment (lsa);
ospf_lsa_install (ospf, NULL, new);
-
+
/* Flood LSA through area. */
ospf_flood_through_area (new->area, NULL, new);
@@ -1486,7 +1488,7 @@ ospf_external_lsa_nexthop_get (struct ospf *ospf, struct in_addr nexthop)
nh.family = AF_INET;
nh.u.prefix4 = nexthop;
nh.prefixlen = IPV4_MAX_BITLEN;
-
+
/* XXX/SCALE: If there were a lot of oi's on an ifp, then it'd be
* better to make use of the per-ifp table of ois.
*/
@@ -1512,7 +1514,7 @@ ospf_get_ip_from_ifp (struct ospf_interface *oi)
if (if_is_operative (oi->ifp))
return oi->address->u.prefix4;
-
+
return fwd;
}
@@ -1600,7 +1602,7 @@ ospf_external_lsa_body_set (struct stream *s, struct external_info *ei,
/* If prefix is default, specify DEFAULT_ROUTE. */
type = is_prefix_default (&ei->p) ? DEFAULT_ROUTE : ei->type;
-
+
mtype = (ROUTEMAP_METRIC_TYPE (ei) != -1) ?
ROUTEMAP_METRIC_TYPE (ei) : metric_type (ospf, type);
@@ -1612,13 +1614,13 @@ ospf_external_lsa_body_set (struct stream *s, struct external_info *ei,
/* Put 0 metric. TOS metric is not supported. */
stream_put_ospf_metric (s, mvalue);
-
+
/* Get forwarding address to nexthop if on the Connection List, else 0. */
fwd_addr = ospf_external_lsa_nexthop_get (ospf, ei->nexthop);
/* Put forwarding address. */
stream_put_ipv4 (s, fwd_addr.s_addr);
-
+
/* Put route tag -- This value should be introduced from configuration. */
stream_putl (s, 0);
}
@@ -1690,7 +1692,7 @@ ospf_external_lsa_new (struct ospf *ospf,
/* As Type-7 */
static void
-ospf_install_flood_nssa (struct ospf *ospf,
+ospf_install_flood_nssa (struct ospf *ospf,
struct ospf_lsa *lsa, struct external_info *ei)
{
struct ospf_lsa *new;
@@ -1699,12 +1701,12 @@ ospf_install_flood_nssa (struct ospf *ospf,
struct listnode *node, *nnode;
/* LSA may be a Type-5 originated via translation of a Type-7 LSA
- * which originated from an NSSA area. In which case it should not be
+ * which originated from an NSSA area. In which case it should not be
* flooded back to NSSA areas.
*/
if (CHECK_FLAG (lsa->flags, OSPF_LSA_LOCAL_XLT))
return;
-
+
/* NSSA Originate or Refresh (If anyNSSA)
LSA is self-originated. And just installed as Type-5.
@@ -1735,11 +1737,11 @@ ospf_install_flood_nssa (struct ospf *ospf,
if (! IS_OSPF_ABR (ospf))
{
SET_FLAG(new->data->options, OSPF_OPTION_NP);
-
+
/* set non-zero FWD ADDR
-
+
draft-ietf-ospf-nssa-update-09.txt
-
+
if the network between the NSSA AS boundary router and the
adjacent AS is advertised into OSPF as an internal OSPF route,
the forwarding address should be the next op address as is cu
@@ -1750,14 +1752,14 @@ ospf_install_flood_nssa (struct ospf *ospf,
which belong to the NSSA. If no such addresses exist, then
no type-7 LSA's with the P-bit set should originate from this
router. */
-
+
/* kevinm: not updating lsa anymore, just new */
extlsa = (struct as_external_lsa *)(new->data);
-
+
if (extlsa->e[0].fwd_addr.s_addr == 0)
extlsa->e[0].fwd_addr = ospf_get_nssa_ip(area); /* this NSSA area in ifp */
- if (extlsa->e[0].fwd_addr.s_addr == 0)
+ if (extlsa->e[0].fwd_addr.s_addr == 0)
{
if (IS_DEBUG_OSPF_NSSA)
zlog_debug ("LSA[Type-7]: Could not build FWD-ADDR");
@@ -1775,17 +1777,17 @@ ospf_install_flood_nssa (struct ospf *ospf,
}
static struct ospf_lsa *
-ospf_lsa_translated_nssa_new (struct ospf *ospf,
+ospf_lsa_translated_nssa_new (struct ospf *ospf,
struct ospf_lsa *type7)
{
struct ospf_lsa *new;
struct as_external_lsa *ext, *extnew;
struct external_info ei;
-
+
ext = (struct as_external_lsa *)(type7->data);
- /* need external_info struct, fill in bare minimum */
+ /* need external_info struct, fill in bare minimum */
ei.p.family = AF_INET;
ei.p.prefix = type7->data->id;
ei.p.prefixlen = ip_masklen (ext->mask);
@@ -1794,18 +1796,18 @@ ospf_lsa_translated_nssa_new (struct ospf *ospf,
ei.route_map_set.metric = -1;
ei.route_map_set.metric_type = -1;
ei.tag = 0;
-
+
if ( (new = ospf_external_lsa_new (ospf, &ei, &type7->data->id)) == NULL)
{
if (IS_DEBUG_OSPF_NSSA)
zlog_debug ("ospf_nssa_translate_originate(): Could not originate "
- "Translated Type-5 for %s",
+ "Translated Type-5 for %s",
inet_ntoa (ei.p.prefix));
return NULL;
}
extnew = (struct as_external_lsa *)(new->data);
-
+
/* copy over Type-7 data to new */
extnew->e[0].tos = ext->e[0].tos;
extnew->e[0].route_tag = ext->e[0].route_tag;
@@ -1813,10 +1815,10 @@ ospf_lsa_translated_nssa_new (struct ospf *ospf,
new->data->ls_seqnum = type7->data->ls_seqnum;
/* add translated flag, checksum and lock new lsa */
- SET_FLAG (new->flags, OSPF_LSA_LOCAL_XLT); /* Translated from 7 */
+ SET_FLAG (new->flags, OSPF_LSA_LOCAL_XLT); /* Translated from 7 */
new = ospf_lsa_lock (new);
-
- return new;
+
+ return new;
}
/* Originate Translated Type-5 for supplied Type-7 NSSA LSA */
@@ -1825,11 +1827,11 @@ ospf_translated_nssa_originate (struct ospf *ospf, struct ospf_lsa *type7)
{
struct ospf_lsa *new;
struct as_external_lsa *extnew;
-
+
/* we cant use ospf_external_lsa_originate() as we need to set
* the OSPF_LSA_LOCAL_XLT flag, must originate by hand
*/
-
+
if ( (new = ospf_lsa_translated_nssa_new (ospf, type7)) == NULL)
{
if (IS_DEBUG_OSPF_NSSA)
@@ -1838,9 +1840,9 @@ ospf_translated_nssa_originate (struct ospf *ospf, struct ospf_lsa *type7)
inet_ntoa (type7->data->id));
return NULL;
}
-
+
extnew = (struct as_external_lsa *)new;
-
+
if (IS_DEBUG_OSPF_NSSA)
{
zlog_debug ("ospf_translated_nssa_originate(): "
@@ -1849,16 +1851,16 @@ ospf_translated_nssa_originate (struct ospf *ospf, struct ospf_lsa *type7)
zlog_debug (" Network mask: %d",ip_masklen (extnew->mask));
zlog_debug (" Forward addr: %s", inet_ntoa (extnew->e[0].fwd_addr));
}
-
+
if ( (new = ospf_lsa_install (ospf, NULL, new)) == NULL)
{
- if (IS_DEBUG_OSPF_NSSA);
+ if (IS_DEBUG_OSPF_NSSA)
zlog_debug ("ospf_lsa_translated_nssa_originate(): "
"Could not install LSA "
"id %s", inet_ntoa (type7->data->id));
return NULL;
}
-
+
ospf->lsa_originate_count++;
ospf_flood_through_as (ospf, NULL, new);
@@ -1867,11 +1869,11 @@ ospf_translated_nssa_originate (struct ospf *ospf, struct ospf_lsa *type7)
/* Refresh Translated from NSSA AS-external-LSA. */
struct ospf_lsa *
-ospf_translated_nssa_refresh (struct ospf *ospf, struct ospf_lsa *type7,
+ospf_translated_nssa_refresh (struct ospf *ospf, struct ospf_lsa *type7,
struct ospf_lsa *type5)
{
struct ospf_lsa *new = NULL;
-
+
/* Sanity checks. */
assert (type7 || type5);
if (!(type7 || type5))
@@ -1887,8 +1889,8 @@ ospf_translated_nssa_refresh (struct ospf *ospf, struct ospf_lsa *type7,
{
/* find the translated Type-5 for this Type-7 */
struct as_external_lsa *ext = (struct as_external_lsa *)(type7->data);
- struct prefix_ipv4 p =
- {
+ struct prefix_ipv4 p =
+ {
.prefix = type7->data->id,
.prefixlen = ip_masklen (ext->mask),
.family = AF_INET,
@@ -1905,13 +1907,13 @@ ospf_translated_nssa_refresh (struct ospf *ospf, struct ospf_lsa *type7,
struct route_node *rn;
struct ospf_lsa *lsa;
struct ospf_area *area;
-
+
for (ALL_LIST_ELEMENTS (ospf->areas, ln, lnn, area))
{
- if (area->external_routing != OSPF_AREA_NSSA
+ if (area->external_routing != OSPF_AREA_NSSA
&& !type7)
continue;
-
+
LSDB_LOOP (NSSA_LSDB(area), rn, lsa)
{
if (lsa->data->id.s_addr == type5->data->id.s_addr)
@@ -1945,7 +1947,7 @@ ospf_translated_nssa_refresh (struct ospf *ospf, struct ospf_lsa *type7,
/* Delete LSA from neighbor retransmit-list. */
ospf_ls_retransmit_delete_nbr_as (ospf, type5);
-
+
/* create new translated LSA */
if ( (new = ospf_lsa_translated_nssa_new (ospf, type7)) == NULL)
{
@@ -1964,7 +1966,7 @@ ospf_translated_nssa_refresh (struct ospf *ospf, struct ospf_lsa *type7,
inet_ntoa (type7->data->id));
return NULL;
}
-
+
/* Flood LSA through area. */
ospf_flood_through_as (ospf, NULL, new);
@@ -2023,11 +2025,11 @@ ospf_external_lsa_originate (struct ospf *ospf, struct external_info *ei)
flushed from the AS.
*/
-
+
/* Check the AS-external-LSA should be originated. */
if (!ospf_redistribute_check (ospf, ei, NULL))
return NULL;
-
+
/* Create new AS-external-LSA instance. */
if ((new = ospf_external_lsa_new (ospf, ei, NULL)) == NULL)
{
@@ -2082,7 +2084,7 @@ ospf_external_lsa_originate_timer (struct thread *thread)
if (!is_prefix_default ((struct prefix_ipv4 *)&ei->p))
if (!ospf_external_lsa_originate (ospf, ei))
zlog_warn ("LSA: AS-external-LSA was not originated.");
-
+
return 0;
}
@@ -2092,7 +2094,7 @@ ospf_default_external_info (struct ospf *ospf)
int type;
struct route_node *rn;
struct prefix_ipv4 p;
-
+
p.family = AF_INET;
p.prefix.s_addr = 0;
p.prefixlen = 0;
@@ -2121,7 +2123,7 @@ ospf_default_originate_timer (struct thread *thread)
struct in_addr nexthop;
struct external_info *ei;
struct ospf *ospf;
-
+
ospf = THREAD_ARG (thread);
p.family = AF_INET;
@@ -2138,7 +2140,7 @@ ospf_default_originate_timer (struct thread *thread)
if ((ei = ospf_default_external_info (ospf)))
ospf_external_lsa_originate (ospf, ei);
-
+
return 0;
}
@@ -2155,15 +2157,15 @@ ospf_nssa_lsa_flush (struct ospf *ospf, struct prefix_ipv4 *p)
if (area->external_routing == OSPF_AREA_NSSA)
{
if (!(lsa = ospf_lsa_lookup (area, OSPF_AS_NSSA_LSA, p->prefix,
- ospf->router_id)))
+ ospf->router_id)))
{
- if (IS_DEBUG_OSPF (lsa, LSA_FLOODING))
+ if (IS_DEBUG_OSPF (lsa, LSA_FLOODING))
zlog_debug ("LSA: There is no such AS-NSSA-LSA %s/%d in LSDB",
inet_ntoa (p->prefix), p->prefixlen);
continue;
}
ospf_ls_retransmit_delete_nbr_area (area, lsa);
- if (!IS_LSA_MAXAGE (lsa))
+ if (!IS_LSA_MAXAGE (lsa))
{
ospf_refresher_unregister_lsa (ospf, lsa);
ospf_lsa_flush_area (lsa, area);
@@ -2193,8 +2195,8 @@ ospf_external_lsa_flush (struct ospf *ospf,
return;
}
- /* If LSA is selforiginated, not a translated LSA, and there is
- * NSSA area, flush Type-7 LSA's at first.
+ /* If LSA is selforiginated, not a translated LSA, and there is
+ * NSSA area, flush Type-7 LSA's at first.
*/
if (IS_LSA_SELF(lsa) && (ospf->anyNSSA)
&& !(CHECK_FLAG (lsa->flags, OSPF_LSA_LOCAL_XLT)))
@@ -2292,13 +2294,13 @@ ospf_external_lsa_refresh (struct ospf *ospf, struct ospf_lsa *lsa,
{
struct ospf_lsa *new;
int changed;
-
+
/* Check the AS-external-LSA should be originated. */
if (!ospf_redistribute_check (ospf, ei, &changed))
{
if (IS_DEBUG_OSPF (lsa, LSA_GENERATE))
zlog_debug ("LSA[Type%d:%s]: Could not be refreshed, "
- "redist check fail",
+ "redist check fail",
lsa->data->type, inet_ntoa (lsa->data->id));
ospf_external_lsa_flush (ospf, ei->type, &ei->p,
ei->ifindex /*, ei->nexthop */);
@@ -2320,7 +2322,7 @@ ospf_external_lsa_refresh (struct ospf *ospf, struct ospf_lsa *lsa,
ospf_refresher_unregister_lsa (ospf, lsa);
new = ospf_external_lsa_new (ospf, ei, &lsa->data->id);
-
+
if (new == NULL)
{
if (IS_DEBUG_OSPF (lsa, LSA_GENERATE))
@@ -2328,7 +2330,7 @@ ospf_external_lsa_refresh (struct ospf *ospf, struct ospf_lsa *lsa,
inet_ntoa (lsa->data->id));
return NULL;
}
-
+
new->data->ls_seqnum = lsa_seqnum_increment (lsa);
ospf_lsa_install (ospf, NULL, new); /* As type-5. */
@@ -2340,8 +2342,8 @@ ospf_external_lsa_refresh (struct ospf *ospf, struct ospf_lsa *lsa,
if (ospf->anyNSSA && !(CHECK_FLAG (new->flags, OSPF_LSA_LOCAL_XLT)))
ospf_install_flood_nssa (ospf, new, ei); /* Install/Flood per new rules */
- /* Register self-originated LSA to refresh queue.
- * Translated LSAs should not be registered, but refreshed upon
+ /* Register self-originated LSA to refresh queue.
+ * Translated LSAs should not be registered, but refreshed upon
* refresh of the Type-7
*/
if ( !CHECK_FLAG (new->flags, OSPF_LSA_LOCAL_XLT) )
@@ -2358,7 +2360,7 @@ ospf_external_lsa_refresh (struct ospf *ospf, struct ospf_lsa *lsa,
return new;
}
-
+
/* LSA installation functions. */
/* Install router-LSA to an area. */
@@ -2371,7 +2373,7 @@ ospf_router_lsa_install (struct ospf *ospf, struct ospf_lsa *new,
/* RFC 2328 Section 13.2 Router-LSAs and network-LSAs
The entire routing table must be recalculated, starting with
the shortest path calculations for each area (not just the
- area whose link-state database has changed).
+ area whose link-state database has changed).
*/
if (IS_LSA_SELF (new))
@@ -2402,7 +2404,7 @@ ospf_router_lsa_install (struct ospf *ospf, struct ospf_lsa *new,
/* Install network-LSA to an area. */
static struct ospf_lsa *
ospf_network_lsa_install (struct ospf *ospf,
- struct ospf_interface *oi,
+ struct ospf_interface *oi,
struct ospf_lsa *new,
int rt_recalc)
{
@@ -2410,7 +2412,7 @@ ospf_network_lsa_install (struct ospf *ospf,
/* RFC 2328 Section 13.2 Router-LSAs and network-LSAs
The entire routing table must be recalculated, starting with
the shortest path calculations for each area (not just the
- area whose link-state database has changed).
+ area whose link-state database has changed).
*/
if (IS_LSA_SELF (new))
{
@@ -2450,7 +2452,7 @@ ospf_summary_lsa_install (struct ospf *ospf, struct ospf_lsa *new,
#else /* #if 0 */
ospf_spf_calculate_schedule (ospf);
#endif /* #if 0 */
-
+
if (IS_DEBUG_OSPF (lsa, LSA_INSTALL))
zlog_debug ("ospf_summary_lsa_install(): SPF scheduled");
}
@@ -2477,7 +2479,7 @@ ospf_summary_asbr_lsa_install (struct ospf *ospf, struct ospf_lsa *new,
#if 0
/* These don't exist yet... */
ospf_summary_incremental_update(new);
- /* Isn't this done by the above call?
+ /* Isn't this done by the above call?
- RFC 2328 Section 16.5 implies it should be */
/* ospf_ase_calculate_schedule(); */
#else /* #if 0 */
@@ -2513,7 +2515,7 @@ ospf_external_lsa_install (struct ospf *ospf, struct ospf_lsa *new,
if (new->data->type == OSPF_AS_NSSA_LSA)
{
/* There is no point to register selforiginate Type-7 LSA for
- * refreshing. We rely on refreshing Type-5 LSA's
+ * refreshing. We rely on refreshing Type-5 LSA's
*/
if (IS_LSA_SELF (new))
return new;
@@ -2521,12 +2523,12 @@ ospf_external_lsa_install (struct ospf *ospf, struct ospf_lsa *new,
{
/* Try refresh type-5 translated LSA for this LSA, if one exists.
* New translations will be taken care of by the abr_task.
- */
+ */
ospf_translated_nssa_refresh (ospf, new, NULL);
}
}
- /* Register self-originated LSA to refresh queue.
+ /* Register self-originated LSA to refresh queue.
* Leave Translated LSAs alone if NSSA is enabled
*/
if (IS_LSA_SELF (new) && !CHECK_FLAG (new->flags, OSPF_LSA_LOCAL_XLT ) )
@@ -2540,7 +2542,7 @@ ospf_discard_from_db (struct ospf *ospf,
struct ospf_lsdb *lsdb, struct ospf_lsa *lsa)
{
struct ospf_lsa *old;
-
+
if (!lsdb)
{
zlog_warn ("%s: Called with NULL lsdb!", __func__);
@@ -2551,7 +2553,7 @@ ospf_discard_from_db (struct ospf *ospf,
lsa->data->type, inet_ntoa (lsa->data->id));
return;
}
-
+
old = ospf_lsdb_lookup (lsdb, lsa);
if (!old)
@@ -2662,11 +2664,11 @@ ospf_lsa_install (struct ospf *ospf, struct ospf_interface *oi,
if (ospf_lsa_is_self_originated(ospf, lsa))
{
lsa->data->ls_seqnum = htonl(OSPF_MAX_SEQUENCE_NUMBER);
-
+
if (!IS_LSA_MAXAGE(lsa))
lsa->flags |= OSPF_LSA_PREMATURE_AGE;
lsa->data->ls_age = htons (OSPF_LSA_MAXAGE);
-
+
if (IS_DEBUG_OSPF (lsa, LSA_REFRESH))
{
zlog_debug ("ospf_lsa_install() Premature Aging "
@@ -2723,7 +2725,7 @@ ospf_lsa_install (struct ospf *ospf, struct ospf_interface *oi,
if (IS_LSA_SELF (lsa))
lsa->oi = oi; /* Specify outgoing ospf-interface for this LSA. */
else
- ; /* Incoming "oi" for this LSA has set at LSUpd reception. */
+ {;}; /* Incoming "oi" for this LSA has set at LSUpd reception. */
/* Fallthrough */
case OSPF_OPAQUE_AREA_LSA:
case OSPF_OPAQUE_AS_LSA:
@@ -2764,17 +2766,17 @@ ospf_lsa_install (struct ospf *ospf, struct ospf_interface *oi,
}
}
- /*
+ /*
If received LSA' ls_age is MaxAge, or lsa is being prematurely aged
- (it's getting flushed out of the area), set LSA on MaxAge LSA list.
+ (it's getting flushed out of the area), set LSA on MaxAge LSA list.
*/
if ((lsa->flags & OSPF_LSA_PREMATURE_AGE) ||
(IS_LSA_MAXAGE (new) && !IS_LSA_SELF (new)))
{
if (IS_DEBUG_OSPF (lsa, LSA_INSTALL))
zlog_debug ("LSA[Type%d:%s]: Install LSA 0x%p, MaxAge",
- new->data->type,
- inet_ntoa (new->data->id),
+ new->data->type,
+ inet_ntoa (new->data->id),
lsa);
ospf_lsa_flush (ospf, lsa);
}
@@ -2782,13 +2784,13 @@ ospf_lsa_install (struct ospf *ospf, struct ospf_interface *oi,
return new;
}
-
+
static int
ospf_check_nbr_status (struct ospf *ospf)
{
struct listnode *node, *nnode;
struct ospf_interface *oi;
-
+
for (ALL_LIST_ELEMENTS (ospf->oiflist, node, nnode, oi))
{
struct route_node *rn;
@@ -2807,7 +2809,7 @@ ospf_check_nbr_status (struct ospf *ospf)
return 1;
}
-
+
static int
ospf_maxage_lsa_remover (struct thread *thread)
@@ -2832,11 +2834,11 @@ ospf_maxage_lsa_remover (struct thread *thread)
reschedule = 1;
continue;
}
-
+
/* TODO: maybe convert this function to a work-queue */
if (thread_should_yield (thread))
OSPF_TIMER_ON (ospf->t_maxage, ospf_maxage_lsa_remover, 0);
-
+
/* Remove LSA from the LSDB */
if (CHECK_FLAG (lsa->flags, OSPF_LSA_SELF))
if (IS_DEBUG_OSPF (lsa, LSA_FLOODING))
@@ -3077,7 +3079,7 @@ ospf_lsa_lookup (struct ospf_area *area, u_int32_t type,
}
struct ospf_lsa *
-ospf_lsa_lookup_by_id (struct ospf_area *area, u_int32_t type,
+ospf_lsa_lookup_by_id (struct ospf_area *area, u_int32_t type,
struct in_addr id)
{
struct ospf_lsa *lsa;
@@ -3315,7 +3317,7 @@ ospf_flush_self_originated_lsas_now (struct ospf *ospf)
if (IS_DEBUG_OSPF_EVENT)
zlog_debug ("LSA[Type%d:%s]: Schedule self-originated LSA to FLUSH",
lsa->data->type, inet_ntoa (lsa->data->id));
-
+
ospf_refresher_unregister_lsa (ospf, lsa);
ospf_lsa_flush_area (lsa, area);
ospf_lsa_unlock (&area->router_lsa_self);
@@ -3331,7 +3333,7 @@ ospf_flush_self_originated_lsas_now (struct ospf *ospf)
if (IS_DEBUG_OSPF_EVENT)
zlog_debug ("LSA[Type%d:%s]: Schedule self-originated LSA to FLUSH",
lsa->data->type, inet_ntoa (lsa->data->id));
-
+
ospf_refresher_unregister_lsa (ospf, oi->network_lsa_self);
ospf_lsa_flush_area (oi->network_lsa_self, area);
ospf_lsa_unlock (&oi->network_lsa_self);
@@ -3381,7 +3383,7 @@ ospf_flush_self_originated_lsas_now (struct ospf *ospf)
/* If there is self-originated LSA, then return 1, otherwise return 0. */
/* An interface-independent version of ospf_lsa_is_self_originated */
-int
+int
ospf_lsa_is_self_originated (struct ospf *ospf, struct ospf_lsa *lsa)
{
struct listnode *node;
@@ -3470,7 +3472,7 @@ ospf_lsa_unique_id (struct ospf *ospf,
return id;
}
-
+
#define LSA_ACTION_FLOOD_AREA 1
#define LSA_ACTION_FLUSH_AREA 2
@@ -3500,6 +3502,8 @@ ospf_lsa_action (struct thread *t)
case LSA_ACTION_FLUSH_AREA:
ospf_lsa_flush_area (data->lsa, data->area);
break;
+ default:
+ break ;
}
ospf_lsa_unlock (&data->lsa); /* Message */
@@ -3533,7 +3537,7 @@ ospf_schedule_lsa_flush_area (struct ospf_area *area, struct ospf_lsa *lsa)
thread_add_event (master, ospf_lsa_action, data, 0);
}
-
+
/* LSA Refreshment functions. */
struct ospf_lsa *
ospf_lsa_refresh (struct ospf *ospf, struct ospf_lsa *lsa)
@@ -3549,7 +3553,7 @@ ospf_lsa_refresh (struct ospf *ospf, struct ospf_lsa *lsa)
case OSPF_ROUTER_LSA:
new = ospf_router_lsa_refresh (lsa);
break;
- case OSPF_NETWORK_LSA:
+ case OSPF_NETWORK_LSA:
new = ospf_network_lsa_refresh (lsa);
break;
case OSPF_SUMMARY_LSA:
@@ -3559,7 +3563,7 @@ ospf_lsa_refresh (struct ospf *ospf, struct ospf_lsa *lsa)
new = ospf_summary_asbr_lsa_refresh (ospf, lsa);
break;
case OSPF_AS_EXTERNAL_LSA:
- /* Translated from NSSA Type-5s are refreshed when
+ /* Translated from NSSA Type-5s are refreshed when
* from refresh of Type-7 - do not refresh these directly.
*/
if (CHECK_FLAG (lsa->flags, OSPF_LSA_LOCAL_XLT))
@@ -3587,7 +3591,7 @@ void
ospf_refresher_register_lsa (struct ospf *ospf, struct ospf_lsa *lsa)
{
u_int16_t index, current_index;
-
+
assert (lsa->lock > 0);
assert (CHECK_FLAG (lsa->flags, OSPF_LSA_SELF));
@@ -3597,19 +3601,19 @@ ospf_refresher_register_lsa (struct ospf *ospf, struct ospf_lsa *lsa)
if (LS_AGE (lsa) == 0 &&
ntohl (lsa->data->ls_seqnum) == OSPF_INITIAL_SEQUENCE_NUMBER)
- /* Randomize first update by OSPF_LS_REFRESH_SHIFT factor */
+ /* Randomize first update by OSPF_LS_REFRESH_SHIFT factor */
delay = OSPF_LS_REFRESH_SHIFT + (random () % OSPF_LS_REFRESH_TIME);
else
/* Randomize another updates by +-OSPF_LS_REFRESH_JITTER factor */
delay = OSPF_LS_REFRESH_TIME - LS_AGE (lsa) - OSPF_LS_REFRESH_JITTER
- + (random () % (2*OSPF_LS_REFRESH_JITTER));
+ + (random () % (2*OSPF_LS_REFRESH_JITTER));
if (delay < 0)
delay = 0;
current_index = ospf->lsa_refresh_queue.index + (quagga_time (NULL)
- ospf->lsa_refresher_started)/OSPF_LSA_REFRESHER_GRANULARITY;
-
+
index = (current_index + delay/OSPF_LSA_REFRESHER_GRANULARITY)
% (OSPF_LSA_REFRESHER_SLOTS);
@@ -3623,7 +3627,7 @@ ospf_refresher_register_lsa (struct ospf *ospf, struct ospf_lsa *lsa)
lsa->refresh_list = index;
if (IS_DEBUG_OSPF (lsa, LSA_REFRESH))
zlog_debug ("LSA[Refresh:%s]: ospf_refresher_register_lsa(): "
- "setting refresh_list on lsa %p (slod %d)",
+ "setting refresh_list on lsa %p (slod %d)",
inet_ntoa (lsa->data->id), lsa, index);
}
}
@@ -3660,9 +3664,9 @@ ospf_lsa_refresh_walker (struct thread *t)
if (IS_DEBUG_OSPF (lsa, LSA_REFRESH))
zlog_debug ("LSA[Refresh]:ospf_lsa_refresh_walker(): start");
-
+
i = ospf->lsa_refresh_queue.index;
-
+
/* Note: if clock has jumped backwards, then time change could be negative,
so we are careful to cast the expression to unsigned before taking
modulus. */
@@ -3684,7 +3688,7 @@ ospf_lsa_refresh_walker (struct thread *t)
"refresh index %d", i);
refresh_list = ospf->lsa_refresh_queue.qs [i];
-
+
assert (i >= 0);
ospf->lsa_refresh_queue.qs [i] = NULL;
@@ -3695,9 +3699,9 @@ ospf_lsa_refresh_walker (struct thread *t)
{
if (IS_DEBUG_OSPF (lsa, LSA_REFRESH))
zlog_debug ("LSA[Refresh:%s]: ospf_lsa_refresh_walker(): "
- "refresh lsa %p (slot %d)",
+ "refresh lsa %p (slot %d)",
inet_ntoa (lsa->data->id), lsa, i);
-
+
assert (lsa->lock > 0);
list_delete_node (refresh_list, node);
lsa->refresh_list = -1;
@@ -3717,12 +3721,12 @@ ospf_lsa_refresh_walker (struct thread *t)
assert (lsa->lock > 0);
ospf_lsa_unlock (&lsa); /* lsa_refresh_queue & temp for lsa_to_refresh*/
}
-
+
list_delete (lsa_to_refresh);
-
+
if (IS_DEBUG_OSPF (lsa, LSA_REFRESH))
zlog_debug ("LSA[Refresh]: ospf_lsa_refresh_walker(): end");
-
+
return 0;
}