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