1/* $OpenBSD: if_trunk.c,v 1.30 2007/01/31 06:20:19 reyk Exp $ */ 2 3/* 4 * Copyright (c) 2005, 2006 Reyk Floeter <reyk@openbsd.org> 5 * Copyright (c) 2007 Andrew Thompson <thompsa@FreeBSD.org> 6 * 7 * Permission to use, copy, modify, and distribute this software for any 8 * purpose with or without fee is hereby granted, provided that the above --- 4 unchanged lines hidden (view full) --- 13 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 14 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 15 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 16 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 17 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 18 */ 19 20#include <sys/cdefs.h> |
21__FBSDID("$FreeBSD: head/sys/net/if_lagg.c 269492 2014-08-04 00:58:12Z mav $"); |
22 23#include "opt_inet.h" 24#include "opt_inet6.h" 25 26#include <sys/param.h> 27#include <sys/kernel.h> 28#include <sys/malloc.h> 29#include <sys/mbuf.h> --- 1182 unchanged lines hidden (view full) --- 1212 1213static int 1214lagg_ether_cmdmulti(struct lagg_port *lp, int set) 1215{ 1216 struct lagg_softc *sc = lp->lp_softc; 1217 struct ifnet *ifp = lp->lp_ifp; 1218 struct ifnet *scifp = sc->sc_ifp; 1219 struct lagg_mc *mc; |
1220 struct ifmultiaddr *ifma; |
1221 int error; 1222 1223 LAGG_WLOCK_ASSERT(sc); 1224 |
1225 if (set) { |
1226 IF_ADDR_WLOCK(scifp); |
1227 TAILQ_FOREACH(ifma, &scifp->if_multiaddrs, ifma_link) { 1228 if (ifma->ifma_addr->sa_family != AF_LINK) 1229 continue; |
1230 mc = malloc(sizeof(struct lagg_mc), M_DEVBUF, M_NOWAIT); |
1231 if (mc == NULL) { 1232 IF_ADDR_WUNLOCK(scifp); |
1233 return (ENOMEM); |
1234 } 1235 bcopy(ifma->ifma_addr, &mc->mc_addr, 1236 ifma->ifma_addr->sa_len); 1237 mc->mc_addr.sdl_index = ifp->if_index; 1238 mc->mc_ifma = NULL; |
1239 SLIST_INSERT_HEAD(&lp->lp_mc_head, mc, mc_entries); 1240 } |
1241 IF_ADDR_WUNLOCK(scifp); 1242 SLIST_FOREACH (mc, &lp->lp_mc_head, mc_entries) { 1243 error = if_addmulti(ifp, 1244 (struct sockaddr *)&mc->mc_addr, &mc->mc_ifma); 1245 if (error) 1246 return (error); 1247 } |
1248 } else { 1249 while ((mc = SLIST_FIRST(&lp->lp_mc_head)) != NULL) { 1250 SLIST_REMOVE(&lp->lp_mc_head, mc, lagg_mc, mc_entries); |
1251 if (mc->mc_ifma && !lp->lp_detaching) 1252 if_delmulti_ifma(mc->mc_ifma); |
1253 free(mc, M_DEVBUF); 1254 } 1255 } 1256 return (0); 1257} 1258 1259/* Handle a ref counted flag that should be set on the lagg port as well */ 1260static int --- 762 unchanged lines hidden --- |