/*
- * Copyright (c) 2004-2011 Apple Inc. All rights reserved.
+ * Copyright (c) 2004-2014 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
static int bond_get_status(ifbond_ref ifb, struct if_bond_req * ibr_p,
user_addr_t datap);
-static __inline__ int
-ifbond_flags_promisc(ifbond_ref ifb)
-{
- return ((ifb->ifb_flags & IFBF_PROMISC) != 0);
-}
-
-static __inline__ void
-ifbond_flags_set_promisc(ifbond_ref ifb)
-{
- ifb->ifb_flags |= IFBF_PROMISC;
- return;
-}
-
-static __inline__ void
-ifbond_flags_clear_promisc(ifbond_ref ifb)
-{
- ifb->ifb_flags &= ~IFBF_PROMISC;
- return;
-}
-
static __inline__ int
ifbond_flags_if_detaching(ifbond_ref ifb)
{
return ((ifb->ifb_flags & IFBF_LLADDR) != 0);
}
-static __inline__ void
-ifbond_flags_set_lladdr(ifbond_ref ifb)
-{
- ifb->ifb_flags |= IFBF_LLADDR;
- return;
-}
-
-static __inline__ void
-ifbond_flags_clear_lladdr(ifbond_ref ifb)
-{
- ifb->ifb_flags &= ~IFBF_LLADDR;
- return;
-}
-
static __inline__ int
ifbond_flags_change_in_progress(ifbond_ref ifb)
{
/* leave room for ethernet header */
size = length + sizeof(struct ether_header);
if (size > (int)MHLEN) {
- /* XXX doesn't handle large payloads */
- printf("bond: packet_buffer_allocate size %d > max %u\n", size, MHLEN);
- return (NULL);
+ if (size > (int)MCLBYTES) {
+ printf("bond: packet_buffer_allocate size %d > max %u\n",
+ size, MCLBYTES);
+ return (NULL);
+ }
+ m = m_getcl(M_WAITOK, MT_DATA, M_PKTHDR);
+ } else {
+ m = m_gethdr(M_WAITOK, MT_DATA);
}
- m = m_gethdr(M_WAITOK, MT_DATA);
if (m == NULL) {
return (NULL);
}
case IFM_10G_SR:
case IFM_10G_LR:
return (10000);
+ case IFM_2500_T:
+ return (2500);
+ case IFM_5000_T:
+ return (5000);
}
}
{
bond_globals_ref b;
- b = _MALLOC(sizeof(*b), M_BOND, M_WAITOK);
+ b = _MALLOC(sizeof(*b), M_BOND, M_WAITOK | M_ZERO);
if (b == NULL) {
return (NULL);
}
- bzero(b, sizeof(*b));
TAILQ_INIT(&b->ifbond_list);
b->system = *sys;
b->system_priority = sys_pri;
}
b = NULL;
if (ifp != NULL) {
- b = bond_globals_create(0x8000, (lacp_system_ref)ifnet_lladdr(ifp));
+ b = bond_globals_create(0x8000, (lacp_system_ref)IF_LLADDR(ifp));
}
bond_lock();
if (g_bond != NULL) {
int error;
ifbond_ref ifb;
ifnet_t ifp;
- struct ifnet_init_params bond_init;
+ struct ifnet_init_eparams bond_init;
error = bond_globals_init();
if (error != 0) {
return (error);
}
- ifb = _MALLOC(sizeof(ifbond), M_BOND, M_WAITOK);
+ ifb = _MALLOC(sizeof(ifbond), M_BOND, M_WAITOK | M_ZERO);
if (ifb == NULL) {
return (ENOMEM);
}
- bzero(ifb, sizeof(*ifb));
ifbond_retain(ifb);
TAILQ_INIT(&ifb->ifb_port_list);
}
bzero(&bond_init, sizeof(bond_init));
+ bond_init.ver = IFNET_INIT_CURRENT_VERSION;
+ bond_init.len = sizeof (bond_init);
+ bond_init.flags = IFNET_INIT_LEGACY;
bond_init.uniqueid = ifb->ifb_name;
bond_init.uniqueid_len = strlen(ifb->ifb_name);
bond_init.name = ifc->ifc_name;
bond_init.add_proto = ether_add_proto;
bond_init.del_proto = ether_del_proto;
bond_init.check_multi = ether_check_multi;
- bond_init.framer = ether_frameout;
+ bond_init.framer_extended = ether_frameout_extended;
bond_init.ioctl = bond_ioctl;
bond_init.set_bpf_tap = bond_set_bpf_tap;
bond_init.detach = bond_if_free;
bond_init.broadcast_addr = etherbroadcastaddr;
bond_init.broadcast_len = ETHER_ADDR_LEN;
bond_init.softc = ifb;
- error = ifnet_allocate(&bond_init, &ifp);
+ error = ifnet_allocate_extended(&bond_init, &ifp);
if (error) {
ifbond_release(ifb);
uint32_t h;
ifbond_ref ifb;
struct ifnet * port_ifp = NULL;
+ int err;
+ struct flowadv adv = { FADV_SUCCESS };
if (m == 0) {
return (0);
m_freem(m);
return (0);
}
- if (m->m_pkthdr.socket_id != 0) {
- h = m->m_pkthdr.socket_id;
+ if (m->m_pkthdr.pkt_flowid != 0) {
+ h = m->m_pkthdr.pkt_flowid;
}
else {
struct ether_header * eh_p;
}
bond_bpf_output(ifp, m, bpf_func);
- return (ifnet_output_raw(port_ifp, PF_BOND, m));
+ err = dlil_output(port_ifp, PF_BOND, m, NULL, NULL, 1, &adv);
+
+ if (err == 0) {
+ if (adv.code == FADV_FLOW_CONTROLLED) {
+ err = EQFULL;
+ } else if (adv.code == FADV_SUSPENDED) {
+ err = EQSUSPENDED;
+ }
+ }
+
+ return (err);
done:
bond_unlock();
}
m->m_pkthdr.rcvif = ifp;
bond_bpf_input(ifp, m, eh_p, bpf_func);
- m->m_pkthdr.header = frame_header;
+ m->m_pkthdr.pkt_hdr = frame_header;
dlil_input_packet_list(ifp, m);
return 0;
lacp_actor_partner_state s;
*ret_error = 0;
- p = _MALLOC(sizeof(*p), M_BOND, M_WAITOK);
+ p = _MALLOC(sizeof(*p), M_BOND, M_WAITOK | M_ZERO);
if (p == NULL) {
*ret_error = ENOMEM;
return (NULL);
}
- bzero(p, sizeof(*p));
multicast_list_init(&p->po_multicast);
if ((u_int32_t)snprintf(p->po_name, sizeof(p->po_name), "%s%d",
ifnet_name(port_ifp), ifnet_unit(port_ifp))
p->po_bond = ifb;
/* remember the port's ethernet address so it can be restored */
- ether_addr_copy(&p->po_saved_addr, ifnet_lladdr(port_ifp));
+ ether_addr_copy(&p->po_saved_addr, IF_LLADDR(port_ifp));
/* add it to the list of ports */
TAILQ_INSERT_TAIL(&ifb->ifb_port_list, p, po_port_list);
/* first port added to bond determines bond's ethernet address */
if (first) {
- ifnet_set_lladdr_and_type(ifp, ifnet_lladdr(port_ifp), ETHER_ADDR_LEN,
+ ifnet_set_lladdr_and_type(ifp, IF_LLADDR(port_ifp), ETHER_ADDR_LEN,
IFT_ETHER);
}
/* re-program the port's ethernet address */
error = if_siflladdr(port_ifp,
- (const struct ether_addr *)ifnet_lladdr(ifp));
+ (const struct ether_addr *)IF_LLADDR(ifp));
if (error != 0) {
/* port doesn't support setting the link address */
printf("bond_add_interface(%s, %s): if_siflladdr failed %d\n",
ifnet_set_mtu(ifp, 0);
ifb->ifb_altmtu = 0;
} else if (ifbond_flags_lladdr(ifb) == FALSE
- && bcmp(&p->po_saved_addr, ifnet_lladdr(ifp),
+ && bcmp(&p->po_saved_addr, IF_LLADDR(ifp),
ETHER_ADDR_LEN) == 0) {
new_link_address = TRUE;
}
scan_ifp = scan_port->po_ifp;
error = if_siflladdr(scan_ifp,
- (const struct ether_addr *) ifnet_lladdr(ifp));
+ (const struct ether_addr *) IF_LLADDR(ifp));
if (error != 0) {
printf("bond_remove_interface(%s, %s): "
"if_siflladdr (%s) failed %d\n",
break;
}
bzero(&ibs, sizeof(ibs));
- strncpy(ibs.ibs_if_name, port->po_name, sizeof(ibs.ibs_if_name));
+ strlcpy(ibs.ibs_if_name, port->po_name, sizeof(ibs.ibs_if_name));
ibs.ibs_port_priority = port->po_priority;
if (ifb->ifb_mode == IF_BOND_MODE_LACP) {
ibs.ibs_state = port->po_actor_state;
bond_set_promisc(__unused struct ifnet *ifp)
{
int error = 0;
- /*
- * The benefit of doing this currently does not warrant
- * the added code complexity. Do nothing and return.
- */
return (error);
}
event.header.event_code = event_code;
event.header.event_data[0] = ifnet_family(ifp);
event.unit = (u_int32_t) ifnet_unit(ifp);
- strncpy(event.if_name, ifnet_name(ifp), IFNAMSIZ);
+ strlcpy(event.if_name, ifnet_name(ifp), IFNAMSIZ);
ifnet_event(ifp, &event.header);
return;
}
error);
goto done;
}
-#endif
-#if NETAT
- error = proto_register_plumber(PF_APPLETALK, APPLE_IF_FAM_BOND,
- ether_attach_at,
- ether_detach_at);
- if (error != 0) {
- printf("bond: proto_register_plumber failed for AppleTalk error=%d\n",
- error);
- goto done;
- }
#endif
error = bond_clone_attach();
if (error != 0) {