]>
git.proxmox.com Git - mirror_frr.git/blob - pimd/pim_tib.c
2 * TIB (Tree Information Base) - just PIM <> IGMP/MLD glue for now
3 * Copyright (C) 2022 David Lamparter for NetDEF, Inc.
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the Free
7 * Software Foundation; either version 2 of the License, or (at your option)
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
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
25 #include "pim_instance.h"
26 #include "pim_iface.h"
27 #include "pim_upstream.h"
31 static struct channel_oil
*
32 tib_sg_oil_setup(struct pim_instance
*pim
, pim_sgaddr sg
, struct interface
*oif
)
34 struct pim_interface
*pim_oif
= oif
->info
;
35 int input_iface_vif_index
= 0;
37 struct prefix src
, grp
;
38 struct pim_nexthop nexthop
;
39 struct pim_upstream
*up
= NULL
;
41 if (!pim_rp_set_upstream_addr(pim
, &vif_source
, sg
.src
, sg
.grp
)) {
42 /* no PIM RP - create a dummy channel oil */
43 return pim_channel_oil_add(pim
, &sg
, __func__
);
46 pim_addr_to_prefix(&src
, vif_source
); // RP or Src addr
47 pim_addr_to_prefix(&grp
, sg
.grp
);
49 up
= pim_upstream_find(pim
, &sg
);
51 memcpy(&nexthop
, &up
->rpf
.source_nexthop
,
52 sizeof(struct pim_nexthop
));
53 pim_ecmp_nexthop_lookup(pim
, &nexthop
, &src
, &grp
, 0);
54 if (nexthop
.interface
)
55 input_iface_vif_index
= pim_if_find_vifindex_by_ifindex(
56 pim
, nexthop
.interface
->ifindex
);
58 input_iface_vif_index
=
59 pim_ecmp_fib_lookup_if_vif_index(pim
, &src
, &grp
);
62 zlog_debug("%s: NHT %pSG vif_source %pPAs vif_index:%d",
63 __func__
, &sg
, &vif_source
, input_iface_vif_index
);
65 if (input_iface_vif_index
< 1) {
66 if (PIM_DEBUG_IGMP_TRACE
)
68 "%s %s: could not find input interface for %pSG",
69 __FILE__
, __func__
, &sg
);
71 return pim_channel_oil_add(pim
, &sg
, __func__
);
75 * Protect IGMP against adding looped MFC entries created by both
76 * source and receiver attached to the same interface. See TODO T22.
77 * Block only when the intf is non DR DR must create upstream.
79 if ((input_iface_vif_index
== pim_oif
->mroute_vif_index
) &&
80 !(PIM_I_am_DR(pim_oif
))) {
81 /* ignore request for looped MFC entry */
82 if (PIM_DEBUG_IGMP_TRACE
)
84 "%s: ignoring request for looped MFC entry (S,G)=%pSG: oif=%s vif_index=%d",
85 __func__
, &sg
, oif
->name
,
86 input_iface_vif_index
);
91 return pim_channel_oil_add(pim
, &sg
, __func__
);
94 bool tib_sg_gm_join(struct pim_instance
*pim
, pim_sgaddr sg
,
95 struct interface
*oif
, struct channel_oil
**oilp
)
97 struct pim_interface
*pim_oif
= oif
->info
;
100 if (PIM_DEBUG_IGMP_TRACE
)
101 zlog_debug("%s: multicast not enabled on oif=%s?",
102 __func__
, oif
->name
);
107 *oilp
= tib_sg_oil_setup(pim
, sg
, oif
);
111 if (PIM_I_am_DR(pim_oif
) || PIM_I_am_DualActive(pim_oif
)) {
114 result
= pim_channel_add_oif(*oilp
, oif
, PIM_OIF_FLAG_PROTO_GM
,
117 if (PIM_DEBUG_MROUTE
)
118 zlog_warn("%s: add_oif() failed with return=%d",
123 if (PIM_DEBUG_IGMP_TRACE
)
125 "%s: %pSG was received on %s interface but we are not DR for that interface",
126 __func__
, &sg
, oif
->name
);
131 Feed IGMPv3-gathered local membership information into PIM
132 per-interface (S,G) state.
134 if (!pim_ifchannel_local_membership_add(oif
, &sg
, false /*is_vxlan*/)) {
135 if (PIM_DEBUG_MROUTE
)
137 "%s: Failure to add local membership for %pSG",
140 pim_channel_del_oif(*oilp
, oif
, PIM_OIF_FLAG_PROTO_GM
,
148 void tib_sg_gm_prune(struct pim_instance
*pim
, pim_sgaddr sg
,
149 struct interface
*oif
, struct channel_oil
**oilp
)
154 It appears that in certain circumstances that
155 igmp_source_forward_stop is called when IGMP forwarding
156 was not enabled in oif_flags for this outgoing interface.
157 Possibly because of multiple calls. When that happens, we
158 enter the below if statement and this function returns early
159 which in turn triggers the calling function to assert.
160 Making the call to pim_channel_del_oif and ignoring the return code
161 fixes the issue without ill effect, similar to
162 pim_forward_stop below.
164 result
= pim_channel_del_oif(*oilp
, oif
, PIM_OIF_FLAG_PROTO_GM
,
167 if (PIM_DEBUG_IGMP_TRACE
)
169 "%s: pim_channel_del_oif() failed with return=%d",
175 Feed IGMPv3-gathered local membership information into PIM
176 per-interface (S,G) state.
178 pim_ifchannel_local_membership_del(oif
, &sg
);