]>
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 | #include <zebra.h> | |
21 | ||
22 | #include "log.h" | |
23 | #include "memory.h" | |
24 | #include "linklist.h" | |
744d91b3 | 25 | #include "if.h" |
040d86ad DS |
26 | #include "hash.h" |
27 | #include "jhash.h" | |
12e41d03 DL |
28 | |
29 | #include "pimd.h" | |
30 | #include "pim_oil.h" | |
31 | #include "pim_str.h" | |
32 | #include "pim_iface.h" | |
37653d4f | 33 | #include "pim_time.h" |
5923b739 | 34 | #include "pim_vxlan.h" |
12e41d03 | 35 | |
611925dc DS |
36 | // struct list *pim_channel_oil_list = NULL; |
37 | // struct hash *pim_channel_oil_hash = NULL; | |
040d86ad | 38 | |
a155fed5 AK |
39 | static void pim_channel_update_mute(struct channel_oil *c_oil); |
40 | ||
d62a17ae | 41 | char *pim_channel_oil_dump(struct channel_oil *c_oil, char *buf, size_t size) |
781a1745 | 42 | { |
a2dc7057 | 43 | char *out; |
9bf5f19c | 44 | struct interface *ifp; |
d62a17ae | 45 | struct prefix_sg sg; |
46 | int i; | |
47 | ||
d62a17ae | 48 | sg.src = c_oil->oil.mfcc_origin; |
49 | sg.grp = c_oil->oil.mfcc_mcastgrp; | |
9bf5f19c DS |
50 | ifp = pim_if_find_by_vif_index(c_oil->pim, c_oil->oil.mfcc_parent); |
51 | snprintf(buf, size, "%s IIF: %s, OIFS: ", pim_str_sg_dump(&sg), | |
52 | ifp ? ifp->name : "(?)"); | |
d62a17ae | 53 | |
a2dc7057 | 54 | out = buf + strlen(buf); |
d62a17ae | 55 | for (i = 0; i < MAXVIFS; i++) { |
56 | if (c_oil->oil.mfcc_ttls[i] != 0) { | |
9bf5f19c DS |
57 | ifp = pim_if_find_by_vif_index(c_oil->pim, i); |
58 | snprintf(out, buf + size - out, "%s ", | |
59 | ifp ? ifp->name : "(?)"); | |
a2dc7057 | 60 | out += strlen(out); |
d62a17ae | 61 | } |
62 | } | |
63 | ||
64 | return buf; | |
781a1745 DS |
65 | } |
66 | ||
7315ecda DS |
67 | int pim_channel_oil_compare(const struct channel_oil *c1, |
68 | const struct channel_oil *c2) | |
040d86ad | 69 | { |
d62a17ae | 70 | if (ntohl(c1->oil.mfcc_mcastgrp.s_addr) |
71 | < ntohl(c2->oil.mfcc_mcastgrp.s_addr)) | |
72 | return -1; | |
040d86ad | 73 | |
d62a17ae | 74 | if (ntohl(c1->oil.mfcc_mcastgrp.s_addr) |
75 | > ntohl(c2->oil.mfcc_mcastgrp.s_addr)) | |
76 | return 1; | |
040d86ad | 77 | |
d62a17ae | 78 | if (ntohl(c1->oil.mfcc_origin.s_addr) |
79 | < ntohl(c2->oil.mfcc_origin.s_addr)) | |
80 | return -1; | |
040d86ad | 81 | |
d62a17ae | 82 | if (ntohl(c1->oil.mfcc_origin.s_addr) |
83 | > ntohl(c2->oil.mfcc_origin.s_addr)) | |
84 | return 1; | |
040d86ad | 85 | |
d62a17ae | 86 | return 0; |
040d86ad DS |
87 | } |
88 | ||
611925dc | 89 | void pim_oil_init(struct pim_instance *pim) |
040d86ad | 90 | { |
7315ecda | 91 | rb_pim_oil_init(&pim->channel_oil_head); |
040d86ad DS |
92 | } |
93 | ||
611925dc | 94 | void pim_oil_terminate(struct pim_instance *pim) |
040d86ad | 95 | { |
7315ecda DS |
96 | struct channel_oil *c_oil; |
97 | ||
98 | while ((c_oil = rb_pim_oil_pop(&pim->channel_oil_head))) | |
99 | pim_channel_oil_free(c_oil); | |
040d86ad | 100 | |
7315ecda | 101 | rb_pim_oil_fini(&pim->channel_oil_head); |
040d86ad DS |
102 | } |
103 | ||
12e41d03 DL |
104 | void pim_channel_oil_free(struct channel_oil *c_oil) |
105 | { | |
d62a17ae | 106 | XFREE(MTYPE_PIM_CHANNEL_OIL, c_oil); |
12e41d03 DL |
107 | } |
108 | ||
4d9ad5dc MS |
109 | struct channel_oil *pim_find_channel_oil(struct pim_instance *pim, |
110 | struct prefix_sg *sg) | |
12e41d03 | 111 | { |
d62a17ae | 112 | struct channel_oil *c_oil = NULL; |
113 | struct channel_oil lookup; | |
d270b216 | 114 | |
d62a17ae | 115 | lookup.oil.mfcc_mcastgrp = sg->grp; |
116 | lookup.oil.mfcc_origin = sg->src; | |
d270b216 | 117 | |
7315ecda | 118 | c_oil = rb_pim_oil_find(&pim->channel_oil_head, &lookup); |
d270b216 | 119 | |
d62a17ae | 120 | return c_oil; |
12e41d03 DL |
121 | } |
122 | ||
611925dc DS |
123 | struct channel_oil *pim_channel_oil_add(struct pim_instance *pim, |
124 | struct prefix_sg *sg, | |
7984af18 | 125 | const char *name) |
12e41d03 | 126 | { |
d62a17ae | 127 | struct channel_oil *c_oil; |
d62a17ae | 128 | |
611925dc | 129 | c_oil = pim_find_channel_oil(pim, sg); |
d62a17ae | 130 | if (c_oil) { |
d62a17ae | 131 | ++c_oil->oil_ref_count; |
a155fed5 AK |
132 | |
133 | if (!c_oil->up) { | |
134 | /* channel might be present prior to upstream */ | |
135 | c_oil->up = pim_upstream_find( | |
136 | pim, sg); | |
137 | /* if the upstream entry is being anchored to an | |
138 | * already existing channel OIL we need to re-evaluate | |
139 | * the "Mute" state on AA OIFs | |
140 | */ | |
141 | pim_channel_update_mute(c_oil); | |
142 | } | |
8a3e7e9e | 143 | |
7984af18 AK |
144 | /* check if the IIF has changed |
145 | * XXX - is this really needed | |
146 | */ | |
147 | pim_upstream_mroute_iif_update(c_oil, __func__); | |
148 | ||
8a3e7e9e DS |
149 | if (PIM_DEBUG_MROUTE) |
150 | zlog_debug( | |
151 | "%s(%s): Existing oil for %pSG4 Ref Count: %d (Post Increment)", | |
152 | __PRETTY_FUNCTION__, name, sg, | |
153 | c_oil->oil_ref_count); | |
d62a17ae | 154 | return c_oil; |
155 | } | |
156 | ||
d62a17ae | 157 | c_oil = XCALLOC(MTYPE_PIM_CHANNEL_OIL, sizeof(*c_oil)); |
d62a17ae | 158 | |
159 | c_oil->oil.mfcc_mcastgrp = sg->grp; | |
160 | c_oil->oil.mfcc_origin = sg->src; | |
d62a17ae | 161 | |
7984af18 | 162 | c_oil->oil.mfcc_parent = MAXVIFS; |
d62a17ae | 163 | c_oil->oil_ref_count = 1; |
164 | c_oil->installed = 0; | |
611925dc DS |
165 | c_oil->up = pim_upstream_find(pim, sg); |
166 | c_oil->pim = pim; | |
d62a17ae | 167 | |
7315ecda | 168 | rb_pim_oil_add(&pim->channel_oil_head, c_oil); |
d62a17ae | 169 | |
8a3e7e9e | 170 | if (PIM_DEBUG_MROUTE) |
7984af18 AK |
171 | zlog_debug("%s(%s): c_oil %s add", |
172 | __func__, name, pim_str_sg_dump(sg)); | |
173 | ||
d62a17ae | 174 | return c_oil; |
12e41d03 DL |
175 | } |
176 | ||
a155fed5 AK |
177 | struct channel_oil *pim_channel_oil_del(struct channel_oil *c_oil, |
178 | const char *name) | |
12e41d03 | 179 | { |
8a3e7e9e DS |
180 | if (PIM_DEBUG_MROUTE) { |
181 | struct prefix_sg sg = {.src = c_oil->oil.mfcc_mcastgrp, | |
182 | .grp = c_oil->oil.mfcc_origin}; | |
183 | ||
184 | zlog_debug( | |
185 | "%s(%s): Del oil for %pSG4, Ref Count: %d (Predecrement)", | |
186 | __PRETTY_FUNCTION__, name, &sg, c_oil->oil_ref_count); | |
187 | } | |
d62a17ae | 188 | --c_oil->oil_ref_count; |
189 | ||
190 | if (c_oil->oil_ref_count < 1) { | |
191 | /* | |
192 | * notice that listnode_delete() can't be moved | |
193 | * into pim_channel_oil_free() because the later is | |
194 | * called by list_delete_all_node() | |
195 | */ | |
196 | c_oil->up = NULL; | |
7315ecda | 197 | rb_pim_oil_del(&c_oil->pim->channel_oil_head, c_oil); |
d62a17ae | 198 | |
199 | pim_channel_oil_free(c_oil); | |
a155fed5 AK |
200 | return NULL; |
201 | } | |
202 | ||
203 | return c_oil; | |
204 | } | |
205 | ||
206 | void pim_channel_oil_upstream_deref(struct channel_oil *c_oil) | |
207 | { | |
208 | /* The upstream entry associated with a channel_oil is abt to be | |
209 | * deleted. If the channel_oil is kept around because of other | |
210 | * references we need to remove upstream based states out of it. | |
211 | */ | |
212 | c_oil = pim_channel_oil_del(c_oil, __func__); | |
213 | if (c_oil) { | |
214 | /* note: here we assume that c_oil->up has already been | |
215 | * cleared | |
216 | */ | |
217 | pim_channel_update_mute(c_oil); | |
d62a17ae | 218 | } |
12e41d03 | 219 | } |
1865a44a | 220 | |
d62a17ae | 221 | int pim_channel_del_oif(struct channel_oil *channel_oil, struct interface *oif, |
1b249e70 | 222 | uint32_t proto_mask, const char *caller) |
887fa014 | 223 | { |
d62a17ae | 224 | struct pim_interface *pim_ifp; |
225 | ||
226 | zassert(channel_oil); | |
227 | zassert(oif); | |
228 | ||
229 | pim_ifp = oif->info; | |
230 | ||
231 | /* | |
232 | * Don't do anything if we've been asked to remove a source | |
233 | * that is not actually on it. | |
234 | */ | |
235 | if (!(channel_oil->oif_flags[pim_ifp->mroute_vif_index] & proto_mask)) { | |
236 | if (PIM_DEBUG_MROUTE) { | |
237 | char group_str[INET_ADDRSTRLEN]; | |
238 | char source_str[INET_ADDRSTRLEN]; | |
239 | pim_inet4_dump("<group?>", | |
240 | channel_oil->oil.mfcc_mcastgrp, | |
241 | group_str, sizeof(group_str)); | |
242 | pim_inet4_dump("<source?>", | |
243 | channel_oil->oil.mfcc_origin, source_str, | |
244 | sizeof(source_str)); | |
245 | zlog_debug( | |
246 | "%s %s: no existing protocol mask %u(%u) for requested OIF %s (vif_index=%d, min_ttl=%d) for channel (S,G)=(%s,%s)", | |
247 | __FILE__, __PRETTY_FUNCTION__, proto_mask, | |
248 | channel_oil | |
249 | ->oif_flags[pim_ifp->mroute_vif_index], | |
250 | oif->name, pim_ifp->mroute_vif_index, | |
251 | channel_oil->oil | |
252 | .mfcc_ttls[pim_ifp->mroute_vif_index], | |
253 | source_str, group_str); | |
254 | } | |
255 | return 0; | |
256 | } | |
257 | ||
258 | channel_oil->oif_flags[pim_ifp->mroute_vif_index] &= ~proto_mask; | |
259 | ||
5923b739 AK |
260 | if (channel_oil->oif_flags[pim_ifp->mroute_vif_index] & |
261 | PIM_OIF_FLAG_PROTO_ANY) { | |
d62a17ae | 262 | if (PIM_DEBUG_MROUTE) { |
263 | char group_str[INET_ADDRSTRLEN]; | |
264 | char source_str[INET_ADDRSTRLEN]; | |
265 | pim_inet4_dump("<group?>", | |
266 | channel_oil->oil.mfcc_mcastgrp, | |
267 | group_str, sizeof(group_str)); | |
268 | pim_inet4_dump("<source?>", | |
269 | channel_oil->oil.mfcc_origin, source_str, | |
270 | sizeof(source_str)); | |
271 | zlog_debug( | |
272 | "%s %s: other protocol masks remain for requested OIF %s (vif_index=%d, min_ttl=%d) for channel (S,G)=(%s,%s)", | |
273 | __FILE__, __PRETTY_FUNCTION__, oif->name, | |
274 | pim_ifp->mroute_vif_index, | |
275 | channel_oil->oil | |
276 | .mfcc_ttls[pim_ifp->mroute_vif_index], | |
277 | source_str, group_str); | |
278 | } | |
279 | return 0; | |
280 | } | |
281 | ||
282 | channel_oil->oil.mfcc_ttls[pim_ifp->mroute_vif_index] = 0; | |
5923b739 AK |
283 | /* clear mute; will be re-evaluated when the OIF becomes valid again */ |
284 | channel_oil->oif_flags[pim_ifp->mroute_vif_index] &= ~PIM_OIF_FLAG_MUTE; | |
d62a17ae | 285 | |
69e3538c | 286 | if (pim_upstream_mroute_add(channel_oil, __PRETTY_FUNCTION__)) { |
d62a17ae | 287 | if (PIM_DEBUG_MROUTE) { |
288 | char group_str[INET_ADDRSTRLEN]; | |
289 | char source_str[INET_ADDRSTRLEN]; | |
290 | pim_inet4_dump("<group?>", | |
291 | channel_oil->oil.mfcc_mcastgrp, | |
292 | group_str, sizeof(group_str)); | |
293 | pim_inet4_dump("<source?>", | |
294 | channel_oil->oil.mfcc_origin, source_str, | |
295 | sizeof(source_str)); | |
296 | zlog_debug( | |
297 | "%s %s: could not remove output interface %s (vif_index=%d) for channel (S,G)=(%s,%s)", | |
298 | __FILE__, __PRETTY_FUNCTION__, oif->name, | |
299 | pim_ifp->mroute_vif_index, source_str, | |
300 | group_str); | |
301 | } | |
302 | return -1; | |
887fa014 | 303 | } |
d62a17ae | 304 | |
305 | --channel_oil->oil_size; | |
306 | ||
307 | if (PIM_DEBUG_MROUTE) { | |
308 | char group_str[INET_ADDRSTRLEN]; | |
309 | char source_str[INET_ADDRSTRLEN]; | |
310 | pim_inet4_dump("<group?>", channel_oil->oil.mfcc_mcastgrp, | |
311 | group_str, sizeof(group_str)); | |
312 | pim_inet4_dump("<source?>", channel_oil->oil.mfcc_origin, | |
313 | source_str, sizeof(source_str)); | |
314 | zlog_debug( | |
1b249e70 AK |
315 | "%s(%s): (S,G)=(%s,%s): proto_mask=%u IIF:%d OIF=%s vif_index=%d", |
316 | __PRETTY_FUNCTION__, caller, source_str, group_str, | |
d62a17ae | 317 | proto_mask, channel_oil->oil.mfcc_parent, oif->name, |
318 | pim_ifp->mroute_vif_index); | |
887fa014 | 319 | } |
d62a17ae | 320 | |
321 | return 0; | |
887fa014 DS |
322 | } |
323 | ||
1537a668 AK |
324 | void pim_channel_del_inherited_oif(struct channel_oil *c_oil, |
325 | struct interface *oif, const char *caller) | |
326 | { | |
327 | struct pim_upstream *up = c_oil->up; | |
328 | ||
329 | pim_channel_del_oif(c_oil, oif, PIM_OIF_FLAG_PROTO_STAR, | |
330 | caller); | |
331 | ||
332 | /* if an inherited OIF is being removed join-desired can change | |
333 | * if the inherited OIL is now empty and KAT is running | |
334 | */ | |
335 | if (up && up->sg.src.s_addr != INADDR_ANY && | |
336 | pim_upstream_empty_inherited_olist(up)) | |
337 | pim_upstream_update_join_desired(up->pim, up); | |
338 | } | |
887fa014 | 339 | |
5923b739 AK |
340 | static bool pim_channel_eval_oif_mute(struct channel_oil *c_oil, |
341 | struct pim_interface *pim_ifp) | |
342 | { | |
343 | struct pim_interface *pim_reg_ifp; | |
344 | struct pim_interface *vxlan_ifp; | |
345 | bool do_mute = false; | |
346 | struct pim_instance *pim = c_oil->pim; | |
347 | ||
348 | if (!c_oil->up) | |
349 | return do_mute; | |
350 | ||
351 | pim_reg_ifp = pim->regiface->info; | |
352 | if (pim_ifp == pim_reg_ifp) { | |
353 | /* suppress pimreg in the OIL if the mroute is not supposed to | |
354 | * trigger register encapsulated data | |
355 | */ | |
356 | if (PIM_UPSTREAM_FLAG_TEST_NO_PIMREG_DATA(c_oil->up->flags)) | |
357 | do_mute = true; | |
358 | ||
359 | return do_mute; | |
360 | } | |
361 | ||
362 | vxlan_ifp = pim_vxlan_get_term_ifp(pim); | |
363 | if (pim_ifp == vxlan_ifp) { | |
364 | /* 1. vxlan termination device must never be added to the | |
365 | * origination mroute (and that can actually happen because | |
366 | * of XG inheritance from the termination mroute) otherwise | |
367 | * traffic will end up looping. | |
368 | * PS: This check has also been extended to non-orig mroutes | |
369 | * that have a local SIP as such mroutes can move back and | |
370 | * forth between orig<=>non-orig type. | |
371 | * 2. vxlan termination device should be removed from the non-DF | |
372 | * to prevent duplicates to the overlay rxer | |
373 | */ | |
374 | if (PIM_UPSTREAM_FLAG_TEST_SRC_VXLAN_ORIG(c_oil->up->flags) || | |
375 | PIM_UPSTREAM_FLAG_TEST_MLAG_NON_DF(c_oil->up->flags) || | |
376 | pim_vxlan_is_local_sip(c_oil->up)) | |
377 | do_mute = true; | |
378 | ||
379 | return do_mute; | |
380 | } | |
381 | ||
382 | return do_mute; | |
383 | } | |
384 | ||
385 | void pim_channel_update_oif_mute(struct channel_oil *c_oil, | |
386 | struct pim_interface *pim_ifp) | |
387 | { | |
388 | bool old_mute; | |
389 | bool new_mute; | |
390 | ||
391 | /* If pim_ifp is not a part of the OIL there is nothing to do */ | |
392 | if (!c_oil->oil.mfcc_ttls[pim_ifp->mroute_vif_index]) | |
393 | return; | |
394 | ||
395 | old_mute = !!(c_oil->oif_flags[pim_ifp->mroute_vif_index] & | |
396 | PIM_OIF_FLAG_MUTE); | |
397 | new_mute = pim_channel_eval_oif_mute(c_oil, pim_ifp); | |
398 | if (old_mute == new_mute) | |
399 | return; | |
400 | ||
401 | if (new_mute) | |
402 | c_oil->oif_flags[pim_ifp->mroute_vif_index] |= | |
403 | PIM_OIF_FLAG_MUTE; | |
404 | else | |
405 | c_oil->oif_flags[pim_ifp->mroute_vif_index] &= | |
406 | ~PIM_OIF_FLAG_MUTE; | |
407 | ||
69e3538c | 408 | pim_upstream_mroute_add(c_oil, __PRETTY_FUNCTION__); |
5923b739 AK |
409 | } |
410 | ||
a155fed5 AK |
411 | /* pim_upstream has been set or cleared on the c_oil. re-eval mute state |
412 | * on all existing OIFs | |
413 | */ | |
414 | static void pim_channel_update_mute(struct channel_oil *c_oil) | |
415 | { | |
416 | struct pim_interface *pim_reg_ifp; | |
417 | struct pim_interface *vxlan_ifp; | |
418 | ||
419 | pim_reg_ifp = c_oil->pim->regiface->info; | |
420 | if (pim_reg_ifp) | |
421 | pim_channel_update_oif_mute(c_oil, pim_reg_ifp); | |
422 | vxlan_ifp = pim_vxlan_get_term_ifp(c_oil->pim); | |
423 | if (vxlan_ifp) | |
424 | pim_channel_update_oif_mute(c_oil, vxlan_ifp); | |
425 | } | |
426 | ||
d62a17ae | 427 | int pim_channel_add_oif(struct channel_oil *channel_oil, struct interface *oif, |
1b249e70 | 428 | uint32_t proto_mask, const char *caller) |
1865a44a | 429 | { |
d62a17ae | 430 | struct pim_interface *pim_ifp; |
431 | int old_ttl; | |
432 | ||
433 | /* | |
434 | * If we've gotten here we've gone bad, but let's | |
435 | * not take down pim | |
436 | */ | |
437 | if (!channel_oil) { | |
438 | zlog_warn("Attempt to Add OIF for non-existent channel oil"); | |
439 | return -1; | |
440 | } | |
1865a44a | 441 | |
d62a17ae | 442 | pim_ifp = oif->info; |
1865a44a | 443 | |
d62a17ae | 444 | /* Prevent single protocol from subscribing same interface to |
445 | channel (S,G) multiple times */ | |
446 | if (channel_oil->oif_flags[pim_ifp->mroute_vif_index] & proto_mask) { | |
447 | if (PIM_DEBUG_MROUTE) { | |
448 | char group_str[INET_ADDRSTRLEN]; | |
449 | char source_str[INET_ADDRSTRLEN]; | |
450 | pim_inet4_dump("<group?>", | |
451 | channel_oil->oil.mfcc_mcastgrp, | |
452 | group_str, sizeof(group_str)); | |
453 | pim_inet4_dump("<source?>", | |
454 | channel_oil->oil.mfcc_origin, source_str, | |
455 | sizeof(source_str)); | |
456 | zlog_debug( | |
457 | "%s %s: existing protocol mask %u requested OIF %s (vif_index=%d, min_ttl=%d) for channel (S,G)=(%s,%s)", | |
458 | __FILE__, __PRETTY_FUNCTION__, proto_mask, | |
459 | oif->name, pim_ifp->mroute_vif_index, | |
460 | channel_oil->oil | |
461 | .mfcc_ttls[pim_ifp->mroute_vif_index], | |
462 | source_str, group_str); | |
463 | } | |
464 | return -3; | |
465 | } | |
466 | ||
467 | /* Allow other protocol to request subscription of same interface to | |
468 | * channel (S,G), we need to note this information | |
469 | */ | |
470 | if (channel_oil->oif_flags[pim_ifp->mroute_vif_index] | |
471 | & PIM_OIF_FLAG_PROTO_ANY) { | |
472 | ||
d23756e9 SP |
473 | /* Updating time here is not required as this time has to |
474 | * indicate when the interface is added | |
475 | */ | |
476 | ||
d62a17ae | 477 | channel_oil->oif_flags[pim_ifp->mroute_vif_index] |= proto_mask; |
478 | /* Check the OIF really exists before returning, and only log | |
479 | warning otherwise */ | |
480 | if (channel_oil->oil.mfcc_ttls[pim_ifp->mroute_vif_index] < 1) { | |
481 | { | |
482 | char group_str[INET_ADDRSTRLEN]; | |
483 | char source_str[INET_ADDRSTRLEN]; | |
484 | pim_inet4_dump("<group?>", | |
485 | channel_oil->oil.mfcc_mcastgrp, | |
486 | group_str, sizeof(group_str)); | |
487 | pim_inet4_dump("<source?>", | |
488 | channel_oil->oil.mfcc_origin, | |
489 | source_str, sizeof(source_str)); | |
490 | zlog_warn( | |
491 | "%s %s: new protocol mask %u requested nonexistent OIF %s (vif_index=%d, min_ttl=%d) for channel (S,G)=(%s,%s)", | |
492 | __FILE__, __PRETTY_FUNCTION__, | |
493 | proto_mask, oif->name, | |
494 | pim_ifp->mroute_vif_index, | |
495 | channel_oil->oil.mfcc_ttls | |
496 | [pim_ifp->mroute_vif_index], | |
497 | source_str, group_str); | |
498 | } | |
499 | } | |
500 | ||
501 | return 0; | |
502 | } | |
503 | ||
504 | old_ttl = channel_oil->oil.mfcc_ttls[pim_ifp->mroute_vif_index]; | |
505 | ||
506 | if (old_ttl > 0) { | |
507 | if (PIM_DEBUG_MROUTE) { | |
508 | char group_str[INET_ADDRSTRLEN]; | |
509 | char source_str[INET_ADDRSTRLEN]; | |
510 | pim_inet4_dump("<group?>", | |
511 | channel_oil->oil.mfcc_mcastgrp, | |
512 | group_str, sizeof(group_str)); | |
513 | pim_inet4_dump("<source?>", | |
514 | channel_oil->oil.mfcc_origin, source_str, | |
515 | sizeof(source_str)); | |
516 | zlog_debug( | |
517 | "%s %s: interface %s (vif_index=%d) is existing output for channel (S,G)=(%s,%s)", | |
518 | __FILE__, __PRETTY_FUNCTION__, oif->name, | |
519 | pim_ifp->mroute_vif_index, source_str, | |
520 | group_str); | |
521 | } | |
522 | return -4; | |
523 | } | |
524 | ||
525 | channel_oil->oil.mfcc_ttls[pim_ifp->mroute_vif_index] = | |
526 | PIM_MROUTE_MIN_TTL; | |
527 | ||
5923b739 AK |
528 | /* Some OIFs are held in a muted state i.e. the PIM state machine |
529 | * decided to include the OIF but additional status check such as | |
530 | * MLAG DF role prevent it from being activated for traffic | |
531 | * forwarding. | |
532 | */ | |
533 | if (pim_channel_eval_oif_mute(channel_oil, pim_ifp)) | |
534 | channel_oil->oif_flags[pim_ifp->mroute_vif_index] |= | |
535 | PIM_OIF_FLAG_MUTE; | |
536 | else | |
537 | channel_oil->oif_flags[pim_ifp->mroute_vif_index] &= | |
538 | ~PIM_OIF_FLAG_MUTE; | |
539 | ||
47e3ce59 SP |
540 | /* channel_oil->oil.mfcc_parent != MAXVIFS indicate this entry is not |
541 | * valid to get installed in kernel. | |
c3156184 | 542 | */ |
47e3ce59 | 543 | if (channel_oil->oil.mfcc_parent != MAXVIFS) { |
69e3538c | 544 | if (pim_upstream_mroute_add(channel_oil, __PRETTY_FUNCTION__)) { |
c3156184 SP |
545 | if (PIM_DEBUG_MROUTE) { |
546 | char group_str[INET_ADDRSTRLEN]; | |
547 | char source_str[INET_ADDRSTRLEN]; | |
548 | pim_inet4_dump("<group?>", | |
549 | channel_oil->oil.mfcc_mcastgrp, | |
550 | group_str, sizeof(group_str)); | |
551 | pim_inet4_dump("<source?>", | |
552 | channel_oil->oil.mfcc_origin, source_str, | |
553 | sizeof(source_str)); | |
554 | zlog_debug( | |
555 | "%s %s: could not add output interface %s (vif_index=%d) for channel (S,G)=(%s,%s)", | |
556 | __FILE__, __PRETTY_FUNCTION__, oif->name, | |
557 | pim_ifp->mroute_vif_index, source_str, | |
558 | group_str); | |
559 | } | |
d62a17ae | 560 | |
c3156184 SP |
561 | channel_oil->oil.mfcc_ttls[pim_ifp->mroute_vif_index] |
562 | = old_ttl; | |
563 | return -5; | |
564 | } | |
d62a17ae | 565 | } |
566 | ||
567 | channel_oil->oif_creation[pim_ifp->mroute_vif_index] = | |
568 | pim_time_monotonic_sec(); | |
569 | ++channel_oil->oil_size; | |
570 | channel_oil->oif_flags[pim_ifp->mroute_vif_index] |= proto_mask; | |
571 | ||
572 | if (PIM_DEBUG_MROUTE) { | |
573 | char group_str[INET_ADDRSTRLEN]; | |
574 | char source_str[INET_ADDRSTRLEN]; | |
575 | pim_inet4_dump("<group?>", channel_oil->oil.mfcc_mcastgrp, | |
576 | group_str, sizeof(group_str)); | |
577 | pim_inet4_dump("<source?>", channel_oil->oil.mfcc_origin, | |
578 | source_str, sizeof(source_str)); | |
579 | zlog_debug( | |
1b249e70 AK |
580 | "%s(%s): (S,G)=(%s,%s): proto_mask=%u OIF=%s vif_index=%d: DONE", |
581 | __PRETTY_FUNCTION__, caller, source_str, group_str, | |
d62a17ae | 582 | proto_mask, oif->name, pim_ifp->mroute_vif_index); |
583 | } | |
584 | ||
585 | return 0; | |
1865a44a | 586 | } |
ce0ddb4e | 587 | |
d62a17ae | 588 | int pim_channel_oil_empty(struct channel_oil *c_oil) |
ce0ddb4e | 589 | { |
d86632fb | 590 | static struct mfcctl null_oil; |
d62a17ae | 591 | |
592 | if (!c_oil) | |
593 | return 1; | |
d62a17ae | 594 | |
9e558d9a AK |
595 | /* exclude pimreg from the OIL when checking if the inherited_oil is |
596 | * non-NULL. | |
597 | * pimreg device (in all vrfs) uses a vifi of | |
598 | * 0 (PIM_OIF_PIM_REGISTER_VIF) so we simply mfcc_ttls[0] */ | |
599 | return !memcmp(&c_oil->oil.mfcc_ttls[1], &null_oil.mfcc_ttls[1], | |
600 | sizeof(null_oil.mfcc_ttls) - sizeof(null_oil.mfcc_ttls[0])); | |
ce0ddb4e | 601 | } |