]>
Commit | Line | Data |
---|---|---|
acddc0ed | 1 | // SPDX-License-Identifier: GPL-2.0-or-later |
12e41d03 | 2 | /* |
896014f4 DL |
3 | * PIM for Quagga |
4 | * Copyright (C) 2008 Everton da Silva Marques | |
896014f4 | 5 | */ |
12e41d03 DL |
6 | |
7 | #include <zebra.h> | |
8 | ||
12e41d03 DL |
9 | #include "if.h" |
10 | #include "log.h" | |
11 | #include "prefix.h" | |
12 | #include "zclient.h" | |
13 | #include "stream.h" | |
14 | #include "network.h" | |
dfe43e25 DW |
15 | #include "vty.h" |
16 | #include "plist.h" | |
ba4eb1bc | 17 | #include "lib/bfd.h" |
12e41d03 DL |
18 | |
19 | #include "pimd.h" | |
20 | #include "pim_pim.h" | |
21 | #include "pim_zebra.h" | |
22 | #include "pim_iface.h" | |
23 | #include "pim_str.h" | |
24 | #include "pim_oil.h" | |
25 | #include "pim_rpf.h" | |
26 | #include "pim_time.h" | |
27 | #include "pim_join.h" | |
28 | #include "pim_zlookup.h" | |
29 | #include "pim_ifchannel.h" | |
8f5f5e91 | 30 | #include "pim_rp.h" |
2560106c | 31 | #include "pim_igmpv3.h" |
982bff89 | 32 | #include "pim_jp_agg.h" |
1bc98276 | 33 | #include "pim_nht.h" |
15a5dafe | 34 | #include "pim_ssm.h" |
af7b561b | 35 | #include "pim_vxlan.h" |
46c2687c | 36 | #include "pim_mlag.h" |
12e41d03 DL |
37 | |
38 | #undef PIM_DEBUG_IFADDR_DUMP | |
39 | #define PIM_DEBUG_IFADDR_DUMP | |
40 | ||
36b5b98f | 41 | struct zclient *zclient; |
38f4935a | 42 | |
12e41d03 | 43 | |
12e41d03 | 44 | /* Router-id update message from zebra. */ |
121f9dee | 45 | static int pim_router_id_update_zebra(ZAPI_CALLBACK_ARGS) |
12e41d03 | 46 | { |
d62a17ae | 47 | struct prefix router_id; |
12e41d03 | 48 | |
d62a17ae | 49 | zebra_router_id_update_read(zclient->ibuf, &router_id); |
12e41d03 | 50 | |
d62a17ae | 51 | return 0; |
12e41d03 DL |
52 | } |
53 | ||
121f9dee | 54 | static int pim_zebra_interface_vrf_update(ZAPI_CALLBACK_ARGS) |
ee568318 DS |
55 | { |
56 | struct interface *ifp; | |
57 | vrf_id_t new_vrf_id; | |
58 | ||
59 | ifp = zebra_interface_vrf_update_read(zclient->ibuf, vrf_id, | |
60 | &new_vrf_id); | |
61 | if (!ifp) | |
62 | return 0; | |
63 | ||
64 | if (PIM_DEBUG_ZEBRA) | |
15569c58 DA |
65 | zlog_debug("%s: %s updating from %u to %u", __func__, ifp->name, |
66 | vrf_id, new_vrf_id); | |
ee568318 | 67 | |
a36898e7 | 68 | if_update_to_new_vrf(ifp, new_vrf_id); |
ee568318 DS |
69 | |
70 | return 0; | |
71 | } | |
72 | ||
12e41d03 DL |
73 | #ifdef PIM_DEBUG_IFADDR_DUMP |
74 | static void dump_if_address(struct interface *ifp) | |
75 | { | |
d62a17ae | 76 | struct connected *ifc; |
77 | struct listnode *node; | |
78 | ||
5e81f5dd DS |
79 | zlog_debug("%s %s: interface %s addresses:", __FILE__, __func__, |
80 | ifp->name); | |
d62a17ae | 81 | |
82 | for (ALL_LIST_ELEMENTS_RO(ifp->connected, node, ifc)) { | |
83 | struct prefix *p = ifc->address; | |
84 | ||
85 | if (p->family != AF_INET) | |
86 | continue; | |
87 | ||
ee2bbf7c MS |
88 | zlog_debug("%s %s: interface %s address %pI4 %s", __FILE__, |
89 | __func__, ifp->name, &p->u.prefix4, | |
d62a17ae | 90 | CHECK_FLAG(ifc->flags, ZEBRA_IFA_SECONDARY) |
91 | ? "secondary" | |
92 | : "primary"); | |
93 | } | |
12e41d03 DL |
94 | } |
95 | #endif | |
96 | ||
121f9dee | 97 | static int pim_zebra_if_address_add(ZAPI_CALLBACK_ARGS) |
12e41d03 | 98 | { |
d62a17ae | 99 | struct connected *c; |
100 | struct prefix *p; | |
101 | struct pim_interface *pim_ifp; | |
102 | ||
103 | /* | |
104 | zebra api notifies address adds/dels events by using the same call | |
105 | interface_add_read below, see comments in lib/zclient.c | |
106 | ||
107 | zebra_interface_address_read(ZEBRA_INTERFACE_ADDRESS_ADD, ...) | |
108 | will add address to interface list by calling | |
109 | connected_add_by_prefix() | |
110 | */ | |
121f9dee | 111 | c = zebra_interface_address_read(cmd, zclient->ibuf, vrf_id); |
d62a17ae | 112 | if (!c) |
113 | return 0; | |
114 | ||
115 | pim_ifp = c->ifp->info; | |
116 | p = c->address; | |
117 | ||
118 | if (PIM_DEBUG_ZEBRA) { | |
2dbe669b DA |
119 | zlog_debug("%s: %s(%u) connected IP address %pFX flags %u %s", |
120 | __func__, c->ifp->name, vrf_id, p, c->flags, | |
996c9314 LB |
121 | CHECK_FLAG(c->flags, ZEBRA_IFA_SECONDARY) |
122 | ? "secondary" | |
123 | : "primary"); | |
d62a17ae | 124 | |
12e41d03 | 125 | #ifdef PIM_DEBUG_IFADDR_DUMP |
d62a17ae | 126 | dump_if_address(c->ifp); |
12e41d03 | 127 | #endif |
d62a17ae | 128 | } |
12e41d03 | 129 | |
94120cb2 | 130 | #if PIM_IPV == 4 |
034db86b DL |
131 | if (p->family != PIM_AF) |
132 | SET_FLAG(c->flags, ZEBRA_IFA_SECONDARY); | |
133 | else if (!CHECK_FLAG(c->flags, ZEBRA_IFA_SECONDARY)) { | |
134 | /* trying to add primary address? */ | |
135 | pim_addr primary_addr = pim_find_primary_addr(c->ifp); | |
136 | pim_addr addr = pim_addr_from_prefix(p); | |
137 | ||
138 | if (pim_addr_cmp(primary_addr, addr)) { | |
2dbe669b | 139 | if (PIM_DEBUG_ZEBRA) |
d62a17ae | 140 | zlog_warn( |
2dbe669b DA |
141 | "%s: %s : forcing secondary flag on %pFX", |
142 | __func__, c->ifp->name, p); | |
d62a17ae | 143 | SET_FLAG(c->flags, ZEBRA_IFA_SECONDARY); |
144 | } | |
145 | } | |
97feb13f DL |
146 | #else /* PIM_IPV != 4 */ |
147 | if (p->family != PIM_AF) | |
148 | return 0; | |
149 | #endif | |
12e41d03 | 150 | |
d62a17ae | 151 | pim_if_addr_add(c); |
26bb1fd5 | 152 | if (pim_ifp) { |
94120cb2 DL |
153 | struct pim_instance *pim; |
154 | ||
26bb1fd5 | 155 | pim = pim_get_pim_instance(vrf_id); |
e2067d59 | 156 | if (!pim) { |
157 | if (PIM_DEBUG_ZEBRA) | |
158 | zlog_debug("%s: Unable to find pim instance", | |
159 | __func__); | |
160 | return 0; | |
161 | } | |
162 | ||
26bb1fd5 DS |
163 | pim_ifp->pim = pim; |
164 | ||
d62a17ae | 165 | pim_rp_check_on_if_add(pim_ifp); |
26bb1fd5 | 166 | } |
12e41d03 | 167 | |
d62a17ae | 168 | if (if_is_loopback(c->ifp)) { |
4bb0e8f0 | 169 | struct vrf *vrf = vrf_lookup_by_id(vrf_id); |
d62a17ae | 170 | struct interface *ifp; |
d8424057 | 171 | |
451fda4f | 172 | FOR_ALL_INTERFACES (vrf, ifp) { |
d62a17ae | 173 | if (!if_is_loopback(ifp) && if_is_operative(ifp)) |
174 | pim_if_addr_add_all(ifp); | |
175 | } | |
176 | } | |
d62a17ae | 177 | return 0; |
12e41d03 DL |
178 | } |
179 | ||
121f9dee | 180 | static int pim_zebra_if_address_del(ZAPI_CALLBACK_ARGS) |
12e41d03 | 181 | { |
d62a17ae | 182 | struct connected *c; |
183 | struct prefix *p; | |
fec883d9 | 184 | struct vrf *vrf = vrf_lookup_by_id(vrf_id); |
819f099b DS |
185 | |
186 | if (!vrf) | |
187 | return 0; | |
d62a17ae | 188 | |
189 | /* | |
190 | zebra api notifies address adds/dels events by using the same call | |
191 | interface_add_read below, see comments in lib/zclient.c | |
192 | ||
193 | zebra_interface_address_read(ZEBRA_INTERFACE_ADDRESS_DELETE, ...) | |
194 | will remove address from interface list by calling | |
195 | connected_delete_by_prefix() | |
196 | */ | |
121f9dee | 197 | c = zebra_interface_address_read(cmd, zclient->ibuf, vrf_id); |
d62a17ae | 198 | if (!c) |
199 | return 0; | |
200 | ||
201 | p = c->address; | |
6233f087 | 202 | |
94120cb2 DL |
203 | if (PIM_DEBUG_ZEBRA) { |
204 | zlog_debug( | |
205 | "%s: %s(%u) disconnected IP address %pFX flags %u %s", | |
206 | __func__, c->ifp->name, vrf_id, p, c->flags, | |
207 | CHECK_FLAG(c->flags, ZEBRA_IFA_SECONDARY) | |
208 | ? "secondary" | |
209 | : "primary"); | |
12e41d03 | 210 | #ifdef PIM_DEBUG_IFADDR_DUMP |
94120cb2 | 211 | dump_if_address(c->ifp); |
12e41d03 | 212 | #endif |
94120cb2 | 213 | } |
12e41d03 | 214 | |
97feb13f | 215 | if (p->family == PIM_AF) { |
94120cb2 | 216 | struct pim_instance *pim; |
12e41d03 | 217 | |
94120cb2 | 218 | pim = vrf->info; |
d62a17ae | 219 | pim_if_addr_del(c, 0); |
fec883d9 DS |
220 | pim_rp_setup(pim); |
221 | pim_i_am_rp_re_evaluate(pim); | |
d62a17ae | 222 | } |
6233f087 | 223 | |
721c0857 | 224 | connected_free(&c); |
d62a17ae | 225 | return 0; |
12e41d03 DL |
226 | } |
227 | ||
74389231 DS |
228 | void pim_zebra_update_all_interfaces(struct pim_instance *pim) |
229 | { | |
230 | struct interface *ifp; | |
231 | ||
232 | FOR_ALL_INTERFACES (pim->vrf, ifp) { | |
233 | struct pim_interface *pim_ifp = ifp->info; | |
234 | struct pim_iface_upstream_switch *us; | |
235 | struct listnode *node; | |
236 | ||
237 | if (!pim_ifp) | |
238 | continue; | |
239 | ||
240 | for (ALL_LIST_ELEMENTS_RO(pim_ifp->upstream_switch_list, node, | |
241 | us)) { | |
242 | struct pim_rpf rpf; | |
243 | ||
244 | rpf.source_nexthop.interface = ifp; | |
144035b7 | 245 | rpf.rpf_addr = us->address; |
74389231 DS |
246 | pim_joinprune_send(&rpf, us->us); |
247 | pim_jp_agg_clear_group(us->us); | |
248 | } | |
249 | } | |
250 | } | |
251 | ||
cc67ccf9 DS |
252 | void pim_zebra_upstream_rpf_changed(struct pim_instance *pim, |
253 | struct pim_upstream *up, | |
254 | struct pim_rpf *old) | |
255 | { | |
1250cb5d SP |
256 | if (old->source_nexthop.interface) { |
257 | struct pim_neighbor *nbr; | |
cc67ccf9 | 258 | |
144035b7 | 259 | nbr = pim_neighbor_find(old->source_nexthop.interface, |
689b9f10 SP |
260 | old->rpf_addr, true); |
261 | ||
1250cb5d | 262 | if (nbr) |
c5cdf069 | 263 | pim_jp_agg_remove_group(nbr->upstream_jp_agg, up, nbr); |
cc67ccf9 | 264 | |
cc67ccf9 | 265 | /* |
1250cb5d SP |
266 | * We have detected a case where we might need |
267 | * to rescan the inherited o_list so do it. | |
cc67ccf9 | 268 | */ |
1250cb5d SP |
269 | if (up->channel_oil->oil_inherited_rescan) { |
270 | pim_upstream_inherited_olist_decide(pim, up); | |
271 | up->channel_oil->oil_inherited_rescan = 0; | |
272 | } | |
cc67ccf9 | 273 | |
1250cb5d SP |
274 | if (up->join_state == PIM_UPSTREAM_JOINED) { |
275 | /* | |
276 | * If we come up real fast we can be here | |
277 | * where the mroute has not been installed | |
278 | * so install it. | |
279 | */ | |
280 | if (!up->channel_oil->installed) | |
69e3538c | 281 | pim_upstream_mroute_add(up->channel_oil, |
15569c58 | 282 | __func__); |
1250cb5d SP |
283 | |
284 | /* | |
285 | * RFC 4601: 4.5.7. Sending (S,G) | |
286 | * Join/Prune Messages | |
287 | * | |
288 | * Transitions from Joined State | |
289 | * | |
290 | * RPF'(S,G) changes not due to an Assert | |
291 | * | |
292 | * The upstream (S,G) state machine remains | |
293 | * in Joined state. Send Join(S,G) to the new | |
294 | * upstream neighbor, which is the new value | |
295 | * of RPF'(S,G). Send Prune(S,G) to the old | |
296 | * upstream neighbor, which is the old value | |
297 | * of RPF'(S,G). Set the Join Timer (JT) to | |
298 | * expire after t_periodic seconds. | |
299 | */ | |
300 | pim_jp_agg_switch_interface(old, &up->rpf, up); | |
301 | ||
302 | pim_upstream_join_timer_restart(up, old); | |
303 | } /* up->join_state == PIM_UPSTREAM_JOINED */ | |
304 | } | |
305 | ||
306 | else { | |
cc67ccf9 | 307 | /* |
1250cb5d SP |
308 | * We have detected a case where we might need |
309 | * to rescan the inherited o_list so do it. | |
cc67ccf9 | 310 | */ |
1250cb5d SP |
311 | if (up->channel_oil->oil_inherited_rescan) { |
312 | pim_upstream_inherited_olist_decide(pim, up); | |
313 | up->channel_oil->oil_inherited_rescan = 0; | |
314 | } | |
cc67ccf9 | 315 | |
db431af2 AK |
316 | if (up->join_state == PIM_UPSTREAM_JOINED) |
317 | pim_jp_agg_switch_interface(old, &up->rpf, up); | |
318 | ||
1250cb5d | 319 | if (!up->channel_oil->installed) |
15569c58 | 320 | pim_upstream_mroute_add(up->channel_oil, __func__); |
1250cb5d | 321 | } |
cc67ccf9 | 322 | |
1250cb5d SP |
323 | /* FIXME can join_desired actually be changed by pim_rpf_update() |
324 | * returning PIM_RPF_CHANGED ? | |
325 | */ | |
cc67ccf9 DS |
326 | pim_upstream_update_join_desired(pim, up); |
327 | } | |
328 | ||
94120cb2 | 329 | __attribute__((unused)) |
121f9dee | 330 | static int pim_zebra_vxlan_sg_proc(ZAPI_CALLBACK_ARGS) |
af7b561b AK |
331 | { |
332 | struct stream *s; | |
333 | struct pim_instance *pim; | |
6fff2cc6 DL |
334 | pim_sgaddr sg; |
335 | size_t prefixlen; | |
af7b561b AK |
336 | |
337 | pim = pim_get_pim_instance(vrf_id); | |
338 | if (!pim) | |
339 | return 0; | |
340 | ||
341 | s = zclient->ibuf; | |
342 | ||
6fff2cc6 | 343 | prefixlen = stream_getl(s); |
c631920c DL |
344 | stream_get(&sg.src, s, prefixlen); |
345 | stream_get(&sg.grp, s, prefixlen); | |
af7b561b | 346 | |
9bace5c2 DL |
347 | if (PIM_DEBUG_ZEBRA) |
348 | zlog_debug("%u:recv SG %s %pSG", vrf_id, | |
349 | (cmd == ZEBRA_VXLAN_SG_ADD) ? "add" : "del", &sg); | |
af7b561b | 350 | |
121f9dee | 351 | if (cmd == ZEBRA_VXLAN_SG_ADD) |
af7b561b AK |
352 | pim_vxlan_sg_add(pim, &sg); |
353 | else | |
354 | pim_vxlan_sg_del(pim, &sg); | |
355 | ||
356 | return 0; | |
357 | } | |
358 | ||
94120cb2 | 359 | __attribute__((unused)) |
ecbbc3a7 AK |
360 | static void pim_zebra_vxlan_replay(void) |
361 | { | |
362 | struct stream *s = NULL; | |
363 | ||
364 | /* Check socket. */ | |
365 | if (!zclient || zclient->sock < 0) | |
366 | return; | |
367 | ||
368 | s = zclient->obuf; | |
369 | stream_reset(s); | |
370 | ||
371 | zclient_create_header(s, ZEBRA_VXLAN_SG_REPLAY, VRF_DEFAULT); | |
372 | stream_putw_at(s, 0, stream_get_endp(s)); | |
373 | ||
374 | zclient_send_message(zclient); | |
375 | } | |
376 | ||
da11e325 | 377 | void pim_scan_oil(struct pim_instance *pim) |
8a67a996 | 378 | { |
d62a17ae | 379 | struct channel_oil *c_oil; |
d62a17ae | 380 | |
bfc92019 DS |
381 | pim->scan_oil_last = pim_time_monotonic_sec(); |
382 | ++pim->scan_oil_events; | |
d62a17ae | 383 | |
7315ecda | 384 | frr_each (rb_pim_oil, &pim->channel_oil_head, c_oil) |
7984af18 | 385 | pim_upstream_mroute_iif_update(c_oil, __func__); |
12e41d03 DL |
386 | } |
387 | ||
e6685141 | 388 | static void on_rpf_cache_refresh(struct event *t) |
12e41d03 | 389 | { |
da11e325 DS |
390 | struct pim_instance *pim = THREAD_ARG(t); |
391 | ||
d62a17ae | 392 | /* update kernel multicast forwarding cache (MFC) */ |
da11e325 | 393 | pim_scan_oil(pim); |
12e41d03 | 394 | |
bfc92019 DS |
395 | pim->rpf_cache_refresh_last = pim_time_monotonic_sec(); |
396 | ++pim->rpf_cache_refresh_events; | |
12e41d03 | 397 | |
d62a17ae | 398 | // It is called as part of pim_neighbor_add |
399 | // pim_rp_setup (); | |
12e41d03 DL |
400 | } |
401 | ||
da11e325 | 402 | void sched_rpf_cache_refresh(struct pim_instance *pim) |
12e41d03 | 403 | { |
bfc92019 | 404 | ++pim->rpf_cache_refresh_requests; |
12e41d03 | 405 | |
bfc92019 | 406 | pim_rpf_set_refresh_time(pim); |
e71bf8f7 | 407 | |
da11e325 | 408 | if (pim->rpf_cache_refresher) { |
d62a17ae | 409 | /* Refresh timer is already running */ |
410 | return; | |
411 | } | |
12e41d03 | 412 | |
d62a17ae | 413 | /* Start refresh timer */ |
12e41d03 | 414 | |
d62a17ae | 415 | if (PIM_DEBUG_ZEBRA) { |
15569c58 | 416 | zlog_debug("%s: triggering %ld msec timer", __func__, |
da03883e | 417 | router->rpf_cache_refresh_delay_msec); |
d62a17ae | 418 | } |
12e41d03 | 419 | |
36417fcc | 420 | thread_add_timer_msec(router->master, on_rpf_cache_refresh, pim, |
da03883e | 421 | router->rpf_cache_refresh_delay_msec, |
da11e325 | 422 | &pim->rpf_cache_refresher); |
12e41d03 DL |
423 | } |
424 | ||
d62a17ae | 425 | static void pim_zebra_connected(struct zclient *zclient) |
48e8451b | 426 | { |
94120cb2 | 427 | #if PIM_IPV == 4 |
d62a17ae | 428 | /* Send the client registration */ |
0945d5ed | 429 | bfd_client_sendmsg(zclient, ZEBRA_BFD_CLIENT_REGISTER, router->vrf_id); |
94120cb2 | 430 | #endif |
ba4eb1bc | 431 | |
4dfe9ad2 | 432 | zclient_send_reg_requests(zclient, router->vrf_id); |
ecbbc3a7 | 433 | |
94120cb2 | 434 | #if PIM_IPV == 4 |
ecbbc3a7 AK |
435 | /* request for VxLAN BUM group addresses */ |
436 | pim_zebra_vxlan_replay(); | |
94120cb2 | 437 | #endif |
48e8451b | 438 | } |
8711a53d | 439 | |
ac567a6f DS |
440 | static void pim_zebra_capabilities(struct zclient_capabilities *cap) |
441 | { | |
05ca004b | 442 | router->mlag_role = cap->role; |
75700af6 | 443 | router->multipath = cap->ecmp; |
ac567a6f DS |
444 | } |
445 | ||
a243d1db | 446 | static zclient_handler *const pim_handlers[] = { |
a243d1db DL |
447 | [ZEBRA_INTERFACE_ADDRESS_ADD] = pim_zebra_if_address_add, |
448 | [ZEBRA_INTERFACE_ADDRESS_DELETE] = pim_zebra_if_address_del, | |
0455229c DL |
449 | |
450 | [ZEBRA_NEXTHOP_UPDATE] = pim_parse_nexthop_update, | |
94120cb2 | 451 | [ZEBRA_ROUTER_ID_UPDATE] = pim_router_id_update_zebra, |
a243d1db | 452 | [ZEBRA_INTERFACE_VRF_UPDATE] = pim_zebra_interface_vrf_update, |
a243d1db | 453 | |
97feb13f | 454 | #if PIM_IPV == 4 |
a243d1db DL |
455 | [ZEBRA_VXLAN_SG_ADD] = pim_zebra_vxlan_sg_proc, |
456 | [ZEBRA_VXLAN_SG_DEL] = pim_zebra_vxlan_sg_proc, | |
457 | ||
458 | [ZEBRA_MLAG_PROCESS_UP] = pim_zebra_mlag_process_up, | |
459 | [ZEBRA_MLAG_PROCESS_DOWN] = pim_zebra_mlag_process_down, | |
460 | [ZEBRA_MLAG_FORWARD_MSG] = pim_zebra_mlag_handle_msg, | |
94120cb2 | 461 | #endif |
a243d1db DL |
462 | }; |
463 | ||
eb05883f | 464 | void pim_zebra_init(void) |
12e41d03 | 465 | { |
d62a17ae | 466 | /* Socket for receiving updates from Zebra daemon */ |
a243d1db DL |
467 | zclient = zclient_new(router->master, &zclient_options_default, |
468 | pim_handlers, array_size(pim_handlers)); | |
d62a17ae | 469 | |
ac567a6f | 470 | zclient->zebra_capabilities = pim_zebra_capabilities; |
d62a17ae | 471 | zclient->zebra_connected = pim_zebra_connected; |
d62a17ae | 472 | |
342213ea | 473 | zclient_init(zclient, ZEBRA_ROUTE_PIM, 0, &pimd_privs); |
d62a17ae | 474 | if (PIM_DEBUG_PIM_TRACE) { |
15569c58 | 475 | zlog_notice("%s: zclient socket initialized", __func__); |
d62a17ae | 476 | } |
477 | ||
478 | zclient_lookup_new(); | |
12e41d03 DL |
479 | } |
480 | ||
12e41d03 DL |
481 | void pim_forward_start(struct pim_ifchannel *ch) |
482 | { | |
d62a17ae | 483 | struct pim_upstream *up = ch->upstream; |
9443810e | 484 | uint32_t mask = 0; |
d62a17ae | 485 | |
8e8be741 | 486 | if (PIM_DEBUG_PIM_TRACE) |
41490e0e | 487 | zlog_debug("%s: (S,G)=%pSG oif=%s (%pPA)", __func__, &ch->sg, |
8e8be741 | 488 | ch->interface->name, &up->upstream_addr); |
d62a17ae | 489 | |
9443810e | 490 | if (PIM_IF_FLAG_TEST_PROTO_IGMP(ch->flags)) |
80a82b56 | 491 | mask = PIM_OIF_FLAG_PROTO_GM; |
d62a17ae | 492 | |
9443810e SP |
493 | if (PIM_IF_FLAG_TEST_PROTO_PIM(ch->flags)) |
494 | mask |= PIM_OIF_FLAG_PROTO_PIM; | |
495 | ||
1b249e70 AK |
496 | pim_channel_add_oif(up->channel_oil, ch->interface, |
497 | mask, __func__); | |
12e41d03 DL |
498 | } |
499 | ||
86696f7b | 500 | void pim_forward_stop(struct pim_ifchannel *ch) |
12e41d03 | 501 | { |
d62a17ae | 502 | struct pim_upstream *up = ch->upstream; |
12e41d03 | 503 | |
d62a17ae | 504 | if (PIM_DEBUG_PIM_TRACE) { |
86696f7b | 505 | zlog_debug("%s: (S,G)=%s oif=%s installed: %d", |
15569c58 | 506 | __func__, ch->sg_str, ch->interface->name, |
86696f7b | 507 | up->channel_oil->installed); |
d62a17ae | 508 | } |
12e41d03 | 509 | |
2164ed5d DS |
510 | /* |
511 | * If a channel is being removed, check to see if we still need | |
512 | * to inherit the interface. If so make sure it is added in | |
513 | */ | |
514 | if (pim_upstream_evaluate_join_desired_interface(up, ch, ch->parent)) | |
515 | pim_channel_add_oif(up->channel_oil, ch->interface, | |
1b249e70 | 516 | PIM_OIF_FLAG_PROTO_PIM, __func__); |
2164ed5d DS |
517 | else |
518 | pim_channel_del_oif(up->channel_oil, ch->interface, | |
1b249e70 | 519 | PIM_OIF_FLAG_PROTO_PIM, __func__); |
12e41d03 | 520 | } |
8799b66b | 521 | |
d62a17ae | 522 | void pim_zebra_zclient_update(struct vty *vty) |
8799b66b | 523 | { |
d62a17ae | 524 | vty_out(vty, "Zclient update socket: "); |
525 | ||
526 | if (zclient) { | |
527 | vty_out(vty, "%d failures=%d\n", zclient->sock, zclient->fail); | |
528 | } else { | |
529 | vty_out(vty, "<null zclient>\n"); | |
530 | } | |
8799b66b | 531 | } |
1bc98276 | 532 | |
d62a17ae | 533 | struct zclient *pim_zebra_zclient_get(void) |
1bc98276 | 534 | { |
d62a17ae | 535 | if (zclient) |
536 | return zclient; | |
537 | else | |
538 | return NULL; | |
1bc98276 | 539 | } |
ddbf3e60 DS |
540 | |
541 | void pim_zebra_interface_set_master(struct interface *vrf, | |
542 | struct interface *ifp) | |
543 | { | |
544 | zclient_interface_set_master(zclient, vrf, ifp); | |
545 | } |