]> git.proxmox.com Git - mirror_frr.git/blob - pimd/pim_iface.h
Merge pull request #11114 from opensourcerouting/vrf-declvar-macros
[mirror_frr.git] / pimd / pim_iface.h
1 /*
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
18 */
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"
27 #include "vrf.h"
28 #include "zclient.h"
29 #include "ferr.h"
30
31 #include "pim_igmp.h"
32 #include "pim_upstream.h"
33 #include "pim_instance.h"
34 #include "bfd.h"
35 #include "pim_str.h"
36
37 #define PIM_IF_IS_DELETED(ifp) ((ifp)->ifindex == IFINDEX_INTERNAL)
38
39 #define PIM_I_am_DR(pim_ifp) \
40 !pim_addr_cmp((pim_ifp)->pim_dr_addr, (pim_ifp)->primary_address)
41 #define PIM_I_am_DualActive(pim_ifp) (pim_ifp)->activeactive == true
42
43 /* Macros for interface flags */
44
45 /*
46 * PIM needs to know if hello is required to send before other PIM messages
47 * like Join, prune, assert would go out
48 */
49 #define PIM_IF_FLAG_HELLO_SENT (1 << 0)
50
51 #define PIM_IF_FLAG_TEST_HELLO_SENT(flags) ((flags)&PIM_IF_FLAG_HELLO_SENT)
52
53 #define PIM_IF_FLAG_SET_HELLO_SENT(flags) ((flags) |= PIM_IF_FLAG_HELLO_SENT)
54
55 #define PIM_IF_FLAG_UNSET_HELLO_SENT(flags) ((flags) &= ~PIM_IF_FLAG_HELLO_SENT)
56
57 struct pim_iface_upstream_switch {
58 pim_addr address;
59 struct list *us;
60 };
61
62 enum pim_secondary_addr_flags {
63 PIM_SEC_ADDRF_NONE = 0,
64 PIM_SEC_ADDRF_STALE = (1 << 0)
65 };
66
67 struct pim_secondary_addr {
68 struct prefix addr;
69 enum pim_secondary_addr_flags flags;
70 };
71
72 struct pim_interface {
73 bool pim_enable : 1;
74 bool pim_can_disable_join_suppression : 1;
75
76 bool igmp_enable : 1;
77
78 ifindex_t mroute_vif_index;
79 struct pim_instance *pim;
80
81 #if PIM_IPV == 6
82 /* link-locals: MLD uses lowest addr, PIM uses highest... */
83 pim_addr ll_lowest;
84 pim_addr ll_highest;
85 #endif
86
87 pim_addr primary_address; /* remember addr to detect change */
88 struct list *sec_addr_list; /* list of struct pim_secondary_addr */
89 pim_addr update_source; /* user can statically set the primary
90 * address of the interface */
91
92 int igmp_version; /* IGMP version */
93 int gm_default_robustness_variable; /* IGMP or MLD QRV */
94 int gm_default_query_interval; /* IGMP or MLD secs between general
95 queries */
96 int gm_query_max_response_time_dsec; /* IGMP or MLD Max Response Time in
97 dsecs for general queries */
98 int gm_specific_query_max_response_time_dsec; /* IGMP or MLD Max
99 Response Time in dsecs
100 called as last member
101 query interval, defines
102 the maximum response
103 time advertised in IGMP
104 group-specific
105 queries */
106 int gm_last_member_query_count; /* IGMP or MLD last member
107 query count
108 */
109 struct list *gm_socket_list; /* list of struct IGMP or MLD sock */
110 struct list *gm_join_list; /* list of struct IGMP or MLD join */
111 struct list *gm_group_list; /* list of struct IGMP or MLD group */
112 struct hash *gm_group_hash;
113
114 int pim_sock_fd; /* PIM socket file descriptor */
115 struct thread *t_pim_sock_read; /* thread for reading PIM socket */
116 int64_t pim_sock_creation; /* timestamp of PIM socket creation */
117
118 struct thread *t_pim_hello_timer;
119 int pim_hello_period;
120 int pim_default_holdtime;
121 int pim_triggered_hello_delay;
122 uint32_t pim_generation_id;
123 uint16_t pim_propagation_delay_msec; /* config */
124 uint16_t pim_override_interval_msec; /* config */
125 struct list *pim_neighbor_list; /* list of struct pim_neighbor */
126 struct list *upstream_switch_list;
127 struct pim_ifchannel_rb ifchannel_rb;
128
129 /* neighbors without lan_delay */
130 int pim_number_of_nonlandelay_neighbors;
131 uint16_t pim_neighbors_highest_propagation_delay_msec;
132 uint16_t pim_neighbors_highest_override_interval_msec;
133
134 /* DR Election */
135 int64_t pim_dr_election_last; /* timestamp */
136 int pim_dr_election_count;
137 int pim_dr_election_changes;
138 pim_addr pim_dr_addr;
139 uint32_t pim_dr_priority; /* config */
140 int pim_dr_num_nondrpri_neighbors; /* neighbors without dr_pri */
141
142 /* boundary prefix-list */
143 char *boundary_oil_plist;
144
145 /* Turn on Active-Active for this interface */
146 bool activeactive;
147 bool am_i_dr;
148
149 int64_t pim_ifstat_start; /* start timestamp for stats */
150 uint64_t pim_ifstat_bsm_rx;
151 uint64_t pim_ifstat_bsm_tx;
152 uint32_t pim_ifstat_hello_sent;
153 uint32_t pim_ifstat_hello_sendfail;
154 uint32_t pim_ifstat_hello_recv;
155 uint32_t pim_ifstat_hello_recvfail;
156 uint32_t pim_ifstat_join_recv;
157 uint32_t pim_ifstat_join_send;
158 uint32_t pim_ifstat_prune_recv;
159 uint32_t pim_ifstat_prune_send;
160 uint32_t pim_ifstat_reg_recv;
161 uint32_t pim_ifstat_reg_send;
162 uint32_t pim_ifstat_reg_stop_recv;
163 uint32_t pim_ifstat_reg_stop_send;
164 uint32_t pim_ifstat_assert_recv;
165 uint32_t pim_ifstat_assert_send;
166 uint32_t pim_ifstat_bsm_cfg_miss;
167 uint32_t pim_ifstat_ucast_bsm_cfg_miss;
168 uint32_t pim_ifstat_bsm_invalid_sz;
169 uint8_t flags;
170 bool bsm_enable; /* bsm processing enable */
171 bool ucast_bsm_accept; /* ucast bsm processing */
172
173 uint32_t igmp_ifstat_joins_sent;
174 uint32_t igmp_ifstat_joins_failed;
175 uint32_t igmp_peak_group_count;
176
177 struct {
178 bool enabled;
179 uint32_t min_rx;
180 uint32_t min_tx;
181 uint8_t detection_multiplier;
182 char *profile;
183 } bfd_config;
184 };
185
186 /*
187 * if default_holdtime is set (>= 0), use it;
188 * otherwise default_holdtime is 3.5 * hello_period
189 */
190 #define PIM_IF_DEFAULT_HOLDTIME(pim_ifp) \
191 (((pim_ifp)->pim_default_holdtime < 0) \
192 ? ((pim_ifp)->pim_hello_period * 7 / 2) \
193 : ((pim_ifp)->pim_default_holdtime))
194
195 void pim_if_init(struct pim_instance *pim);
196 void pim_if_terminate(struct pim_instance *pim);
197
198 struct pim_interface *pim_if_new(struct interface *ifp, bool igmp, bool pim,
199 bool ispimreg, bool is_vxlan_term);
200 void pim_if_delete(struct interface *ifp);
201 void pim_if_addr_add(struct connected *ifc);
202 void pim_if_addr_del(struct connected *ifc, int force_prim_as_any);
203 void pim_if_addr_add_all(struct interface *ifp);
204 void pim_if_addr_del_all(struct interface *ifp);
205 void pim_if_addr_del_all_igmp(struct interface *ifp);
206
207 int pim_if_add_vif(struct interface *ifp, bool ispimreg, bool is_vxlan_term);
208 int pim_if_del_vif(struct interface *ifp);
209 void pim_if_add_vif_all(struct pim_instance *pim);
210 void pim_if_del_vif_all(struct pim_instance *pim);
211
212 struct interface *pim_if_find_by_vif_index(struct pim_instance *pim,
213 ifindex_t vif_index);
214 int pim_if_find_vifindex_by_ifindex(struct pim_instance *pim,
215 ifindex_t ifindex);
216
217 int pim_if_lan_delay_enabled(struct interface *ifp);
218 uint16_t pim_if_effective_propagation_delay_msec(struct interface *ifp);
219 uint16_t pim_if_effective_override_interval_msec(struct interface *ifp);
220 uint16_t pim_if_jp_override_interval_msec(struct interface *ifp);
221 struct pim_neighbor *pim_if_find_neighbor(struct interface *ifp, pim_addr addr);
222
223 long pim_if_t_suppressed_msec(struct interface *ifp);
224 int pim_if_t_override_msec(struct interface *ifp);
225
226 pim_addr pim_find_primary_addr(struct interface *ifp);
227
228 ferr_r pim_if_igmp_join_add(struct interface *ifp, struct in_addr group_addr,
229 struct in_addr source_addr);
230 int pim_if_igmp_join_del(struct interface *ifp, struct in_addr group_addr,
231 struct in_addr source_addr);
232
233 void pim_if_update_could_assert(struct interface *ifp);
234
235 void pim_if_assert_on_neighbor_down(struct interface *ifp, pim_addr neigh_addr);
236
237 void pim_if_rpf_interface_changed(struct interface *old_rpf_ifp,
238 struct pim_upstream *up);
239
240 void pim_if_update_join_desired(struct pim_interface *pim_ifp);
241
242 void pim_if_update_assert_tracking_desired(struct interface *ifp);
243
244 void pim_if_create_pimreg(struct pim_instance *pim);
245
246 struct prefix *pim_if_connected_to_source(struct interface *ifp, pim_addr src);
247 int pim_update_source_set(struct interface *ifp, pim_addr source);
248
249 bool pim_if_is_vrf_device(struct interface *ifp);
250
251 int pim_if_ifchannel_count(struct pim_interface *pim_ifp);
252
253 void pim_iface_init(void);
254
255 #endif /* PIM_IFACE_H */