summaryrefslogtreecommitdiff
path: root/ospfd
diff options
context:
space:
mode:
authorAcee Lindem <acee@lindem.com>2024-10-22 14:48:33 +0000
committerAcee Lindem <acee@lindem.com>2024-10-25 14:31:10 +0000
commitc735f25abb0c454a49b08de60fa2ed5521133f9a (patch)
tree5da9f5ae9caeca3fff56b66dc06bae3df0c86973 /ospfd
parentfd6f46e9fd3122b64bfefe526c3825b2d109ec22 (diff)
ospfd: Fix opaque LSA refresh interval and modify LSA cmds.
The configured OSPF refresh interval was not being used for opaque LSA (it always used the constant). Also, modified the timers lsa min-arrival command to have a maximum of 5000 msecs as well as providing a path for backward command compatibility. Added missing user documentation for both timers lsa min-arrival and timers throttle lsa all. Signed-off-by: Acee Lindem <acee@lindem.com>
Diffstat (limited to 'ospfd')
-rw-r--r--ospfd/ospf_lsa.c28
-rw-r--r--ospfd/ospf_lsa.h4
-rw-r--r--ospfd/ospf_opaque.c25
-rw-r--r--ospfd/ospf_vty.c79
4 files changed, 58 insertions, 78 deletions
diff --git a/ospfd/ospf_lsa.c b/ospfd/ospf_lsa.c
index a8b8de6d5b..f175bbf9e4 100644
--- a/ospfd/ospf_lsa.c
+++ b/ospfd/ospf_lsa.c
@@ -101,24 +101,30 @@ struct timeval msec2tv(int a)
return ret;
}
-int ospf_lsa_refresh_delay(struct ospf_lsa *lsa)
+int tv2msec(struct timeval tv)
+{
+ int msecs;
+
+ msecs = tv.tv_sec * 1000;
+ msecs += tv.tv_usec / 1000;
+
+ return msecs;
+}
+
+int ospf_lsa_refresh_delay(struct ospf *ospf, struct ospf_lsa *lsa)
{
struct timeval delta;
int delay = 0;
- if (monotime_since(&lsa->tv_orig, &delta)
- < OSPF_MIN_LS_INTERVAL * 1000LL) {
- struct timeval minv = msec2tv(OSPF_MIN_LS_INTERVAL);
- timersub(&minv, &delta, &minv);
+ if (monotime_since(&lsa->tv_orig, &delta) < ospf->min_ls_interval * 1000LL) {
+ struct timeval minv = msec2tv(ospf->min_ls_interval);
- /* TBD: remove padding to full sec, return timeval instead */
- delay = minv.tv_sec + !!minv.tv_usec;
+ timersub(&minv, &delta, &minv);
+ delay = tv2msec(minv);
if (IS_DEBUG_OSPF(lsa, LSA_GENERATE))
- zlog_debug(
- "LSA[Type%d:%pI4]: Refresh timer delay %d seconds",
- lsa->data->type, &lsa->data->id,
- delay);
+ zlog_debug("LSA[Type%d:%pI4]: Refresh timer delay %d milliseconds",
+ lsa->data->type, &lsa->data->id, delay);
assert(delay > 0);
}
diff --git a/ospfd/ospf_lsa.h b/ospfd/ospf_lsa.h
index c751f081fb..418675cb10 100644
--- a/ospfd/ospf_lsa.h
+++ b/ospfd/ospf_lsa.h
@@ -225,12 +225,14 @@ enum lsid_status { LSID_AVAILABLE = 0, LSID_CHANGE, LSID_NOT_AVAILABLE };
/* Prototypes. */
/* XXX: Eek, time functions, similar are in lib/thread.c */
extern struct timeval int2tv(int);
+
extern struct timeval msec2tv(int a);
+extern int tv2msec(struct timeval tv);
extern int get_age(struct ospf_lsa *lsa);
extern uint16_t ospf_lsa_checksum(struct lsa_header *lsah);
extern int ospf_lsa_checksum_valid(struct lsa_header *lsah);
-extern int ospf_lsa_refresh_delay(struct ospf_lsa *lsa);
+extern int ospf_lsa_refresh_delay(struct ospf *ospf, struct ospf_lsa *lsa);
extern const char *dump_lsa_key(struct ospf_lsa *lsa);
extern uint32_t lsa_seqnum_increment(struct ospf_lsa *lsa);
diff --git a/ospfd/ospf_opaque.c b/ospfd/ospf_opaque.c
index 5d2d65658f..d8b272d60b 100644
--- a/ospfd/ospf_opaque.c
+++ b/ospfd/ospf_opaque.c
@@ -2051,7 +2051,7 @@ void ospf_opaque_lsa_refresh_schedule(struct ospf_lsa *lsa0)
struct opaque_info_per_type *oipt;
struct opaque_info_per_id *oipi;
struct ospf_lsa *lsa;
- struct ospf *top;
+ struct ospf *ospf;
int delay;
if ((oipt = lookup_opaque_info_by_type(lsa0)) == NULL
@@ -2076,6 +2076,11 @@ void ospf_opaque_lsa_refresh_schedule(struct ospf_lsa *lsa0)
goto out;
}
+ if ((lsa0->area != NULL) && (lsa0->area->ospf != NULL))
+ ospf = lsa0->area->ospf;
+ else
+ ospf = ospf_lookup_by_vrf_id(VRF_DEFAULT);
+
/* Delete this lsa from neighbor retransmit-list. */
switch (lsa->data->type) {
case OSPF_OPAQUE_LINK_LSA:
@@ -2083,10 +2088,7 @@ void ospf_opaque_lsa_refresh_schedule(struct ospf_lsa *lsa0)
ospf_ls_retransmit_delete_nbr_area(lsa->area, lsa);
break;
case OSPF_OPAQUE_AS_LSA:
- top = ospf_lookup_by_vrf_id(VRF_DEFAULT);
- if ((lsa0->area != NULL) && (lsa0->area->ospf != NULL))
- top = lsa0->area->ospf;
- ospf_ls_retransmit_delete_nbr_as(top, lsa);
+ ospf_ls_retransmit_delete_nbr_as(ospf, lsa);
break;
default:
flog_warn(EC_OSPF_LSA_UNEXPECTED, "%s: Unexpected LSA-type(%u)",
@@ -2094,17 +2096,14 @@ void ospf_opaque_lsa_refresh_schedule(struct ospf_lsa *lsa0)
goto out;
}
- delay = ospf_lsa_refresh_delay(lsa);
+ delay = ospf_lsa_refresh_delay(ospf, lsa);
if (IS_DEBUG_OSPF_EVENT)
- zlog_debug(
- "Schedule Type-%u Opaque-LSA to REFRESH in %d sec later: [opaque-type=%u, opaque-id=%x]",
- lsa->data->type, delay,
- GET_OPAQUE_TYPE(ntohl(lsa->data->id.s_addr)),
- GET_OPAQUE_ID(ntohl(lsa->data->id.s_addr)));
+ zlog_debug("Schedule Type-%u Opaque-LSA to REFRESH in %d msec later: [opaque-type=%u, opaque-id=%x]",
+ lsa->data->type, delay, GET_OPAQUE_TYPE(ntohl(lsa->data->id.s_addr)),
+ GET_OPAQUE_ID(ntohl(lsa->data->id.s_addr)));
- OSPF_OPAQUE_TIMER_ON(oipi->t_opaque_lsa_self,
- ospf_opaque_lsa_refresh_timer, oipi, delay * 1000);
+ OSPF_OPAQUE_TIMER_ON(oipi->t_opaque_lsa_self, ospf_opaque_lsa_refresh_timer, oipi, delay);
out:
return;
}
diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c
index 01cbfedc1c..567e156bba 100644
--- a/ospfd/ospf_vty.c
+++ b/ospfd/ospf_vty.c
@@ -2305,34 +2305,9 @@ static int ospf_timers_spf_set(struct vty *vty, unsigned int delay,
return CMD_SUCCESS;
}
-DEFUN (ospf_timers_min_ls_interval,
+DEFPY (ospf_timers_min_ls_interval,
ospf_timers_min_ls_interval_cmd,
- "timers throttle lsa all (0-5000)",
- "Adjust routing timers\n"
- "Throttling adaptive timer\n"
- "LSA delay between transmissions\n"
- "All LSA types\n"
- "Delay (msec) between sending LSAs\n")
-{
- VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf);
- int idx_number = 4;
- unsigned int interval;
-
- if (argc < 5) {
- vty_out(vty, "Insufficient arguments\n");
- return CMD_WARNING_CONFIG_FAILED;
- }
-
- interval = strtoul(argv[idx_number]->arg, NULL, 10);
-
- ospf->min_ls_interval = interval;
-
- return CMD_SUCCESS;
-}
-
-DEFUN (no_ospf_timers_min_ls_interval,
- no_ospf_timers_min_ls_interval_cmd,
- "no timers throttle lsa all [(0-5000)]",
+ "[no] timers throttle lsa all ![(0-5000)]$lsa_refresh_interval",
NO_STR
"Adjust routing timers\n"
"Throttling adaptive timer\n"
@@ -2341,7 +2316,11 @@ DEFUN (no_ospf_timers_min_ls_interval,
"Delay (msec) between sending LSAs\n")
{
VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf);
- ospf->min_ls_interval = OSPF_MIN_LS_INTERVAL;
+
+ if (no)
+ ospf->min_ls_interval = OSPF_MIN_LS_INTERVAL;
+ else
+ ospf->min_ls_interval = strtoul(lsa_refresh_interval_str, NULL, 10);
return CMD_SUCCESS;
}
@@ -2390,40 +2369,35 @@ DEFUN (no_ospf_timers_throttle_spf,
}
-DEFUN (ospf_timers_lsa_min_arrival,
+DEFPY (ospf_timers_lsa_min_arrival,
ospf_timers_lsa_min_arrival_cmd,
- "timers lsa min-arrival (0-600000)",
+ "[no] timers lsa min-arrival ![(0-5000)]$min_arrival",
+ NO_STR
"Adjust routing timers\n"
"OSPF LSA timers\n"
- "Minimum delay in receiving new version of a LSA\n"
+ "Minimum delay in receiving new version of an LSA\n"
"Delay in milliseconds\n")
{
VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf);
- ospf->min_ls_arrival = strtoul(argv[argc - 1]->arg, NULL, 10);
+ if (no)
+ ospf->min_ls_arrival = OSPF_MIN_LS_ARRIVAL;
+ else
+ ospf->min_ls_arrival = strtoul(min_arrival_str, NULL, 10);
return CMD_SUCCESS;
}
-DEFUN (no_ospf_timers_lsa_min_arrival,
- no_ospf_timers_lsa_min_arrival_cmd,
- "no timers lsa min-arrival [(0-600000)]",
- NO_STR
- "Adjust routing timers\n"
- "OSPF LSA timers\n"
- "Minimum delay in receiving new version of a LSA\n"
- "Delay in milliseconds\n")
+DEFPY_HIDDEN (ospf_timers_lsa_min_arrival_deprecated,
+ ospf_timers_lsa_min_arrival_deprecated_cmd,
+ "timers lsa min-arrival [(5001-60000)]$min_arrival",
+ "Adjust routing timers\n"
+ "OSPF LSA timers\n"
+ "Minimum delay in receiving new version of an LSA\n"
+ "Deprecated delay in milliseconds - delays in this range default to 5000 msec\n")
{
VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf);
- unsigned int minarrival;
-
- if (argc > 4) {
- minarrival = strtoul(argv[argc - 1]->arg, NULL, 10);
-
- if (ospf->min_ls_arrival != minarrival
- || minarrival == OSPF_MIN_LS_ARRIVAL)
- return CMD_SUCCESS;
- }
-
- ospf->min_ls_arrival = OSPF_MIN_LS_ARRIVAL;
+ vty_out(vty, "%% OSPF `timers lsa min-arrival` set to the maximum of %u milliseconds\n",
+ OSPF_MIN_LS_ARRIVAL_MAX);
+ ospf->min_ls_arrival = OSPF_MIN_LS_ARRIVAL_MAX;
return CMD_SUCCESS;
}
@@ -13710,9 +13684,8 @@ void ospf_vty_init(void)
/* LSA timers commands */
install_element(OSPF_NODE, &ospf_timers_min_ls_interval_cmd);
- install_element(OSPF_NODE, &no_ospf_timers_min_ls_interval_cmd);
install_element(OSPF_NODE, &ospf_timers_lsa_min_arrival_cmd);
- install_element(OSPF_NODE, &no_ospf_timers_lsa_min_arrival_cmd);
+ install_element(OSPF_NODE, &ospf_timers_lsa_min_arrival_deprecated_cmd);
/* refresh timer commands */
install_element(OSPF_NODE, &ospf_refresh_timer_cmd);