Skip to content

Commit

Permalink
mcast-snooping: Remove typedef from mcast_group_proto.
Browse files Browse the repository at this point in the history
Typedefs are confusing and the coding style generally advises to not
use them.  Removing typedef until others start using it.

This typedef already got me while testing an OVN update to use OVS 3.3
as a submodule, since the variable was declared in a switch statement
and it wasn't clearly visible that there is a variable definition in
one of the cases and braces should be used.  Strangely some versions
of compilers do not require braces in this case, so OVN change works
locally, but not in CI.

Fixes: 077d0ba ("mcast-snooping: Store IGMP/MLD protocol version.")
Acked-by: Mohammad Heib <[email protected]>
Signed-off-by: Ilya Maximets <[email protected]>
  • Loading branch information
igsilya committed Jan 29, 2024
1 parent 96990ea commit 7b838a2
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions lib/mcast-snooping.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ mcast_snooping_flood_unreg(const struct mcast_snooping *ms)
}

char *
mcast_snooping_group_protocol_str(mcast_group_proto grp_proto)
mcast_snooping_group_protocol_str(enum mcast_group_proto grp_proto)
{
switch (grp_proto) {
case MCAST_GROUP_IGMPV1:
Expand Down Expand Up @@ -414,7 +414,7 @@ bool
mcast_snooping_add_group(struct mcast_snooping *ms,
const struct in6_addr *addr,
uint16_t vlan, void *port,
mcast_group_proto grp_proto)
enum mcast_group_proto grp_proto)
OVS_REQ_WRLOCK(ms->rwlock)
{
bool learned;
Expand Down Expand Up @@ -460,7 +460,7 @@ mcast_snooping_add_group(struct mcast_snooping *ms,
bool
mcast_snooping_add_group4(struct mcast_snooping *ms, ovs_be32 ip4,
uint16_t vlan, void *port,
mcast_group_proto grp_proto)
enum mcast_group_proto grp_proto)
OVS_REQ_WRLOCK(ms->rwlock)
{
struct in6_addr addr = in6_addr_mapped_ipv4(ip4);
Expand Down
12 changes: 6 additions & 6 deletions lib/mcast-snooping.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ struct mcast_snooping;
#define MCAST_MROUTER_PORT_IDLE_TIME 180

/* Multicast group protocol. */
typedef enum {
enum mcast_group_proto {
MCAST_GROUP_IGMPV1 = 0,
MCAST_GROUP_IGMPV2,
MCAST_GROUP_IGMPV3,
MCAST_GROUP_MLDV1,
MCAST_GROUP_MLDV2,
} mcast_group_proto;
};

/* Multicast group entry.
* Guarded by owning 'mcast_snooping''s rwlock. */
Expand All @@ -61,7 +61,7 @@ struct mcast_group {
uint16_t vlan;

/* Multicast group IPv6/IPv4 Protocol version IGMPv1,2,3 or MLDv1,2 */
mcast_group_proto protocol_version;
enum mcast_group_proto protocol_version;

/* Node in parent struct mcast_snooping group_lru. */
struct ovs_list group_node OVS_GUARDED;
Expand Down Expand Up @@ -198,11 +198,11 @@ mcast_snooping_lookup4(const struct mcast_snooping *ms, ovs_be32 ip4,
bool mcast_snooping_add_group(struct mcast_snooping *ms,
const struct in6_addr *addr,
uint16_t vlan, void *port,
mcast_group_proto grp_proto)
enum mcast_group_proto grp_proto)
OVS_REQ_WRLOCK(ms->rwlock);
bool mcast_snooping_add_group4(struct mcast_snooping *ms, ovs_be32 ip4,
uint16_t vlan, void *port,
mcast_group_proto grp_proto)
enum mcast_group_proto grp_proto)
OVS_REQ_WRLOCK(ms->rwlock);
int mcast_snooping_add_report(struct mcast_snooping *ms,
const struct dp_packet *p,
Expand All @@ -224,7 +224,7 @@ bool mcast_snooping_add_mrouter(struct mcast_snooping *ms, uint16_t vlan,
OVS_REQ_WRLOCK(ms->rwlock);
bool mcast_snooping_is_query(ovs_be16 igmp_type);
bool mcast_snooping_is_membership(ovs_be16 igmp_type);
char *mcast_snooping_group_protocol_str(mcast_group_proto grp_proto);
char *mcast_snooping_group_protocol_str(enum mcast_group_proto grp_proto);

/* Flush. */
void mcast_snooping_mdb_flush(struct mcast_snooping *ms);
Expand Down
2 changes: 1 addition & 1 deletion ofproto/ofproto-dpif-xlate.c
Original file line number Diff line number Diff line change
Expand Up @@ -2796,7 +2796,7 @@ update_mcast_snooping_table4__(const struct xlate_ctx *ctx,
OVS_REQ_WRLOCK(ms->rwlock)
{
const struct igmp_header *igmp;
mcast_group_proto grp_proto;
enum mcast_group_proto grp_proto;
int count;
size_t offset;
ovs_be32 ip4 = flow->igmp_group_ip4;
Expand Down

0 comments on commit 7b838a2

Please sign in to comment.