summaryrefslogtreecommitdiff
path: root/ospf6d/ospf6_interface.c
diff options
context:
space:
mode:
Diffstat (limited to 'ospf6d/ospf6_interface.c')
-rw-r--r--ospf6d/ospf6_interface.c112
1 files changed, 58 insertions, 54 deletions
diff --git a/ospf6d/ospf6_interface.c b/ospf6d/ospf6_interface.c
index b63a3c02db..ae9f13bc10 100644
--- a/ospf6d/ospf6_interface.c
+++ b/ospf6d/ospf6_interface.c
@@ -127,7 +127,7 @@ static uint8_t ospf6_default_iftype(struct interface *ifp)
{
if (if_is_pointopoint(ifp))
return OSPF_IFTYPE_POINTOPOINT;
- else if (if_is_loopback_or_vrf(ifp))
+ else if (if_is_loopback(ifp))
return OSPF_IFTYPE_LOOPBACK;
else
return OSPF_IFTYPE_BROADCAST;
@@ -150,7 +150,7 @@ static uint32_t ospf6_interface_get_cost(struct ospf6_interface *oi)
: OSPF6_INTERFACE_BANDWIDTH;
}
- ospf6 = ospf6_lookup_by_vrf_id(oi->interface->vrf_id);
+ ospf6 = oi->interface->vrf->info;
refbw = ospf6 ? ospf6->ref_bandwidth : OSPF6_REFERENCE_BANDWIDTH;
/* A specifed ip ospf cost overrides a calculated one. */
@@ -387,7 +387,7 @@ void ospf6_interface_state_update(struct interface *ifp)
if (if_is_operative(ifp)
&& (ospf6_interface_get_linklocal_address(oi->interface)
- || if_is_loopback_or_vrf(oi->interface)))
+ || if_is_loopback(oi->interface)))
thread_execute(master, interface_up, oi, 0);
else
thread_execute(master, interface_down, oi, 0);
@@ -675,7 +675,8 @@ uint8_t dr_election(struct ospf6_interface *oi)
if (on->state < OSPF6_NEIGHBOR_TWOWAY)
continue;
/* Schedule AdjOK. */
- thread_add_event(master, adj_ok, on, 0, NULL);
+ thread_add_event(master, adj_ok, on, 0,
+ &on->thread_adj_ok);
}
}
@@ -749,7 +750,7 @@ int interface_up(struct thread *thread)
/* check interface has a link-local address */
if (!(ospf6_interface_get_linklocal_address(oi->interface)
- || if_is_loopback_or_vrf(oi->interface))) {
+ || if_is_loopback(oi->interface))) {
zlog_warn(
"Interface %s has no link local address, can't execute [InterfaceUp]",
oi->interface->name);
@@ -818,8 +819,7 @@ int interface_up(struct thread *thread)
/* Schedule Hello */
if (!CHECK_FLAG(oi->flag, OSPF6_INTERFACE_PASSIVE)
- && !if_is_loopback_or_vrf(oi->interface)) {
- oi->thread_send_hello = NULL;
+ && !if_is_loopback(oi->interface)) {
thread_add_event(master, ospf6_hello_send, oi, 0,
&oi->thread_send_hello);
}
@@ -971,6 +971,10 @@ static const char *ospf6_iftype_str(uint8_t iftype)
return "UNKNOWN";
}
+#if CONFDATE > 20220709
+CPP_NOTICE("Time to remove ospf6Enabled from JSON output")
+#endif
+
/* show specified interface structure */
static int ospf6_interface_show(struct vty *vty, struct interface *ifp,
json_object *json_obj, bool use_json)
@@ -1242,7 +1246,6 @@ struct in6_addr *ospf6_interface_get_global_address(struct interface *ifp)
{
struct listnode *n;
struct connected *c;
- struct in6_addr *l = (struct in6_addr *)NULL;
/* for each connected address */
for (ALL_LIST_ELEMENTS_RO(ifp->connected, n, c)) {
@@ -1251,23 +1254,23 @@ struct in6_addr *ospf6_interface_get_global_address(struct interface *ifp)
continue;
if (!IN6_IS_ADDR_LINKLOCAL(&c->address->u.prefix6))
- l = &c->address->u.prefix6;
+ return &c->address->u.prefix6;
}
- return l;
+
+ return NULL;
}
static int show_ospf6_interface_common(struct vty *vty, vrf_id_t vrf_id,
int argc, struct cmd_token **argv,
int idx_ifname, int intf_idx,
- int json_idx)
+ int json_idx, bool uj)
{
struct vrf *vrf = vrf_lookup_by_id(vrf_id);
struct interface *ifp;
json_object *json;
json_object *json_int;
- bool uj = use_json(argc, argv);
if (uj) {
json = json_object_new_object();
@@ -1277,10 +1280,7 @@ static int show_ospf6_interface_common(struct vty *vty, vrf_id_t vrf_id,
if (ifp == NULL) {
json_object_string_add(json, "noSuchInterface",
argv[idx_ifname]->arg);
- vty_out(vty, "%s\n",
- json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
- json_object_free(json);
+ vty_json(vty, json);
json_object_free(json_int);
return CMD_WARNING;
}
@@ -1294,10 +1294,7 @@ static int show_ospf6_interface_common(struct vty *vty, vrf_id_t vrf_id,
json_int);
}
}
- vty_out(vty, "%s\n",
- json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
- json_object_free(json);
+ vty_json(vty, json);
} else {
if (argc == intf_idx) {
ifp = if_lookup_by_name(argv[idx_ifname]->arg, vrf_id);
@@ -1329,6 +1326,7 @@ DEFUN(show_ipv6_ospf6_interface, show_ipv6_ospf6_interface_ifname_cmd,
const char *vrf_name = NULL;
bool all_vrf = false;
int idx_vrf = 0;
+ bool uj = use_json(argc, argv);
OSPF6_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf);
if (idx_vrf > 0) {
@@ -1341,13 +1339,15 @@ DEFUN(show_ipv6_ospf6_interface, show_ipv6_ospf6_interface_ifname_cmd,
if (all_vrf || strcmp(ospf6->name, vrf_name) == 0) {
show_ospf6_interface_common(vty, ospf6->vrf_id, argc,
argv, idx_ifname, intf_idx,
- json_idx);
+ json_idx, uj);
if (!all_vrf)
break;
}
}
+ OSPF6_CMD_CHECK_VRF(uj, all_vrf, ospf6);
+
return CMD_SUCCESS;
}
@@ -1361,11 +1361,6 @@ static int ospf6_interface_show_traffic(struct vty *vty,
struct ospf6_interface *oi = NULL;
json_object *json_interface;
- if (intf_ifp)
- vrf = vrf_lookup_by_id(intf_ifp->vrf_id);
- else
- vrf = vrf_lookup_by_id(vrf_id);
-
if (!display_once && !use_json) {
vty_out(vty, "\n");
vty_out(vty, "%-12s%-17s%-17s%-17s%-17s%-17s\n", "Interface",
@@ -1379,6 +1374,7 @@ static int ospf6_interface_show_traffic(struct vty *vty,
}
if (intf_ifp == NULL) {
+ vrf = vrf_lookup_by_id(vrf_id);
FOR_ALL_INTERFACES (vrf, ifp) {
if (ifp->info)
oi = (struct ospf6_interface *)ifp->info;
@@ -1467,14 +1463,13 @@ static int ospf6_interface_show_traffic(struct vty *vty,
static int ospf6_interface_show_traffic_common(struct vty *vty, int argc,
struct cmd_token **argv,
- vrf_id_t vrf_id)
+ vrf_id_t vrf_id, bool uj)
{
int idx_ifname = 0;
int display_once = 0;
char *intf_name = NULL;
struct interface *ifp = NULL;
json_object *json = NULL;
- bool uj = use_json(argc, argv);
if (uj)
json = json_object_new_object();
@@ -1488,10 +1483,7 @@ static int ospf6_interface_show_traffic_common(struct vty *vty, int argc,
"No Such Interface");
json_object_string_add(json, "interface",
intf_name);
- vty_out(vty, "%s\n",
- json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
- json_object_free(json);
+ vty_json(vty, json);
return CMD_WARNING;
}
if (ifp->info == NULL) {
@@ -1500,10 +1492,7 @@ static int ospf6_interface_show_traffic_common(struct vty *vty, int argc,
"OSPF not enabled on this interface");
json_object_string_add(json, "interface",
intf_name);
- vty_out(vty, "%s\n",
- json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
- json_object_free(json);
+ vty_json(vty, json);
return 0;
}
} else {
@@ -1523,12 +1512,8 @@ static int ospf6_interface_show_traffic_common(struct vty *vty, int argc,
ospf6_interface_show_traffic(vty, ifp, display_once, json, uj, vrf_id);
- if (uj) {
- vty_out(vty, "%s\n",
- json_object_to_json_string_ext(
- json, JSON_C_TO_STRING_PRETTY));
- json_object_free(json);
- }
+ if (uj)
+ vty_json(vty, json);
return CMD_SUCCESS;
}
@@ -1545,19 +1530,22 @@ DEFUN(show_ipv6_ospf6_interface_traffic, show_ipv6_ospf6_interface_traffic_cmd,
const char *vrf_name = NULL;
bool all_vrf = false;
int idx_vrf = 0;
+ bool uj = use_json(argc, argv);
OSPF6_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf);
for (ALL_LIST_ELEMENTS_RO(om6->ospf6, node, ospf6)) {
if (all_vrf || strcmp(ospf6->name, vrf_name) == 0) {
ospf6_interface_show_traffic_common(vty, argc, argv,
- ospf6->vrf_id);
+ ospf6->vrf_id, uj);
if (!all_vrf)
break;
}
}
+ OSPF6_CMD_CHECK_VRF(uj, all_vrf, ospf6);
+
return CMD_SUCCESS;
}
@@ -1621,6 +1609,8 @@ DEFUN(show_ipv6_ospf6_interface_ifname_prefix,
}
}
+ OSPF6_CMD_CHECK_VRF(uj, all_vrf, ospf6);
+
return CMD_SUCCESS;
}
@@ -1671,6 +1661,8 @@ DEFUN(show_ipv6_ospf6_interface_prefix, show_ipv6_ospf6_interface_prefix_cmd,
}
}
+ OSPF6_CMD_CHECK_VRF(uj, all_vrf, ospf6);
+
return CMD_SUCCESS;
}
@@ -1685,7 +1677,7 @@ void ospf6_interface_start(struct ospf6_interface *oi)
if (oi->area)
return;
- ospf6 = ospf6_lookup_by_vrf_id(oi->interface->vrf_id);
+ ospf6 = oi->interface->vrf->info;
if (!ospf6)
return;
@@ -2315,7 +2307,7 @@ DEFUN (no_ipv6_ospf6_passive,
THREAD_OFF(oi->thread_sso);
/* don't send hellos over loopback interface */
- if (!if_is_loopback_or_vrf(oi->interface))
+ if (!if_is_loopback(oi->interface))
thread_add_event(master, ospf6_hello_send, oi, 0,
&oi->thread_send_hello);
@@ -2740,27 +2732,39 @@ void ospf6_interface_clear(struct interface *ifp)
/* Clear interface */
DEFUN (clear_ipv6_ospf6_interface,
clear_ipv6_ospf6_interface_cmd,
- "clear ipv6 ospf6 interface [IFNAME]",
+ "clear ipv6 ospf6 [vrf NAME] interface [IFNAME]",
CLEAR_STR
IP6_STR
OSPF6_STR
+ VRF_CMD_HELP_STR
INTERFACE_STR
IFNAME_STR
)
{
- struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
+ struct vrf *vrf;
+ int idx_vrf = 3;
int idx_ifname = 4;
struct interface *ifp;
+ const char *vrf_name;
+
+ if (argv_find(argv, argc, "vrf", &idx_vrf))
+ vrf_name = argv[idx_vrf + 1]->arg;
+ else
+ vrf_name = VRF_DEFAULT_NAME;
+ vrf = vrf_lookup_by_name(vrf_name);
+ if (!vrf) {
+ vty_out(vty, "%% VRF %s not found\n", vrf_name);
+ return CMD_WARNING;
+ }
- if (argc == 4) /* Clear all the ospfv3 interfaces. */
- {
+ if (!argv_find(argv, argc, "IFNAME", &idx_ifname)) {
+ /* Clear all the ospfv3 interfaces. */
FOR_ALL_INTERFACES (vrf, ifp)
ospf6_interface_clear(ifp);
- } else /* Interface name is specified. */
- {
- if ((ifp = if_lookup_by_name(argv[idx_ifname]->arg,
- VRF_DEFAULT))
- == NULL) {
+ } else {
+ /* Interface name is specified. */
+ ifp = if_lookup_by_name_vrf(argv[idx_ifname]->arg, vrf);
+ if (!ifp) {
vty_out(vty, "No such Interface: %s\n",
argv[idx_ifname]->arg);
return CMD_WARNING;