Convert to if_foreach_llmaddr() KPI.

Reviewed by:	gallatin
This commit is contained in:
glebius 2019-10-14 20:18:36 +00:00
parent cad5513a14
commit c69fd8a5cd

View File

@ -1091,12 +1091,35 @@ mxge_change_promisc(mxge_softc_t *sc, int promisc)
}
}
struct mxge_add_maddr_ctx {
mxge_softc_t *sc;
int error;
};
static u_int
mxge_add_maddr(void *arg, struct sockaddr_dl *sdl, u_int cnt)
{
struct mxge_add_maddr_ctx *ctx = arg;
mxge_cmd_t cmd;
if (ctx->error != 0)
return (0);
bcopy(LLADDR(sdl), &cmd.data0, 4);
bcopy(LLADDR(sdl) + 4, &cmd.data1, 2);
cmd.data0 = htonl(cmd.data0);
cmd.data1 = htonl(cmd.data1);
ctx->error = mxge_send_cmd(ctx->sc, MXGEFW_JOIN_MULTICAST_GROUP, &cmd);
return (1);
}
static void
mxge_set_multicast_list(mxge_softc_t *sc)
{
mxge_cmd_t cmd;
struct ifmultiaddr *ifma;
struct mxge_add_maddr_ctx ctx;
struct ifnet *ifp = sc->ifp;
mxge_cmd_t cmd;
int err;
/* This firmware is known to not support multicast */
@ -1129,28 +1152,16 @@ mxge_set_multicast_list(mxge_softc_t *sc)
}
/* Walk the multicast list, and add each address */
if_maddr_rlock(ifp);
CK_STAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) {
if (ifma->ifma_addr->sa_family != AF_LINK)
continue;
bcopy(LLADDR((struct sockaddr_dl *)ifma->ifma_addr),
&cmd.data0, 4);
bcopy(LLADDR((struct sockaddr_dl *)ifma->ifma_addr) + 4,
&cmd.data1, 2);
cmd.data0 = htonl(cmd.data0);
cmd.data1 = htonl(cmd.data1);
err = mxge_send_cmd(sc, MXGEFW_JOIN_MULTICAST_GROUP, &cmd);
if (err != 0) {
device_printf(sc->dev, "Failed "
"MXGEFW_JOIN_MULTICAST_GROUP, error status:"
"%d\t", err);
/* abort, leaving multicast filtering off */
if_maddr_runlock(ifp);
return;
}
ctx.sc = sc;
ctx.error = 0;
if_foreach_llmaddr(ifp, mxge_add_maddr, &ctx);
if (ctx.error != 0) {
device_printf(sc->dev, "Failed MXGEFW_JOIN_MULTICAST_GROUP, "
"error status:" "%d\t", ctx.error);
/* abort, leaving multicast filtering off */
return;
}
if_maddr_runlock(ifp);
/* Enable multicast filtering */
err = mxge_send_cmd(sc, MXGEFW_DISABLE_ALLMULTI, &cmd);
if (err != 0) {