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