]>
Commit | Line | Data |
---|---|---|
12e41d03 | 1 | /* |
896014f4 DL |
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 | */ | |
12e41d03 DL |
19 | |
20 | #ifndef PIM_UPSTREAM_H | |
21 | #define PIM_UPSTREAM_H | |
22 | ||
23 | #include <zebra.h> | |
05e451f8 | 24 | #include <prefix.h> |
ba4eb1bc | 25 | #include "plist.h" |
12e41d03 | 26 | |
f9717886 | 27 | #include <pimd/pim_rpf.h> |
ba4eb1bc CS |
28 | #include "pim_str.h" |
29 | #include "pim_ifchannel.h" | |
bfea315d | 30 | |
12e41d03 | 31 | #define PIM_UPSTREAM_FLAG_MASK_DR_JOIN_DESIRED (1 << 0) |
ca973133 DS |
32 | #define PIM_UPSTREAM_FLAG_MASK_DR_JOIN_DESIRED_UPDATED (1 << 1) |
33 | #define PIM_UPSTREAM_FLAG_MASK_FHR (1 << 2) | |
34 | #define PIM_UPSTREAM_FLAG_MASK_SRC_IGMP (1 << 3) | |
35 | #define PIM_UPSTREAM_FLAG_MASK_SRC_PIM (1 << 4) | |
36 | #define PIM_UPSTREAM_FLAG_MASK_SRC_STREAM (1 << 5) | |
1bf16443 | 37 | #define PIM_UPSTREAM_FLAG_MASK_SRC_MSDP (1 << 6) |
54179a37 | 38 | #define PIM_UPSTREAM_FLAG_MASK_SEND_SG_RPT_PRUNE (1 << 7) |
850a9f99 | 39 | #define PIM_UPSTREAM_FLAG_MASK_SRC_LHR (1 << 8) |
820b4a40 AK |
40 | /* In the case of pim vxlan we prime the pump by registering the |
41 | * vxlan source and keeping the SPT (FHR-RP) alive by sending periodic | |
42 | * NULL registers. So we need to prevent KAT expiry because of the | |
43 | * lack of BUM traffic. | |
44 | */ | |
45 | #define PIM_UPSTREAM_FLAG_MASK_DISABLE_KAT_EXPIRY (1 << 9) | |
850a9f99 | 46 | #define PIM_UPSTREAM_FLAG_ALL 0xFFFFFFFF |
12e41d03 DL |
47 | |
48 | #define PIM_UPSTREAM_FLAG_TEST_DR_JOIN_DESIRED(flags) ((flags) & PIM_UPSTREAM_FLAG_MASK_DR_JOIN_DESIRED) | |
49 | #define PIM_UPSTREAM_FLAG_TEST_DR_JOIN_DESIRED_UPDATED(flags) ((flags) & PIM_UPSTREAM_FLAG_MASK_DR_JOIN_DESIRED_UPDATED) | |
69ff3706 | 50 | #define PIM_UPSTREAM_FLAG_TEST_FHR(flags) ((flags) & PIM_UPSTREAM_FLAG_MASK_FHR) |
1d3a62cd DS |
51 | #define PIM_UPSTREAM_FLAG_TEST_SRC_IGMP(flags) ((flags) & PIM_UPSTREAM_FLAG_MASK_SRC_IGMP) |
52 | #define PIM_UPSTREAM_FLAG_TEST_SRC_PIM(flags) ((flags) & PIM_UPSTREAM_FLAG_MASK_SRC_PIM) | |
53 | #define PIM_UPSTREAM_FLAG_TEST_SRC_STREAM(flags) ((flags) & PIM_UPSTREAM_FLAG_MASK_SRC_STREAM) | |
7667c556 | 54 | #define PIM_UPSTREAM_FLAG_TEST_SRC_MSDP(flags) ((flags) & PIM_UPSTREAM_FLAG_MASK_SRC_MSDP) |
54179a37 | 55 | #define PIM_UPSTREAM_FLAG_TEST_SEND_SG_RPT_PRUNE(flags) ((flags) & PIM_UPSTREAM_FLAG_MASK_SEND_SG_RPT_PRUNE) |
850a9f99 | 56 | #define PIM_UPSTREAM_FLAG_TEST_SRC_LHR(flags) ((flags) & PIM_UPSTREAM_FLAG_MASK_SRC_LHR) |
820b4a40 | 57 | #define PIM_UPSTREAM_FLAG_TEST_DISABLE_KAT_EXPIRY(flags) ((flags) & PIM_UPSTREAM_FLAG_MASK_DISABLE_KAT_EXPIRY) |
12e41d03 DL |
58 | |
59 | #define PIM_UPSTREAM_FLAG_SET_DR_JOIN_DESIRED(flags) ((flags) |= PIM_UPSTREAM_FLAG_MASK_DR_JOIN_DESIRED) | |
60 | #define PIM_UPSTREAM_FLAG_SET_DR_JOIN_DESIRED_UPDATED(flags) ((flags) |= PIM_UPSTREAM_FLAG_MASK_DR_JOIN_DESIRED_UPDATED) | |
69ff3706 | 61 | #define PIM_UPSTREAM_FLAG_SET_FHR(flags) ((flags) |= PIM_UPSTREAM_FLAG_MASK_FHR) |
1d3a62cd DS |
62 | #define PIM_UPSTREAM_FLAG_SET_SRC_IGMP(flags) ((flags) |= PIM_UPSTREAM_FLAG_MASK_SRC_IGMP) |
63 | #define PIM_UPSTREAM_FLAG_SET_SRC_PIM(flags) ((flags) |= PIM_UPSTREAM_FLAG_MASK_SRC_PIM) | |
64 | #define PIM_UPSTREAM_FLAG_SET_SRC_STREAM(flags) ((flags) |= PIM_UPSTREAM_FLAG_MASK_SRC_STREAM) | |
7667c556 | 65 | #define PIM_UPSTREAM_FLAG_SET_SRC_MSDP(flags) ((flags) |= PIM_UPSTREAM_FLAG_MASK_SRC_MSDP) |
54179a37 | 66 | #define PIM_UPSTREAM_FLAG_SET_SEND_SG_RPT_PRUNE(flags) ((flags) |= PIM_UPSTREAM_FLAG_MASK_SEND_SG_RPT_PRUNE) |
850a9f99 | 67 | #define PIM_UPSTREAM_FLAG_SET_SRC_LHR(flags) ((flags) |= PIM_UPSTREAM_FLAG_MASK_SRC_LHR) |
820b4a40 | 68 | #define PIM_UPSTREAM_FLAG_SET_DISABLE_KAT_EXPIRY(flags) ((flags) |= PIM_UPSTREAM_FLAG_MASK_DISABLE_KAT_EXPIRY) |
12e41d03 DL |
69 | |
70 | #define PIM_UPSTREAM_FLAG_UNSET_DR_JOIN_DESIRED(flags) ((flags) &= ~PIM_UPSTREAM_FLAG_MASK_DR_JOIN_DESIRED) | |
71 | #define PIM_UPSTREAM_FLAG_UNSET_DR_JOIN_DESIRED_UPDATED(flags) ((flags) &= ~PIM_UPSTREAM_FLAG_MASK_DR_JOIN_DESIRED_UPDATED) | |
69ff3706 | 72 | #define PIM_UPSTREAM_FLAG_UNSET_FHR(flags) ((flags) &= ~PIM_UPSTREAM_FLAG_MASK_FHR) |
1d3a62cd DS |
73 | #define PIM_UPSTREAM_FLAG_UNSET_SRC_IGMP(flags) ((flags) &= ~PIM_UPSTREAM_FLAG_MASK_SRC_IGMP) |
74 | #define PIM_UPSTREAM_FLAG_UNSET_SRC_PIM(flags) ((flags) &= ~PIM_UPSTREAM_FLAG_MASK_SRC_PIM) | |
75 | #define PIM_UPSTREAM_FLAG_UNSET_SRC_STREAM(flags) ((flags) &= ~PIM_UPSTREAM_FLAG_MASK_SRC_STREAM) | |
7667c556 | 76 | #define PIM_UPSTREAM_FLAG_UNSET_SRC_MSDP(flags) ((flags) &= ~PIM_UPSTREAM_FLAG_MASK_SRC_MSDP) |
54179a37 | 77 | #define PIM_UPSTREAM_FLAG_UNSET_SEND_SG_RPT_PRUNE(flags) ((flags) &= ~PIM_UPSTREAM_FLAG_MASK_SEND_SG_RPT_PRUNE) |
850a9f99 | 78 | #define PIM_UPSTREAM_FLAG_UNSET_SRC_LHR(flags) ((flags) &= ~PIM_UPSTREAM_FLAG_MASK_SRC_LHR) |
820b4a40 | 79 | #define PIM_UPSTREAM_FLAG_UNSET_DISABLE_KAT_EXPIRY(flags) ((flags) &= ~PIM_UPSTREAM_FLAG_MASK_DISABLE_KAT_EXPIRY) |
12e41d03 | 80 | |
12e41d03 | 81 | enum pim_upstream_state { |
d62a17ae | 82 | PIM_UPSTREAM_NOTJOINED, |
83 | PIM_UPSTREAM_JOINED, | |
12e41d03 DL |
84 | }; |
85 | ||
0c2ebf00 | 86 | enum pim_reg_state { |
d62a17ae | 87 | PIM_REG_NOINFO, |
88 | PIM_REG_JOIN, | |
89 | PIM_REG_JOIN_PENDING, | |
90 | PIM_REG_PRUNE, | |
0c2ebf00 | 91 | }; |
92 | ||
d99764f6 | 93 | enum pim_upstream_sptbit { |
d62a17ae | 94 | PIM_UPSTREAM_SPTBIT_FALSE, |
95 | PIM_UPSTREAM_SPTBIT_TRUE | |
d99764f6 DS |
96 | }; |
97 | ||
12e41d03 DL |
98 | /* |
99 | Upstream (S,G) channel in Joined state | |
12e41d03 | 100 | (S,G) in the "Not Joined" state is not represented |
12e41d03 | 101 | See RFC 4601: 4.5.7. Sending (S,G) Join/Prune Message |
bbe598df SP |
102 | |
103 | upstream_addr : Who we are talking to. | |
104 | For (*, G), upstream_addr is RP address or INADDR_ANY(if RP not configured) | |
105 | For (S, G), upstream_addr is source address | |
106 | ||
107 | rpf: contains the nexthop information to whom we are talking to. | |
108 | ||
109 | join_state: JOINED/NOTJOINED | |
110 | ||
111 | In the case when FRR receives IGMP/PIM (*, G) join for group G and RP is not | |
112 | configured, then create a pim_upstream with the below information. | |
113 | pim_upstream->upstream address: INADDR_ANY | |
114 | pim_upstream->rpf: Unknown | |
115 | pim_upstream->state: NOTJOINED | |
116 | ||
117 | When a new RP gets configured for G, find the corresponding pim upstream (*,G) | |
118 | entries and update the upstream address as new RP address if it the better one | |
119 | for the group G. | |
120 | ||
121 | When RP becomes reachable, populate the nexthop information in | |
122 | pim_upstream->rpf and update the state to JOINED. | |
123 | ||
12e41d03 DL |
124 | */ |
125 | struct pim_upstream { | |
d62a17ae | 126 | struct pim_upstream *parent; |
127 | struct in_addr upstream_addr; /* Who we are talking to */ | |
128 | struct in_addr upstream_register; /*Who we received a register from*/ | |
129 | struct prefix_sg sg; /* (S,G) group key */ | |
130 | char sg_str[PIM_SG_LEN]; | |
131 | uint32_t flags; | |
132 | struct channel_oil *channel_oil; | |
133 | struct list *sources; | |
134 | struct list *ifchannels; | |
135 | ||
136 | enum pim_upstream_state join_state; | |
137 | enum pim_reg_state reg_state; | |
138 | enum pim_upstream_sptbit sptbit; | |
139 | ||
140 | int ref_count; | |
141 | ||
142 | struct pim_rpf rpf; | |
143 | ||
144 | struct thread *t_join_timer; | |
145 | ||
146 | /* | |
147 | * RST(S,G) | |
148 | */ | |
149 | struct thread *t_rs_timer; | |
2ddab288 | 150 | #define PIM_REGISTER_SUPPRESSION_PERIOD (60) |
38de2445 | 151 | #define PIM_REGISTER_PROBE_PERIOD (5) |
2ddab288 | 152 | |
d62a17ae | 153 | /* |
154 | * KAT(S,G) | |
155 | */ | |
156 | struct thread *t_ka_timer; | |
4a4c4a07 | 157 | #define PIM_KEEPALIVE_PERIOD (210) |
2925dff5 | 158 | #define PIM_RP_KEEPALIVE_PERIOD \ |
a6c5db59 | 159 | (3 * router->register_suppress_time + router->register_probe_time) |
4a4c4a07 | 160 | |
d62a17ae | 161 | /* on the RP we restart a timer to indicate if registers are being rxed |
162 | * for | |
163 | * SG. This is needed by MSDP to determine its local SA cache */ | |
164 | struct thread *t_msdp_reg_timer; | |
2925dff5 | 165 | #define PIM_MSDP_REG_RXED_PERIOD (3 * (1.5 * router->register_suppress_time)) |
1bf16443 | 166 | |
d62a17ae | 167 | int64_t state_transition; /* Record current state uptime */ |
12e41d03 DL |
168 | }; |
169 | ||
9b29ea95 DS |
170 | struct pim_upstream *pim_upstream_find(struct pim_instance *pim, |
171 | struct prefix_sg *sg); | |
d62a17ae | 172 | struct pim_upstream *pim_upstream_find_or_add(struct prefix_sg *sg, |
173 | struct interface *ifp, int flags, | |
174 | const char *name); | |
2002dcdb DS |
175 | struct pim_upstream *pim_upstream_add(struct pim_instance *pim, |
176 | struct prefix_sg *sg, | |
d62a17ae | 177 | struct interface *ifp, int flags, |
0885a9f1 DS |
178 | const char *name, |
179 | struct pim_ifchannel *ch); | |
d62a17ae | 180 | void pim_upstream_ref(struct pim_upstream *up, int flags, const char *name); |
9b29ea95 DS |
181 | struct pim_upstream *pim_upstream_del(struct pim_instance *pim, |
182 | struct pim_upstream *up, | |
d62a17ae | 183 | const char *name); |
12e41d03 | 184 | |
9b29ea95 DS |
185 | int pim_upstream_evaluate_join_desired(struct pim_instance *pim, |
186 | struct pim_upstream *up); | |
9f44d042 | 187 | int pim_upstream_evaluate_join_desired_interface(struct pim_upstream *up, |
d62a17ae | 188 | struct pim_ifchannel *ch, |
189 | struct pim_ifchannel *starch); | |
9b29ea95 DS |
190 | void pim_upstream_update_join_desired(struct pim_instance *pim, |
191 | struct pim_upstream *up); | |
12e41d03 DL |
192 | |
193 | void pim_upstream_join_suppress(struct pim_upstream *up, | |
d62a17ae | 194 | struct in_addr rpf_addr, int holdtime); |
c48a612c | 195 | |
12e41d03 | 196 | void pim_upstream_join_timer_decrease_to_t_override(const char *debug_label, |
d62a17ae | 197 | struct pim_upstream *up); |
c48a612c | 198 | |
d62a17ae | 199 | void pim_upstream_join_timer_restart(struct pim_upstream *up, |
200 | struct pim_rpf *old); | |
9b29ea95 DS |
201 | void pim_upstream_rpf_genid_changed(struct pim_instance *pim, |
202 | struct in_addr neigh_addr); | |
12e41d03 DL |
203 | void pim_upstream_rpf_interface_changed(struct pim_upstream *up, |
204 | struct interface *old_rpf_ifp); | |
205 | ||
206 | void pim_upstream_update_could_assert(struct pim_upstream *up); | |
207 | void pim_upstream_update_my_assert_metric(struct pim_upstream *up); | |
208 | ||
d62a17ae | 209 | void pim_upstream_keep_alive_timer_start(struct pim_upstream *up, |
210 | uint32_t time); | |
cb40b272 | 211 | |
8e5f97e3 DS |
212 | int pim_upstream_switch_to_spt_desired(struct pim_instance *pim, |
213 | struct prefix_sg *sg); | |
214 | #define SwitchToSptDesired(pim, sg) pim_upstream_switch_to_spt_desired (pim, sg) | |
d62a17ae | 215 | int pim_upstream_is_sg_rpt(struct pim_upstream *up); |
cb40b272 | 216 | |
d62a17ae | 217 | void pim_upstream_set_sptbit(struct pim_upstream *up, |
218 | struct interface *incoming); | |
3a66b17b | 219 | |
d62a17ae | 220 | void pim_upstream_start_register_stop_timer(struct pim_upstream *up, |
221 | int null_register); | |
627ed2a3 | 222 | |
d62a17ae | 223 | void pim_upstream_send_join(struct pim_upstream *up); |
56638739 | 224 | |
1eca8576 | 225 | void pim_upstream_switch(struct pim_instance *pim, struct pim_upstream *up, |
d62a17ae | 226 | enum pim_upstream_state new_state); |
7fcdfb34 | 227 | |
d62a17ae | 228 | const char *pim_upstream_state2str(enum pim_upstream_state join_state); |
e0e127b0 | 229 | #define PIM_REG_STATE_STR_LEN 12 |
d62a17ae | 230 | const char *pim_reg_state2str(enum pim_reg_state state, char *state_str); |
4fdc8f36 | 231 | |
9b29ea95 DS |
232 | int pim_upstream_inherited_olist_decide(struct pim_instance *pim, |
233 | struct pim_upstream *up); | |
234 | int pim_upstream_inherited_olist(struct pim_instance *pim, | |
235 | struct pim_upstream *up); | |
d62a17ae | 236 | int pim_upstream_empty_inherited_olist(struct pim_upstream *up); |
d3dd1804 | 237 | |
9b29ea95 | 238 | void pim_upstream_find_new_rpf(struct pim_instance *pim); |
1bf16443 | 239 | void pim_upstream_msdp_reg_timer_start(struct pim_upstream *up); |
d3dd1804 | 240 | |
9b29ea95 DS |
241 | void pim_upstream_init(struct pim_instance *pim); |
242 | void pim_upstream_terminate(struct pim_instance *pim); | |
982bff89 | 243 | |
d62a17ae | 244 | void join_timer_start(struct pim_upstream *up); |
245 | int pim_upstream_compare(void *arg1, void *arg2); | |
9b29ea95 | 246 | void pim_upstream_register_reevaluate(struct pim_instance *pim); |
a7b2b1e2 | 247 | |
9b29ea95 DS |
248 | void pim_upstream_add_lhr_star_pimreg(struct pim_instance *pim); |
249 | void pim_upstream_remove_lhr_star_pimreg(struct pim_instance *pim, | |
250 | const char *nlist); | |
df94f9a9 | 251 | |
9b29ea95 DS |
252 | void pim_upstream_spt_prefix_list_update(struct pim_instance *pim, |
253 | struct prefix_list *pl); | |
7c591950 DS |
254 | |
255 | unsigned int pim_upstream_hash_key(void *arg); | |
74df8d6d | 256 | bool pim_upstream_equal(const void *arg1, const void *arg2); |
ff459c36 AK |
257 | struct pim_upstream *pim_upstream_keep_alive_timer_proc( |
258 | struct pim_upstream *up); | |
12e41d03 | 259 | #endif /* PIM_UPSTREAM_H */ |