]>
Commit | Line | Data |
---|---|---|
f96f2713 | 1 | /* |
2 | * OSPF Graceful Restart helper functions. | |
3 | * | |
4 | * Copyright (C) 2020-21 Vmware, Inc. | |
5 | * Rajesh Kumar Girada | |
6 | * | |
7 | * This file is part of GNU Zebra. | |
8 | * | |
9 | * GNU Zebra is free software; you can redistribute it and/or modify it | |
10 | * under the terms of the GNU General Public License as published by the | |
11 | * Free Software Foundation; either version 2, or (at your option) any | |
12 | * later version. | |
13 | * | |
14 | * GNU Zebra is distributed in the hope that it will be useful, but | |
15 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
17 | * General Public License for more details. | |
18 | * | |
19 | * You should have received a copy of the GNU General Public License along | |
20 | * with this program; see the file COPYING; if not, write to the Free Software | |
21 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
22 | */ | |
23 | ||
cd52c44c RW |
24 | #ifndef _ZEBRA_OSPF_GR_H |
25 | #define _ZEBRA_OSPF_GR_H | |
f96f2713 | 26 | |
27 | #define OSPF_GR_NOT_HELPER 0 | |
28 | #define OSPF_GR_ACTIVE_HELPER 1 | |
29 | ||
30 | #define OSPF_GR_HELPER_NO_LSACHECK 0 | |
31 | #define OSPF_GR_HELPER_LSACHECK 1 | |
32 | ||
33 | #define OSPF_MAX_GRACE_INTERVAL 1800 | |
34 | #define OSPF_MIN_GRACE_INTERVAL 1 | |
10514170 | 35 | #define OSPF_DFLT_GRACE_INTERVAL 120 |
f96f2713 | 36 | |
37 | enum ospf_helper_exit_reason { | |
38 | OSPF_GR_HELPER_EXIT_NONE = 0, | |
39 | OSPF_GR_HELPER_INPROGRESS, | |
40 | OSPF_GR_HELPER_TOPO_CHG, | |
41 | OSPF_GR_HELPER_GRACE_TIMEOUT, | |
42 | OSPF_GR_HELPER_COMPLETED | |
43 | }; | |
44 | ||
45 | enum ospf_gr_restart_reason { | |
46 | OSPF_GR_UNKNOWN_RESTART = 0, | |
47 | OSPF_GR_SW_RESTART = 1, | |
48 | OSPF_GR_SW_UPGRADE = 2, | |
49 | OSPF_GR_SWITCH_REDUNDANT_CARD = 3, | |
50 | OSPF_GR_INVALID_REASON_CODE = 4 | |
51 | }; | |
52 | ||
53 | enum ospf_gr_helper_rejected_reason { | |
54 | OSPF_HELPER_REJECTED_NONE, | |
55 | OSPF_HELPER_SUPPORT_DISABLED, | |
56 | OSPF_HELPER_NOT_A_VALID_NEIGHBOUR, | |
57 | OSPF_HELPER_PLANNED_ONLY_RESTART, | |
58 | OSPF_HELPER_TOPO_CHANGE_RTXMT_LIST, | |
10514170 RW |
59 | OSPF_HELPER_LSA_AGE_MORE, |
60 | OSPF_HELPER_RESTARTING, | |
f96f2713 | 61 | }; |
62 | ||
63 | /* Ref RFC3623 appendex-A */ | |
64 | /* Grace period TLV */ | |
65 | #define GRACE_PERIOD_TYPE 1 | |
66 | #define GRACE_PERIOD_LENGTH 4 | |
67 | ||
68 | struct grace_tlv_graceperiod { | |
69 | struct tlv_header header; | |
70 | uint32_t interval; | |
71 | }; | |
72 | ||
73 | /* Restart reason TLV */ | |
74 | #define RESTART_REASON_TYPE 2 | |
75 | #define RESTART_REASON_LENGTH 1 | |
76 | ||
77 | struct grace_tlv_restart_reason { | |
78 | struct tlv_header header; | |
79 | uint8_t reason; | |
80 | uint8_t reserved[3]; | |
81 | }; | |
82 | ||
83 | /* Restarter ip address TLV */ | |
84 | #define RESTARTER_IP_ADDR_TYPE 3 | |
85 | #define RESTARTER_IP_ADDR_LEN 4 | |
86 | ||
87 | struct grace_tlv_restart_addr { | |
88 | struct tlv_header header; | |
89 | struct in_addr addr; | |
90 | }; | |
91 | ||
92 | struct ospf_helper_info { | |
93 | ||
94 | /* Grace interval received from | |
95 | * Restarting Router. | |
96 | */ | |
97 | uint32_t recvd_grace_period; | |
98 | ||
99 | /* Grace interval used for grace | |
100 | * gracetimer. | |
101 | */ | |
102 | uint32_t actual_grace_period; | |
103 | ||
104 | /* Grace timer,This Router acts as | |
105 | * helper until this timer until | |
cd52c44c RW |
106 | * this timer expires. |
107 | */ | |
f96f2713 | 108 | struct thread *t_grace_timer; |
109 | ||
110 | /* Helper status */ | |
111 | uint32_t gr_helper_status; | |
112 | ||
113 | /* Helper exit reason*/ | |
114 | enum ospf_helper_exit_reason helper_exit_reason; | |
115 | ||
116 | /* Planned/Unplanned restart*/ | |
117 | enum ospf_gr_restart_reason gr_restart_reason; | |
118 | ||
119 | /* Helper rejected reason */ | |
120 | enum ospf_gr_helper_rejected_reason rejected_reason; | |
121 | }; | |
122 | ||
123 | struct advRtr { | |
124 | struct in_addr advRtrAddr; | |
125 | }; | |
126 | ||
127 | #define OSPF_HELPER_ENABLE_RTR_COUNT(ospf) (ospf->enable_rtr_list->count) | |
128 | ||
129 | /* Check for planned restart */ | |
130 | #define OSPF_GR_IS_PLANNED_RESTART(reason) \ | |
131 | ((reason == OSPF_GR_SW_RESTART) || (reason == OSPF_GR_SW_UPGRADE)) | |
132 | ||
133 | /* Check the router is HELPER for current neighbour */ | |
134 | #define OSPF_GR_IS_ACTIVE_HELPER(N) \ | |
135 | ((N)->gr_helper_info.gr_helper_status == OSPF_GR_ACTIVE_HELPER) | |
136 | ||
137 | /* Check the LSA is GRACE LSA */ | |
138 | #define IS_GRACE_LSA(lsa) \ | |
139 | ((lsa->data->type == OSPF_OPAQUE_LINK_LSA) \ | |
140 | && (GET_OPAQUE_TYPE(ntohl(lsa->data->id.s_addr)) \ | |
141 | == OPAQUE_TYPE_GRACE_LSA)) | |
142 | ||
143 | /* Check neighbour is in FULL state */ | |
144 | #define IS_NBR_STATE_FULL(nbr) (nsm_should_adj(nbr) && (nbr->state == NSM_Full)) | |
145 | ||
146 | /* Check neighbour is DR_OTHER and state is 2_WAY */ | |
147 | #define IS_NBR_STATE_2_WAY_WITH_DROTHER(nbr) \ | |
148 | ((ospf_get_nbr_ism_role(nbr) == ISM_DROther) \ | |
149 | && (nbr->state == NSM_TwoWay)) | |
150 | ||
151 | #define OSPF_GR_FALSE false | |
152 | #define OSPF_GR_TRUE true | |
153 | ||
154 | #define OSPF_GR_SUCCESS 1 | |
155 | #define OSPF_GR_FAILURE 0 | |
156 | #define OSPF_GR_INVALID -1 | |
06bc3110 | 157 | |
d05d5280 MS |
158 | const char *ospf_exit_reason2str(unsigned int reason); |
159 | const char *ospf_restart_reason2str(unsigned int reason); | |
160 | const char *ospf_rejected_reason2str(unsigned int reason); | |
abd5b8c7 | 161 | |
51f8588e RW |
162 | extern void ospf_gr_helper_instance_init(struct ospf *ospf); |
163 | extern void ospf_gr_helper_instance_stop(struct ospf *ospf); | |
164 | extern void ospf_gr_helper_init(void); | |
165 | extern void ospf_gr_helper_stop(void); | |
ad686992 | 166 | extern int ospf_process_grace_lsa(struct ospf *ospf, struct ospf_lsa *lsa, |
167 | struct ospf_neighbor *nbr); | |
168 | extern void ospf_gr_helper_exit(struct ospf_neighbor *nbr, | |
169 | enum ospf_helper_exit_reason reason); | |
df074ec3 | 170 | extern void ospf_process_maxage_grace_lsa(struct ospf *ospf, |
171 | struct ospf_lsa *lsa, | |
172 | struct ospf_neighbor *nbr); | |
173 | extern void ospf_helper_handle_topo_chg(struct ospf *ospf, | |
174 | struct ospf_lsa *lsa); | |
07b33add | 175 | extern void ospf_gr_helper_support_set(struct ospf *ospf, bool support); |
176 | extern void ospf_gr_helper_support_set_per_routerid(struct ospf *ospf, | |
177 | struct in_addr *rid, | |
178 | bool support); | |
179 | extern void ospf_gr_helper_lsa_check_set(struct ospf *ospf, bool lsacheck); | |
180 | extern void ospf_gr_helper_supported_gracetime_set(struct ospf *ospf, | |
181 | uint32_t interval); | |
182 | extern void ospf_gr_helper_set_supported_planned_only_restart(struct ospf *ospf, | |
183 | bool planned_only); | |
10514170 RW |
184 | |
185 | extern void ospf_gr_check_lsdb_consistency(struct ospf *ospf, | |
186 | struct ospf_area *area); | |
187 | extern void ospf_gr_check_adjs(struct ospf *ospf); | |
188 | extern void ospf_gr_nvm_read(struct ospf *ospf); | |
189 | extern void ospf_gr_init(void); | |
190 | ||
cd52c44c | 191 | #endif /* _ZEBRA_OSPF_GR_H */ |