mirror of
https://git.proxmox.com/git/mirror_frr
synced 2026-01-06 10:57:38 +00:00
Merge remote-tracking branch 'savannah/sf/ospfd'
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
This commit is contained in:
commit
b2e5bdbe10
46
lib/vty.h
46
lib/vty.h
@ -149,8 +149,8 @@ struct vty
|
||||
#define PRINTF_ATTRIBUTE(a,b)
|
||||
#endif /* __GNUC__ */
|
||||
|
||||
/* Utility macros to convert VTY argument to unsigned long or integer. */
|
||||
#define VTY_GET_LONG(NAME,V,STR) \
|
||||
/* Utility macros to convert VTY argument to unsigned long */
|
||||
#define VTY_GET_ULONG(NAME,V,STR) \
|
||||
do { \
|
||||
char *endptr = NULL; \
|
||||
errno = 0; \
|
||||
@ -162,20 +162,38 @@ do { \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define VTY_GET_INTEGER_RANGE(NAME,V,STR,MIN,MAX) \
|
||||
do { \
|
||||
unsigned long tmpl; \
|
||||
VTY_GET_LONG(NAME, tmpl, STR); \
|
||||
if ( (tmpl < (MIN)) || (tmpl > (MAX))) \
|
||||
{ \
|
||||
vty_out (vty, "%% Invalid %s value%s", NAME, VTY_NEWLINE); \
|
||||
return CMD_WARNING; \
|
||||
} \
|
||||
(V) = tmpl; \
|
||||
/*
|
||||
* The logic below ((TMPL) <= ((MIN) && (TMPL) != (MIN)) is
|
||||
* done to circumvent the compiler complaining about
|
||||
* comparing unsigned numbers against zero, if MIN is zero.
|
||||
* NB: The compiler isn't smart enough to supress the warning
|
||||
* if you write (MIN) != 0 && tmpl < (MIN).
|
||||
*/
|
||||
#define VTY_GET_INTEGER_RANGE_HEART(NAME,TMPL,STR,MIN,MAX) \
|
||||
do { \
|
||||
VTY_GET_ULONG(NAME, (TMPL), STR); \
|
||||
if ( ((TMPL) <= (MIN) && (TMPL) != (MIN)) || (TMPL) > (MAX) ) \
|
||||
{ \
|
||||
vty_out (vty, "%% Invalid %s value%s", NAME, VTY_NEWLINE);\
|
||||
return CMD_WARNING; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define VTY_GET_INTEGER(NAME,V,STR) \
|
||||
VTY_GET_INTEGER_RANGE(NAME,V,STR,0U,UINT32_MAX)
|
||||
#define VTY_GET_INTEGER_RANGE(NAME,V,STR,MIN,MAX) \
|
||||
do { \
|
||||
unsigned long tmpl; \
|
||||
VTY_GET_INTEGER_RANGE_HEART(NAME,tmpl,STR,MIN,MAX); \
|
||||
(V) = tmpl; \
|
||||
} while (0)
|
||||
|
||||
#define VTY_CHECK_INTEGER_RANGE(NAME,STR,MIN,MAX) \
|
||||
do { \
|
||||
unsigned long tmpl; \
|
||||
VTY_GET_INTEGER_RANGE_HEART(NAME,tmpl,STR,MIN,MAX); \
|
||||
} while (0)
|
||||
|
||||
#define VTY_GET_INTEGER(NAME,V,STR) \
|
||||
VTY_GET_INTEGER_RANGE(NAME,V,STR,0U,UINT32_MAX)
|
||||
|
||||
#define VTY_GET_IPV4_ADDRESS(NAME,V,STR) \
|
||||
do { \
|
||||
|
||||
@ -1140,7 +1140,8 @@ ospf_abr_announce_rtr_to_area (struct prefix_ipv4 *p, u_int32_t cost,
|
||||
GET_METRIC (slsa->metric), cost);
|
||||
}
|
||||
|
||||
if (old && (GET_METRIC (slsa->metric) == cost))
|
||||
if (old && (GET_METRIC (slsa->metric) == cost) &&
|
||||
((old->flags & OSPF_LSA_IN_MAXAGE) == 0))
|
||||
{
|
||||
if (IS_DEBUG_OSPF_EVENT)
|
||||
zlog_debug ("ospf_abr_announce_rtr_to_area(): old summary approved");
|
||||
|
||||
@ -299,13 +299,10 @@ void
|
||||
ospf_apiserver_event (enum event event, int fd,
|
||||
struct ospf_apiserver *apiserv)
|
||||
{
|
||||
struct thread *apiserver_serv_thread;
|
||||
|
||||
switch (event)
|
||||
{
|
||||
case OSPF_APISERVER_ACCEPT:
|
||||
apiserver_serv_thread =
|
||||
thread_add_read (master, ospf_apiserver_accept, apiserv, fd);
|
||||
(void)thread_add_read (master, ospf_apiserver_accept, apiserv, fd);
|
||||
break;
|
||||
case OSPF_APISERVER_SYNC_READ:
|
||||
apiserv->t_sync_read =
|
||||
|
||||
@ -203,7 +203,6 @@ ospf_dr_election (struct ospf_interface *oi)
|
||||
struct in_addr old_dr, old_bdr;
|
||||
int old_state, new_state;
|
||||
struct list *el_list;
|
||||
struct ospf_neighbor *dr, *bdr;
|
||||
|
||||
/* backup current values. */
|
||||
old_dr = DR (oi);
|
||||
@ -216,8 +215,8 @@ ospf_dr_election (struct ospf_interface *oi)
|
||||
ospf_dr_eligible_routers (oi->nbrs, el_list);
|
||||
|
||||
/* First election of DR and BDR. */
|
||||
bdr = ospf_elect_bdr (oi, el_list);
|
||||
dr = ospf_elect_dr (oi, el_list);
|
||||
ospf_elect_bdr (oi, el_list);
|
||||
ospf_elect_dr (oi, el_list);
|
||||
|
||||
new_state = ospf_ism_state (oi);
|
||||
|
||||
|
||||
@ -1340,12 +1340,8 @@ static void
|
||||
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);
|
||||
stream_put_ipv4 (s, (u_int32_t) 0);
|
||||
|
||||
/* Set # TOS. */
|
||||
stream_putc (s, (u_char) 0);
|
||||
@ -2737,7 +2733,9 @@ ospf_lsa_install (struct ospf *ospf, struct ospf_interface *oi,
|
||||
if (IS_LSA_SELF (lsa))
|
||||
lsa->oi = oi; /* Specify outgoing ospf-interface for this LSA. */
|
||||
else
|
||||
; /* Incoming "oi" for this LSA has set at LSUpd reception. */
|
||||
{
|
||||
/* Incoming "oi" for this LSA has set at LSUpd reception. */
|
||||
}
|
||||
/* Fallthrough */
|
||||
case OSPF_OPAQUE_AREA_LSA:
|
||||
case OSPF_OPAQUE_AS_LSA:
|
||||
@ -2782,15 +2780,14 @@ ospf_lsa_install (struct ospf *ospf, struct ospf_interface *oi,
|
||||
If received LSA' ls_age is MaxAge, or lsa is being prematurely aged
|
||||
(it's getting flushed out of the area), set LSA on MaxAge LSA list.
|
||||
*/
|
||||
if ((lsa->flags & OSPF_LSA_PREMATURE_AGE) ||
|
||||
(IS_LSA_MAXAGE (new) && !IS_LSA_SELF (new)))
|
||||
if (IS_LSA_MAXAGE (new))
|
||||
{
|
||||
if (IS_DEBUG_OSPF (lsa, LSA_INSTALL))
|
||||
zlog_debug ("LSA[Type%d:%s]: Install LSA 0x%p, MaxAge",
|
||||
new->data->type,
|
||||
inet_ntoa (new->data->id),
|
||||
lsa);
|
||||
ospf_lsa_flush (ospf, lsa);
|
||||
ospf_lsa_maxage (ospf, lsa);
|
||||
}
|
||||
|
||||
return new;
|
||||
@ -2828,7 +2825,7 @@ ospf_maxage_lsa_remover (struct thread *thread)
|
||||
{
|
||||
struct ospf *ospf = THREAD_ARG (thread);
|
||||
struct ospf_lsa *lsa;
|
||||
struct listnode *node, *nnode;
|
||||
struct route_node *rn;
|
||||
int reschedule = 0;
|
||||
|
||||
ospf->t_maxage = NULL;
|
||||
@ -2839,8 +2836,13 @@ ospf_maxage_lsa_remover (struct thread *thread)
|
||||
reschedule = !ospf_check_nbr_status (ospf);
|
||||
|
||||
if (!reschedule)
|
||||
for (ALL_LIST_ELEMENTS (ospf->maxage_lsa, node, nnode, lsa))
|
||||
for (rn = route_top(ospf->maxage_lsa); rn; rn = route_next(rn))
|
||||
{
|
||||
if ((lsa = rn->info) == NULL)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (lsa->retransmit_counter > 0)
|
||||
{
|
||||
reschedule = 1;
|
||||
@ -2893,13 +2895,22 @@ ospf_maxage_lsa_remover (struct thread *thread)
|
||||
void
|
||||
ospf_lsa_maxage_delete (struct ospf *ospf, struct ospf_lsa *lsa)
|
||||
{
|
||||
struct listnode *n;
|
||||
struct route_node *rn;
|
||||
struct prefix_ls lsa_prefix;
|
||||
|
||||
if ((n = listnode_lookup (ospf->maxage_lsa, lsa)))
|
||||
ls_prefix_set (&lsa_prefix, lsa);
|
||||
|
||||
if ((rn = route_node_lookup(ospf->maxage_lsa,
|
||||
(struct prefix *)&lsa_prefix)))
|
||||
{
|
||||
list_delete_node (ospf->maxage_lsa, n);
|
||||
UNSET_FLAG(lsa->flags, OSPF_LSA_IN_MAXAGE);
|
||||
ospf_lsa_unlock (&lsa); /* maxage_lsa */
|
||||
if (rn->info == lsa)
|
||||
{
|
||||
UNSET_FLAG(lsa->flags, OSPF_LSA_IN_MAXAGE);
|
||||
ospf_lsa_unlock (&lsa); /* maxage_lsa */
|
||||
rn->info = NULL;
|
||||
route_unlock_node (rn); /* route_node_lookup */
|
||||
}
|
||||
route_unlock_node (rn); /* route_node_lookup */
|
||||
}
|
||||
}
|
||||
|
||||
@ -2911,6 +2922,9 @@ ospf_lsa_maxage_delete (struct ospf *ospf, struct ospf_lsa *lsa)
|
||||
void
|
||||
ospf_lsa_maxage (struct ospf *ospf, struct ospf_lsa *lsa)
|
||||
{
|
||||
struct prefix_ls lsa_prefix;
|
||||
struct route_node *rn;
|
||||
|
||||
/* When we saw a MaxAge LSA flooded to us, we put it on the list
|
||||
and schedule the MaxAge LSA remover. */
|
||||
if (CHECK_FLAG(lsa->flags, OSPF_LSA_IN_MAXAGE))
|
||||
@ -2921,8 +2935,25 @@ ospf_lsa_maxage (struct ospf *ospf, struct ospf_lsa *lsa)
|
||||
return;
|
||||
}
|
||||
|
||||
listnode_add (ospf->maxage_lsa, ospf_lsa_lock (lsa));
|
||||
SET_FLAG(lsa->flags, OSPF_LSA_IN_MAXAGE);
|
||||
ls_prefix_set (&lsa_prefix, lsa);
|
||||
if ((rn = route_node_get (ospf->maxage_lsa,
|
||||
(struct prefix *)&lsa_prefix)) != NULL)
|
||||
{
|
||||
if (rn->info != NULL)
|
||||
{
|
||||
route_unlock_node (rn);
|
||||
}
|
||||
else
|
||||
{
|
||||
rn->info = ospf_lsa_lock(lsa);
|
||||
SET_FLAG(lsa->flags, OSPF_LSA_IN_MAXAGE);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
zlog_err("Unable to allocate memory for maxage lsa\n");
|
||||
assert(0);
|
||||
}
|
||||
|
||||
if (IS_DEBUG_OSPF (lsa, LSA_FLOODING))
|
||||
zlog_debug ("LSA[%s]: MaxAge LSA remover scheduled.", dump_lsa_key (lsa));
|
||||
|
||||
@ -243,6 +243,7 @@ extern int tv_cmp (struct timeval, struct timeval);
|
||||
|
||||
extern int get_age (struct ospf_lsa *);
|
||||
extern u_int16_t ospf_lsa_checksum (struct lsa_header *);
|
||||
extern int ospf_lsa_checksum_valid (struct lsa_header *);
|
||||
extern int ospf_lsa_refresh_delay (struct ospf_lsa *);
|
||||
|
||||
extern const char *dump_lsa_key (struct ospf_lsa *);
|
||||
|
||||
@ -72,13 +72,16 @@ ospf_lsdb_cleanup (struct ospf_lsdb *lsdb)
|
||||
route_table_finish (lsdb->type[i].db);
|
||||
}
|
||||
|
||||
static void
|
||||
lsdb_prefix_set (struct prefix_ls *lp, struct ospf_lsa *lsa)
|
||||
void
|
||||
ls_prefix_set (struct prefix_ls *lp, struct ospf_lsa *lsa)
|
||||
{
|
||||
lp->family = 0;
|
||||
lp->prefixlen = 64;
|
||||
lp->id = lsa->data->id;
|
||||
lp->adv_router = lsa->data->adv_router;
|
||||
if (lp && lsa && lsa->data)
|
||||
{
|
||||
lp->family = 0;
|
||||
lp->prefixlen = 64;
|
||||
lp->id = lsa->data->id;
|
||||
lp->adv_router = lsa->data->adv_router;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
@ -115,7 +118,7 @@ ospf_lsdb_add (struct ospf_lsdb *lsdb, struct ospf_lsa *lsa)
|
||||
struct route_node *rn;
|
||||
|
||||
table = lsdb->type[lsa->data->type].db;
|
||||
lsdb_prefix_set (&lp, lsa);
|
||||
ls_prefix_set (&lp, lsa);
|
||||
rn = route_node_get (table, (struct prefix *)&lp);
|
||||
|
||||
/* nothing to do? */
|
||||
@ -167,7 +170,7 @@ ospf_lsdb_delete (struct ospf_lsdb *lsdb, struct ospf_lsa *lsa)
|
||||
|
||||
assert (lsa->data->type < OSPF_MAX_LSA);
|
||||
table = lsdb->type[lsa->data->type].db;
|
||||
lsdb_prefix_set (&lp, lsa);
|
||||
ls_prefix_set (&lp, lsa);
|
||||
if ((rn = route_node_lookup (table, (struct prefix *) &lp)))
|
||||
{
|
||||
if (rn->info == lsa)
|
||||
@ -218,7 +221,7 @@ ospf_lsdb_lookup (struct ospf_lsdb *lsdb, struct ospf_lsa *lsa)
|
||||
struct ospf_lsa *find;
|
||||
|
||||
table = lsdb->type[lsa->data->type].db;
|
||||
lsdb_prefix_set (&lp, lsa);
|
||||
ls_prefix_set (&lp, lsa);
|
||||
rn = route_node_lookup (table, (struct prefix *) &lp);
|
||||
if (rn)
|
||||
{
|
||||
|
||||
@ -66,6 +66,7 @@ extern struct ospf_lsdb *ospf_lsdb_new (void);
|
||||
extern void ospf_lsdb_init (struct ospf_lsdb *);
|
||||
extern void ospf_lsdb_free (struct ospf_lsdb *);
|
||||
extern void ospf_lsdb_cleanup (struct ospf_lsdb *);
|
||||
extern void ls_prefix_set (struct prefix_ls *lp, struct ospf_lsa *lsa);
|
||||
extern void ospf_lsdb_add (struct ospf_lsdb *, struct ospf_lsa *);
|
||||
extern void ospf_lsdb_delete (struct ospf_lsdb *, struct ospf_lsa *);
|
||||
extern void ospf_lsdb_delete_all (struct ospf_lsdb *);
|
||||
|
||||
@ -191,6 +191,11 @@ main (int argc, char **argv)
|
||||
/* Set umask before anything for security */
|
||||
umask (0027);
|
||||
|
||||
#ifdef SUPPORT_OSPF_API
|
||||
/* OSPF apiserver is disabled by default. */
|
||||
ospf_apiserver_enable = 0;
|
||||
#endif /* SUPPORT_OSPF_API */
|
||||
|
||||
/* get program name */
|
||||
progname = ((p = strrchr (argv[0], '/')) ? ++p : argv[0]);
|
||||
|
||||
@ -275,11 +280,6 @@ main (int argc, char **argv)
|
||||
/* OSPF master init. */
|
||||
ospf_master_init ();
|
||||
|
||||
#ifdef SUPPORT_OSPF_API
|
||||
/* OSPF apiserver is disabled by default. */
|
||||
ospf_apiserver_enable = 0;
|
||||
#endif /* SUPPORT_OSPF_API */
|
||||
|
||||
/* Initializations. */
|
||||
master = om->master;
|
||||
|
||||
|
||||
@ -228,7 +228,7 @@ ospf_sock_init (void)
|
||||
}
|
||||
|
||||
void
|
||||
ospf_adjust_sndbuflen (struct ospf * ospf, int buflen)
|
||||
ospf_adjust_sndbuflen (struct ospf * ospf, unsigned int buflen)
|
||||
{
|
||||
int ret, newbuflen;
|
||||
/* Check if any work has to be done at all. */
|
||||
@ -249,11 +249,11 @@ ospf_adjust_sndbuflen (struct ospf * ospf, int buflen)
|
||||
*/
|
||||
ret = setsockopt_so_sendbuf (ospf->fd, buflen);
|
||||
newbuflen = getsockopt_so_sendbuf (ospf->fd);
|
||||
if (ret < 0 || newbuflen < buflen)
|
||||
zlog_warn ("%s: tried to set SO_SNDBUF to %d, but got %d",
|
||||
if (ret < 0 || newbuflen < 0 || newbuflen < (int) buflen)
|
||||
zlog_warn ("%s: tried to set SO_SNDBUF to %u, but got %d",
|
||||
__func__, buflen, newbuflen);
|
||||
if (newbuflen >= 0)
|
||||
ospf->maxsndbuflen = newbuflen;
|
||||
ospf->maxsndbuflen = (unsigned int)newbuflen;
|
||||
else
|
||||
zlog_warn ("%s: failed to get SO_SNDBUF", __func__);
|
||||
if (ospfd_privs.change (ZPRIVS_LOWER))
|
||||
|
||||
@ -34,6 +34,6 @@ extern int ospf_if_drop_alldrouters (struct ospf *, struct prefix *,
|
||||
unsigned int);
|
||||
extern int ospf_if_ipmulticast (struct ospf *, struct prefix *, unsigned int);
|
||||
extern int ospf_sock_init (void);
|
||||
extern void ospf_adjust_sndbuflen (struct ospf *, int);
|
||||
extern void ospf_adjust_sndbuflen (struct ospf *, unsigned int);
|
||||
|
||||
#endif /* _ZEBRA_OSPF_NETWORK_H */
|
||||
|
||||
@ -72,14 +72,11 @@ ospf_inactivity_timer (struct thread *thread)
|
||||
static int
|
||||
ospf_db_desc_timer (struct thread *thread)
|
||||
{
|
||||
struct ospf_interface *oi;
|
||||
struct ospf_neighbor *nbr;
|
||||
|
||||
nbr = THREAD_ARG (thread);
|
||||
nbr->t_db_desc = NULL;
|
||||
|
||||
oi = nbr->oi;
|
||||
|
||||
if (IS_DEBUG_OSPF (nsm, NSM_TIMERS))
|
||||
zlog (NULL, LOG_DEBUG, "NSM[%s:%s]: Timer (DD Retransmit timer expire)",
|
||||
IF_NAME (nbr->oi), inet_ntoa (nbr->src));
|
||||
@ -643,7 +640,7 @@ nsm_notice_state_change (struct ospf_neighbor *nbr, int next_state, int event)
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
nsm_change_state (struct ospf_neighbor *nbr, int state)
|
||||
{
|
||||
struct ospf_interface *oi = nbr->oi;
|
||||
@ -787,11 +784,9 @@ ospf_nsm_event (struct thread *thread)
|
||||
int event;
|
||||
int next_state;
|
||||
struct ospf_neighbor *nbr;
|
||||
struct in_addr router_id;
|
||||
|
||||
nbr = THREAD_ARG (thread);
|
||||
event = THREAD_VAL (thread);
|
||||
router_id = nbr->router_id;
|
||||
|
||||
if (IS_DEBUG_OSPF (nsm, NSM_EVENTS))
|
||||
zlog_debug ("NSM[%s:%s]: %s (%s)", IF_NAME (nbr->oi),
|
||||
|
||||
@ -81,7 +81,6 @@
|
||||
|
||||
/* Prototypes. */
|
||||
extern int ospf_nsm_event (struct thread *);
|
||||
extern void nsm_change_state (struct ospf_neighbor *, int);
|
||||
extern void ospf_check_nbr_loading (struct ospf_neighbor *);
|
||||
extern int ospf_db_summary_isempty (struct ospf_neighbor *);
|
||||
extern int ospf_db_summary_count (struct ospf_neighbor *);
|
||||
|
||||
@ -223,9 +223,15 @@ ospf_opaque_type_name (u_char opaque_type)
|
||||
default:
|
||||
if (OPAQUE_TYPE_RANGE_UNASSIGNED (opaque_type))
|
||||
name = "Unassigned";
|
||||
/* XXX warning: comparison is always true due to limited range of data type */
|
||||
else if (OPAQUE_TYPE_RANGE_RESERVED (opaque_type))
|
||||
name = "Private/Experimental";
|
||||
else
|
||||
{
|
||||
u_int32_t bigger_range = opaque_type;
|
||||
/*
|
||||
* Get around type-limits warning: comparison is always true due to limited range of data type
|
||||
*/
|
||||
if (OPAQUE_TYPE_RANGE_RESERVED (bigger_range))
|
||||
name = "Private/Experimental";
|
||||
}
|
||||
break;
|
||||
}
|
||||
return name;
|
||||
|
||||
@ -1761,7 +1761,11 @@ ospf_ls_upd (struct ip *iph, struct ospf_header *ospfh,
|
||||
ospf_lsa_discard (L); \
|
||||
continue; }
|
||||
|
||||
/* Process each LSA received in the one packet. */
|
||||
/* Process each LSA received in the one packet.
|
||||
*
|
||||
* Numbers in parentheses, e.g. (1), (2), etc., and the corresponding
|
||||
* text below are from the steps in RFC 2328, Section 13.
|
||||
*/
|
||||
for (ALL_LIST_ELEMENTS (lsas, node, nnode, lsa))
|
||||
{
|
||||
struct ospf_lsa *ls_ret, *current;
|
||||
@ -1785,11 +1789,11 @@ ospf_ls_upd (struct ip *iph, struct ospf_header *ospfh,
|
||||
|
||||
listnode_delete (lsas, lsa); /* We don't need it in list anymore */
|
||||
|
||||
/* Validate Checksum - Done above by ospf_ls_upd_list_lsa() */
|
||||
/* (1) Validate Checksum - Done above by ospf_ls_upd_list_lsa() */
|
||||
|
||||
/* LSA Type - Done above by ospf_ls_upd_list_lsa() */
|
||||
/* (2) LSA Type - Done above by ospf_ls_upd_list_lsa() */
|
||||
|
||||
/* Do not take in AS External LSAs if we are a stub or NSSA. */
|
||||
/* (3) Do not take in AS External LSAs if we are a stub or NSSA. */
|
||||
|
||||
/* Do not take in AS NSSA if this neighbor and we are not NSSA */
|
||||
|
||||
@ -1821,21 +1825,24 @@ ospf_ls_upd (struct ip *iph, struct ospf_header *ospfh,
|
||||
|
||||
current = ospf_lsa_lookup_by_header (oi->area, lsa->data);
|
||||
|
||||
/* If the LSA's LS age is equal to MaxAge, and there is currently
|
||||
/* (4) If the LSA's LS age is equal to MaxAge, and there is currently
|
||||
no instance of the LSA in the router's link state database,
|
||||
and none of router's neighbors are in states Exchange or Loading,
|
||||
then take the following actions. */
|
||||
then take the following actions: */
|
||||
|
||||
if (IS_LSA_MAXAGE (lsa) && !current &&
|
||||
(ospf_nbr_count (oi, NSM_Exchange) +
|
||||
ospf_nbr_count (oi, NSM_Loading)) == 0)
|
||||
{
|
||||
/* Response Link State Acknowledgment. */
|
||||
/* (4a) Response Link State Acknowledgment. */
|
||||
ospf_ls_ack_send (nbr, lsa);
|
||||
|
||||
/* Discard LSA. */
|
||||
zlog_info ("Link State Update[%s]: LS age is equal to MaxAge.",
|
||||
dump_lsa_key(lsa));
|
||||
/* (4b) Discard LSA. */
|
||||
if (IS_DEBUG_OSPF (lsa, LSA))
|
||||
{
|
||||
zlog_debug ("Link State Update[%s]: LS age is equal to MaxAge.",
|
||||
dump_lsa_key(lsa));
|
||||
}
|
||||
DISCARD_LSA (lsa, 3);
|
||||
}
|
||||
|
||||
@ -1890,7 +1897,7 @@ ospf_ls_upd (struct ip *iph, struct ospf_header *ospfh,
|
||||
#endif /* HAVE_OPAQUE_LSA */
|
||||
|
||||
/* It might be happen that received LSA is self-originated network LSA, but
|
||||
* router ID is cahnged. So, we should check if LSA is a network-LSA whose
|
||||
* router ID is changed. So, we should check if LSA is a network-LSA whose
|
||||
* Link State ID is one of the router's own IP interface addresses but whose
|
||||
* Advertising Router is not equal to the router's own Router ID
|
||||
* According to RFC 2328 12.4.2 and 13.4 this LSA should be flushed.
|
||||
@ -1929,7 +1936,9 @@ ospf_ls_upd (struct ip *iph, struct ospf_header *ospfh,
|
||||
/* (5) Find the instance of this LSA that is currently contained
|
||||
in the router's link state database. If there is no
|
||||
database copy, or the received LSA is more recent than
|
||||
the database copy the following steps must be performed. */
|
||||
the database copy the following steps must be performed.
|
||||
(The sub steps from RFC 2328 section 13 step (5) will be performed in
|
||||
ospf_flood() ) */
|
||||
|
||||
if (current == NULL ||
|
||||
(ret = ospf_lsa_more_recent (current, lsa)) < 0)
|
||||
|
||||
@ -126,6 +126,31 @@ ospf_route_table_free (struct route_table *rt)
|
||||
route_table_finish (rt);
|
||||
}
|
||||
|
||||
/* If a prefix exists in the new routing table, then return 1,
|
||||
otherwise return 0. Since the ZEBRA-RIB does an implicit
|
||||
withdraw, it is not necessary to send a delete, an add later
|
||||
will act like an implicit delete. */
|
||||
static int
|
||||
ospf_route_exist_new_table (struct route_table *rt, struct prefix_ipv4 *prefix)
|
||||
{
|
||||
struct route_node *rn;
|
||||
|
||||
assert (rt);
|
||||
assert (prefix);
|
||||
|
||||
rn = route_node_lookup (rt, (struct prefix *) prefix);
|
||||
if (!rn) {
|
||||
return 0;
|
||||
}
|
||||
route_unlock_node (rn);
|
||||
|
||||
if (!rn->info) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* If a prefix and a nexthop match any route in the routing table,
|
||||
then return 1, otherwise return 0. */
|
||||
int
|
||||
@ -223,13 +248,13 @@ ospf_route_delete_uniq (struct route_table *rt, struct route_table *cmprt)
|
||||
{
|
||||
if (or->type == OSPF_DESTINATION_NETWORK)
|
||||
{
|
||||
if (! ospf_route_match_same (cmprt,
|
||||
(struct prefix_ipv4 *) &rn->p, or))
|
||||
if (! ospf_route_exist_new_table (cmprt,
|
||||
(struct prefix_ipv4 *) &rn->p))
|
||||
ospf_zebra_delete ((struct prefix_ipv4 *) &rn->p, or);
|
||||
}
|
||||
else if (or->type == OSPF_DESTINATION_DISCARD)
|
||||
if (! ospf_route_match_same (cmprt,
|
||||
(struct prefix_ipv4 *) &rn->p, or))
|
||||
if (! ospf_route_exist_new_table (cmprt,
|
||||
(struct prefix_ipv4 *) &rn->p))
|
||||
ospf_zebra_delete_discard ((struct prefix_ipv4 *) &rn->p);
|
||||
}
|
||||
}
|
||||
|
||||
@ -443,12 +443,16 @@ static void *
|
||||
route_set_metric_compile (const char *arg)
|
||||
{
|
||||
u_int32_t *metric;
|
||||
int32_t ret;
|
||||
|
||||
metric = XCALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (u_int32_t));
|
||||
*metric = atoi (arg);
|
||||
ret = atoi (arg);
|
||||
|
||||
if (*metric >= 0)
|
||||
return metric;
|
||||
if (ret >= 0)
|
||||
{
|
||||
*metric = (u_int32_t)ret;
|
||||
return metric;
|
||||
}
|
||||
|
||||
XFREE (MTYPE_ROUTE_MAP_COMPILED, metric);
|
||||
return NULL;
|
||||
|
||||
@ -205,7 +205,7 @@ get_mpls_te_instance_value (void)
|
||||
{
|
||||
static u_int32_t seqno = 0;
|
||||
|
||||
if (LEGAL_TE_INSTANCE_RANGE (seqno + 1))
|
||||
if (seqno < MAX_LEGAL_TE_INSTANCE_NUM )
|
||||
seqno += 1;
|
||||
else
|
||||
seqno = 1; /* Avoid zero. */
|
||||
|
||||
@ -41,7 +41,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#define LEGAL_TE_INSTANCE_RANGE(i) (0 <= (i) && (i) <= 0xffff)
|
||||
#define MAX_LEGAL_TE_INSTANCE_NUM (0xffff)
|
||||
|
||||
/*
|
||||
* 24 16 8 0
|
||||
|
||||
@ -1742,12 +1742,11 @@ DEFUN (no_ospf_area_default_cost,
|
||||
struct ospf *ospf = vty->index;
|
||||
struct ospf_area *area;
|
||||
struct in_addr area_id;
|
||||
u_int32_t cost;
|
||||
int format;
|
||||
struct prefix_ipv4 p;
|
||||
|
||||
VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id, format, argv[0]);
|
||||
VTY_GET_INTEGER_RANGE ("stub default cost", cost, argv[1], 0, 16777215);
|
||||
VTY_CHECK_INTEGER_RANGE ("stub default cost", argv[1], 0, OSPF_LS_INFINITY);
|
||||
|
||||
area = ospf_area_lookup_by_area_id (ospf, area_id);
|
||||
if (area == NULL)
|
||||
@ -1933,7 +1932,6 @@ DEFUN (no_ospf_area_filter_list,
|
||||
struct ospf *ospf = vty->index;
|
||||
struct ospf_area *area;
|
||||
struct in_addr area_id;
|
||||
struct prefix_list *plist;
|
||||
int format;
|
||||
|
||||
VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
|
||||
@ -1941,7 +1939,6 @@ DEFUN (no_ospf_area_filter_list,
|
||||
if ((area = ospf_area_lookup_by_area_id (ospf, area_id)) == NULL)
|
||||
return CMD_SUCCESS;
|
||||
|
||||
plist = prefix_list_lookup (AFI_IP, argv[1]);
|
||||
if (strncmp (argv[2], "in", 2) == 0)
|
||||
{
|
||||
if (PREFIX_NAME_IN (area))
|
||||
@ -2322,7 +2319,7 @@ DEFUN (ospf_neighbor,
|
||||
if (argc > 1)
|
||||
ospf_nbr_nbma_priority_set (ospf, nbr_addr, priority);
|
||||
if (argc > 2)
|
||||
ospf_nbr_nbma_poll_interval_set (ospf, nbr_addr, priority);
|
||||
ospf_nbr_nbma_poll_interval_set (ospf, nbr_addr, interval);
|
||||
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
@ -2394,11 +2391,10 @@ DEFUN (no_ospf_neighbor,
|
||||
{
|
||||
struct ospf *ospf = vty->index;
|
||||
struct in_addr nbr_addr;
|
||||
int ret;
|
||||
|
||||
VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]);
|
||||
|
||||
ret = ospf_nbr_nbma_unset (ospf, nbr_addr);
|
||||
(void)ospf_nbr_nbma_unset (ospf, nbr_addr);
|
||||
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
@ -4035,21 +4031,26 @@ show_ip_ospf_database_summary (struct vty *vty, struct ospf *ospf, int self)
|
||||
static void
|
||||
show_ip_ospf_database_maxage (struct vty *vty, struct ospf *ospf)
|
||||
{
|
||||
struct listnode *node;
|
||||
struct route_node *rn;
|
||||
struct ospf_lsa *lsa;
|
||||
|
||||
vty_out (vty, "%s MaxAge Link States:%s%s",
|
||||
VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE);
|
||||
|
||||
for (ALL_LIST_ELEMENTS_RO (ospf->maxage_lsa, node, lsa))
|
||||
for (rn = route_top (ospf->maxage_lsa); rn; rn = route_next (rn))
|
||||
{
|
||||
vty_out (vty, "Link type: %d%s", lsa->data->type, VTY_NEWLINE);
|
||||
vty_out (vty, "Link State ID: %s%s",
|
||||
inet_ntoa (lsa->data->id), VTY_NEWLINE);
|
||||
vty_out (vty, "Advertising Router: %s%s",
|
||||
inet_ntoa (lsa->data->adv_router), VTY_NEWLINE);
|
||||
vty_out (vty, "LSA lock count: %d%s", lsa->lock, VTY_NEWLINE);
|
||||
vty_out (vty, "%s", VTY_NEWLINE);
|
||||
struct ospf_lsa *lsa;
|
||||
|
||||
if ((lsa = rn->info) != NULL)
|
||||
{
|
||||
vty_out (vty, "Link type: %d%s", lsa->data->type, VTY_NEWLINE);
|
||||
vty_out (vty, "Link State ID: %s%s",
|
||||
inet_ntoa (lsa->data->id), VTY_NEWLINE);
|
||||
vty_out (vty, "Advertising Router: %s%s",
|
||||
inet_ntoa (lsa->data->adv_router), VTY_NEWLINE);
|
||||
vty_out (vty, "LSA lock count: %d%s", lsa->lock, VTY_NEWLINE);
|
||||
vty_out (vty, "%s", VTY_NEWLINE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -5403,7 +5404,7 @@ DEFUN (ip_ospf_priority,
|
||||
"Address of interface")
|
||||
{
|
||||
struct interface *ifp = vty->index;
|
||||
u_int32_t priority;
|
||||
long priority;
|
||||
struct route_node *rn;
|
||||
struct in_addr addr;
|
||||
int ret;
|
||||
@ -6037,7 +6038,7 @@ DEFUN (ospf_distribute_list_out,
|
||||
int source;
|
||||
|
||||
/* Get distribute source. */
|
||||
source = proto_redistnum(AFI_IP, argv[0]);
|
||||
source = proto_redistnum(AFI_IP, argv[1]);
|
||||
if (source < 0 || source == ZEBRA_ROUTE_OSPF)
|
||||
return CMD_WARNING;
|
||||
|
||||
@ -6056,7 +6057,7 @@ DEFUN (no_ospf_distribute_list_out,
|
||||
struct ospf *ospf = vty->index;
|
||||
int source;
|
||||
|
||||
source = proto_redistnum(AFI_IP, argv[0]);
|
||||
source = proto_redistnum(AFI_IP, argv[1]);
|
||||
if (source < 0 || source == ZEBRA_ROUTE_OSPF)
|
||||
return CMD_WARNING;
|
||||
|
||||
@ -7020,6 +7021,10 @@ DEFUN (ospf_max_metric_router_lsa_admin,
|
||||
if (!CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED))
|
||||
ospf_router_lsa_update_area (area);
|
||||
}
|
||||
|
||||
/* Allows for areas configured later to get the property */
|
||||
ospf->stub_router_admin_set = OSPF_STUB_ROUTER_ADMINISTRATIVE_SET;
|
||||
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
@ -7047,6 +7052,7 @@ DEFUN (no_ospf_max_metric_router_lsa_admin,
|
||||
ospf_router_lsa_update_area (area);
|
||||
}
|
||||
}
|
||||
ospf->stub_router_admin_set = OSPF_STUB_ROUTER_ADMINISTRATIVE_UNSET;
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
@ -133,8 +133,8 @@ ospf_interface_delete (int command, struct zclient *zclient,
|
||||
|
||||
if (IS_DEBUG_OSPF (zebra, ZEBRA_INTERFACE))
|
||||
zlog_debug
|
||||
("Zebra: interface delete %s index %d flags %lld metric %d mtu %d",
|
||||
ifp->name, ifp->ifindex, ifp->flags, ifp->metric, ifp->mtu);
|
||||
("Zebra: interface delete %s index %d flags %llx metric %d mtu %d",
|
||||
ifp->name, ifp->ifindex, (unsigned long long)ifp->flags, ifp->metric, ifp->mtu);
|
||||
|
||||
#ifdef HAVE_SNMP
|
||||
ospf_snmp_if_delete (ifp);
|
||||
@ -1004,7 +1004,7 @@ ospf_distribute_list_update_timer (struct thread *thread)
|
||||
|
||||
/* Update distribute-list and set timer to apply access-list. */
|
||||
void
|
||||
ospf_distribute_list_update (struct ospf *ospf, int type)
|
||||
ospf_distribute_list_update (struct ospf *ospf, uintptr_t type)
|
||||
{
|
||||
struct route_table *rt;
|
||||
|
||||
@ -1217,7 +1217,6 @@ ospf_distance_unset (struct vty *vty, struct ospf *ospf,
|
||||
{
|
||||
int ret;
|
||||
struct prefix_ipv4 p;
|
||||
u_char distance;
|
||||
struct route_node *rn;
|
||||
struct ospf_distance *odistance;
|
||||
|
||||
@ -1228,8 +1227,6 @@ ospf_distance_unset (struct vty *vty, struct ospf *ospf,
|
||||
return CMD_WARNING;
|
||||
}
|
||||
|
||||
distance = atoi (distance_str);
|
||||
|
||||
rn = route_node_lookup (ospf->distance_table, (struct prefix *) &p);
|
||||
if (!rn)
|
||||
{
|
||||
|
||||
@ -54,7 +54,7 @@ extern int ospf_redistribute_check (struct ospf *, struct external_info *,
|
||||
int *);
|
||||
extern int ospf_distribute_check_connected (struct ospf *,
|
||||
struct external_info *);
|
||||
extern void ospf_distribute_list_update (struct ospf *, int);
|
||||
extern void ospf_distribute_list_update (struct ospf *, uintptr_t);
|
||||
|
||||
extern int ospf_is_type_redistributed (int);
|
||||
extern void ospf_distance_reset (struct ospf *);
|
||||
|
||||
@ -182,7 +182,8 @@ ospf_new (void)
|
||||
|
||||
new->stub_router_startup_time = OSPF_STUB_ROUTER_UNCONFIGURED;
|
||||
new->stub_router_shutdown_time = OSPF_STUB_ROUTER_UNCONFIGURED;
|
||||
|
||||
new->stub_router_admin_set = OSPF_STUB_ROUTER_ADMINISTRATIVE_UNSET;
|
||||
|
||||
/* Distribute parameter init. */
|
||||
for (i = 0; i <= ZEBRA_ROUTE_MAX; i++)
|
||||
{
|
||||
@ -200,7 +201,7 @@ ospf_new (void)
|
||||
|
||||
/* MaxAge init. */
|
||||
new->maxage_delay = OSFP_LSA_MAXAGE_REMOVE_DELAY_DEFAULT;
|
||||
new->maxage_lsa = list_new ();
|
||||
new->maxage_lsa = route_table_init();
|
||||
new->t_maxage_walker =
|
||||
thread_add_timer (master, ospf_lsa_maxage_walker,
|
||||
new, OSPF_LSA_MAXAGE_CHECK_INTERVAL);
|
||||
@ -222,7 +223,7 @@ ospf_new (void)
|
||||
}
|
||||
new->maxsndbuflen = getsockopt_so_sendbuf (new->fd);
|
||||
if (IS_DEBUG_OSPF (zebra, ZEBRA_INTERFACE))
|
||||
zlog_debug ("%s: starting with OSPF send buffer size %d",
|
||||
zlog_debug ("%s: starting with OSPF send buffer size %u",
|
||||
__func__, new->maxsndbuflen);
|
||||
if ((new->ibuf = stream_new(OSPF_MAX_PACKET_SIZE+1)) == NULL)
|
||||
{
|
||||
@ -501,10 +502,18 @@ ospf_finish_final (struct ospf *ospf)
|
||||
ospf_lsdb_delete_all (ospf->lsdb);
|
||||
ospf_lsdb_free (ospf->lsdb);
|
||||
|
||||
for (ALL_LIST_ELEMENTS (ospf->maxage_lsa, node, nnode, lsa))
|
||||
ospf_lsa_unlock (&lsa); /* maxage_lsa */
|
||||
for (rn = route_top (ospf->maxage_lsa); rn; rn = route_next (rn))
|
||||
{
|
||||
struct ospf_lsa *lsa;
|
||||
|
||||
list_delete (ospf->maxage_lsa);
|
||||
if ((lsa = rn->info) != NULL)
|
||||
{
|
||||
ospf_lsa_unlock (&lsa);
|
||||
rn->info = NULL;
|
||||
}
|
||||
route_unlock_node (rn);
|
||||
}
|
||||
route_table_finish (ospf->maxage_lsa);
|
||||
|
||||
if (ospf->old_table)
|
||||
ospf_route_table_free (ospf->old_table);
|
||||
@ -676,6 +685,10 @@ ospf_area_get (struct ospf *ospf, struct in_addr area_id, int format)
|
||||
area->format = format;
|
||||
listnode_add_sort (ospf->areas, area);
|
||||
ospf_check_abr_status (ospf);
|
||||
if (ospf->stub_router_admin_set == OSPF_STUB_ROUTER_ADMINISTRATIVE_SET)
|
||||
{
|
||||
SET_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED);
|
||||
}
|
||||
}
|
||||
|
||||
return area;
|
||||
|
||||
@ -195,6 +195,9 @@ struct ospf
|
||||
unsigned int stub_router_startup_time; /* seconds */
|
||||
unsigned int stub_router_shutdown_time; /* seconds */
|
||||
#define OSPF_STUB_ROUTER_UNCONFIGURED 0
|
||||
u_char stub_router_admin_set;
|
||||
#define OSPF_STUB_ROUTER_ADMINISTRATIVE_SET 1
|
||||
#define OSPF_STUB_ROUTER_ADMINISTRATIVE_UNSET 0
|
||||
|
||||
#define OSPF_STUB_MAX_METRIC_SUMMARY_COST 0x00ff0000
|
||||
|
||||
@ -245,7 +248,7 @@ struct ospf
|
||||
/* Time stamps. */
|
||||
struct timeval ts_spf; /* SPF calculation time stamp. */
|
||||
|
||||
struct list *maxage_lsa; /* List of MaxAge LSA for deletion. */
|
||||
struct route_table *maxage_lsa; /* List of MaxAge LSA for deletion. */
|
||||
int redistribute; /* Num of redistributed protocols. */
|
||||
|
||||
/* Threads. */
|
||||
@ -270,7 +273,7 @@ struct ospf
|
||||
struct thread *t_write;
|
||||
struct thread *t_read;
|
||||
int fd;
|
||||
int maxsndbuflen;
|
||||
unsigned int maxsndbuflen;
|
||||
struct stream *ibuf;
|
||||
struct list *oi_write_q;
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user