Changeset View
Standalone View
sys/net/if_lagg.c
Show First 20 Lines • Show All 95 Lines • ▼ Show 20 Lines | |||||
static void lagg_clone_destroy(struct ifnet *); | static void lagg_clone_destroy(struct ifnet *); | ||||
static VNET_DEFINE(struct if_clone *, lagg_cloner); | static VNET_DEFINE(struct if_clone *, lagg_cloner); | ||||
#define V_lagg_cloner VNET(lagg_cloner) | #define V_lagg_cloner VNET(lagg_cloner) | ||||
static const char laggname[] = "lagg"; | static const char laggname[] = "lagg"; | ||||
static void lagg_lladdr(struct lagg_softc *, uint8_t *); | static void lagg_lladdr(struct lagg_softc *, uint8_t *); | ||||
static void lagg_capabilities(struct lagg_softc *); | static void lagg_capabilities(struct lagg_softc *); | ||||
static void lagg_port_lladdr(struct lagg_port *, uint8_t *, lagg_llqtype); | static void lagg_port_lladdr(struct lagg_port *, uint8_t *, lagg_llqtype); | ||||
static void lagg_port_setlladdr(void *, int); | static void lagg_port_ops(void *, int); | ||||
static void lagg_port_set_mtu(struct lagg_softc *, struct lagg_llq *); | |||||
static void lagg_port_setlladdr(struct lagg_llq *); | |||||
smh: style(9) should be 4 space indented, more below | |||||
Not Done Inline ActionsThis still seems incorrect (tab intended) smh: This still seems incorrect (tab intended) | |||||
Not Done Inline ActionsAh, thanks. I did it the way it is because other stuff in the file is done that way. For example, see the prototypes for lagg_port_output(), lagg_setflag(), lagg_rr_input(), lagg_fail_input(), lagg_lb_input(), lagg_bcast_input(), lagg_lacp_input(). If you still want me to change this, I can, but I'd rather go with the in-file precedent. rpokala: Ah, thanks.
I did it the way it is because other stuff in the file is done that way. For… | |||||
Not Done Inline ActionsIf that's the case then all good :) smh: If that's the case then all good :) | |||||
Not Done Inline ActionsExcellent. Can you mark this approved for the record, so I can commit? rpokala: Excellent. Can you mark this approved for the record, so I can commit? | |||||
static int lagg_port_create(struct lagg_softc *, struct ifnet *); | static int lagg_port_create(struct lagg_softc *, struct ifnet *); | ||||
static int lagg_port_destroy(struct lagg_port *, int); | static int lagg_port_destroy(struct lagg_port *, int); | ||||
static struct mbuf *lagg_input(struct ifnet *, struct mbuf *); | static struct mbuf *lagg_input(struct ifnet *, struct mbuf *); | ||||
static void lagg_linkstate(struct lagg_softc *); | static void lagg_linkstate(struct lagg_softc *); | ||||
static void lagg_port_state(struct ifnet *, int); | static void lagg_port_state(struct ifnet *, int); | ||||
static int lagg_port_ioctl(struct ifnet *, u_long, caddr_t); | static int lagg_port_ioctl(struct ifnet *, u_long, caddr_t); | ||||
static int lagg_port_output(struct ifnet *, struct mbuf *, | static int lagg_port_output(struct ifnet *, struct mbuf *, | ||||
const struct sockaddr *, struct route *); | const struct sockaddr *, struct route *); | ||||
Show All 12 Lines | |||||
static int lagg_setflags(struct lagg_port *, int status); | static int lagg_setflags(struct lagg_port *, int status); | ||||
static uint64_t lagg_get_counter(struct ifnet *ifp, ift_counter cnt); | static uint64_t lagg_get_counter(struct ifnet *ifp, ift_counter cnt); | ||||
static int lagg_transmit(struct ifnet *, struct mbuf *); | static int lagg_transmit(struct ifnet *, struct mbuf *); | ||||
static void lagg_qflush(struct ifnet *); | static void lagg_qflush(struct ifnet *); | ||||
static int lagg_media_change(struct ifnet *); | static int lagg_media_change(struct ifnet *); | ||||
static void lagg_media_status(struct ifnet *, struct ifmediareq *); | static void lagg_media_status(struct ifnet *, struct ifmediareq *); | ||||
static struct lagg_port *lagg_link_active(struct lagg_softc *, | static struct lagg_port *lagg_link_active(struct lagg_softc *, | ||||
struct lagg_port *); | struct lagg_port *); | ||||
static int lagg_change_mtu(struct ifnet *ifp, struct ifreq *ifr); | |||||
static struct lagg_llq *lagg_get_llq_entry(struct lagg_softc *, | |||||
struct ifnet *); | |||||
static void lagg_llq_list_cleanup(struct lagg_softc *); | |||||
/* Simple round robin */ | /* Simple round robin */ | ||||
static void lagg_rr_attach(struct lagg_softc *); | static void lagg_rr_attach(struct lagg_softc *); | ||||
static int lagg_rr_start(struct lagg_softc *, struct mbuf *); | static int lagg_rr_start(struct lagg_softc *, struct mbuf *); | ||||
static struct mbuf *lagg_rr_input(struct lagg_softc *, struct lagg_port *, | static struct mbuf *lagg_rr_input(struct lagg_softc *, struct lagg_port *, | ||||
struct mbuf *); | struct mbuf *); | ||||
/* Active failover */ | /* Active failover */ | ||||
▲ Show 20 Lines • Show All 341 Lines • ▼ Show 20 Lines | lagg_clone_create(struct if_clone *ifc, int unit, caddr_t params) | ||||
/* Hash all layers by default */ | /* Hash all layers by default */ | ||||
sc->sc_flags = MBUF_HASHFLAG_L2|MBUF_HASHFLAG_L3|MBUF_HASHFLAG_L4; | sc->sc_flags = MBUF_HASHFLAG_L2|MBUF_HASHFLAG_L3|MBUF_HASHFLAG_L4; | ||||
lagg_proto_attach(sc, LAGG_PROTO_DEFAULT); | lagg_proto_attach(sc, LAGG_PROTO_DEFAULT); | ||||
LAGG_LOCK_INIT(sc); | LAGG_LOCK_INIT(sc); | ||||
SLIST_INIT(&sc->sc_ports); | SLIST_INIT(&sc->sc_ports); | ||||
TASK_INIT(&sc->sc_lladdr_task, 0, lagg_port_setlladdr, sc); | TASK_INIT(&sc->sc_llq_task, 0, lagg_port_ops, sc); | ||||
/* Initialise pseudo media types */ | /* Initialise pseudo media types */ | ||||
ifmedia_init(&sc->sc_media, 0, lagg_media_change, | ifmedia_init(&sc->sc_media, 0, lagg_media_change, | ||||
lagg_media_status); | lagg_media_status); | ||||
ifmedia_add(&sc->sc_media, IFM_ETHER | IFM_AUTO, 0, NULL); | ifmedia_add(&sc->sc_media, IFM_ETHER | IFM_AUTO, 0, NULL); | ||||
ifmedia_set(&sc->sc_media, IFM_ETHER | IFM_AUTO); | ifmedia_set(&sc->sc_media, IFM_ETHER | IFM_AUTO); | ||||
if_initname(ifp, laggname, unit); | if_initname(ifp, laggname, unit); | ||||
▲ Show 20 Lines • Show All 49 Lines • ▼ Show 20 Lines | lagg_clone_destroy(struct ifnet *ifp) | ||||
ifmedia_removeall(&sc->sc_media); | ifmedia_removeall(&sc->sc_media); | ||||
ether_ifdetach(ifp); | ether_ifdetach(ifp); | ||||
if_free(ifp); | if_free(ifp); | ||||
LAGG_LIST_LOCK(); | LAGG_LIST_LOCK(); | ||||
SLIST_REMOVE(&V_lagg_list, sc, lagg_softc, sc_entries); | SLIST_REMOVE(&V_lagg_list, sc, lagg_softc, sc_entries); | ||||
LAGG_LIST_UNLOCK(); | LAGG_LIST_UNLOCK(); | ||||
taskqueue_drain(taskqueue_swi, &sc->sc_lladdr_task); | taskqueue_drain(taskqueue_swi, &sc->sc_llq_task); | ||||
LAGG_LOCK_DESTROY(sc); | LAGG_LOCK_DESTROY(sc); | ||||
free(sc, M_DEVBUF); | free(sc, M_DEVBUF); | ||||
} | } | ||||
/* | /* | ||||
* Set link-layer address on the lagg interface itself. | * Set link-layer address on the lagg interface itself. | ||||
* | * | ||||
* Set noinline to be dtrace-friendly | * Set noinline to be dtrace-friendly | ||||
▲ Show 20 Lines • Show All 102 Lines • ▼ Show 20 Lines | lagg_port_lladdr(struct lagg_port *lp, uint8_t *lladdr, lagg_llqtype llq_type) | ||||
} | } | ||||
llq = malloc(sizeof(struct lagg_llq), M_DEVBUF, M_NOWAIT | M_ZERO); | llq = malloc(sizeof(struct lagg_llq), M_DEVBUF, M_NOWAIT | M_ZERO); | ||||
if (llq == NULL) /* XXX what to do */ | if (llq == NULL) /* XXX what to do */ | ||||
return; | return; | ||||
llq->llq_ifp = ifp; | llq->llq_ifp = ifp; | ||||
llq->llq_type = llq_type; | llq->llq_type = llq_type; | ||||
llq->flags |= LAGG_ASYNC_SET_MAC_ADDR; | |||||
bcopy(lladdr, llq->llq_lladdr, ETHER_ADDR_LEN); | bcopy(lladdr, llq->llq_lladdr, ETHER_ADDR_LEN); | ||||
/* XXX: We should insert to tail */ | /* XXX: We should insert to tail */ | ||||
SLIST_INSERT_HEAD(&sc->sc_llq_head, llq, llq_entries); | SLIST_INSERT_HEAD(&sc->sc_llq_head, llq, llq_entries); | ||||
taskqueue_enqueue(taskqueue_swi, &sc->sc_lladdr_task); | taskqueue_enqueue(taskqueue_swi, &sc->sc_llq_task); | ||||
} | } | ||||
/* | /* | ||||
* Set the interface MAC address from a taskqueue to avoid a LOR. | * Set the interface MTU, MAC address from a taskqueue to avoid a LOR. | ||||
* | * | ||||
* Set noinline to be dtrace-friendly | * Set noinline to be dtrace-friendly | ||||
*/ | */ | ||||
static __noinline void | static __noinline void | ||||
lagg_port_setlladdr(void *arg, int pending) | lagg_port_ops(void *arg, int pending) | ||||
{ | { | ||||
struct lagg_softc *sc = (struct lagg_softc *)arg; | struct lagg_softc *sc = (struct lagg_softc *)arg; | ||||
struct lagg_llq *llq, *head; | struct lagg_llq *llq, *head; | ||||
struct ifnet *ifp; | |||||
/* Grab a local reference of the queue and remove it from the softc */ | /* Grab a local reference of the queue and remove it from the softc */ | ||||
LAGG_WLOCK(sc); | LAGG_WLOCK(sc); | ||||
head = SLIST_FIRST(&sc->sc_llq_head); | head = SLIST_FIRST(&sc->sc_llq_head); | ||||
SLIST_FIRST(&sc->sc_llq_head) = NULL; | SLIST_FIRST(&sc->sc_llq_head) = NULL; | ||||
LAGG_WUNLOCK(sc); | LAGG_WUNLOCK(sc); | ||||
if (!head) | |||||
smhUnsubmitted Done Inline Actionsstyle(9) bool use of pointer type. smh: style(9) bool use of pointer type. | |||||
return; | |||||
/* | /* | ||||
* Traverse the queue and set the lladdr on each ifp. It is safe to do | * Traverse the queue and set the lladdr on each ifp. It is safe to do | ||||
* unlocked as we have the only reference to it. | * unlocked as we have the only reference to it. | ||||
*/ | */ | ||||
if (head->flags & LAGG_ASYNC_SET_MTU) { | |||||
Done Inline ActionsNot sure if its possible but if we have no llq_entries then err will be uninitialised on return. smh: Not sure if its possible but if we have no llq_entries then err will be uninitialised on return. | |||||
/* | |||||
* Set the new MTU on the lagg port and its members. | |||||
* If failed, REVERT to the old MTU. | |||||
*/ | |||||
lagg_port_set_mtu(sc, head); | |||||
} | |||||
if (head->flags & LAGG_ASYNC_SET_MAC_ADDR) { | |||||
/* | |||||
* Set the MAC address. | |||||
*/ | |||||
lagg_port_setlladdr(head); | |||||
} | |||||
melifaroUnsubmitted Done Inline ActionsWhat if we have multiple events queued on tasq? e.g mtu AND mac change melifaro: What if we have multiple events queued on tasq? e.g mtu AND mac change | |||||
if (!(head->flags & LAGG_ASYNC_SET_MASK)) | |||||
if_printf(sc->sc_ifp, | |||||
"Lagg port ops: flag (0x%x) not supported\n", head->flags); | |||||
smhUnsubmitted Done Inline Actionsstyle(9) four space additional indent only should be used, more below. smh: style(9) four space additional indent only should be used, more below. | |||||
/* Finally free the per port llq entry; DO THIS OPERATION LAST */ | |||||
for (llq = head; llq != NULL; llq = head) { | for (llq = head; llq != NULL; llq = head) { | ||||
head = SLIST_NEXT(llq, llq_entries); | |||||
free(llq, M_DEVBUF); | |||||
} | |||||
Done Inline Actionsstyle(9) blank line after vars. smh: style(9) blank line after vars. | |||||
} | |||||
static void | |||||
lagg_port_set_mtu(struct lagg_softc *sc, struct lagg_llq *head) | |||||
{ | |||||
struct lagg_llq *llq; | |||||
int err = 0; | |||||
/* Set the new MTU on the lagg interface */ | |||||
LAGG_WLOCK(sc); | |||||
sc->sc_ifp->if_mtu = head->ifr->ifr_mtu; | |||||
LAGG_WUNLOCK(sc); | |||||
/* Set the new MTU on the physical interface */ | |||||
for (llq = head; llq != NULL; llq = SLIST_NEXT(llq, llq_entries)) { | |||||
err = (*llq->llq_ioctl)(llq->llq_ifp, SIOCSIFMTU, (caddr_t)llq->ifr); | |||||
hrsUnsubmitted Done Inline ActionsPlease separate a llq loop from a handler for per-port configuration. A llq traversal should be required only once in lagg_port_ops() if the handlers process a single lagg_llq entry. hrs: Please separate a llq loop from a handler for per-port configuration. A llq traversal should be… | |||||
if (err) { | |||||
if_printf(llq->llq_ifp, | |||||
"Failed to change MTU from %d to %d (err %d)\n", | |||||
llq->old_mtu, llq->ifr->ifr_mtu, err); | |||||
break; | |||||
} | |||||
} | |||||
Done Inline Actionsstatic void should be on a separate line, few more below. Also not keen on the name for this method may be something like lagg_llq_free_entries? smh: static void should be on a separate line, few more below.
Also not keen on the name for this… | |||||
if (err) { | |||||
/* Restore the old MTU on the lagg interface */ | |||||
melifaroUnsubmitted Done Inline ActionsNot that easy, unfortunately. melifaro: Not that easy, unfortunately.
At this moment original ioctl returned 0, so other things/events… | |||||
LAGG_WLOCK(sc); | |||||
sc->sc_ifp->if_mtu = head->old_mtu; | |||||
LAGG_WUNLOCK(sc); | |||||
/* Restore the old MTU on the physical interface */ | |||||
for (llq = head; llq != NULL; llq = SLIST_NEXT(llq, llq_entries)) { | |||||
smhUnsubmitted Done Inline ActionsLooks like this attempts to change more that would have been done above before the error, is that intended? smh: Looks like this attempts to change more that would have been done above before the error, is… | |||||
rpokalaAuthorUnsubmitted Done Inline ActionsFor the interfaces after the one that failed (and therefore which still have the old MTU), this is a noop. rpokala: For the interfaces after the one that failed (and therefore which still have the old MTU), this… | |||||
llq->ifr->ifr_mtu = llq->old_mtu; | |||||
err = (*llq->llq_ioctl) | |||||
(llq->llq_ifp, SIOCSIFMTU, (caddr_t)llq->ifr); | |||||
if (err) { | |||||
if_printf(llq->llq_ifp, | |||||
"Failed to restore MTU to %d (err %d)\n", | |||||
llq->old_mtu, err); | |||||
} | |||||
} | |||||
} | |||||
/* Common to all lagg member ports */ | |||||
free(head->ifr, M_DEVBUF); | |||||
} | |||||
smhUnsubmitted Done Inline ActionsLooks like the error gets lost, although printed, is there no way we can avoid this? smh: Looks like the error gets lost, although printed, is there no way we can avoid this? | |||||
static void lagg_llq_list_cleanup(struct lagg_softc *sc) | |||||
{ | |||||
struct lagg_llq *head, *llq; | |||||
LAGG_WLOCK_ASSERT(sc); | |||||
head = SLIST_FIRST(&sc->sc_llq_head); | |||||
SLIST_FIRST(&sc->sc_llq_head) = NULL; | |||||
Done Inline ActionsNo need for == TRUE on bool. smh: No need for == TRUE on bool. | |||||
for (llq = head; llq != NULL; llq = head) { | |||||
head = SLIST_NEXT(llq, llq_entries); | |||||
free(llq, M_DEVBUF); | |||||
} | |||||
} | |||||
static struct lagg_llq * | |||||
Done Inline ActionsI assume this is checked after cv_has_waiters as that indicates an mtu change is in progress hence there's no easy way to confirm what it will become? Its a shame ioctl doesn't currently have EBUSY as a possible return error as that may be simpler. smh: I assume this is checked after cv_has_waiters as that indicates an mtu change is in progress… | |||||
lagg_get_llq_entry(struct lagg_softc *sc, struct ifnet *ifp) | |||||
Done Inline ActionsThis looks a bit messy given you only need LAGG_WUNLOCK(sc); I would do something like (also eliminates done var too). Alternatively just use goto out, which while it sets busy to false that should be fine. if (SLIST_EMPTY(&sc->sc_ports)) { LAGG_WUNLOCK(sc); return (EIO); } else if (sc->sc_mtu_ctxt.busy) { LAGG_WUNLOCK(sc); return (EBUSY); } else if (ifp->if_mtu == ifr->ifr_mtu) { LAGG_WUNLOCK(sc); return (0); } sc->sc_mtu_ctxt.busy = TRUE; smh: This looks a bit messy given you only need LAGG_WUNLOCK(sc); I would do something like (also… | |||||
{ | |||||
struct lagg_llq *llq; | |||||
LAGG_WLOCK_ASSERT(sc); | |||||
SLIST_FOREACH(llq, &sc->sc_llq_head, llq_entries) { | |||||
if (llq->llq_ifp == ifp) { | |||||
break; | |||||
} | |||||
} | |||||
return llq; | |||||
smhUnsubmitted Done Inline Actionsstyle(9) bracing around return. smh: style(9) bracing around return. | |||||
rpokalaAuthorUnsubmitted Done Inline ActionsI rather hate that idiom, but fine. :-P rpokala: I rather hate that idiom, but fine. :-P | |||||
} | |||||
static int | |||||
lagg_change_mtu(struct ifnet *ifp, struct ifreq *ifr) | |||||
{ | |||||
struct lagg_softc *sc = (struct lagg_softc *)ifp->if_softc; | |||||
smhUnsubmitted Done Inline Actionsstyle(9) init of vars in declaration should be avoided. Moving to down to where its first needed can avoid setting it at all. smh: style(9) init of vars in declaration should be avoided.
Moving to down to where its first… | |||||
struct lagg_port *lp; | |||||
struct lagg_llq *llq; | |||||
struct ifreq *ifr_copy, *old_ifr = NULL; | |||||
/* No change in MTU */ | |||||
if (ifp->if_mtu == ifr->ifr_mtu) | |||||
return (0); | |||||
ifr_copy = malloc(sizeof(struct ifreq), M_DEVBUF, M_NOWAIT); | |||||
if (ifr_copy == NULL) | |||||
return (ENOMEM); | |||||
bcopy(ifr, ifr_copy, sizeof(struct ifreq)); | |||||
LAGG_WLOCK(sc); | |||||
/* All lagg ports (MTU change) shall be queued atomic */ | |||||
SLIST_FOREACH(lp, &sc->sc_ports, lp_entries) { | |||||
/* Check to make sure its not already queued */ | |||||
llq = lagg_get_llq_entry(sc, lp->lp_ifp); | |||||
if (!llq) { | |||||
smhUnsubmitted Done Inline Actionsstyle(9) bool use of pointer type. smh: style(9) bool use of pointer type. | |||||
hrsUnsubmitted Done Inline ActionsIs this (llq == NULL), not (llq != NULL)? hrs: Is this (llq == NULL), not (llq != NULL)? | |||||
llq = malloc(sizeof(struct lagg_llq), M_DEVBUF, M_NOWAIT); | |||||
if (llq == NULL) { | |||||
lagg_llq_list_cleanup(sc); | |||||
hrsUnsubmitted Done Inline ActionsWhy is cleanup required here? This removes all of tasks not limited to MTU change. hrs: Why is cleanup required here? This removes all of tasks not limited to MTU change. | |||||
LAGG_WUNLOCK(sc); | |||||
free(ifr_copy, M_DEVBUF); | |||||
if (old_ifr) | |||||
smhUnsubmitted Done Inline Actionsstyle(9) bool use of pointer type. smh: style(9) bool use of pointer type. | |||||
free(old_ifr, M_DEVBUF); | |||||
return (ENOMEM); | |||||
} | |||||
SLIST_INSERT_HEAD(&sc->sc_llq_head, llq, llq_entries); | |||||
} else { | |||||
old_ifr = llq->ifr; | |||||
} | |||||
/* Update the llq even if pending, it might have updated */ | |||||
smhUnsubmitted Done Inline Actionsconsider: "it might have been updated." smh: consider: "it might have been updated." | |||||
llq->ifr = ifr_copy; | |||||
llq->old_mtu = ifp->if_mtu; | |||||
llq->llq_ifp = lp->lp_ifp; | |||||
llq->llq_ioctl = lp->lp_ioctl; | |||||
llq->flags |= LAGG_ASYNC_SET_MTU; | |||||
} | |||||
taskqueue_enqueue(taskqueue_swi, &sc->sc_llq_task); | |||||
LAGG_WUNLOCK(sc); | |||||
if (old_ifr) | |||||
smhUnsubmitted Done Inline Actionsstyle(9) bool use of pointer type. smh: style(9) bool use of pointer type. | |||||
hrsUnsubmitted Done Inline Actionsfree(NULL) does nothing. Checking if NULL or not is useless. hrs: free(NULL) does nothing. Checking if NULL or not is useless. | |||||
free(old_ifr, M_DEVBUF); | |||||
return (0); | |||||
} | |||||
static void | |||||
lagg_port_setlladdr(struct lagg_llq *head) | |||||
{ | |||||
struct lagg_llq *llq; | |||||
struct ifnet *ifp; | |||||
for (llq = head; llq != NULL; llq = head) { | |||||
hrsUnsubmitted Done Inline ActionsThis traversal and freeing an entry after processing it should be done in lagg_port_ops(). hrs: This traversal and freeing an entry after processing it should be done in lagg_port_ops(). | |||||
ifp = llq->llq_ifp; | ifp = llq->llq_ifp; | ||||
CURVNET_SET(ifp->if_vnet); | CURVNET_SET(ifp->if_vnet); | ||||
/* | /* | ||||
* Set the link layer address on the laggport interface. | * Set the link layer address on the laggport interface. | ||||
* Note that if_setlladdr() or iflladdr_event handler | * Note that if_setlladdr() or iflladdr_event handler | ||||
* may result in arp transmission / lltable updates. | * may result in arp transmission / lltable updates. | ||||
*/ | */ | ||||
if (llq->llq_type == LAGG_LLQTYPE_PHYS) | if (llq->llq_type == LAGG_LLQTYPE_PHYS) | ||||
if_setlladdr(ifp, llq->llq_lladdr, | if_setlladdr(ifp, llq->llq_lladdr, | ||||
ETHER_ADDR_LEN); | ETHER_ADDR_LEN); | ||||
else | else | ||||
EVENTHANDLER_INVOKE(iflladdr_event, ifp); | EVENTHANDLER_INVOKE(iflladdr_event, ifp); | ||||
CURVNET_RESTORE(); | CURVNET_RESTORE(); | ||||
head = SLIST_NEXT(llq, llq_entries); | head = SLIST_NEXT(llq, llq_entries); | ||||
free(llq, M_DEVBUF); | |||||
} | } | ||||
} | } | ||||
static int | static int | ||||
lagg_port_create(struct lagg_softc *sc, struct ifnet *ifp) | lagg_port_create(struct lagg_softc *sc, struct ifnet *ifp) | ||||
{ | { | ||||
struct lagg_softc *sc_ptr; | struct lagg_softc *sc_ptr; | ||||
struct lagg_port *lp, *tlp; | struct lagg_port *lp, *tlp; | ||||
▲ Show 20 Lines • Show All 794 Lines • ▼ Show 20 Lines | case SIOCDELMULTI: | ||||
LAGG_WUNLOCK(sc); | LAGG_WUNLOCK(sc); | ||||
break; | break; | ||||
case SIOCSIFMEDIA: | case SIOCSIFMEDIA: | ||||
case SIOCGIFMEDIA: | case SIOCGIFMEDIA: | ||||
error = ifmedia_ioctl(ifp, ifr, &sc->sc_media, cmd); | error = ifmedia_ioctl(ifp, ifr, &sc->sc_media, cmd); | ||||
break; | break; | ||||
case SIOCSIFCAP: | case SIOCSIFCAP: | ||||
case SIOCSIFMTU: | /* Do not allow the CAPs to be directly changed. */ | ||||
/* Do not allow the MTU or caps to be directly changed */ | |||||
error = EINVAL; | error = EINVAL; | ||||
break; | |||||
case SIOCSIFMTU: | |||||
error = lagg_change_mtu(ifp, ifr); | |||||
break; | break; | ||||
default: | default: | ||||
error = ether_ioctl(ifp, cmd, data); | error = ether_ioctl(ifp, cmd, data); | ||||
break; | break; | ||||
} | } | ||||
return (error); | return (error); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 52 Lines • ▼ Show 20 Lines | lagg_ether_cmdmulti(struct lagg_port *lp, int set) | ||||
} else { | } else { | ||||
while ((mc = SLIST_FIRST(&lp->lp_mc_head)) != NULL) { | while ((mc = SLIST_FIRST(&lp->lp_mc_head)) != NULL) { | ||||
SLIST_REMOVE(&lp->lp_mc_head, mc, lagg_mc, mc_entries); | SLIST_REMOVE(&lp->lp_mc_head, mc, lagg_mc, mc_entries); | ||||
if (mc->mc_ifma && !lp->lp_detaching) | if (mc->mc_ifma && !lp->lp_detaching) | ||||
if_delmulti_ifma(mc->mc_ifma); | if_delmulti_ifma(mc->mc_ifma); | ||||
free(mc, M_DEVBUF); | free(mc, M_DEVBUF); | ||||
} | } | ||||
} | } | ||||
return (0); | return (0); | ||||
Done Inline Actionsstyle(9) says to not include unnecessary braces (which I personally disagree with, but what can you do?) rstone: style(9) says to not include unnecessary braces (which I personally disagree with, but what can… | |||||
} | } | ||||
Done Inline Actionsstyle(9): put brackets around the return value: return (0); rstone: style(9): put brackets around the return value:
return (0); | |||||
/* Handle a ref counted flag that should be set on the lagg port as well */ | /* Handle a ref counted flag that should be set on the lagg port as well */ | ||||
static int | static int | ||||
lagg_setflag(struct lagg_port *lp, int flag, int status, | lagg_setflag(struct lagg_port *lp, int flag, int status, | ||||
int (*func)(struct ifnet *, int)) | int (*func)(struct ifnet *, int)) | ||||
{ | { | ||||
struct lagg_softc *sc = lp->lp_softc; | struct lagg_softc *sc = lp->lp_softc; | ||||
struct ifnet *scifp = sc->sc_ifp; | struct ifnet *scifp = sc->sc_ifp; | ||||
Show All 21 Lines | if (status != (lp->lp_ifflags & flag)) { | ||||
lp->lp_ifflags &= ~flag; | lp->lp_ifflags &= ~flag; | ||||
lp->lp_ifflags |= status; | lp->lp_ifflags |= status; | ||||
} | } | ||||
return (0); | return (0); | ||||
} | } | ||||
/* | /* | ||||
* Handle IFF_* flags that require certain changes on the lagg port | * Handle IFF_* flags that require certain changes on the lagg port | ||||
* if "status" is true, update ports flags respective to the lagg | * if "status" is true, update ports flags respective to the lagg | ||||
Done Inline ActionsI find the flow control here a bit confusing (my first read through, I thought that err2 could be used unitinialized). Given that you have a continue in the if block, I would find it clearer to not have an else here rstone: I find the flow control here a bit confusing (my first read through, I thought that err2 could… | |||||
* if "status" is false, forcedly clear the flags set on port. | * if "status" is false, forcedly clear the flags set on port. | ||||
*/ | */ | ||||
static int | static int | ||||
lagg_setflags(struct lagg_port *lp, int status) | lagg_setflags(struct lagg_port *lp, int status) | ||||
{ | { | ||||
int error, i; | int error, i; | ||||
for (i = 0; lagg_pflags[i].flag; i++) { | for (i = 0; lagg_pflags[i].flag; i++) { | ||||
▲ Show 20 Lines • Show All 569 Lines • Show Last 20 Lines |
style(9) should be 4 space indented, more below