]>
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_iface.h"
26 #include "pim_upstream.h"
30 static struct channel_oil
*
31 tib_sg_oil_setup(struct pim_instance
*pim
, pim_sgaddr sg
, struct interface
*oif
)
33 struct pim_interface
*pim_oif
= oif
->info
;
34 int input_iface_vif_index
= 0;
36 struct prefix src
, grp
;
37 struct pim_nexthop nexthop
;
38 struct pim_upstream
*up
= NULL
;
40 if (!pim_rp_set_upstream_addr(pim
, &vif_source
, sg
.src
, sg
.grp
)) {
41 /* no PIM RP - create a dummy channel oil */
42 return pim_channel_oil_add(pim
, &sg
, __func__
);
45 pim_addr_to_prefix(&src
, vif_source
); // RP or Src addr
46 pim_addr_to_prefix(&grp
, sg
.grp
);
48 up
= pim_upstream_find(pim
, &sg
);
50 memcpy(&nexthop
, &up
->rpf
.source_nexthop
,
51 sizeof(struct pim_nexthop
));
52 pim_ecmp_nexthop_lookup(pim
, &nexthop
, &src
, &grp
, 0);
53 if (nexthop
.interface
)
54 input_iface_vif_index
= pim_if_find_vifindex_by_ifindex(
55 pim
, nexthop
.interface
->ifindex
);
57 input_iface_vif_index
=
58 pim_ecmp_fib_lookup_if_vif_index(pim
, &src
, &grp
);
61 zlog_debug("%s: NHT %pSG vif_source %pPAs vif_index:%d",
62 __func__
, &sg
, &vif_source
, input_iface_vif_index
);
64 if (input_iface_vif_index
< 1) {
65 if (PIM_DEBUG_IGMP_TRACE
)
67 "%s %s: could not find input interface for %pSG",
68 __FILE__
, __func__
, &sg
);
70 return pim_channel_oil_add(pim
, &sg
, __func__
);
74 * Protect IGMP against adding looped MFC entries created by both
75 * source and receiver attached to the same interface. See TODO T22.
76 * Block only when the intf is non DR DR must create upstream.
78 if ((input_iface_vif_index
== pim_oif
->mroute_vif_index
) &&
79 !(PIM_I_am_DR(pim_oif
))) {
80 /* ignore request for looped MFC entry */
81 if (PIM_DEBUG_IGMP_TRACE
)
83 "%s: ignoring request for looped MFC entry (S,G)=%pSG: oif=%s vif_index=%d",
84 __func__
, &sg
, oif
->name
,
85 input_iface_vif_index
);
90 return pim_channel_oil_add(pim
, &sg
, __func__
);
93 bool tib_sg_gm_join(struct pim_instance
*pim
, pim_sgaddr sg
,
94 struct interface
*oif
, struct channel_oil
**oilp
)
96 struct pim_interface
*pim_oif
= oif
->info
;
99 if (PIM_DEBUG_IGMP_TRACE
)
100 zlog_debug("%s: multicast not enabled on oif=%s?",
101 __func__
, oif
->name
);
106 *oilp
= tib_sg_oil_setup(pim
, sg
, oif
);
110 if (PIM_I_am_DR(pim_oif
) || PIM_I_am_DualActive(pim_oif
)) {
113 result
= pim_channel_add_oif(*oilp
, oif
,
114 PIM_OIF_FLAG_PROTO_IGMP
, __func__
);
116 if (PIM_DEBUG_MROUTE
)
117 zlog_warn("%s: add_oif() failed with return=%d",
122 if (PIM_DEBUG_IGMP_TRACE
)
124 "%s: %pSG was received on %s interface but we are not DR for that interface",
125 __func__
, &sg
, oif
->name
);
130 Feed IGMPv3-gathered local membership information into PIM
131 per-interface (S,G) state.
133 if (!pim_ifchannel_local_membership_add(oif
, &sg
, false /*is_vxlan*/)) {
134 if (PIM_DEBUG_MROUTE
)
136 "%s: Failure to add local membership for %pSG",
139 pim_channel_del_oif(*oilp
, oif
, PIM_OIF_FLAG_PROTO_IGMP
,
147 void tib_sg_gm_prune(struct pim_instance
*pim
, pim_sgaddr sg
,
148 struct interface
*oif
, struct channel_oil
**oilp
)
153 It appears that in certain circumstances that
154 igmp_source_forward_stop is called when IGMP forwarding
155 was not enabled in oif_flags for this outgoing interface.
156 Possibly because of multiple calls. When that happens, we
157 enter the below if statement and this function returns early
158 which in turn triggers the calling function to assert.
159 Making the call to pim_channel_del_oif and ignoring the return code
160 fixes the issue without ill effect, similar to
161 pim_forward_stop below.
163 result
= pim_channel_del_oif(*oilp
, oif
, PIM_OIF_FLAG_PROTO_IGMP
,
166 if (PIM_DEBUG_IGMP_TRACE
)
168 "%s: pim_channel_del_oif() failed with return=%d",
174 Feed IGMPv3-gathered local membership information into PIM
175 per-interface (S,G) state.
177 pim_ifchannel_local_membership_del(oif
, &sg
);