]> git.proxmox.com Git - mirror_frr.git/blobdiff - ospf6d/ospf6_interface.c
Merge pull request #12798 from donaldsharp/rib_match_multicast
[mirror_frr.git] / ospf6d / ospf6_interface.c
index c58bb3a0fbad9807c561a8dec4110bfcdf94f3b2..7a22fdf0641f96cd41524ba3a33f1fee567d3793 100644 (file)
@@ -1,21 +1,6 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
 /*
  * Copyright (C) 2003 Yasuhiro Ohara
- *
- * 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 this program; see the file COPYING; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
 #include <zebra.h>
@@ -37,6 +22,7 @@
 #include "ospf6_route.h"
 #include "ospf6_area.h"
 #include "ospf6_abr.h"
+#include "ospf6_nssa.h"
 #include "ospf6_interface.h"
 #include "ospf6_neighbor.h"
 #include "ospf6_intra.h"
@@ -165,8 +151,6 @@ static uint32_t ospf6_interface_get_cost(struct ospf6_interface *oi)
                cost = (uint32_t)((double)refbw / (double)bw + (double)0.5);
                if (cost < 1)
                        cost = 1;
-               else if (cost > UINT32_MAX)
-                       cost = UINT32_MAX;
        }
 
        return cost;
@@ -304,6 +288,9 @@ void ospf6_interface_delete(struct ospf6_interface *oi)
        /* disable from area list if possible */
        ospf6_area_interface_delete(oi);
 
+       if (oi->at_data.auth_key)
+               XFREE(MTYPE_OSPF6_AUTH_MANUAL_KEY, oi->at_data.auth_key);
+
        /* Free BFD allocated data. */
        XFREE(MTYPE_TMP, oi->bfd_config.profile);
 
@@ -968,10 +955,6 @@ 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)
@@ -998,11 +981,8 @@ static int ospf6_interface_show(struct vty *vty, struct interface *ifp,
                                       ospf6_iftype_str(default_iftype));
                json_object_int_add(json_obj, "interfaceId", ifp->ifindex);
 
-               if (ifp->info == NULL) {
-                       json_object_boolean_false_add(json_obj, "ospf6Enabled");
+               if (ifp->info == NULL)
                        return 0;
-               }
-               json_object_boolean_true_add(json_obj, "ospf6Enabled");
 
                oi = (struct ospf6_interface *)ifp->info;
 
@@ -1125,14 +1105,21 @@ static int ospf6_interface_show(struct vty *vty, struct interface *ifp,
                                    oi->dead_interval);
                json_object_int_add(json_obj, "timerIntervalsConfigRetransmit",
                                    oi->rxmt_interval);
+               json_object_boolean_add(
+                       json_obj, "timerPassiveIface",
+                       !!CHECK_FLAG(oi->flag, OSPF6_INTERFACE_PASSIVE));
        } else {
                vty_out(vty, "  State %s, Transmit Delay %d sec, Priority %d\n",
                        ospf6_interface_state_str[oi->state], oi->transdelay,
                        oi->priority);
                vty_out(vty, "  Timer intervals configured:\n");
-               vty_out(vty, "   Hello %d(%pTHd), Dead %d, Retransmit %d\n",
-                       oi->hello_interval, oi->thread_send_hello,
-                       oi->dead_interval, oi->rxmt_interval);
+               if (!CHECK_FLAG(oi->flag, OSPF6_INTERFACE_PASSIVE))
+                       vty_out(vty,
+                               "   Hello %d(%pTHd), Dead %d, Retransmit %d\n",
+                               oi->hello_interval, oi->thread_send_hello,
+                               oi->dead_interval, oi->rxmt_interval);
+               else
+                       vty_out(vty, "   No Hellos (Passive interface)\n");
        }
 
        inet_ntop(AF_INET, &oi->drouter, drouter, sizeof(drouter));
@@ -1152,7 +1139,7 @@ static int ospf6_interface_show(struct vty *vty, struct interface *ifp,
 
        if (use_json) {
                timerclear(&res);
-               if (oi->thread_send_lsupdate)
+               if (thread_is_scheduled(oi->thread_send_lsupdate))
                        timersub(&oi->thread_send_lsupdate->u.sands, &now,
                                 &res);
                timerstring(&res, duration, sizeof(duration));
@@ -1162,7 +1149,9 @@ static int ospf6_interface_show(struct vty *vty, struct interface *ifp,
                                       duration);
                json_object_string_add(
                        json_obj, "lsUpdateSendThread",
-                       (oi->thread_send_lsupdate ? "on" : "off"));
+                       (thread_is_scheduled(oi->thread_send_lsupdate)
+                                ? "on"
+                                : "off"));
 
                json_arr = json_object_new_array();
                for (ALL_LSDB(oi->lsupdate_list, lsa, lsanext))
@@ -1172,7 +1161,7 @@ static int ospf6_interface_show(struct vty *vty, struct interface *ifp,
                                       json_arr);
 
                timerclear(&res);
-               if (oi->thread_send_lsack)
+               if (thread_is_scheduled(oi->thread_send_lsack))
                        timersub(&oi->thread_send_lsack->u.sands, &now, &res);
                timerstring(&res, duration, sizeof(duration));
 
@@ -1180,8 +1169,10 @@ static int ospf6_interface_show(struct vty *vty, struct interface *ifp,
                                    oi->lsack_list->count);
                json_object_string_add(json_obj, "pendingLsaLsAckTime",
                                       duration);
-               json_object_string_add(json_obj, "lsAckSendThread",
-                                      (oi->thread_send_lsack ? "on" : "off"));
+               json_object_string_add(
+                       json_obj, "lsAckSendThread",
+                       (thread_is_scheduled(oi->thread_send_lsack) ? "on"
+                                                                   : "off"));
 
                json_arr = json_object_new_array();
                for (ALL_LSDB(oi->lsack_list, lsa, lsanext))
@@ -1191,25 +1182,28 @@ static int ospf6_interface_show(struct vty *vty, struct interface *ifp,
 
        } else {
                timerclear(&res);
-               if (oi->thread_send_lsupdate)
+               if (thread_is_scheduled(oi->thread_send_lsupdate))
                        timersub(&oi->thread_send_lsupdate->u.sands, &now,
                                 &res);
                timerstring(&res, duration, sizeof(duration));
                vty_out(vty,
                        "    %d Pending LSAs for LSUpdate in Time %s [thread %s]\n",
                        oi->lsupdate_list->count, duration,
-                       (oi->thread_send_lsupdate ? "on" : "off"));
+                       (thread_is_scheduled(oi->thread_send_lsupdate)
+                                ? "on"
+                                : "off"));
                for (ALL_LSDB(oi->lsupdate_list, lsa, lsanext))
                        vty_out(vty, "      %s\n", lsa->name);
 
                timerclear(&res);
-               if (oi->thread_send_lsack)
+               if (thread_is_scheduled(oi->thread_send_lsack))
                        timersub(&oi->thread_send_lsack->u.sands, &now, &res);
                timerstring(&res, duration, sizeof(duration));
                vty_out(vty,
                        "    %d Pending LSAs for LSAck in Time %s [thread %s]\n",
                        oi->lsack_list->count, duration,
-                       (oi->thread_send_lsack ? "on" : "off"));
+                       (thread_is_scheduled(oi->thread_send_lsack) ? "on"
+                                                                   : "off"));
                for (ALL_LSDB(oi->lsack_list, lsa, lsanext))
                        vty_out(vty, "      %s\n", lsa->name);
        }
@@ -1236,7 +1230,8 @@ static int ospf6_interface_show(struct vty *vty, struct interface *ifp,
                }
        }
 
-       json_auth = json_object_new_object();
+       if (use_json)
+               json_auth = json_object_new_object();
        if (oi->at_data.flags != 0) {
                if (use_json) {
                        if (CHECK_FLAG(oi->at_data.flags,
@@ -1714,8 +1709,11 @@ void ospf6_interface_start(struct ospf6_interface *oi)
        if (oi->area_id_format == OSPF6_AREA_FMT_UNSET)
                return;
 
-       if (oi->area)
+       if (oi->area) {
+               /* Recompute cost */
+               ospf6_interface_recalculate_cost(oi);
                return;
+       }
 
        ospf6 = oi->interface->vrf->info;
        if (!ospf6)
@@ -1735,8 +1733,10 @@ void ospf6_interface_start(struct ospf6_interface *oi)
        ospf6_interface_enable(oi);
 
        /* If the router is ABR, originate summary routes */
-       if (ospf6_check_and_set_router_abr(ospf6))
+       if (ospf6_check_and_set_router_abr(ospf6)) {
                ospf6_abr_enable_area(oa);
+               ospf6_schedule_abr_task(ospf6);
+       }
 }
 
 void ospf6_interface_stop(struct ospf6_interface *oi)