]> git.proxmox.com Git - mirror_frr.git/blobdiff - ospf6d/ospf6_intra.c
Merge pull request #12798 from donaldsharp/rib_match_multicast
[mirror_frr.git] / ospf6d / ospf6_intra.c
index 6abc1c7d0993893dabc63eb500bafb6da925dcd9..e7ce2f5f723e1769c07f6f394990f01823c9fe3a 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>
@@ -142,19 +127,15 @@ static int ospf6_router_lsa_show(struct vty *vty, struct ospf6_lsa *lsa,
                        json_object_string_add(json_loop, "type", name);
                        json_object_int_add(json_loop, "metric",
                                            ntohs(lsdesc->metric));
-                       json_object_string_add(json_loop, "interfaceId",
-                                              inet_ntop(AF_INET,
-                                                        &lsdesc->interface_id,
-                                                        buf, sizeof(buf)));
-                       json_object_string_add(
-                               json_loop, "neighborInterfaceId",
-                               inet_ntop(AF_INET,
-                                         &lsdesc->neighbor_interface_id, buf,
-                                         sizeof(buf)));
-                       json_object_string_add(
-                               json_loop, "neighborRouterId",
-                               inet_ntop(AF_INET, &lsdesc->neighbor_router_id,
-                                         buf, sizeof(buf)));
+                       json_object_string_addf(
+                               json_loop, "interfaceId", "%pI4",
+                               (in_addr_t *)&lsdesc->interface_id);
+                       json_object_string_addf(
+                               json_loop, "neighborInterfaceId", "%pI4",
+                               (in_addr_t *)&lsdesc->neighbor_interface_id);
+                       json_object_string_addf(json_loop, "neighborRouterId",
+                                               "%pI4",
+                                               &lsdesc->neighbor_router_id);
                        json_object_array_add(json_arr, json_loop);
                } else {
                        vty_out(vty, "    Type: %s Metric: %d\n", name,
@@ -228,7 +209,7 @@ int ospf6_router_is_stub_router(struct ospf6_lsa *lsa)
        return OSPF6_NOT_STUB_ROUTER;
 }
 
-int ospf6_router_lsa_originate(struct thread *thread)
+void ospf6_router_lsa_originate(struct thread *thread)
 {
        struct ospf6_area *oa;
 
@@ -253,7 +234,7 @@ int ospf6_router_lsa_originate(struct thread *thread)
                if (IS_DEBUG_OSPF6_GR)
                        zlog_debug(
                                "Graceful Restart in progress, don't originate LSA");
-               return 0;
+               return;
        }
 
        if (IS_OSPF6_DEBUG_ORIGINATE(ROUTER))
@@ -298,7 +279,7 @@ int ospf6_router_lsa_originate(struct thread *thread)
                                       + sizeof(struct ospf6_router_lsa)) {
                                zlog_warn(
                                        "Size limit setting for Router-LSA too short");
-                               return 0;
+                               return;
                        }
 
                        /* Fill LSA Header */
@@ -437,8 +418,6 @@ int ospf6_router_lsa_originate(struct thread *thread)
        if (count && !link_state_id)
                ospf6_spf_schedule(oa->ospf6,
                                   OSPF6_SPF_FLAGS_ROUTER_LSA_ORIGINATED);
-
-       return 0;
 }
 
 /*******************************/
@@ -515,7 +494,7 @@ static int ospf6_network_lsa_show(struct vty *vty, struct ospf6_lsa *lsa,
        return 0;
 }
 
-int ospf6_network_lsa_originate(struct thread *thread)
+void ospf6_network_lsa_originate(struct thread *thread)
 {
        struct ospf6_interface *oi;
 
@@ -542,7 +521,7 @@ int ospf6_network_lsa_originate(struct thread *thread)
                if (IS_DEBUG_OSPF6_GR)
                        zlog_debug(
                                "Graceful Restart in progress, don't originate LSA");
-               return 0;
+               return;
        }
 
        old = ospf6_lsdb_lookup(htons(OSPF6_LSTYPE_NETWORK),
@@ -562,7 +541,7 @@ int ospf6_network_lsa_originate(struct thread *thread)
                                oi->area->ospf6,
                                OSPF6_SPF_FLAGS_NETWORK_LSA_ORIGINATED);
                }
-               return 0;
+               return;
        }
 
        if (IS_OSPF6_DEBUG_ORIGINATE(NETWORK))
@@ -581,7 +560,7 @@ int ospf6_network_lsa_originate(struct thread *thread)
                        zlog_debug("Interface stub, ignore");
                if (old)
                        ospf6_lsa_purge(old);
-               return 0;
+               return;
        }
 
        /* prepare buffer */
@@ -639,8 +618,6 @@ int ospf6_network_lsa_originate(struct thread *thread)
 
        /* Originate */
        ospf6_lsa_originate_area(lsa, oi->area);
-
-       return 0;
 }
 
 
@@ -769,7 +746,7 @@ static int ospf6_link_lsa_show(struct vty *vty, struct ospf6_lsa *lsa,
        return 0;
 }
 
-int ospf6_link_lsa_originate(struct thread *thread)
+void ospf6_link_lsa_originate(struct thread *thread)
 {
        struct ospf6_interface *oi;
 
@@ -789,7 +766,7 @@ int ospf6_link_lsa_originate(struct thread *thread)
                if (IS_DEBUG_OSPF6_GR)
                        zlog_debug(
                                "Graceful Restart in progress, don't originate LSA");
-               return 0;
+               return;
        }
 
 
@@ -801,7 +778,7 @@ int ospf6_link_lsa_originate(struct thread *thread)
        if (CHECK_FLAG(oi->flag, OSPF6_INTERFACE_DISABLE)) {
                if (old)
                        ospf6_lsa_purge(old);
-               return 0;
+               return;
        }
 
        if (IS_OSPF6_DEBUG_ORIGINATE(LINK))
@@ -816,7 +793,7 @@ int ospf6_link_lsa_originate(struct thread *thread)
                                oi->interface->name);
                if (old)
                        ospf6_lsa_purge(old);
-               return 0;
+               return;
        }
 
        /* prepare buffer */
@@ -864,8 +841,6 @@ int ospf6_link_lsa_originate(struct thread *thread)
 
        /* Originate */
        ospf6_lsa_originate_interface(lsa, oi);
-
-       return 0;
 }
 
 
@@ -1007,7 +982,7 @@ static int ospf6_intra_prefix_lsa_show(struct vty *vty, struct ospf6_lsa *lsa,
        return 0;
 }
 
-int ospf6_intra_prefix_lsa_originate_stub(struct thread *thread)
+void ospf6_intra_prefix_lsa_originate_stub(struct thread *thread)
 {
        struct ospf6_area *oa;
 
@@ -1032,7 +1007,7 @@ int ospf6_intra_prefix_lsa_originate_stub(struct thread *thread)
                if (IS_DEBUG_OSPF6_GR)
                        zlog_debug(
                                "Graceful Restart in progress, don't originate LSA");
-               return 0;
+               return;
        }
 
        /* find previous LSA */
@@ -1055,7 +1030,7 @@ int ospf6_intra_prefix_lsa_originate_stub(struct thread *thread)
                                        oa->lsdb);
                        }
                }
-               return 0;
+               return;
        }
 
        if (IS_OSPF6_DEBUG_ORIGINATE(INTRA_PREFIX))
@@ -1131,7 +1106,7 @@ int ospf6_intra_prefix_lsa_originate_stub(struct thread *thread)
                        }
                }
                ospf6_route_table_delete(route_advertise);
-               return 0;
+               return;
        }
 
        /* Neighbor change to FULL, if INTRA-AREA-PREFIX LSA
@@ -1216,7 +1191,7 @@ int ospf6_intra_prefix_lsa_originate_stub(struct thread *thread)
                if (IS_OSPF6_DEBUG_ORIGINATE(INTRA_PREFIX))
                        zlog_debug(
                                "Quit to Advertise Intra-Prefix: no route to advertise");
-               return 0;
+               return;
        }
 
        intra_prefix_lsa->prefix_num = htons(prefix_num);
@@ -1239,12 +1214,10 @@ int ospf6_intra_prefix_lsa_originate_stub(struct thread *thread)
 
        /* Originate */
        ospf6_lsa_originate_area(lsa, oa);
-
-       return 0;
 }
 
 
-int ospf6_intra_prefix_lsa_originate_transit(struct thread *thread)
+void ospf6_intra_prefix_lsa_originate_transit(struct thread *thread)
 {
        struct ospf6_interface *oi;
 
@@ -1272,7 +1245,7 @@ int ospf6_intra_prefix_lsa_originate_transit(struct thread *thread)
                if (IS_DEBUG_OSPF6_GR)
                        zlog_debug(
                                "Graceful Restart in progress, don't originate LSA");
-               return 0;
+               return;
        }
 
        /* find previous LSA */
@@ -1283,7 +1256,7 @@ int ospf6_intra_prefix_lsa_originate_transit(struct thread *thread)
        if (CHECK_FLAG(oi->flag, OSPF6_INTERFACE_DISABLE)) {
                if (old)
                        ospf6_lsa_purge(old);
-               return 0;
+               return;
        }
 
        if (IS_OSPF6_DEBUG_ORIGINATE(INTRA_PREFIX))
@@ -1308,7 +1281,7 @@ int ospf6_intra_prefix_lsa_originate_transit(struct thread *thread)
                        zlog_debug("  Interface is not DR");
                if (old)
                        ospf6_lsa_purge(old);
-               return 0;
+               return;
        }
 
        full_count = 0;
@@ -1321,7 +1294,7 @@ int ospf6_intra_prefix_lsa_originate_transit(struct thread *thread)
                        zlog_debug("  Interface is stub");
                if (old)
                        ospf6_lsa_purge(old);
-               return 0;
+               return;
        }
 
        /* connected prefix to advertise */
@@ -1410,7 +1383,7 @@ int ospf6_intra_prefix_lsa_originate_transit(struct thread *thread)
                if (IS_OSPF6_DEBUG_ORIGINATE(INTRA_PREFIX))
                        zlog_debug(
                                "Quit to Advertise Intra-Prefix: no route to advertise");
-               return 0;
+               return;
        }
 
        intra_prefix_lsa->prefix_num = htons(prefix_num);
@@ -1433,8 +1406,6 @@ int ospf6_intra_prefix_lsa_originate_transit(struct thread *thread)
 
        /* Originate */
        ospf6_lsa_originate_area(lsa, oi->area);
-
-       return 0;
 }
 
 static void ospf6_intra_prefix_update_route_origin(struct ospf6_route *oa_route,
@@ -1779,10 +1750,8 @@ void ospf6_intra_prefix_lsa_add(struct ospf6_lsa *lsa)
        intra_prefix_lsa =
                (struct ospf6_intra_prefix_lsa *)OSPF6_LSA_HEADER_END(
                        lsa->header);
-       if (intra_prefix_lsa->ref_type == htons(OSPF6_LSTYPE_ROUTER))
-               ospf6_linkstate_prefix(intra_prefix_lsa->ref_adv_router,
-                                      intra_prefix_lsa->ref_id, &ls_prefix);
-       else if (intra_prefix_lsa->ref_type == htons(OSPF6_LSTYPE_NETWORK))
+       if (intra_prefix_lsa->ref_type == htons(OSPF6_LSTYPE_ROUTER) ||
+           intra_prefix_lsa->ref_type == htons(OSPF6_LSTYPE_NETWORK))
                ospf6_linkstate_prefix(intra_prefix_lsa->ref_adv_router,
                                       intra_prefix_lsa->ref_id, &ls_prefix);
        else {
@@ -2024,7 +1993,7 @@ void ospf6_intra_prefix_lsa_remove(struct ospf6_lsa *lsa)
                        break;
                prefix_num--;
 
-               memset(&prefix, 0, sizeof(struct prefix));
+               memset(&prefix, 0, sizeof(prefix));
                prefix.family = AF_INET6;
                prefix.prefixlen = op->prefix_length;
                ospf6_prefix_in6_addr(&prefix.u.prefix6, intra_prefix_lsa, op);
@@ -2152,7 +2121,7 @@ static void ospf6_brouter_debug_print(struct ospf6_route *brouter)
        char installed[64], changed[64];
        struct timeval now, res;
        char id[16], adv_router[16];
-       char capa[16], options[16];
+       char capa[16], options[32];
 
        brouter_id = ADV_ROUTER_IN_PREFIX(&brouter->prefix);
        inet_ntop(AF_INET, &brouter_id, brouter_name, sizeof(brouter_name));