]>
Commit | Line | Data |
---|---|---|
12e41d03 | 1 | /* |
896014f4 DL |
2 | * PIM for Quagga |
3 | * Copyright (C) 2008 Everton da Silva Marques | |
4 | * | |
5 | * This program is free software; you can redistribute it and/or modify | |
6 | * it under the terms of the GNU General Public License as published by | |
7 | * the Free Software Foundation; either version 2 of the License, or | |
8 | * (at your option) any later version. | |
9 | * | |
10 | * This program is distributed in the hope that it will be useful, but | |
11 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 | * General Public License for more details. | |
14 | * | |
15 | * You should have received a copy of the GNU General Public License along | |
16 | * with this program; see the file COPYING; if not, write to the Free Software | |
17 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
83190a40 | 18 | */ |
12e41d03 DL |
19 | |
20 | #ifndef PIM_IFACE_H | |
21 | #define PIM_IFACE_H | |
22 | ||
23 | #include <zebra.h> | |
24 | ||
25 | #include "if.h" | |
26 | #include "vty.h" | |
ba4eb1bc CS |
27 | #include "vrf.h" |
28 | #include "zclient.h" | |
37664928 | 29 | #include "ferr.h" |
12e41d03 DL |
30 | |
31 | #include "pim_igmp.h" | |
32 | #include "pim_upstream.h" | |
e34e07e6 | 33 | #include "pim_instance.h" |
ba4eb1bc | 34 | #include "bfd.h" |
568b78b5 | 35 | #include "pim_str.h" |
12e41d03 DL |
36 | |
37 | #define PIM_IF_MASK_PIM (1 << 0) | |
38 | #define PIM_IF_MASK_IGMP (1 << 1) | |
39 | #define PIM_IF_MASK_IGMP_LISTEN_ALLROUTERS (1 << 2) | |
7c98d487 | 40 | #define PIM_IF_MASK_PIM_CAN_DISABLE_JOIN_SUPPRESSION (1 << 3) |
12e41d03 DL |
41 | |
42 | #define PIM_IF_IS_DELETED(ifp) ((ifp)->ifindex == IFINDEX_INTERNAL) | |
43 | ||
44 | #define PIM_IF_TEST_PIM(options) (PIM_IF_MASK_PIM & (options)) | |
45 | #define PIM_IF_TEST_IGMP(options) (PIM_IF_MASK_IGMP & (options)) | |
46 | #define PIM_IF_TEST_IGMP_LISTEN_ALLROUTERS(options) (PIM_IF_MASK_IGMP_LISTEN_ALLROUTERS & (options)) | |
7c98d487 DA |
47 | #define PIM_IF_TEST_PIM_CAN_DISABLE_JOIN_SUPPRESSION(options) \ |
48 | (PIM_IF_MASK_PIM_CAN_DISABLE_JOIN_SUPPRESSION & (options)) | |
12e41d03 DL |
49 | |
50 | #define PIM_IF_DO_PIM(options) ((options) |= PIM_IF_MASK_PIM) | |
51 | #define PIM_IF_DO_IGMP(options) ((options) |= PIM_IF_MASK_IGMP) | |
52 | #define PIM_IF_DO_IGMP_LISTEN_ALLROUTERS(options) ((options) |= PIM_IF_MASK_IGMP_LISTEN_ALLROUTERS) | |
7c98d487 DA |
53 | #define PIM_IF_DO_PIM_CAN_DISABLE_JOIN_SUPPRESSION(options) \ |
54 | ((options) |= PIM_IF_MASK_PIM_CAN_DISABLE_JOIN_SUPPRESSION) | |
12e41d03 DL |
55 | |
56 | #define PIM_IF_DONT_PIM(options) ((options) &= ~PIM_IF_MASK_PIM) | |
57 | #define PIM_IF_DONT_IGMP(options) ((options) &= ~PIM_IF_MASK_IGMP) | |
58 | #define PIM_IF_DONT_IGMP_LISTEN_ALLROUTERS(options) ((options) &= ~PIM_IF_MASK_IGMP_LISTEN_ALLROUTERS) | |
7c98d487 DA |
59 | #define PIM_IF_DONT_PIM_CAN_DISABLE_JOIN_SUPPRESSION(options) \ |
60 | ((options) &= ~PIM_IF_MASK_PIM_CAN_DISABLE_JOIN_SUPPRESSION) | |
12e41d03 | 61 | |
883052c6 DL |
62 | #define PIM_I_am_DR(pim_ifp) \ |
63 | !pim_addr_cmp((pim_ifp)->pim_dr_addr, (pim_ifp)->primary_address) | |
22c35834 | 64 | #define PIM_I_am_DualActive(pim_ifp) (pim_ifp)->activeactive == true |
84366c7e | 65 | |
79992e8a MR |
66 | /* Macros for interface flags */ |
67 | ||
68 | /* | |
69 | * PIM needs to know if hello is required to send before other PIM messages | |
70 | * like Join, prune, assert would go out | |
71 | */ | |
72 | #define PIM_IF_FLAG_HELLO_SENT (1 << 0) | |
73 | ||
74 | #define PIM_IF_FLAG_TEST_HELLO_SENT(flags) ((flags)&PIM_IF_FLAG_HELLO_SENT) | |
75 | ||
76 | #define PIM_IF_FLAG_SET_HELLO_SENT(flags) ((flags) |= PIM_IF_FLAG_HELLO_SENT) | |
77 | ||
78 | #define PIM_IF_FLAG_UNSET_HELLO_SENT(flags) ((flags) &= ~PIM_IF_FLAG_HELLO_SENT) | |
79 | ||
982bff89 | 80 | struct pim_iface_upstream_switch { |
568b78b5 | 81 | pim_addr address; |
d62a17ae | 82 | struct list *us; |
982bff89 DS |
83 | }; |
84 | ||
7176984f | 85 | enum pim_secondary_addr_flags { |
d62a17ae | 86 | PIM_SEC_ADDRF_NONE = 0, |
87 | PIM_SEC_ADDRF_STALE = (1 << 0) | |
7176984f | 88 | }; |
89 | ||
90 | struct pim_secondary_addr { | |
d62a17ae | 91 | struct prefix addr; |
92 | enum pim_secondary_addr_flags flags; | |
7176984f | 93 | }; |
94 | ||
12e41d03 | 95 | struct pim_interface { |
d62a17ae | 96 | uint32_t options; /* bit vector */ |
97 | ifindex_t mroute_vif_index; | |
c3bd5a10 | 98 | struct pim_instance *pim; |
12e76340 | 99 | pim_addr primary_address; /* remember addr to detect change */ |
d62a17ae | 100 | struct list *sec_addr_list; /* list of struct pim_secondary_addr */ |
12e76340 | 101 | pim_addr update_source; /* user can statically set the primary |
d62a17ae | 102 | * address of the interface */ |
18adcff1 SG |
103 | |
104 | int igmp_version; /* IGMP version */ | |
105 | int gm_default_robustness_variable; /* IGMP or MLD QRV */ | |
106 | int gm_default_query_interval; /* IGMP or MLD secs between general | |
107 | queries */ | |
108 | int gm_query_max_response_time_dsec; /* IGMP or MLD Max Response Time in | |
d62a17ae | 109 | dsecs for general queries */ |
18adcff1 SG |
110 | int gm_specific_query_max_response_time_dsec; /* IGMP or MLD Max |
111 | Response Time in dsecs | |
112 | called as last member | |
113 | query interval, defines | |
114 | the maximum response | |
115 | time advertised in IGMP | |
116 | group-specific | |
117 | queries */ | |
118 | int gm_last_member_query_count; /* IGMP or MLD last member | |
119 | query count | |
120 | */ | |
121 | struct list *gm_socket_list; /* list of struct IGMP or MLD sock */ | |
122 | struct list *gm_join_list; /* list of struct IGMP or MLD join */ | |
123 | struct list *gm_group_list; /* list of struct IGMP or MLD group */ | |
124 | struct hash *gm_group_hash; | |
d62a17ae | 125 | |
126 | int pim_sock_fd; /* PIM socket file descriptor */ | |
127 | struct thread *t_pim_sock_read; /* thread for reading PIM socket */ | |
128 | int64_t pim_sock_creation; /* timestamp of PIM socket creation */ | |
129 | ||
130 | struct thread *t_pim_hello_timer; | |
131 | int pim_hello_period; | |
132 | int pim_default_holdtime; | |
133 | int pim_triggered_hello_delay; | |
134 | uint32_t pim_generation_id; | |
135 | uint16_t pim_propagation_delay_msec; /* config */ | |
136 | uint16_t pim_override_interval_msec; /* config */ | |
137 | struct list *pim_neighbor_list; /* list of struct pim_neighbor */ | |
138 | struct list *upstream_switch_list; | |
ad7b74c4 | 139 | struct pim_ifchannel_rb ifchannel_rb; |
d62a17ae | 140 | |
141 | /* neighbors without lan_delay */ | |
142 | int pim_number_of_nonlandelay_neighbors; | |
143 | uint16_t pim_neighbors_highest_propagation_delay_msec; | |
144 | uint16_t pim_neighbors_highest_override_interval_msec; | |
145 | ||
146 | /* DR Election */ | |
147 | int64_t pim_dr_election_last; /* timestamp */ | |
148 | int pim_dr_election_count; | |
149 | int pim_dr_election_changes; | |
12e76340 | 150 | pim_addr pim_dr_addr; |
d62a17ae | 151 | uint32_t pim_dr_priority; /* config */ |
152 | int pim_dr_num_nondrpri_neighbors; /* neighbors without dr_pri */ | |
153 | ||
b0f525a8 QY |
154 | /* boundary prefix-list */ |
155 | char *boundary_oil_plist; | |
156 | ||
414d885a DS |
157 | /* Turn on Active-Active for this interface */ |
158 | bool activeactive; | |
46a9ea8b | 159 | bool am_i_dr; |
414d885a | 160 | |
d62a17ae | 161 | int64_t pim_ifstat_start; /* start timestamp for stats */ |
8a4dfb5d | 162 | uint64_t pim_ifstat_bsm_rx; |
163 | uint64_t pim_ifstat_bsm_tx; | |
d62a17ae | 164 | uint32_t pim_ifstat_hello_sent; |
165 | uint32_t pim_ifstat_hello_sendfail; | |
166 | uint32_t pim_ifstat_hello_recv; | |
167 | uint32_t pim_ifstat_hello_recvfail; | |
168 | uint32_t pim_ifstat_join_recv; | |
169 | uint32_t pim_ifstat_join_send; | |
170 | uint32_t pim_ifstat_prune_recv; | |
171 | uint32_t pim_ifstat_prune_send; | |
172 | uint32_t pim_ifstat_reg_recv; | |
173 | uint32_t pim_ifstat_reg_send; | |
174 | uint32_t pim_ifstat_reg_stop_recv; | |
175 | uint32_t pim_ifstat_reg_stop_send; | |
176 | uint32_t pim_ifstat_assert_recv; | |
177 | uint32_t pim_ifstat_assert_send; | |
8a4dfb5d | 178 | uint32_t pim_ifstat_bsm_cfg_miss; |
179 | uint32_t pim_ifstat_ucast_bsm_cfg_miss; | |
180 | uint32_t pim_ifstat_bsm_invalid_sz; | |
79992e8a | 181 | uint8_t flags; |
8a4dfb5d | 182 | bool bsm_enable; /* bsm processing enable */ |
183 | bool ucast_bsm_accept; /* ucast bsm processing */ | |
1f3e6bf5 RZ |
184 | |
185 | struct { | |
186 | bool enabled; | |
187 | uint32_t min_rx; | |
188 | uint32_t min_tx; | |
189 | uint8_t detection_multiplier; | |
745b8d4a | 190 | char *profile; |
1f3e6bf5 | 191 | } bfd_config; |
12e41d03 DL |
192 | }; |
193 | ||
194 | /* | |
18adcff1 SG |
195 | * if default_holdtime is set (>= 0), use it; |
196 | * otherwise default_holdtime is 3.5 * hello_period | |
12e41d03 | 197 | */ |
d62a17ae | 198 | #define PIM_IF_DEFAULT_HOLDTIME(pim_ifp) \ |
199 | (((pim_ifp)->pim_default_holdtime < 0) \ | |
200 | ? ((pim_ifp)->pim_hello_period * 7 / 2) \ | |
201 | : ((pim_ifp)->pim_default_holdtime)) | |
12e41d03 | 202 | |
f88df3a6 DS |
203 | void pim_if_init(struct pim_instance *pim); |
204 | void pim_if_terminate(struct pim_instance *pim); | |
12e41d03 | 205 | |
85a13586 | 206 | struct pim_interface *pim_if_new(struct interface *ifp, bool igmp, bool pim, |
b1891fa0 | 207 | bool ispimreg, bool is_vxlan_term); |
d62a17ae | 208 | void pim_if_delete(struct interface *ifp); |
12e41d03 DL |
209 | void pim_if_addr_add(struct connected *ifc); |
210 | void pim_if_addr_del(struct connected *ifc, int force_prim_as_any); | |
211 | void pim_if_addr_add_all(struct interface *ifp); | |
212 | void pim_if_addr_del_all(struct interface *ifp); | |
213 | void pim_if_addr_del_all_igmp(struct interface *ifp); | |
12e41d03 | 214 | |
b1891fa0 | 215 | int pim_if_add_vif(struct interface *ifp, bool ispimreg, bool is_vxlan_term); |
12e41d03 | 216 | int pim_if_del_vif(struct interface *ifp); |
f88df3a6 DS |
217 | void pim_if_add_vif_all(struct pim_instance *pim); |
218 | void pim_if_del_vif_all(struct pim_instance *pim); | |
12e41d03 | 219 | |
7cfc7bcf DS |
220 | struct interface *pim_if_find_by_vif_index(struct pim_instance *pim, |
221 | ifindex_t vif_index); | |
222 | int pim_if_find_vifindex_by_ifindex(struct pim_instance *pim, | |
223 | ifindex_t ifindex); | |
12e41d03 DL |
224 | |
225 | int pim_if_lan_delay_enabled(struct interface *ifp); | |
226 | uint16_t pim_if_effective_propagation_delay_msec(struct interface *ifp); | |
227 | uint16_t pim_if_effective_override_interval_msec(struct interface *ifp); | |
228 | uint16_t pim_if_jp_override_interval_msec(struct interface *ifp); | |
9bb93fa0 | 229 | struct pim_neighbor *pim_if_find_neighbor(struct interface *ifp, pim_addr addr); |
12e41d03 DL |
230 | |
231 | long pim_if_t_suppressed_msec(struct interface *ifp); | |
232 | int pim_if_t_override_msec(struct interface *ifp); | |
233 | ||
034db86b | 234 | pim_addr pim_find_primary_addr(struct interface *ifp); |
12e41d03 | 235 | |
37664928 DS |
236 | ferr_r pim_if_igmp_join_add(struct interface *ifp, struct in_addr group_addr, |
237 | struct in_addr source_addr); | |
d62a17ae | 238 | int pim_if_igmp_join_del(struct interface *ifp, struct in_addr group_addr, |
12e41d03 DL |
239 | struct in_addr source_addr); |
240 | ||
241 | void pim_if_update_could_assert(struct interface *ifp); | |
242 | ||
9bb93fa0 | 243 | void pim_if_assert_on_neighbor_down(struct interface *ifp, pim_addr neigh_addr); |
12e41d03 DL |
244 | |
245 | void pim_if_rpf_interface_changed(struct interface *old_rpf_ifp, | |
246 | struct pim_upstream *up); | |
247 | ||
248 | void pim_if_update_join_desired(struct pim_interface *pim_ifp); | |
249 | ||
250 | void pim_if_update_assert_tracking_desired(struct interface *ifp); | |
251 | ||
43e40fdf | 252 | void pim_if_create_pimreg(struct pim_instance *pim); |
3565202d | 253 | |
034db86b DL |
254 | struct prefix *pim_if_connected_to_source(struct interface *ifp, pim_addr src); |
255 | int pim_update_source_set(struct interface *ifp, pim_addr source); | |
3fdfd943 | 256 | |
e55a43d4 | 257 | bool pim_if_is_vrf_device(struct interface *ifp); |
ad7b74c4 DS |
258 | |
259 | int pim_if_ifchannel_count(struct pim_interface *pim_ifp); | |
138c5a74 | 260 | |
6b88faa7 | 261 | void pim_iface_init(void); |
138c5a74 | 262 | |
12e41d03 | 263 | #endif /* PIM_IFACE_H */ |