Commit 77f0cae1 authored by David S. Miller's avatar David S. Miller

Merge branch 'bridge-m,cast-cleanups'

Nikolay Aleksandrov says:

====================
net: bridge: mcast: simplify allow/block EHT code

The set does two minor cleanups of the EHT allow/block handling code:
patch 01 removes code which is unreachable (it was used in initial EHT
versions, but isn't anymore) and prepares the allow/block functions to be
factored out. Patch 02 factors out common allow/block handling code.
There are no functional changes.

v2: send patch 02 and the proper version of both patches
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 5a30833b e09cf582
...@@ -498,11 +498,13 @@ static void br_multicast_del_eht_host(struct net_bridge_port_group *pg, ...@@ -498,11 +498,13 @@ static void br_multicast_del_eht_host(struct net_bridge_port_group *pg,
&set_h->h_addr); &set_h->h_addr);
} }
static void __eht_allow_incl(struct net_bridge_port_group *pg, /* create new set entries from reports */
union net_bridge_eht_addr *h_addr, static void __eht_create_set_entries(struct net_bridge_port_group *pg,
void *srcs, union net_bridge_eht_addr *h_addr,
u32 nsrcs, void *srcs,
size_t addr_size) u32 nsrcs,
size_t addr_size,
int filter_mode)
{ {
union net_bridge_eht_addr eht_src_addr; union net_bridge_eht_addr eht_src_addr;
u32 src_idx; u32 src_idx;
...@@ -511,72 +513,17 @@ static void __eht_allow_incl(struct net_bridge_port_group *pg, ...@@ -511,72 +513,17 @@ static void __eht_allow_incl(struct net_bridge_port_group *pg,
for (src_idx = 0; src_idx < nsrcs; src_idx++) { for (src_idx = 0; src_idx < nsrcs; src_idx++) {
memcpy(&eht_src_addr, srcs + (src_idx * addr_size), addr_size); memcpy(&eht_src_addr, srcs + (src_idx * addr_size), addr_size);
br_multicast_create_eht_set_entry(pg, &eht_src_addr, h_addr, br_multicast_create_eht_set_entry(pg, &eht_src_addr, h_addr,
MCAST_INCLUDE, filter_mode,
false); false);
} }
} }
static bool __eht_allow_excl(struct net_bridge_port_group *pg, /* delete existing set entries and their (S,G) entries if they were the last */
union net_bridge_eht_addr *h_addr, static bool __eht_del_set_entries(struct net_bridge_port_group *pg,
void *srcs, union net_bridge_eht_addr *h_addr,
u32 nsrcs, void *srcs,
size_t addr_size) u32 nsrcs,
{ size_t addr_size)
bool changed = false, host_excl = false;
union net_bridge_eht_addr eht_src_addr;
struct net_bridge_group_src *src_ent;
struct br_ip src_ip;
u32 src_idx;
host_excl = !!(br_multicast_eht_host_filter_mode(pg, h_addr) == MCAST_EXCLUDE);
memset(&eht_src_addr, 0, sizeof(eht_src_addr));
for (src_idx = 0; src_idx < nsrcs; src_idx++) {
memcpy(&eht_src_addr, srcs + (src_idx * addr_size), addr_size);
if (!host_excl) {
br_multicast_create_eht_set_entry(pg, &eht_src_addr, h_addr,
MCAST_INCLUDE,
false);
} else {
if (!br_multicast_del_eht_set_entry(pg, &eht_src_addr,
h_addr))
continue;
memcpy(&src_ip, srcs + (src_idx * addr_size), addr_size);
src_ent = br_multicast_find_group_src(pg, &src_ip);
if (!src_ent)
continue;
br_multicast_del_group_src(src_ent, true);
changed = true;
}
}
return changed;
}
static bool br_multicast_eht_allow(struct net_bridge_port_group *pg,
union net_bridge_eht_addr *h_addr,
void *srcs,
u32 nsrcs,
size_t addr_size)
{
bool changed = false;
switch (br_multicast_eht_host_filter_mode(pg, h_addr)) {
case MCAST_INCLUDE:
__eht_allow_incl(pg, h_addr, srcs, nsrcs, addr_size);
break;
case MCAST_EXCLUDE:
changed = __eht_allow_excl(pg, h_addr, srcs, nsrcs, addr_size);
break;
}
return changed;
}
static bool __eht_block_incl(struct net_bridge_port_group *pg,
union net_bridge_eht_addr *h_addr,
void *srcs,
u32 nsrcs,
size_t addr_size)
{ {
union net_bridge_eht_addr eht_src_addr; union net_bridge_eht_addr eht_src_addr;
struct net_bridge_group_src *src_ent; struct net_bridge_group_src *src_ent;
...@@ -602,39 +549,23 @@ static bool __eht_block_incl(struct net_bridge_port_group *pg, ...@@ -602,39 +549,23 @@ static bool __eht_block_incl(struct net_bridge_port_group *pg,
return changed; return changed;
} }
static bool __eht_block_excl(struct net_bridge_port_group *pg, static bool br_multicast_eht_allow(struct net_bridge_port_group *pg,
union net_bridge_eht_addr *h_addr, union net_bridge_eht_addr *h_addr,
void *srcs, void *srcs,
u32 nsrcs, u32 nsrcs,
size_t addr_size) size_t addr_size)
{ {
bool changed = false, host_excl = false; bool changed = false;
union net_bridge_eht_addr eht_src_addr;
struct net_bridge_group_src *src_ent;
struct br_ip src_ip;
u32 src_idx;
host_excl = !!(br_multicast_eht_host_filter_mode(pg, h_addr) == MCAST_EXCLUDE); switch (br_multicast_eht_host_filter_mode(pg, h_addr)) {
memset(&eht_src_addr, 0, sizeof(eht_src_addr)); case MCAST_INCLUDE:
memset(&src_ip, 0, sizeof(src_ip)); __eht_create_set_entries(pg, h_addr, srcs, nsrcs, addr_size,
src_ip.proto = pg->key.addr.proto; MCAST_INCLUDE);
for (src_idx = 0; src_idx < nsrcs; src_idx++) { break;
memcpy(&eht_src_addr, srcs + (src_idx * addr_size), addr_size); case MCAST_EXCLUDE:
if (host_excl) { changed = __eht_del_set_entries(pg, h_addr, srcs, nsrcs,
br_multicast_create_eht_set_entry(pg, &eht_src_addr, h_addr, addr_size);
MCAST_EXCLUDE, break;
false);
} else {
if (!br_multicast_del_eht_set_entry(pg, &eht_src_addr,
h_addr))
continue;
memcpy(&src_ip, srcs + (src_idx * addr_size), addr_size);
src_ent = br_multicast_find_group_src(pg, &src_ip);
if (!src_ent)
continue;
br_multicast_del_group_src(src_ent, true);
changed = true;
}
} }
return changed; return changed;
...@@ -650,10 +581,12 @@ static bool br_multicast_eht_block(struct net_bridge_port_group *pg, ...@@ -650,10 +581,12 @@ static bool br_multicast_eht_block(struct net_bridge_port_group *pg,
switch (br_multicast_eht_host_filter_mode(pg, h_addr)) { switch (br_multicast_eht_host_filter_mode(pg, h_addr)) {
case MCAST_INCLUDE: case MCAST_INCLUDE:
changed = __eht_block_incl(pg, h_addr, srcs, nsrcs, addr_size); changed = __eht_del_set_entries(pg, h_addr, srcs, nsrcs,
addr_size);
break; break;
case MCAST_EXCLUDE: case MCAST_EXCLUDE:
changed = __eht_block_excl(pg, h_addr, srcs, nsrcs, addr_size); __eht_create_set_entries(pg, h_addr, srcs, nsrcs, addr_size,
MCAST_EXCLUDE);
break; break;
} }
...@@ -671,7 +604,6 @@ static bool __eht_inc_exc(struct net_bridge_port_group *pg, ...@@ -671,7 +604,6 @@ static bool __eht_inc_exc(struct net_bridge_port_group *pg,
{ {
bool changed = false, flush_entries = to_report; bool changed = false, flush_entries = to_report;
union net_bridge_eht_addr eht_src_addr; union net_bridge_eht_addr eht_src_addr;
u32 src_idx;
if (br_multicast_eht_host_filter_mode(pg, h_addr) != filter_mode) if (br_multicast_eht_host_filter_mode(pg, h_addr) != filter_mode)
flush_entries = true; flush_entries = true;
...@@ -680,11 +612,8 @@ static bool __eht_inc_exc(struct net_bridge_port_group *pg, ...@@ -680,11 +612,8 @@ static bool __eht_inc_exc(struct net_bridge_port_group *pg,
/* if we're changing mode del host and its entries */ /* if we're changing mode del host and its entries */
if (flush_entries) if (flush_entries)
br_multicast_del_eht_host(pg, h_addr); br_multicast_del_eht_host(pg, h_addr);
for (src_idx = 0; src_idx < nsrcs; src_idx++) { __eht_create_set_entries(pg, h_addr, srcs, nsrcs, addr_size,
memcpy(&eht_src_addr, srcs + (src_idx * addr_size), addr_size); filter_mode);
br_multicast_create_eht_set_entry(pg, &eht_src_addr, h_addr,
filter_mode, false);
}
/* we can be missing sets only if we've deleted some entries */ /* we can be missing sets only if we've deleted some entries */
if (flush_entries) { if (flush_entries) {
struct net_bridge *br = pg->key.port->br; struct net_bridge *br = pg->key.port->br;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment