3 * Copyright (C) 2008 Everton da Silva Marques
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.
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.
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
32 #include "pim_upstream.h"
33 #include "pim_instance.h"
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)
41 #define PIM_IF_IS_DELETED(ifp) ((ifp)->ifindex == IFINDEX_INTERNAL)
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))
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)
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)
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
64 struct pim_iface_upstream_switch
{
65 struct in_addr address
;
69 enum pim_secondary_addr_flags
{
70 PIM_SEC_ADDRF_NONE
= 0,
71 PIM_SEC_ADDRF_STALE
= (1 << 0)
74 struct pim_secondary_addr
{
76 enum pim_secondary_addr_flags flags
;
79 struct pim_interface
{
80 uint32_t options
; /* bit vector */
81 ifindex_t mroute_vif_index
;
82 struct pim_instance
*pim
;
84 struct in_addr primary_address
; /* remember addr to detect change */
85 struct list
*sec_addr_list
; /* list of struct pim_secondary_addr */
86 struct in_addr update_source
; /* user can statically set the primary
87 * address of the interface */
89 int igmp_version
; /* IGMP version */
90 int igmp_default_robustness_variable
; /* IGMPv3 QRV */
91 int igmp_default_query_interval
; /* IGMPv3 secs between general
93 int igmp_query_max_response_time_dsec
; /* IGMPv3 Max Response Time in
94 dsecs for general queries */
95 int igmp_specific_query_max_response_time_dsec
; /* IGMPv3 Max Response
103 int igmp_last_member_query_count
; /* IGMP last member query count */
104 struct list
*igmp_socket_list
; /* list of struct igmp_sock */
105 struct list
*igmp_join_list
; /* list of struct igmp_join */
106 struct list
*igmp_group_list
; /* list of struct igmp_group */
107 struct hash
*igmp_group_hash
;
109 int pim_sock_fd
; /* PIM socket file descriptor */
110 struct thread
*t_pim_sock_read
; /* thread for reading PIM socket */
111 int64_t pim_sock_creation
; /* timestamp of PIM socket creation */
113 struct thread
*t_pim_hello_timer
;
114 int pim_hello_period
;
115 int pim_default_holdtime
;
116 int pim_triggered_hello_delay
;
117 uint32_t pim_generation_id
;
118 uint16_t pim_propagation_delay_msec
; /* config */
119 uint16_t pim_override_interval_msec
; /* config */
120 struct list
*pim_neighbor_list
; /* list of struct pim_neighbor */
121 struct list
*upstream_switch_list
;
122 struct pim_ifchannel_rb ifchannel_rb
;
124 /* neighbors without lan_delay */
125 int pim_number_of_nonlandelay_neighbors
;
126 uint16_t pim_neighbors_highest_propagation_delay_msec
;
127 uint16_t pim_neighbors_highest_override_interval_msec
;
130 int64_t pim_dr_election_last
; /* timestamp */
131 int pim_dr_election_count
;
132 int pim_dr_election_changes
;
133 struct in_addr pim_dr_addr
;
134 uint32_t pim_dr_priority
; /* config */
135 int pim_dr_num_nondrpri_neighbors
; /* neighbors without dr_pri */
137 /* boundary prefix-list */
138 char *boundary_oil_plist
;
140 /* Turn on Active-Active for this interface */
144 int64_t pim_ifstat_start
; /* start timestamp for stats */
145 uint64_t pim_ifstat_bsm_rx
;
146 uint64_t pim_ifstat_bsm_tx
;
147 uint32_t pim_ifstat_hello_sent
;
148 uint32_t pim_ifstat_hello_sendfail
;
149 uint32_t pim_ifstat_hello_recv
;
150 uint32_t pim_ifstat_hello_recvfail
;
151 uint32_t pim_ifstat_join_recv
;
152 uint32_t pim_ifstat_join_send
;
153 uint32_t pim_ifstat_prune_recv
;
154 uint32_t pim_ifstat_prune_send
;
155 uint32_t pim_ifstat_reg_recv
;
156 uint32_t pim_ifstat_reg_send
;
157 uint32_t pim_ifstat_reg_stop_recv
;
158 uint32_t pim_ifstat_reg_stop_send
;
159 uint32_t pim_ifstat_assert_recv
;
160 uint32_t pim_ifstat_assert_send
;
161 uint32_t pim_ifstat_bsm_cfg_miss
;
162 uint32_t pim_ifstat_ucast_bsm_cfg_miss
;
163 uint32_t pim_ifstat_bsm_invalid_sz
;
164 bool bsm_enable
; /* bsm processing enable */
165 bool ucast_bsm_accept
; /* ucast bsm processing */
171 uint8_t detection_multiplier
;
177 if default_holdtime is set (>= 0), use it;
178 otherwise default_holdtime is 3.5 * hello_period
180 #define PIM_IF_DEFAULT_HOLDTIME(pim_ifp) \
181 (((pim_ifp)->pim_default_holdtime < 0) \
182 ? ((pim_ifp)->pim_hello_period * 7 / 2) \
183 : ((pim_ifp)->pim_default_holdtime))
185 void pim_if_init(struct pim_instance
*pim
);
186 void pim_if_terminate(struct pim_instance
*pim
);
188 struct pim_interface
*pim_if_new(struct interface
*ifp
, bool igmp
, bool pim
,
189 bool ispimreg
, bool is_vxlan_term
);
190 void pim_if_delete(struct interface
*ifp
);
191 void pim_if_addr_add(struct connected
*ifc
);
192 void pim_if_addr_del(struct connected
*ifc
, int force_prim_as_any
);
193 void pim_if_addr_add_all(struct interface
*ifp
);
194 void pim_if_addr_del_all(struct interface
*ifp
);
195 void pim_if_addr_del_all_igmp(struct interface
*ifp
);
197 int pim_if_add_vif(struct interface
*ifp
, bool ispimreg
, bool is_vxlan_term
);
198 int pim_if_del_vif(struct interface
*ifp
);
199 void pim_if_add_vif_all(struct pim_instance
*pim
);
200 void pim_if_del_vif_all(struct pim_instance
*pim
);
202 struct interface
*pim_if_find_by_vif_index(struct pim_instance
*pim
,
203 ifindex_t vif_index
);
204 int pim_if_find_vifindex_by_ifindex(struct pim_instance
*pim
,
207 int pim_if_lan_delay_enabled(struct interface
*ifp
);
208 uint16_t pim_if_effective_propagation_delay_msec(struct interface
*ifp
);
209 uint16_t pim_if_effective_override_interval_msec(struct interface
*ifp
);
210 uint16_t pim_if_jp_override_interval_msec(struct interface
*ifp
);
211 struct pim_neighbor
*pim_if_find_neighbor(struct interface
*ifp
,
212 struct in_addr addr
);
214 long pim_if_t_suppressed_msec(struct interface
*ifp
);
215 int pim_if_t_override_msec(struct interface
*ifp
);
217 struct in_addr
pim_find_primary_addr(struct interface
*ifp
);
219 ferr_r
pim_if_igmp_join_add(struct interface
*ifp
, struct in_addr group_addr
,
220 struct in_addr source_addr
);
221 int pim_if_igmp_join_del(struct interface
*ifp
, struct in_addr group_addr
,
222 struct in_addr source_addr
);
224 void pim_if_update_could_assert(struct interface
*ifp
);
226 void pim_if_assert_on_neighbor_down(struct interface
*ifp
,
227 struct in_addr neigh_addr
);
229 void pim_if_rpf_interface_changed(struct interface
*old_rpf_ifp
,
230 struct pim_upstream
*up
);
232 void pim_if_update_join_desired(struct pim_interface
*pim_ifp
);
234 void pim_if_update_assert_tracking_desired(struct interface
*ifp
);
236 void pim_if_create_pimreg(struct pim_instance
*pim
);
238 struct prefix
*pim_if_connected_to_source(struct interface
*ifp
, struct in_addr src
);
239 int pim_update_source_set(struct interface
*ifp
, struct in_addr source
);
241 bool pim_if_is_vrf_device(struct interface
*ifp
);
243 int pim_if_ifchannel_count(struct pim_interface
*pim_ifp
);
245 extern int pim_ifp_create(struct interface
*ifp
);
246 extern int pim_ifp_up(struct interface
*ifp
);
247 extern int pim_ifp_down(struct interface
*ifp
);
248 extern int pim_ifp_destroy(struct interface
*ifp
);
250 #endif /* PIM_IFACE_H */