summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/mcast-snooping.c78
-rw-r--r--lib/mcast-snooping.h20
-rw-r--r--ofproto/ofproto-dpif-xlate.c8
-rw-r--r--ofproto/ofproto-dpif.c3
4 files changed, 52 insertions, 57 deletions
diff --git a/lib/mcast-snooping.c b/lib/mcast-snooping.c
index e84efc60f..87b6b0c6d 100644
--- a/lib/mcast-snooping.c
+++ b/lib/mcast-snooping.c
@@ -38,6 +38,8 @@
COVERAGE_DEFINE(mcast_snooping_learned);
COVERAGE_DEFINE(mcast_snooping_expired);
+static struct mcast_port_bundle *
+mcast_snooping_port_lookup(struct ovs_list *list, void *port);
static struct mcast_mrouter_bundle *
mcast_snooping_mrouter_lookup(struct mcast_snooping *ms, uint16_t vlan,
void *port)
@@ -382,7 +384,7 @@ mcast_snooping_add_group(struct mcast_snooping *ms, ovs_be32 ip4,
/* Avoid duplicate packets. */
if (mcast_snooping_mrouter_lookup(ms, vlan, port)
- || mcast_snooping_fport_lookup(ms, vlan, port)) {
+ || mcast_snooping_port_lookup(&ms->fport_list, port)) {
return false;
}
@@ -488,7 +490,7 @@ mcast_snooping_add_mrouter(struct mcast_snooping *ms, uint16_t vlan,
struct mcast_mrouter_bundle *mrouter;
/* Avoid duplicate packets. */
- if (mcast_snooping_fport_lookup(ms, vlan, port)) {
+ if (mcast_snooping_port_lookup(&ms->fport_list, port)) {
return false;
}
@@ -515,22 +517,22 @@ mcast_snooping_flush_mrouter(struct mcast_mrouter_bundle *mrouter)
free(mrouter);
}
-/* Flood ports. */
+/* Ports */
-static struct mcast_fport_bundle *
-mcast_fport_from_list_node(struct ovs_list *list)
+static struct mcast_port_bundle *
+mcast_port_from_list_node(struct ovs_list *list)
{
- return CONTAINER_OF(list, struct mcast_fport_bundle, fport_node);
+ return CONTAINER_OF(list, struct mcast_port_bundle, node);
}
/* If the list is not empty, stores the fport in '*f' and returns true.
* Otherwise, if the list is empty, stores NULL in '*f' and return false. */
static bool
-fport_get(const struct mcast_snooping *ms, struct mcast_fport_bundle **f)
- OVS_REQ_RDLOCK(ms->rwlock)
+mcast_snooping_port_get(const struct ovs_list *list,
+ struct mcast_port_bundle **f)
{
- if (!list_is_empty(&ms->fport_list)) {
- *f = mcast_fport_from_list_node(ms->fport_list.next);
+ if (!list_is_empty(list)) {
+ *f = mcast_port_from_list_node(list->next);
return true;
} else {
*f = NULL;
@@ -538,53 +540,51 @@ fport_get(const struct mcast_snooping *ms, struct mcast_fport_bundle **f)
}
}
-struct mcast_fport_bundle *
-mcast_snooping_fport_lookup(struct mcast_snooping *ms, uint16_t vlan,
- void *port)
- OVS_REQ_RDLOCK(ms->rwlock)
+static struct mcast_port_bundle *
+mcast_snooping_port_lookup(struct ovs_list *list, void *port)
{
- struct mcast_fport_bundle *fport;
+ struct mcast_port_bundle *pbundle;
- LIST_FOR_EACH (fport, fport_node, &ms->fport_list) {
- if (fport->vlan == vlan && fport->port == port) {
- return fport;
+ LIST_FOR_EACH (pbundle, node, list) {
+ if (pbundle->port == port) {
+ return pbundle;
}
}
return NULL;
}
static void
-mcast_snooping_add_fport(struct mcast_snooping *ms, uint16_t vlan, void *port)
- OVS_REQ_WRLOCK(ms->rwlock)
+mcast_snooping_add_port(struct ovs_list *list, void *port)
{
- struct mcast_fport_bundle *fport;
+ struct mcast_port_bundle *pbundle;
- fport = xmalloc(sizeof *fport);
- fport->vlan = vlan;
- fport->port = port;
- list_insert(&ms->fport_list, &fport->fport_node);
+ pbundle = xmalloc(sizeof *pbundle);
+ pbundle->port = port;
+ list_insert(list, &pbundle->node);
}
static void
-mcast_snooping_flush_fport(struct mcast_fport_bundle *fport)
+mcast_snooping_flush_port(struct mcast_port_bundle *pbundle)
{
- list_remove(&fport->fport_node);
- free(fport);
+ list_remove(&pbundle->node);
+ free(pbundle);
}
+
+/* Flood ports. */
void
-mcast_snooping_set_port_flood(struct mcast_snooping *ms, uint16_t vlan,
- void *port, bool flood)
+mcast_snooping_set_port_flood(struct mcast_snooping *ms, void *port,
+ bool flood)
OVS_REQ_WRLOCK(ms->rwlock)
{
- struct mcast_fport_bundle *fport;
+ struct mcast_port_bundle *fbundle;
- fport = mcast_snooping_fport_lookup(ms, vlan, port);
- if (flood && !fport) {
- mcast_snooping_add_fport(ms, vlan, port);
+ fbundle = mcast_snooping_port_lookup(&ms->fport_list, port);
+ if (flood && !fbundle) {
+ mcast_snooping_add_port(&ms->fport_list, port);
ms->need_revalidate = true;
- } else if (!flood && fport) {
- mcast_snooping_flush_fport(fport);
+ } else if (!flood && fbundle) {
+ mcast_snooping_flush_port(fbundle);
ms->need_revalidate = true;
}
}
@@ -628,7 +628,7 @@ mcast_snooping_flush__(struct mcast_snooping *ms)
{
struct mcast_group *grp;
struct mcast_mrouter_bundle *mrouter;
- struct mcast_fport_bundle *fport;
+ struct mcast_port_bundle *pbundle;
while (group_get_lru(ms, &grp)) {
mcast_snooping_flush_group(ms, grp);
@@ -640,8 +640,8 @@ mcast_snooping_flush__(struct mcast_snooping *ms)
mcast_snooping_flush_mrouter(mrouter);
}
- while (fport_get(ms, &fport)) {
- mcast_snooping_flush_fport(fport);
+ while (mcast_snooping_port_get(&ms->fport_list, &pbundle)) {
+ mcast_snooping_flush_port(pbundle);
}
}
diff --git a/lib/mcast-snooping.h b/lib/mcast-snooping.h
index d65148c5f..c23ed6be9 100644
--- a/lib/mcast-snooping.h
+++ b/lib/mcast-snooping.h
@@ -87,17 +87,17 @@ struct mcast_mrouter_bundle {
void *port OVS_GUARDED;
};
-/* The bundle to be flooded with multicast traffic.
+/* The bundle to send multicast traffic.
* Guarded by owning 'mcast_snooping''s rwlock */
-struct mcast_fport_bundle {
- /* Node in parent struct mcast_snooping fport_list. */
- struct ovs_list fport_node;
+struct mcast_port_bundle {
+ /* Node in parent struct mcast_snooping. */
+ struct ovs_list node;
/* VLAN tag. */
uint16_t vlan;
/* Learned port. */
- void *port OVS_GUARDED;
+ void *port;
};
/* Multicast snooping table. */
@@ -113,7 +113,7 @@ struct mcast_snooping {
* front, most recently used at the back. */
struct ovs_list mrouter_lru OVS_GUARDED;
- /* Contains struct mcast_fport_bundle to be flooded with multicast
+ /* Contains struct mcast_port_bundle to be flooded with multicast
* packets in no special order. */
struct ovs_list fport_list OVS_GUARDED;
@@ -160,8 +160,8 @@ void mcast_snooping_set_max_entries(struct mcast_snooping *ms,
bool
mcast_snooping_set_flood_unreg(struct mcast_snooping *ms, bool enable)
OVS_REQ_WRLOCK(ms->rwlock);
-void mcast_snooping_set_port_flood(struct mcast_snooping *ms, uint16_t vlan,
- void *port, bool flood)
+void mcast_snooping_set_port_flood(struct mcast_snooping *ms, void *port,
+ bool flood)
OVS_REQ_WRLOCK(ms->rwlock);
/* Lookup. */
@@ -180,10 +180,6 @@ bool mcast_snooping_leave_group(struct mcast_snooping *ms, ovs_be32 ip4,
bool mcast_snooping_add_mrouter(struct mcast_snooping *ms, uint16_t vlan,
void *port)
OVS_REQ_WRLOCK(ms->rwlock);
-struct mcast_fport_bundle *
-mcast_snooping_fport_lookup(struct mcast_snooping *ms, uint16_t vlan,
- void *port)
- OVS_REQ_RDLOCK(ms->rwlock);
bool mcast_snooping_is_query(ovs_be16 igmp_type);
bool mcast_snooping_is_membership(ovs_be16 igmp_type);
diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c
index 0786513f5..6f98da196 100644
--- a/ofproto/ofproto-dpif-xlate.c
+++ b/ofproto/ofproto-dpif-xlate.c
@@ -1982,7 +1982,7 @@ update_mcast_snooping_table(const struct xbridge *xbridge,
struct mcast_snooping *ms = xbridge->ms;
struct xlate_cfg *xcfg;
struct xbundle *mcast_xbundle;
- struct mcast_fport_bundle *fport;
+ struct mcast_port_bundle *fport;
/* Don't learn the OFPP_NONE port. */
if (in_xbundle == &ofpp_none_bundle) {
@@ -1993,7 +1993,7 @@ update_mcast_snooping_table(const struct xbridge *xbridge,
mcast_xbundle = NULL;
ovs_rwlock_wrlock(&ms->rwlock);
xcfg = ovsrcu_get(struct xlate_cfg *, &xcfgp);
- LIST_FOR_EACH(fport, fport_node, &ms->fport_list) {
+ LIST_FOR_EACH(fport, node, &ms->fport_list) {
mcast_xbundle = xbundle_lookup(xcfg, fport->port);
if (mcast_xbundle == in_xbundle) {
break;
@@ -2066,11 +2066,11 @@ xlate_normal_mcast_send_fports(struct xlate_ctx *ctx,
OVS_REQ_RDLOCK(ms->rwlock)
{
struct xlate_cfg *xcfg;
- struct mcast_fport_bundle *fport;
+ struct mcast_port_bundle *fport;
struct xbundle *mcast_xbundle;
xcfg = ovsrcu_get(struct xlate_cfg *, &xcfgp);
- LIST_FOR_EACH(fport, fport_node, &ms->fport_list) {
+ LIST_FOR_EACH(fport, node, &ms->fport_list) {
mcast_xbundle = xbundle_lookup(xcfg, fport->port);
if (mcast_xbundle && mcast_xbundle != in_xbundle) {
xlate_report(ctx, "forwarding to mcast flood port");
diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c
index b909fd9e0..18dbfe55e 100644
--- a/ofproto/ofproto-dpif.c
+++ b/ofproto/ofproto-dpif.c
@@ -3156,8 +3156,7 @@ set_mcast_snooping_port(struct ofproto *ofproto_, void *aux, bool flood)
if (ofproto->ms) {
ovs_rwlock_wrlock(&ofproto->ms->rwlock);
- mcast_snooping_set_port_flood(ofproto->ms, bundle->vlan, bundle,
- flood);
+ mcast_snooping_set_port_flood(ofproto->ms, bundle, flood);
ovs_rwlock_unlock(&ofproto->ms->rwlock);
}
return 0;