This patch adds the functions needed to update the multicast snooping database based on the Report/Leave/Query received.
They are marked with OVS_UNUSED for now. Signed-off-by: Flavio Leitner <f...@redhat.com> --- ofproto/ofproto-dpif-xlate.c | 80 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c index e38be4c..427958c 100644 --- a/ofproto/ofproto-dpif-xlate.c +++ b/ofproto/ofproto-dpif-xlate.c @@ -1401,6 +1401,86 @@ update_learning_table(const struct xbridge *xbridge, } } +/* Updates multicast snooping table 'ms' given that a packet matching 'flow' + * was received on 'in_xbundle' in 'vlan' and is Report or Query. */ +OVS_UNUSED static void +update_mcast_snooping_table__(const struct xbridge *xbridge, + const struct flow *flow, + const struct mcast_ip *grp, int vlan, + struct xbundle *in_xbundle) +OVS_REQ_WRLOCK(xbridge->ms->rwlock) +{ + static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(60, 30); + + switch (ntohs(flow->igmp_type)) { + case IGMP_HOST_MEMBERSHIP_REPORT: + case IGMPV2_HOST_MEMBERSHIP_REPORT: + if (mcast_snooping_add_group(xbridge->ms, grp, vlan, + in_xbundle->ofbundle)) { + VLOG_DBG_RL(&rl, "bridge %s: multicast snooping learned that " + IP_FMT" is on port %s in VLAN %d", + xbridge->name, IP_ARGS(grp->u.ip4), + in_xbundle->name, vlan); + } + break; + case IGMP_HOST_LEAVE_MESSAGE: + if (mcast_snooping_leave_group(xbridge->ms, grp, vlan, + in_xbundle->ofbundle)) { + VLOG_DBG_RL(&rl, "bridge %s: multicast snooping leaving " + IP_FMT" is on port %s in VLAN %d", + xbridge->name, IP_ARGS(grp->u.ip4), + in_xbundle->name, vlan); + } + break; + case IGMP_HOST_MEMBERSHIP_QUERY: + if (flow->nw_src && mcast_snooping_add_mrouter(xbridge->ms, vlan, + in_xbundle->ofbundle)) { + VLOG_DBG_RL(&rl, "bridge %s: multicast snooping query from " + IP_FMT" is on port %s in VLAN %d", + xbridge->name, IP_ARGS(flow->nw_src), + in_xbundle->name, vlan); + } + break; + } +} + +/* Updates multicast snooping table 'ms' given that a packet matching 'flow' + * was received on 'in_xbundle' in 'vlan'. */ +OVS_UNUSED static void +update_mcast_snooping_table(const struct xbridge *xbridge, + const struct flow *flow, int vlan, + struct xbundle *in_xbundle) +{ + struct mcast_ip maddr; + struct xbundle *mcast_xbundle; + struct mcast_fport_bundle *fport; + + /* Don't learn the OFPP_NONE port. */ + if (in_xbundle == &ofpp_none_bundle) { + return; + } + + /* Don't learn from flood ports */ + mcast_xbundle = NULL; + ovs_rwlock_wrlock(&xbridge->ms->rwlock); + LIST_FOR_EACH(fport, list_node, &xbridge->ms->fport_list) { + mcast_xbundle = xbundle_lookup(fport->port.p); + if (mcast_xbundle == in_xbundle) { + break; + } + } + + if (mcast_xbundle && mcast_xbundle == in_xbundle) { + ovs_rwlock_unlock(&xbridge->ms->rwlock); + return; + } + + maddr.proto = flow->dl_type; + maddr.u.ip4 = flow->igmp_group.u.ip4; + update_mcast_snooping_table__(xbridge, flow, &maddr, vlan, in_xbundle); + ovs_rwlock_unlock(&xbridge->ms->rwlock); +} + /* send the packet to ports having the multicast group learned */ OVS_UNUSED static void xlate_normal_mcast_send_group(struct xlate_ctx *ctx, struct mcast_entry *mcast, -- 1.9.0 _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev