]> git.proxmox.com Git - mirror_frr.git/blobdiff - ospfd/ospf_packet.c
Merge pull request #12798 from donaldsharp/rib_match_multicast
[mirror_frr.git] / ospfd / ospf_packet.c
index 466b5fa2a27cd062553eda548682465950b738d9..5268c9896b470ca604214805fd882e5b7fa0d4dc 100644 (file)
@@ -1,22 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
 /*
  * OSPF Sending and Receiving OSPF Packets.
  * 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>
@@ -43,6 +28,7 @@
 #include "ospfd/ospf_network.h"
 #include "ospfd/ospf_interface.h"
 #include "ospfd/ospf_ism.h"
+#include "ospfd/ospf_abr.h"
 #include "ospfd/ospf_asbr.h"
 #include "ospfd/ospf_lsa.h"
 #include "ospfd/ospf_lsdb.h"
@@ -1169,8 +1155,8 @@ static void ospf_db_desc_proc(struct stream *s, struct ospf_interface *oi,
                if (IS_OPAQUE_LSA(lsah->type)
                    && !CHECK_FLAG(nbr->options, OSPF_OPTION_O)) {
                        flog_warn(EC_OSPF_PACKET,
-                                 "LSA[Type%d:%pI4]: Opaque capability mismatch?",
-                                 lsah->type, &lsah->id);
+                                 "LSA[Type%d:%pI4] from %pI4: Opaque capability mismatch?",
+                                 lsah->type, &lsah->id, &lsah->adv_router);
                        OSPF_NSM_EVENT_SCHEDULE(nbr, NSM_SeqNumberMismatch);
                        return;
                }
@@ -1716,6 +1702,12 @@ static struct list *ospf_ls_upd_list_lsa(struct ospf_neighbor *nbr,
                        break;
                }
 
+               if (length < OSPF_LSA_HEADER_SIZE) {
+                       flog_warn(EC_OSPF_PACKET,
+                                 "Link State Update: LSA length too small.");
+                       break;
+               }
+
                /* Validate the LSA's LS checksum. */
                sum = lsah->checksum;
                if (!ospf_lsa_checksum_valid(lsah)) {
@@ -1781,9 +1773,10 @@ static struct list *ospf_ls_upd_list_lsa(struct ospf_neighbor *nbr,
                                continue;
                        }
                } else if (IS_OPAQUE_LSA(lsah->type)) {
-                       flog_warn(EC_OSPF_PACKET,
-                                 "LSA[Type%d:%pI4]: Opaque capability mismatch?",
-                                 lsah->type, &lsah->id);
+                       flog_warn(
+                               EC_OSPF_PACKET,
+                               "LSA[Type%d:%pI4] from %pI4: Opaque capability mismatch?",
+                               lsah->type, &lsah->id, &lsah->adv_router);
                        continue;
                }
 
@@ -3325,6 +3318,14 @@ static int ospf_make_hello(struct ospf_interface *oi, struct stream *s)
        else
                stream_putw(s, 0); /* hello-interval of 0 for fast-hellos */
 
+       /* Check if flood-reduction is enabled,
+        * if yes set the DC bit in the options.
+        */
+       if (OSPF_FR_CONFIG(oi->ospf, oi->area))
+               SET_FLAG(OPTIONS(oi), OSPF_OPTION_DC);
+       else if (CHECK_FLAG(OPTIONS(oi), OSPF_OPTION_DC))
+               UNSET_FLAG(OPTIONS(oi), OSPF_OPTION_DC);
+
        if (IS_DEBUG_OSPF_EVENT)
                zlog_debug("%s: options: %x, int: %s", __func__, OPTIONS(oi),
                           IF_NAME(oi));
@@ -3413,6 +3414,8 @@ static int ospf_make_db_desc(struct ospf_interface *oi,
        options = OPTIONS(oi);
        if (CHECK_FLAG(oi->ospf->config, OSPF_OPAQUE_CAPABLE))
                SET_FLAG(options, OSPF_OPTION_O);
+       if (OSPF_FR_CONFIG(oi->ospf, oi->area))
+               SET_FLAG(options, OSPF_OPTION_DC);
        stream_putc(s, options);
 
        /* DD flags */