summaryrefslogtreecommitdiff
path: root/ospf6d/ospf6_flood.c
diff options
context:
space:
mode:
authorhasso <hasso>2004-09-01 21:36:14 +0000
committerhasso <hasso>2004-09-01 21:36:14 +0000
commit1e05838a4db178f25eef560d774cf63d7af6d3c4 (patch)
treef87bdb34ec1337e390b885d5344f1a40c7dbb383 /ospf6d/ospf6_flood.c
parent863076db0f6ef0f9090abdfd9e2388db0bf02770 (diff)
Merge svn revision 975 from Zebra repository.
Diffstat (limited to 'ospf6d/ospf6_flood.c')
-rw-r--r--ospf6d/ospf6_flood.c161
1 files changed, 115 insertions, 46 deletions
diff --git a/ospf6d/ospf6_flood.c b/ospf6d/ospf6_flood.c
index ec5c1c68..e9ba52b0 100644
--- a/ospf6d/ospf6_flood.c
+++ b/ospf6d/ospf6_flood.c
@@ -25,6 +25,7 @@
#include "thread.h"
#include "linklist.h"
#include "vty.h"
+#include "command.h"
#include "ospf6d.h"
#include "ospf6_proto.h"
@@ -41,6 +42,8 @@
#include "ospf6_flood.h"
+unsigned char conf_debug_ospf6_flooding;
+
struct ospf6_lsdb *
ospf6_get_scoped_lsdb (struct ospf6_lsa *lsa)
{
@@ -99,7 +102,7 @@ ospf6_lsa_originate (struct ospf6_lsa *lsa)
suppress this update of the LSA */
if (old && ! OSPF6_LSA_IS_DIFFER (lsa, old))
{
- if (IS_OSPF6_DEBUG_LSA (ORIGINATE))
+ if (IS_OSPF6_DEBUG_ORIGINATE_TYPE (lsa->header->type))
zlog_info ("Suppress updating LSA: %s", lsa->name);
ospf6_lsa_delete (lsa);
return;
@@ -112,7 +115,8 @@ ospf6_lsa_originate (struct ospf6_lsa *lsa)
lsa->refresh = thread_add_timer (master, ospf6_lsa_refresh, lsa,
LS_REFRESH_TIME);
- if (IS_OSPF6_DEBUG_LSA (ORIGINATE))
+ if (IS_OSPF6_DEBUG_LSA_TYPE (lsa->header->type) ||
+ IS_OSPF6_DEBUG_ORIGINATE_TYPE (lsa->header->type))
{
zlog_info ("LSA Originate:");
ospf6_lsa_header_print (lsa);
@@ -185,14 +189,14 @@ ospf6_decrement_retrans_count (struct ospf6_lsa *lsa)
/* The LSA must be on the retrans-list of a neighbor. It means
the "lsa" is a copied one, and we have to decrement the
- retransmission count of the original one (instead of "lsa"'s).
+ retransmission count of the original one (instead of this "lsa"'s).
In order to find the original LSA, first we have to find
appropriate LSDB that have the original LSA. */
lsdb = ospf6_get_scoped_lsdb (lsa);
/* Find the original LSA of which the retrans_count should be decremented */
orig = ospf6_lsdb_lookup (lsa->header->type, lsa->header->id,
- lsa->header->adv_router, lsdb);
+ lsa->header->adv_router, lsdb);
if (orig)
{
orig->retrans_count--;
@@ -207,7 +211,8 @@ ospf6_install_lsa (struct ospf6_lsa *lsa)
struct ospf6_lsa *old;
struct timeval now;
- if (IS_OSPF6_DEBUG_LSA (RECV) || IS_OSPF6_DEBUG_LSA (DATABASE))
+ if (IS_OSPF6_DEBUG_LSA_TYPE (lsa->header->type) ||
+ IS_OSPF6_DEBUG_EXAMIN_TYPE (lsa->header->type))
zlog_info ("Install LSA: %s", lsa->name);
/* Remove the old instance from all neighbors' Link state
@@ -244,22 +249,27 @@ ospf6_flood_interface (struct ospf6_neighbor *from,
struct ospf6_neighbor *on;
struct ospf6_lsa *req;
int retrans_added = 0;
+ int is_debug = 0;
- if (IS_OSPF6_DEBUG_LSA (SEND))
- zlog_info ("Flooding on %s: %s", oi->interface->name, lsa->name);
+ if (IS_OSPF6_DEBUG_FLOODING ||
+ IS_OSPF6_DEBUG_FLOOD_TYPE (lsa->header->type))
+ {
+ is_debug++;
+ zlog_info ("Flooding on %s: %s", oi->interface->name, lsa->name);
+ }
/* (1) For each neighbor */
for (node = listhead (oi->neighbor_list); node; nextnode (node))
{
on = (struct ospf6_neighbor *) getdata (node);
- if (IS_OSPF6_DEBUG_LSA (SEND))
+ if (is_debug)
zlog_info ("To neighbor %s", on->name);
/* (a) if neighbor state < Exchange, examin next */
if (on->state < OSPF6_NEIGHBOR_EXCHANGE)
{
- if (IS_OSPF6_DEBUG_LSA (SEND))
+ if (is_debug)
zlog_info ("Neighbor state less than ExChange, next neighbor");
continue;
}
@@ -267,14 +277,14 @@ ospf6_flood_interface (struct ospf6_neighbor *from,
/* (b) if neighbor not yet Full, check request-list */
if (on->state != OSPF6_NEIGHBOR_FULL)
{
- if (IS_OSPF6_DEBUG_LSA (SEND))
+ if (is_debug)
zlog_info ("Neighbor not yet Full");
req = ospf6_lsdb_lookup (lsa->header->type, lsa->header->id,
lsa->header->adv_router, on->request_list);
if (req == NULL)
{
- if (IS_OSPF6_DEBUG_LSA (SEND))
+ if (is_debug)
zlog_info ("Not on request-list for this neighbor");
/* fall through */
}
@@ -283,7 +293,7 @@ ospf6_flood_interface (struct ospf6_neighbor *from,
/* If new LSA less recent, examin next neighbor */
if (ospf6_lsa_compare (lsa, req) > 0)
{
- if (IS_OSPF6_DEBUG_LSA (SEND))
+ if (is_debug)
zlog_info ("Requesting is newer, next neighbor");
continue;
}
@@ -292,7 +302,7 @@ ospf6_flood_interface (struct ospf6_neighbor *from,
examin next neighbor */
if (ospf6_lsa_compare (lsa, req) == 0)
{
- if (IS_OSPF6_DEBUG_LSA (SEND))
+ if (is_debug)
zlog_info ("Requesting the same, remove it, next neighbor");
ospf6_lsdb_remove (req, on->request_list);
continue;
@@ -301,7 +311,7 @@ ospf6_flood_interface (struct ospf6_neighbor *from,
/* If the new LSA is more recent, delete from request-list */
if (ospf6_lsa_compare (lsa, req) < 0)
{
- if (IS_OSPF6_DEBUG_LSA (SEND))
+ if (is_debug)
zlog_info ("Received is newer, remove requesting");
ospf6_lsdb_remove (req, on->request_list);
/* fall through */
@@ -313,13 +323,13 @@ ospf6_flood_interface (struct ospf6_neighbor *from,
examin next neighbor */
if (from == on)
{
- if (IS_OSPF6_DEBUG_LSA (SEND))
+ if (is_debug)
zlog_info ("Received is from the neighbor, next neighbor");
continue;
}
/* (d) add retrans-list, schedule retransmission */
- if (IS_OSPF6_DEBUG_LSA (SEND))
+ if (is_debug)
zlog_info ("Add retrans-list of this neighbor");
ospf6_increment_retrans_count (lsa);
ospf6_lsdb_add (ospf6_lsa_copy (lsa), on->retrans_list);
@@ -333,7 +343,7 @@ ospf6_flood_interface (struct ospf6_neighbor *from,
/* (2) examin next interface if not added to retrans-list */
if (retrans_added == 0)
{
- if (IS_OSPF6_DEBUG_LSA (SEND))
+ if (is_debug)
zlog_info ("No retransmission scheduled, next interface");
return;
}
@@ -343,7 +353,7 @@ ospf6_flood_interface (struct ospf6_neighbor *from,
if (from && from->ospf6_if == oi &&
(from->router_id == oi->drouter || from->router_id == oi->bdrouter))
{
- if (IS_OSPF6_DEBUG_LSA (SEND))
+ if (is_debug)
zlog_info ("Received is from the I/F's DR or BDR, next interface");
return;
}
@@ -352,13 +362,13 @@ ospf6_flood_interface (struct ospf6_neighbor *from,
and the interface state is BDR, examin next interface */
if (from && from->ospf6_if == oi && oi->state == OSPF6_INTERFACE_BDR)
{
- if (IS_OSPF6_DEBUG_LSA (SEND))
+ if (is_debug)
zlog_info ("Received is from the I/F, itself BDR, next interface");
return;
}
/* (5) flood the LSA out the interface. */
- if (IS_OSPF6_DEBUG_LSA (SEND))
+ if (is_debug)
zlog_info ("Schedule flooding for the interface");
if (if_is_broadcast (oi->interface))
{
@@ -451,7 +461,8 @@ ospf6_flood_clear_interface (struct ospf6_lsa *lsa, struct ospf6_interface *oi)
lsa->header->adv_router, on->retrans_list);
if (rem && ! ospf6_lsa_compare (rem, lsa))
{
- if (IS_OSPF6_DEBUG_LSA (DATABASE))
+ if (IS_OSPF6_DEBUG_FLOODING ||
+ IS_OSPF6_DEBUG_FLOOD_TYPE (lsa->header->type))
zlog_info ("Remove %s from retrans_list of %s",
rem->name, on->name);
ospf6_decrement_retrans_count (rem);
@@ -522,6 +533,11 @@ ospf6_acknowledge_lsa_bdrouter (struct ospf6_lsa *lsa, int ismore_recent,
struct ospf6_neighbor *from)
{
struct ospf6_interface *oi;
+ int is_debug = 0;
+
+ if (IS_OSPF6_DEBUG_FLOODING ||
+ IS_OSPF6_DEBUG_FLOOD_TYPE (lsa->header->type))
+ is_debug++;
assert (from && from->ospf6_if);
oi = from->ospf6_if;
@@ -530,7 +546,7 @@ ospf6_acknowledge_lsa_bdrouter (struct ospf6_lsa *lsa, int ismore_recent,
No acknowledgement sent. */
if (CHECK_FLAG (lsa->flag, OSPF6_LSA_FLOODBACK))
{
- if (IS_OSPF6_DEBUG_LSA (RECV))
+ if (is_debug)
zlog_info ("No acknowledgement (BDR & FloodBack)");
return;
}
@@ -543,7 +559,7 @@ ospf6_acknowledge_lsa_bdrouter (struct ospf6_lsa *lsa, int ismore_recent,
{
if (oi->drouter == from->router_id)
{
- if (IS_OSPF6_DEBUG_LSA (RECV))
+ if (is_debug)
zlog_info ("Delayed acknowledgement (BDR & MoreRecent & from DR)");
/* Delayed acknowledgement */
ospf6_lsdb_add (ospf6_lsa_copy (lsa), oi->lsack_list);
@@ -553,7 +569,7 @@ ospf6_acknowledge_lsa_bdrouter (struct ospf6_lsa *lsa, int ismore_recent,
}
else
{
- if (IS_OSPF6_DEBUG_LSA (RECV))
+ if (is_debug)
zlog_info ("No acknowledgement (BDR & MoreRecent & ! from DR)");
}
return;
@@ -567,7 +583,7 @@ ospf6_acknowledge_lsa_bdrouter (struct ospf6_lsa *lsa, int ismore_recent,
{
if (oi->drouter == from->router_id)
{
- if (IS_OSPF6_DEBUG_LSA (RECV))
+ if (is_debug)
zlog_info ("Delayed acknowledgement (BDR & Duplicate & ImpliedAck & from DR)");
/* Delayed acknowledgement */
ospf6_lsdb_add (ospf6_lsa_copy (lsa), oi->lsack_list);
@@ -577,7 +593,7 @@ ospf6_acknowledge_lsa_bdrouter (struct ospf6_lsa *lsa, int ismore_recent,
}
else
{
- if (IS_OSPF6_DEBUG_LSA (RECV))
+ if (is_debug)
zlog_info ("No acknowledgement (BDR & Duplicate & ImpliedAck & ! from DR)");
}
return;
@@ -588,7 +604,7 @@ ospf6_acknowledge_lsa_bdrouter (struct ospf6_lsa *lsa, int ismore_recent,
if (CHECK_FLAG (lsa->flag, OSPF6_LSA_DUPLICATE) &&
! CHECK_FLAG (lsa->flag, OSPF6_LSA_IMPLIEDACK))
{
- if (IS_OSPF6_DEBUG_LSA (RECV))
+ if (is_debug)
zlog_info ("Direct acknowledgement (BDR & Duplicate)");
ospf6_lsdb_add (ospf6_lsa_copy (lsa), from->lsack_list);
if (from->thread_send_lsack == NULL)
@@ -609,6 +625,11 @@ ospf6_acknowledge_lsa_allother (struct ospf6_lsa *lsa, int ismore_recent,
struct ospf6_neighbor *from)
{
struct ospf6_interface *oi;
+ int is_debug = 0;
+
+ if (IS_OSPF6_DEBUG_FLOODING ||
+ IS_OSPF6_DEBUG_FLOOD_TYPE (lsa->header->type))
+ is_debug++;
assert (from && from->ospf6_if);
oi = from->ospf6_if;
@@ -617,7 +638,7 @@ ospf6_acknowledge_lsa_allother (struct ospf6_lsa *lsa, int ismore_recent,
No acknowledgement sent. */
if (CHECK_FLAG (lsa->flag, OSPF6_LSA_FLOODBACK))
{
- if (IS_OSPF6_DEBUG_LSA (RECV))
+ if (is_debug)
zlog_info ("No acknowledgement (AllOther & FloodBack)");
return;
}
@@ -626,7 +647,7 @@ ospf6_acknowledge_lsa_allother (struct ospf6_lsa *lsa, int ismore_recent,
back out receiving interface. Delayed acknowledgement sent. */
if (ismore_recent < 0)
{
- if (IS_OSPF6_DEBUG_LSA (RECV))
+ if (is_debug)
zlog_info ("Delayed acknowledgement (AllOther & MoreRecent)");
/* Delayed acknowledgement */
ospf6_lsdb_add (ospf6_lsa_copy (lsa), oi->lsack_list);
@@ -641,7 +662,7 @@ ospf6_acknowledge_lsa_allother (struct ospf6_lsa *lsa, int ismore_recent,
if (CHECK_FLAG (lsa->flag, OSPF6_LSA_DUPLICATE) &&
CHECK_FLAG (lsa->flag, OSPF6_LSA_IMPLIEDACK))
{
- if (IS_OSPF6_DEBUG_LSA (RECV))
+ if (is_debug)
zlog_info ("No acknowledgement (AllOther & Duplicate & ImpliedAck)");
return;
}
@@ -651,7 +672,7 @@ ospf6_acknowledge_lsa_allother (struct ospf6_lsa *lsa, int ismore_recent,
if (CHECK_FLAG (lsa->flag, OSPF6_LSA_DUPLICATE) &&
! CHECK_FLAG (lsa->flag, OSPF6_LSA_IMPLIEDACK))
{
- if (IS_OSPF6_DEBUG_LSA (RECV))
+ if (is_debug)
zlog_info ("Direct acknowledgement (AllOther & Duplicate)");
ospf6_lsdb_add (ospf6_lsa_copy (lsa), from->lsack_list);
if (from->thread_send_lsack == NULL)
@@ -733,6 +754,7 @@ ospf6_receive_lsa (struct ospf6_neighbor *from,
struct ospf6_lsa *new = NULL, *old = NULL, *rem = NULL;
int ismore_recent;
unsigned short cksum;
+ int is_debug = 0;
ismore_recent = 1;
assert (from);
@@ -740,8 +762,10 @@ ospf6_receive_lsa (struct ospf6_neighbor *from,
/* make lsa structure for received lsa */
new = ospf6_lsa_create (lsa_header);
- if (IS_OSPF6_DEBUG_LSA (RECV))
+ if (IS_OSPF6_DEBUG_FLOODING ||
+ IS_OSPF6_DEBUG_FLOOD_TYPE (new->header->type))
{
+ is_debug++;
zlog_info ("LSA Receive from %s", from->name);
ospf6_lsa_header_print (new);
}
@@ -750,7 +774,7 @@ ospf6_receive_lsa (struct ospf6_neighbor *from,
cksum = ntohs (new->header->checksum);
if (ntohs (ospf6_lsa_checksum (new->header)) != cksum)
{
- if (IS_OSPF6_DEBUG_LSA (RECV))
+ if (is_debug)
zlog_info ("Wrong LSA Checksum, discard");
ospf6_lsa_delete (new);
return;
@@ -761,7 +785,7 @@ ospf6_receive_lsa (struct ospf6_neighbor *from,
if (IS_AREA_STUB (from->ospf6_if->area) &&
OSPF6_LSA_SCOPE (new->header->type) == OSPF6_SCOPE_AS)
{
- if (IS_OSPF6_DEBUG_LSA (RECV))
+ if (is_debug)
zlog_info ("AS-External-LSA (or AS-scope LSA) in stub area, discard");
ospf6_lsa_delete (new);
return;
@@ -783,7 +807,7 @@ ospf6_receive_lsa (struct ospf6_neighbor *from,
new->lsdb = from->ospf6_if->area->ospf6->lsdb;
break;
default:
- if (IS_OSPF6_DEBUG_LSA (RECV))
+ if (is_debug)
zlog_info ("LSA has reserved scope, discard");
ospf6_lsa_delete (new);
return;
@@ -794,7 +818,7 @@ ospf6_receive_lsa (struct ospf6_neighbor *from,
if (ospf6_is_maxage_lsa_drop (new, from))
{
/* log */
- if (IS_OSPF6_DEBUG_LSA (RECV))
+ if (is_debug)
zlog_info ("Drop MaxAge LSA with direct acknowledgement.");
/* a) Acknowledge back to neighbor (Direct acknowledgement, 13.5) */
@@ -817,7 +841,7 @@ ospf6_receive_lsa (struct ospf6_neighbor *from,
ismore_recent = ospf6_lsa_compare (new, old);
if (ntohl (new->header->seqnum) == ntohl (old->header->seqnum))
{
- if (IS_OSPF6_DEBUG_LSA (RECV))
+ if (is_debug)
zlog_info ("Received is duplicated LSA");
SET_FLAG (new->flag, OSPF6_LSA_DUPLICATE);
}
@@ -837,7 +861,7 @@ ospf6_receive_lsa (struct ospf6_neighbor *from,
timersub (&now, &old->installed, &res);
if (res.tv_sec < MIN_LS_ARRIVAL)
{
- if (IS_OSPF6_DEBUG_LSA (RECV) || IS_OSPF6_DEBUG_LSA (TIMER))
+ if (is_debug)
zlog_info ("LSA can't be updated within MinLSArrival, discard");
ospf6_lsa_delete (new);
return; /* examin next lsa */
@@ -846,7 +870,7 @@ ospf6_receive_lsa (struct ospf6_neighbor *from,
gettimeofday (&new->received, (struct timezone *) NULL);
- if (IS_OSPF6_DEBUG_LSA (RECV))
+ if (is_debug)
zlog_info ("Flood, Install, Possibly acknowledge the received LSA");
/* (b) immediately flood and (c) remove from all retrans-list */
@@ -873,7 +897,7 @@ ospf6_receive_lsa (struct ospf6_neighbor *from,
/* Self-originated LSA (newer than ours) is received from
another router. We have to make a new instance of the LSA
or have to flush this LSA. */
- if (IS_OSPF6_DEBUG_LSA (RECV))
+ if (is_debug)
{
zlog_info ("Newer instance of the self-originated LSA");
zlog_info ("Schedule reorigination");
@@ -891,7 +915,7 @@ ospf6_receive_lsa (struct ospf6_neighbor *from,
/* if no database copy, should go above state (5) */
assert (old);
- if (IS_OSPF6_DEBUG_LSA (RECV))
+ if (is_debug)
{
zlog_info ("Received is not newer, on the neighbor's request-list");
zlog_info ("BadLSReq, discard the received LSA");
@@ -907,7 +931,7 @@ ospf6_receive_lsa (struct ospf6_neighbor *from,
/* (7) if neither one is more recent */
if (ismore_recent == 0)
{
- if (IS_OSPF6_DEBUG_LSA (RECV))
+ if (is_debug)
zlog_info ("The same instance as database copy (neither recent)");
/* (a) if on retrans-list, Treat this LSA as an Ack: Implied Ack */
@@ -915,7 +939,7 @@ ospf6_receive_lsa (struct ospf6_neighbor *from,
new->header->adv_router, from->retrans_list);
if (rem)
{
- if (IS_OSPF6_DEBUG_LSA (RECV))
+ if (is_debug)
{
zlog_info ("It is on the neighbor's retrans-list.");
zlog_info ("Treat as an Implied acknowledgement");
@@ -925,7 +949,7 @@ ospf6_receive_lsa (struct ospf6_neighbor *from,
ospf6_lsdb_remove (rem, from->retrans_list);
}
- if (IS_OSPF6_DEBUG_LSA (RECV))
+ if (is_debug)
zlog_info ("Possibly acknowledge and then discard");
/* (b) possibly acknowledge */
@@ -944,7 +968,7 @@ ospf6_receive_lsa (struct ospf6_neighbor *from,
if (OSPF6_LSA_IS_MAXAGE (old) &&
old->header->seqnum == htonl (MAX_SEQUENCE_NUMBER))
{
- if (IS_OSPF6_DEBUG_LSA (RECV))
+ if (is_debug)
{
zlog_info ("The LSA is in Seqnumber Wrapping");
zlog_info ("MaxAge & MaxSeqNum, discard");
@@ -955,7 +979,7 @@ ospf6_receive_lsa (struct ospf6_neighbor *from,
/* Otherwise, Send database copy of this LSA to this neighbor */
{
- if (IS_OSPF6_DEBUG_LSA (RECV))
+ if (is_debug)
{
zlog_info ("Database copy is more recent.");
zlog_info ("Send back directly and then discard");
@@ -975,4 +999,49 @@ ospf6_receive_lsa (struct ospf6_neighbor *from,
}
+DEFUN (debug_ospf6_flooding,
+ debug_ospf6_flooding_cmd,
+ "debug ospf6 flooding",
+ DEBUG_STR
+ OSPF6_STR
+ "Debug OSPFv3 flooding function\n"
+ )
+{
+ OSPF6_DEBUG_FLOODING_ON ();
+ return CMD_SUCCESS;
+}
+
+DEFUN (no_debug_ospf6_flooding,
+ no_debug_ospf6_flooding_cmd,
+ "no debug ospf6 flooding",
+ NO_STR
+ DEBUG_STR
+ OSPF6_STR
+ "Debug OSPFv3 flooding function\n"
+ )
+{
+ OSPF6_DEBUG_FLOODING_OFF ();
+ return CMD_SUCCESS;
+}
+
+int
+config_write_ospf6_debug_flood (struct vty *vty)
+{
+ if (IS_OSPF6_DEBUG_FLOODING)
+ vty_out (vty, "debug ospf6 flooding%s", VNL);
+ return 0;
+}
+
+void
+install_element_ospf6_debug_flood ()
+{
+ install_element (ENABLE_NODE, &debug_ospf6_flooding_cmd);
+ install_element (ENABLE_NODE, &no_debug_ospf6_flooding_cmd);
+ install_element (CONFIG_NODE, &debug_ospf6_flooding_cmd);
+ install_element (CONFIG_NODE, &no_debug_ospf6_flooding_cmd);
+}
+
+
+
+