]> git.puffer.fish Git - mirror/frr.git/commitdiff
ospfd: ospf GR helper data structure definitions.
authorrgirada <rgirada@vmware.com>
Fri, 21 Aug 2020 11:46:56 +0000 (04:46 -0700)
committerrgirada <rgirada@vmware.com>
Tue, 22 Sep 2020 06:59:59 +0000 (23:59 -0700)
Description:
Graceful restart helper support specific data structure
changes.

Signed-off-by: Rajesh Girada <rgirada@vmware.com>
ospfd/ospf_dump.h
ospfd/ospf_gr_helper.h [new file with mode: 0644]
ospfd/ospf_neighbor.h
ospfd/ospfd.h

index faae27e2cf593f2c4ff0054d792cc1c8a96e2f23..a2df4ff22c1ebfecd7bf54612cf8e4d56f4e8219 100644 (file)
@@ -62,6 +62,9 @@
 #define OSPF_DEBUG_DEFAULTINFO 0x20
 #define OSPF_DEBUG_LDP_SYNC 0x40
 
+#define OSPF_DEBUG_GR_HELPER 0x01
+#define OSPF_DEBUG_GR 0x03
+
 /* Macro for setting debug option. */
 #define CONF_DEBUG_PACKET_ON(a, b)         conf_debug_ospf_packet[a] |= (b)
 #define CONF_DEBUG_PACKET_OFF(a, b)        conf_debug_ospf_packet[a] &= ~(b)
 #define IS_DEBUG_OSPF_DEFAULT_INFO IS_DEBUG_OSPF(defaultinfo, DEFAULTINFO)
 
 #define IS_DEBUG_OSPF_LDP_SYNC IS_DEBUG_OSPF(ldp_sync, LDP_SYNC)
+#define IS_DEBUG_OSPF_GR_HELPER IS_DEBUG_OSPF(gr, GR_HELPER)
 
 #define IS_CONF_DEBUG_OSPF_PACKET(a, b)                                        \
        (conf_debug_ospf_packet[a] & OSPF_DEBUG_##b)
@@ -130,6 +134,7 @@ extern unsigned long term_debug_ospf_ext;
 extern unsigned long term_debug_ospf_sr;
 extern unsigned long term_debug_ospf_defaultinfo;
 extern unsigned long term_debug_ospf_ldp_sync;
+extern unsigned long term_debug_ospf_gr;
 
 /* Message Strings. */
 extern char *ospf_lsa_type_str[];
diff --git a/ospfd/ospf_gr_helper.h b/ospfd/ospf_gr_helper.h
new file mode 100644 (file)
index 0000000..8cf9f3a
--- /dev/null
@@ -0,0 +1,154 @@
+/*
+ * OSPF Graceful Restart helper functions.
+ *
+ * Copyright (C) 2020-21 Vmware, Inc.
+ * Rajesh Kumar Girada
+ *
+ * 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
+ */
+
+#ifndef _ZEBRA_OSPF_HELPER_H
+#define _ZEBRA_OSPF_HELPER_H
+
+#define OSPF_GR_NOT_HELPER 0
+#define OSPF_GR_ACTIVE_HELPER 1
+
+#define OSPF_GR_HELPER_NO_LSACHECK 0
+#define OSPF_GR_HELPER_LSACHECK 1
+
+#define OSPF_MAX_GRACE_INTERVAL 1800
+#define OSPF_MIN_GRACE_INTERVAL 1
+
+enum ospf_helper_exit_reason {
+       OSPF_GR_HELPER_EXIT_NONE = 0,
+       OSPF_GR_HELPER_INPROGRESS,
+       OSPF_GR_HELPER_TOPO_CHG,
+       OSPF_GR_HELPER_GRACE_TIMEOUT,
+       OSPF_GR_HELPER_COMPLETED
+};
+
+enum ospf_gr_restart_reason {
+       OSPF_GR_UNKNOWN_RESTART = 0,
+       OSPF_GR_SW_RESTART = 1,
+       OSPF_GR_SW_UPGRADE = 2,
+       OSPF_GR_SWITCH_REDUNDANT_CARD = 3,
+       OSPF_GR_INVALID_REASON_CODE = 4
+};
+
+enum ospf_gr_helper_rejected_reason {
+       OSPF_HELPER_REJECTED_NONE,
+       OSPF_HELPER_SUPPORT_DISABLED,
+       OSPF_HELPER_NOT_A_VALID_NEIGHBOUR,
+       OSPF_HELPER_PLANNED_ONLY_RESTART,
+       OSPF_HELPER_TOPO_CHANGE_RTXMT_LIST,
+       OSPF_HELPER_LSA_AGE_MORE
+};
+
+/* Ref RFC3623 appendex-A */
+/* Grace period TLV */
+#define GRACE_PERIOD_TYPE 1
+#define GRACE_PERIOD_LENGTH 4
+
+struct grace_tlv_graceperiod {
+       struct tlv_header header;
+       uint32_t interval;
+};
+
+/* Restart reason TLV */
+#define RESTART_REASON_TYPE 2
+#define RESTART_REASON_LENGTH 1
+
+struct grace_tlv_restart_reason {
+       struct tlv_header header;
+       uint8_t reason;
+       uint8_t reserved[3];
+};
+
+/* Restarter ip address TLV */
+#define RESTARTER_IP_ADDR_TYPE 3
+#define RESTARTER_IP_ADDR_LEN 4
+
+struct grace_tlv_restart_addr {
+       struct tlv_header header;
+       struct in_addr addr;
+};
+
+struct ospf_helper_info {
+
+       /* Grace interval received from
+        * Restarting Router.
+        */
+       uint32_t recvd_grace_period;
+
+       /* Grace interval used for grace
+        * gracetimer.
+        */
+       uint32_t actual_grace_period;
+
+       /* Grace timer,This Router acts as
+        * helper until this timer until
+        * this timer expires*/
+       struct thread *t_grace_timer;
+
+       /* Helper status */
+       uint32_t gr_helper_status;
+
+       /* Helper exit reason*/
+       enum ospf_helper_exit_reason helper_exit_reason;
+
+       /* Planned/Unplanned restart*/
+       enum ospf_gr_restart_reason  gr_restart_reason;
+
+       /* Helper rejected reason */
+       enum ospf_gr_helper_rejected_reason rejected_reason;
+};
+
+struct advRtr {
+       struct in_addr advRtrAddr;
+};
+
+#define OSPF_HELPER_ENABLE_RTR_COUNT(ospf) (ospf->enable_rtr_list->count)
+
+/* Check for planned restart */
+#define OSPF_GR_IS_PLANNED_RESTART(reason)                                     \
+       ((reason == OSPF_GR_SW_RESTART) || (reason == OSPF_GR_SW_UPGRADE))
+
+/* Check the router is HELPER for current neighbour */
+#define OSPF_GR_IS_ACTIVE_HELPER(N)                                                         \
+       ((N)->gr_helper_info.gr_helper_status == OSPF_GR_ACTIVE_HELPER)
+
+/* Check the LSA is GRACE LSA */
+#define IS_GRACE_LSA(lsa)                                                      \
+       ((lsa->data->type == OSPF_OPAQUE_LINK_LSA)                             \
+        && (GET_OPAQUE_TYPE(ntohl(lsa->data->id.s_addr))                      \
+            == OPAQUE_TYPE_GRACE_LSA))
+
+/* Check neighbour is in FULL state */
+#define IS_NBR_STATE_FULL(nbr) (nsm_should_adj(nbr) && (nbr->state == NSM_Full))
+
+/* Check neighbour is DR_OTHER and state is 2_WAY */
+#define IS_NBR_STATE_2_WAY_WITH_DROTHER(nbr)                                   \
+       ((ospf_get_nbr_ism_role(nbr) == ISM_DROther)                           \
+        && (nbr->state == NSM_TwoWay))
+
+#define OSPF_GR_FALSE false
+#define OSPF_GR_TRUE true
+
+#define OSPF_GR_SUCCESS 1
+#define OSPF_GR_FAILURE 0
+#define OSPF_GR_INVALID -1
+#endif /* _ZEBRA_OSPF_HELPER_H */
index 91dfc7a276dbeb11094aad106257ced2e30ce605..758693e28948fd79f72c07e807d550c66c2984c1 100644 (file)
@@ -22,6 +22,7 @@
 #ifndef _ZEBRA_OSPF_NEIGHBOR_H
 #define _ZEBRA_OSPF_NEIGHBOR_H
 
+#include <ospfd/ospf_gr_helper.h>
 #include <ospfd/ospf_packet.h>
 
 /* Neighbor Data Structure */
@@ -88,6 +89,9 @@ struct ospf_neighbor {
 
        /* BFD information */
        void *bfd_info;
+
+       /* ospf graceful restart HELPER info */
+       struct ospf_helper_info gr_helper_info;
 };
 
 /* Macros. */
@@ -113,5 +117,4 @@ extern struct ospf_neighbor *ospf_nbr_lookup_by_addr(struct route_table *,
 extern struct ospf_neighbor *ospf_nbr_lookup_by_routerid(struct route_table *,
                                                         struct in_addr *);
 extern void ospf_renegotiate_optional_capabilities(struct ospf *top);
-
 #endif /* _ZEBRA_OSPF_NEIGHBOR_H */
index 55bc64317ed3f045310ff849eabda24d9e060636..5009355d48d3f2414631253e950f7ab9fd91b9fa 100644 (file)
@@ -319,7 +319,41 @@ struct ospf {
 
        /* Redistributed external information. */
        struct list *external[ZEBRA_ROUTE_MAX + 1];
-#define EXTERNAL_INFO(E)      (E->external_info)
+#define EXTERNAL_INFO(E) (E->external_info)
+
+       /* Gracefull restart Helper supported configs*/
+       /* Supported grace interval*/
+       uint32_t supported_grace_time;
+
+       /* Helper support
+        * Supported : True
+        * Not Supported : False.
+        */
+       bool is_helper_supported;
+
+       /* Support for strict LSA check.
+        * if it is set,Helper aborted
+        * upon a TOPO change.
+        */
+       bool strict_lsa_check;
+
+       /* Support as HELPER only for
+        * planned restarts.
+        */
+       bool only_planned_restart;
+
+       /* This list contains the advertisement
+        * routerids which are not support for HELPERs.
+        */
+       struct hash *enable_rtr_list;
+
+       /* HELPER for number of active
+        * RESTARTERs.
+        */
+       uint16_t active_restarter_cnt;
+
+       /* last HELPER exit reason */
+       uint32_t last_exit_reason;
 
        /* MPLS LDP-IGP Sync */
        struct ldp_sync_info_cmd ldp_sync_cmd;