1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * PIM for FRR - PIM Instance
4 * Copyright (C) 2017 Cumulus Networks, Inc.
7 #ifndef __PIM_INSTANCE_H__
8 #define __PIM_INSTANCE_H__
14 #include "pim_assert.h"
16 #include "pim_vxlan_instance.h"
18 #include "pim_upstream.h"
19 #include "pim_mroute.h"
21 enum pim_spt_switchover
{
26 /* stats for updates rxed from the MLAG component during the life of a
29 struct pim_mlag_msg_stats
{
30 uint32_t mroute_add_rx
;
31 uint32_t mroute_add_tx
;
32 uint32_t mroute_del_rx
;
33 uint32_t mroute_del_tx
;
34 uint32_t mlag_status_updates
;
35 uint32_t pim_status_updates
;
36 uint32_t vxlan_updates
;
37 uint32_t peer_zebra_status_updates
;
40 struct pim_mlag_stats
{
41 /* message stats are reset when the connection to mlagd flaps */
42 struct pim_mlag_msg_stats msg
;
43 uint32_t mlagd_session_downs
;
44 uint32_t peer_session_downs
;
45 uint32_t peer_zebra_downs
;
50 /* connection to the local MLAG daemon is up */
51 PIM_MLAGF_LOCAL_CONN_UP
= (1 << 0),
52 /* connection to the MLAG daemon on the peer switch is up. note
53 * that there is no direct connection between FRR and the peer MLAG
54 * daemon. this is just a peer-session status provided by the local
57 PIM_MLAGF_PEER_CONN_UP
= (1 << 1),
58 /* status update rxed from the local daemon */
59 PIM_MLAGF_STATUS_RXED
= (1 << 2),
60 /* initial dump of data done post peerlink flap */
61 PIM_MLAGF_PEER_REPLAY_DONE
= (1 << 3),
62 /* zebra is up on the peer */
63 PIM_MLAGF_PEER_ZEBRA_UP
= (1 << 4)
67 struct event_loop
*master
;
72 struct pim_assert_metric infinite_assert_metric
;
73 long rpf_cache_refresh_delay_msec
;
74 uint32_t register_suppress_time
;
76 uint32_t register_probe_time
;
80 * What is the default vrf that we work in
84 enum mlag_role mlag_role
;
85 uint32_t pim_mlag_intf_cnt
;
86 /* if true we have registered with MLAG */
87 bool mlag_process_register
;
88 /* if true local MLAG process reported that it is connected
89 * with the peer MLAG process
91 bool connected_to_mlag
;
92 /* Holds the client data(unencoded) that need to be pushed to MCLAGD*/
93 struct stream_fifo
*mlag_fifo
;
94 struct stream
*mlag_stream
;
95 struct event
*zpthread_mlag_write
;
96 struct in_addr anycast_vtep_ip
;
97 struct in_addr local_vtep_ip
;
98 struct pim_mlag_stats mlag_stats
;
99 enum pim_mlag_flags mlag_flags
;
100 char peerlink_rif
[INTERFACE_NAMSIZ
];
101 struct interface
*peerlink_rif_p
;
105 struct pim_instance
{
110 enum pim_spt_switchover switchover
;
114 /* The name of the register-accept prefix-list */
115 char *register_plist
;
117 struct hash
*rpf_hash
;
119 void *ssm_info
; /* per-vrf SSM configuration */
121 int send_v6_secondary
;
123 struct event
*thread
;
125 int reg_sock
; /* Socket to send register msg */
126 int64_t mroute_socket_creation
;
127 int64_t mroute_add_events
;
128 int64_t mroute_add_last
;
129 int64_t mroute_del_events
;
130 int64_t mroute_del_last
;
132 struct interface
*regiface
;
134 // List of static routes;
135 struct list
*static_routes
;
137 // Upstream vrf specific information
138 struct rb_pim_upstream_head upstream_head
;
139 struct timer_wheel
*upstream_sg_wheel
;
144 struct list
*rp_list
;
145 struct route_table
*rp_table
;
147 int iface_vif_index
[MAXVIFS
];
150 struct rb_pim_oil_head channel_oil_head
;
152 struct pim_msdp msdp
;
153 struct pim_vxlan_instance vxlan
;
155 struct list
*ssmpingd_list
;
156 pim_addr ssmpingd_group_addr
;
158 unsigned int gm_socket_if_count
;
160 struct event
*t_gm_recv
;
162 unsigned int gm_group_count
;
163 unsigned int gm_watermark_limit
;
164 unsigned int keep_alive_time
;
165 unsigned int rp_keep_alive_time
;
168 bool ecmp_rebalance_enable
;
169 /* No. of Dual active I/fs in pim_instance */
170 uint32_t inst_mlag_intf_cnt
;
173 struct bsm_scope global_scope
;
176 uint64_t bsm_dropped
;
178 /* If we need to rescan all our upstreams */
179 struct event
*rpf_cache_refresher
;
180 int64_t rpf_cache_refresh_requests
;
181 int64_t rpf_cache_refresh_events
;
182 int64_t rpf_cache_refresh_last
;
183 int64_t scan_oil_events
;
184 int64_t scan_oil_last
;
186 int64_t nexthop_lookups
;
187 int64_t nexthop_lookups_avoided
;
188 int64_t last_route_change_time
;
190 uint64_t gm_rx_drop_sys
;
193 void pim_vrf_init(void);
194 void pim_vrf_terminate(void);
196 extern struct pim_router
*router
;
198 struct pim_instance
*pim_get_pim_instance(vrf_id_t vrf_id
);