]> git.proxmox.com Git - mirror_frr.git/blobdiff - ospfd/ospf_interface.c
*: auto-convert to SPDX License IDs
[mirror_frr.git] / ospfd / ospf_interface.c
index 2a758d55838e63f9dcf59b00779c216baaabe068..4ea367ecad36bf5eac3fc4618ea043c322728dac 100644 (file)
@@ -1,22 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
 /*
  * OSPF Interface functions.
  * Copyright (C) 1999, 2000 Toshiaki Takada
- *
- * 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>
@@ -30,6 +15,7 @@
 #include "command.h"
 #include "stream.h"
 #include "log.h"
+#include "network.h"
 #include "zclient.h"
 #include "bfd.h"
 #include "ldp_sync.h"
@@ -274,7 +260,7 @@ struct ospf_interface *ospf_if_new(struct ospf *ospf, struct interface *ifp,
        oi->t_ls_upd_event = NULL;
        oi->t_ls_ack_direct = NULL;
 
-       oi->crypt_seqnum = time(NULL);
+       oi->crypt_seqnum = frr_sequence32_next();
 
        ospf_opaque_type9_lsa_init(oi);
 
@@ -461,13 +447,13 @@ struct ospf_interface *ospf_if_lookup_recv_if(struct ospf *ospf,
 {
        struct route_node *rn;
        struct prefix_ipv4 addr;
-       struct ospf_interface *oi, *match;
+       struct ospf_interface *oi, *match, *unnumbered_match;
 
        addr.family = AF_INET;
        addr.prefix = src;
        addr.prefixlen = IPV4_MAX_BITLEN;
 
-       match = NULL;
+       match = unnumbered_match = NULL;
 
        for (rn = route_top(IF_OIFS(ifp)); rn; rn = route_next(rn)) {
                oi = rn->info;
@@ -482,7 +468,7 @@ struct ospf_interface *ospf_if_lookup_recv_if(struct ospf *ospf,
                        continue;
 
                if (CHECK_FLAG(oi->connected->flags, ZEBRA_IFA_UNNUMBERED))
-                       match = oi;
+                       unnumbered_match = oi;
                else if (prefix_match(CONNECTED_PREFIX(oi->connected),
                                      (struct prefix *)&addr)) {
                        if ((match == NULL) || (match->address->prefixlen
@@ -491,7 +477,10 @@ struct ospf_interface *ospf_if_lookup_recv_if(struct ospf *ospf,
                }
        }
 
-       return match;
+       if (match)
+               return match;
+
+       return unnumbered_match;
 }
 
 void ospf_interface_fifo_flush(struct ospf_interface *oi)
@@ -909,18 +898,19 @@ struct ospf_interface *ospf_vl_new(struct ospf *ospf,
        struct prefix_ipv4 *p;
 
        if (IS_DEBUG_OSPF_EVENT)
-               zlog_debug("ospf_vl_new()(%s): Start", ospf_get_name(ospf));
+               zlog_debug("%s: (%s): Start", __func__, ospf_get_name(ospf));
        if (vlink_count == OSPF_VL_MAX_COUNT) {
                if (IS_DEBUG_OSPF_EVENT)
                        zlog_debug(
-                               "ospf_vl_new(): Alarm: cannot create more than OSPF_MAX_VL_COUNT virtual links");
+                               "%s: Alarm: cannot create more than OSPF_MAX_VL_COUNT virtual links",
+                               __func__);
+
                return NULL;
        }
 
        if (IS_DEBUG_OSPF_EVENT)
-               zlog_debug(
-                       "ospf_vl_new(): creating pseudo zebra interface vrf id %u",
-                       ospf->vrf_id);
+               zlog_debug("%s: creating pseudo zebra interface vrf id %u",
+                          __func__, ospf->vrf_id);
 
        snprintf(ifname, sizeof(ifname), "VLINK%u", vlink_count);
        vi = if_get_by_name(ifname, ospf->vrf_id, ospf->name);
@@ -944,7 +934,9 @@ struct ospf_interface *ospf_vl_new(struct ospf *ospf,
        if (voi == NULL) {
                if (IS_DEBUG_OSPF_EVENT)
                        zlog_debug(
-                               "ospf_vl_new(): Alarm: OSPF int structure is not created");
+                               "%s: Alarm: OSPF int structure is not created",
+                               __func__);
+
                return NULL;
        }
        voi->connected = co;
@@ -954,17 +946,15 @@ struct ospf_interface *ospf_vl_new(struct ospf *ospf,
 
        vlink_count++;
        if (IS_DEBUG_OSPF_EVENT)
-               zlog_debug("ospf_vl_new(): Created name: %s", ifname);
-       if (IS_DEBUG_OSPF_EVENT)
-               zlog_debug("ospf_vl_new(): set if->name to %s", vi->name);
+               zlog_debug("%s: Created name: %s set if->name to %s", __func__,
+                          ifname, vi->name);
 
        area_id.s_addr = INADDR_ANY;
        area = ospf_area_get(ospf, area_id);
        voi->area = area;
 
        if (IS_DEBUG_OSPF_EVENT)
-               zlog_debug(
-                       "ospf_vl_new(): set associated area to the backbone");
+               zlog_debug("%s: set associated area to the backbone", __func__);
 
        /* Add pseudo neighbor. */
        ospf_nbr_self_reset(voi, voi->ospf->router_id);
@@ -972,7 +962,7 @@ struct ospf_interface *ospf_vl_new(struct ospf *ospf,
        ospf_area_add_if(voi->area, voi);
 
        if (IS_DEBUG_OSPF_EVENT)
-               zlog_debug("ospf_vl_new(): Stop");
+               zlog_debug("%s: Stop", __func__);
        return voi;
 }
 
@@ -1167,10 +1157,8 @@ void ospf_vl_up_check(struct ospf_area *area, struct in_addr rid,
        struct ospf_interface *oi;
 
        if (IS_DEBUG_OSPF_EVENT) {
-               zlog_debug("ospf_vl_up_check(): Start");
-               zlog_debug("ospf_vl_up_check(): Router ID is %pI4",
-                          &rid);
-               zlog_debug("ospf_vl_up_check(): Area is %pI4",
+               zlog_debug("%s: Start", __func__);
+               zlog_debug("%s: Router ID is %pI4 Area is %pI4", __func__, &rid,
                           &area->area_id);
        }
 
@@ -1189,13 +1177,13 @@ void ospf_vl_up_check(struct ospf_area *area, struct in_addr rid,
                        SET_FLAG(vl_data->flags, OSPF_VL_FLAG_APPROVED);
 
                        if (IS_DEBUG_OSPF_EVENT)
-                               zlog_debug(
-                                       "ospf_vl_up_check(): this VL matched");
+                               zlog_debug("%s: this VL matched", __func__);
 
                        if (oi->state == ISM_Down) {
                                if (IS_DEBUG_OSPF_EVENT)
                                        zlog_debug(
-                                               "ospf_vl_up_check(): VL is down, waking it up");
+                                               "%s: VL is down, waking it up",
+                                               __func__);
                                SET_FLAG(oi->ifp->flags, IFF_UP);
                                OSPF_ISM_EVENT_EXECUTE(oi, ISM_InterfaceUp);
                        }
@@ -1203,13 +1191,15 @@ void ospf_vl_up_check(struct ospf_area *area, struct in_addr rid,
                        if (ospf_vl_set_params(area, vl_data, v)) {
                                if (IS_DEBUG_OSPF(ism, ISM_EVENTS))
                                        zlog_debug(
-                                               "ospf_vl_up_check: VL cost change, scheduling router lsa refresh");
+                                               "%s: VL cost change, scheduling router lsa refresh",
+                                               __func__);
                                if (ospf->backbone)
                                        ospf_router_lsa_update_area(
                                                ospf->backbone);
                                else if (IS_DEBUG_OSPF(ism, ISM_EVENTS))
                                        zlog_debug(
-                                               "ospf_vl_up_check: VL cost change, no backbone!");
+                                               "%s: VL cost change, no backbone!",
+                                               __func__);
                        }
                }
        }