2002-12-13 21:15:29 +01:00
|
|
|
|
/*
|
|
|
|
|
* OSPF Link State Advertisement
|
|
|
|
|
* Copyright (C) 1999, 2000 Toshiaki Takada
|
|
|
|
|
*
|
|
|
|
|
* This file is part of GNU Zebra.
|
|
|
|
|
*
|
|
|
|
|
* GNU Zebra is free software; you can redistribute it and/or modify it
|
|
|
|
|
* under the terms of the GNU General Public License as published by the
|
|
|
|
|
* Free Software Foundation; either version 2, or (at your option) any
|
|
|
|
|
* later version.
|
|
|
|
|
*
|
|
|
|
|
* GNU Zebra is distributed in the hope that it will be useful, but
|
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
* General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with GNU Zebra; see the file COPYING. If not, write to the Free
|
|
|
|
|
* Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
|
|
|
|
* 02111-1307, USA.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <zebra.h>
|
|
|
|
|
|
|
|
|
|
#include "linklist.h"
|
|
|
|
|
#include "prefix.h"
|
|
|
|
|
#include "if.h"
|
|
|
|
|
#include "table.h"
|
|
|
|
|
#include "memory.h"
|
|
|
|
|
#include "stream.h"
|
|
|
|
|
#include "log.h"
|
|
|
|
|
#include "thread.h"
|
|
|
|
|
#include "hash.h"
|
|
|
|
|
#include "sockunion.h" /* for inet_aton() */
|
2008-08-13 20:09:10 +02:00
|
|
|
|
#include "checksum.h"
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
|
|
#include "ospfd/ospfd.h"
|
|
|
|
|
#include "ospfd/ospf_interface.h"
|
|
|
|
|
#include "ospfd/ospf_ism.h"
|
|
|
|
|
#include "ospfd/ospf_asbr.h"
|
|
|
|
|
#include "ospfd/ospf_lsa.h"
|
|
|
|
|
#include "ospfd/ospf_lsdb.h"
|
|
|
|
|
#include "ospfd/ospf_neighbor.h"
|
|
|
|
|
#include "ospfd/ospf_nsm.h"
|
|
|
|
|
#include "ospfd/ospf_flood.h"
|
|
|
|
|
#include "ospfd/ospf_packet.h"
|
|
|
|
|
#include "ospfd/ospf_spf.h"
|
|
|
|
|
#include "ospfd/ospf_dump.h"
|
|
|
|
|
#include "ospfd/ospf_route.h"
|
|
|
|
|
#include "ospfd/ospf_ase.h"
|
|
|
|
|
#include "ospfd/ospf_zebra.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
u_int32_t
|
|
|
|
|
get_metric (u_char *metric)
|
|
|
|
|
{
|
|
|
|
|
u_int32_t m;
|
|
|
|
|
m = metric[0];
|
|
|
|
|
m = (m << 8) + metric[1];
|
|
|
|
|
m = (m << 8) + metric[2];
|
|
|
|
|
return m;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct timeval
|
|
|
|
|
tv_adjust (struct timeval a)
|
|
|
|
|
{
|
|
|
|
|
while (a.tv_usec >= 1000000)
|
|
|
|
|
{
|
|
|
|
|
a.tv_usec -= 1000000;
|
|
|
|
|
a.tv_sec++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
while (a.tv_usec < 0)
|
|
|
|
|
{
|
|
|
|
|
a.tv_usec += 1000000;
|
|
|
|
|
a.tv_sec--;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return a;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
tv_ceil (struct timeval a)
|
|
|
|
|
{
|
|
|
|
|
a = tv_adjust (a);
|
|
|
|
|
|
|
|
|
|
return (a.tv_usec ? a.tv_sec + 1 : a.tv_sec);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
tv_floor (struct timeval a)
|
|
|
|
|
{
|
|
|
|
|
a = tv_adjust (a);
|
|
|
|
|
|
|
|
|
|
return a.tv_sec;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct timeval
|
|
|
|
|
int2tv (int a)
|
|
|
|
|
{
|
|
|
|
|
struct timeval ret;
|
|
|
|
|
|
|
|
|
|
ret.tv_sec = a;
|
|
|
|
|
ret.tv_usec = 0;
|
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct timeval
|
|
|
|
|
tv_add (struct timeval a, struct timeval b)
|
|
|
|
|
{
|
|
|
|
|
struct timeval ret;
|
|
|
|
|
|
|
|
|
|
ret.tv_sec = a.tv_sec + b.tv_sec;
|
|
|
|
|
ret.tv_usec = a.tv_usec + b.tv_usec;
|
|
|
|
|
|
|
|
|
|
return tv_adjust (ret);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct timeval
|
|
|
|
|
tv_sub (struct timeval a, struct timeval b)
|
|
|
|
|
{
|
|
|
|
|
struct timeval ret;
|
|
|
|
|
|
|
|
|
|
ret.tv_sec = a.tv_sec - b.tv_sec;
|
|
|
|
|
ret.tv_usec = a.tv_usec - b.tv_usec;
|
|
|
|
|
|
|
|
|
|
return tv_adjust (ret);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
tv_cmp (struct timeval a, struct timeval b)
|
|
|
|
|
{
|
|
|
|
|
return (a.tv_sec == b.tv_sec ?
|
|
|
|
|
a.tv_usec - b.tv_usec : a.tv_sec - b.tv_sec);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
ospf_lsa_refresh_delay (struct ospf_lsa *lsa)
|
|
|
|
|
{
|
|
|
|
|
struct timeval delta, now;
|
|
|
|
|
int delay = 0;
|
|
|
|
|
|
2006-08-27 08:49:29 +02:00
|
|
|
|
quagga_gettime (QUAGGA_CLK_MONOTONIC, &now);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
delta = tv_sub (now, lsa->tv_orig);
|
|
|
|
|
|
|
|
|
|
if (tv_cmp (delta, int2tv (OSPF_MIN_LS_INTERVAL)) < 0)
|
|
|
|
|
{
|
|
|
|
|
delay = tv_ceil (tv_sub (int2tv (OSPF_MIN_LS_INTERVAL), delta));
|
|
|
|
|
|
|
|
|
|
if (IS_DEBUG_OSPF (lsa, LSA_GENERATE))
|
2004-12-08 19:12:06 +01:00
|
|
|
|
zlog_debug ("LSA[Type%d:%s]: Refresh timer delay %d seconds",
|
2002-12-13 21:15:29 +01:00
|
|
|
|
lsa->data->type, inet_ntoa (lsa->data->id), delay);
|
|
|
|
|
|
|
|
|
|
assert (delay > 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return delay;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
get_age (struct ospf_lsa *lsa)
|
|
|
|
|
{
|
|
|
|
|
int age;
|
|
|
|
|
|
2006-08-27 08:49:29 +02:00
|
|
|
|
age = ntohs (lsa->data->ls_age)
|
|
|
|
|
+ tv_floor (tv_sub (recent_relative_time (), lsa->tv_recv));
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
|
|
return age;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Fletcher Checksum -- Refer to RFC1008. */
|
|
|
|
|
|
2008-08-13 20:09:10 +02:00
|
|
|
|
/* All the offsets are zero-based. The offsets in the RFC1008 are
|
|
|
|
|
one-based. */
|
2002-12-13 21:15:29 +01:00
|
|
|
|
u_int16_t
|
|
|
|
|
ospf_lsa_checksum (struct lsa_header *lsa)
|
|
|
|
|
{
|
2008-08-13 20:09:10 +02:00
|
|
|
|
u_char *buffer = (u_char *) &lsa->options;
|
|
|
|
|
int options_offset = buffer - (u_char *) &lsa->ls_age; /* should be 2 */
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
2008-08-13 20:09:10 +02:00
|
|
|
|
/* Skip the AGE field */
|
|
|
|
|
u_int16_t len = ntohs(lsa->length) - options_offset;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
2008-08-13 20:09:10 +02:00
|
|
|
|
/* Checksum offset starts from "options" field, not the beginning of the
|
|
|
|
|
lsa_header struct. The offset is 14, rather than 16. */
|
|
|
|
|
int checksum_offset = (u_char *) &lsa->checksum - buffer;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
2008-08-13 20:09:10 +02:00
|
|
|
|
return fletcher_checksum(buffer, len, checksum_offset);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Create OSPF LSA. */
|
|
|
|
|
struct ospf_lsa *
|
|
|
|
|
ospf_lsa_new ()
|
|
|
|
|
{
|
|
|
|
|
struct ospf_lsa *new;
|
|
|
|
|
|
|
|
|
|
new = XCALLOC (MTYPE_OSPF_LSA, sizeof (struct ospf_lsa));
|
|
|
|
|
|
|
|
|
|
new->flags = 0;
|
|
|
|
|
new->lock = 1;
|
|
|
|
|
new->retransmit_counter = 0;
|
2006-08-27 08:49:29 +02:00
|
|
|
|
new->tv_recv = recent_relative_time ();
|
2002-12-13 21:15:29 +01:00
|
|
|
|
new->tv_orig = new->tv_recv;
|
|
|
|
|
new->refresh_list = -1;
|
|
|
|
|
|
|
|
|
|
return new;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Duplicate OSPF LSA. */
|
|
|
|
|
struct ospf_lsa *
|
|
|
|
|
ospf_lsa_dup (struct ospf_lsa *lsa)
|
|
|
|
|
{
|
|
|
|
|
struct ospf_lsa *new;
|
|
|
|
|
|
|
|
|
|
if (lsa == NULL)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
new = XCALLOC (MTYPE_OSPF_LSA, sizeof (struct ospf_lsa));
|
|
|
|
|
|
|
|
|
|
memcpy (new, lsa, sizeof (struct ospf_lsa));
|
|
|
|
|
UNSET_FLAG (new->flags, OSPF_LSA_DISCARD);
|
|
|
|
|
new->lock = 1;
|
|
|
|
|
new->retransmit_counter = 0;
|
|
|
|
|
new->data = ospf_lsa_data_dup (lsa->data);
|
|
|
|
|
|
2002-12-13 22:44:27 +01:00
|
|
|
|
/* kevinm: Clear the refresh_list, otherwise there are going
|
|
|
|
|
to be problems when we try to remove the LSA from the
|
|
|
|
|
queue (which it's not a member of.)
|
|
|
|
|
XXX: Should we add the LSA to the refresh_list queue? */
|
|
|
|
|
new->refresh_list = -1;
|
|
|
|
|
|
|
|
|
|
if (IS_DEBUG_OSPF (lsa, LSA))
|
2004-12-08 19:12:06 +01:00
|
|
|
|
zlog_debug ("LSA: duplicated %p (new: %p)", lsa, new);
|
2002-12-13 22:44:27 +01:00
|
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
|
return new;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Free OSPF LSA. */
|
|
|
|
|
void
|
|
|
|
|
ospf_lsa_free (struct ospf_lsa *lsa)
|
|
|
|
|
{
|
|
|
|
|
assert (lsa->lock == 0);
|
|
|
|
|
|
|
|
|
|
if (IS_DEBUG_OSPF (lsa, LSA))
|
2004-12-08 19:12:06 +01:00
|
|
|
|
zlog_debug ("LSA: freed %p", lsa);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
|
|
/* Delete LSA data. */
|
|
|
|
|
if (lsa->data != NULL)
|
|
|
|
|
ospf_lsa_data_free (lsa->data);
|
|
|
|
|
|
|
|
|
|
assert (lsa->refresh_list < 0);
|
|
|
|
|
|
|
|
|
|
memset (lsa, 0, sizeof (struct ospf_lsa));
|
|
|
|
|
XFREE (MTYPE_OSPF_LSA, lsa);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Lock LSA. */
|
|
|
|
|
struct ospf_lsa *
|
|
|
|
|
ospf_lsa_lock (struct ospf_lsa *lsa)
|
|
|
|
|
{
|
|
|
|
|
lsa->lock++;
|
|
|
|
|
return lsa;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Unlock LSA. */
|
|
|
|
|
void
|
2006-07-26 11:37:26 +02:00
|
|
|
|
ospf_lsa_unlock (struct ospf_lsa **lsa)
|
2002-12-13 21:15:29 +01:00
|
|
|
|
{
|
|
|
|
|
/* This is sanity check. */
|
2006-07-26 11:37:26 +02:00
|
|
|
|
if (!lsa || !*lsa)
|
2002-12-13 21:15:29 +01:00
|
|
|
|
return;
|
|
|
|
|
|
2006-07-26 11:37:26 +02:00
|
|
|
|
(*lsa)->lock--;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
2006-07-26 11:37:26 +02:00
|
|
|
|
assert ((*lsa)->lock >= 0);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
2006-07-26 11:37:26 +02:00
|
|
|
|
if ((*lsa)->lock == 0)
|
2002-12-13 21:15:29 +01:00
|
|
|
|
{
|
2006-07-26 11:37:26 +02:00
|
|
|
|
assert (CHECK_FLAG ((*lsa)->flags, OSPF_LSA_DISCARD));
|
|
|
|
|
ospf_lsa_free (*lsa);
|
|
|
|
|
*lsa = NULL;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Check discard flag. */
|
|
|
|
|
void
|
|
|
|
|
ospf_lsa_discard (struct ospf_lsa *lsa)
|
|
|
|
|
{
|
|
|
|
|
if (!CHECK_FLAG (lsa->flags, OSPF_LSA_DISCARD))
|
|
|
|
|
{
|
|
|
|
|
SET_FLAG (lsa->flags, OSPF_LSA_DISCARD);
|
2006-07-26 11:37:26 +02:00
|
|
|
|
ospf_lsa_unlock (&lsa);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Create LSA data. */
|
|
|
|
|
struct lsa_header *
|
|
|
|
|
ospf_lsa_data_new (size_t size)
|
|
|
|
|
{
|
2008-08-18 23:13:29 +02:00
|
|
|
|
return XCALLOC (MTYPE_OSPF_LSA_DATA, size);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Duplicate LSA data. */
|
|
|
|
|
struct lsa_header *
|
|
|
|
|
ospf_lsa_data_dup (struct lsa_header *lsah)
|
|
|
|
|
{
|
|
|
|
|
struct lsa_header *new;
|
|
|
|
|
|
|
|
|
|
new = ospf_lsa_data_new (ntohs (lsah->length));
|
|
|
|
|
memcpy (new, lsah, ntohs (lsah->length));
|
|
|
|
|
|
|
|
|
|
return new;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Free LSA data. */
|
|
|
|
|
void
|
|
|
|
|
ospf_lsa_data_free (struct lsa_header *lsah)
|
|
|
|
|
{
|
|
|
|
|
if (IS_DEBUG_OSPF (lsa, LSA))
|
2004-12-08 19:12:06 +01:00
|
|
|
|
zlog_debug ("LSA[Type%d:%s]: data freed %p",
|
2002-12-13 21:15:29 +01:00
|
|
|
|
lsah->type, inet_ntoa (lsah->id), lsah);
|
|
|
|
|
|
|
|
|
|
XFREE (MTYPE_OSPF_LSA_DATA, lsah);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* LSA general functions. */
|
|
|
|
|
|
|
|
|
|
const char *
|
|
|
|
|
dump_lsa_key (struct ospf_lsa *lsa)
|
|
|
|
|
{
|
|
|
|
|
static char buf[] = {
|
2004-09-23 21:18:23 +02:00
|
|
|
|
"Type255,id(255.255.255.255),ar(255.255.255.255)"
|
2002-12-13 21:15:29 +01:00
|
|
|
|
};
|
|
|
|
|
struct lsa_header *lsah;
|
|
|
|
|
|
|
|
|
|
if (lsa != NULL && (lsah = lsa->data) != NULL)
|
|
|
|
|
{
|
|
|
|
|
char id[INET_ADDRSTRLEN], ar[INET_ADDRSTRLEN];
|
|
|
|
|
strcpy (id, inet_ntoa (lsah->id));
|
|
|
|
|
strcpy (ar, inet_ntoa (lsah->adv_router));
|
|
|
|
|
|
|
|
|
|
sprintf (buf, "Type%d,id(%s),ar(%s)", lsah->type, id, ar);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
strcpy (buf, "NULL");
|
|
|
|
|
|
|
|
|
|
return buf;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
u_int32_t
|
|
|
|
|
lsa_seqnum_increment (struct ospf_lsa *lsa)
|
|
|
|
|
{
|
|
|
|
|
u_int32_t seqnum;
|
|
|
|
|
|
|
|
|
|
seqnum = ntohl (lsa->data->ls_seqnum) + 1;
|
|
|
|
|
|
|
|
|
|
return htonl (seqnum);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
lsa_header_set (struct stream *s, u_char options,
|
2003-03-25 06:07:42 +01:00
|
|
|
|
u_char type, struct in_addr id, struct in_addr router_id)
|
2002-12-13 21:15:29 +01:00
|
|
|
|
{
|
|
|
|
|
struct lsa_header *lsah;
|
|
|
|
|
|
|
|
|
|
lsah = (struct lsa_header *) STREAM_DATA (s);
|
|
|
|
|
|
|
|
|
|
lsah->ls_age = htons (0);
|
|
|
|
|
lsah->options = options;
|
|
|
|
|
lsah->type = type;
|
|
|
|
|
lsah->id = id;
|
2003-03-25 06:07:42 +01:00
|
|
|
|
lsah->adv_router = router_id;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
lsah->ls_seqnum = htonl (OSPF_INITIAL_SEQUENCE_NUMBER);
|
|
|
|
|
|
2005-02-09 16:51:56 +01:00
|
|
|
|
stream_forward_endp (s, OSPF_LSA_HEADER_SIZE);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
}
|
|
|
|
|
|
2003-03-25 06:07:42 +01:00
|
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
|
/* router-LSA related functions. */
|
|
|
|
|
/* Get router-LSA flags. */
|
2005-05-06 23:37:42 +02:00
|
|
|
|
static u_char
|
2002-12-13 21:15:29 +01:00
|
|
|
|
router_lsa_flags (struct ospf_area *area)
|
|
|
|
|
{
|
|
|
|
|
u_char flags;
|
|
|
|
|
|
2003-03-25 06:07:42 +01:00
|
|
|
|
flags = area->ospf->flags;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
|
|
/* Set virtual link flag. */
|
|
|
|
|
if (ospf_full_virtual_nbrs (area))
|
|
|
|
|
SET_FLAG (flags, ROUTER_LSA_VIRTUAL);
|
|
|
|
|
else
|
|
|
|
|
/* Just sanity check */
|
|
|
|
|
UNSET_FLAG (flags, ROUTER_LSA_VIRTUAL);
|
|
|
|
|
|
|
|
|
|
/* Set Shortcut ABR behabiour flag. */
|
|
|
|
|
UNSET_FLAG (flags, ROUTER_LSA_SHORTCUT);
|
2003-03-25 06:07:42 +01:00
|
|
|
|
if (area->ospf->abr_type == OSPF_ABR_SHORTCUT)
|
2002-12-13 21:15:29 +01:00
|
|
|
|
if (!OSPF_IS_AREA_BACKBONE (area))
|
|
|
|
|
if ((area->shortcut_configured == OSPF_SHORTCUT_DEFAULT &&
|
2003-03-25 06:07:42 +01:00
|
|
|
|
area->ospf->backbone == NULL) ||
|
2002-12-13 21:15:29 +01:00
|
|
|
|
area->shortcut_configured == OSPF_SHORTCUT_ENABLE)
|
|
|
|
|
SET_FLAG (flags, ROUTER_LSA_SHORTCUT);
|
|
|
|
|
|
|
|
|
|
/* ASBR can't exit in stub area. */
|
2007-08-06 17:50:20 +02:00
|
|
|
|
if (area->external_routing == OSPF_AREA_STUB)
|
2003-06-22 10:22:18 +02:00
|
|
|
|
UNSET_FLAG (flags, ROUTER_LSA_EXTERNAL);
|
|
|
|
|
/* If ASBR set External flag */
|
|
|
|
|
else if (IS_OSPF_ASBR (area->ospf))
|
|
|
|
|
SET_FLAG (flags, ROUTER_LSA_EXTERNAL);
|
|
|
|
|
|
|
|
|
|
/* Set ABR dependent flags */
|
|
|
|
|
if (IS_OSPF_ABR (area->ospf))
|
|
|
|
|
{
|
|
|
|
|
SET_FLAG (flags, ROUTER_LSA_BORDER);
|
|
|
|
|
/* If Area is NSSA and we are both ABR and unconditional translator,
|
2003-07-12 23:30:57 +02:00
|
|
|
|
* set Nt bit to inform other routers.
|
2003-06-22 10:22:18 +02:00
|
|
|
|
*/
|
2003-07-12 23:30:57 +02:00
|
|
|
|
if ( (area->external_routing == OSPF_AREA_NSSA)
|
|
|
|
|
&& (area->NSSATranslatorRole == OSPF_NSSA_ROLE_ALWAYS))
|
|
|
|
|
SET_FLAG (flags, ROUTER_LSA_NT);
|
2003-06-22 10:22:18 +02:00
|
|
|
|
}
|
2002-12-13 21:15:29 +01:00
|
|
|
|
return flags;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Lookup neighbor other than myself.
|
|
|
|
|
And check neighbor count,
|
|
|
|
|
Point-to-Point link must have only 1 neighbor. */
|
|
|
|
|
struct ospf_neighbor *
|
2003-03-25 06:07:42 +01:00
|
|
|
|
ospf_nbr_lookup_ptop (struct ospf_interface *oi)
|
2002-12-13 21:15:29 +01:00
|
|
|
|
{
|
|
|
|
|
struct ospf_neighbor *nbr = NULL;
|
2003-03-25 06:07:42 +01:00
|
|
|
|
struct route_node *rn;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
|
|
/* Search neighbor, there must be one of two nbrs. */
|
2003-03-25 06:07:42 +01:00
|
|
|
|
for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
|
|
|
|
|
if ((nbr = rn->info))
|
|
|
|
|
if (!IPV4_ADDR_SAME (&nbr->router_id, &oi->ospf->router_id))
|
2002-12-13 21:15:29 +01:00
|
|
|
|
if (nbr->state == NSM_Full)
|
2003-03-25 06:07:42 +01:00
|
|
|
|
{
|
|
|
|
|
route_unlock_node (rn);
|
|
|
|
|
break;
|
|
|
|
|
}
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
|
|
/* PtoP link must have only 1 neighbor. */
|
2003-03-25 06:07:42 +01:00
|
|
|
|
if (ospf_nbr_count (oi, 0) > 1)
|
2002-12-13 21:15:29 +01:00
|
|
|
|
zlog_warn ("Point-to-Point link has more than 1 neighobrs.");
|
|
|
|
|
|
|
|
|
|
return nbr;
|
|
|
|
|
}
|
|
|
|
|
|
2005-10-29 Paul Jakma <paul.jakma@sun.com>
* (general) RFC3137 stub-router support
* ospfd.h: Add OSPF_OUTPUT_COST_INFINITE define.
(struct ospf_master) Add a OSPF_MASTER_SHUTDOWN flag for
options, to allow shutdown to distinguish between complete
shutdown and shutdown of a subset of ospf instances.
(struct ospf)
Add stub_router_{startup,shutdown_}time, configuration of startup
and shutdown time for stub-router.
Add t_graceful_shutdown struct thread, timer for graceful
shutdown, if needed.
(struct ospf_area) Add stub_router_state - run time state of
stub-router for an area. Add flags for ADMIN, IS and WAS
states.
Add t_stub_router, timer thread to resend router-lsa for an
area.
* ospf_lsa.c: (ospf_link_cost) new simple function to spit out
either the given lnks cost or infinite cost if stub-router is
in effect.
(lsa_link_{ptop,broadcast,virtuallink,ptomp}_set) use
previous function for transit-links.
(ospf_stub_router_timer) timer thread for end of startup stub
router. Change state as required for the area and setup
re-origination of router-lsa.
(ospf_stub_router_check) Check/do whether stub-router should be
enabled, and whether it requires timer to be setup.
(ospf_router_lsa_new) call previous function at top.
(ospf_router_lsa_originate) no external callers, made static.
* ospf_lsa.h: (ospf_router_lsa_originate) removed.
* ospf_main.c: (sigint) make static.
remove call to exit, as ospf_terminate now deals with
exiting.
* ospf_route.c: (ospf_terminate) removed, now in ospfd.c.
* ospf_vty.c: (show_ip_ospf_area) print out state of
stub-router, if active.
(show_ip_ospf) print out configuration of stub-router
support, and details of graceful-shutdown if the timer is
active.
((no)?ospf_max_metric_router_lsa_{admin,startup,shutdown}) new
commands to (de-)?configure stub-router support.
(config_write_stub_router) write out config of stub-router.
(ospf_config_write) call previous.
(ospf_vty_init) install the new stub-router commands.
* ospfd.c: various functions made static.
(ospf_new) Set defaults for stub-router. Graceful shutdown
is made to default on, just to be adventerous.
(ospf_graceful_shutdown_finish) new function, final part of
shutdown.
(ospf_graceful_shutdown_timer) timer thread wrapper for
graceful-shutdown.
(ospf_graceful_shutdown_check) check whether to setup timer
for shutdown or proceed directly to final shutdown.
(ospf_terminate) moved here from ospf_route.c, call
ospf_finish for each instance.
(ospf_finish) renamed to ospf_finish_final and made static.
(ospf_finish) new function, exported wrapper around
ospf_graceful_shutdown_check.
(ospf_finish_final) complete shutdown of an instance.
Add missing TIMER_OFF's of two timer threads.
(ospf_area_free) opaque self lsa timer should be turned off.
2005-10-29 14:50:09 +02:00
|
|
|
|
/* Determine cost of link, taking RFC3137 stub-router support into
|
|
|
|
|
* consideration
|
|
|
|
|
*/
|
|
|
|
|
static u_int16_t
|
|
|
|
|
ospf_link_cost (struct ospf_interface *oi)
|
|
|
|
|
{
|
|
|
|
|
/* RFC3137 stub router support */
|
|
|
|
|
if (!CHECK_FLAG (oi->area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED))
|
|
|
|
|
return oi->output_cost;
|
|
|
|
|
else
|
|
|
|
|
return OSPF_OUTPUT_COST_INFINITE;
|
|
|
|
|
}
|
|
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
|
/* Set a link information. */
|
2006-01-18 16:07:38 +01:00
|
|
|
|
static char
|
2002-12-13 21:15:29 +01:00
|
|
|
|
link_info_set (struct stream *s, struct in_addr id,
|
|
|
|
|
struct in_addr data, u_char type, u_char tos, u_int16_t cost)
|
|
|
|
|
{
|
2006-01-18 16:07:38 +01:00
|
|
|
|
/* LSA stream is initially allocated to OSPF_MAX_LSA_SIZE, suits
|
|
|
|
|
* vast majority of cases. Some rare routers with lots of links need more.
|
|
|
|
|
* we try accomodate those here.
|
|
|
|
|
*/
|
|
|
|
|
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)
|
|
|
|
|
{
|
|
|
|
|
/* we futz the size here for simplicity, really we need to account
|
|
|
|
|
* for just:
|
|
|
|
|
* IP Header - (sizeof (struct ip))
|
|
|
|
|
* OSPF Header - OSPF_HEADER_SIZE
|
|
|
|
|
* LSA Header - OSPF_LSA_HEADER_SIZE
|
|
|
|
|
* MD5 auth data, if MD5 is configured - OSPF_AUTH_MD5_SIZE.
|
|
|
|
|
*
|
|
|
|
|
* Simpler just to subtract OSPF_MAX_LSA_SIZE though.
|
|
|
|
|
*/
|
|
|
|
|
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 %ld, size %ld",
|
|
|
|
|
__func__, STREAM_REMAIN (s), STREAM_SIZE (s));
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
|
/* 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. */
|
2006-01-18 16:07:38 +01:00
|
|
|
|
|
|
|
|
|
return 1;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
}
|
|
|
|
|
|
[PtP over ethernet] New peer flag allows much more addressing flexibility
2006-12-12 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
* if.h: (struct connected) Add new ZEBRA_IFA_PEER flag indicating
whether a peer address has been configured. Comment now shows
the new interpretation of the destination addr: if ZEBRA_IFA_PEER
is set, then it must contain the destination address, otherwise
it may contain the broadcast address or be NULL.
(CONNECTED_DEST_HOST,CONNECTED_POINTOPOINT_HOST) Remove obsolete
macros that were specific to IPv4 and not fully general.
(CONNECTED_PEER) New macro to check ZEBRA_IFA_PEER flag.
(CONNECTED_PREFIX) New macro giving the prefix to insert into
the RIB: if CONNECTED_PEER, then use the destination (peer) address,
else use the address field.
(CONNECTED_ID) New macro to come up with an identifying address
for the struct connected.
* if.c: (if_lookup_address, connected_lookup_address) Streamline
logic with new CONNECTED_PREFIX macro.
* prefix.h: (PREFIX_COPY_IPV4, PREFIX_COPY_IPV6) New macros
for better performance than the general prefix_copy function.
* zclient.c: (zebra_interface_address_read) For non-null destination
addresses, set prefixlen to equal the address prefixlen. This
is needed to get the new CONNECTED_PREFIX macro to work properly.
* connected.c: (connected_up_ipv4, connected_down_ipv4,
connected_up_ipv6, connected_down_ipv6) Simplify logic using the
new CONNECTED_PREFIX macro.
(connected_add_ipv4) Set prefixlen in destination addresses (required
by the CONNECTED_PREFIX macro). Use CONNECTED_PEER macro instead
of testing for IFF_POINTOPOINT. Delete invalid warning message.
Warn about cases where the ZEBRA_IFA_PEER is set but no
destination address has been supplied (and turn off the flag).
(connected_add_ipv6) Add new flags argument so callers may set
the ZEBRA_IFA_PEER flag. If peer/broadcast address satisfies
IN6_IS_ADDR_UNSPECIFIED, then reject it with a warning.
Set prefixlen in destination address so CONNECTED_PREFIX will work.
* connected.h: (connected_add_ipv6) Add new flags argument so
callers may set the ZEBRA_IFA_PEER flag.
* interface.c: (connected_dump_vty) Use CONNECTED_PEER macro
to decide whether the destination address is a peer or broadcast
address (instead of checking IFF_BROADCAST and IFF_POINTOPOINT).
* if_ioctl.c: (if_getaddrs) Instead of setting a peer address
only when the IFF_POINTOPOINT is set, we now accept a peer
address whenever it is available and not the same as the local
address. Otherwise (no peer address assigned), we check
for a broadcast address (regardless of the IFF_BROADCAST flag).
And must now pass a flags value of ZEBRA_IFA_PEER to
connected_add_ipv4 when a peer address is assigned.
The same new logic is used with the IPv6 code as well (and we
pass the new flags argument to connected_add_ipv6).
(if_get_addr) Do not bother to check IFF_POINTOPOINT: just
issue the SIOCGIFDSTADDR ioctl and see if we get back
a peer address not matching the local address (and set
the ZEBRA_IFA_PEER in that case). If there's no peer address,
try to grab SIOCGIFBRDADDR regardless of whether IFF_BROADCAST is set.
* if_ioctl_solaris.c: (if_get_addr) Just try the SIOCGLIFDSTADDR ioctl
without bothering to check the IFF_POINTOPOINT flag. And if
no peer address was found, just try the SIOCGLIFBRDADDR ioctl
without checking the IFF_BROADCAST flag. Call connected_add_ipv4
and connected_add_ipv6 with appropriate flags.
* if_proc.c: (ifaddr_proc_ipv6) Must pass new flags argument to
connected_add_ipv6.
* kernel_socket.c: (ifam_read) Must pass new flags argument to
connected_add_ipv6.
* rt_netlink.c: (netlink_interface_addr) Copy logic from iproute2
to determine local and possible peer address (so there's no longer
a test for IFF_POINTOPOINT). Set ZEBRA_IFA_PEER flag appropriately.
Pass new flags argument to connected_add_ipv6.
(netlink_address) Test !CONNECTED_PEER instead of if_is_broadcast
to determine whether the connected destination address is a
broadcast address.
* bgp_nexthop.c: (bgp_connected_add, bgp_connected_delete)
Simplify logic by using new CONNECTED_PREFIX macro.
* ospf_interface.c: (ospf_if_is_configured, ospf_if_lookup_by_prefix,
ospf_if_lookup_recv_if) Simplify logic using new CONNECTED_PREFIX
macro.
* ospf_lsa.c: (lsa_link_ptop_set) Using the new CONNECTED_PREFIX
macro, both options collapse into the same code.
* ospf_snmp.c: (ospf_snmp_if_update) Simplify logic using new
CONNECTED_ID macro.
(ospf_snmp_is_if_have_addr) Simplify logic using new CONNECTED_PREFIX
macro.
* ospf_vty.c: (show_ip_ospf_interface_sub) Use new CONNECTED_PEER macro
instead of testing the IFF_POINTOPOINT flag.
* ospfd.c: (ospf_network_match_iface) Use new CONNECTED_PEER macro
instead of testing with if_is_pointopoint. And add commented-out
code to implement alternative (in my opinion) more elegant behavior
that has no special-case treatment for PtP addresses.
(ospf_network_run) Use new CONNECTED_ID macro to simplify logic.
* rip_interface.c: (rip_interface_multicast_set) Use new CONNECTED_ID
macro to simplify logic.
(rip_request_interface_send) Fix minor bug: ipv4_broadcast_addr does
not give a useful result if prefixlen is 32 (we require a peer
address in such cases).
* ripd.c: (rip_update_interface) Fix same bug as above.
2006-12-12 20:18:21 +01:00
|
|
|
|
/* Describe Point-to-Point link (Section 12.4.1.1). */
|
2005-05-06 23:37:42 +02:00
|
|
|
|
static int
|
2002-12-13 21:15:29 +01:00
|
|
|
|
lsa_link_ptop_set (struct stream *s, struct ospf_interface *oi)
|
|
|
|
|
{
|
|
|
|
|
int links = 0;
|
|
|
|
|
struct ospf_neighbor *nbr;
|
|
|
|
|
struct in_addr id, mask;
|
2005-10-29 Paul Jakma <paul.jakma@sun.com>
* (general) RFC3137 stub-router support
* ospfd.h: Add OSPF_OUTPUT_COST_INFINITE define.
(struct ospf_master) Add a OSPF_MASTER_SHUTDOWN flag for
options, to allow shutdown to distinguish between complete
shutdown and shutdown of a subset of ospf instances.
(struct ospf)
Add stub_router_{startup,shutdown_}time, configuration of startup
and shutdown time for stub-router.
Add t_graceful_shutdown struct thread, timer for graceful
shutdown, if needed.
(struct ospf_area) Add stub_router_state - run time state of
stub-router for an area. Add flags for ADMIN, IS and WAS
states.
Add t_stub_router, timer thread to resend router-lsa for an
area.
* ospf_lsa.c: (ospf_link_cost) new simple function to spit out
either the given lnks cost or infinite cost if stub-router is
in effect.
(lsa_link_{ptop,broadcast,virtuallink,ptomp}_set) use
previous function for transit-links.
(ospf_stub_router_timer) timer thread for end of startup stub
router. Change state as required for the area and setup
re-origination of router-lsa.
(ospf_stub_router_check) Check/do whether stub-router should be
enabled, and whether it requires timer to be setup.
(ospf_router_lsa_new) call previous function at top.
(ospf_router_lsa_originate) no external callers, made static.
* ospf_lsa.h: (ospf_router_lsa_originate) removed.
* ospf_main.c: (sigint) make static.
remove call to exit, as ospf_terminate now deals with
exiting.
* ospf_route.c: (ospf_terminate) removed, now in ospfd.c.
* ospf_vty.c: (show_ip_ospf_area) print out state of
stub-router, if active.
(show_ip_ospf) print out configuration of stub-router
support, and details of graceful-shutdown if the timer is
active.
((no)?ospf_max_metric_router_lsa_{admin,startup,shutdown}) new
commands to (de-)?configure stub-router support.
(config_write_stub_router) write out config of stub-router.
(ospf_config_write) call previous.
(ospf_vty_init) install the new stub-router commands.
* ospfd.c: various functions made static.
(ospf_new) Set defaults for stub-router. Graceful shutdown
is made to default on, just to be adventerous.
(ospf_graceful_shutdown_finish) new function, final part of
shutdown.
(ospf_graceful_shutdown_timer) timer thread wrapper for
graceful-shutdown.
(ospf_graceful_shutdown_check) check whether to setup timer
for shutdown or proceed directly to final shutdown.
(ospf_terminate) moved here from ospf_route.c, call
ospf_finish for each instance.
(ospf_finish) renamed to ospf_finish_final and made static.
(ospf_finish) new function, exported wrapper around
ospf_graceful_shutdown_check.
(ospf_finish_final) complete shutdown of an instance.
Add missing TIMER_OFF's of two timer threads.
(ospf_area_free) opaque self lsa timer should be turned off.
2005-10-29 14:50:09 +02:00
|
|
|
|
u_int16_t cost = ospf_link_cost (oi);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
|
|
if (IS_DEBUG_OSPF (lsa, LSA_GENERATE))
|
2004-12-08 19:12:06 +01:00
|
|
|
|
zlog_debug ("LSA[Type1]: Set link Point-to-Point");
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
2003-03-25 06:07:42 +01:00
|
|
|
|
if ((nbr = ospf_nbr_lookup_ptop (oi)))
|
2002-12-13 21:15:29 +01:00
|
|
|
|
if (nbr->state == NSM_Full)
|
|
|
|
|
{
|
|
|
|
|
/* For unnumbered point-to-point networks, the Link Data field
|
|
|
|
|
should specify the interface's MIB-II ifIndex value. */
|
2006-01-18 16:07:38 +01:00
|
|
|
|
links += link_info_set (s, nbr->router_id, oi->address->u.prefix4,
|
|
|
|
|
LSA_LINK_TYPE_POINTOPOINT, 0, cost);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
}
|
|
|
|
|
|
[PtP over ethernet] New peer flag allows much more addressing flexibility
2006-12-12 Andrew J. Schorr <ajschorr@alumni.princeton.edu>
* if.h: (struct connected) Add new ZEBRA_IFA_PEER flag indicating
whether a peer address has been configured. Comment now shows
the new interpretation of the destination addr: if ZEBRA_IFA_PEER
is set, then it must contain the destination address, otherwise
it may contain the broadcast address or be NULL.
(CONNECTED_DEST_HOST,CONNECTED_POINTOPOINT_HOST) Remove obsolete
macros that were specific to IPv4 and not fully general.
(CONNECTED_PEER) New macro to check ZEBRA_IFA_PEER flag.
(CONNECTED_PREFIX) New macro giving the prefix to insert into
the RIB: if CONNECTED_PEER, then use the destination (peer) address,
else use the address field.
(CONNECTED_ID) New macro to come up with an identifying address
for the struct connected.
* if.c: (if_lookup_address, connected_lookup_address) Streamline
logic with new CONNECTED_PREFIX macro.
* prefix.h: (PREFIX_COPY_IPV4, PREFIX_COPY_IPV6) New macros
for better performance than the general prefix_copy function.
* zclient.c: (zebra_interface_address_read) For non-null destination
addresses, set prefixlen to equal the address prefixlen. This
is needed to get the new CONNECTED_PREFIX macro to work properly.
* connected.c: (connected_up_ipv4, connected_down_ipv4,
connected_up_ipv6, connected_down_ipv6) Simplify logic using the
new CONNECTED_PREFIX macro.
(connected_add_ipv4) Set prefixlen in destination addresses (required
by the CONNECTED_PREFIX macro). Use CONNECTED_PEER macro instead
of testing for IFF_POINTOPOINT. Delete invalid warning message.
Warn about cases where the ZEBRA_IFA_PEER is set but no
destination address has been supplied (and turn off the flag).
(connected_add_ipv6) Add new flags argument so callers may set
the ZEBRA_IFA_PEER flag. If peer/broadcast address satisfies
IN6_IS_ADDR_UNSPECIFIED, then reject it with a warning.
Set prefixlen in destination address so CONNECTED_PREFIX will work.
* connected.h: (connected_add_ipv6) Add new flags argument so
callers may set the ZEBRA_IFA_PEER flag.
* interface.c: (connected_dump_vty) Use CONNECTED_PEER macro
to decide whether the destination address is a peer or broadcast
address (instead of checking IFF_BROADCAST and IFF_POINTOPOINT).
* if_ioctl.c: (if_getaddrs) Instead of setting a peer address
only when the IFF_POINTOPOINT is set, we now accept a peer
address whenever it is available and not the same as the local
address. Otherwise (no peer address assigned), we check
for a broadcast address (regardless of the IFF_BROADCAST flag).
And must now pass a flags value of ZEBRA_IFA_PEER to
connected_add_ipv4 when a peer address is assigned.
The same new logic is used with the IPv6 code as well (and we
pass the new flags argument to connected_add_ipv6).
(if_get_addr) Do not bother to check IFF_POINTOPOINT: just
issue the SIOCGIFDSTADDR ioctl and see if we get back
a peer address not matching the local address (and set
the ZEBRA_IFA_PEER in that case). If there's no peer address,
try to grab SIOCGIFBRDADDR regardless of whether IFF_BROADCAST is set.
* if_ioctl_solaris.c: (if_get_addr) Just try the SIOCGLIFDSTADDR ioctl
without bothering to check the IFF_POINTOPOINT flag. And if
no peer address was found, just try the SIOCGLIFBRDADDR ioctl
without checking the IFF_BROADCAST flag. Call connected_add_ipv4
and connected_add_ipv6 with appropriate flags.
* if_proc.c: (ifaddr_proc_ipv6) Must pass new flags argument to
connected_add_ipv6.
* kernel_socket.c: (ifam_read) Must pass new flags argument to
connected_add_ipv6.
* rt_netlink.c: (netlink_interface_addr) Copy logic from iproute2
to determine local and possible peer address (so there's no longer
a test for IFF_POINTOPOINT). Set ZEBRA_IFA_PEER flag appropriately.
Pass new flags argument to connected_add_ipv6.
(netlink_address) Test !CONNECTED_PEER instead of if_is_broadcast
to determine whether the connected destination address is a
broadcast address.
* bgp_nexthop.c: (bgp_connected_add, bgp_connected_delete)
Simplify logic by using new CONNECTED_PREFIX macro.
* ospf_interface.c: (ospf_if_is_configured, ospf_if_lookup_by_prefix,
ospf_if_lookup_recv_if) Simplify logic using new CONNECTED_PREFIX
macro.
* ospf_lsa.c: (lsa_link_ptop_set) Using the new CONNECTED_PREFIX
macro, both options collapse into the same code.
* ospf_snmp.c: (ospf_snmp_if_update) Simplify logic using new
CONNECTED_ID macro.
(ospf_snmp_is_if_have_addr) Simplify logic using new CONNECTED_PREFIX
macro.
* ospf_vty.c: (show_ip_ospf_interface_sub) Use new CONNECTED_PEER macro
instead of testing the IFF_POINTOPOINT flag.
* ospfd.c: (ospf_network_match_iface) Use new CONNECTED_PEER macro
instead of testing with if_is_pointopoint. And add commented-out
code to implement alternative (in my opinion) more elegant behavior
that has no special-case treatment for PtP addresses.
(ospf_network_run) Use new CONNECTED_ID macro to simplify logic.
* rip_interface.c: (rip_interface_multicast_set) Use new CONNECTED_ID
macro to simplify logic.
(rip_request_interface_send) Fix minor bug: ipv4_broadcast_addr does
not give a useful result if prefixlen is 32 (we require a peer
address in such cases).
* ripd.c: (rip_update_interface) Fix same bug as above.
2006-12-12 20:18:21 +01:00
|
|
|
|
/* Regardless of the state of the neighboring router, we must
|
|
|
|
|
add a Type 3 link (stub network).
|
|
|
|
|
N.B. Options 1 & 2 share basically the same logic. */
|
|
|
|
|
masklen2ip (oi->address->prefixlen, &mask);
|
|
|
|
|
id.s_addr = CONNECTED_PREFIX(oi->connected)->u.prefix4.s_addr & mask.s_addr;
|
|
|
|
|
links += link_info_set (s, id, mask, LSA_LINK_TYPE_STUB, 0,
|
|
|
|
|
oi->output_cost);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
return links;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Describe Broadcast Link. */
|
2005-05-06 23:37:42 +02:00
|
|
|
|
static int
|
2002-12-13 21:15:29 +01:00
|
|
|
|
lsa_link_broadcast_set (struct stream *s, struct ospf_interface *oi)
|
|
|
|
|
{
|
|
|
|
|
struct ospf_neighbor *dr;
|
|
|
|
|
struct in_addr id, mask;
|
2005-10-29 Paul Jakma <paul.jakma@sun.com>
* (general) RFC3137 stub-router support
* ospfd.h: Add OSPF_OUTPUT_COST_INFINITE define.
(struct ospf_master) Add a OSPF_MASTER_SHUTDOWN flag for
options, to allow shutdown to distinguish between complete
shutdown and shutdown of a subset of ospf instances.
(struct ospf)
Add stub_router_{startup,shutdown_}time, configuration of startup
and shutdown time for stub-router.
Add t_graceful_shutdown struct thread, timer for graceful
shutdown, if needed.
(struct ospf_area) Add stub_router_state - run time state of
stub-router for an area. Add flags for ADMIN, IS and WAS
states.
Add t_stub_router, timer thread to resend router-lsa for an
area.
* ospf_lsa.c: (ospf_link_cost) new simple function to spit out
either the given lnks cost or infinite cost if stub-router is
in effect.
(lsa_link_{ptop,broadcast,virtuallink,ptomp}_set) use
previous function for transit-links.
(ospf_stub_router_timer) timer thread for end of startup stub
router. Change state as required for the area and setup
re-origination of router-lsa.
(ospf_stub_router_check) Check/do whether stub-router should be
enabled, and whether it requires timer to be setup.
(ospf_router_lsa_new) call previous function at top.
(ospf_router_lsa_originate) no external callers, made static.
* ospf_lsa.h: (ospf_router_lsa_originate) removed.
* ospf_main.c: (sigint) make static.
remove call to exit, as ospf_terminate now deals with
exiting.
* ospf_route.c: (ospf_terminate) removed, now in ospfd.c.
* ospf_vty.c: (show_ip_ospf_area) print out state of
stub-router, if active.
(show_ip_ospf) print out configuration of stub-router
support, and details of graceful-shutdown if the timer is
active.
((no)?ospf_max_metric_router_lsa_{admin,startup,shutdown}) new
commands to (de-)?configure stub-router support.
(config_write_stub_router) write out config of stub-router.
(ospf_config_write) call previous.
(ospf_vty_init) install the new stub-router commands.
* ospfd.c: various functions made static.
(ospf_new) Set defaults for stub-router. Graceful shutdown
is made to default on, just to be adventerous.
(ospf_graceful_shutdown_finish) new function, final part of
shutdown.
(ospf_graceful_shutdown_timer) timer thread wrapper for
graceful-shutdown.
(ospf_graceful_shutdown_check) check whether to setup timer
for shutdown or proceed directly to final shutdown.
(ospf_terminate) moved here from ospf_route.c, call
ospf_finish for each instance.
(ospf_finish) renamed to ospf_finish_final and made static.
(ospf_finish) new function, exported wrapper around
ospf_graceful_shutdown_check.
(ospf_finish_final) complete shutdown of an instance.
Add missing TIMER_OFF's of two timer threads.
(ospf_area_free) opaque self lsa timer should be turned off.
2005-10-29 14:50:09 +02:00
|
|
|
|
u_int16_t cost = ospf_link_cost (oi);
|
|
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
|
/* Describe Type 3 Link. */
|
|
|
|
|
if (oi->state == ISM_Waiting)
|
|
|
|
|
{
|
|
|
|
|
masklen2ip (oi->address->prefixlen, &mask);
|
|
|
|
|
id.s_addr = oi->address->u.prefix4.s_addr & mask.s_addr;
|
2006-01-18 16:07:38 +01:00
|
|
|
|
return link_info_set (s, id, mask, LSA_LINK_TYPE_STUB, 0,
|
|
|
|
|
oi->output_cost);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dr = ospf_nbr_lookup_by_addr (oi->nbrs, &DR (oi));
|
|
|
|
|
/* Describe Type 2 link. */
|
|
|
|
|
if (dr && (dr->state == NSM_Full ||
|
|
|
|
|
IPV4_ADDR_SAME (&oi->address->u.prefix4, &DR (oi))) &&
|
2003-03-25 06:07:42 +01:00
|
|
|
|
ospf_nbr_count (oi, NSM_Full) > 0)
|
2002-12-13 21:15:29 +01:00
|
|
|
|
{
|
2006-01-18 16:07:38 +01:00
|
|
|
|
return link_info_set (s, DR (oi), oi->address->u.prefix4,
|
|
|
|
|
LSA_LINK_TYPE_TRANSIT, 0, cost);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
}
|
|
|
|
|
/* Describe type 3 link. */
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
masklen2ip (oi->address->prefixlen, &mask);
|
|
|
|
|
id.s_addr = oi->address->u.prefix4.s_addr & mask.s_addr;
|
2006-01-18 16:07:38 +01:00
|
|
|
|
return link_info_set (s, id, mask, LSA_LINK_TYPE_STUB, 0,
|
|
|
|
|
oi->output_cost);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2005-05-06 23:37:42 +02:00
|
|
|
|
static int
|
2002-12-13 21:15:29 +01:00
|
|
|
|
lsa_link_loopback_set (struct stream *s, struct ospf_interface *oi)
|
|
|
|
|
{
|
|
|
|
|
struct in_addr id, mask;
|
2005-10-29 Paul Jakma <paul.jakma@sun.com>
* (general) RFC3137 stub-router support
* ospfd.h: Add OSPF_OUTPUT_COST_INFINITE define.
(struct ospf_master) Add a OSPF_MASTER_SHUTDOWN flag for
options, to allow shutdown to distinguish between complete
shutdown and shutdown of a subset of ospf instances.
(struct ospf)
Add stub_router_{startup,shutdown_}time, configuration of startup
and shutdown time for stub-router.
Add t_graceful_shutdown struct thread, timer for graceful
shutdown, if needed.
(struct ospf_area) Add stub_router_state - run time state of
stub-router for an area. Add flags for ADMIN, IS and WAS
states.
Add t_stub_router, timer thread to resend router-lsa for an
area.
* ospf_lsa.c: (ospf_link_cost) new simple function to spit out
either the given lnks cost or infinite cost if stub-router is
in effect.
(lsa_link_{ptop,broadcast,virtuallink,ptomp}_set) use
previous function for transit-links.
(ospf_stub_router_timer) timer thread for end of startup stub
router. Change state as required for the area and setup
re-origination of router-lsa.
(ospf_stub_router_check) Check/do whether stub-router should be
enabled, and whether it requires timer to be setup.
(ospf_router_lsa_new) call previous function at top.
(ospf_router_lsa_originate) no external callers, made static.
* ospf_lsa.h: (ospf_router_lsa_originate) removed.
* ospf_main.c: (sigint) make static.
remove call to exit, as ospf_terminate now deals with
exiting.
* ospf_route.c: (ospf_terminate) removed, now in ospfd.c.
* ospf_vty.c: (show_ip_ospf_area) print out state of
stub-router, if active.
(show_ip_ospf) print out configuration of stub-router
support, and details of graceful-shutdown if the timer is
active.
((no)?ospf_max_metric_router_lsa_{admin,startup,shutdown}) new
commands to (de-)?configure stub-router support.
(config_write_stub_router) write out config of stub-router.
(ospf_config_write) call previous.
(ospf_vty_init) install the new stub-router commands.
* ospfd.c: various functions made static.
(ospf_new) Set defaults for stub-router. Graceful shutdown
is made to default on, just to be adventerous.
(ospf_graceful_shutdown_finish) new function, final part of
shutdown.
(ospf_graceful_shutdown_timer) timer thread wrapper for
graceful-shutdown.
(ospf_graceful_shutdown_check) check whether to setup timer
for shutdown or proceed directly to final shutdown.
(ospf_terminate) moved here from ospf_route.c, call
ospf_finish for each instance.
(ospf_finish) renamed to ospf_finish_final and made static.
(ospf_finish) new function, exported wrapper around
ospf_graceful_shutdown_check.
(ospf_finish_final) complete shutdown of an instance.
Add missing TIMER_OFF's of two timer threads.
(ospf_area_free) opaque self lsa timer should be turned off.
2005-10-29 14:50:09 +02:00
|
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
|
/* Describe Type 3 Link. */
|
|
|
|
|
if (oi->state != ISM_Loopback)
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
mask.s_addr = 0xffffffff;
|
|
|
|
|
id.s_addr = oi->address->u.prefix4.s_addr;
|
2006-01-18 16:07:38 +01:00
|
|
|
|
return link_info_set (s, id, mask, LSA_LINK_TYPE_STUB, 0, oi->output_cost);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Describe Virtual Link. */
|
2005-05-06 23:37:42 +02:00
|
|
|
|
static int
|
2002-12-13 21:15:29 +01:00
|
|
|
|
lsa_link_virtuallink_set (struct stream *s, struct ospf_interface *oi)
|
|
|
|
|
{
|
|
|
|
|
struct ospf_neighbor *nbr;
|
2005-10-29 Paul Jakma <paul.jakma@sun.com>
* (general) RFC3137 stub-router support
* ospfd.h: Add OSPF_OUTPUT_COST_INFINITE define.
(struct ospf_master) Add a OSPF_MASTER_SHUTDOWN flag for
options, to allow shutdown to distinguish between complete
shutdown and shutdown of a subset of ospf instances.
(struct ospf)
Add stub_router_{startup,shutdown_}time, configuration of startup
and shutdown time for stub-router.
Add t_graceful_shutdown struct thread, timer for graceful
shutdown, if needed.
(struct ospf_area) Add stub_router_state - run time state of
stub-router for an area. Add flags for ADMIN, IS and WAS
states.
Add t_stub_router, timer thread to resend router-lsa for an
area.
* ospf_lsa.c: (ospf_link_cost) new simple function to spit out
either the given lnks cost or infinite cost if stub-router is
in effect.
(lsa_link_{ptop,broadcast,virtuallink,ptomp}_set) use
previous function for transit-links.
(ospf_stub_router_timer) timer thread for end of startup stub
router. Change state as required for the area and setup
re-origination of router-lsa.
(ospf_stub_router_check) Check/do whether stub-router should be
enabled, and whether it requires timer to be setup.
(ospf_router_lsa_new) call previous function at top.
(ospf_router_lsa_originate) no external callers, made static.
* ospf_lsa.h: (ospf_router_lsa_originate) removed.
* ospf_main.c: (sigint) make static.
remove call to exit, as ospf_terminate now deals with
exiting.
* ospf_route.c: (ospf_terminate) removed, now in ospfd.c.
* ospf_vty.c: (show_ip_ospf_area) print out state of
stub-router, if active.
(show_ip_ospf) print out configuration of stub-router
support, and details of graceful-shutdown if the timer is
active.
((no)?ospf_max_metric_router_lsa_{admin,startup,shutdown}) new
commands to (de-)?configure stub-router support.
(config_write_stub_router) write out config of stub-router.
(ospf_config_write) call previous.
(ospf_vty_init) install the new stub-router commands.
* ospfd.c: various functions made static.
(ospf_new) Set defaults for stub-router. Graceful shutdown
is made to default on, just to be adventerous.
(ospf_graceful_shutdown_finish) new function, final part of
shutdown.
(ospf_graceful_shutdown_timer) timer thread wrapper for
graceful-shutdown.
(ospf_graceful_shutdown_check) check whether to setup timer
for shutdown or proceed directly to final shutdown.
(ospf_terminate) moved here from ospf_route.c, call
ospf_finish for each instance.
(ospf_finish) renamed to ospf_finish_final and made static.
(ospf_finish) new function, exported wrapper around
ospf_graceful_shutdown_check.
(ospf_finish_final) complete shutdown of an instance.
Add missing TIMER_OFF's of two timer threads.
(ospf_area_free) opaque self lsa timer should be turned off.
2005-10-29 14:50:09 +02:00
|
|
|
|
u_int16_t cost = ospf_link_cost (oi);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
|
|
if (oi->state == ISM_PointToPoint)
|
2003-03-25 06:07:42 +01:00
|
|
|
|
if ((nbr = ospf_nbr_lookup_ptop (oi)))
|
2002-12-13 21:15:29 +01:00
|
|
|
|
if (nbr->state == NSM_Full)
|
|
|
|
|
{
|
2006-01-18 16:07:38 +01:00
|
|
|
|
return link_info_set (s, nbr->router_id, oi->address->u.prefix4,
|
|
|
|
|
LSA_LINK_TYPE_VIRTUALLINK, 0, cost);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#define lsa_link_nbma_set(S,O) lsa_link_broadcast_set (S, O)
|
|
|
|
|
|
2002-12-13 21:59:45 +01:00
|
|
|
|
/* 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 */
|
2005-05-06 23:37:42 +02:00
|
|
|
|
static int
|
2003-03-25 06:07:42 +01:00
|
|
|
|
lsa_link_ptomp_set (struct stream *s, struct ospf_interface *oi)
|
2002-12-13 21:59:45 +01:00
|
|
|
|
{
|
|
|
|
|
int links = 0;
|
|
|
|
|
struct route_node *rn;
|
|
|
|
|
struct ospf_neighbor *nbr = NULL;
|
|
|
|
|
struct in_addr id, mask;
|
2005-10-29 Paul Jakma <paul.jakma@sun.com>
* (general) RFC3137 stub-router support
* ospfd.h: Add OSPF_OUTPUT_COST_INFINITE define.
(struct ospf_master) Add a OSPF_MASTER_SHUTDOWN flag for
options, to allow shutdown to distinguish between complete
shutdown and shutdown of a subset of ospf instances.
(struct ospf)
Add stub_router_{startup,shutdown_}time, configuration of startup
and shutdown time for stub-router.
Add t_graceful_shutdown struct thread, timer for graceful
shutdown, if needed.
(struct ospf_area) Add stub_router_state - run time state of
stub-router for an area. Add flags for ADMIN, IS and WAS
states.
Add t_stub_router, timer thread to resend router-lsa for an
area.
* ospf_lsa.c: (ospf_link_cost) new simple function to spit out
either the given lnks cost or infinite cost if stub-router is
in effect.
(lsa_link_{ptop,broadcast,virtuallink,ptomp}_set) use
previous function for transit-links.
(ospf_stub_router_timer) timer thread for end of startup stub
router. Change state as required for the area and setup
re-origination of router-lsa.
(ospf_stub_router_check) Check/do whether stub-router should be
enabled, and whether it requires timer to be setup.
(ospf_router_lsa_new) call previous function at top.
(ospf_router_lsa_originate) no external callers, made static.
* ospf_lsa.h: (ospf_router_lsa_originate) removed.
* ospf_main.c: (sigint) make static.
remove call to exit, as ospf_terminate now deals with
exiting.
* ospf_route.c: (ospf_terminate) removed, now in ospfd.c.
* ospf_vty.c: (show_ip_ospf_area) print out state of
stub-router, if active.
(show_ip_ospf) print out configuration of stub-router
support, and details of graceful-shutdown if the timer is
active.
((no)?ospf_max_metric_router_lsa_{admin,startup,shutdown}) new
commands to (de-)?configure stub-router support.
(config_write_stub_router) write out config of stub-router.
(ospf_config_write) call previous.
(ospf_vty_init) install the new stub-router commands.
* ospfd.c: various functions made static.
(ospf_new) Set defaults for stub-router. Graceful shutdown
is made to default on, just to be adventerous.
(ospf_graceful_shutdown_finish) new function, final part of
shutdown.
(ospf_graceful_shutdown_timer) timer thread wrapper for
graceful-shutdown.
(ospf_graceful_shutdown_check) check whether to setup timer
for shutdown or proceed directly to final shutdown.
(ospf_terminate) moved here from ospf_route.c, call
ospf_finish for each instance.
(ospf_finish) renamed to ospf_finish_final and made static.
(ospf_finish) new function, exported wrapper around
ospf_graceful_shutdown_check.
(ospf_finish_final) complete shutdown of an instance.
Add missing TIMER_OFF's of two timer threads.
(ospf_area_free) opaque self lsa timer should be turned off.
2005-10-29 14:50:09 +02:00
|
|
|
|
u_int16_t cost = ospf_link_cost (oi);
|
2002-12-13 21:59:45 +01:00
|
|
|
|
|
|
|
|
|
mask.s_addr = 0xffffffff;
|
|
|
|
|
id.s_addr = oi->address->u.prefix4.s_addr;
|
2006-01-18 16:07:38 +01:00
|
|
|
|
links += link_info_set (s, id, mask, LSA_LINK_TYPE_STUB, 0, 0);
|
2002-12-13 21:59:45 +01:00
|
|
|
|
|
2003-04-05 21:34:32 +02:00
|
|
|
|
if (IS_DEBUG_OSPF (lsa, LSA_GENERATE))
|
2004-12-08 19:12:06 +01:00
|
|
|
|
zlog_debug ("PointToMultipoint: running ptomultip_set");
|
2002-12-13 21:59:45 +01:00
|
|
|
|
|
|
|
|
|
/* Search neighbor, */
|
|
|
|
|
for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
|
|
|
|
|
if ((nbr = rn->info) != NULL)
|
|
|
|
|
/* Ignore myself. */
|
2003-03-25 06:07:42 +01:00
|
|
|
|
if (!IPV4_ADDR_SAME (&nbr->router_id, &oi->ospf->router_id))
|
2002-12-13 21:59:45 +01:00
|
|
|
|
if (nbr->state == NSM_Full)
|
|
|
|
|
|
|
|
|
|
{
|
2006-01-18 16:07:38 +01:00
|
|
|
|
links += link_info_set (s, nbr->router_id, oi->address->u.prefix4,
|
|
|
|
|
LSA_LINK_TYPE_POINTOPOINT, 0, cost);
|
2003-04-05 21:34:32 +02:00
|
|
|
|
if (IS_DEBUG_OSPF (lsa, LSA_GENERATE))
|
2004-12-08 19:12:06 +01:00
|
|
|
|
zlog_debug ("PointToMultipoint: set link to %s",
|
2003-04-05 21:34:32 +02:00
|
|
|
|
inet_ntoa(oi->address->u.prefix4));
|
2002-12-13 21:59:45 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return links;
|
|
|
|
|
}
|
|
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
|
/* Set router-LSA link information. */
|
2005-05-06 23:37:42 +02:00
|
|
|
|
static int
|
2002-12-13 21:15:29 +01:00
|
|
|
|
router_lsa_link_set (struct stream *s, struct ospf_area *area)
|
|
|
|
|
{
|
2004-09-23 21:18:23 +02:00
|
|
|
|
struct listnode *node;
|
2005-04-07 Paul Jakma <paul.jakma@sun.com>
* (global): Fix up list loops to match changes in lib/linklist,
and some basic auditing of usage.
* configure.ac: define QUAGGA_NO_DEPRECATED_INTERFACES
* HACKING: Add notes about deprecating interfaces and commands.
* lib/linklist.h: Add usage comments.
Rename getdata macro to listgetdata.
Rename nextnode to listnextnode and fix its odd behaviour to be
less dangerous.
Make listgetdata macro assert node is not null, NULL list entries
should be bug condition.
ALL_LIST_ELEMENTS, new macro, forward-referencing macro for use
with for loop, Suggested by Jim Carlson of Sun.
Add ALL_LIST_ELEMENTS_RO for cases which obviously do not need the
"safety" of previous macro.
LISTNODE_ADD and DELETE macros renamed to ATTACH, DETACH, to
distinguish from the similarly named functions, and reflect their
effect better.
Add a QUAGGA_NO_DEPRECATED_INTERFACES define guarded section
with the old defines which were modified above,
for backwards compatibility - guarded to prevent Quagga using it..
* lib/linklist.c: fix up for linklist.h changes.
* ospf6d/ospf6_abr.c: (ospf6_abr_examin_brouter) change to a single
scan of the area list, rather than scanning all areas first for
INTER_ROUTER and then again for INTER_NETWORK. According to
16.2, the scan should be area specific anyway, and further
ospf6d does not seem to implement 16.3 anyway.
2005-04-07 09:30:20 +02:00
|
|
|
|
struct ospf_interface *oi;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
int links = 0;
|
|
|
|
|
|
2005-04-07 Paul Jakma <paul.jakma@sun.com>
* (global): Fix up list loops to match changes in lib/linklist,
and some basic auditing of usage.
* configure.ac: define QUAGGA_NO_DEPRECATED_INTERFACES
* HACKING: Add notes about deprecating interfaces and commands.
* lib/linklist.h: Add usage comments.
Rename getdata macro to listgetdata.
Rename nextnode to listnextnode and fix its odd behaviour to be
less dangerous.
Make listgetdata macro assert node is not null, NULL list entries
should be bug condition.
ALL_LIST_ELEMENTS, new macro, forward-referencing macro for use
with for loop, Suggested by Jim Carlson of Sun.
Add ALL_LIST_ELEMENTS_RO for cases which obviously do not need the
"safety" of previous macro.
LISTNODE_ADD and DELETE macros renamed to ATTACH, DETACH, to
distinguish from the similarly named functions, and reflect their
effect better.
Add a QUAGGA_NO_DEPRECATED_INTERFACES define guarded section
with the old defines which were modified above,
for backwards compatibility - guarded to prevent Quagga using it..
* lib/linklist.c: fix up for linklist.h changes.
* ospf6d/ospf6_abr.c: (ospf6_abr_examin_brouter) change to a single
scan of the area list, rather than scanning all areas first for
INTER_ROUTER and then again for INTER_NETWORK. According to
16.2, the scan should be area specific anyway, and further
ospf6d does not seem to implement 16.3 anyway.
2005-04-07 09:30:20 +02:00
|
|
|
|
for (ALL_LIST_ELEMENTS_RO (area->oiflist, node, oi))
|
2002-12-13 21:15:29 +01:00
|
|
|
|
{
|
|
|
|
|
struct interface *ifp = oi->ifp;
|
|
|
|
|
|
|
|
|
|
/* Check interface is up, OSPF is enable. */
|
2002-12-13 22:03:13 +01:00
|
|
|
|
if (if_is_operative (ifp))
|
2002-12-13 21:15:29 +01:00
|
|
|
|
{
|
|
|
|
|
if (oi->state != ISM_Down)
|
|
|
|
|
{
|
|
|
|
|
/* Describe each link. */
|
|
|
|
|
switch (oi->type)
|
|
|
|
|
{
|
|
|
|
|
case OSPF_IFTYPE_POINTOPOINT:
|
|
|
|
|
links += lsa_link_ptop_set (s, oi);
|
|
|
|
|
break;
|
|
|
|
|
case OSPF_IFTYPE_BROADCAST:
|
|
|
|
|
links += lsa_link_broadcast_set (s, oi);
|
|
|
|
|
break;
|
|
|
|
|
case OSPF_IFTYPE_NBMA:
|
|
|
|
|
links += lsa_link_nbma_set (s, oi);
|
|
|
|
|
break;
|
|
|
|
|
case OSPF_IFTYPE_POINTOMULTIPOINT:
|
2003-03-25 06:07:42 +01:00
|
|
|
|
links += lsa_link_ptomp_set (s, oi);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
break;
|
|
|
|
|
case OSPF_IFTYPE_VIRTUALLINK:
|
|
|
|
|
links += lsa_link_virtuallink_set (s, oi);
|
|
|
|
|
break;
|
|
|
|
|
case OSPF_IFTYPE_LOOPBACK:
|
|
|
|
|
links += lsa_link_loopback_set (s, oi);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return links;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Set router-LSA body. */
|
2005-05-06 23:37:42 +02:00
|
|
|
|
static void
|
2002-12-13 21:15:29 +01:00
|
|
|
|
ospf_router_lsa_body_set (struct stream *s, struct ospf_area *area)
|
|
|
|
|
{
|
|
|
|
|
unsigned long putp;
|
|
|
|
|
u_int16_t cnt;
|
|
|
|
|
|
|
|
|
|
/* Set flags. */
|
|
|
|
|
stream_putc (s, router_lsa_flags (area));
|
|
|
|
|
|
|
|
|
|
/* Set Zero fields. */
|
|
|
|
|
stream_putc (s, 0);
|
|
|
|
|
|
|
|
|
|
/* Keep pointer to # links. */
|
2005-02-09 16:51:56 +01:00
|
|
|
|
putp = stream_get_endp(s);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
|
|
/* Forward word */
|
|
|
|
|
stream_putw(s, 0);
|
|
|
|
|
|
|
|
|
|
/* Set all link information. */
|
|
|
|
|
cnt = router_lsa_link_set (s, area);
|
|
|
|
|
|
|
|
|
|
/* Set # of links here. */
|
|
|
|
|
stream_putw_at (s, putp, cnt);
|
|
|
|
|
}
|
2005-10-29 Paul Jakma <paul.jakma@sun.com>
* (general) RFC3137 stub-router support
* ospfd.h: Add OSPF_OUTPUT_COST_INFINITE define.
(struct ospf_master) Add a OSPF_MASTER_SHUTDOWN flag for
options, to allow shutdown to distinguish between complete
shutdown and shutdown of a subset of ospf instances.
(struct ospf)
Add stub_router_{startup,shutdown_}time, configuration of startup
and shutdown time for stub-router.
Add t_graceful_shutdown struct thread, timer for graceful
shutdown, if needed.
(struct ospf_area) Add stub_router_state - run time state of
stub-router for an area. Add flags for ADMIN, IS and WAS
states.
Add t_stub_router, timer thread to resend router-lsa for an
area.
* ospf_lsa.c: (ospf_link_cost) new simple function to spit out
either the given lnks cost or infinite cost if stub-router is
in effect.
(lsa_link_{ptop,broadcast,virtuallink,ptomp}_set) use
previous function for transit-links.
(ospf_stub_router_timer) timer thread for end of startup stub
router. Change state as required for the area and setup
re-origination of router-lsa.
(ospf_stub_router_check) Check/do whether stub-router should be
enabled, and whether it requires timer to be setup.
(ospf_router_lsa_new) call previous function at top.
(ospf_router_lsa_originate) no external callers, made static.
* ospf_lsa.h: (ospf_router_lsa_originate) removed.
* ospf_main.c: (sigint) make static.
remove call to exit, as ospf_terminate now deals with
exiting.
* ospf_route.c: (ospf_terminate) removed, now in ospfd.c.
* ospf_vty.c: (show_ip_ospf_area) print out state of
stub-router, if active.
(show_ip_ospf) print out configuration of stub-router
support, and details of graceful-shutdown if the timer is
active.
((no)?ospf_max_metric_router_lsa_{admin,startup,shutdown}) new
commands to (de-)?configure stub-router support.
(config_write_stub_router) write out config of stub-router.
(ospf_config_write) call previous.
(ospf_vty_init) install the new stub-router commands.
* ospfd.c: various functions made static.
(ospf_new) Set defaults for stub-router. Graceful shutdown
is made to default on, just to be adventerous.
(ospf_graceful_shutdown_finish) new function, final part of
shutdown.
(ospf_graceful_shutdown_timer) timer thread wrapper for
graceful-shutdown.
(ospf_graceful_shutdown_check) check whether to setup timer
for shutdown or proceed directly to final shutdown.
(ospf_terminate) moved here from ospf_route.c, call
ospf_finish for each instance.
(ospf_finish) renamed to ospf_finish_final and made static.
(ospf_finish) new function, exported wrapper around
ospf_graceful_shutdown_check.
(ospf_finish_final) complete shutdown of an instance.
Add missing TIMER_OFF's of two timer threads.
(ospf_area_free) opaque self lsa timer should be turned off.
2005-10-29 14:50:09 +02:00
|
|
|
|
|
|
|
|
|
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_timer_add (area);
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
2005-10-29 Paul Jakma <paul.jakma@sun.com>
* (general) RFC3137 stub-router support
* ospfd.h: Add OSPF_OUTPUT_COST_INFINITE define.
(struct ospf_master) Add a OSPF_MASTER_SHUTDOWN flag for
options, to allow shutdown to distinguish between complete
shutdown and shutdown of a subset of ospf instances.
(struct ospf)
Add stub_router_{startup,shutdown_}time, configuration of startup
and shutdown time for stub-router.
Add t_graceful_shutdown struct thread, timer for graceful
shutdown, if needed.
(struct ospf_area) Add stub_router_state - run time state of
stub-router for an area. Add flags for ADMIN, IS and WAS
states.
Add t_stub_router, timer thread to resend router-lsa for an
area.
* ospf_lsa.c: (ospf_link_cost) new simple function to spit out
either the given lnks cost or infinite cost if stub-router is
in effect.
(lsa_link_{ptop,broadcast,virtuallink,ptomp}_set) use
previous function for transit-links.
(ospf_stub_router_timer) timer thread for end of startup stub
router. Change state as required for the area and setup
re-origination of router-lsa.
(ospf_stub_router_check) Check/do whether stub-router should be
enabled, and whether it requires timer to be setup.
(ospf_router_lsa_new) call previous function at top.
(ospf_router_lsa_originate) no external callers, made static.
* ospf_lsa.h: (ospf_router_lsa_originate) removed.
* ospf_main.c: (sigint) make static.
remove call to exit, as ospf_terminate now deals with
exiting.
* ospf_route.c: (ospf_terminate) removed, now in ospfd.c.
* ospf_vty.c: (show_ip_ospf_area) print out state of
stub-router, if active.
(show_ip_ospf) print out configuration of stub-router
support, and details of graceful-shutdown if the timer is
active.
((no)?ospf_max_metric_router_lsa_{admin,startup,shutdown}) new
commands to (de-)?configure stub-router support.
(config_write_stub_router) write out config of stub-router.
(ospf_config_write) call previous.
(ospf_vty_init) install the new stub-router commands.
* ospfd.c: various functions made static.
(ospf_new) Set defaults for stub-router. Graceful shutdown
is made to default on, just to be adventerous.
(ospf_graceful_shutdown_finish) new function, final part of
shutdown.
(ospf_graceful_shutdown_timer) timer thread wrapper for
graceful-shutdown.
(ospf_graceful_shutdown_check) check whether to setup timer
for shutdown or proceed directly to final shutdown.
(ospf_terminate) moved here from ospf_route.c, call
ospf_finish for each instance.
(ospf_finish) renamed to ospf_finish_final and made static.
(ospf_finish) new function, exported wrapper around
ospf_graceful_shutdown_check.
(ospf_finish_final) complete shutdown of an instance.
Add missing TIMER_OFF's of two timer threads.
(ospf_area_free) opaque self lsa timer should be turned off.
2005-10-29 14:50:09 +02:00
|
|
|
|
inline static void
|
|
|
|
|
ospf_stub_router_check (struct ospf_area *area)
|
|
|
|
|
{
|
|
|
|
|
/* area must either be administratively configured to be stub
|
|
|
|
|
* or startup-time stub-router must be configured and we must in a pre-stub
|
|
|
|
|
* state.
|
|
|
|
|
*/
|
|
|
|
|
if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED))
|
|
|
|
|
{
|
|
|
|
|
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
|
|
|
|
|
* tries configure it (take effect next restart).
|
|
|
|
|
*/
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
|
/* Create new router-LSA. */
|
2005-05-06 23:37:42 +02:00
|
|
|
|
static struct ospf_lsa *
|
2002-12-13 21:15:29 +01:00
|
|
|
|
ospf_router_lsa_new (struct ospf_area *area)
|
|
|
|
|
{
|
2003-03-25 06:07:42 +01:00
|
|
|
|
struct ospf *ospf = area->ospf;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
struct stream *s;
|
|
|
|
|
struct lsa_header *lsah;
|
|
|
|
|
struct ospf_lsa *new;
|
|
|
|
|
int length;
|
|
|
|
|
|
|
|
|
|
if (IS_DEBUG_OSPF (lsa, LSA_GENERATE))
|
2004-12-08 19:12:06 +01:00
|
|
|
|
zlog_debug ("LSA[Type1]: Create router-LSA instance");
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
2005-10-29 Paul Jakma <paul.jakma@sun.com>
* (general) RFC3137 stub-router support
* ospfd.h: Add OSPF_OUTPUT_COST_INFINITE define.
(struct ospf_master) Add a OSPF_MASTER_SHUTDOWN flag for
options, to allow shutdown to distinguish between complete
shutdown and shutdown of a subset of ospf instances.
(struct ospf)
Add stub_router_{startup,shutdown_}time, configuration of startup
and shutdown time for stub-router.
Add t_graceful_shutdown struct thread, timer for graceful
shutdown, if needed.
(struct ospf_area) Add stub_router_state - run time state of
stub-router for an area. Add flags for ADMIN, IS and WAS
states.
Add t_stub_router, timer thread to resend router-lsa for an
area.
* ospf_lsa.c: (ospf_link_cost) new simple function to spit out
either the given lnks cost or infinite cost if stub-router is
in effect.
(lsa_link_{ptop,broadcast,virtuallink,ptomp}_set) use
previous function for transit-links.
(ospf_stub_router_timer) timer thread for end of startup stub
router. Change state as required for the area and setup
re-origination of router-lsa.
(ospf_stub_router_check) Check/do whether stub-router should be
enabled, and whether it requires timer to be setup.
(ospf_router_lsa_new) call previous function at top.
(ospf_router_lsa_originate) no external callers, made static.
* ospf_lsa.h: (ospf_router_lsa_originate) removed.
* ospf_main.c: (sigint) make static.
remove call to exit, as ospf_terminate now deals with
exiting.
* ospf_route.c: (ospf_terminate) removed, now in ospfd.c.
* ospf_vty.c: (show_ip_ospf_area) print out state of
stub-router, if active.
(show_ip_ospf) print out configuration of stub-router
support, and details of graceful-shutdown if the timer is
active.
((no)?ospf_max_metric_router_lsa_{admin,startup,shutdown}) new
commands to (de-)?configure stub-router support.
(config_write_stub_router) write out config of stub-router.
(ospf_config_write) call previous.
(ospf_vty_init) install the new stub-router commands.
* ospfd.c: various functions made static.
(ospf_new) Set defaults for stub-router. Graceful shutdown
is made to default on, just to be adventerous.
(ospf_graceful_shutdown_finish) new function, final part of
shutdown.
(ospf_graceful_shutdown_timer) timer thread wrapper for
graceful-shutdown.
(ospf_graceful_shutdown_check) check whether to setup timer
for shutdown or proceed directly to final shutdown.
(ospf_terminate) moved here from ospf_route.c, call
ospf_finish for each instance.
(ospf_finish) renamed to ospf_finish_final and made static.
(ospf_finish) new function, exported wrapper around
ospf_graceful_shutdown_check.
(ospf_finish_final) complete shutdown of an instance.
Add missing TIMER_OFF's of two timer threads.
(ospf_area_free) opaque self lsa timer should be turned off.
2005-10-29 14:50:09 +02:00
|
|
|
|
/* check whether stub-router is desired, and if this is the first
|
|
|
|
|
* router LSA.
|
|
|
|
|
*/
|
|
|
|
|
ospf_stub_router_check (area);
|
|
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
|
/* Create a stream for LSA. */
|
|
|
|
|
s = stream_new (OSPF_MAX_LSA_SIZE);
|
|
|
|
|
/* Set LSA common header fields. */
|
2003-07-12 23:30:57 +02:00
|
|
|
|
lsa_header_set (s, LSA_OPTIONS_GET (area) | LSA_OPTIONS_NSSA_GET (area),
|
|
|
|
|
OSPF_ROUTER_LSA, ospf->router_id, ospf->router_id);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
|
|
/* Set router-LSA body fields. */
|
|
|
|
|
ospf_router_lsa_body_set (s, area);
|
|
|
|
|
|
|
|
|
|
/* Set length. */
|
|
|
|
|
length = stream_get_endp (s);
|
2006-01-18 16:07:38 +01:00
|
|
|
|
lsah = (struct lsa_header *) STREAM_DATA (s);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
lsah->length = htons (length);
|
|
|
|
|
|
|
|
|
|
/* Now, create OSPF LSA instance. */
|
2005-11-20 15:54:12 +01:00
|
|
|
|
if ( (new = ospf_lsa_new ()) == NULL)
|
|
|
|
|
{
|
|
|
|
|
zlog_err ("%s: Unable to create new lsa", __func__);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
|
new->area = area;
|
2008-11-04 14:37:29 +01:00
|
|
|
|
SET_FLAG (new->flags, OSPF_LSA_SELF | OSPF_LSA_SELF_CHECKED);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
|
|
/* Copy LSA data to store, discard stream. */
|
|
|
|
|
new->data = ospf_lsa_data_new (length);
|
|
|
|
|
memcpy (new->data, lsah, length);
|
|
|
|
|
stream_free (s);
|
|
|
|
|
|
|
|
|
|
return new;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Originate Router-LSA. */
|
2005-10-29 Paul Jakma <paul.jakma@sun.com>
* (general) RFC3137 stub-router support
* ospfd.h: Add OSPF_OUTPUT_COST_INFINITE define.
(struct ospf_master) Add a OSPF_MASTER_SHUTDOWN flag for
options, to allow shutdown to distinguish between complete
shutdown and shutdown of a subset of ospf instances.
(struct ospf)
Add stub_router_{startup,shutdown_}time, configuration of startup
and shutdown time for stub-router.
Add t_graceful_shutdown struct thread, timer for graceful
shutdown, if needed.
(struct ospf_area) Add stub_router_state - run time state of
stub-router for an area. Add flags for ADMIN, IS and WAS
states.
Add t_stub_router, timer thread to resend router-lsa for an
area.
* ospf_lsa.c: (ospf_link_cost) new simple function to spit out
either the given lnks cost or infinite cost if stub-router is
in effect.
(lsa_link_{ptop,broadcast,virtuallink,ptomp}_set) use
previous function for transit-links.
(ospf_stub_router_timer) timer thread for end of startup stub
router. Change state as required for the area and setup
re-origination of router-lsa.
(ospf_stub_router_check) Check/do whether stub-router should be
enabled, and whether it requires timer to be setup.
(ospf_router_lsa_new) call previous function at top.
(ospf_router_lsa_originate) no external callers, made static.
* ospf_lsa.h: (ospf_router_lsa_originate) removed.
* ospf_main.c: (sigint) make static.
remove call to exit, as ospf_terminate now deals with
exiting.
* ospf_route.c: (ospf_terminate) removed, now in ospfd.c.
* ospf_vty.c: (show_ip_ospf_area) print out state of
stub-router, if active.
(show_ip_ospf) print out configuration of stub-router
support, and details of graceful-shutdown if the timer is
active.
((no)?ospf_max_metric_router_lsa_{admin,startup,shutdown}) new
commands to (de-)?configure stub-router support.
(config_write_stub_router) write out config of stub-router.
(ospf_config_write) call previous.
(ospf_vty_init) install the new stub-router commands.
* ospfd.c: various functions made static.
(ospf_new) Set defaults for stub-router. Graceful shutdown
is made to default on, just to be adventerous.
(ospf_graceful_shutdown_finish) new function, final part of
shutdown.
(ospf_graceful_shutdown_timer) timer thread wrapper for
graceful-shutdown.
(ospf_graceful_shutdown_check) check whether to setup timer
for shutdown or proceed directly to final shutdown.
(ospf_terminate) moved here from ospf_route.c, call
ospf_finish for each instance.
(ospf_finish) renamed to ospf_finish_final and made static.
(ospf_finish) new function, exported wrapper around
ospf_graceful_shutdown_check.
(ospf_finish_final) complete shutdown of an instance.
Add missing TIMER_OFF's of two timer threads.
(ospf_area_free) opaque self lsa timer should be turned off.
2005-10-29 14:50:09 +02:00
|
|
|
|
static struct ospf_lsa *
|
2002-12-13 21:15:29 +01:00
|
|
|
|
ospf_router_lsa_originate (struct ospf_area *area)
|
|
|
|
|
{
|
|
|
|
|
struct ospf_lsa *new;
|
2005-10-29 Paul Jakma <paul.jakma@sun.com>
* (general) RFC3137 stub-router support
* ospfd.h: Add OSPF_OUTPUT_COST_INFINITE define.
(struct ospf_master) Add a OSPF_MASTER_SHUTDOWN flag for
options, to allow shutdown to distinguish between complete
shutdown and shutdown of a subset of ospf instances.
(struct ospf)
Add stub_router_{startup,shutdown_}time, configuration of startup
and shutdown time for stub-router.
Add t_graceful_shutdown struct thread, timer for graceful
shutdown, if needed.
(struct ospf_area) Add stub_router_state - run time state of
stub-router for an area. Add flags for ADMIN, IS and WAS
states.
Add t_stub_router, timer thread to resend router-lsa for an
area.
* ospf_lsa.c: (ospf_link_cost) new simple function to spit out
either the given lnks cost or infinite cost if stub-router is
in effect.
(lsa_link_{ptop,broadcast,virtuallink,ptomp}_set) use
previous function for transit-links.
(ospf_stub_router_timer) timer thread for end of startup stub
router. Change state as required for the area and setup
re-origination of router-lsa.
(ospf_stub_router_check) Check/do whether stub-router should be
enabled, and whether it requires timer to be setup.
(ospf_router_lsa_new) call previous function at top.
(ospf_router_lsa_originate) no external callers, made static.
* ospf_lsa.h: (ospf_router_lsa_originate) removed.
* ospf_main.c: (sigint) make static.
remove call to exit, as ospf_terminate now deals with
exiting.
* ospf_route.c: (ospf_terminate) removed, now in ospfd.c.
* ospf_vty.c: (show_ip_ospf_area) print out state of
stub-router, if active.
(show_ip_ospf) print out configuration of stub-router
support, and details of graceful-shutdown if the timer is
active.
((no)?ospf_max_metric_router_lsa_{admin,startup,shutdown}) new
commands to (de-)?configure stub-router support.
(config_write_stub_router) write out config of stub-router.
(ospf_config_write) call previous.
(ospf_vty_init) install the new stub-router commands.
* ospfd.c: various functions made static.
(ospf_new) Set defaults for stub-router. Graceful shutdown
is made to default on, just to be adventerous.
(ospf_graceful_shutdown_finish) new function, final part of
shutdown.
(ospf_graceful_shutdown_timer) timer thread wrapper for
graceful-shutdown.
(ospf_graceful_shutdown_check) check whether to setup timer
for shutdown or proceed directly to final shutdown.
(ospf_terminate) moved here from ospf_route.c, call
ospf_finish for each instance.
(ospf_finish) renamed to ospf_finish_final and made static.
(ospf_finish) new function, exported wrapper around
ospf_graceful_shutdown_check.
(ospf_finish_final) complete shutdown of an instance.
Add missing TIMER_OFF's of two timer threads.
(ospf_area_free) opaque self lsa timer should be turned off.
2005-10-29 14:50:09 +02:00
|
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
|
/* Create new router-LSA instance. */
|
2005-11-20 15:54:12 +01:00
|
|
|
|
if ( (new = ospf_router_lsa_new (area)) == NULL)
|
|
|
|
|
{
|
|
|
|
|
zlog_err ("%s: ospf_router_lsa_new returned NULL", __func__);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
|
|
/* Sanity check. */
|
|
|
|
|
if (new->data->adv_router.s_addr == 0)
|
|
|
|
|
{
|
|
|
|
|
if (IS_DEBUG_OSPF_EVENT)
|
2004-12-08 19:12:06 +01:00
|
|
|
|
zlog_debug ("LSA[Type1]: AdvRouter is 0, discard");
|
2002-12-13 21:15:29 +01:00
|
|
|
|
ospf_lsa_discard (new);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Install LSA to LSDB. */
|
2003-03-25 06:07:42 +01:00
|
|
|
|
new = ospf_lsa_install (area->ospf, NULL, new);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
|
|
/* Update LSA origination count. */
|
2003-03-25 06:07:42 +01:00
|
|
|
|
area->ospf->lsa_originate_count++;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
|
|
/* Flooding new LSA through area. */
|
|
|
|
|
ospf_flood_through_area (area, NULL, new);
|
|
|
|
|
|
|
|
|
|
if (IS_DEBUG_OSPF (lsa, LSA_GENERATE))
|
|
|
|
|
{
|
2004-12-08 19:12:06 +01:00
|
|
|
|
zlog_debug ("LSA[Type%d:%s]: Originate router-LSA %p",
|
2002-12-13 21:15:29 +01:00
|
|
|
|
new->data->type, inet_ntoa (new->data->id), new);
|
|
|
|
|
ospf_lsa_header_dump (new->data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return new;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Refresh router-LSA. */
|
2005-05-06 23:37:42 +02:00
|
|
|
|
static struct ospf_lsa *
|
2002-12-13 21:15:29 +01:00
|
|
|
|
ospf_router_lsa_refresh (struct ospf_lsa *lsa)
|
|
|
|
|
{
|
|
|
|
|
struct ospf_area *area = lsa->area;
|
|
|
|
|
struct ospf_lsa *new;
|
|
|
|
|
|
|
|
|
|
/* Sanity check. */
|
|
|
|
|
assert (lsa->data);
|
|
|
|
|
|
|
|
|
|
/* Delete LSA from neighbor retransmit-list. */
|
2003-03-25 06:07:42 +01:00
|
|
|
|
ospf_ls_retransmit_delete_nbr_area (area, lsa);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
|
|
/* Create new router-LSA instance. */
|
2005-11-20 15:54:12 +01:00
|
|
|
|
if ( (new = ospf_router_lsa_new (area)) == NULL)
|
|
|
|
|
{
|
|
|
|
|
zlog_err ("%s: ospf_router_lsa_new returned NULL", __func__);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
|
new->data->ls_seqnum = lsa_seqnum_increment (lsa);
|
|
|
|
|
|
2003-03-25 06:07:42 +01:00
|
|
|
|
ospf_lsa_install (area->ospf, NULL, new);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
|
|
/* Flood LSA through area. */
|
|
|
|
|
ospf_flood_through_area (area, NULL, new);
|
|
|
|
|
|
|
|
|
|
/* Debug logging. */
|
|
|
|
|
if (IS_DEBUG_OSPF (lsa, LSA_GENERATE))
|
|
|
|
|
{
|
2004-12-08 19:12:06 +01:00
|
|
|
|
zlog_debug ("LSA[Type%d:%s]: router-LSA refresh",
|
2002-12-13 21:15:29 +01:00
|
|
|
|
new->data->type, inet_ntoa (new->data->id));
|
|
|
|
|
ospf_lsa_header_dump (new->data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2005-05-06 23:37:42 +02:00
|
|
|
|
static int
|
2002-12-13 21:15:29 +01:00
|
|
|
|
ospf_router_lsa_timer (struct thread *t)
|
|
|
|
|
{
|
|
|
|
|
struct ospf_area *area;
|
|
|
|
|
|
|
|
|
|
if (IS_DEBUG_OSPF_EVENT)
|
2004-12-08 19:12:06 +01:00
|
|
|
|
zlog_debug ("Timer[router-LSA]: (router-LSA Refresh expire)");
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
|
|
area = THREAD_ARG (t);
|
|
|
|
|
area->t_router_lsa_self = NULL;
|
|
|
|
|
|
|
|
|
|
/* Now refresh router-LSA. */
|
|
|
|
|
if (area->router_lsa_self)
|
|
|
|
|
ospf_router_lsa_refresh (area->router_lsa_self);
|
|
|
|
|
/* Newly originate router-LSA. */
|
|
|
|
|
else
|
|
|
|
|
ospf_router_lsa_originate (area);
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
ospf_router_lsa_timer_add (struct ospf_area *area)
|
|
|
|
|
{
|
|
|
|
|
/* Keep area's self-originated router-LSA. */
|
|
|
|
|
struct ospf_lsa *lsa = area->router_lsa_self;
|
|
|
|
|
|
|
|
|
|
/* Cancel previously scheduled router-LSA timer. */
|
|
|
|
|
if (area->t_router_lsa_self)
|
|
|
|
|
if (IS_DEBUG_OSPF (lsa, LSA_GENERATE))
|
2004-12-08 19:12:06 +01:00
|
|
|
|
zlog_debug ("LSA[Type1]: Cancel previous router-LSA timer");
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
|
|
OSPF_TIMER_OFF (area->t_router_lsa_self);
|
|
|
|
|
|
|
|
|
|
/* If router-LSA is originated previously, check the interval time. */
|
|
|
|
|
if (lsa)
|
|
|
|
|
{
|
|
|
|
|
int delay;
|
|
|
|
|
if ((delay = ospf_lsa_refresh_delay (lsa)) > 0)
|
|
|
|
|
{
|
|
|
|
|
OSPF_AREA_TIMER_ON (area->t_router_lsa_self,
|
|
|
|
|
ospf_router_lsa_timer, delay);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (IS_DEBUG_OSPF (lsa, LSA_GENERATE))
|
2004-12-08 19:12:06 +01:00
|
|
|
|
zlog_debug ("LSA[Type1]: Scheduling router-LSA origination right away");
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
|
|
/* Immediately refresh router-LSA. */
|
|
|
|
|
OSPF_AREA_TIMER_ON (area->t_router_lsa_self, ospf_router_lsa_timer, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int
|
2003-03-25 06:07:42 +01:00
|
|
|
|
ospf_router_lsa_update_timer (struct thread *thread)
|
2002-12-13 21:15:29 +01:00
|
|
|
|
{
|
2003-03-25 06:07:42 +01:00
|
|
|
|
struct ospf *ospf = THREAD_ARG (thread);
|
2005-04-07 Paul Jakma <paul.jakma@sun.com>
* (global): Fix up list loops to match changes in lib/linklist,
and some basic auditing of usage.
* configure.ac: define QUAGGA_NO_DEPRECATED_INTERFACES
* HACKING: Add notes about deprecating interfaces and commands.
* lib/linklist.h: Add usage comments.
Rename getdata macro to listgetdata.
Rename nextnode to listnextnode and fix its odd behaviour to be
less dangerous.
Make listgetdata macro assert node is not null, NULL list entries
should be bug condition.
ALL_LIST_ELEMENTS, new macro, forward-referencing macro for use
with for loop, Suggested by Jim Carlson of Sun.
Add ALL_LIST_ELEMENTS_RO for cases which obviously do not need the
"safety" of previous macro.
LISTNODE_ADD and DELETE macros renamed to ATTACH, DETACH, to
distinguish from the similarly named functions, and reflect their
effect better.
Add a QUAGGA_NO_DEPRECATED_INTERFACES define guarded section
with the old defines which were modified above,
for backwards compatibility - guarded to prevent Quagga using it..
* lib/linklist.c: fix up for linklist.h changes.
* ospf6d/ospf6_abr.c: (ospf6_abr_examin_brouter) change to a single
scan of the area list, rather than scanning all areas first for
INTER_ROUTER and then again for INTER_NETWORK. According to
16.2, the scan should be area specific anyway, and further
ospf6d does not seem to implement 16.3 anyway.
2005-04-07 09:30:20 +02:00
|
|
|
|
struct listnode *node, *nnode;
|
|
|
|
|
struct ospf_area *area;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
|
|
if (IS_DEBUG_OSPF (lsa, LSA_GENERATE))
|
2004-12-08 19:12:06 +01:00
|
|
|
|
zlog_debug ("Timer[router-LSA Update]: (timer expire)");
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
2003-03-25 06:07:42 +01:00
|
|
|
|
ospf->t_router_lsa_update = NULL;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
2005-04-07 Paul Jakma <paul.jakma@sun.com>
* (global): Fix up list loops to match changes in lib/linklist,
and some basic auditing of usage.
* configure.ac: define QUAGGA_NO_DEPRECATED_INTERFACES
* HACKING: Add notes about deprecating interfaces and commands.
* lib/linklist.h: Add usage comments.
Rename getdata macro to listgetdata.
Rename nextnode to listnextnode and fix its odd behaviour to be
less dangerous.
Make listgetdata macro assert node is not null, NULL list entries
should be bug condition.
ALL_LIST_ELEMENTS, new macro, forward-referencing macro for use
with for loop, Suggested by Jim Carlson of Sun.
Add ALL_LIST_ELEMENTS_RO for cases which obviously do not need the
"safety" of previous macro.
LISTNODE_ADD and DELETE macros renamed to ATTACH, DETACH, to
distinguish from the similarly named functions, and reflect their
effect better.
Add a QUAGGA_NO_DEPRECATED_INTERFACES define guarded section
with the old defines which were modified above,
for backwards compatibility - guarded to prevent Quagga using it..
* lib/linklist.c: fix up for linklist.h changes.
* ospf6d/ospf6_abr.c: (ospf6_abr_examin_brouter) change to a single
scan of the area list, rather than scanning all areas first for
INTER_ROUTER and then again for INTER_NETWORK. According to
16.2, the scan should be area specific anyway, and further
ospf6d does not seem to implement 16.3 anyway.
2005-04-07 09:30:20 +02:00
|
|
|
|
for (ALL_LIST_ELEMENTS (ospf->areas, node, nnode, area))
|
2002-12-13 21:15:29 +01:00
|
|
|
|
{
|
|
|
|
|
struct ospf_lsa *lsa = area->router_lsa_self;
|
|
|
|
|
struct router_lsa *rl;
|
2004-10-08 10:17:22 +02:00
|
|
|
|
const char *area_str;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
|
|
/* Keep Area ID string. */
|
|
|
|
|
area_str = AREA_NAME (area);
|
|
|
|
|
|
|
|
|
|
/* If LSA not exist in this Area, originate new. */
|
|
|
|
|
if (lsa == NULL)
|
|
|
|
|
{
|
|
|
|
|
if (IS_DEBUG_OSPF (lsa, LSA_GENERATE))
|
2004-12-08 19:12:06 +01:00
|
|
|
|
zlog_debug("LSA[Type1]: Create router-LSA for Area %s", area_str);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
|
|
ospf_router_lsa_originate (area);
|
|
|
|
|
}
|
|
|
|
|
/* If router-ID is changed, Link ID must change.
|
|
|
|
|
First flush old LSA, then originate new. */
|
2003-03-25 06:07:42 +01:00
|
|
|
|
else if (!IPV4_ADDR_SAME (&lsa->data->id, &ospf->router_id))
|
2002-12-13 21:15:29 +01:00
|
|
|
|
{
|
|
|
|
|
if (IS_DEBUG_OSPF (lsa, LSA_GENERATE))
|
2004-12-08 19:12:06 +01:00
|
|
|
|
zlog_debug("LSA[Type%d:%s]: Refresh router-LSA for Area %s",
|
2002-12-13 21:15:29 +01:00
|
|
|
|
lsa->data->type, inet_ntoa (lsa->data->id), area_str);
|
|
|
|
|
ospf_lsa_flush_area (lsa, area);
|
2006-07-26 11:37:26 +02:00
|
|
|
|
ospf_lsa_unlock (&area->router_lsa_self);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
area->router_lsa_self = NULL;
|
|
|
|
|
|
|
|
|
|
/* Refresh router-LSA, (not install) and flood through area. */
|
|
|
|
|
ospf_router_lsa_timer_add (area);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
rl = (struct router_lsa *) lsa->data;
|
|
|
|
|
/* Refresh router-LSA, (not install) and flood through area. */
|
2003-03-25 06:07:42 +01:00
|
|
|
|
if (rl->flags != ospf->flags)
|
2002-12-13 21:15:29 +01:00
|
|
|
|
ospf_router_lsa_timer_add (area);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* network-LSA related functions. */
|
|
|
|
|
/* Originate Network-LSA. */
|
2005-05-06 23:37:42 +02:00
|
|
|
|
static void
|
2002-12-13 21:15:29 +01:00
|
|
|
|
ospf_network_lsa_body_set (struct stream *s, struct ospf_interface *oi)
|
|
|
|
|
{
|
|
|
|
|
struct in_addr mask;
|
|
|
|
|
struct route_node *rn;
|
|
|
|
|
struct ospf_neighbor *nbr;
|
|
|
|
|
|
|
|
|
|
masklen2ip (oi->address->prefixlen, &mask);
|
|
|
|
|
stream_put_ipv4 (s, mask.s_addr);
|
|
|
|
|
|
|
|
|
|
/* The network-LSA lists those routers that are fully adjacent to
|
|
|
|
|
the Designated Router; each fully adjacent router is identified by
|
|
|
|
|
its OSPF Router ID. The Designated Router includes itself in this
|
|
|
|
|
list. RFC2328, Section 12.4.2 */
|
|
|
|
|
|
|
|
|
|
for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
|
|
|
|
|
if ((nbr = rn->info) != NULL)
|
|
|
|
|
if (nbr->state == NSM_Full || nbr == oi->nbr_self)
|
|
|
|
|
stream_put_ipv4 (s, nbr->router_id.s_addr);
|
|
|
|
|
}
|
|
|
|
|
|
2005-05-06 23:37:42 +02:00
|
|
|
|
static struct ospf_lsa *
|
2002-12-13 21:15:29 +01:00
|
|
|
|
ospf_network_lsa_new (struct ospf_interface *oi)
|
|
|
|
|
{
|
|
|
|
|
struct stream *s;
|
|
|
|
|
struct ospf_lsa *new;
|
|
|
|
|
struct lsa_header *lsah;
|
|
|
|
|
int length;
|
|
|
|
|
|
|
|
|
|
/* If there are no neighbours on this network (the net is stub),
|
|
|
|
|
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))
|
2004-12-08 19:12:06 +01:00
|
|
|
|
zlog_debug ("LSA[Type2]: Create network-LSA instance");
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
|
|
/* Create new stream for LSA. */
|
|
|
|
|
s = stream_new (OSPF_MAX_LSA_SIZE);
|
|
|
|
|
lsah = (struct lsa_header *) STREAM_DATA (s);
|
|
|
|
|
|
|
|
|
|
lsa_header_set (s, (OPTIONS (oi) | LSA_OPTIONS_GET (oi->area)),
|
2003-03-25 06:07:42 +01:00
|
|
|
|
OSPF_NETWORK_LSA, DR (oi), oi->ospf->router_id);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
|
|
/* Set network-LSA body fields. */
|
|
|
|
|
ospf_network_lsa_body_set (s, oi);
|
|
|
|
|
|
|
|
|
|
/* Set length. */
|
|
|
|
|
length = stream_get_endp (s);
|
|
|
|
|
lsah->length = htons (length);
|
|
|
|
|
|
|
|
|
|
/* Create OSPF LSA instance. */
|
2005-11-20 15:54:12 +01:00
|
|
|
|
if ( (new = ospf_lsa_new ()) == NULL)
|
|
|
|
|
{
|
|
|
|
|
zlog_err ("%s: ospf_lsa_new returned NULL", __func__);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
|
new->area = oi->area;
|
2008-11-04 14:37:29 +01:00
|
|
|
|
SET_FLAG (new->flags, OSPF_LSA_SELF | OSPF_LSA_SELF_CHECKED);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
|
|
/* Copy LSA to store. */
|
|
|
|
|
new->data = ospf_lsa_data_new (length);
|
|
|
|
|
memcpy (new->data, lsah, length);
|
|
|
|
|
stream_free (s);
|
|
|
|
|
|
|
|
|
|
return new;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Originate network-LSA. */
|
2005-05-06 23:37:42 +02:00
|
|
|
|
static struct ospf_lsa *
|
2002-12-13 21:15:29 +01:00
|
|
|
|
ospf_network_lsa_originate (struct ospf_interface *oi)
|
|
|
|
|
{
|
|
|
|
|
struct ospf_lsa *new;
|
|
|
|
|
|
|
|
|
|
/* Create new network-LSA instance. */
|
|
|
|
|
new = ospf_network_lsa_new (oi);
|
|
|
|
|
if (new == NULL)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
/* Install LSA to LSDB. */
|
2003-03-25 06:07:42 +01:00
|
|
|
|
new = ospf_lsa_install (oi->ospf, oi, new);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
|
|
/* Update LSA origination count. */
|
2003-03-25 06:07:42 +01:00
|
|
|
|
oi->ospf->lsa_originate_count++;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
|
|
/* Flooding new LSA through area. */
|
|
|
|
|
ospf_flood_through_area (oi->area, NULL, new);
|
|
|
|
|
|
|
|
|
|
if (IS_DEBUG_OSPF (lsa, LSA_GENERATE))
|
|
|
|
|
{
|
2004-12-08 19:12:06 +01:00
|
|
|
|
zlog_debug ("LSA[Type%d:%s]: Originate network-LSA %p",
|
2002-12-13 21:15:29 +01:00
|
|
|
|
new->data->type, inet_ntoa (new->data->id), new);
|
|
|
|
|
ospf_lsa_header_dump (new->data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return new;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
ospf_network_lsa_refresh (struct ospf_lsa *lsa, struct ospf_interface *oi)
|
|
|
|
|
{
|
|
|
|
|
struct ospf_area *area = lsa->area;
|
|
|
|
|
struct ospf_lsa *new;
|
|
|
|
|
|
|
|
|
|
assert (lsa->data);
|
|
|
|
|
|
|
|
|
|
/* Delete LSA from neighbor retransmit-list. */
|
2003-03-25 06:07:42 +01:00
|
|
|
|
ospf_ls_retransmit_delete_nbr_area (area, lsa);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
|
|
/* Create new network-LSA instance. */
|
|
|
|
|
new = ospf_network_lsa_new (oi);
|
|
|
|
|
if (new == NULL)
|
|
|
|
|
return -1;
|
|
|
|
|
new->data->ls_seqnum = lsa_seqnum_increment (lsa);
|
|
|
|
|
|
2003-03-25 06:07:42 +01:00
|
|
|
|
ospf_lsa_install (area->ospf, oi, new);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
|
|
/* Flood LSA through aera. */
|
|
|
|
|
ospf_flood_through_area (area, NULL, new);
|
|
|
|
|
|
|
|
|
|
if (IS_DEBUG_OSPF (lsa, LSA_GENERATE))
|
|
|
|
|
{
|
2004-12-08 19:12:06 +01:00
|
|
|
|
zlog_debug ("LSA[Type%d:%s]: network-LSA refresh",
|
2002-12-13 21:15:29 +01:00
|
|
|
|
new->data->type, inet_ntoa (new->data->id));
|
|
|
|
|
ospf_lsa_header_dump (new->data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2005-05-06 23:37:42 +02:00
|
|
|
|
static int
|
2002-12-13 21:15:29 +01:00
|
|
|
|
ospf_network_lsa_refresh_timer (struct thread *t)
|
|
|
|
|
{
|
|
|
|
|
struct ospf_interface *oi;
|
|
|
|
|
|
|
|
|
|
oi = THREAD_ARG (t);
|
|
|
|
|
oi->t_network_lsa_self = NULL;
|
|
|
|
|
|
|
|
|
|
if (oi->network_lsa_self)
|
|
|
|
|
/* Now refresh network-LSA. */
|
|
|
|
|
ospf_network_lsa_refresh (oi->network_lsa_self, oi);
|
|
|
|
|
else
|
|
|
|
|
/* Newly create network-LSA. */
|
|
|
|
|
ospf_network_lsa_originate (oi);
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
ospf_network_lsa_timer_add (struct ospf_interface *oi)
|
|
|
|
|
{
|
|
|
|
|
/* Keep interface's self-originated network-LSA. */
|
|
|
|
|
struct ospf_lsa *lsa = oi->network_lsa_self;
|
|
|
|
|
|
|
|
|
|
/* Cancel previously schedules network-LSA timer. */
|
|
|
|
|
if (oi->t_network_lsa_self)
|
|
|
|
|
if (IS_DEBUG_OSPF (lsa, LSA_GENERATE))
|
2004-12-08 19:12:06 +01:00
|
|
|
|
zlog_debug ("LSA[Type2]: Cancel previous network-LSA timer");
|
2002-12-13 21:15:29 +01:00
|
|
|
|
OSPF_TIMER_OFF (oi->t_network_lsa_self);
|
|
|
|
|
|
|
|
|
|
/* If network-LSA is originated previously, check the interval time. */
|
|
|
|
|
if (lsa)
|
|
|
|
|
{
|
|
|
|
|
int delay;
|
|
|
|
|
if ((delay = ospf_lsa_refresh_delay (lsa)) > 0)
|
|
|
|
|
{
|
|
|
|
|
oi->t_network_lsa_self =
|
|
|
|
|
thread_add_timer (master, ospf_network_lsa_refresh_timer,
|
|
|
|
|
oi, delay);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (IS_DEBUG_OSPF (lsa, LSA_GENERATE))
|
2004-12-08 19:12:06 +01:00
|
|
|
|
zlog_debug ("Scheduling network-LSA origination right away");
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
|
|
/* Immediately refresh network-LSA. */
|
|
|
|
|
oi->t_network_lsa_self =
|
|
|
|
|
thread_add_event (master, ospf_network_lsa_refresh_timer, oi, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2005-05-06 23:37:42 +02:00
|
|
|
|
static void
|
2002-12-13 21:15:29 +01:00
|
|
|
|
stream_put_ospf_metric (struct stream *s, u_int32_t metric_value)
|
|
|
|
|
{
|
|
|
|
|
u_int32_t metric;
|
|
|
|
|
char *mp;
|
|
|
|
|
|
|
|
|
|
/* Put 0 metric. TOS metric is not supported. */
|
|
|
|
|
metric = htonl (metric_value);
|
|
|
|
|
mp = (char *) &metric;
|
|
|
|
|
mp++;
|
|
|
|
|
stream_put (s, mp, 3);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* summary-LSA related functions. */
|
2005-05-06 23:37:42 +02:00
|
|
|
|
static void
|
2002-12-13 21:15:29 +01:00
|
|
|
|
ospf_summary_lsa_body_set (struct stream *s, struct prefix *p,
|
|
|
|
|
u_int32_t metric)
|
|
|
|
|
{
|
|
|
|
|
struct in_addr mask;
|
|
|
|
|
|
|
|
|
|
masklen2ip (p->prefixlen, &mask);
|
|
|
|
|
|
|
|
|
|
/* Put Network Mask. */
|
|
|
|
|
stream_put_ipv4 (s, mask.s_addr);
|
|
|
|
|
|
|
|
|
|
/* Set # TOS. */
|
|
|
|
|
stream_putc (s, (u_char) 0);
|
|
|
|
|
|
|
|
|
|
/* Set metric. */
|
|
|
|
|
stream_put_ospf_metric (s, metric);
|
|
|
|
|
}
|
|
|
|
|
|
2005-05-06 23:37:42 +02:00
|
|
|
|
static struct ospf_lsa *
|
2002-12-13 21:15:29 +01:00
|
|
|
|
ospf_summary_lsa_new (struct ospf_area *area, struct prefix *p,
|
|
|
|
|
u_int32_t metric, struct in_addr id)
|
|
|
|
|
{
|
|
|
|
|
struct stream *s;
|
|
|
|
|
struct ospf_lsa *new;
|
|
|
|
|
struct lsa_header *lsah;
|
|
|
|
|
int length;
|
|
|
|
|
|
2005-11-20 15:54:12 +01:00
|
|
|
|
if (id.s_addr == 0xffffffff)
|
|
|
|
|
{
|
|
|
|
|
/* Maybe Link State ID not available. */
|
|
|
|
|
if (IS_DEBUG_OSPF (lsa, LSA_GENERATE))
|
|
|
|
|
zlog_debug ("LSA[Type%d]: Link ID not available, can't originate",
|
|
|
|
|
OSPF_SUMMARY_LSA);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
|
if (IS_DEBUG_OSPF (lsa, LSA_GENERATE))
|
2004-12-08 19:12:06 +01:00
|
|
|
|
zlog_debug ("LSA[Type3]: Create summary-LSA instance");
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
|
|
/* Create new stream for LSA. */
|
|
|
|
|
s = stream_new (OSPF_MAX_LSA_SIZE);
|
|
|
|
|
lsah = (struct lsa_header *) STREAM_DATA (s);
|
|
|
|
|
|
2003-03-25 06:07:42 +01:00
|
|
|
|
lsa_header_set (s, LSA_OPTIONS_GET (area), OSPF_SUMMARY_LSA,
|
|
|
|
|
id, area->ospf->router_id);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
|
|
/* Set summary-LSA body fields. */
|
|
|
|
|
ospf_summary_lsa_body_set (s, p, metric);
|
|
|
|
|
|
|
|
|
|
/* Set length. */
|
|
|
|
|
length = stream_get_endp (s);
|
|
|
|
|
lsah->length = htons (length);
|
|
|
|
|
|
|
|
|
|
/* Create OSPF LSA instance. */
|
|
|
|
|
new = ospf_lsa_new ();
|
|
|
|
|
new->area = area;
|
2008-11-04 14:37:29 +01:00
|
|
|
|
SET_FLAG (new->flags, OSPF_LSA_SELF | OSPF_LSA_SELF_CHECKED);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
|
|
/* Copy LSA to store. */
|
|
|
|
|
new->data = ospf_lsa_data_new (length);
|
|
|
|
|
memcpy (new->data, lsah, length);
|
|
|
|
|
stream_free (s);
|
|
|
|
|
|
|
|
|
|
return new;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Originate Summary-LSA. */
|
|
|
|
|
struct ospf_lsa *
|
|
|
|
|
ospf_summary_lsa_originate (struct prefix_ipv4 *p, u_int32_t metric,
|
|
|
|
|
struct ospf_area *area)
|
|
|
|
|
{
|
|
|
|
|
struct ospf_lsa *new;
|
|
|
|
|
struct in_addr id;
|
|
|
|
|
|
2003-03-25 06:07:42 +01:00
|
|
|
|
id = ospf_lsa_unique_id (area->ospf, area->lsdb, OSPF_SUMMARY_LSA, p);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
2005-11-20 15:54:12 +01:00
|
|
|
|
if (id.s_addr == 0xffffffff)
|
|
|
|
|
{
|
|
|
|
|
/* Maybe Link State ID not available. */
|
|
|
|
|
if (IS_DEBUG_OSPF (lsa, LSA_GENERATE))
|
|
|
|
|
zlog_debug ("LSA[Type%d]: Link ID not available, can't originate",
|
|
|
|
|
OSPF_SUMMARY_LSA);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
|
/* Create new summary-LSA instance. */
|
2005-11-20 15:54:12 +01:00
|
|
|
|
if ( !(new = ospf_summary_lsa_new (area, (struct prefix *) p, metric, id)))
|
|
|
|
|
return NULL;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
|
|
/* Instlal LSA to LSDB. */
|
2003-03-25 06:07:42 +01:00
|
|
|
|
new = ospf_lsa_install (area->ospf, NULL, new);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
|
|
/* Update LSA origination count. */
|
2003-03-25 06:07:42 +01:00
|
|
|
|
area->ospf->lsa_originate_count++;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
|
|
/* Flooding new LSA through area. */
|
|
|
|
|
ospf_flood_through_area (area, NULL, new);
|
|
|
|
|
|
|
|
|
|
if (IS_DEBUG_OSPF (lsa, LSA_GENERATE))
|
|
|
|
|
{
|
2004-12-08 19:12:06 +01:00
|
|
|
|
zlog_debug ("LSA[Type%d:%s]: Originate summary-LSA %p",
|
2002-12-13 21:15:29 +01:00
|
|
|
|
new->data->type, inet_ntoa (new->data->id), new);
|
|
|
|
|
ospf_lsa_header_dump (new->data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return new;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct ospf_lsa*
|
2003-03-25 06:07:42 +01:00
|
|
|
|
ospf_summary_lsa_refresh (struct ospf *ospf, struct ospf_lsa *lsa)
|
2002-12-13 21:15:29 +01:00
|
|
|
|
{
|
|
|
|
|
struct ospf_lsa *new;
|
|
|
|
|
struct summary_lsa *sl;
|
|
|
|
|
struct prefix p;
|
|
|
|
|
|
|
|
|
|
/* Sanity check. */
|
|
|
|
|
assert (lsa->data);
|
|
|
|
|
|
|
|
|
|
sl = (struct summary_lsa *)lsa->data;
|
|
|
|
|
p.prefixlen = ip_masklen (sl->mask);
|
|
|
|
|
new = ospf_summary_lsa_new (lsa->area, &p, GET_METRIC (sl->metric),
|
|
|
|
|
sl->header.id);
|
2005-11-20 15:54:12 +01:00
|
|
|
|
|
|
|
|
|
if (!new)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
|
new->data->ls_seqnum = lsa_seqnum_increment (lsa);
|
|
|
|
|
|
2003-03-25 06:07:42 +01:00
|
|
|
|
ospf_lsa_install (ospf, NULL, new);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
|
|
/* Flood LSA through AS. */
|
|
|
|
|
ospf_flood_through_area (new->area, NULL, new);
|
|
|
|
|
|
|
|
|
|
/* Debug logging. */
|
|
|
|
|
if (IS_DEBUG_OSPF (lsa, LSA_GENERATE))
|
|
|
|
|
{
|
2004-12-08 19:12:06 +01:00
|
|
|
|
zlog_debug ("LSA[Type%d:%s]: summary-LSA refresh",
|
2002-12-13 21:15:29 +01:00
|
|
|
|
new->data->type, inet_ntoa (new->data->id));
|
|
|
|
|
ospf_lsa_header_dump (new->data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return new;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* summary-ASBR-LSA related functions. */
|
2005-05-06 23:37:42 +02:00
|
|
|
|
static void
|
2002-12-13 21:15:29 +01:00
|
|
|
|
ospf_summary_asbr_lsa_body_set (struct stream *s, struct prefix *p,
|
|
|
|
|
u_int32_t metric)
|
|
|
|
|
{
|
|
|
|
|
struct in_addr mask;
|
|
|
|
|
|
|
|
|
|
masklen2ip (p->prefixlen, &mask);
|
|
|
|
|
|
|
|
|
|
/* Put Network Mask. */
|
|
|
|
|
stream_put_ipv4 (s, mask.s_addr);
|
|
|
|
|
|
|
|
|
|
/* Set # TOS. */
|
|
|
|
|
stream_putc (s, (u_char) 0);
|
|
|
|
|
|
|
|
|
|
/* Set metric. */
|
|
|
|
|
stream_put_ospf_metric (s, metric);
|
|
|
|
|
}
|
|
|
|
|
|
2005-05-06 23:37:42 +02:00
|
|
|
|
static struct ospf_lsa *
|
2002-12-13 21:15:29 +01:00
|
|
|
|
ospf_summary_asbr_lsa_new (struct ospf_area *area, struct prefix *p,
|
|
|
|
|
u_int32_t metric, struct in_addr id)
|
|
|
|
|
{
|
|
|
|
|
struct stream *s;
|
|
|
|
|
struct ospf_lsa *new;
|
|
|
|
|
struct lsa_header *lsah;
|
|
|
|
|
int length;
|
|
|
|
|
|
2005-11-20 15:54:12 +01:00
|
|
|
|
if (id.s_addr == 0xffffffff)
|
|
|
|
|
{
|
|
|
|
|
/* Maybe Link State ID not available. */
|
|
|
|
|
if (IS_DEBUG_OSPF (lsa, LSA_GENERATE))
|
|
|
|
|
zlog_debug ("LSA[Type%d]: Link ID not available, can't originate",
|
|
|
|
|
OSPF_ASBR_SUMMARY_LSA);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
|
if (IS_DEBUG_OSPF (lsa, LSA_GENERATE))
|
2004-12-08 19:12:06 +01:00
|
|
|
|
zlog_debug ("LSA[Type3]: Create summary-LSA instance");
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
|
|
/* Create new stream for LSA. */
|
|
|
|
|
s = stream_new (OSPF_MAX_LSA_SIZE);
|
|
|
|
|
lsah = (struct lsa_header *) STREAM_DATA (s);
|
|
|
|
|
|
2003-03-25 06:07:42 +01:00
|
|
|
|
lsa_header_set (s, LSA_OPTIONS_GET (area), OSPF_ASBR_SUMMARY_LSA,
|
|
|
|
|
id, area->ospf->router_id);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
|
|
/* Set summary-LSA body fields. */
|
|
|
|
|
ospf_summary_asbr_lsa_body_set (s, p, metric);
|
|
|
|
|
|
|
|
|
|
/* Set length. */
|
|
|
|
|
length = stream_get_endp (s);
|
|
|
|
|
lsah->length = htons (length);
|
|
|
|
|
|
|
|
|
|
/* Create OSPF LSA instance. */
|
|
|
|
|
new = ospf_lsa_new ();
|
|
|
|
|
new->area = area;
|
2008-11-04 14:37:29 +01:00
|
|
|
|
SET_FLAG (new->flags, OSPF_LSA_SELF | OSPF_LSA_SELF_CHECKED);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
|
|
/* Copy LSA to store. */
|
|
|
|
|
new->data = ospf_lsa_data_new (length);
|
|
|
|
|
memcpy (new->data, lsah, length);
|
|
|
|
|
stream_free (s);
|
|
|
|
|
|
|
|
|
|
return new;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Originate summary-ASBR-LSA. */
|
|
|
|
|
struct ospf_lsa *
|
|
|
|
|
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;
|
|
|
|
|
|
2003-03-25 06:07:42 +01:00
|
|
|
|
id = ospf_lsa_unique_id (area->ospf, area->lsdb, OSPF_ASBR_SUMMARY_LSA, p);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
2005-11-20 15:54:12 +01:00
|
|
|
|
if (id.s_addr == 0xffffffff)
|
|
|
|
|
{
|
|
|
|
|
/* Maybe Link State ID not available. */
|
|
|
|
|
if (IS_DEBUG_OSPF (lsa, LSA_GENERATE))
|
|
|
|
|
zlog_debug ("LSA[Type%d]: Link ID not available, can't originate",
|
|
|
|
|
OSPF_ASBR_SUMMARY_LSA);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
|
/* Create new summary-LSA instance. */
|
|
|
|
|
new = ospf_summary_asbr_lsa_new (area, (struct prefix *) p, metric, id);
|
2005-11-20 15:54:12 +01:00
|
|
|
|
if (!new)
|
|
|
|
|
return NULL;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
|
|
/* Install LSA to LSDB. */
|
2003-03-25 06:07:42 +01:00
|
|
|
|
new = ospf_lsa_install (area->ospf, NULL, new);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
|
|
/* Update LSA origination count. */
|
2003-03-25 06:07:42 +01:00
|
|
|
|
area->ospf->lsa_originate_count++;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
|
|
/* Flooding new LSA through area. */
|
|
|
|
|
ospf_flood_through_area (area, NULL, new);
|
|
|
|
|
|
|
|
|
|
if (IS_DEBUG_OSPF (lsa, LSA_GENERATE))
|
|
|
|
|
{
|
2004-12-08 19:12:06 +01:00
|
|
|
|
zlog_debug ("LSA[Type%d:%s]: Originate summary-ASBR-LSA %p",
|
2002-12-13 21:15:29 +01:00
|
|
|
|
new->data->type, inet_ntoa (new->data->id), new);
|
|
|
|
|
ospf_lsa_header_dump (new->data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return new;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct ospf_lsa*
|
2003-03-25 06:07:42 +01:00
|
|
|
|
ospf_summary_asbr_lsa_refresh (struct ospf *ospf, struct ospf_lsa *lsa)
|
2002-12-13 21:15:29 +01:00
|
|
|
|
{
|
|
|
|
|
struct ospf_lsa *new;
|
|
|
|
|
struct summary_lsa *sl;
|
|
|
|
|
struct prefix p;
|
|
|
|
|
|
|
|
|
|
/* Sanity check. */
|
|
|
|
|
assert (lsa->data);
|
|
|
|
|
|
|
|
|
|
sl = (struct summary_lsa *)lsa->data;
|
|
|
|
|
p.prefixlen = ip_masklen (sl->mask);
|
|
|
|
|
new = ospf_summary_asbr_lsa_new (lsa->area, &p, GET_METRIC (sl->metric),
|
|
|
|
|
sl->header.id);
|
2005-11-20 15:54:12 +01:00
|
|
|
|
if (!new)
|
|
|
|
|
return NULL;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
|
|
new->data->ls_seqnum = lsa_seqnum_increment (lsa);
|
|
|
|
|
|
2003-03-25 06:07:42 +01:00
|
|
|
|
ospf_lsa_install (ospf, NULL, new);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
|
|
/* Flood LSA through area. */
|
|
|
|
|
ospf_flood_through_area (new->area, NULL, new);
|
|
|
|
|
|
|
|
|
|
if (IS_DEBUG_OSPF (lsa, LSA_GENERATE))
|
|
|
|
|
{
|
2004-12-08 19:12:06 +01:00
|
|
|
|
zlog_debug ("LSA[Type%d:%s]: summary-ASBR-LSA refresh",
|
2002-12-13 21:15:29 +01:00
|
|
|
|
new->data->type, inet_ntoa (new->data->id));
|
|
|
|
|
ospf_lsa_header_dump (new->data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return new;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* AS-external-LSA related functions. */
|
|
|
|
|
|
|
|
|
|
/* Get nexthop for AS-external-LSAs. Return nexthop if its interface
|
|
|
|
|
is connected, else 0*/
|
2005-05-06 23:37:42 +02:00
|
|
|
|
static struct in_addr
|
2003-03-25 06:07:42 +01:00
|
|
|
|
ospf_external_lsa_nexthop_get (struct ospf *ospf, struct in_addr nexthop)
|
2002-12-13 21:15:29 +01:00
|
|
|
|
{
|
|
|
|
|
struct in_addr fwd;
|
|
|
|
|
struct prefix nh;
|
2005-04-07 Paul Jakma <paul.jakma@sun.com>
* (global): Fix up list loops to match changes in lib/linklist,
and some basic auditing of usage.
* configure.ac: define QUAGGA_NO_DEPRECATED_INTERFACES
* HACKING: Add notes about deprecating interfaces and commands.
* lib/linklist.h: Add usage comments.
Rename getdata macro to listgetdata.
Rename nextnode to listnextnode and fix its odd behaviour to be
less dangerous.
Make listgetdata macro assert node is not null, NULL list entries
should be bug condition.
ALL_LIST_ELEMENTS, new macro, forward-referencing macro for use
with for loop, Suggested by Jim Carlson of Sun.
Add ALL_LIST_ELEMENTS_RO for cases which obviously do not need the
"safety" of previous macro.
LISTNODE_ADD and DELETE macros renamed to ATTACH, DETACH, to
distinguish from the similarly named functions, and reflect their
effect better.
Add a QUAGGA_NO_DEPRECATED_INTERFACES define guarded section
with the old defines which were modified above,
for backwards compatibility - guarded to prevent Quagga using it..
* lib/linklist.c: fix up for linklist.h changes.
* ospf6d/ospf6_abr.c: (ospf6_abr_examin_brouter) change to a single
scan of the area list, rather than scanning all areas first for
INTER_ROUTER and then again for INTER_NETWORK. According to
16.2, the scan should be area specific anyway, and further
ospf6d does not seem to implement 16.3 anyway.
2005-04-07 09:30:20 +02:00
|
|
|
|
struct listnode *node;
|
|
|
|
|
struct ospf_interface *oi;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
|
|
fwd.s_addr = 0;
|
|
|
|
|
|
|
|
|
|
if (!nexthop.s_addr)
|
|
|
|
|
return fwd;
|
|
|
|
|
|
|
|
|
|
/* Check whether nexthop is covered by OSPF network. */
|
|
|
|
|
nh.family = AF_INET;
|
|
|
|
|
nh.u.prefix4 = nexthop;
|
|
|
|
|
nh.prefixlen = IPV4_MAX_BITLEN;
|
|
|
|
|
|
2005-04-07 Paul Jakma <paul.jakma@sun.com>
* (global): Fix up list loops to match changes in lib/linklist,
and some basic auditing of usage.
* configure.ac: define QUAGGA_NO_DEPRECATED_INTERFACES
* HACKING: Add notes about deprecating interfaces and commands.
* lib/linklist.h: Add usage comments.
Rename getdata macro to listgetdata.
Rename nextnode to listnextnode and fix its odd behaviour to be
less dangerous.
Make listgetdata macro assert node is not null, NULL list entries
should be bug condition.
ALL_LIST_ELEMENTS, new macro, forward-referencing macro for use
with for loop, Suggested by Jim Carlson of Sun.
Add ALL_LIST_ELEMENTS_RO for cases which obviously do not need the
"safety" of previous macro.
LISTNODE_ADD and DELETE macros renamed to ATTACH, DETACH, to
distinguish from the similarly named functions, and reflect their
effect better.
Add a QUAGGA_NO_DEPRECATED_INTERFACES define guarded section
with the old defines which were modified above,
for backwards compatibility - guarded to prevent Quagga using it..
* lib/linklist.c: fix up for linklist.h changes.
* ospf6d/ospf6_abr.c: (ospf6_abr_examin_brouter) change to a single
scan of the area list, rather than scanning all areas first for
INTER_ROUTER and then again for INTER_NETWORK. According to
16.2, the scan should be area specific anyway, and further
ospf6d does not seem to implement 16.3 anyway.
2005-04-07 09:30:20 +02:00
|
|
|
|
for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
|
|
|
|
|
if (if_is_operative (oi->ifp))
|
|
|
|
|
if (oi->address->family == AF_INET)
|
|
|
|
|
if (prefix_match (oi->address, &nh))
|
|
|
|
|
return nexthop;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
|
|
return fwd;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* NSSA-external-LSA related functions. */
|
|
|
|
|
|
|
|
|
|
/* Get 1st IP connection for Forward Addr */
|
2005-05-06 23:37:42 +02:00
|
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
|
struct in_addr
|
|
|
|
|
ospf_get_ip_from_ifp (struct ospf_interface *oi)
|
|
|
|
|
{
|
|
|
|
|
struct in_addr fwd;
|
|
|
|
|
|
|
|
|
|
fwd.s_addr = 0;
|
|
|
|
|
|
2002-12-13 22:03:13 +01:00
|
|
|
|
if (if_is_operative (oi->ifp))
|
2002-12-13 21:15:29 +01:00
|
|
|
|
return oi->address->u.prefix4;
|
|
|
|
|
|
|
|
|
|
return fwd;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Get 1st IP connection for Forward Addr */
|
|
|
|
|
struct in_addr
|
2002-12-13 22:44:27 +01:00
|
|
|
|
ospf_get_nssa_ip (struct ospf_area *area)
|
2002-12-13 21:15:29 +01:00
|
|
|
|
{
|
|
|
|
|
struct in_addr fwd;
|
2002-12-13 22:44:27 +01:00
|
|
|
|
struct in_addr best_default;
|
2005-04-07 Paul Jakma <paul.jakma@sun.com>
* (global): Fix up list loops to match changes in lib/linklist,
and some basic auditing of usage.
* configure.ac: define QUAGGA_NO_DEPRECATED_INTERFACES
* HACKING: Add notes about deprecating interfaces and commands.
* lib/linklist.h: Add usage comments.
Rename getdata macro to listgetdata.
Rename nextnode to listnextnode and fix its odd behaviour to be
less dangerous.
Make listgetdata macro assert node is not null, NULL list entries
should be bug condition.
ALL_LIST_ELEMENTS, new macro, forward-referencing macro for use
with for loop, Suggested by Jim Carlson of Sun.
Add ALL_LIST_ELEMENTS_RO for cases which obviously do not need the
"safety" of previous macro.
LISTNODE_ADD and DELETE macros renamed to ATTACH, DETACH, to
distinguish from the similarly named functions, and reflect their
effect better.
Add a QUAGGA_NO_DEPRECATED_INTERFACES define guarded section
with the old defines which were modified above,
for backwards compatibility - guarded to prevent Quagga using it..
* lib/linklist.c: fix up for linklist.h changes.
* ospf6d/ospf6_abr.c: (ospf6_abr_examin_brouter) change to a single
scan of the area list, rather than scanning all areas first for
INTER_ROUTER and then again for INTER_NETWORK. According to
16.2, the scan should be area specific anyway, and further
ospf6d does not seem to implement 16.3 anyway.
2005-04-07 09:30:20 +02:00
|
|
|
|
struct listnode *node;
|
|
|
|
|
struct ospf_interface *oi;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
|
|
fwd.s_addr = 0;
|
2002-12-13 22:44:27 +01:00
|
|
|
|
best_default.s_addr = 0;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
2005-04-07 Paul Jakma <paul.jakma@sun.com>
* (global): Fix up list loops to match changes in lib/linklist,
and some basic auditing of usage.
* configure.ac: define QUAGGA_NO_DEPRECATED_INTERFACES
* HACKING: Add notes about deprecating interfaces and commands.
* lib/linklist.h: Add usage comments.
Rename getdata macro to listgetdata.
Rename nextnode to listnextnode and fix its odd behaviour to be
less dangerous.
Make listgetdata macro assert node is not null, NULL list entries
should be bug condition.
ALL_LIST_ELEMENTS, new macro, forward-referencing macro for use
with for loop, Suggested by Jim Carlson of Sun.
Add ALL_LIST_ELEMENTS_RO for cases which obviously do not need the
"safety" of previous macro.
LISTNODE_ADD and DELETE macros renamed to ATTACH, DETACH, to
distinguish from the similarly named functions, and reflect their
effect better.
Add a QUAGGA_NO_DEPRECATED_INTERFACES define guarded section
with the old defines which were modified above,
for backwards compatibility - guarded to prevent Quagga using it..
* lib/linklist.c: fix up for linklist.h changes.
* ospf6d/ospf6_abr.c: (ospf6_abr_examin_brouter) change to a single
scan of the area list, rather than scanning all areas first for
INTER_ROUTER and then again for INTER_NETWORK. According to
16.2, the scan should be area specific anyway, and further
ospf6d does not seem to implement 16.3 anyway.
2005-04-07 09:30:20 +02:00
|
|
|
|
for (ALL_LIST_ELEMENTS_RO (area->ospf->oiflist, node, oi))
|
2002-12-13 21:15:29 +01:00
|
|
|
|
{
|
2002-12-13 22:03:13 +01:00
|
|
|
|
if (if_is_operative (oi->ifp))
|
2002-12-13 21:15:29 +01:00
|
|
|
|
if (oi->area->external_routing == OSPF_AREA_NSSA)
|
2003-03-25 06:07:42 +01:00
|
|
|
|
if (oi->address && oi->address->family == AF_INET)
|
|
|
|
|
{
|
|
|
|
|
if (best_default.s_addr == 0)
|
|
|
|
|
best_default = oi->address->u.prefix4;
|
|
|
|
|
if (oi->area == area)
|
|
|
|
|
return oi->address->u.prefix4;
|
2002-12-13 22:44:27 +01:00
|
|
|
|
}
|
2002-12-13 21:15:29 +01:00
|
|
|
|
}
|
2002-12-13 22:44:27 +01:00
|
|
|
|
if (best_default.s_addr != 0)
|
|
|
|
|
return best_default;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
2003-03-25 06:07:42 +01:00
|
|
|
|
if (best_default.s_addr != 0)
|
|
|
|
|
return best_default;
|
|
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
|
return fwd;
|
|
|
|
|
}
|
2004-06-20 23:00:27 +02:00
|
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
|
#define DEFAULT_DEFAULT_METRIC 20
|
|
|
|
|
#define DEFAULT_DEFAULT_ORIGINATE_METRIC 10
|
|
|
|
|
#define DEFAULT_DEFAULT_ALWAYS_METRIC 1
|
|
|
|
|
|
|
|
|
|
#define DEFAULT_METRIC_TYPE EXTERNAL_METRIC_TYPE_2
|
|
|
|
|
|
|
|
|
|
int
|
2003-03-25 06:07:42 +01:00
|
|
|
|
metric_type (struct ospf *ospf, u_char src)
|
2002-12-13 21:15:29 +01:00
|
|
|
|
{
|
2003-03-25 06:07:42 +01:00
|
|
|
|
return (ospf->dmetric[src].type < 0 ?
|
|
|
|
|
DEFAULT_METRIC_TYPE : ospf->dmetric[src].type);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int
|
2003-03-25 06:07:42 +01:00
|
|
|
|
metric_value (struct ospf *ospf, u_char src)
|
2002-12-13 21:15:29 +01:00
|
|
|
|
{
|
2003-03-25 06:07:42 +01:00
|
|
|
|
if (ospf->dmetric[src].value < 0)
|
2002-12-13 21:15:29 +01:00
|
|
|
|
{
|
|
|
|
|
if (src == DEFAULT_ROUTE)
|
|
|
|
|
{
|
2003-03-25 06:07:42 +01:00
|
|
|
|
if (ospf->default_originate == DEFAULT_ORIGINATE_ZEBRA)
|
2002-12-13 21:15:29 +01:00
|
|
|
|
return DEFAULT_DEFAULT_ORIGINATE_METRIC;
|
|
|
|
|
else
|
|
|
|
|
return DEFAULT_DEFAULT_ALWAYS_METRIC;
|
|
|
|
|
}
|
2003-03-25 06:07:42 +01:00
|
|
|
|
else if (ospf->default_metric < 0)
|
2002-12-13 21:15:29 +01:00
|
|
|
|
return DEFAULT_DEFAULT_METRIC;
|
|
|
|
|
else
|
2003-03-25 06:07:42 +01:00
|
|
|
|
return ospf->default_metric;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
}
|
|
|
|
|
|
2003-03-25 06:07:42 +01:00
|
|
|
|
return ospf->dmetric[src].value;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Set AS-external-LSA body. */
|
2005-05-06 23:37:42 +02:00
|
|
|
|
static void
|
2003-03-25 06:07:42 +01:00
|
|
|
|
ospf_external_lsa_body_set (struct stream *s, struct external_info *ei,
|
|
|
|
|
struct ospf *ospf)
|
2002-12-13 21:15:29 +01:00
|
|
|
|
{
|
|
|
|
|
struct prefix_ipv4 *p = &ei->p;
|
|
|
|
|
struct in_addr mask, fwd_addr;
|
|
|
|
|
u_int32_t mvalue;
|
|
|
|
|
int mtype;
|
|
|
|
|
int type;
|
|
|
|
|
|
|
|
|
|
/* Put Network Mask. */
|
|
|
|
|
masklen2ip (p->prefixlen, &mask);
|
|
|
|
|
stream_put_ipv4 (s, mask.s_addr);
|
|
|
|
|
|
|
|
|
|
/* If prefix is default, specify DEFAULT_ROUTE. */
|
|
|
|
|
type = is_prefix_default (&ei->p) ? DEFAULT_ROUTE : ei->type;
|
|
|
|
|
|
|
|
|
|
mtype = (ROUTEMAP_METRIC_TYPE (ei) != -1) ?
|
2003-03-25 06:07:42 +01:00
|
|
|
|
ROUTEMAP_METRIC_TYPE (ei) : metric_type (ospf, type);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
|
|
mvalue = (ROUTEMAP_METRIC (ei) != -1) ?
|
2003-03-25 06:07:42 +01:00
|
|
|
|
ROUTEMAP_METRIC (ei) : metric_value (ospf, type);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
|
|
/* Put type of external metric. */
|
|
|
|
|
stream_putc (s, (mtype == EXTERNAL_METRIC_TYPE_2 ? 0x80 : 0));
|
|
|
|
|
|
|
|
|
|
/* 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. */
|
2003-03-25 06:07:42 +01:00
|
|
|
|
fwd_addr = ospf_external_lsa_nexthop_get (ospf, ei->nexthop);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
|
|
/* 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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Create new external-LSA. */
|
2005-05-06 23:37:42 +02:00
|
|
|
|
static struct ospf_lsa *
|
2003-03-25 06:07:42 +01:00
|
|
|
|
ospf_external_lsa_new (struct ospf *ospf,
|
|
|
|
|
struct external_info *ei, struct in_addr *old_id)
|
2002-12-13 21:15:29 +01:00
|
|
|
|
{
|
|
|
|
|
struct stream *s;
|
|
|
|
|
struct lsa_header *lsah;
|
|
|
|
|
struct ospf_lsa *new;
|
|
|
|
|
struct in_addr id;
|
|
|
|
|
int length;
|
|
|
|
|
|
|
|
|
|
if (ei == NULL)
|
|
|
|
|
{
|
|
|
|
|
if (IS_DEBUG_OSPF (lsa, LSA_GENERATE))
|
2004-12-08 19:12:06 +01:00
|
|
|
|
zlog_debug ("LSA[Type5]: External info is NULL, could not originated");
|
2002-12-13 21:15:29 +01:00
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (IS_DEBUG_OSPF (lsa, LSA_GENERATE))
|
2004-12-08 19:12:06 +01:00
|
|
|
|
zlog_debug ("LSA[Type5]: Originate AS-external-LSA instance");
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
|
|
/* If old Link State ID is specified, refresh LSA with same ID. */
|
|
|
|
|
if (old_id)
|
|
|
|
|
id = *old_id;
|
|
|
|
|
/* Get Link State with unique ID. */
|
|
|
|
|
else
|
|
|
|
|
{
|
2003-03-25 06:07:42 +01:00
|
|
|
|
id = ospf_lsa_unique_id (ospf, ospf->lsdb, OSPF_AS_EXTERNAL_LSA, &ei->p);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
if (id.s_addr == 0xffffffff)
|
|
|
|
|
{
|
|
|
|
|
/* Maybe Link State ID not available. */
|
|
|
|
|
if (IS_DEBUG_OSPF (lsa, LSA_GENERATE))
|
2004-12-08 19:12:06 +01:00
|
|
|
|
zlog_debug ("LSA[Type5]: Link ID not available, can't originate");
|
2002-12-13 21:15:29 +01:00
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Create new stream for LSA. */
|
|
|
|
|
s = stream_new (OSPF_MAX_LSA_SIZE);
|
|
|
|
|
lsah = (struct lsa_header *) STREAM_DATA (s);
|
|
|
|
|
|
|
|
|
|
/* Set LSA common header fields. */
|
2003-03-25 06:07:42 +01:00
|
|
|
|
lsa_header_set (s, OSPF_OPTION_E, OSPF_AS_EXTERNAL_LSA,
|
|
|
|
|
id, ospf->router_id);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
|
|
/* Set AS-external-LSA body fields. */
|
2003-03-25 06:07:42 +01:00
|
|
|
|
ospf_external_lsa_body_set (s, ei, ospf);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
|
|
/* Set length. */
|
|
|
|
|
length = stream_get_endp (s);
|
|
|
|
|
lsah->length = htons (length);
|
|
|
|
|
|
|
|
|
|
/* Now, create OSPF LSA instance. */
|
|
|
|
|
new = ospf_lsa_new ();
|
|
|
|
|
new->area = NULL;
|
2008-11-04 14:37:29 +01:00
|
|
|
|
SET_FLAG (new->flags, OSPF_LSA_SELF | OSPF_LSA_APPROVED | OSPF_LSA_SELF_CHECKED);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
|
|
/* Copy LSA data to store, discard stream. */
|
|
|
|
|
new->data = ospf_lsa_data_new (length);
|
|
|
|
|
memcpy (new->data, lsah, length);
|
|
|
|
|
stream_free (s);
|
|
|
|
|
|
|
|
|
|
return new;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* As Type-7 */
|
2005-05-06 23:37:42 +02:00
|
|
|
|
static void
|
2003-03-25 06:07:42 +01:00
|
|
|
|
ospf_install_flood_nssa (struct ospf *ospf,
|
|
|
|
|
struct ospf_lsa *lsa, struct external_info *ei)
|
2002-12-13 21:15:29 +01:00
|
|
|
|
{
|
2003-07-12 23:30:57 +02:00
|
|
|
|
struct ospf_lsa *new;
|
2003-03-25 06:07:42 +01:00
|
|
|
|
struct as_external_lsa *extlsa;
|
2005-04-07 Paul Jakma <paul.jakma@sun.com>
* (global): Fix up list loops to match changes in lib/linklist,
and some basic auditing of usage.
* configure.ac: define QUAGGA_NO_DEPRECATED_INTERFACES
* HACKING: Add notes about deprecating interfaces and commands.
* lib/linklist.h: Add usage comments.
Rename getdata macro to listgetdata.
Rename nextnode to listnextnode and fix its odd behaviour to be
less dangerous.
Make listgetdata macro assert node is not null, NULL list entries
should be bug condition.
ALL_LIST_ELEMENTS, new macro, forward-referencing macro for use
with for loop, Suggested by Jim Carlson of Sun.
Add ALL_LIST_ELEMENTS_RO for cases which obviously do not need the
"safety" of previous macro.
LISTNODE_ADD and DELETE macros renamed to ATTACH, DETACH, to
distinguish from the similarly named functions, and reflect their
effect better.
Add a QUAGGA_NO_DEPRECATED_INTERFACES define guarded section
with the old defines which were modified above,
for backwards compatibility - guarded to prevent Quagga using it..
* lib/linklist.c: fix up for linklist.h changes.
* ospf6d/ospf6_abr.c: (ospf6_abr_examin_brouter) change to a single
scan of the area list, rather than scanning all areas first for
INTER_ROUTER and then again for INTER_NETWORK. According to
16.2, the scan should be area specific anyway, and further
ospf6d does not seem to implement 16.3 anyway.
2005-04-07 09:30:20 +02:00
|
|
|
|
struct ospf_area *area;
|
|
|
|
|
struct listnode *node, *nnode;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
2003-07-12 23:30:57 +02:00
|
|
|
|
/* 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
|
|
|
|
|
* flooded back to NSSA areas.
|
|
|
|
|
*/
|
|
|
|
|
if (CHECK_FLAG (lsa->flags, OSPF_LSA_LOCAL_XLT))
|
|
|
|
|
return;
|
|
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
|
/* NSSA Originate or Refresh (If anyNSSA)
|
|
|
|
|
|
|
|
|
|
LSA is self-originated. And just installed as Type-5.
|
|
|
|
|
Additionally, install as Type-7 LSDB for every attached NSSA.
|
|
|
|
|
|
|
|
|
|
P-Bit controls which ABR performs translation to outside world; If
|
|
|
|
|
we are an ABR....do not set the P-bit, because we send the Type-5,
|
|
|
|
|
not as the ABR Translator, but as the ASBR owner within the AS!
|
|
|
|
|
|
|
|
|
|
If we are NOT ABR, Flood through NSSA as Type-7 w/P-bit set. The
|
|
|
|
|
elected ABR Translator will see the P-bit, Translate, and re-flood.
|
|
|
|
|
|
|
|
|
|
Later, ABR_TASK and P-bit will scan Type-7 LSDB and translate to
|
|
|
|
|
Type-5's to non-NSSA Areas. (it will also attempt a re-install) */
|
|
|
|
|
|
2005-04-07 Paul Jakma <paul.jakma@sun.com>
* (global): Fix up list loops to match changes in lib/linklist,
and some basic auditing of usage.
* configure.ac: define QUAGGA_NO_DEPRECATED_INTERFACES
* HACKING: Add notes about deprecating interfaces and commands.
* lib/linklist.h: Add usage comments.
Rename getdata macro to listgetdata.
Rename nextnode to listnextnode and fix its odd behaviour to be
less dangerous.
Make listgetdata macro assert node is not null, NULL list entries
should be bug condition.
ALL_LIST_ELEMENTS, new macro, forward-referencing macro for use
with for loop, Suggested by Jim Carlson of Sun.
Add ALL_LIST_ELEMENTS_RO for cases which obviously do not need the
"safety" of previous macro.
LISTNODE_ADD and DELETE macros renamed to ATTACH, DETACH, to
distinguish from the similarly named functions, and reflect their
effect better.
Add a QUAGGA_NO_DEPRECATED_INTERFACES define guarded section
with the old defines which were modified above,
for backwards compatibility - guarded to prevent Quagga using it..
* lib/linklist.c: fix up for linklist.h changes.
* ospf6d/ospf6_abr.c: (ospf6_abr_examin_brouter) change to a single
scan of the area list, rather than scanning all areas first for
INTER_ROUTER and then again for INTER_NETWORK. According to
16.2, the scan should be area specific anyway, and further
ospf6d does not seem to implement 16.3 anyway.
2005-04-07 09:30:20 +02:00
|
|
|
|
for (ALL_LIST_ELEMENTS (ospf->areas, node, nnode, area))
|
2003-03-25 06:07:42 +01:00
|
|
|
|
{
|
2003-07-03 10:36:02 +02:00
|
|
|
|
/* Don't install Type-7 LSA's into nonNSSA area */
|
|
|
|
|
if (area->external_routing != OSPF_AREA_NSSA)
|
|
|
|
|
continue;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
2003-03-25 06:07:42 +01:00
|
|
|
|
/* make lsa duplicate, lock=1 */
|
2003-07-12 23:30:57 +02:00
|
|
|
|
new = ospf_lsa_dup (lsa);
|
|
|
|
|
new->area = area;
|
|
|
|
|
new->data->type = OSPF_AS_NSSA_LSA;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
2003-03-25 06:07:42 +01:00
|
|
|
|
/* set P-bit if not ABR */
|
2003-04-04 04:44:16 +02:00
|
|
|
|
if (! IS_OSPF_ABR (ospf))
|
2003-03-25 06:07:42 +01:00
|
|
|
|
{
|
2003-07-12 23:30:57 +02:00
|
|
|
|
SET_FLAG(new->data->options, OSPF_OPTION_NP);
|
2003-03-25 06:07:42 +01:00
|
|
|
|
|
|
|
|
|
/* 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
|
|
|
|
|
currently done with type-5 LSAs. If the intervening network is
|
|
|
|
|
not adversited into OSPF as an internal OSPF route and the
|
|
|
|
|
type-7 LSA's P-bit is set a forwarding address should be
|
|
|
|
|
selected from one of the router's active OSPF inteface addresses
|
|
|
|
|
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. */
|
|
|
|
|
|
2003-07-12 23:30:57 +02:00
|
|
|
|
/* kevinm: not updating lsa anymore, just new */
|
|
|
|
|
extlsa = (struct as_external_lsa *)(new->data);
|
2003-03-25 06:07:42 +01:00
|
|
|
|
|
|
|
|
|
if (extlsa->e[0].fwd_addr.s_addr == 0)
|
|
|
|
|
extlsa->e[0].fwd_addr = ospf_get_nssa_ip(area); /* this NSSA area in ifp */
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
2003-05-16 19:31:51 +02:00
|
|
|
|
if (extlsa->e[0].fwd_addr.s_addr == 0)
|
|
|
|
|
{
|
|
|
|
|
if (IS_DEBUG_OSPF_NSSA)
|
2004-12-08 19:12:06 +01:00
|
|
|
|
zlog_debug ("LSA[Type-7]: Could not build FWD-ADDR");
|
2006-07-26 11:37:26 +02:00
|
|
|
|
ospf_lsa_discard (new);
|
2003-05-16 19:31:51 +02:00
|
|
|
|
return;
|
|
|
|
|
}
|
2002-12-13 22:44:27 +01:00
|
|
|
|
}
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
2003-03-25 06:07:42 +01:00
|
|
|
|
/* install also as Type-7 */
|
2003-07-12 23:30:57 +02:00
|
|
|
|
ospf_lsa_install (ospf, NULL, new); /* Remove Old, Lock New = 2 */
|
2003-03-25 06:07:42 +01:00
|
|
|
|
|
|
|
|
|
/* will send each copy, lock=2+n */
|
2003-07-12 23:30:57 +02:00
|
|
|
|
ospf_flood_through_as (ospf, NULL, new); /* all attached NSSA's, no AS/STUBs */
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2005-05-06 23:37:42 +02:00
|
|
|
|
static struct ospf_lsa *
|
2003-07-12 23:30:57 +02:00
|
|
|
|
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 */
|
|
|
|
|
ei.p.family = AF_INET;
|
|
|
|
|
ei.p.prefix = type7->data->id;
|
|
|
|
|
ei.p.prefixlen = ip_masklen (ext->mask);
|
|
|
|
|
ei.type = ZEBRA_ROUTE_OSPF;
|
|
|
|
|
ei.nexthop = ext->header.adv_router;
|
|
|
|
|
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)
|
2004-12-08 19:12:06 +01:00
|
|
|
|
zlog_debug ("ospf_nssa_translate_originate(): Could not originate "
|
2003-07-12 23:30:57 +02:00
|
|
|
|
"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;
|
|
|
|
|
extnew->e[0].fwd_addr.s_addr = ext->e[0].fwd_addr.s_addr;
|
|
|
|
|
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 */
|
|
|
|
|
new = ospf_lsa_lock (new);
|
|
|
|
|
|
|
|
|
|
return new;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* compare type-5 to type-7
|
|
|
|
|
* -1: err, 0: same, 1: different
|
|
|
|
|
*/
|
2005-05-06 23:37:42 +02:00
|
|
|
|
static int
|
2003-07-12 23:30:57 +02:00
|
|
|
|
ospf_lsa_translated_nssa_compare (struct ospf_lsa *t7, struct ospf_lsa *t5)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
struct as_external_lsa *e5 = (struct as_external_lsa *)t5,
|
|
|
|
|
*e7 = (struct as_external_lsa *)t7;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* sanity checks */
|
|
|
|
|
if (! ((t5->data->type == OSPF_AS_EXTERNAL_LSA)
|
|
|
|
|
&& (t7->data->type == OSPF_AS_NSSA_LSA)))
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
|
|
if (t5->data->id.s_addr != t7->data->id.s_addr)
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
|
|
if (t5->data->ls_seqnum != t7->data->ls_seqnum)
|
|
|
|
|
return LSA_REFRESH_FORCE;
|
|
|
|
|
|
|
|
|
|
if (e5->mask.s_addr != e7->mask.s_addr)
|
|
|
|
|
return LSA_REFRESH_FORCE;
|
|
|
|
|
|
|
|
|
|
if (e5->e[0].fwd_addr.s_addr != e7->e[0].fwd_addr.s_addr)
|
|
|
|
|
return LSA_REFRESH_FORCE;
|
|
|
|
|
|
|
|
|
|
if (e5->e[0].route_tag != e7->e[0].route_tag)
|
|
|
|
|
return LSA_REFRESH_FORCE;
|
|
|
|
|
|
|
|
|
|
if (GET_METRIC (e5->e[0].metric) != GET_METRIC (e7->e[0].metric))
|
|
|
|
|
return LSA_REFRESH_FORCE;
|
|
|
|
|
|
|
|
|
|
return LSA_REFRESH_IF_CHANGED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Originate Translated Type-5 for supplied Type-7 NSSA LSA */
|
|
|
|
|
struct ospf_lsa *
|
|
|
|
|
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)
|
2004-12-08 19:12:06 +01:00
|
|
|
|
zlog_debug ("ospf_translated_nssa_originate(): Could not translate "
|
2003-07-12 23:30:57 +02:00
|
|
|
|
"Type-7, Id %s, to Type-5",
|
|
|
|
|
inet_ntoa (type7->data->id));
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
extnew = (struct as_external_lsa *)new;
|
|
|
|
|
|
|
|
|
|
if (IS_DEBUG_OSPF_NSSA)
|
|
|
|
|
{
|
2004-12-08 19:12:06 +01:00
|
|
|
|
zlog_debug ("ospf_translated_nssa_originate(): "
|
2003-07-12 23:30:57 +02:00
|
|
|
|
"translated Type 7, installed:");
|
|
|
|
|
ospf_lsa_header_dump (new->data);
|
2004-12-08 19:12:06 +01:00
|
|
|
|
zlog_debug (" Network mask: %d",ip_masklen (extnew->mask));
|
|
|
|
|
zlog_debug (" Forward addr: %s", inet_ntoa (extnew->e[0].fwd_addr));
|
2003-07-12 23:30:57 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( (new = ospf_lsa_install (ospf, NULL, new)) == NULL)
|
|
|
|
|
{
|
|
|
|
|
if (IS_DEBUG_OSPF_NSSA);
|
2004-12-08 19:12:06 +01:00
|
|
|
|
zlog_debug ("ospf_lsa_translated_nssa_originate(): "
|
2003-07-12 23:30:57 +02:00
|
|
|
|
"Could not install LSA "
|
|
|
|
|
"id %s", inet_ntoa (type7->data->id));
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ospf->lsa_originate_count++;
|
|
|
|
|
ospf_flood_through_as (ospf, NULL, new);
|
|
|
|
|
|
|
|
|
|
return new;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Refresh Translated from NSSA AS-external-LSA. */
|
|
|
|
|
struct ospf_lsa *
|
|
|
|
|
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);
|
2006-05-13 01:15:30 +02:00
|
|
|
|
if (!(type7 || type5))
|
2006-05-13 01:11:14 +02:00
|
|
|
|
return NULL;
|
2003-07-12 23:30:57 +02:00
|
|
|
|
if (type7)
|
|
|
|
|
assert (type7->data);
|
|
|
|
|
if (type5)
|
|
|
|
|
assert (type5->data);
|
|
|
|
|
assert (ospf->anyNSSA);
|
|
|
|
|
|
|
|
|
|
/* get required data according to what has been given */
|
|
|
|
|
if (type7 && type5 == NULL)
|
|
|
|
|
{
|
|
|
|
|
/* find the translated Type-5 for this Type-7 */
|
|
|
|
|
struct as_external_lsa *ext = (struct as_external_lsa *)(type7->data);
|
|
|
|
|
struct prefix_ipv4 p =
|
|
|
|
|
{
|
|
|
|
|
.prefix = type7->data->id,
|
|
|
|
|
.prefixlen = ip_masklen (ext->mask),
|
|
|
|
|
.family = AF_INET,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
type5 = ospf_external_info_find_lsa (ospf, &p);
|
|
|
|
|
}
|
|
|
|
|
else if (type5 && type7 == NULL)
|
|
|
|
|
{
|
|
|
|
|
/* find the type-7 from which supplied type-5 was translated,
|
|
|
|
|
* ie find first type-7 with same LSA Id.
|
|
|
|
|
*/
|
2005-04-07 Paul Jakma <paul.jakma@sun.com>
* (global): Fix up list loops to match changes in lib/linklist,
and some basic auditing of usage.
* configure.ac: define QUAGGA_NO_DEPRECATED_INTERFACES
* HACKING: Add notes about deprecating interfaces and commands.
* lib/linklist.h: Add usage comments.
Rename getdata macro to listgetdata.
Rename nextnode to listnextnode and fix its odd behaviour to be
less dangerous.
Make listgetdata macro assert node is not null, NULL list entries
should be bug condition.
ALL_LIST_ELEMENTS, new macro, forward-referencing macro for use
with for loop, Suggested by Jim Carlson of Sun.
Add ALL_LIST_ELEMENTS_RO for cases which obviously do not need the
"safety" of previous macro.
LISTNODE_ADD and DELETE macros renamed to ATTACH, DETACH, to
distinguish from the similarly named functions, and reflect their
effect better.
Add a QUAGGA_NO_DEPRECATED_INTERFACES define guarded section
with the old defines which were modified above,
for backwards compatibility - guarded to prevent Quagga using it..
* lib/linklist.c: fix up for linklist.h changes.
* ospf6d/ospf6_abr.c: (ospf6_abr_examin_brouter) change to a single
scan of the area list, rather than scanning all areas first for
INTER_ROUTER and then again for INTER_NETWORK. According to
16.2, the scan should be area specific anyway, and further
ospf6d does not seem to implement 16.3 anyway.
2005-04-07 09:30:20 +02:00
|
|
|
|
struct listnode *ln, *lnn;
|
2003-07-12 23:30:57 +02:00
|
|
|
|
struct route_node *rn;
|
|
|
|
|
struct ospf_lsa *lsa;
|
|
|
|
|
struct ospf_area *area;
|
|
|
|
|
|
2005-04-07 Paul Jakma <paul.jakma@sun.com>
* (global): Fix up list loops to match changes in lib/linklist,
and some basic auditing of usage.
* configure.ac: define QUAGGA_NO_DEPRECATED_INTERFACES
* HACKING: Add notes about deprecating interfaces and commands.
* lib/linklist.h: Add usage comments.
Rename getdata macro to listgetdata.
Rename nextnode to listnextnode and fix its odd behaviour to be
less dangerous.
Make listgetdata macro assert node is not null, NULL list entries
should be bug condition.
ALL_LIST_ELEMENTS, new macro, forward-referencing macro for use
with for loop, Suggested by Jim Carlson of Sun.
Add ALL_LIST_ELEMENTS_RO for cases which obviously do not need the
"safety" of previous macro.
LISTNODE_ADD and DELETE macros renamed to ATTACH, DETACH, to
distinguish from the similarly named functions, and reflect their
effect better.
Add a QUAGGA_NO_DEPRECATED_INTERFACES define guarded section
with the old defines which were modified above,
for backwards compatibility - guarded to prevent Quagga using it..
* lib/linklist.c: fix up for linklist.h changes.
* ospf6d/ospf6_abr.c: (ospf6_abr_examin_brouter) change to a single
scan of the area list, rather than scanning all areas first for
INTER_ROUTER and then again for INTER_NETWORK. According to
16.2, the scan should be area specific anyway, and further
ospf6d does not seem to implement 16.3 anyway.
2005-04-07 09:30:20 +02:00
|
|
|
|
for (ALL_LIST_ELEMENTS (ospf->areas, ln, lnn, area))
|
2003-07-12 23:30:57 +02:00
|
|
|
|
{
|
|
|
|
|
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)
|
|
|
|
|
{
|
|
|
|
|
type7 = lsa;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2003-03-25 06:07:42 +01:00
|
|
|
|
}
|
2003-07-12 23:30:57 +02:00
|
|
|
|
|
|
|
|
|
/* do we have type7? */
|
|
|
|
|
if (!type7)
|
|
|
|
|
{
|
|
|
|
|
if (IS_DEBUG_OSPF_NSSA)
|
2004-12-08 19:12:06 +01:00
|
|
|
|
zlog_debug ("ospf_translated_nssa_refresh(): no Type-7 found for "
|
2003-07-12 23:30:57 +02:00
|
|
|
|
"Type-5 LSA Id %s",
|
2006-05-13 01:11:14 +02:00
|
|
|
|
inet_ntoa (type5->data->id));
|
2003-07-12 23:30:57 +02:00
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* do we have valid translated type5? */
|
|
|
|
|
if (type5 == NULL || !CHECK_FLAG (type5->flags, OSPF_LSA_LOCAL_XLT) )
|
|
|
|
|
{
|
|
|
|
|
if (IS_DEBUG_OSPF_NSSA)
|
2004-12-08 19:12:06 +01:00
|
|
|
|
zlog_debug ("ospf_translated_nssa_refresh(): No translated Type-5 "
|
2003-07-12 23:30:57 +02:00
|
|
|
|
"found for Type-7 with Id %s",
|
|
|
|
|
inet_ntoa (type7->data->id));
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* 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)
|
|
|
|
|
{
|
|
|
|
|
if (IS_DEBUG_OSPF_NSSA)
|
2004-12-08 19:12:06 +01:00
|
|
|
|
zlog_debug ("ospf_translated_nssa_refresh(): Could not translate "
|
2003-07-12 23:30:57 +02:00
|
|
|
|
"Type-7 for %s to Type-5",
|
|
|
|
|
inet_ntoa (type7->data->id));
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( !(new = ospf_lsa_install (ospf, NULL, new)) )
|
|
|
|
|
{
|
|
|
|
|
if (IS_DEBUG_OSPF_NSSA)
|
2004-12-08 19:12:06 +01:00
|
|
|
|
zlog_debug ("ospf_translated_nssa_refresh(): Could not install "
|
2003-07-12 23:30:57 +02:00
|
|
|
|
"translated LSA, Id %s",
|
2006-07-04 15:52:29 +02:00
|
|
|
|
inet_ntoa (type7->data->id));
|
2003-07-12 23:30:57 +02:00
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Flood LSA through area. */
|
|
|
|
|
ospf_flood_through_as (ospf, NULL, new);
|
|
|
|
|
|
|
|
|
|
return new;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
is_prefix_default (struct prefix_ipv4 *p)
|
|
|
|
|
{
|
|
|
|
|
struct prefix_ipv4 q;
|
|
|
|
|
|
|
|
|
|
q.family = AF_INET;
|
|
|
|
|
q.prefix.s_addr = 0;
|
|
|
|
|
q.prefixlen = 0;
|
|
|
|
|
|
|
|
|
|
return prefix_same ((struct prefix *) p, (struct prefix *) &q);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Originate an AS-external-LSA, install and flood. */
|
|
|
|
|
struct ospf_lsa *
|
2003-03-25 06:07:42 +01:00
|
|
|
|
ospf_external_lsa_originate (struct ospf *ospf, struct external_info *ei)
|
2002-12-13 21:15:29 +01:00
|
|
|
|
{
|
|
|
|
|
struct ospf_lsa *new;
|
|
|
|
|
|
|
|
|
|
/* Added for NSSA project....
|
|
|
|
|
|
|
|
|
|
External LSAs are originated in ASBRs as usual, but for NSSA systems.
|
|
|
|
|
there is the global Type-5 LSDB and a Type-7 LSDB installed for
|
|
|
|
|
every area. The Type-7's are flooded to every IR and every ABR; We
|
|
|
|
|
install the Type-5 LSDB so that the normal "refresh" code operates
|
|
|
|
|
as usual, and flag them as not used during ASE calculations. The
|
|
|
|
|
Type-7 LSDB is used for calculations. Each Type-7 has a Forwarding
|
|
|
|
|
Address of non-zero.
|
|
|
|
|
|
|
|
|
|
If an ABR is the elected NSSA translator, following SPF and during
|
|
|
|
|
the ABR task it will translate all the scanned Type-7's, with P-bit
|
|
|
|
|
ON and not-self generated, and translate to Type-5's throughout the
|
|
|
|
|
non-NSSA/STUB AS.
|
|
|
|
|
|
|
|
|
|
A difference in operation depends whether this ASBR is an ABR
|
|
|
|
|
or not. If not an ABR, the P-bit is ON, to indicate that any
|
|
|
|
|
elected NSSA-ABR can perform its translation.
|
|
|
|
|
|
|
|
|
|
If an ABR, the P-bit is OFF; No ABR will perform translation and
|
|
|
|
|
this ASBR will flood the Type-5 LSA as usual.
|
|
|
|
|
|
|
|
|
|
For the case where this ASBR is not an ABR, the ASE calculations
|
|
|
|
|
are based on the Type-5 LSDB; The Type-7 LSDB exists just to
|
|
|
|
|
demonstrate to the user that there are LSA's that belong to any
|
|
|
|
|
attached NSSA.
|
|
|
|
|
|
|
|
|
|
Finally, it just so happens that when the ABR is translating every
|
|
|
|
|
Type-7 into Type-5, it installs it into the Type-5 LSDB as an
|
|
|
|
|
approved Type-5 (translated from Type-7); at the end of translation
|
|
|
|
|
if any Translated Type-5's remain unapproved, then they must be
|
|
|
|
|
flushed from the AS.
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/* Check the AS-external-LSA should be originated. */
|
2003-03-25 06:07:42 +01:00
|
|
|
|
if (!ospf_redistribute_check (ospf, ei, NULL))
|
2002-12-13 21:15:29 +01:00
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
/* Create new AS-external-LSA instance. */
|
2003-03-25 06:07:42 +01:00
|
|
|
|
if ((new = ospf_external_lsa_new (ospf, ei, NULL)) == NULL)
|
2002-12-13 21:15:29 +01:00
|
|
|
|
{
|
|
|
|
|
if (IS_DEBUG_OSPF_EVENT)
|
2004-12-08 19:12:06 +01:00
|
|
|
|
zlog_debug ("LSA[Type5:%s]: Could not originate AS-external-LSA",
|
2002-12-13 21:15:29 +01:00
|
|
|
|
inet_ntoa (ei->p.prefix));
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Install newly created LSA into Type-5 LSDB, lock = 1. */
|
2003-03-25 06:07:42 +01:00
|
|
|
|
ospf_lsa_install (ospf, NULL, new);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
|
|
/* Update LSA origination count. */
|
2003-03-25 06:07:42 +01:00
|
|
|
|
ospf->lsa_originate_count++;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
|
|
/* Flooding new LSA. only to AS (non-NSSA/STUB) */
|
2003-03-25 06:07:42 +01:00
|
|
|
|
ospf_flood_through_as (ospf, NULL, new);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
|
|
/* If there is any attached NSSA, do special handling */
|
2003-07-12 23:30:57 +02:00
|
|
|
|
if (ospf->anyNSSA &&
|
|
|
|
|
/* stay away from translated LSAs! */
|
|
|
|
|
!(CHECK_FLAG (new->flags, OSPF_LSA_LOCAL_XLT)))
|
2003-03-25 06:07:42 +01:00
|
|
|
|
ospf_install_flood_nssa (ospf, new, ei); /* Install/Flood Type-7 to all NSSAs */
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
|
|
/* Debug logging. */
|
|
|
|
|
if (IS_DEBUG_OSPF (lsa, LSA_GENERATE))
|
|
|
|
|
{
|
2004-12-08 19:12:06 +01:00
|
|
|
|
zlog_debug ("LSA[Type%d:%s]: Originate AS-external-LSA %p",
|
2002-12-13 21:15:29 +01:00
|
|
|
|
new->data->type, inet_ntoa (new->data->id), new);
|
|
|
|
|
ospf_lsa_header_dump (new->data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return new;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Originate AS-external-LSA from external info with initial flag. */
|
|
|
|
|
int
|
2003-03-25 06:07:42 +01:00
|
|
|
|
ospf_external_lsa_originate_timer (struct thread *thread)
|
2002-12-13 21:15:29 +01:00
|
|
|
|
{
|
2003-03-25 06:07:42 +01:00
|
|
|
|
struct ospf *ospf = THREAD_ARG (thread);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
struct route_node *rn;
|
|
|
|
|
struct external_info *ei;
|
|
|
|
|
struct route_table *rt;
|
2003-03-25 06:07:42 +01:00
|
|
|
|
int type = THREAD_VAL (thread);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
2003-03-25 06:07:42 +01:00
|
|
|
|
ospf->t_external_lsa = NULL;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
|
|
/* Originate As-external-LSA from all type of distribute source. */
|
|
|
|
|
if ((rt = EXTERNAL_INFO (type)))
|
|
|
|
|
for (rn = route_top (rt); rn; rn = route_next (rn))
|
|
|
|
|
if ((ei = rn->info) != NULL)
|
|
|
|
|
if (!is_prefix_default ((struct prefix_ipv4 *)&ei->p))
|
2003-03-25 06:07:42 +01:00
|
|
|
|
if (!ospf_external_lsa_originate (ospf, ei))
|
2002-12-13 21:15:29 +01:00
|
|
|
|
zlog_warn ("LSA: AS-external-LSA was not originated.");
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2005-05-06 23:37:42 +02:00
|
|
|
|
static struct external_info *
|
2003-04-04 04:44:16 +02:00
|
|
|
|
ospf_default_external_info (struct ospf *ospf)
|
2002-12-13 21:15:29 +01:00
|
|
|
|
{
|
|
|
|
|
int type;
|
|
|
|
|
struct route_node *rn;
|
|
|
|
|
struct prefix_ipv4 p;
|
|
|
|
|
|
|
|
|
|
p.family = AF_INET;
|
|
|
|
|
p.prefix.s_addr = 0;
|
|
|
|
|
p.prefixlen = 0;
|
|
|
|
|
|
|
|
|
|
/* First, lookup redistributed default route. */
|
|
|
|
|
for (type = 0; type <= ZEBRA_ROUTE_MAX; type++)
|
|
|
|
|
if (EXTERNAL_INFO (type) && type != ZEBRA_ROUTE_OSPF)
|
|
|
|
|
{
|
|
|
|
|
rn = route_node_lookup (EXTERNAL_INFO (type), (struct prefix *) &p);
|
|
|
|
|
if (rn != NULL)
|
|
|
|
|
{
|
|
|
|
|
route_unlock_node (rn);
|
|
|
|
|
assert (rn->info);
|
2003-03-25 06:07:42 +01:00
|
|
|
|
if (ospf_redistribute_check (ospf, rn->info, NULL))
|
2002-12-13 21:15:29 +01:00
|
|
|
|
return rn->info;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int
|
2003-03-25 06:07:42 +01:00
|
|
|
|
ospf_default_originate_timer (struct thread *thread)
|
2002-12-13 21:15:29 +01:00
|
|
|
|
{
|
|
|
|
|
struct prefix_ipv4 p;
|
|
|
|
|
struct in_addr nexthop;
|
|
|
|
|
struct external_info *ei;
|
2003-04-04 04:44:16 +02:00
|
|
|
|
struct ospf *ospf;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
2006-05-13 00:55:41 +02:00
|
|
|
|
ospf = THREAD_ARG (thread);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
|
|
p.family = AF_INET;
|
|
|
|
|
p.prefix.s_addr = 0;
|
|
|
|
|
p.prefixlen = 0;
|
|
|
|
|
|
2006-05-13 00:55:41 +02:00
|
|
|
|
if (ospf->default_originate == DEFAULT_ORIGINATE_ALWAYS)
|
2002-12-13 21:15:29 +01:00
|
|
|
|
{
|
|
|
|
|
/* If there is no default route via redistribute,
|
|
|
|
|
then originate AS-external-LSA with nexthop 0 (self). */
|
|
|
|
|
nexthop.s_addr = 0;
|
|
|
|
|
ospf_external_info_add (DEFAULT_ROUTE, p, 0, nexthop);
|
|
|
|
|
}
|
|
|
|
|
|
2003-04-04 04:44:16 +02:00
|
|
|
|
if ((ei = ospf_default_external_info (ospf)))
|
2003-03-25 06:07:42 +01:00
|
|
|
|
ospf_external_lsa_originate (ospf, ei);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2003-04-13 23:42:11 +02:00
|
|
|
|
/* Flush any NSSA LSAs for given prefix */
|
|
|
|
|
void
|
|
|
|
|
ospf_nssa_lsa_flush (struct ospf *ospf, struct prefix_ipv4 *p)
|
|
|
|
|
{
|
2005-04-07 Paul Jakma <paul.jakma@sun.com>
* (global): Fix up list loops to match changes in lib/linklist,
and some basic auditing of usage.
* configure.ac: define QUAGGA_NO_DEPRECATED_INTERFACES
* HACKING: Add notes about deprecating interfaces and commands.
* lib/linklist.h: Add usage comments.
Rename getdata macro to listgetdata.
Rename nextnode to listnextnode and fix its odd behaviour to be
less dangerous.
Make listgetdata macro assert node is not null, NULL list entries
should be bug condition.
ALL_LIST_ELEMENTS, new macro, forward-referencing macro for use
with for loop, Suggested by Jim Carlson of Sun.
Add ALL_LIST_ELEMENTS_RO for cases which obviously do not need the
"safety" of previous macro.
LISTNODE_ADD and DELETE macros renamed to ATTACH, DETACH, to
distinguish from the similarly named functions, and reflect their
effect better.
Add a QUAGGA_NO_DEPRECATED_INTERFACES define guarded section
with the old defines which were modified above,
for backwards compatibility - guarded to prevent Quagga using it..
* lib/linklist.c: fix up for linklist.h changes.
* ospf6d/ospf6_abr.c: (ospf6_abr_examin_brouter) change to a single
scan of the area list, rather than scanning all areas first for
INTER_ROUTER and then again for INTER_NETWORK. According to
16.2, the scan should be area specific anyway, and further
ospf6d does not seem to implement 16.3 anyway.
2005-04-07 09:30:20 +02:00
|
|
|
|
struct listnode *node, *nnode;
|
2003-04-13 23:42:11 +02:00
|
|
|
|
struct ospf_lsa *lsa;
|
|
|
|
|
struct ospf_area *area;
|
|
|
|
|
|
2005-04-07 Paul Jakma <paul.jakma@sun.com>
* (global): Fix up list loops to match changes in lib/linklist,
and some basic auditing of usage.
* configure.ac: define QUAGGA_NO_DEPRECATED_INTERFACES
* HACKING: Add notes about deprecating interfaces and commands.
* lib/linklist.h: Add usage comments.
Rename getdata macro to listgetdata.
Rename nextnode to listnextnode and fix its odd behaviour to be
less dangerous.
Make listgetdata macro assert node is not null, NULL list entries
should be bug condition.
ALL_LIST_ELEMENTS, new macro, forward-referencing macro for use
with for loop, Suggested by Jim Carlson of Sun.
Add ALL_LIST_ELEMENTS_RO for cases which obviously do not need the
"safety" of previous macro.
LISTNODE_ADD and DELETE macros renamed to ATTACH, DETACH, to
distinguish from the similarly named functions, and reflect their
effect better.
Add a QUAGGA_NO_DEPRECATED_INTERFACES define guarded section
with the old defines which were modified above,
for backwards compatibility - guarded to prevent Quagga using it..
* lib/linklist.c: fix up for linklist.h changes.
* ospf6d/ospf6_abr.c: (ospf6_abr_examin_brouter) change to a single
scan of the area list, rather than scanning all areas first for
INTER_ROUTER and then again for INTER_NETWORK. According to
16.2, the scan should be area specific anyway, and further
ospf6d does not seem to implement 16.3 anyway.
2005-04-07 09:30:20 +02:00
|
|
|
|
for (ALL_LIST_ELEMENTS (ospf->areas, node, nnode, area))
|
2003-04-13 23:42:11 +02:00
|
|
|
|
{
|
2005-04-07 Paul Jakma <paul.jakma@sun.com>
* (global): Fix up list loops to match changes in lib/linklist,
and some basic auditing of usage.
* configure.ac: define QUAGGA_NO_DEPRECATED_INTERFACES
* HACKING: Add notes about deprecating interfaces and commands.
* lib/linklist.h: Add usage comments.
Rename getdata macro to listgetdata.
Rename nextnode to listnextnode and fix its odd behaviour to be
less dangerous.
Make listgetdata macro assert node is not null, NULL list entries
should be bug condition.
ALL_LIST_ELEMENTS, new macro, forward-referencing macro for use
with for loop, Suggested by Jim Carlson of Sun.
Add ALL_LIST_ELEMENTS_RO for cases which obviously do not need the
"safety" of previous macro.
LISTNODE_ADD and DELETE macros renamed to ATTACH, DETACH, to
distinguish from the similarly named functions, and reflect their
effect better.
Add a QUAGGA_NO_DEPRECATED_INTERFACES define guarded section
with the old defines which were modified above,
for backwards compatibility - guarded to prevent Quagga using it..
* lib/linklist.c: fix up for linklist.h changes.
* ospf6d/ospf6_abr.c: (ospf6_abr_examin_brouter) change to a single
scan of the area list, rather than scanning all areas first for
INTER_ROUTER and then again for INTER_NETWORK. According to
16.2, the scan should be area specific anyway, and further
ospf6d does not seem to implement 16.3 anyway.
2005-04-07 09:30:20 +02:00
|
|
|
|
if (area->external_routing == OSPF_AREA_NSSA)
|
2003-05-16 19:31:51 +02:00
|
|
|
|
{
|
|
|
|
|
if (!(lsa = ospf_lsa_lookup (area, OSPF_AS_NSSA_LSA, p->prefix,
|
|
|
|
|
ospf->router_id)))
|
|
|
|
|
{
|
|
|
|
|
if (IS_DEBUG_OSPF (lsa, LSA_FLOODING))
|
2004-12-08 19:12:06 +01:00
|
|
|
|
zlog_debug ("LSA: There is no such AS-NSSA-LSA %s/%d in LSDB",
|
2003-05-16 19:31:51 +02:00
|
|
|
|
inet_ntoa (p->prefix), p->prefixlen);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
ospf_ls_retransmit_delete_nbr_area (area, lsa);
|
|
|
|
|
if (!IS_LSA_MAXAGE (lsa))
|
|
|
|
|
{
|
|
|
|
|
ospf_refresher_unregister_lsa (ospf, lsa);
|
|
|
|
|
ospf_lsa_flush_area (lsa, area);
|
|
|
|
|
}
|
|
|
|
|
}
|
2003-04-13 23:42:11 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
|
/* Flush an AS-external-LSA from LSDB and routing domain. */
|
|
|
|
|
void
|
2003-03-25 06:07:42 +01:00
|
|
|
|
ospf_external_lsa_flush (struct ospf *ospf,
|
|
|
|
|
u_char type, struct prefix_ipv4 *p,
|
2005-09-19 15:28:05 +02:00
|
|
|
|
unsigned int ifindex /*, struct in_addr nexthop */)
|
2002-12-13 21:15:29 +01:00
|
|
|
|
{
|
|
|
|
|
struct ospf_lsa *lsa;
|
|
|
|
|
|
|
|
|
|
if (IS_DEBUG_OSPF (lsa, LSA_FLOODING))
|
2004-12-08 19:12:06 +01:00
|
|
|
|
zlog_debug ("LSA: Flushing AS-external-LSA %s/%d",
|
2002-12-13 21:15:29 +01:00
|
|
|
|
inet_ntoa (p->prefix), p->prefixlen);
|
|
|
|
|
|
|
|
|
|
/* First lookup LSA from LSDB. */
|
2003-03-25 06:07:42 +01:00
|
|
|
|
if (!(lsa = ospf_external_info_find_lsa (ospf, p)))
|
2002-12-13 21:15:29 +01:00
|
|
|
|
{
|
|
|
|
|
if (IS_DEBUG_OSPF (lsa, LSA_FLOODING))
|
2004-12-08 19:12:06 +01:00
|
|
|
|
zlog_debug ("LSA: There is no such AS-external-LSA %s/%d in LSDB",
|
2002-12-13 21:15:29 +01:00
|
|
|
|
inet_ntoa (p->prefix), p->prefixlen);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2004-06-20 23:00:27 +02:00
|
|
|
|
|
2003-07-12 23:30:57 +02:00
|
|
|
|
/* 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)))
|
2003-05-16 19:31:51 +02:00
|
|
|
|
ospf_nssa_lsa_flush (ospf, p);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
|
|
/* Sweep LSA from Link State Retransmit List. */
|
2003-03-25 06:07:42 +01:00
|
|
|
|
ospf_ls_retransmit_delete_nbr_as (ospf, lsa);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
|
|
/* There must be no self-originated LSA in rtrs_external. */
|
|
|
|
|
#if 0
|
|
|
|
|
/* Remove External route from Zebra. */
|
|
|
|
|
ospf_zebra_delete ((struct prefix_ipv4 *) p, &nexthop);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
if (!IS_LSA_MAXAGE (lsa))
|
|
|
|
|
{
|
|
|
|
|
/* Unregister LSA from Refresh queue. */
|
2003-03-25 06:07:42 +01:00
|
|
|
|
ospf_refresher_unregister_lsa (ospf, lsa);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
|
|
/* Flush AS-external-LSA through AS. */
|
2003-03-25 06:07:42 +01:00
|
|
|
|
ospf_lsa_flush_as (ospf, lsa);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (IS_DEBUG_OSPF (lsa, LSA_FLOODING))
|
2004-12-08 19:12:06 +01:00
|
|
|
|
zlog_debug ("ospf_external_lsa_flush(): stop");
|
2002-12-13 21:15:29 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
2003-03-25 06:07:42 +01:00
|
|
|
|
ospf_external_lsa_refresh_default (struct ospf *ospf)
|
2002-12-13 21:15:29 +01:00
|
|
|
|
{
|
|
|
|
|
struct prefix_ipv4 p;
|
|
|
|
|
struct external_info *ei;
|
|
|
|
|
struct ospf_lsa *lsa;
|
|
|
|
|
|
|
|
|
|
p.family = AF_INET;
|
|
|
|
|
p.prefixlen = 0;
|
|
|
|
|
p.prefix.s_addr = 0;
|
|
|
|
|
|
2003-04-04 04:44:16 +02:00
|
|
|
|
ei = ospf_default_external_info (ospf);
|
2003-03-25 06:07:42 +01:00
|
|
|
|
lsa = ospf_external_info_find_lsa (ospf, &p);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
|
|
if (ei)
|
|
|
|
|
{
|
|
|
|
|
if (lsa)
|
|
|
|
|
{
|
|
|
|
|
if (IS_DEBUG_OSPF_EVENT)
|
2004-12-08 19:12:06 +01:00
|
|
|
|
zlog_debug ("LSA[Type5:0.0.0.0]: Refresh AS-external-LSA %p", lsa);
|
2003-03-25 06:07:42 +01:00
|
|
|
|
ospf_external_lsa_refresh (ospf, lsa, ei, LSA_REFRESH_FORCE);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (IS_DEBUG_OSPF_EVENT)
|
2004-12-08 19:12:06 +01:00
|
|
|
|
zlog_debug ("LSA[Type5:0.0.0.0]: Originate AS-external-LSA");
|
2003-03-25 06:07:42 +01:00
|
|
|
|
ospf_external_lsa_originate (ospf, ei);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (lsa)
|
|
|
|
|
{
|
|
|
|
|
if (IS_DEBUG_OSPF_EVENT)
|
2004-12-08 19:12:06 +01:00
|
|
|
|
zlog_debug ("LSA[Type5:0.0.0.0]: Flush AS-external-LSA");
|
2003-03-25 06:07:42 +01:00
|
|
|
|
ospf_lsa_flush_as (ospf, lsa);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
2003-03-25 06:07:42 +01:00
|
|
|
|
ospf_external_lsa_refresh_type (struct ospf *ospf, u_char type, int force)
|
2002-12-13 21:15:29 +01:00
|
|
|
|
{
|
|
|
|
|
struct route_node *rn;
|
|
|
|
|
struct external_info *ei;
|
|
|
|
|
|
|
|
|
|
if (type != DEFAULT_ROUTE)
|
|
|
|
|
if (EXTERNAL_INFO(type))
|
|
|
|
|
/* Refresh each redistributed AS-external-LSAs. */
|
|
|
|
|
for (rn = route_top (EXTERNAL_INFO (type)); rn; rn = route_next (rn))
|
|
|
|
|
if ((ei = rn->info))
|
|
|
|
|
if (!is_prefix_default (&ei->p))
|
|
|
|
|
{
|
|
|
|
|
struct ospf_lsa *lsa;
|
|
|
|
|
|
2003-03-25 06:07:42 +01:00
|
|
|
|
if ((lsa = ospf_external_info_find_lsa (ospf, &ei->p)))
|
|
|
|
|
ospf_external_lsa_refresh (ospf, lsa, ei, force);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
else
|
2003-03-25 06:07:42 +01:00
|
|
|
|
ospf_external_lsa_originate (ospf, ei);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Refresh AS-external-LSA. */
|
|
|
|
|
void
|
2003-03-25 06:07:42 +01:00
|
|
|
|
ospf_external_lsa_refresh (struct ospf *ospf, struct ospf_lsa *lsa,
|
2002-12-13 21:15:29 +01:00
|
|
|
|
struct external_info *ei, int force)
|
|
|
|
|
{
|
|
|
|
|
struct ospf_lsa *new;
|
|
|
|
|
int changed;
|
|
|
|
|
|
|
|
|
|
/* Check the AS-external-LSA should be originated. */
|
2003-03-25 06:07:42 +01:00
|
|
|
|
if (!ospf_redistribute_check (ospf, ei, &changed))
|
2002-12-13 21:15:29 +01:00
|
|
|
|
{
|
2003-07-12 23:30:57 +02:00
|
|
|
|
if (IS_DEBUG_OSPF (lsa, LSA_GENERATE))
|
2004-12-08 19:12:06 +01:00
|
|
|
|
zlog_debug ("LSA[Type%d:%s]: Could not be refreshed, "
|
2003-07-12 23:30:57 +02:00
|
|
|
|
"redist check fail",
|
|
|
|
|
lsa->data->type, inet_ntoa (lsa->data->id));
|
2003-03-25 06:07:42 +01:00
|
|
|
|
ospf_external_lsa_flush (ospf, ei->type, &ei->p,
|
2005-09-19 15:28:05 +02:00
|
|
|
|
ei->ifindex /*, ei->nexthop */);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!changed && !force)
|
2003-07-12 23:30:57 +02:00
|
|
|
|
{
|
|
|
|
|
if (IS_DEBUG_OSPF (lsa, LSA_GENERATE))
|
2004-12-08 19:12:06 +01:00
|
|
|
|
zlog_debug ("LSA[Type%d:%s]: Not refreshed, not changed/forced",
|
2003-07-12 23:30:57 +02:00
|
|
|
|
lsa->data->type, inet_ntoa (lsa->data->id));
|
|
|
|
|
return;
|
|
|
|
|
}
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
|
|
/* Delete LSA from neighbor retransmit-list. */
|
2003-03-25 06:07:42 +01:00
|
|
|
|
ospf_ls_retransmit_delete_nbr_as (ospf, lsa);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
|
|
/* Unregister AS-external-LSA from refresh-list. */
|
2003-03-25 06:07:42 +01:00
|
|
|
|
ospf_refresher_unregister_lsa (ospf, lsa);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
2003-03-25 06:07:42 +01:00
|
|
|
|
new = ospf_external_lsa_new (ospf, ei, &lsa->data->id);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
|
|
if (new == NULL)
|
|
|
|
|
{
|
|
|
|
|
if (IS_DEBUG_OSPF (lsa, LSA_GENERATE))
|
2004-12-08 19:12:06 +01:00
|
|
|
|
zlog_debug ("LSA[Type%d:%s]: Could not be refreshed", lsa->data->type,
|
2002-12-13 21:15:29 +01:00
|
|
|
|
inet_ntoa (lsa->data->id));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
new->data->ls_seqnum = lsa_seqnum_increment (lsa);
|
|
|
|
|
|
2003-03-25 06:07:42 +01:00
|
|
|
|
ospf_lsa_install (ospf, NULL, new); /* As type-5. */
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
|
|
/* Flood LSA through AS. */
|
2003-03-25 06:07:42 +01:00
|
|
|
|
ospf_flood_through_as (ospf, NULL, new);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
|
|
/* If any attached NSSA, install as Type-7, flood to all NSSA Areas */
|
2003-07-12 23:30:57 +02:00
|
|
|
|
if (ospf->anyNSSA && !(CHECK_FLAG (new->flags, OSPF_LSA_LOCAL_XLT)))
|
2003-03-25 06:07:42 +01:00
|
|
|
|
ospf_install_flood_nssa (ospf, new, ei); /* Install/Flood per new rules */
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
2003-07-12 23:30:57 +02:00
|
|
|
|
/* 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) )
|
|
|
|
|
ospf_refresher_register_lsa (ospf, new);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
|
|
/* Debug logging. */
|
|
|
|
|
if (IS_DEBUG_OSPF (lsa, LSA_GENERATE))
|
|
|
|
|
{
|
2004-12-08 19:12:06 +01:00
|
|
|
|
zlog_debug ("LSA[Type%d:%s]: AS-external-LSA refresh",
|
2003-07-12 23:30:57 +02:00
|
|
|
|
new->data->type, inet_ntoa (new->data->id));
|
2002-12-13 21:15:29 +01:00
|
|
|
|
ospf_lsa_header_dump (new->data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* LSA installation functions. */
|
|
|
|
|
|
|
|
|
|
/* Install router-LSA to an area. */
|
2005-05-06 23:37:42 +02:00
|
|
|
|
static struct ospf_lsa *
|
2003-03-25 06:07:42 +01:00
|
|
|
|
ospf_router_lsa_install (struct ospf *ospf,
|
|
|
|
|
struct ospf_lsa *new, int rt_recalc)
|
2002-12-13 21:15:29 +01:00
|
|
|
|
{
|
|
|
|
|
struct ospf_area *area = new->area;
|
|
|
|
|
|
|
|
|
|
/* 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).
|
|
|
|
|
*/
|
|
|
|
|
if (rt_recalc)
|
2003-03-25 06:07:42 +01:00
|
|
|
|
ospf_spf_calculate_schedule (ospf);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
|
|
if (IS_LSA_SELF (new))
|
|
|
|
|
{
|
|
|
|
|
/* Set router-LSA refresh timer. */
|
|
|
|
|
OSPF_TIMER_OFF (area->t_router_lsa_self);
|
|
|
|
|
OSPF_AREA_TIMER_ON (area->t_router_lsa_self,
|
2003-07-12 23:30:57 +02:00
|
|
|
|
ospf_router_lsa_timer, OSPF_LS_REFRESH_TIME);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
|
|
/* Set self-originated router-LSA. */
|
2006-07-26 11:37:26 +02:00
|
|
|
|
ospf_lsa_unlock (&area->router_lsa_self);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
area->router_lsa_self = ospf_lsa_lock (new);
|
|
|
|
|
|
|
|
|
|
if (IS_DEBUG_OSPF (lsa, LSA_INSTALL))
|
2004-12-08 19:12:06 +01:00
|
|
|
|
zlog_debug("LSA[Type%d]: ID %s seq 0x%x is self-originated",
|
2004-05-31 16:16:54 +02:00
|
|
|
|
new->data->type, inet_ntoa (new->data->id),
|
|
|
|
|
ntohl(new->data->ls_seqnum));
|
2002-12-13 21:15:29 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return new;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#define OSPF_INTERFACE_TIMER_ON(T,F,V) \
|
|
|
|
|
if (!(T)) \
|
|
|
|
|
(T) = thread_add_timer (master, (F), oi, (V))
|
|
|
|
|
|
|
|
|
|
/* Install network-LSA to an area. */
|
2005-05-06 23:37:42 +02:00
|
|
|
|
static struct ospf_lsa *
|
2003-03-25 06:07:42 +01:00
|
|
|
|
ospf_network_lsa_install (struct ospf *ospf,
|
|
|
|
|
struct ospf_interface *oi,
|
2002-12-13 21:15:29 +01:00
|
|
|
|
struct ospf_lsa *new,
|
|
|
|
|
int rt_recalc)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
/* 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).
|
|
|
|
|
*/
|
|
|
|
|
if (rt_recalc)
|
2003-03-25 06:07:42 +01:00
|
|
|
|
ospf_spf_calculate_schedule (ospf);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
|
|
/* We supposed that when LSA is originated by us, we pass the int
|
|
|
|
|
for which it was originated. If LSA was received by flooding,
|
|
|
|
|
the RECEIVED flag is set, so we do not link the LSA to the int. */
|
|
|
|
|
if (IS_LSA_SELF (new) && !CHECK_FLAG (new->flags, OSPF_LSA_RECEIVED))
|
|
|
|
|
{
|
|
|
|
|
/* Set LSRefresh timer. */
|
|
|
|
|
OSPF_TIMER_OFF (oi->t_network_lsa_self);
|
|
|
|
|
|
|
|
|
|
OSPF_INTERFACE_TIMER_ON (oi->t_network_lsa_self,
|
|
|
|
|
ospf_network_lsa_refresh_timer,
|
|
|
|
|
OSPF_LS_REFRESH_TIME);
|
|
|
|
|
|
2006-07-26 11:37:26 +02:00
|
|
|
|
ospf_lsa_unlock (&oi->network_lsa_self);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
oi->network_lsa_self = ospf_lsa_lock (new);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return new;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Install summary-LSA to an area. */
|
2005-05-06 23:37:42 +02:00
|
|
|
|
static struct ospf_lsa *
|
2003-03-25 06:07:42 +01:00
|
|
|
|
ospf_summary_lsa_install (struct ospf *ospf, struct ospf_lsa *new,
|
|
|
|
|
int rt_recalc)
|
2002-12-13 21:15:29 +01:00
|
|
|
|
{
|
|
|
|
|
if (rt_recalc && !IS_LSA_SELF (new))
|
|
|
|
|
{
|
|
|
|
|
/* RFC 2328 Section 13.2 Summary-LSAs
|
|
|
|
|
The best route to the destination described by the summary-
|
|
|
|
|
LSA must be recalculated (see Section 16.5). If this
|
|
|
|
|
destination is an AS boundary router, it may also be
|
|
|
|
|
necessary to re-examine all the AS-external-LSAs.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
|
/* This doesn't exist yet... */
|
|
|
|
|
ospf_summary_incremental_update(new); */
|
|
|
|
|
#else /* #if 0 */
|
2003-03-25 06:07:42 +01:00
|
|
|
|
ospf_spf_calculate_schedule (ospf);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
#endif /* #if 0 */
|
|
|
|
|
|
|
|
|
|
if (IS_DEBUG_OSPF (lsa, LSA_INSTALL))
|
2004-12-08 19:12:06 +01:00
|
|
|
|
zlog_debug ("ospf_summary_lsa_install(): SPF scheduled");
|
2002-12-13 21:15:29 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (IS_LSA_SELF (new))
|
2003-03-25 06:07:42 +01:00
|
|
|
|
ospf_refresher_register_lsa (ospf, new);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
|
|
return new;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Install ASBR-summary-LSA to an area. */
|
2005-05-06 23:37:42 +02:00
|
|
|
|
static struct ospf_lsa *
|
2003-03-25 06:07:42 +01:00
|
|
|
|
ospf_summary_asbr_lsa_install (struct ospf *ospf, struct ospf_lsa *new,
|
|
|
|
|
int rt_recalc)
|
2002-12-13 21:15:29 +01:00
|
|
|
|
{
|
|
|
|
|
if (rt_recalc && !IS_LSA_SELF (new))
|
|
|
|
|
{
|
|
|
|
|
/* RFC 2328 Section 13.2 Summary-LSAs
|
|
|
|
|
The best route to the destination described by the summary-
|
|
|
|
|
LSA must be recalculated (see Section 16.5). If this
|
|
|
|
|
destination is an AS boundary router, it may also be
|
|
|
|
|
necessary to re-examine all the AS-external-LSAs.
|
|
|
|
|
*/
|
|
|
|
|
#if 0
|
|
|
|
|
/* These don't exist yet... */
|
|
|
|
|
ospf_summary_incremental_update(new);
|
|
|
|
|
/* Isn't this done by the above call?
|
|
|
|
|
- RFC 2328 Section 16.5 implies it should be */
|
|
|
|
|
/* ospf_ase_calculate_schedule(); */
|
|
|
|
|
#else /* #if 0 */
|
2003-03-25 06:07:42 +01:00
|
|
|
|
ospf_spf_calculate_schedule (ospf);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
#endif /* #if 0 */
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* register LSA to refresh-list. */
|
|
|
|
|
if (IS_LSA_SELF (new))
|
2003-03-25 06:07:42 +01:00
|
|
|
|
ospf_refresher_register_lsa (ospf, new);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
|
|
return new;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Install AS-external-LSA. */
|
2005-05-06 23:37:42 +02:00
|
|
|
|
static struct ospf_lsa *
|
2003-03-25 06:07:42 +01:00
|
|
|
|
ospf_external_lsa_install (struct ospf *ospf, struct ospf_lsa *new,
|
|
|
|
|
int rt_recalc)
|
2002-12-13 21:15:29 +01:00
|
|
|
|
{
|
2003-03-25 06:07:42 +01:00
|
|
|
|
ospf_ase_register_external_lsa (new, ospf);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
/* If LSA is not self-originated, calculate an external route. */
|
|
|
|
|
if (rt_recalc)
|
|
|
|
|
{
|
|
|
|
|
/* RFC 2328 Section 13.2 AS-external-LSAs
|
|
|
|
|
The best route to the destination described by the AS-
|
|
|
|
|
external-LSA must be recalculated (see Section 16.6).
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
if (!IS_LSA_SELF (new))
|
2003-07-12 23:30:57 +02:00
|
|
|
|
ospf_ase_incremental_update (ospf, new);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
}
|
|
|
|
|
|
2003-07-12 23:30:57 +02:00
|
|
|
|
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
|
|
|
|
|
*/
|
|
|
|
|
if (IS_LSA_SELF (new))
|
|
|
|
|
return new;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* 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);
|
|
|
|
|
}
|
|
|
|
|
}
|
2003-05-16 19:31:51 +02:00
|
|
|
|
|
2003-07-12 23:30:57 +02:00
|
|
|
|
/* Register self-originated LSA to refresh queue.
|
2003-07-13 03:36:06 +02:00
|
|
|
|
* Leave Translated LSAs alone if NSSA is enabled
|
2003-07-12 23:30:57 +02:00
|
|
|
|
*/
|
2004-06-20 23:00:27 +02:00
|
|
|
|
if (IS_LSA_SELF (new) && !CHECK_FLAG (new->flags, OSPF_LSA_LOCAL_XLT ) )
|
2003-03-25 06:07:42 +01:00
|
|
|
|
ospf_refresher_register_lsa (ospf, new);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
|
|
return new;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
2003-03-25 06:07:42 +01:00
|
|
|
|
ospf_discard_from_db (struct ospf *ospf,
|
|
|
|
|
struct ospf_lsdb *lsdb, struct ospf_lsa *lsa)
|
2002-12-13 21:15:29 +01:00
|
|
|
|
{
|
|
|
|
|
struct ospf_lsa *old;
|
|
|
|
|
|
2006-06-15 14:04:57 +02:00
|
|
|
|
if (!lsdb)
|
|
|
|
|
{
|
|
|
|
|
zlog_warn ("%s: Called with NULL lsdb!", __func__);
|
|
|
|
|
if (!lsa)
|
|
|
|
|
zlog_warn ("%s: and NULL LSA!", __func__);
|
|
|
|
|
else
|
|
|
|
|
zlog_warn ("LSA[Type%d:%s]: not associated with LSDB!",
|
|
|
|
|
lsa->data->type, inet_ntoa (lsa->data->id));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
|
old = ospf_lsdb_lookup (lsdb, lsa);
|
|
|
|
|
|
|
|
|
|
if (!old)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (old->refresh_list >= 0)
|
2003-03-25 06:07:42 +01:00
|
|
|
|
ospf_refresher_unregister_lsa (ospf, old);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
|
|
switch (old->data->type)
|
|
|
|
|
{
|
|
|
|
|
case OSPF_AS_EXTERNAL_LSA:
|
2005-05-11 20:09:59 +02:00
|
|
|
|
ospf_ase_unregister_external_lsa (old, ospf);
|
|
|
|
|
ospf_ls_retransmit_delete_nbr_as (ospf, old);
|
|
|
|
|
break;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
#ifdef HAVE_OPAQUE_LSA
|
|
|
|
|
case OSPF_OPAQUE_AS_LSA:
|
2003-03-25 06:07:42 +01:00
|
|
|
|
ospf_ls_retransmit_delete_nbr_as (ospf, old);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
break;
|
2005-05-11 20:09:59 +02:00
|
|
|
|
#endif /* HAVE_OPAQUE_LSA */
|
2003-05-16 19:31:51 +02:00
|
|
|
|
case OSPF_AS_NSSA_LSA:
|
|
|
|
|
ospf_ls_retransmit_delete_nbr_area (old->area, old);
|
|
|
|
|
ospf_ase_unregister_external_lsa (old, ospf);
|
2004-06-20 23:00:27 +02:00
|
|
|
|
break;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
default:
|
2003-03-25 06:07:42 +01:00
|
|
|
|
ospf_ls_retransmit_delete_nbr_area (old->area, old);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2003-03-25 06:07:42 +01:00
|
|
|
|
ospf_lsa_maxage_delete (ospf, old);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
ospf_lsa_discard (old);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct ospf_lsa *
|
2003-03-25 06:07:42 +01:00
|
|
|
|
ospf_lsa_install (struct ospf *ospf, struct ospf_interface *oi,
|
|
|
|
|
struct ospf_lsa *lsa)
|
2002-12-13 21:15:29 +01:00
|
|
|
|
{
|
|
|
|
|
struct ospf_lsa *new = NULL;
|
|
|
|
|
struct ospf_lsa *old = NULL;
|
|
|
|
|
struct ospf_lsdb *lsdb = NULL;
|
|
|
|
|
int rt_recalc;
|
|
|
|
|
|
|
|
|
|
/* Set LSDB. */
|
|
|
|
|
switch (lsa->data->type)
|
|
|
|
|
{
|
2002-12-13 22:44:27 +01:00
|
|
|
|
/* kevinm */
|
|
|
|
|
case OSPF_AS_NSSA_LSA:
|
|
|
|
|
if (lsa->area)
|
|
|
|
|
lsdb = lsa->area->lsdb;
|
|
|
|
|
else
|
2003-03-25 06:07:42 +01:00
|
|
|
|
lsdb = ospf->lsdb;
|
2002-12-13 22:44:27 +01:00
|
|
|
|
break;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
case OSPF_AS_EXTERNAL_LSA:
|
|
|
|
|
#ifdef HAVE_OPAQUE_LSA
|
|
|
|
|
case OSPF_OPAQUE_AS_LSA:
|
|
|
|
|
#endif /* HAVE_OPAQUE_LSA */
|
2003-03-25 06:07:42 +01:00
|
|
|
|
lsdb = ospf->lsdb;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
lsdb = lsa->area->lsdb;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
assert (lsdb);
|
|
|
|
|
|
|
|
|
|
/* RFC 2328 13.2. Installing LSAs in the database
|
|
|
|
|
|
|
|
|
|
Installing a new LSA in the database, either as the result of
|
|
|
|
|
flooding or a newly self-originated LSA, may cause the OSPF
|
|
|
|
|
routing table structure to be recalculated. The contents of the
|
|
|
|
|
new LSA should be compared to the old instance, if present. If
|
|
|
|
|
there is no difference, there is no need to recalculate the
|
|
|
|
|
routing table. When comparing an LSA to its previous instance,
|
|
|
|
|
the following are all considered to be differences in contents:
|
|
|
|
|
|
|
|
|
|
o The LSA's Options field has changed.
|
|
|
|
|
|
|
|
|
|
o One of the LSA instances has LS age set to MaxAge, and
|
|
|
|
|
the other does not.
|
|
|
|
|
|
|
|
|
|
o The length field in the LSA header has changed.
|
|
|
|
|
|
|
|
|
|
o The body of the LSA (i.e., anything outside the 20-byte
|
|
|
|
|
LSA header) has changed. Note that this excludes changes
|
|
|
|
|
in LS Sequence Number and LS Checksum.
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
/* Look up old LSA and determine if any SPF calculation or incremental
|
|
|
|
|
update is needed */
|
|
|
|
|
old = ospf_lsdb_lookup (lsdb, lsa);
|
|
|
|
|
|
|
|
|
|
/* Do comparision and record if recalc needed. */
|
|
|
|
|
rt_recalc = 0;
|
|
|
|
|
if ( old == NULL || ospf_lsa_different(old, lsa))
|
|
|
|
|
rt_recalc = 1;
|
|
|
|
|
|
2003-10-13 11:06:46 +02:00
|
|
|
|
/*
|
|
|
|
|
Sequence number check (Section 14.1 of rfc 2328)
|
|
|
|
|
"Premature aging is used when it is time for a self-originated
|
|
|
|
|
LSA's sequence number field to wrap. At this point, the current
|
|
|
|
|
LSA instance (having LS sequence number MaxSequenceNumber) must
|
|
|
|
|
be prematurely aged and flushed from the routing domain before a
|
|
|
|
|
new instance with sequence number equal to InitialSequenceNumber
|
|
|
|
|
can be originated. "
|
|
|
|
|
*/
|
|
|
|
|
|
2006-03-30 16:16:11 +02:00
|
|
|
|
if (ntohl(lsa->data->ls_seqnum) - 1 == OSPF_MAX_SEQUENCE_NUMBER)
|
2003-10-13 11:06:46 +02:00
|
|
|
|
{
|
|
|
|
|
if (ospf_lsa_is_self_originated(ospf, lsa))
|
|
|
|
|
{
|
2004-05-31 16:16:54 +02:00
|
|
|
|
lsa->data->ls_seqnum = htonl(OSPF_MAX_SEQUENCE_NUMBER);
|
|
|
|
|
|
|
|
|
|
if (!IS_LSA_MAXAGE(lsa))
|
2003-10-13 11:06:46 +02:00
|
|
|
|
lsa->flags |= OSPF_LSA_PREMATURE_AGE;
|
|
|
|
|
lsa->data->ls_age = htons (OSPF_LSA_MAXAGE);
|
|
|
|
|
|
|
|
|
|
if (IS_DEBUG_OSPF (lsa, LSA_REFRESH))
|
|
|
|
|
{
|
2004-12-08 19:12:06 +01:00
|
|
|
|
zlog_debug ("ospf_lsa_install() Premature Aging "
|
2003-10-13 11:06:46 +02:00
|
|
|
|
"lsa 0x%lx", (u_long)lsa);
|
|
|
|
|
ospf_lsa_header_dump (lsa->data);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (IS_DEBUG_OSPF (lsa, LSA_GENERATE))
|
|
|
|
|
{
|
2004-12-08 19:12:06 +01:00
|
|
|
|
zlog_debug ("ospf_lsa_install() got an lsa with seq 0x80000000 "
|
2003-10-13 11:06:46 +02:00
|
|
|
|
"that was not self originated. Ignoring\n");
|
|
|
|
|
ospf_lsa_header_dump (lsa->data);
|
|
|
|
|
}
|
|
|
|
|
return old;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
|
/* discard old LSA from LSDB */
|
|
|
|
|
if (old != NULL)
|
2003-03-25 06:07:42 +01:00
|
|
|
|
ospf_discard_from_db (ospf, lsdb, lsa);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
|
|
/* Calculate Checksum if self-originated?. */
|
|
|
|
|
if (IS_LSA_SELF (lsa))
|
|
|
|
|
ospf_lsa_checksum (lsa->data);
|
|
|
|
|
|
2004-12-22 17:16:02 +01:00
|
|
|
|
/* Insert LSA to LSDB. */
|
|
|
|
|
ospf_lsdb_add (lsdb, lsa);
|
|
|
|
|
lsa->lsdb = lsdb;
|
|
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
|
/* Do LSA specific installation process. */
|
|
|
|
|
switch (lsa->data->type)
|
|
|
|
|
{
|
|
|
|
|
case OSPF_ROUTER_LSA:
|
2003-03-25 06:07:42 +01:00
|
|
|
|
new = ospf_router_lsa_install (ospf, lsa, rt_recalc);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
break;
|
|
|
|
|
case OSPF_NETWORK_LSA:
|
|
|
|
|
assert (oi);
|
2003-03-25 06:07:42 +01:00
|
|
|
|
new = ospf_network_lsa_install (ospf, oi, lsa, rt_recalc);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
break;
|
|
|
|
|
case OSPF_SUMMARY_LSA:
|
2003-03-25 06:07:42 +01:00
|
|
|
|
new = ospf_summary_lsa_install (ospf, lsa, rt_recalc);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
break;
|
|
|
|
|
case OSPF_ASBR_SUMMARY_LSA:
|
2003-03-25 06:07:42 +01:00
|
|
|
|
new = ospf_summary_asbr_lsa_install (ospf, lsa, rt_recalc);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
break;
|
|
|
|
|
case OSPF_AS_EXTERNAL_LSA:
|
2003-03-25 06:07:42 +01:00
|
|
|
|
new = ospf_external_lsa_install (ospf, lsa, rt_recalc);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
break;
|
|
|
|
|
#ifdef HAVE_OPAQUE_LSA
|
|
|
|
|
case OSPF_OPAQUE_LINK_LSA:
|
2003-01-18 01:12:02 +01:00
|
|
|
|
if (IS_LSA_SELF (lsa))
|
2003-03-25 06:07:42 +01:00
|
|
|
|
lsa->oi = oi; /* Specify outgoing ospf-interface for this LSA. */
|
2003-01-18 01:12:02 +01:00
|
|
|
|
else
|
2003-03-25 06:07:42 +01:00
|
|
|
|
; /* Incoming "oi" for this LSA has set at LSUpd reception. */
|
2003-01-18 01:12:02 +01:00
|
|
|
|
/* Fallthrough */
|
2002-12-13 21:15:29 +01:00
|
|
|
|
case OSPF_OPAQUE_AREA_LSA:
|
|
|
|
|
case OSPF_OPAQUE_AS_LSA:
|
|
|
|
|
new = ospf_opaque_lsa_install (lsa, rt_recalc);
|
|
|
|
|
break;
|
|
|
|
|
#endif /* HAVE_OPAQUE_LSA */
|
2003-07-12 23:30:57 +02:00
|
|
|
|
case OSPF_AS_NSSA_LSA:
|
2003-03-25 06:07:42 +01:00
|
|
|
|
new = ospf_external_lsa_install (ospf, lsa, rt_recalc);
|
2003-07-12 23:30:57 +02:00
|
|
|
|
default: /* type-6,8,9....nothing special */
|
2002-12-13 21:15:29 +01:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (new == NULL)
|
|
|
|
|
return new; /* Installation failed, cannot proceed further -- endo. */
|
|
|
|
|
|
|
|
|
|
/* Debug logs. */
|
|
|
|
|
if (IS_DEBUG_OSPF (lsa, LSA_INSTALL))
|
|
|
|
|
{
|
|
|
|
|
char area_str[INET_ADDRSTRLEN];
|
|
|
|
|
|
|
|
|
|
switch (lsa->data->type)
|
|
|
|
|
{
|
|
|
|
|
case OSPF_AS_EXTERNAL_LSA:
|
|
|
|
|
#ifdef HAVE_OPAQUE_LSA
|
|
|
|
|
case OSPF_OPAQUE_AS_LSA:
|
|
|
|
|
#endif /* HAVE_OPAQUE_LSA */
|
2004-06-20 23:00:27 +02:00
|
|
|
|
case OSPF_AS_NSSA_LSA:
|
2004-12-08 19:12:06 +01:00
|
|
|
|
zlog_debug ("LSA[%s]: Install %s",
|
2002-12-13 21:15:29 +01:00
|
|
|
|
dump_lsa_key (new),
|
|
|
|
|
LOOKUP (ospf_lsa_type_msg, new->data->type));
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
strcpy (area_str, inet_ntoa (new->area->area_id));
|
2004-12-08 19:12:06 +01:00
|
|
|
|
zlog_debug ("LSA[%s]: Install %s to Area %s",
|
2002-12-13 21:15:29 +01:00
|
|
|
|
dump_lsa_key (new),
|
|
|
|
|
LOOKUP (ospf_lsa_type_msg, new->data->type), area_str);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2003-10-13 11:06:46 +02:00
|
|
|
|
/*
|
|
|
|
|
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.
|
|
|
|
|
*/
|
|
|
|
|
if ((lsa->flags & OSPF_LSA_PREMATURE_AGE) ||
|
|
|
|
|
(IS_LSA_MAXAGE (new) && !IS_LSA_SELF (new)))
|
2002-12-13 21:15:29 +01:00
|
|
|
|
{
|
2003-10-13 11:06:46 +02:00
|
|
|
|
if (IS_DEBUG_OSPF (lsa, LSA_INSTALL))
|
2004-12-08 19:12:06 +01:00
|
|
|
|
zlog_debug ("LSA[Type%d:%s]: Install LSA 0x%p, MaxAge",
|
2004-05-31 16:16:54 +02:00
|
|
|
|
new->data->type,
|
|
|
|
|
inet_ntoa (new->data->id),
|
|
|
|
|
lsa);
|
2003-03-25 06:07:42 +01:00
|
|
|
|
ospf_lsa_maxage (ospf, lsa);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return new;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2005-05-06 23:37:42 +02:00
|
|
|
|
static int
|
2003-03-25 06:07:42 +01:00
|
|
|
|
ospf_check_nbr_status (struct ospf *ospf)
|
2002-12-13 21:15:29 +01:00
|
|
|
|
{
|
2005-04-07 Paul Jakma <paul.jakma@sun.com>
* (global): Fix up list loops to match changes in lib/linklist,
and some basic auditing of usage.
* configure.ac: define QUAGGA_NO_DEPRECATED_INTERFACES
* HACKING: Add notes about deprecating interfaces and commands.
* lib/linklist.h: Add usage comments.
Rename getdata macro to listgetdata.
Rename nextnode to listnextnode and fix its odd behaviour to be
less dangerous.
Make listgetdata macro assert node is not null, NULL list entries
should be bug condition.
ALL_LIST_ELEMENTS, new macro, forward-referencing macro for use
with for loop, Suggested by Jim Carlson of Sun.
Add ALL_LIST_ELEMENTS_RO for cases which obviously do not need the
"safety" of previous macro.
LISTNODE_ADD and DELETE macros renamed to ATTACH, DETACH, to
distinguish from the similarly named functions, and reflect their
effect better.
Add a QUAGGA_NO_DEPRECATED_INTERFACES define guarded section
with the old defines which were modified above,
for backwards compatibility - guarded to prevent Quagga using it..
* lib/linklist.c: fix up for linklist.h changes.
* ospf6d/ospf6_abr.c: (ospf6_abr_examin_brouter) change to a single
scan of the area list, rather than scanning all areas first for
INTER_ROUTER and then again for INTER_NETWORK. According to
16.2, the scan should be area specific anyway, and further
ospf6d does not seem to implement 16.3 anyway.
2005-04-07 09:30:20 +02:00
|
|
|
|
struct listnode *node, *nnode;
|
|
|
|
|
struct ospf_interface *oi;
|
|
|
|
|
|
|
|
|
|
for (ALL_LIST_ELEMENTS (ospf->oiflist, node, nnode, oi))
|
2002-12-13 21:15:29 +01:00
|
|
|
|
{
|
|
|
|
|
struct route_node *rn;
|
|
|
|
|
struct ospf_neighbor *nbr;
|
|
|
|
|
|
|
|
|
|
if (ospf_if_is_enable (oi))
|
|
|
|
|
for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
|
|
|
|
|
if ((nbr = rn->info) != NULL)
|
|
|
|
|
if (nbr->state == NSM_Exchange || nbr->state == NSM_Loading)
|
|
|
|
|
{
|
|
|
|
|
route_unlock_node (rn);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef ORIGINAL_CODING
|
|
|
|
|
/* This function flood the maxaged LSA to DR. */
|
|
|
|
|
void
|
|
|
|
|
ospf_maxage_flood (struct ospf_lsa *lsa)
|
|
|
|
|
{
|
|
|
|
|
switch (lsa->data->type)
|
|
|
|
|
{
|
|
|
|
|
case OSPF_ROUTER_LSA:
|
|
|
|
|
case OSPF_NETWORK_LSA:
|
|
|
|
|
case OSPF_SUMMARY_LSA:
|
|
|
|
|
case OSPF_ASBR_SUMMARY_LSA:
|
|
|
|
|
case OSPF_AS_NSSA_LSA:
|
|
|
|
|
#ifdef HAVE_OPAQUE_LSA
|
|
|
|
|
case OSPF_OPAQUE_LINK_LSA:
|
|
|
|
|
case OSPF_OPAQUE_AREA_LSA:
|
|
|
|
|
#endif /* HAVE_OPAQUE_LSA */
|
|
|
|
|
ospf_flood_through_area (lsa->area, NULL, lsa);
|
|
|
|
|
break;
|
|
|
|
|
case OSPF_AS_EXTERNAL_LSA:
|
|
|
|
|
#ifdef HAVE_OPAQUE_LSA
|
|
|
|
|
case OSPF_OPAQUE_AS_LSA:
|
|
|
|
|
#endif /* HAVE_OPAQUE_LSA */
|
|
|
|
|
ospf_flood_through_as (NULL, lsa);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif /* ORIGINAL_CODING */
|
|
|
|
|
|
2005-05-06 23:37:42 +02:00
|
|
|
|
static int
|
2002-12-13 21:15:29 +01:00
|
|
|
|
ospf_maxage_lsa_remover (struct thread *thread)
|
|
|
|
|
{
|
2003-03-25 06:07:42 +01:00
|
|
|
|
struct ospf *ospf = THREAD_ARG (thread);
|
2005-04-07 Paul Jakma <paul.jakma@sun.com>
* (global): Fix up list loops to match changes in lib/linklist,
and some basic auditing of usage.
* configure.ac: define QUAGGA_NO_DEPRECATED_INTERFACES
* HACKING: Add notes about deprecating interfaces and commands.
* lib/linklist.h: Add usage comments.
Rename getdata macro to listgetdata.
Rename nextnode to listnextnode and fix its odd behaviour to be
less dangerous.
Make listgetdata macro assert node is not null, NULL list entries
should be bug condition.
ALL_LIST_ELEMENTS, new macro, forward-referencing macro for use
with for loop, Suggested by Jim Carlson of Sun.
Add ALL_LIST_ELEMENTS_RO for cases which obviously do not need the
"safety" of previous macro.
LISTNODE_ADD and DELETE macros renamed to ATTACH, DETACH, to
distinguish from the similarly named functions, and reflect their
effect better.
Add a QUAGGA_NO_DEPRECATED_INTERFACES define guarded section
with the old defines which were modified above,
for backwards compatibility - guarded to prevent Quagga using it..
* lib/linklist.c: fix up for linklist.h changes.
* ospf6d/ospf6_abr.c: (ospf6_abr_examin_brouter) change to a single
scan of the area list, rather than scanning all areas first for
INTER_ROUTER and then again for INTER_NETWORK. According to
16.2, the scan should be area specific anyway, and further
ospf6d does not seem to implement 16.3 anyway.
2005-04-07 09:30:20 +02:00
|
|
|
|
struct ospf_lsa *lsa;
|
|
|
|
|
struct listnode *node, *nnode;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
int reschedule = 0;
|
|
|
|
|
|
2003-03-25 06:07:42 +01:00
|
|
|
|
ospf->t_maxage = NULL;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
|
|
if (IS_DEBUG_OSPF (lsa, LSA_FLOODING))
|
2004-12-08 19:12:06 +01:00
|
|
|
|
zlog_debug ("LSA[MaxAge]: remover Start");
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
2003-03-25 06:07:42 +01:00
|
|
|
|
reschedule = !ospf_check_nbr_status (ospf);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
|
|
if (!reschedule)
|
2005-04-07 Paul Jakma <paul.jakma@sun.com>
* (global): Fix up list loops to match changes in lib/linklist,
and some basic auditing of usage.
* configure.ac: define QUAGGA_NO_DEPRECATED_INTERFACES
* HACKING: Add notes about deprecating interfaces and commands.
* lib/linklist.h: Add usage comments.
Rename getdata macro to listgetdata.
Rename nextnode to listnextnode and fix its odd behaviour to be
less dangerous.
Make listgetdata macro assert node is not null, NULL list entries
should be bug condition.
ALL_LIST_ELEMENTS, new macro, forward-referencing macro for use
with for loop, Suggested by Jim Carlson of Sun.
Add ALL_LIST_ELEMENTS_RO for cases which obviously do not need the
"safety" of previous macro.
LISTNODE_ADD and DELETE macros renamed to ATTACH, DETACH, to
distinguish from the similarly named functions, and reflect their
effect better.
Add a QUAGGA_NO_DEPRECATED_INTERFACES define guarded section
with the old defines which were modified above,
for backwards compatibility - guarded to prevent Quagga using it..
* lib/linklist.c: fix up for linklist.h changes.
* ospf6d/ospf6_abr.c: (ospf6_abr_examin_brouter) change to a single
scan of the area list, rather than scanning all areas first for
INTER_ROUTER and then again for INTER_NETWORK. According to
16.2, the scan should be area specific anyway, and further
ospf6d does not seem to implement 16.3 anyway.
2005-04-07 09:30:20 +02:00
|
|
|
|
for (ALL_LIST_ELEMENTS (ospf->maxage_lsa, node, nnode, lsa))
|
2002-12-13 21:15:29 +01:00
|
|
|
|
{
|
|
|
|
|
if (lsa->retransmit_counter > 0)
|
|
|
|
|
{
|
|
|
|
|
reschedule = 1;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Remove LSA from the LSDB */
|
|
|
|
|
if (CHECK_FLAG (lsa->flags, OSPF_LSA_SELF))
|
|
|
|
|
if (IS_DEBUG_OSPF (lsa, LSA_FLOODING))
|
2004-12-08 19:12:06 +01:00
|
|
|
|
zlog_debug ("LSA[Type%d:%s]: LSA 0x%lx is self-oririnated: ",
|
2003-10-13 11:06:46 +02:00
|
|
|
|
lsa->data->type, inet_ntoa (lsa->data->id), (u_long)lsa);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
|
|
if (IS_DEBUG_OSPF (lsa, LSA_FLOODING))
|
2004-12-08 19:12:06 +01:00
|
|
|
|
zlog_debug ("LSA[Type%d:%s]: MaxAge LSA removed from list",
|
2002-12-13 21:15:29 +01:00
|
|
|
|
lsa->data->type, inet_ntoa (lsa->data->id));
|
|
|
|
|
|
|
|
|
|
/* Flood max age LSA. */
|
|
|
|
|
#ifdef ORIGINAL_CODING
|
|
|
|
|
ospf_maxage_flood (lsa);
|
|
|
|
|
#else /* ORIGINAL_CODING */
|
2003-03-25 06:07:42 +01:00
|
|
|
|
ospf_flood_through (ospf, NULL, lsa);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
#endif /* ORIGINAL_CODING */
|
|
|
|
|
|
2003-10-13 11:06:46 +02:00
|
|
|
|
if (lsa->flags & OSPF_LSA_PREMATURE_AGE)
|
|
|
|
|
{
|
|
|
|
|
if (IS_DEBUG_OSPF (lsa, LSA_FLOODING))
|
2004-12-08 19:12:06 +01:00
|
|
|
|
zlog_debug ("originating new router lsa for lsa 0x%lx \n",
|
2003-10-13 11:06:46 +02:00
|
|
|
|
(u_long)lsa);
|
|
|
|
|
ospf_router_lsa_originate(lsa->area);
|
|
|
|
|
}
|
|
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
|
/* Remove from lsdb. */
|
2006-06-15 14:04:57 +02:00
|
|
|
|
if (lsa->lsdb)
|
|
|
|
|
{
|
|
|
|
|
ospf_discard_from_db (ospf, lsa->lsdb, lsa);
|
|
|
|
|
ospf_lsdb_delete (lsa->lsdb, lsa);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
zlog_warn ("%s: LSA[Type%d:%s]: No associated LSDB!", __func__,
|
|
|
|
|
lsa->data->type, inet_ntoa (lsa->data->id));
|
2002-12-13 21:15:29 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* A MaxAge LSA must be removed immediately from the router's link
|
|
|
|
|
state database as soon as both a) it is no longer contained on any
|
|
|
|
|
neighbor Link state retransmission lists and b) none of the router's
|
|
|
|
|
neighbors are in states Exchange or Loading. */
|
|
|
|
|
if (reschedule)
|
2003-03-25 06:07:42 +01:00
|
|
|
|
OSPF_TIMER_ON (ospf->t_maxage, ospf_maxage_lsa_remover, 2);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2005-05-06 23:37:42 +02:00
|
|
|
|
static int
|
2003-03-25 06:07:42 +01:00
|
|
|
|
ospf_lsa_maxage_exist (struct ospf *ospf, struct ospf_lsa *new)
|
2002-12-13 21:15:29 +01:00
|
|
|
|
{
|
2004-09-23 21:18:23 +02:00
|
|
|
|
struct listnode *node;
|
2005-04-07 Paul Jakma <paul.jakma@sun.com>
* (global): Fix up list loops to match changes in lib/linklist,
and some basic auditing of usage.
* configure.ac: define QUAGGA_NO_DEPRECATED_INTERFACES
* HACKING: Add notes about deprecating interfaces and commands.
* lib/linklist.h: Add usage comments.
Rename getdata macro to listgetdata.
Rename nextnode to listnextnode and fix its odd behaviour to be
less dangerous.
Make listgetdata macro assert node is not null, NULL list entries
should be bug condition.
ALL_LIST_ELEMENTS, new macro, forward-referencing macro for use
with for loop, Suggested by Jim Carlson of Sun.
Add ALL_LIST_ELEMENTS_RO for cases which obviously do not need the
"safety" of previous macro.
LISTNODE_ADD and DELETE macros renamed to ATTACH, DETACH, to
distinguish from the similarly named functions, and reflect their
effect better.
Add a QUAGGA_NO_DEPRECATED_INTERFACES define guarded section
with the old defines which were modified above,
for backwards compatibility - guarded to prevent Quagga using it..
* lib/linklist.c: fix up for linklist.h changes.
* ospf6d/ospf6_abr.c: (ospf6_abr_examin_brouter) change to a single
scan of the area list, rather than scanning all areas first for
INTER_ROUTER and then again for INTER_NETWORK. According to
16.2, the scan should be area specific anyway, and further
ospf6d does not seem to implement 16.3 anyway.
2005-04-07 09:30:20 +02:00
|
|
|
|
struct ospf_lsa *lsa;
|
|
|
|
|
|
|
|
|
|
for (ALL_LIST_ELEMENTS_RO (ospf->maxage_lsa, node, lsa))
|
|
|
|
|
if (lsa == new)
|
2002-12-13 21:15:29 +01:00
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
2003-03-25 06:07:42 +01:00
|
|
|
|
ospf_lsa_maxage_delete (struct ospf *ospf, struct ospf_lsa *lsa)
|
2002-12-13 21:15:29 +01:00
|
|
|
|
{
|
2004-09-23 21:18:23 +02:00
|
|
|
|
struct listnode *n;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
2003-03-25 06:07:42 +01:00
|
|
|
|
if ((n = listnode_lookup (ospf->maxage_lsa, lsa)))
|
2002-12-13 21:15:29 +01:00
|
|
|
|
{
|
2003-03-25 06:07:42 +01:00
|
|
|
|
list_delete_node (ospf->maxage_lsa, n);
|
2006-07-26 11:37:26 +02:00
|
|
|
|
ospf_lsa_unlock (&lsa); /* maxage_lsa */
|
2002-12-13 21:15:29 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
2003-03-25 06:07:42 +01:00
|
|
|
|
ospf_lsa_maxage (struct ospf *ospf, struct ospf_lsa *lsa)
|
2002-12-13 21:15:29 +01:00
|
|
|
|
{
|
|
|
|
|
/* When we saw a MaxAge LSA flooded to us, we put it on the list
|
|
|
|
|
and schedule the MaxAge LSA remover. */
|
2003-03-25 06:07:42 +01:00
|
|
|
|
if (ospf_lsa_maxage_exist (ospf, lsa))
|
2002-12-13 21:15:29 +01:00
|
|
|
|
{
|
|
|
|
|
if (IS_DEBUG_OSPF (lsa, LSA_FLOODING))
|
2004-12-08 19:12:06 +01:00
|
|
|
|
zlog_debug ("LSA[Type%d:%s]: %p already exists on MaxAge LSA list",
|
2002-12-13 21:15:29 +01:00
|
|
|
|
lsa->data->type, inet_ntoa (lsa->data->id), lsa);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2003-03-25 06:07:42 +01:00
|
|
|
|
listnode_add (ospf->maxage_lsa, ospf_lsa_lock (lsa));
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
|
|
if (IS_DEBUG_OSPF (lsa, LSA_FLOODING))
|
2004-12-08 19:12:06 +01:00
|
|
|
|
zlog_debug ("LSA[%s]: MaxAge LSA remover scheduled.", dump_lsa_key (lsa));
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
2003-03-25 06:07:42 +01:00
|
|
|
|
OSPF_TIMER_ON (ospf->t_maxage, ospf_maxage_lsa_remover, 2);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
}
|
|
|
|
|
|
2005-05-06 23:37:42 +02:00
|
|
|
|
static int
|
2003-03-25 06:07:42 +01:00
|
|
|
|
ospf_lsa_maxage_walker_remover (struct ospf *ospf, struct ospf_lsa *lsa)
|
2002-12-13 21:15:29 +01:00
|
|
|
|
{
|
|
|
|
|
/* Stay away from any Local Translated Type-7 LSAs */
|
|
|
|
|
if (CHECK_FLAG (lsa->flags, OSPF_LSA_LOCAL_XLT))
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
if (IS_LSA_MAXAGE (lsa))
|
|
|
|
|
/* Self-originated LSAs should NOT time-out instead,
|
|
|
|
|
they're flushed and submitted to the max_age list explicitly. */
|
2003-03-25 06:07:42 +01:00
|
|
|
|
if (!ospf_lsa_is_self_originated (ospf, lsa))
|
2002-12-13 21:15:29 +01:00
|
|
|
|
{
|
|
|
|
|
if (IS_DEBUG_OSPF (lsa, LSA_FLOODING))
|
2004-12-08 19:12:06 +01:00
|
|
|
|
zlog_debug("LSA[%s]: is MaxAge", dump_lsa_key (lsa));
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
|
|
switch (lsa->data->type)
|
|
|
|
|
{
|
|
|
|
|
#ifdef HAVE_OPAQUE_LSA
|
2003-02-03 19:40:56 +01:00
|
|
|
|
case OSPF_OPAQUE_LINK_LSA:
|
|
|
|
|
case OSPF_OPAQUE_AREA_LSA:
|
2002-12-13 21:15:29 +01:00
|
|
|
|
case OSPF_OPAQUE_AS_LSA:
|
2003-01-18 01:12:02 +01:00
|
|
|
|
/*
|
|
|
|
|
* As a general rule, whenever network topology has changed
|
|
|
|
|
* (due to an LSA removal in this case), routing recalculation
|
|
|
|
|
* should be triggered. However, this is not true for opaque
|
|
|
|
|
* LSAs. Even if an opaque LSA instance is going to be removed
|
|
|
|
|
* from the routing domain, it does not mean a change in network
|
|
|
|
|
* topology, and thus, routing recalculation is not needed here.
|
|
|
|
|
*/
|
|
|
|
|
break;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
#endif /* HAVE_OPAQUE_LSA */
|
2003-01-18 01:12:02 +01:00
|
|
|
|
case OSPF_AS_EXTERNAL_LSA:
|
2004-06-20 23:00:27 +02:00
|
|
|
|
case OSPF_AS_NSSA_LSA:
|
2003-03-25 06:07:42 +01:00
|
|
|
|
ospf_ase_incremental_update (ospf, lsa);
|
|
|
|
|
break;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
default:
|
2003-03-25 06:07:42 +01:00
|
|
|
|
ospf_spf_calculate_schedule (ospf);
|
|
|
|
|
break;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
}
|
2003-03-25 06:07:42 +01:00
|
|
|
|
ospf_lsa_maxage (ospf, lsa);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Periodical check of MaxAge LSA. */
|
|
|
|
|
int
|
2003-03-25 06:07:42 +01:00
|
|
|
|
ospf_lsa_maxage_walker (struct thread *thread)
|
2002-12-13 21:15:29 +01:00
|
|
|
|
{
|
2003-03-25 06:07:42 +01:00
|
|
|
|
struct ospf *ospf = THREAD_ARG (thread);
|
|
|
|
|
struct route_node *rn;
|
|
|
|
|
struct ospf_lsa *lsa;
|
2005-04-07 Paul Jakma <paul.jakma@sun.com>
* (global): Fix up list loops to match changes in lib/linklist,
and some basic auditing of usage.
* configure.ac: define QUAGGA_NO_DEPRECATED_INTERFACES
* HACKING: Add notes about deprecating interfaces and commands.
* lib/linklist.h: Add usage comments.
Rename getdata macro to listgetdata.
Rename nextnode to listnextnode and fix its odd behaviour to be
less dangerous.
Make listgetdata macro assert node is not null, NULL list entries
should be bug condition.
ALL_LIST_ELEMENTS, new macro, forward-referencing macro for use
with for loop, Suggested by Jim Carlson of Sun.
Add ALL_LIST_ELEMENTS_RO for cases which obviously do not need the
"safety" of previous macro.
LISTNODE_ADD and DELETE macros renamed to ATTACH, DETACH, to
distinguish from the similarly named functions, and reflect their
effect better.
Add a QUAGGA_NO_DEPRECATED_INTERFACES define guarded section
with the old defines which were modified above,
for backwards compatibility - guarded to prevent Quagga using it..
* lib/linklist.c: fix up for linklist.h changes.
* ospf6d/ospf6_abr.c: (ospf6_abr_examin_brouter) change to a single
scan of the area list, rather than scanning all areas first for
INTER_ROUTER and then again for INTER_NETWORK. According to
16.2, the scan should be area specific anyway, and further
ospf6d does not seem to implement 16.3 anyway.
2005-04-07 09:30:20 +02:00
|
|
|
|
struct ospf_area *area;
|
|
|
|
|
struct listnode *node, *nnode;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
2003-03-25 06:07:42 +01:00
|
|
|
|
ospf->t_maxage_walker = NULL;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
2005-04-07 Paul Jakma <paul.jakma@sun.com>
* (global): Fix up list loops to match changes in lib/linklist,
and some basic auditing of usage.
* configure.ac: define QUAGGA_NO_DEPRECATED_INTERFACES
* HACKING: Add notes about deprecating interfaces and commands.
* lib/linklist.h: Add usage comments.
Rename getdata macro to listgetdata.
Rename nextnode to listnextnode and fix its odd behaviour to be
less dangerous.
Make listgetdata macro assert node is not null, NULL list entries
should be bug condition.
ALL_LIST_ELEMENTS, new macro, forward-referencing macro for use
with for loop, Suggested by Jim Carlson of Sun.
Add ALL_LIST_ELEMENTS_RO for cases which obviously do not need the
"safety" of previous macro.
LISTNODE_ADD and DELETE macros renamed to ATTACH, DETACH, to
distinguish from the similarly named functions, and reflect their
effect better.
Add a QUAGGA_NO_DEPRECATED_INTERFACES define guarded section
with the old defines which were modified above,
for backwards compatibility - guarded to prevent Quagga using it..
* lib/linklist.c: fix up for linklist.h changes.
* ospf6d/ospf6_abr.c: (ospf6_abr_examin_brouter) change to a single
scan of the area list, rather than scanning all areas first for
INTER_ROUTER and then again for INTER_NETWORK. According to
16.2, the scan should be area specific anyway, and further
ospf6d does not seem to implement 16.3 anyway.
2005-04-07 09:30:20 +02:00
|
|
|
|
for (ALL_LIST_ELEMENTS (ospf->areas, node, nnode, area))
|
2002-12-13 21:15:29 +01:00
|
|
|
|
{
|
2003-03-25 06:07:42 +01:00
|
|
|
|
LSDB_LOOP (ROUTER_LSDB (area), rn, lsa)
|
|
|
|
|
ospf_lsa_maxage_walker_remover (ospf, lsa);
|
|
|
|
|
LSDB_LOOP (NETWORK_LSDB (area), rn, lsa)
|
|
|
|
|
ospf_lsa_maxage_walker_remover (ospf, lsa);
|
|
|
|
|
LSDB_LOOP (SUMMARY_LSDB (area), rn, lsa)
|
|
|
|
|
ospf_lsa_maxage_walker_remover (ospf, lsa);
|
|
|
|
|
LSDB_LOOP (ASBR_SUMMARY_LSDB (area), rn, lsa)
|
|
|
|
|
ospf_lsa_maxage_walker_remover (ospf, lsa);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
#ifdef HAVE_OPAQUE_LSA
|
2003-03-25 06:07:42 +01:00
|
|
|
|
LSDB_LOOP (OPAQUE_AREA_LSDB (area), rn, lsa)
|
|
|
|
|
ospf_lsa_maxage_walker_remover (ospf, lsa);
|
|
|
|
|
LSDB_LOOP (OPAQUE_LINK_LSDB (area), rn, lsa)
|
|
|
|
|
ospf_lsa_maxage_walker_remover (ospf, lsa);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
#endif /* HAVE_OPAQUE_LSA */
|
2003-05-10 22:06:51 +02:00
|
|
|
|
LSDB_LOOP (NSSA_LSDB (area), rn, lsa)
|
|
|
|
|
ospf_lsa_maxage_walker_remover (ospf, lsa);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
}
|
|
|
|
|
|
2003-05-10 22:06:51 +02:00
|
|
|
|
/* for AS-external-LSAs. */
|
2003-03-25 06:07:42 +01:00
|
|
|
|
if (ospf->lsdb)
|
|
|
|
|
{
|
|
|
|
|
LSDB_LOOP (EXTERNAL_LSDB (ospf), rn, lsa)
|
|
|
|
|
ospf_lsa_maxage_walker_remover (ospf, lsa);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
#ifdef HAVE_OPAQUE_LSA
|
2003-03-25 06:07:42 +01:00
|
|
|
|
LSDB_LOOP (OPAQUE_AS_LSDB (ospf), rn, lsa)
|
|
|
|
|
ospf_lsa_maxage_walker_remover (ospf, lsa);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
#endif /* HAVE_OPAQUE_LSA */
|
2003-03-25 06:07:42 +01:00
|
|
|
|
}
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
2003-03-25 06:07:42 +01:00
|
|
|
|
OSPF_TIMER_ON (ospf->t_maxage_walker, ospf_lsa_maxage_walker,
|
|
|
|
|
OSPF_LSA_MAXAGE_CHECK_INTERVAL);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2003-03-25 06:07:42 +01:00
|
|
|
|
struct ospf_lsa *
|
|
|
|
|
ospf_lsa_lookup_by_prefix (struct ospf_lsdb *lsdb, u_char type,
|
|
|
|
|
struct prefix_ipv4 *p, struct in_addr router_id)
|
2002-12-13 21:15:29 +01:00
|
|
|
|
{
|
2003-03-25 06:07:42 +01:00
|
|
|
|
struct ospf_lsa *lsa;
|
|
|
|
|
struct in_addr mask, id;
|
|
|
|
|
struct lsa_header_mask
|
|
|
|
|
{
|
|
|
|
|
struct lsa_header header;
|
|
|
|
|
struct in_addr mask;
|
|
|
|
|
} *hmask;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
2003-03-25 06:07:42 +01:00
|
|
|
|
lsa = ospf_lsdb_lookup_by_id (lsdb, type, p->prefix, router_id);
|
|
|
|
|
if (lsa == NULL)
|
|
|
|
|
return NULL;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
2003-03-25 06:07:42 +01:00
|
|
|
|
masklen2ip (p->prefixlen, &mask);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
2003-03-25 06:07:42 +01:00
|
|
|
|
hmask = (struct lsa_header_mask *) lsa->data;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
2003-03-25 06:07:42 +01:00
|
|
|
|
if (mask.s_addr != hmask->mask.s_addr)
|
|
|
|
|
{
|
|
|
|
|
id.s_addr = p->prefix.s_addr | (~mask.s_addr);
|
|
|
|
|
lsa = ospf_lsdb_lookup_by_id (lsdb, type, id, router_id);
|
|
|
|
|
if (!lsa)
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
2003-03-25 06:07:42 +01:00
|
|
|
|
return lsa;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct ospf_lsa *
|
|
|
|
|
ospf_lsa_lookup (struct ospf_area *area, u_int32_t type,
|
|
|
|
|
struct in_addr id, struct in_addr adv_router)
|
|
|
|
|
{
|
2003-04-13 22:20:53 +02:00
|
|
|
|
struct ospf *ospf = ospf_lookup();
|
|
|
|
|
assert(ospf);
|
|
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
|
switch (type)
|
|
|
|
|
{
|
|
|
|
|
case OSPF_ROUTER_LSA:
|
|
|
|
|
case OSPF_NETWORK_LSA:
|
|
|
|
|
case OSPF_SUMMARY_LSA:
|
|
|
|
|
case OSPF_ASBR_SUMMARY_LSA:
|
|
|
|
|
case OSPF_AS_NSSA_LSA:
|
|
|
|
|
#ifdef HAVE_OPAQUE_LSA
|
|
|
|
|
case OSPF_OPAQUE_LINK_LSA:
|
|
|
|
|
case OSPF_OPAQUE_AREA_LSA:
|
|
|
|
|
#endif /* HAVE_OPAQUE_LSA */
|
|
|
|
|
return ospf_lsdb_lookup_by_id (area->lsdb, type, id, adv_router);
|
|
|
|
|
case OSPF_AS_EXTERNAL_LSA:
|
|
|
|
|
#ifdef HAVE_OPAQUE_LSA
|
|
|
|
|
case OSPF_OPAQUE_AS_LSA:
|
|
|
|
|
#endif /* HAVE_OPAQUE_LSA */
|
2003-04-13 22:20:53 +02:00
|
|
|
|
return ospf_lsdb_lookup_by_id (ospf->lsdb, type, id, adv_router);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct ospf_lsa *
|
|
|
|
|
ospf_lsa_lookup_by_id (struct ospf_area *area, u_int32_t type,
|
|
|
|
|
struct in_addr id)
|
|
|
|
|
{
|
|
|
|
|
struct ospf_lsa *lsa;
|
|
|
|
|
struct route_node *rn;
|
|
|
|
|
|
|
|
|
|
switch (type)
|
|
|
|
|
{
|
|
|
|
|
case OSPF_ROUTER_LSA:
|
|
|
|
|
return ospf_lsdb_lookup_by_id (area->lsdb, type, id, id);
|
|
|
|
|
case OSPF_NETWORK_LSA:
|
|
|
|
|
for (rn = route_top (NETWORK_LSDB (area)); rn; rn = route_next (rn))
|
|
|
|
|
if ((lsa = rn->info))
|
|
|
|
|
if (IPV4_ADDR_SAME (&lsa->data->id, &id))
|
|
|
|
|
{
|
|
|
|
|
route_unlock_node (rn);
|
|
|
|
|
return lsa;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case OSPF_SUMMARY_LSA:
|
|
|
|
|
case OSPF_ASBR_SUMMARY_LSA:
|
|
|
|
|
/* Currently not used. */
|
|
|
|
|
assert (1);
|
|
|
|
|
return ospf_lsdb_lookup_by_id (area->lsdb, type, id, id);
|
|
|
|
|
case OSPF_AS_EXTERNAL_LSA:
|
2003-07-12 23:30:57 +02:00
|
|
|
|
case OSPF_AS_NSSA_LSA:
|
2002-12-13 21:15:29 +01:00
|
|
|
|
#ifdef HAVE_OPAQUE_LSA
|
|
|
|
|
case OSPF_OPAQUE_LINK_LSA:
|
|
|
|
|
case OSPF_OPAQUE_AREA_LSA:
|
|
|
|
|
case OSPF_OPAQUE_AS_LSA:
|
|
|
|
|
/* Currently not used. */
|
|
|
|
|
break;
|
|
|
|
|
#endif /* HAVE_OPAQUE_LSA */
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct ospf_lsa *
|
|
|
|
|
ospf_lsa_lookup_by_header (struct ospf_area *area, struct lsa_header *lsah)
|
|
|
|
|
{
|
|
|
|
|
struct ospf_lsa *match;
|
|
|
|
|
|
|
|
|
|
#ifdef HAVE_OPAQUE_LSA
|
|
|
|
|
/*
|
|
|
|
|
* Strictly speaking, the LSA-ID field for Opaque-LSAs (type-9/10/11)
|
|
|
|
|
* is redefined to have two subfields; opaque-type and opaque-id.
|
|
|
|
|
* However, it is harmless to treat the two sub fields together, as if
|
|
|
|
|
* they two were forming a unique LSA-ID.
|
|
|
|
|
*/
|
|
|
|
|
#endif /* HAVE_OPAQUE_LSA */
|
|
|
|
|
|
|
|
|
|
match = ospf_lsa_lookup (area, lsah->type, lsah->id, lsah->adv_router);
|
|
|
|
|
|
|
|
|
|
if (match == NULL)
|
|
|
|
|
if (IS_DEBUG_OSPF (lsa, LSA) == OSPF_DEBUG_LSA)
|
2004-12-08 19:12:06 +01:00
|
|
|
|
zlog_debug ("LSA[Type%d:%s]: Lookup by header, NO MATCH",
|
2002-12-13 21:15:29 +01:00
|
|
|
|
lsah->type, inet_ntoa (lsah->id));
|
|
|
|
|
|
|
|
|
|
return match;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* return +n, l1 is more recent.
|
|
|
|
|
return -n, l2 is more recent.
|
|
|
|
|
return 0, l1 and l2 is identical. */
|
|
|
|
|
int
|
|
|
|
|
ospf_lsa_more_recent (struct ospf_lsa *l1, struct ospf_lsa *l2)
|
|
|
|
|
{
|
|
|
|
|
int r;
|
|
|
|
|
int x, y;
|
|
|
|
|
|
|
|
|
|
if (l1 == NULL && l2 == NULL)
|
|
|
|
|
return 0;
|
|
|
|
|
if (l1 == NULL)
|
|
|
|
|
return -1;
|
|
|
|
|
if (l2 == NULL)
|
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
|
|
/* compare LS sequence number. */
|
|
|
|
|
x = (int) ntohl (l1->data->ls_seqnum);
|
|
|
|
|
y = (int) ntohl (l2->data->ls_seqnum);
|
|
|
|
|
if (x > y)
|
|
|
|
|
return 1;
|
|
|
|
|
if (x < y)
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
|
|
/* compare LS checksum. */
|
|
|
|
|
r = ntohs (l1->data->checksum) - ntohs (l2->data->checksum);
|
|
|
|
|
if (r)
|
|
|
|
|
return r;
|
|
|
|
|
|
|
|
|
|
/* compare LS age. */
|
|
|
|
|
if (IS_LSA_MAXAGE (l1) && !IS_LSA_MAXAGE (l2))
|
|
|
|
|
return 1;
|
|
|
|
|
else if (!IS_LSA_MAXAGE (l1) && IS_LSA_MAXAGE (l2))
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
|
|
/* compare LS age with MaxAgeDiff. */
|
|
|
|
|
if (LS_AGE (l1) - LS_AGE (l2) > OSPF_LSA_MAXAGE_DIFF)
|
|
|
|
|
return -1;
|
|
|
|
|
else if (LS_AGE (l2) - LS_AGE (l1) > OSPF_LSA_MAXAGE_DIFF)
|
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
|
|
/* LSAs are identical. */
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* If two LSAs are different, return 1, otherwise return 0. */
|
|
|
|
|
int
|
|
|
|
|
ospf_lsa_different (struct ospf_lsa *l1, struct ospf_lsa *l2)
|
|
|
|
|
{
|
|
|
|
|
char *p1, *p2;
|
|
|
|
|
assert (l1);
|
|
|
|
|
assert (l2);
|
|
|
|
|
assert (l1->data);
|
|
|
|
|
assert (l2->data);
|
|
|
|
|
|
|
|
|
|
if (l1->data->options != l2->data->options)
|
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
|
|
if (IS_LSA_MAXAGE (l1) && !IS_LSA_MAXAGE (l2))
|
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
|
|
if (IS_LSA_MAXAGE (l2) && !IS_LSA_MAXAGE (l1))
|
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
|
|
if (l1->data->length != l2->data->length)
|
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
|
|
if (l1->data->length == 0)
|
|
|
|
|
return 1;
|
|
|
|
|
|
2003-04-03 03:27:01 +02:00
|
|
|
|
assert ( ntohs(l1->data->length) > OSPF_LSA_HEADER_SIZE);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
|
|
p1 = (char *) l1->data;
|
|
|
|
|
p2 = (char *) l2->data;
|
|
|
|
|
|
|
|
|
|
if (memcmp (p1 + OSPF_LSA_HEADER_SIZE, p2 + OSPF_LSA_HEADER_SIZE,
|
|
|
|
|
ntohs( l1->data->length ) - OSPF_LSA_HEADER_SIZE) != 0)
|
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#ifdef ORIGINAL_CODING
|
|
|
|
|
void
|
|
|
|
|
ospf_lsa_flush_self_originated (struct ospf_neighbor *nbr,
|
|
|
|
|
struct ospf_lsa *self,
|
|
|
|
|
struct ospf_lsa *new)
|
|
|
|
|
{
|
|
|
|
|
u_int32_t seqnum;
|
|
|
|
|
|
|
|
|
|
/* Adjust LS Sequence Number. */
|
|
|
|
|
seqnum = ntohl (new->data->ls_seqnum) + 1;
|
|
|
|
|
self->data->ls_seqnum = htonl (seqnum);
|
|
|
|
|
|
|
|
|
|
/* Recalculate LSA checksum. */
|
|
|
|
|
ospf_lsa_checksum (self->data);
|
|
|
|
|
|
|
|
|
|
/* Reflooding LSA. */
|
|
|
|
|
/* RFC2328 Section 13.3
|
|
|
|
|
On non-broadcast networks, separate Link State Update
|
|
|
|
|
packets must be sent, as unicasts, to each adjacent neighbor
|
|
|
|
|
(i.e., those in state Exchange or greater). The destination
|
|
|
|
|
IP addresses for these packets are the neighbors' IP
|
|
|
|
|
addresses. */
|
|
|
|
|
if (nbr->oi->type == OSPF_IFTYPE_NBMA)
|
|
|
|
|
{
|
|
|
|
|
struct route_node *rn;
|
|
|
|
|
struct ospf_neighbor *onbr;
|
|
|
|
|
|
|
|
|
|
for (rn = route_top (nbr->oi->nbrs); rn; rn = route_next (rn))
|
|
|
|
|
if ((onbr = rn->info) != NULL)
|
|
|
|
|
if (onbr != nbr->oi->nbr_self && onbr->status >= NSM_Exchange)
|
|
|
|
|
ospf_ls_upd_send_lsa (onbr, self, OSPF_SEND_PACKET_DIRECT);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
ospf_ls_upd_send_lsa (nbr, self, OSPF_SEND_PACKET_INDIRECT);
|
|
|
|
|
|
|
|
|
|
if (IS_DEBUG_OSPF (lsa, LSA_GENERATE))
|
2004-12-08 19:12:06 +01:00
|
|
|
|
zlog_debug ("LSA[Type%d:%s]: Flush self-originated LSA",
|
2002-12-13 21:15:29 +01:00
|
|
|
|
self->data->type, inet_ntoa (self->data->id));
|
|
|
|
|
}
|
|
|
|
|
#else /* ORIGINAL_CODING */
|
|
|
|
|
static int
|
2003-03-25 06:07:42 +01:00
|
|
|
|
ospf_lsa_flush_schedule (struct ospf *ospf, struct ospf_lsa *lsa)
|
2002-12-13 21:15:29 +01:00
|
|
|
|
{
|
|
|
|
|
if (lsa == NULL || !IS_LSA_SELF (lsa))
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
if (IS_DEBUG_OSPF_EVENT)
|
2004-12-08 19:12:06 +01:00
|
|
|
|
zlog_debug ("LSA[Type%d:%s]: Schedule self-originated LSA to FLUSH", lsa->data->type, inet_ntoa (lsa->data->id));
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
|
|
/* Force given lsa's age to MaxAge. */
|
|
|
|
|
lsa->data->ls_age = htons (OSPF_LSA_MAXAGE);
|
|
|
|
|
|
|
|
|
|
switch (lsa->data->type)
|
|
|
|
|
{
|
|
|
|
|
#ifdef HAVE_OPAQUE_LSA
|
|
|
|
|
case OSPF_OPAQUE_LINK_LSA:
|
|
|
|
|
case OSPF_OPAQUE_AREA_LSA:
|
|
|
|
|
case OSPF_OPAQUE_AS_LSA:
|
|
|
|
|
ospf_opaque_lsa_refresh (lsa);
|
|
|
|
|
break;
|
|
|
|
|
#endif /* HAVE_OPAQUE_LSA */
|
|
|
|
|
default:
|
2003-03-25 06:07:42 +01:00
|
|
|
|
ospf_lsa_maxage (ospf, lsa);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
2003-03-25 06:07:42 +01:00
|
|
|
|
ospf_flush_self_originated_lsas_now (struct ospf *ospf)
|
2002-12-13 21:15:29 +01:00
|
|
|
|
{
|
2005-04-07 Paul Jakma <paul.jakma@sun.com>
* (global): Fix up list loops to match changes in lib/linklist,
and some basic auditing of usage.
* configure.ac: define QUAGGA_NO_DEPRECATED_INTERFACES
* HACKING: Add notes about deprecating interfaces and commands.
* lib/linklist.h: Add usage comments.
Rename getdata macro to listgetdata.
Rename nextnode to listnextnode and fix its odd behaviour to be
less dangerous.
Make listgetdata macro assert node is not null, NULL list entries
should be bug condition.
ALL_LIST_ELEMENTS, new macro, forward-referencing macro for use
with for loop, Suggested by Jim Carlson of Sun.
Add ALL_LIST_ELEMENTS_RO for cases which obviously do not need the
"safety" of previous macro.
LISTNODE_ADD and DELETE macros renamed to ATTACH, DETACH, to
distinguish from the similarly named functions, and reflect their
effect better.
Add a QUAGGA_NO_DEPRECATED_INTERFACES define guarded section
with the old defines which were modified above,
for backwards compatibility - guarded to prevent Quagga using it..
* lib/linklist.c: fix up for linklist.h changes.
* ospf6d/ospf6_abr.c: (ospf6_abr_examin_brouter) change to a single
scan of the area list, rather than scanning all areas first for
INTER_ROUTER and then again for INTER_NETWORK. According to
16.2, the scan should be area specific anyway, and further
ospf6d does not seem to implement 16.3 anyway.
2005-04-07 09:30:20 +02:00
|
|
|
|
struct listnode *node, *nnode;
|
|
|
|
|
struct listnode *node2, *nnode2;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
struct ospf_area *area;
|
|
|
|
|
struct ospf_interface *oi;
|
|
|
|
|
struct ospf_lsa *lsa;
|
2003-03-25 06:07:42 +01:00
|
|
|
|
struct route_node *rn;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
int need_to_flush_ase = 0;
|
|
|
|
|
|
2005-04-07 Paul Jakma <paul.jakma@sun.com>
* (global): Fix up list loops to match changes in lib/linklist,
and some basic auditing of usage.
* configure.ac: define QUAGGA_NO_DEPRECATED_INTERFACES
* HACKING: Add notes about deprecating interfaces and commands.
* lib/linklist.h: Add usage comments.
Rename getdata macro to listgetdata.
Rename nextnode to listnextnode and fix its odd behaviour to be
less dangerous.
Make listgetdata macro assert node is not null, NULL list entries
should be bug condition.
ALL_LIST_ELEMENTS, new macro, forward-referencing macro for use
with for loop, Suggested by Jim Carlson of Sun.
Add ALL_LIST_ELEMENTS_RO for cases which obviously do not need the
"safety" of previous macro.
LISTNODE_ADD and DELETE macros renamed to ATTACH, DETACH, to
distinguish from the similarly named functions, and reflect their
effect better.
Add a QUAGGA_NO_DEPRECATED_INTERFACES define guarded section
with the old defines which were modified above,
for backwards compatibility - guarded to prevent Quagga using it..
* lib/linklist.c: fix up for linklist.h changes.
* ospf6d/ospf6_abr.c: (ospf6_abr_examin_brouter) change to a single
scan of the area list, rather than scanning all areas first for
INTER_ROUTER and then again for INTER_NETWORK. According to
16.2, the scan should be area specific anyway, and further
ospf6d does not seem to implement 16.3 anyway.
2005-04-07 09:30:20 +02:00
|
|
|
|
for (ALL_LIST_ELEMENTS (ospf->areas, node, nnode, area))
|
2002-12-13 21:15:29 +01:00
|
|
|
|
{
|
|
|
|
|
if ((lsa = area->router_lsa_self) != NULL)
|
|
|
|
|
{
|
|
|
|
|
if (IS_DEBUG_OSPF_EVENT)
|
2004-12-08 19:12:06 +01:00
|
|
|
|
zlog_debug ("LSA[Type%d:%s]: Schedule self-originated LSA to FLUSH", lsa->data->type, inet_ntoa (lsa->data->id));
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
|
|
ospf_lsa_flush_area (lsa, area);
|
2006-07-26 11:37:26 +02:00
|
|
|
|
ospf_lsa_unlock (&area->router_lsa_self);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
area->router_lsa_self = NULL;
|
|
|
|
|
OSPF_TIMER_OFF (area->t_router_lsa_self);
|
|
|
|
|
}
|
|
|
|
|
|
2005-04-07 Paul Jakma <paul.jakma@sun.com>
* (global): Fix up list loops to match changes in lib/linklist,
and some basic auditing of usage.
* configure.ac: define QUAGGA_NO_DEPRECATED_INTERFACES
* HACKING: Add notes about deprecating interfaces and commands.
* lib/linklist.h: Add usage comments.
Rename getdata macro to listgetdata.
Rename nextnode to listnextnode and fix its odd behaviour to be
less dangerous.
Make listgetdata macro assert node is not null, NULL list entries
should be bug condition.
ALL_LIST_ELEMENTS, new macro, forward-referencing macro for use
with for loop, Suggested by Jim Carlson of Sun.
Add ALL_LIST_ELEMENTS_RO for cases which obviously do not need the
"safety" of previous macro.
LISTNODE_ADD and DELETE macros renamed to ATTACH, DETACH, to
distinguish from the similarly named functions, and reflect their
effect better.
Add a QUAGGA_NO_DEPRECATED_INTERFACES define guarded section
with the old defines which were modified above,
for backwards compatibility - guarded to prevent Quagga using it..
* lib/linklist.c: fix up for linklist.h changes.
* ospf6d/ospf6_abr.c: (ospf6_abr_examin_brouter) change to a single
scan of the area list, rather than scanning all areas first for
INTER_ROUTER and then again for INTER_NETWORK. According to
16.2, the scan should be area specific anyway, and further
ospf6d does not seem to implement 16.3 anyway.
2005-04-07 09:30:20 +02:00
|
|
|
|
for (ALL_LIST_ELEMENTS (area->oiflist, node2, nnode2, oi))
|
2002-12-13 21:15:29 +01:00
|
|
|
|
{
|
|
|
|
|
if ((lsa = oi->network_lsa_self) != NULL
|
2005-04-07 Paul Jakma <paul.jakma@sun.com>
* (global): Fix up list loops to match changes in lib/linklist,
and some basic auditing of usage.
* configure.ac: define QUAGGA_NO_DEPRECATED_INTERFACES
* HACKING: Add notes about deprecating interfaces and commands.
* lib/linklist.h: Add usage comments.
Rename getdata macro to listgetdata.
Rename nextnode to listnextnode and fix its odd behaviour to be
less dangerous.
Make listgetdata macro assert node is not null, NULL list entries
should be bug condition.
ALL_LIST_ELEMENTS, new macro, forward-referencing macro for use
with for loop, Suggested by Jim Carlson of Sun.
Add ALL_LIST_ELEMENTS_RO for cases which obviously do not need the
"safety" of previous macro.
LISTNODE_ADD and DELETE macros renamed to ATTACH, DETACH, to
distinguish from the similarly named functions, and reflect their
effect better.
Add a QUAGGA_NO_DEPRECATED_INTERFACES define guarded section
with the old defines which were modified above,
for backwards compatibility - guarded to prevent Quagga using it..
* lib/linklist.c: fix up for linklist.h changes.
* ospf6d/ospf6_abr.c: (ospf6_abr_examin_brouter) change to a single
scan of the area list, rather than scanning all areas first for
INTER_ROUTER and then again for INTER_NETWORK. According to
16.2, the scan should be area specific anyway, and further
ospf6d does not seem to implement 16.3 anyway.
2005-04-07 09:30:20 +02:00
|
|
|
|
&& oi->state == ISM_DR
|
|
|
|
|
&& oi->full_nbrs > 0)
|
2002-12-13 21:15:29 +01:00
|
|
|
|
{
|
|
|
|
|
if (IS_DEBUG_OSPF_EVENT)
|
2004-12-08 19:12:06 +01:00
|
|
|
|
zlog_debug ("LSA[Type%d:%s]: Schedule self-originated LSA to FLUSH", lsa->data->type, inet_ntoa (lsa->data->id));
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
|
|
ospf_lsa_flush_area (oi->network_lsa_self, area);
|
2006-07-26 11:37:26 +02:00
|
|
|
|
ospf_lsa_unlock (&oi->network_lsa_self);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
oi->network_lsa_self = NULL;
|
|
|
|
|
OSPF_TIMER_OFF (oi->t_network_lsa_self);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (oi->type != OSPF_IFTYPE_VIRTUALLINK
|
|
|
|
|
&& area->external_routing == OSPF_AREA_DEFAULT)
|
|
|
|
|
need_to_flush_ase = 1;
|
|
|
|
|
}
|
|
|
|
|
|
2003-03-25 06:07:42 +01:00
|
|
|
|
LSDB_LOOP (SUMMARY_LSDB (area), rn, lsa)
|
|
|
|
|
ospf_lsa_flush_schedule (ospf, lsa);
|
|
|
|
|
LSDB_LOOP (ASBR_SUMMARY_LSDB (area), rn, lsa)
|
|
|
|
|
ospf_lsa_flush_schedule (ospf, lsa);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
#ifdef HAVE_OPAQUE_LSA
|
2003-03-25 06:07:42 +01:00
|
|
|
|
LSDB_LOOP (OPAQUE_LINK_LSDB (area), rn, lsa)
|
|
|
|
|
ospf_lsa_flush_schedule (ospf, lsa);
|
|
|
|
|
LSDB_LOOP (OPAQUE_AREA_LSDB (area), rn, lsa)
|
|
|
|
|
ospf_lsa_flush_schedule (ospf, lsa);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
#endif /* HAVE_OPAQUE_LSA */
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (need_to_flush_ase)
|
|
|
|
|
{
|
2003-03-25 06:07:42 +01:00
|
|
|
|
LSDB_LOOP (EXTERNAL_LSDB (ospf), rn, lsa)
|
|
|
|
|
ospf_lsa_flush_schedule (ospf, lsa);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
#ifdef HAVE_OPAQUE_LSA
|
2003-03-25 06:07:42 +01:00
|
|
|
|
LSDB_LOOP (OPAQUE_AS_LSDB (ospf), rn, lsa)
|
|
|
|
|
ospf_lsa_flush_schedule (ospf, lsa);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
#endif /* HAVE_OPAQUE_LSA */
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Make sure that the MaxAge LSA remover is executed immediately,
|
|
|
|
|
* without conflicting to other threads.
|
|
|
|
|
*/
|
2003-03-25 06:07:42 +01:00
|
|
|
|
if (ospf->t_maxage != NULL)
|
2002-12-13 21:15:29 +01:00
|
|
|
|
{
|
2003-03-25 06:07:42 +01:00
|
|
|
|
OSPF_TIMER_OFF (ospf->t_maxage);
|
|
|
|
|
thread_execute (master, ospf_maxage_lsa_remover, ospf, 0);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
#endif /* ORIGINAL_CODING */
|
|
|
|
|
|
|
|
|
|
/* If there is self-originated LSA, then return 1, otherwise return 0. */
|
|
|
|
|
/* An interface-independent version of ospf_lsa_is_self_originated */
|
|
|
|
|
int
|
2003-03-25 06:07:42 +01:00
|
|
|
|
ospf_lsa_is_self_originated (struct ospf *ospf, struct ospf_lsa *lsa)
|
2002-12-13 21:15:29 +01:00
|
|
|
|
{
|
2004-09-23 21:18:23 +02:00
|
|
|
|
struct listnode *node;
|
2005-04-07 Paul Jakma <paul.jakma@sun.com>
* (global): Fix up list loops to match changes in lib/linklist,
and some basic auditing of usage.
* configure.ac: define QUAGGA_NO_DEPRECATED_INTERFACES
* HACKING: Add notes about deprecating interfaces and commands.
* lib/linklist.h: Add usage comments.
Rename getdata macro to listgetdata.
Rename nextnode to listnextnode and fix its odd behaviour to be
less dangerous.
Make listgetdata macro assert node is not null, NULL list entries
should be bug condition.
ALL_LIST_ELEMENTS, new macro, forward-referencing macro for use
with for loop, Suggested by Jim Carlson of Sun.
Add ALL_LIST_ELEMENTS_RO for cases which obviously do not need the
"safety" of previous macro.
LISTNODE_ADD and DELETE macros renamed to ATTACH, DETACH, to
distinguish from the similarly named functions, and reflect their
effect better.
Add a QUAGGA_NO_DEPRECATED_INTERFACES define guarded section
with the old defines which were modified above,
for backwards compatibility - guarded to prevent Quagga using it..
* lib/linklist.c: fix up for linklist.h changes.
* ospf6d/ospf6_abr.c: (ospf6_abr_examin_brouter) change to a single
scan of the area list, rather than scanning all areas first for
INTER_ROUTER and then again for INTER_NETWORK. According to
16.2, the scan should be area specific anyway, and further
ospf6d does not seem to implement 16.3 anyway.
2005-04-07 09:30:20 +02:00
|
|
|
|
struct ospf_interface *oi;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
|
|
/* This LSA is already checked. */
|
|
|
|
|
if (CHECK_FLAG (lsa->flags, OSPF_LSA_SELF_CHECKED))
|
|
|
|
|
return CHECK_FLAG (lsa->flags, OSPF_LSA_SELF);
|
|
|
|
|
|
|
|
|
|
/* Make sure LSA is self-checked. */
|
|
|
|
|
SET_FLAG (lsa->flags, OSPF_LSA_SELF_CHECKED);
|
|
|
|
|
|
|
|
|
|
/* AdvRouter and Router ID is the same. */
|
2003-03-25 06:07:42 +01:00
|
|
|
|
if (IPV4_ADDR_SAME (&lsa->data->adv_router, &ospf->router_id))
|
2002-12-13 21:15:29 +01:00
|
|
|
|
SET_FLAG (lsa->flags, OSPF_LSA_SELF);
|
|
|
|
|
|
|
|
|
|
/* LSA is router-LSA. */
|
|
|
|
|
else if (lsa->data->type == OSPF_ROUTER_LSA &&
|
2003-03-25 06:07:42 +01:00
|
|
|
|
IPV4_ADDR_SAME (&lsa->data->id, &ospf->router_id))
|
2002-12-13 21:15:29 +01:00
|
|
|
|
SET_FLAG (lsa->flags, OSPF_LSA_SELF);
|
|
|
|
|
|
|
|
|
|
/* LSA is network-LSA. Compare Link ID with all interfaces. */
|
|
|
|
|
else if (lsa->data->type == OSPF_NETWORK_LSA)
|
2005-04-07 Paul Jakma <paul.jakma@sun.com>
* (global): Fix up list loops to match changes in lib/linklist,
and some basic auditing of usage.
* configure.ac: define QUAGGA_NO_DEPRECATED_INTERFACES
* HACKING: Add notes about deprecating interfaces and commands.
* lib/linklist.h: Add usage comments.
Rename getdata macro to listgetdata.
Rename nextnode to listnextnode and fix its odd behaviour to be
less dangerous.
Make listgetdata macro assert node is not null, NULL list entries
should be bug condition.
ALL_LIST_ELEMENTS, new macro, forward-referencing macro for use
with for loop, Suggested by Jim Carlson of Sun.
Add ALL_LIST_ELEMENTS_RO for cases which obviously do not need the
"safety" of previous macro.
LISTNODE_ADD and DELETE macros renamed to ATTACH, DETACH, to
distinguish from the similarly named functions, and reflect their
effect better.
Add a QUAGGA_NO_DEPRECATED_INTERFACES define guarded section
with the old defines which were modified above,
for backwards compatibility - guarded to prevent Quagga using it..
* lib/linklist.c: fix up for linklist.h changes.
* ospf6d/ospf6_abr.c: (ospf6_abr_examin_brouter) change to a single
scan of the area list, rather than scanning all areas first for
INTER_ROUTER and then again for INTER_NETWORK. According to
16.2, the scan should be area specific anyway, and further
ospf6d does not seem to implement 16.3 anyway.
2005-04-07 09:30:20 +02:00
|
|
|
|
for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
|
2002-12-13 21:15:29 +01:00
|
|
|
|
{
|
|
|
|
|
/* Ignore virtual link. */
|
|
|
|
|
if (oi->type != OSPF_IFTYPE_VIRTUALLINK)
|
|
|
|
|
if (oi->address->family == AF_INET)
|
|
|
|
|
if (IPV4_ADDR_SAME (&lsa->data->id, &oi->address->u.prefix4))
|
|
|
|
|
{
|
|
|
|
|
/* to make it easier later */
|
|
|
|
|
SET_FLAG (lsa->flags, OSPF_LSA_SELF);
|
|
|
|
|
return CHECK_FLAG (lsa->flags, OSPF_LSA_SELF);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return CHECK_FLAG (lsa->flags, OSPF_LSA_SELF);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Get unique Link State ID. */
|
|
|
|
|
struct in_addr
|
2003-03-25 06:07:42 +01:00
|
|
|
|
ospf_lsa_unique_id (struct ospf *ospf,
|
|
|
|
|
struct ospf_lsdb *lsdb, u_char type, struct prefix_ipv4 *p)
|
2002-12-13 21:15:29 +01:00
|
|
|
|
{
|
|
|
|
|
struct ospf_lsa *lsa;
|
|
|
|
|
struct in_addr mask, id;
|
|
|
|
|
|
|
|
|
|
id = p->prefix;
|
|
|
|
|
|
|
|
|
|
/* Check existence of LSA instance. */
|
2003-03-25 06:07:42 +01:00
|
|
|
|
lsa = ospf_lsdb_lookup_by_id (lsdb, type, id, ospf->router_id);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
if (lsa)
|
|
|
|
|
{
|
|
|
|
|
struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
|
|
|
|
|
if (ip_masklen (al->mask) == p->prefixlen)
|
|
|
|
|
{
|
|
|
|
|
if (IS_DEBUG_OSPF (lsa, LSA_GENERATE))
|
2004-12-08 19:12:06 +01:00
|
|
|
|
zlog_debug ("ospf_lsa_unique_id(): "
|
2002-12-13 21:15:29 +01:00
|
|
|
|
"Can't get Link State ID for %s/%d",
|
|
|
|
|
inet_ntoa (p->prefix), p->prefixlen);
|
|
|
|
|
/* id.s_addr = 0; */
|
|
|
|
|
id.s_addr = 0xffffffff;
|
|
|
|
|
return id;
|
|
|
|
|
}
|
|
|
|
|
/* Masklen differs, then apply wildcard mask to Link State ID. */
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
masklen2ip (p->prefixlen, &mask);
|
|
|
|
|
|
|
|
|
|
id.s_addr = p->prefix.s_addr | (~mask.s_addr);
|
2003-03-25 06:07:42 +01:00
|
|
|
|
lsa = ospf_lsdb_lookup_by_id (ospf->lsdb, type,
|
|
|
|
|
id, ospf->router_id);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
if (lsa)
|
|
|
|
|
{
|
|
|
|
|
if (IS_DEBUG_OSPF (lsa, LSA_GENERATE))
|
2004-12-08 19:12:06 +01:00
|
|
|
|
zlog_debug ("ospf_lsa_unique_id(): "
|
2002-12-13 21:15:29 +01:00
|
|
|
|
"Can't get Link State ID for %s/%d",
|
|
|
|
|
inet_ntoa (p->prefix), p->prefixlen);
|
|
|
|
|
/* id.s_addr = 0; */
|
|
|
|
|
id.s_addr = 0xffffffff;
|
|
|
|
|
return id;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return id;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-05-13 00:57:57 +02:00
|
|
|
|
#define LSA_ACTION_FLOOD_AREA 1
|
|
|
|
|
#define LSA_ACTION_FLUSH_AREA 2
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
|
|
struct lsa_action
|
|
|
|
|
{
|
|
|
|
|
u_char action;
|
|
|
|
|
struct ospf_area *area;
|
|
|
|
|
struct ospf_lsa *lsa;
|
|
|
|
|
};
|
|
|
|
|
|
2005-05-06 23:37:42 +02:00
|
|
|
|
static int
|
2002-12-13 21:15:29 +01:00
|
|
|
|
ospf_lsa_action (struct thread *t)
|
|
|
|
|
{
|
|
|
|
|
struct lsa_action *data;
|
|
|
|
|
|
|
|
|
|
data = THREAD_ARG (t);
|
|
|
|
|
|
|
|
|
|
if (IS_DEBUG_OSPF (lsa, LSA) == OSPF_DEBUG_LSA)
|
2004-12-08 19:12:06 +01:00
|
|
|
|
zlog_debug ("LSA[Action]: Performing scheduled LSA action: %d",
|
2002-12-13 21:15:29 +01:00
|
|
|
|
data->action);
|
|
|
|
|
|
|
|
|
|
switch (data->action)
|
|
|
|
|
{
|
|
|
|
|
case LSA_ACTION_FLOOD_AREA:
|
|
|
|
|
ospf_flood_through_area (data->area, NULL, data->lsa);
|
|
|
|
|
break;
|
|
|
|
|
case LSA_ACTION_FLUSH_AREA:
|
|
|
|
|
ospf_lsa_flush_area (data->lsa, data->area);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2006-07-26 11:37:26 +02:00
|
|
|
|
ospf_lsa_unlock (&data->lsa); /* Message */
|
2002-12-13 21:15:29 +01:00
|
|
|
|
XFREE (MTYPE_OSPF_MESSAGE, data);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
ospf_schedule_lsa_flood_area (struct ospf_area *area, struct ospf_lsa *lsa)
|
|
|
|
|
{
|
|
|
|
|
struct lsa_action *data;
|
|
|
|
|
|
2008-08-18 23:13:29 +02:00
|
|
|
|
data = XCALLOC (MTYPE_OSPF_MESSAGE, sizeof (struct lsa_action));
|
2002-12-13 21:15:29 +01:00
|
|
|
|
data->action = LSA_ACTION_FLOOD_AREA;
|
|
|
|
|
data->area = area;
|
2006-07-26 11:37:26 +02:00
|
|
|
|
data->lsa = ospf_lsa_lock (lsa); /* Message / Flood area */
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
|
|
thread_add_event (master, ospf_lsa_action, data, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
ospf_schedule_lsa_flush_area (struct ospf_area *area, struct ospf_lsa *lsa)
|
|
|
|
|
{
|
|
|
|
|
struct lsa_action *data;
|
|
|
|
|
|
2008-08-18 23:13:29 +02:00
|
|
|
|
data = XCALLOC (MTYPE_OSPF_MESSAGE, sizeof (struct lsa_action));
|
2002-12-13 21:15:29 +01:00
|
|
|
|
data->action = LSA_ACTION_FLUSH_AREA;
|
|
|
|
|
data->area = area;
|
2006-07-26 11:37:26 +02:00
|
|
|
|
data->lsa = ospf_lsa_lock (lsa); /* Message / Flush area */
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
|
|
thread_add_event (master, ospf_lsa_action, data, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* LSA Refreshment functions. */
|
2005-05-06 23:37:42 +02:00
|
|
|
|
static void
|
2003-03-25 06:07:42 +01:00
|
|
|
|
ospf_lsa_refresh (struct ospf *ospf, struct ospf_lsa *lsa)
|
2002-12-13 21:15:29 +01:00
|
|
|
|
{
|
|
|
|
|
struct external_info *ei;
|
|
|
|
|
assert (CHECK_FLAG (lsa->flags, OSPF_LSA_SELF));
|
|
|
|
|
|
|
|
|
|
switch (lsa->data->type)
|
|
|
|
|
{
|
|
|
|
|
/* Router and Network LSAs are processed differently. */
|
|
|
|
|
case OSPF_ROUTER_LSA:
|
|
|
|
|
case OSPF_NETWORK_LSA:
|
|
|
|
|
break;
|
|
|
|
|
case OSPF_SUMMARY_LSA:
|
2003-03-25 06:07:42 +01:00
|
|
|
|
ospf_summary_lsa_refresh (ospf, lsa);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
break;
|
|
|
|
|
case OSPF_ASBR_SUMMARY_LSA:
|
2003-03-25 06:07:42 +01:00
|
|
|
|
ospf_summary_asbr_lsa_refresh (ospf, lsa);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
break;
|
|
|
|
|
case OSPF_AS_EXTERNAL_LSA:
|
2003-07-12 23:30:57 +02:00
|
|
|
|
/* 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))
|
|
|
|
|
break;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
ei = ospf_external_info_check (lsa);
|
|
|
|
|
if (ei)
|
2003-07-12 23:30:57 +02:00
|
|
|
|
ospf_external_lsa_refresh (ospf, lsa, ei, LSA_REFRESH_FORCE);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
else
|
2003-07-12 23:30:57 +02:00
|
|
|
|
ospf_lsa_flush_as (ospf, lsa);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
break;
|
|
|
|
|
#ifdef HAVE_OPAQUE_LSA
|
|
|
|
|
case OSPF_OPAQUE_LINK_LSA:
|
|
|
|
|
case OSPF_OPAQUE_AREA_LSA:
|
|
|
|
|
case OSPF_OPAQUE_AS_LSA:
|
|
|
|
|
ospf_opaque_lsa_refresh (lsa);
|
|
|
|
|
break;
|
2003-05-16 19:31:51 +02:00
|
|
|
|
#endif /* HAVE_OPAQUE_LSA */
|
2002-12-13 21:15:29 +01:00
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
2003-03-25 06:07:42 +01:00
|
|
|
|
ospf_refresher_register_lsa (struct ospf *ospf, struct ospf_lsa *lsa)
|
2002-12-13 21:15:29 +01:00
|
|
|
|
{
|
|
|
|
|
u_int16_t index, current_index;
|
|
|
|
|
|
|
|
|
|
assert (CHECK_FLAG (lsa->flags, OSPF_LSA_SELF));
|
|
|
|
|
|
|
|
|
|
if (lsa->refresh_list < 0)
|
|
|
|
|
{
|
|
|
|
|
int delay;
|
|
|
|
|
|
|
|
|
|
if (LS_AGE (lsa) == 0 &&
|
|
|
|
|
ntohl (lsa->data->ls_seqnum) == OSPF_INITIAL_SEQUENCE_NUMBER)
|
|
|
|
|
/* 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));
|
|
|
|
|
|
|
|
|
|
if (delay < 0)
|
|
|
|
|
delay = 0;
|
|
|
|
|
|
2003-03-25 06:07:42 +01:00
|
|
|
|
current_index = ospf->lsa_refresh_queue.index +
|
2006-08-27 08:49:29 +02:00
|
|
|
|
(quagga_time (NULL) - ospf->lsa_refresher_started)/OSPF_LSA_REFRESHER_GRANULARITY;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
|
|
index = (current_index + delay/OSPF_LSA_REFRESHER_GRANULARITY)
|
|
|
|
|
% (OSPF_LSA_REFRESHER_SLOTS);
|
|
|
|
|
|
|
|
|
|
if (IS_DEBUG_OSPF (lsa, LSA_REFRESH))
|
2004-12-08 19:12:06 +01:00
|
|
|
|
zlog_debug ("LSA[Refresh]: lsa %s with age %d added to index %d",
|
2003-07-12 23:30:57 +02:00
|
|
|
|
inet_ntoa (lsa->data->id), LS_AGE (lsa), index);
|
2003-03-25 06:07:42 +01:00
|
|
|
|
if (!ospf->lsa_refresh_queue.qs[index])
|
|
|
|
|
ospf->lsa_refresh_queue.qs[index] = list_new ();
|
2006-07-26 11:37:26 +02:00
|
|
|
|
listnode_add (ospf->lsa_refresh_queue.qs[index],
|
|
|
|
|
ospf_lsa_lock (lsa)); /* lsa_refresh_queue */
|
2002-12-13 21:15:29 +01:00
|
|
|
|
lsa->refresh_list = index;
|
2002-12-13 22:44:27 +01:00
|
|
|
|
if (IS_DEBUG_OSPF (lsa, LSA_REFRESH))
|
2004-12-08 19:12:06 +01:00
|
|
|
|
zlog_debug ("LSA[Refresh:%s]: ospf_refresher_register_lsa(): "
|
2003-07-12 23:30:57 +02:00
|
|
|
|
"setting refresh_list on lsa %p (slod %d)",
|
|
|
|
|
inet_ntoa (lsa->data->id), lsa, index);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
2003-03-25 06:07:42 +01:00
|
|
|
|
ospf_refresher_unregister_lsa (struct ospf *ospf, struct ospf_lsa *lsa)
|
2002-12-13 21:15:29 +01:00
|
|
|
|
{
|
|
|
|
|
assert (CHECK_FLAG (lsa->flags, OSPF_LSA_SELF));
|
|
|
|
|
if (lsa->refresh_list >= 0)
|
|
|
|
|
{
|
2004-09-23 21:18:23 +02:00
|
|
|
|
struct list *refresh_list = ospf->lsa_refresh_queue.qs[lsa->refresh_list];
|
2002-12-13 21:15:29 +01:00
|
|
|
|
listnode_delete (refresh_list, lsa);
|
|
|
|
|
if (!listcount (refresh_list))
|
|
|
|
|
{
|
|
|
|
|
list_free (refresh_list);
|
2003-03-25 06:07:42 +01:00
|
|
|
|
ospf->lsa_refresh_queue.qs[lsa->refresh_list] = NULL;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
}
|
2006-07-26 11:37:26 +02:00
|
|
|
|
ospf_lsa_unlock (&lsa); /* lsa_refresh_queue */
|
2002-12-13 21:15:29 +01:00
|
|
|
|
lsa->refresh_list = -1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
ospf_lsa_refresh_walker (struct thread *t)
|
|
|
|
|
{
|
2004-09-23 21:18:23 +02:00
|
|
|
|
struct list *refresh_list;
|
2005-04-07 Paul Jakma <paul.jakma@sun.com>
* (global): Fix up list loops to match changes in lib/linklist,
and some basic auditing of usage.
* configure.ac: define QUAGGA_NO_DEPRECATED_INTERFACES
* HACKING: Add notes about deprecating interfaces and commands.
* lib/linklist.h: Add usage comments.
Rename getdata macro to listgetdata.
Rename nextnode to listnextnode and fix its odd behaviour to be
less dangerous.
Make listgetdata macro assert node is not null, NULL list entries
should be bug condition.
ALL_LIST_ELEMENTS, new macro, forward-referencing macro for use
with for loop, Suggested by Jim Carlson of Sun.
Add ALL_LIST_ELEMENTS_RO for cases which obviously do not need the
"safety" of previous macro.
LISTNODE_ADD and DELETE macros renamed to ATTACH, DETACH, to
distinguish from the similarly named functions, and reflect their
effect better.
Add a QUAGGA_NO_DEPRECATED_INTERFACES define guarded section
with the old defines which were modified above,
for backwards compatibility - guarded to prevent Quagga using it..
* lib/linklist.c: fix up for linklist.h changes.
* ospf6d/ospf6_abr.c: (ospf6_abr_examin_brouter) change to a single
scan of the area list, rather than scanning all areas first for
INTER_ROUTER and then again for INTER_NETWORK. According to
16.2, the scan should be area specific anyway, and further
ospf6d does not seem to implement 16.3 anyway.
2005-04-07 09:30:20 +02:00
|
|
|
|
struct listnode *node, *nnode;
|
2003-03-25 06:07:42 +01:00
|
|
|
|
struct ospf *ospf = THREAD_ARG (t);
|
2005-04-07 Paul Jakma <paul.jakma@sun.com>
* (global): Fix up list loops to match changes in lib/linklist,
and some basic auditing of usage.
* configure.ac: define QUAGGA_NO_DEPRECATED_INTERFACES
* HACKING: Add notes about deprecating interfaces and commands.
* lib/linklist.h: Add usage comments.
Rename getdata macro to listgetdata.
Rename nextnode to listnextnode and fix its odd behaviour to be
less dangerous.
Make listgetdata macro assert node is not null, NULL list entries
should be bug condition.
ALL_LIST_ELEMENTS, new macro, forward-referencing macro for use
with for loop, Suggested by Jim Carlson of Sun.
Add ALL_LIST_ELEMENTS_RO for cases which obviously do not need the
"safety" of previous macro.
LISTNODE_ADD and DELETE macros renamed to ATTACH, DETACH, to
distinguish from the similarly named functions, and reflect their
effect better.
Add a QUAGGA_NO_DEPRECATED_INTERFACES define guarded section
with the old defines which were modified above,
for backwards compatibility - guarded to prevent Quagga using it..
* lib/linklist.c: fix up for linklist.h changes.
* ospf6d/ospf6_abr.c: (ospf6_abr_examin_brouter) change to a single
scan of the area list, rather than scanning all areas first for
INTER_ROUTER and then again for INTER_NETWORK. According to
16.2, the scan should be area specific anyway, and further
ospf6d does not seem to implement 16.3 anyway.
2005-04-07 09:30:20 +02:00
|
|
|
|
struct ospf_lsa *lsa;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
int i;
|
2004-09-23 21:18:23 +02:00
|
|
|
|
struct list *lsa_to_refresh = list_new ();
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
|
|
if (IS_DEBUG_OSPF (lsa, LSA_REFRESH))
|
2004-12-08 19:12:06 +01:00
|
|
|
|
zlog_debug ("LSA[Refresh]:ospf_lsa_refresh_walker(): start");
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
|
|
|
2003-03-25 06:07:42 +01:00
|
|
|
|
i = ospf->lsa_refresh_queue.index;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
2005-03-13 20:27:22 +01:00
|
|
|
|
/* 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. */
|
2003-03-25 06:07:42 +01:00
|
|
|
|
ospf->lsa_refresh_queue.index =
|
2005-03-13 20:27:22 +01:00
|
|
|
|
((unsigned long)(ospf->lsa_refresh_queue.index +
|
2006-08-27 08:49:29 +02:00
|
|
|
|
(quagga_time (NULL) - ospf->lsa_refresher_started) /
|
2005-03-13 20:27:22 +01:00
|
|
|
|
OSPF_LSA_REFRESHER_GRANULARITY)) % OSPF_LSA_REFRESHER_SLOTS;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
|
|
if (IS_DEBUG_OSPF (lsa, LSA_REFRESH))
|
2004-12-08 19:12:06 +01:00
|
|
|
|
zlog_debug ("LSA[Refresh]: ospf_lsa_refresh_walker(): next index %d",
|
2003-03-25 06:07:42 +01:00
|
|
|
|
ospf->lsa_refresh_queue.index);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
2003-03-25 06:07:42 +01:00
|
|
|
|
for (;i != ospf->lsa_refresh_queue.index;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
i = (i + 1) % OSPF_LSA_REFRESHER_SLOTS)
|
|
|
|
|
{
|
|
|
|
|
if (IS_DEBUG_OSPF (lsa, LSA_REFRESH))
|
2004-12-08 19:12:06 +01:00
|
|
|
|
zlog_debug ("LSA[Refresh]: ospf_lsa_refresh_walker(): "
|
2003-07-12 23:30:57 +02:00
|
|
|
|
"refresh index %d", i);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
2003-03-25 06:07:42 +01:00
|
|
|
|
refresh_list = ospf->lsa_refresh_queue.qs [i];
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
2003-03-25 06:07:42 +01:00
|
|
|
|
ospf->lsa_refresh_queue.qs [i] = NULL;
|
|
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
|
if (refresh_list)
|
|
|
|
|
{
|
2005-04-07 Paul Jakma <paul.jakma@sun.com>
* (global): Fix up list loops to match changes in lib/linklist,
and some basic auditing of usage.
* configure.ac: define QUAGGA_NO_DEPRECATED_INTERFACES
* HACKING: Add notes about deprecating interfaces and commands.
* lib/linklist.h: Add usage comments.
Rename getdata macro to listgetdata.
Rename nextnode to listnextnode and fix its odd behaviour to be
less dangerous.
Make listgetdata macro assert node is not null, NULL list entries
should be bug condition.
ALL_LIST_ELEMENTS, new macro, forward-referencing macro for use
with for loop, Suggested by Jim Carlson of Sun.
Add ALL_LIST_ELEMENTS_RO for cases which obviously do not need the
"safety" of previous macro.
LISTNODE_ADD and DELETE macros renamed to ATTACH, DETACH, to
distinguish from the similarly named functions, and reflect their
effect better.
Add a QUAGGA_NO_DEPRECATED_INTERFACES define guarded section
with the old defines which were modified above,
for backwards compatibility - guarded to prevent Quagga using it..
* lib/linklist.c: fix up for linklist.h changes.
* ospf6d/ospf6_abr.c: (ospf6_abr_examin_brouter) change to a single
scan of the area list, rather than scanning all areas first for
INTER_ROUTER and then again for INTER_NETWORK. According to
16.2, the scan should be area specific anyway, and further
ospf6d does not seem to implement 16.3 anyway.
2005-04-07 09:30:20 +02:00
|
|
|
|
for (ALL_LIST_ELEMENTS (refresh_list, node, nnode, lsa))
|
2002-12-13 21:15:29 +01:00
|
|
|
|
{
|
|
|
|
|
if (IS_DEBUG_OSPF (lsa, LSA_REFRESH))
|
2004-12-08 19:12:06 +01:00
|
|
|
|
zlog_debug ("LSA[Refresh:%s]: ospf_lsa_refresh_walker(): "
|
2003-07-12 23:30:57 +02:00
|
|
|
|
"refresh lsa %p (slot %d)",
|
|
|
|
|
inet_ntoa (lsa->data->id), lsa, i);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
|
|
list_delete_node (refresh_list, node);
|
2006-07-26 11:37:26 +02:00
|
|
|
|
ospf_lsa_unlock (&lsa); /* lsa_refresh_queue */
|
2002-12-13 21:15:29 +01:00
|
|
|
|
lsa->refresh_list = -1;
|
|
|
|
|
listnode_add (lsa_to_refresh, lsa);
|
|
|
|
|
}
|
|
|
|
|
list_free (refresh_list);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2003-03-25 06:07:42 +01:00
|
|
|
|
ospf->t_lsa_refresher = thread_add_timer (master, ospf_lsa_refresh_walker,
|
|
|
|
|
ospf, ospf->lsa_refresh_interval);
|
2006-08-27 08:49:29 +02:00
|
|
|
|
ospf->lsa_refresher_started = quagga_time (NULL);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
2005-04-07 Paul Jakma <paul.jakma@sun.com>
* (global): Fix up list loops to match changes in lib/linklist,
and some basic auditing of usage.
* configure.ac: define QUAGGA_NO_DEPRECATED_INTERFACES
* HACKING: Add notes about deprecating interfaces and commands.
* lib/linklist.h: Add usage comments.
Rename getdata macro to listgetdata.
Rename nextnode to listnextnode and fix its odd behaviour to be
less dangerous.
Make listgetdata macro assert node is not null, NULL list entries
should be bug condition.
ALL_LIST_ELEMENTS, new macro, forward-referencing macro for use
with for loop, Suggested by Jim Carlson of Sun.
Add ALL_LIST_ELEMENTS_RO for cases which obviously do not need the
"safety" of previous macro.
LISTNODE_ADD and DELETE macros renamed to ATTACH, DETACH, to
distinguish from the similarly named functions, and reflect their
effect better.
Add a QUAGGA_NO_DEPRECATED_INTERFACES define guarded section
with the old defines which were modified above,
for backwards compatibility - guarded to prevent Quagga using it..
* lib/linklist.c: fix up for linklist.h changes.
* ospf6d/ospf6_abr.c: (ospf6_abr_examin_brouter) change to a single
scan of the area list, rather than scanning all areas first for
INTER_ROUTER and then again for INTER_NETWORK. According to
16.2, the scan should be area specific anyway, and further
ospf6d does not seem to implement 16.3 anyway.
2005-04-07 09:30:20 +02:00
|
|
|
|
for (ALL_LIST_ELEMENTS (lsa_to_refresh, node, nnode, lsa))
|
|
|
|
|
ospf_lsa_refresh (ospf, lsa);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
|
|
list_delete (lsa_to_refresh);
|
|
|
|
|
|
|
|
|
|
if (IS_DEBUG_OSPF (lsa, LSA_REFRESH))
|
2004-12-08 19:12:06 +01:00
|
|
|
|
zlog_debug ("LSA[Refresh]: ospf_lsa_refresh_walker(): end");
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|