summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDiogo Oliveira <14191454+dorDiogo@users.noreply.github.com>2023-01-20 17:08:45 -0800
committerDiogo Oliveira <14191454+dorDiogo@users.noreply.github.com>2023-02-28 08:48:30 -0800
commite36ec6acbc347625e7fa1c6f63722292117884b5 (patch)
treec3f1ac316c9b755e027bac93ee9b4f4ffc869169
parent617d2b71c0d1b61dfb319f5f629953a95e6beef5 (diff)
isisd: Add support for isis hello padding sometimes
New configuration to pad ISIS hello packets during adjacency formation only. Signed-off-by: Diogo Oliveira <14191454+dorDiogo@users.noreply.github.com>
-rw-r--r--isisd/isis_circuit.c34
-rw-r--r--isisd/isis_circuit.h11
-rw-r--r--isisd/isis_cli.c32
-rw-r--r--isisd/isis_misc.c13
-rw-r--r--isisd/isis_misc.h1
-rw-r--r--isisd/isis_nb_config.c2
-rw-r--r--isisd/isis_pdu.c7
-rw-r--r--isisd/isis_snmp.c4
-rw-r--r--yang/frr-isisd.yang26
9 files changed, 100 insertions, 30 deletions
diff --git a/isisd/isis_circuit.c b/isisd/isis_circuit.c
index dd5f921bef..ebf9901c52 100644
--- a/isisd/isis_circuit.c
+++ b/isisd/isis_circuit.c
@@ -107,7 +107,7 @@ struct isis_circuit *isis_circuit_new(struct interface *ifp, const char *tag)
"/frr-interface:lib/interface/frr-isisd:isis/circuit-type");
circuit->flags = 0;
- circuit->pad_hellos = yang_get_default_bool(
+ circuit->pad_hellos = yang_get_default_enum(
"/frr-interface:lib/interface/frr-isisd:isis/hello/padding");
circuit->hello_interval[0] = yang_get_default_uint32(
"/frr-interface:lib/interface/frr-isisd:isis/hello/interval/level-1");
@@ -145,7 +145,7 @@ struct isis_circuit *isis_circuit_new(struct interface *ifp, const char *tag)
#else
circuit->is_type_config = IS_LEVEL_1_AND_2;
circuit->flags = 0;
- circuit->pad_hellos = 1;
+ circuit->pad_hellos = ISIS_HELLO_PADDING_ALWAYS;
for (i = 0; i < 2; i++) {
circuit->hello_interval[i] = DEFAULT_HELLO_INTERVAL;
circuit->hello_multiplier[i] = DEFAULT_HELLO_MULTIPLIER;
@@ -1029,7 +1029,8 @@ void isis_circuit_print_json(struct isis_circuit *circuit,
circuit->hello_multiplier[0]);
json_object_string_add(
hold_json, "pad",
- (circuit->pad_hellos ? "yes" : "no"));
+ isis_hello_padding2string(
+ circuit->pad_hellos));
json_object_int_add(level_json, "cnsp-interval",
circuit->csnp_interval[0]);
json_object_int_add(level_json, "psnp-interval",
@@ -1137,11 +1138,11 @@ void isis_circuit_print_vty(struct isis_circuit *circuit, struct vty *vty,
vty_out(vty, ", Active neighbors: %u\n",
circuit->upadjcount[0]);
vty_out(vty,
- " Hello interval: %u, Holddown count: %u %s\n",
+ " Hello interval: %u, Holddown count: %u, Padding: %s\n",
circuit->hello_interval[0],
circuit->hello_multiplier[0],
- (circuit->pad_hellos ? "(pad)"
- : "(no-pad)"));
+ isis_hello_padding2string(
+ circuit->pad_hellos));
vty_out(vty,
" CNSP interval: %u, PSNP interval: %u\n",
circuit->csnp_interval[0],
@@ -1169,11 +1170,11 @@ void isis_circuit_print_vty(struct isis_circuit *circuit, struct vty *vty,
vty_out(vty, ", Active neighbors: %u\n",
circuit->upadjcount[1]);
vty_out(vty,
- " Hello interval: %u, Holddown count: %u %s\n",
+ " Hello interval: %u, Holddown count: %u, Padding: %s\n",
circuit->hello_interval[1],
circuit->hello_multiplier[1],
- (circuit->pad_hellos ? "(pad)"
- : "(no-pad)"));
+ isis_hello_padding2string(
+ circuit->pad_hellos));
vty_out(vty,
" CNSP interval: %u, PSNP interval: %u\n",
circuit->csnp_interval[1],
@@ -1319,11 +1320,20 @@ static int isis_interface_config_write(struct vty *vty)
}
}
- /* ISIS - Hello padding - Defaults to true so only
- * display if false */
- if (circuit->pad_hellos == 0) {
+ /* ISIS - Hello padding - Defaults to always so only
+ * display if not always */
+ switch (circuit->pad_hellos) {
+ case ISIS_HELLO_PADDING_DISABLED:
vty_out(vty, " no " PROTO_NAME " hello padding\n");
write++;
+ break;
+ case ISIS_HELLO_PADDING_SOMETIMES:
+ vty_out(vty, PROTO_NAME
+ " hello padding sometimes\n");
+ write++;
+ break;
+ case ISIS_HELLO_PADDING_ALWAYS:
+ break;
}
if (circuit->disable_threeway_adj) {
diff --git a/isisd/isis_circuit.h b/isisd/isis_circuit.h
index 494e96b697..58aa28195f 100644
--- a/isisd/isis_circuit.h
+++ b/isisd/isis_circuit.h
@@ -63,6 +63,15 @@ struct isis_circuit_arg {
struct isis_circuit *circuit;
};
+/*
+ * Hello padding types
+ */
+enum isis_hello_padding {
+ ISIS_HELLO_PADDING_ALWAYS,
+ ISIS_HELLO_PADDING_DISABLED,
+ ISIS_HELLO_PADDING_SOMETIMES
+};
+
struct isis_circuit {
enum isis_circuit_state state;
uint8_t circuit_id; /* l1/l2 bcast CircuitID */
@@ -100,7 +109,7 @@ struct isis_circuit {
struct isis_p2p_info p2p;
} u;
uint8_t priority[ISIS_LEVELS]; /* l1/2 IS configured priority */
- int pad_hellos; /* add padding to Hello PDUs ? */
+ enum isis_hello_padding pad_hellos; /* type of Hello PDUs padding */
char ext_domain; /* externalDomain (boolean) */
int lsp_regenerate_pending[ISIS_LEVELS];
uint64_t lsp_error_counter;
diff --git a/isisd/isis_cli.c b/isisd/isis_cli.c
index 5c7f610881..f430ded745 100644
--- a/isisd/isis_cli.c
+++ b/isisd/isis_cli.c
@@ -2239,15 +2239,22 @@ void cli_show_ip_isis_threeway_shake(struct vty *vty,
/*
* XPath: /frr-interface:lib/interface/frr-isisd:isis/hello/padding
*/
-DEFPY_YANG(isis_hello_padding, isis_hello_padding_cmd, "[no] isis hello padding",
- NO_STR
- "IS-IS routing protocol\n"
- "Add padding to IS-IS hello packets\n"
- "Pad hello packets\n")
+DEFPY_YANG(isis_hello_padding, isis_hello_padding_cmd,
+ "[no] isis hello padding [sometimes]$padding_type",
+ NO_STR
+ "IS-IS routing protocol\n"
+ "Type of padding for IS-IS hello packets\n"
+ "Pad hello packets\n"
+ "Add padding to hello packets during adjacency formation only.\n")
{
- nb_cli_enqueue_change(vty, "./frr-isisd:isis/hello/padding",
- NB_OP_MODIFY, no ? "false" : "true");
-
+ if (no) {
+ nb_cli_enqueue_change(vty, "./frr-isisd:isis/hello/padding",
+ NB_OP_MODIFY, "disabled");
+ } else {
+ nb_cli_enqueue_change(vty, "./frr-isisd:isis/hello/padding",
+ NB_OP_MODIFY,
+ padding_type ? padding_type : "always");
+ }
return nb_cli_apply_changes(vty, NULL);
}
@@ -2255,10 +2262,13 @@ void cli_show_ip_isis_hello_padding(struct vty *vty,
const struct lyd_node *dnode,
bool show_defaults)
{
- if (!yang_dnode_get_bool(dnode, NULL))
+ int hello_padding_type = yang_dnode_get_enum(dnode, NULL);
+ if (hello_padding_type == ISIS_HELLO_PADDING_DISABLED)
vty_out(vty, " no");
-
- vty_out(vty, " isis hello padding\n");
+ vty_out(vty, " isis hello padding");
+ if (hello_padding_type == ISIS_HELLO_PADDING_SOMETIMES)
+ vty_out(vty, " sometimes");
+ vty_out(vty, "\n");
}
/*
diff --git a/isisd/isis_misc.c b/isisd/isis_misc.c
index 4a490ab5ac..7c6d600362 100644
--- a/isisd/isis_misc.c
+++ b/isisd/isis_misc.c
@@ -294,6 +294,19 @@ const char *syst2string(int type)
return NULL; /* not reached */
}
+const char *isis_hello_padding2string(int hello_padding_type)
+{
+ switch (hello_padding_type) {
+ case ISIS_HELLO_PADDING_DISABLED:
+ return "no";
+ case ISIS_HELLO_PADDING_SOMETIMES:
+ return "sometimes";
+ case ISIS_HELLO_PADDING_ALWAYS:
+ return "yes";
+ }
+ return NULL; /* not reached */
+}
+
/*
* Print functions - we print to static vars
*/
diff --git a/isisd/isis_misc.h b/isisd/isis_misc.h
index b8b4ebd280..01d9abe869 100644
--- a/isisd/isis_misc.h
+++ b/isisd/isis_misc.h
@@ -16,6 +16,7 @@ const char *circuit_t2string(int);
const char *circuit_state2string(int state);
const char *circuit_type2string(int type);
const char *syst2string(int);
+const char *isis_hello_padding2string(int hello_padding_type);
struct in_addr newprefix2inaddr(uint8_t *prefix_start, uint8_t prefix_masklen);
/*
* Converting input to memory stored format
diff --git a/isisd/isis_nb_config.c b/isisd/isis_nb_config.c
index ea021a4ff5..fbb237688b 100644
--- a/isisd/isis_nb_config.c
+++ b/isisd/isis_nb_config.c
@@ -2765,7 +2765,7 @@ int lib_interface_isis_hello_padding_modify(struct nb_cb_modify_args *args)
return NB_OK;
circuit = nb_running_get_entry(args->dnode, NULL, true);
- circuit->pad_hellos = yang_dnode_get_bool(args->dnode, NULL);
+ circuit->pad_hellos = yang_dnode_get_enum(args->dnode, NULL);
return NB_OK;
}
diff --git a/isisd/isis_pdu.c b/isisd/isis_pdu.c
index 70ec2426d3..9ddc427c13 100644
--- a/isisd/isis_pdu.c
+++ b/isisd/isis_pdu.c
@@ -1964,8 +1964,13 @@ int send_hello(struct isis_circuit *circuit, int level)
isis_tlvs_add_global_ipv6_addresses(tlvs,
circuit->ipv6_non_link);
+ bool should_pad_hello =
+ circuit->pad_hellos == ISIS_HELLO_PADDING_ALWAYS ||
+ (circuit->pad_hellos == ISIS_HELLO_PADDING_SOMETIMES &&
+ circuit->upadjcount[0] + circuit->upadjcount[1] == 0);
+
if (isis_pack_tlvs(tlvs, circuit->snd_stream, len_pointer,
- circuit->pad_hellos, false)) {
+ should_pad_hello, false)) {
isis_free_tlvs(tlvs);
return ISIS_WARNING; /* XXX: Maybe Log TLV structure? */
}
diff --git a/isisd/isis_snmp.c b/isisd/isis_snmp.c
index ae570a0864..b4ae063639 100644
--- a/isisd/isis_snmp.c
+++ b/isisd/isis_snmp.c
@@ -2161,7 +2161,9 @@ static uint8_t *isis_snmp_find_circ(struct variable *v, oid *name,
/*
* return false if lan hellos must be padded
*/
- if (circuit->pad_hellos)
+ if (circuit->pad_hellos == ISIS_HELLO_PADDING_ALWAYS ||
+ (circuit->pad_hellos == ISIS_HELLO_PADDING_SOMETIMES &&
+ circuit->upadjcount[0] + circuit->upadjcount[1] == 0))
return SNMP_INTEGER(ISIS_SNMP_TRUTH_VALUE_FALSE);
return SNMP_INTEGER(ISIS_SNMP_TRUTH_VALUE_TRUE);
diff --git a/yang/frr-isisd.yang b/yang/frr-isisd.yang
index ff3ba5d12b..f2927339ad 100644
--- a/yang/frr-isisd.yang
+++ b/yang/frr-isisd.yang
@@ -116,6 +116,26 @@ module frr-isisd {
associated with an interface.";
}
+ typedef hello-padding-type {
+ type enumeration {
+ enum "always" {
+ value 0;
+ description
+ "Add padding to all hello packets.";
+ }
+ enum "disabled" {
+ value 1;
+ description
+ "Do not add any padding to hello packets.";
+ }
+ enum "sometimes" {
+ value 2;
+ description
+ "Add padding to hello packets during adjacency formation only.";
+ }
+ }
+ }
+
typedef network-type {
type enumeration {
enum "unknown" {
@@ -605,10 +625,10 @@ module frr-isisd {
description
"Parameters related to IS-IS hello PDUs.";
leaf padding {
- type boolean;
- default "true";
+ type hello-padding-type;
+ default "always";
description
- "Add padding to IS-IS hello PDUs.";
+ "Type of padding for IS-IS hello packets.";
}
container interval {