]> git.proxmox.com Git - mirror_frr.git/blob - pimd/pim_upstream.h
Merge remote-tracking branch 'origin/master' into pim_crash_a_boo
[mirror_frr.git] / pimd / pim_upstream.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_UPSTREAM_H
21 #define PIM_UPSTREAM_H
22
23 #include <zebra.h>
24 #include <prefix.h>
25
26 #include <pimd/pim_rpf.h>
27
28 #define PIM_UPSTREAM_FLAG_MASK_DR_JOIN_DESIRED (1 << 0)
29 #define PIM_UPSTREAM_FLAG_MASK_DR_JOIN_DESIRED_UPDATED (1 << 1)
30 #define PIM_UPSTREAM_FLAG_MASK_FHR (1 << 2)
31 #define PIM_UPSTREAM_FLAG_MASK_SRC_IGMP (1 << 3)
32 #define PIM_UPSTREAM_FLAG_MASK_SRC_PIM (1 << 4)
33 #define PIM_UPSTREAM_FLAG_MASK_SRC_STREAM (1 << 5)
34 #define PIM_UPSTREAM_FLAG_MASK_SRC_MSDP (1 << 6)
35 #define PIM_UPSTREAM_FLAG_MASK_SEND_SG_RPT_PRUNE (1 << 7)
36 #define PIM_UPSTREAM_FLAG_MASK_SRC_LHR (1 << 8)
37 #define PIM_UPSTREAM_FLAG_ALL 0xFFFFFFFF
38
39 #define PIM_UPSTREAM_FLAG_TEST_DR_JOIN_DESIRED(flags) ((flags) & PIM_UPSTREAM_FLAG_MASK_DR_JOIN_DESIRED)
40 #define PIM_UPSTREAM_FLAG_TEST_DR_JOIN_DESIRED_UPDATED(flags) ((flags) & PIM_UPSTREAM_FLAG_MASK_DR_JOIN_DESIRED_UPDATED)
41 #define PIM_UPSTREAM_FLAG_TEST_FHR(flags) ((flags) & PIM_UPSTREAM_FLAG_MASK_FHR)
42 #define PIM_UPSTREAM_FLAG_TEST_SRC_IGMP(flags) ((flags) & PIM_UPSTREAM_FLAG_MASK_SRC_IGMP)
43 #define PIM_UPSTREAM_FLAG_TEST_SRC_PIM(flags) ((flags) & PIM_UPSTREAM_FLAG_MASK_SRC_PIM)
44 #define PIM_UPSTREAM_FLAG_TEST_SRC_STREAM(flags) ((flags) & PIM_UPSTREAM_FLAG_MASK_SRC_STREAM)
45 #define PIM_UPSTREAM_FLAG_TEST_SRC_MSDP(flags) ((flags) & PIM_UPSTREAM_FLAG_MASK_SRC_MSDP)
46 #define PIM_UPSTREAM_FLAG_TEST_SEND_SG_RPT_PRUNE(flags) ((flags) & PIM_UPSTREAM_FLAG_MASK_SEND_SG_RPT_PRUNE)
47 #define PIM_UPSTREAM_FLAG_TEST_SRC_LHR(flags) ((flags) & PIM_UPSTREAM_FLAG_MASK_SRC_LHR)
48
49 #define PIM_UPSTREAM_FLAG_SET_DR_JOIN_DESIRED(flags) ((flags) |= PIM_UPSTREAM_FLAG_MASK_DR_JOIN_DESIRED)
50 #define PIM_UPSTREAM_FLAG_SET_DR_JOIN_DESIRED_UPDATED(flags) ((flags) |= PIM_UPSTREAM_FLAG_MASK_DR_JOIN_DESIRED_UPDATED)
51 #define PIM_UPSTREAM_FLAG_SET_FHR(flags) ((flags) |= PIM_UPSTREAM_FLAG_MASK_FHR)
52 #define PIM_UPSTREAM_FLAG_SET_SRC_IGMP(flags) ((flags) |= PIM_UPSTREAM_FLAG_MASK_SRC_IGMP)
53 #define PIM_UPSTREAM_FLAG_SET_SRC_PIM(flags) ((flags) |= PIM_UPSTREAM_FLAG_MASK_SRC_PIM)
54 #define PIM_UPSTREAM_FLAG_SET_SRC_STREAM(flags) ((flags) |= PIM_UPSTREAM_FLAG_MASK_SRC_STREAM)
55 #define PIM_UPSTREAM_FLAG_SET_SRC_MSDP(flags) ((flags) |= PIM_UPSTREAM_FLAG_MASK_SRC_MSDP)
56 #define PIM_UPSTREAM_FLAG_SET_SEND_SG_RPT_PRUNE(flags) ((flags) |= PIM_UPSTREAM_FLAG_MASK_SEND_SG_RPT_PRUNE)
57 #define PIM_UPSTREAM_FLAG_SET_SRC_LHR(flags) ((flags) |= PIM_UPSTREAM_FLAG_MASK_SRC_LHR)
58
59 #define PIM_UPSTREAM_FLAG_UNSET_DR_JOIN_DESIRED(flags) ((flags) &= ~PIM_UPSTREAM_FLAG_MASK_DR_JOIN_DESIRED)
60 #define PIM_UPSTREAM_FLAG_UNSET_DR_JOIN_DESIRED_UPDATED(flags) ((flags) &= ~PIM_UPSTREAM_FLAG_MASK_DR_JOIN_DESIRED_UPDATED)
61 #define PIM_UPSTREAM_FLAG_UNSET_FHR(flags) ((flags) &= ~PIM_UPSTREAM_FLAG_MASK_FHR)
62 #define PIM_UPSTREAM_FLAG_UNSET_SRC_IGMP(flags) ((flags) &= ~PIM_UPSTREAM_FLAG_MASK_SRC_IGMP)
63 #define PIM_UPSTREAM_FLAG_UNSET_SRC_PIM(flags) ((flags) &= ~PIM_UPSTREAM_FLAG_MASK_SRC_PIM)
64 #define PIM_UPSTREAM_FLAG_UNSET_SRC_STREAM(flags) ((flags) &= ~PIM_UPSTREAM_FLAG_MASK_SRC_STREAM)
65 #define PIM_UPSTREAM_FLAG_UNSET_SRC_MSDP(flags) ((flags) &= ~PIM_UPSTREAM_FLAG_MASK_SRC_MSDP)
66 #define PIM_UPSTREAM_FLAG_UNSET_SEND_SG_RPT_PRUNE(flags) ((flags) &= ~PIM_UPSTREAM_FLAG_MASK_SEND_SG_RPT_PRUNE)
67 #define PIM_UPSTREAM_FLAG_UNSET_SRC_LHR(flags) ((flags) &= ~PIM_UPSTREAM_FLAG_MASK_SRC_LHR)
68
69 enum pim_upstream_state {
70 PIM_UPSTREAM_NOTJOINED,
71 PIM_UPSTREAM_JOINED,
72 };
73
74 enum pim_reg_state {
75 PIM_REG_NOINFO,
76 PIM_REG_JOIN,
77 PIM_REG_JOIN_PENDING,
78 PIM_REG_PRUNE,
79 };
80
81 enum pim_upstream_sptbit {
82 PIM_UPSTREAM_SPTBIT_FALSE,
83 PIM_UPSTREAM_SPTBIT_TRUE
84 };
85
86 /*
87 Upstream (S,G) channel in Joined state
88
89 (S,G) in the "Not Joined" state is not represented
90
91 See RFC 4601: 4.5.7. Sending (S,G) Join/Prune Message
92 */
93 struct pim_upstream {
94 struct pim_upstream *parent;
95 struct in_addr upstream_addr;/* Who we are talking to */
96 struct in_addr upstream_register; /*Who we received a register from*/
97 struct prefix_sg sg; /* (S,G) group key */
98 char sg_str[PIM_SG_LEN];
99 uint32_t flags;
100 struct channel_oil *channel_oil;
101 struct list *sources;
102 struct list *ifchannels;
103
104 enum pim_upstream_state join_state;
105 enum pim_reg_state reg_state;
106 enum pim_upstream_sptbit sptbit;
107
108 int ref_count;
109
110 struct pim_rpf rpf;
111
112 struct thread *t_join_timer;
113
114 /*
115 * RST(S,G)
116 */
117 struct thread *t_rs_timer;
118 #define PIM_REGISTER_SUPPRESSION_PERIOD (60)
119 #define PIM_REGISTER_PROBE_PERIOD (15)
120
121 /*
122 * KAT(S,G)
123 */
124 struct thread *t_ka_timer;
125 #define PIM_KEEPALIVE_PERIOD (210)
126 #define PIM_RP_KEEPALIVE_PERIOD ( 3 * qpim_register_suppress_time + qpim_register_probe_time )
127
128 /* on the RP we restart a timer to indicate if registers are being rxed for
129 * SG. This is needed by MSDP to determine its local SA cache */
130 struct thread *t_msdp_reg_timer;
131 #define PIM_MSDP_REG_RXED_PERIOD (3 * (1.5 * qpim_register_suppress_time))
132
133 int64_t state_transition; /* Record current state uptime */
134 };
135
136 struct list *pim_upstream_list;
137 struct hash *pim_upstream_hash;
138
139 void pim_upstream_free(struct pim_upstream *up);
140 struct pim_upstream *pim_upstream_find (struct prefix_sg *sg);
141 struct pim_upstream *pim_upstream_find_or_add (struct prefix_sg *sg,
142 struct interface *ifp, int flags,
143 const char *name);
144 struct pim_upstream *pim_upstream_add (struct prefix_sg *sg,
145 struct interface *ifp, int flags,
146 const char *name);
147 void pim_upstream_ref (struct pim_upstream *up, int flags, const char *name);
148 struct pim_upstream *pim_upstream_del(struct pim_upstream *up, const char *name);
149
150 int pim_upstream_evaluate_join_desired(struct pim_upstream *up);
151 int pim_upstream_evaluate_join_desired_interface(struct pim_upstream *up,
152 struct pim_ifchannel *ch,
153 struct pim_ifchannel *starch);
154 void pim_upstream_update_join_desired(struct pim_upstream *up);
155
156 void pim_upstream_join_suppress(struct pim_upstream *up,
157 struct in_addr rpf_addr,
158 int holdtime);
159
160 void pim_upstream_join_timer_decrease_to_t_override(const char *debug_label,
161 struct pim_upstream *up);
162
163 void pim_upstream_join_timer_restart(struct pim_upstream *up, struct pim_rpf *old);
164 void pim_upstream_rpf_genid_changed(struct in_addr neigh_addr);
165 void pim_upstream_rpf_interface_changed(struct pim_upstream *up,
166 struct interface *old_rpf_ifp);
167
168 void pim_upstream_update_could_assert(struct pim_upstream *up);
169 void pim_upstream_update_my_assert_metric(struct pim_upstream *up);
170
171 void pim_upstream_keep_alive_timer_start (struct pim_upstream *up, uint32_t time);
172
173 int pim_upstream_switch_to_spt_desired (struct prefix_sg *sg);
174 #define SwitchToSptDesired(sg) pim_upstream_switch_to_spt_desired (sg)
175 int pim_upstream_is_sg_rpt (struct pim_upstream *up);
176
177 void pim_upstream_set_sptbit (struct pim_upstream *up, struct interface *incoming);
178
179 void pim_upstream_start_register_stop_timer (struct pim_upstream *up, int null_register);
180
181 void pim_upstream_send_join (struct pim_upstream *up);
182
183 void pim_upstream_switch (struct pim_upstream *up, enum pim_upstream_state new_state);
184
185 const char *pim_upstream_state2str (enum pim_upstream_state join_state);
186 #define PIM_REG_STATE_STR_LEN 12
187 const char *pim_reg_state2str (enum pim_reg_state state, char *state_str);
188
189 int pim_upstream_inherited_olist_decide (struct pim_upstream *up);
190 int pim_upstream_inherited_olist (struct pim_upstream *up);
191 int pim_upstream_empty_inherited_olist (struct pim_upstream *up);
192
193 void pim_upstream_find_new_rpf (void);
194 void pim_upstream_msdp_reg_timer_start(struct pim_upstream *up);
195
196 void pim_upstream_init (void);
197 void pim_upstream_terminate (void);
198
199 void join_timer_start (struct pim_upstream *up);
200 int pim_upstream_compare (void *arg1, void *arg2);
201 void pim_upstream_register_reevaluate (void);
202
203 void pim_upstream_add_lhr_star_pimreg (void);
204 void pim_upstream_remove_lhr_star_pimreg (const char *nlist);
205
206 void pim_upstream_spt_prefix_list_update (struct prefix_list *pl);
207 #endif /* PIM_UPSTREAM_H */