Mercurial > illumos > illumos-gate
changeset 5102:b6ea1a119e46
6220365 ActorPortNumber computation could be improved
6367825 Message size is incorrect when Nemo sends DL_NOTIFY_ACK
6507483 the CACHE_IF_UPDATED flag in ip_rcm is not used
6509647 do_check_rate() in dladm wifi might return unitialized error code
6514482 the DLS_PROMISC_MULTI flag check is not needed to add the txloop function
6573306 aggregation state is not updated in time.
6595696 aggregation port potentially will not be able to be attached
author | yz147064 |
---|---|
date | Thu, 20 Sep 2007 01:07:16 -0700 |
parents | aa0fba8e3ae2 |
children | 29839afd54fd |
files | usr/src/cmd/rcm_daemon/common/ip_rcm.c usr/src/lib/libdladm/common/libdlwlan.c usr/src/uts/common/io/aggr/aggr_grp.c usr/src/uts/common/io/aggr/aggr_lacp.c usr/src/uts/common/io/aggr/aggr_port.c usr/src/uts/common/io/dls/dls.c usr/src/uts/common/io/sundlpi.c usr/src/uts/common/sys/aggr_impl.h |
diffstat | 8 files changed, 84 insertions(+), 131 deletions(-) [+] |
line wrap: on
line diff
--- a/usr/src/cmd/rcm_daemon/common/ip_rcm.c Thu Sep 20 00:59:05 2007 -0700 +++ b/usr/src/cmd/rcm_daemon/common/ip_rcm.c Thu Sep 20 01:07:16 2007 -0700 @@ -2,9 +2,8 @@ * CDDL HEADER START * * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. @@ -20,7 +19,7 @@ * CDDL HEADER END */ /* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -118,8 +117,7 @@ #define CACHE_IF_STALE 0x1 /* stale cached data */ #define CACHE_IF_NEW 0x2 /* new cached interface */ #define CACHE_IF_OFFLINED 0x4 /* interface offlined */ -#define CACHE_IF_UPDATED 0x8 /* interface props. updated */ -#define CACHE_IF_IGNORE 0x10 /* state held elsewhere */ +#define CACHE_IF_IGNORE 0x8 /* state held elsewhere */ /* Network Cache lookup options */ #define CACHE_NO_REFRESH 0x1 /* cache refresh not needed */ @@ -283,9 +281,6 @@ static uint64_t if_get_flags(ip_pif_t *); static int mpathd_send_cmd(mpathd_cmd_t *); static int connect_to_mpathd(int); -#ifdef RCM_IPMP_DEBUG -static void dump_node(ip_cache_t *); -#endif static int modop(char *, char *, int, char); static int get_modlist(char *, ip_lif_t *); static int ip_domux2fd(int *, int *, struct lifreq *); @@ -516,10 +511,10 @@ if (ip_offlinelist(hd, node, errorp, flags, depend_info) == RCM_SUCCESS) { rcm_log_message(RCM_DEBUG, - "IP: consumers agree on detach"); + "IP: consumers agree on detach"); } else { ip_log_err(node, errorp, - "Device consumers prohibit offline"); + "Device consumers prohibit offline"); (void) mutex_unlock(&cache_lock); return (RCM_FAILURE); } @@ -594,10 +589,10 @@ if (ip_offlinelist(hd, node, errorp, flags, depend_info) == RCM_SUCCESS) { rcm_log_message(RCM_DEBUG, - "IP: consumers agree on detach"); + "IP: consumers agree on detach"); } else { ip_log_err(node, errorp, - "Device consumers prohibit offline"); + "Device consumers prohibit offline"); (void) mutex_unlock(&cache_lock); errno = EBUSY; return (RCM_FAILURE); @@ -815,6 +810,7 @@ /* remove the cached entry for the resource */ cache_remove(node); + free_node(node); (void) mutex_unlock(&cache_lock); return (RCM_SUCCESS); @@ -888,7 +884,7 @@ if (nip != (struct net_interface *)0) { if (nip->name != 0) { ip_consumer_notify(hd, nip->name, errorp, flags, - depend_info); + depend_info); free(nip->name); } if (nip->type != 0) @@ -1244,7 +1240,6 @@ probelif->li_ifflags = ifflags; lif_listed++; - probe->ip_cachestate |= CACHE_IF_UPDATED; probelif->li_cachestate &= ~(CACHE_IF_STALE); break; } @@ -1265,8 +1260,6 @@ probe->ip_pif = probepif; - probe->ip_cachestate |= CACHE_IF_UPDATED; - /* Save interface name */ (void) memcpy(&probepif->pi_ifname, &pif.pi_ifname, sizeof (pif.pi_ifname)); @@ -1303,9 +1296,6 @@ probelif->li_pif = probepif; probepif->pi_lifs = probelif; - probelif->li_cachestate = CACHE_IF_NEW; - - probe->ip_cachestate |= CACHE_IF_UPDATED; } rcm_log_message(RCM_TRACE3, "IP: update_pif: (%s) success\n", @@ -1610,7 +1600,7 @@ "(%s) %s\n"), pif->pi_ifname, strerror(errno)); - clr_cfg_state(pif); + clr_cfg_state(pif); return (-1); } i++; @@ -1621,7 +1611,7 @@ "%s failed: %s\n"), pif->pi_ifname, lif->li_modules[i], strerror(errno)); - clr_cfg_state(pif); + clr_cfg_state(pif); return (-1); } } @@ -1723,7 +1713,7 @@ if (rcm_exec_cmd(syscmd) != 0) { rcm_log_message(RCM_ERROR, _("IP: Cannot unplumb (%s) %s\n"), - pif->pi_ifname, strerror(errno)); + pif->pi_ifname, strerror(errno)); return (-1); } } @@ -1736,7 +1726,7 @@ if (rcm_exec_cmd(syscmd) != 0) { rcm_log_message(RCM_ERROR, _("IP: Cannot unplumb (%s) %s\n"), - pif->pi_ifname, strerror(errno)); + pif->pi_ifname, strerror(errno)); return (-1); } } @@ -1861,7 +1851,7 @@ if (rcm_exec_cmd(syscmd) != 0) { rcm_log_message(RCM_ERROR, _("IP: Cannot addif (%s:%d) " - "%s\n"), + "%s\n"), pif->pi_ifname, i, strerror(errno)); return (-1); } @@ -3501,8 +3491,7 @@ } freehostent(hp); } - rcm_log_message(RCM_TRACE2, "IP: ifaddr(%s) = %s\n", - addr, ifaddr); + rcm_log_message(RCM_TRACE2, "IP: ifaddr(%s) = %s\n", addr, ifaddr); /* now search the interfaces */ lifrp = lifc.lifc_req; @@ -3622,38 +3611,3 @@ *sp++ = '\0'; } } - -#ifdef RCM_IPMP_DEBUG -static void -dump_node(ip_cache_t *node) -{ - ip_pif_t *pif = node->ip_pif; - ip_lif_t *lif = pif->pi_lifs; - - rcm_log_message(RCM_TRACE1, "Node dump:\n"); - rcm_log_message(RCM_TRACE1, "resource = %s\t cache flags = 0x%x\n", - node->ip_resource, node->ip_cachestate); - rcm_log_message(RCM_TRACE1, "ifname = %s\n", pif->pi_ifname); - rcm_log_message(RCM_TRACE1, "groupname = %s\n", pif->pi_grpname); - - if (lif == NULL) { - rcm_log_message(RCM_TRACE1, "No lifs hosted on this device.\n"); - return; - } - - rcm_log_message(RCM_TRACE1, - "Logical interfaces hosted on this device - \n"); - while (lif != NULL) { - rcm_log_message(RCM_TRACE1, "\t ifnum = %d \t ifflags = 0x%x", - lif->li_ifnum, lif->li_ifflags); - if (lif->li_addr.family == AF_INET) - rcm_log_message(RCM_TRACE1, "\t Family = IPv4"); - else if (lif->li_addr.family == AF_INET6) - rcm_log_message(RCM_TRACE1, "\t Family = IPv6"); - else rcm_log_message(RCM_TRACE1, "\t Family = <Unknown>"); - rcm_log_message(RCM_TRACE1, "\n"); - - lif = lif->li_next; - } -} -#endif /* RCM_IPMP_DEBUG */
--- a/usr/src/lib/libdladm/common/libdlwlan.c Thu Sep 20 00:59:05 2007 -0700 +++ b/usr/src/lib/libdladm/common/libdlwlan.c Thu Sep 20 01:07:16 2007 -0700 @@ -1814,8 +1814,10 @@ return (DLADM_STATUS_BADVALCNT); buf = malloc((sizeof (char *) + DLADM_STRSIZE) * MAX_SUPPORT_RATES); - if (buf == NULL) + if (buf == NULL) { + status = DLADM_STATUS_NOMEM; goto done; + } modval = (char **)(void *)buf; for (i = 0; i < MAX_SUPPORT_RATES; i++) {
--- a/usr/src/uts/common/io/aggr/aggr_grp.c Thu Sep 20 00:59:05 2007 -0700 +++ b/usr/src/uts/common/io/aggr/aggr_grp.c Thu Sep 20 01:07:16 2007 -0700 @@ -329,8 +329,8 @@ cport = cport->lp_next) { rw_enter(&cport->lp_lock, RW_WRITER); if (aggr_port_unicst(cport, grp->lg_addr) != 0) { - link_state_changed = link_state_changed || - aggr_grp_detach_port(grp, cport); + if (aggr_grp_detach_port(grp, cport)) + link_state_changed = B_TRUE; } else { /* * If a port was detached because of a previous @@ -339,8 +339,8 @@ * address now, and this might cause the link state * of the aggregation to change. */ - link_state_changed = link_state_changed || - aggr_grp_attach_port(grp, cport); + if (aggr_grp_attach_port(grp, cport)) + link_state_changed = B_TRUE; } rw_exit(&cport->lp_lock); } @@ -517,13 +517,13 @@ /* * Attach each port if necessary. */ - link_state_changed = link_state_changed || - aggr_port_notify_link(grp, port, B_FALSE); + if (aggr_port_notify_link(grp, port, B_FALSE)) + link_state_changed = B_TRUE; } /* update the MAC address of the constituent ports */ - link_state_changed = link_state_changed || - aggr_grp_update_ports_mac(grp); + if (aggr_grp_update_ports_mac(grp)) + link_state_changed = B_TRUE; if (link_state_changed) mac_link_update(grp->lg_mh, grp->lg_link_state); @@ -765,8 +765,13 @@ /* * Attach each port if necessary. */ - for (port = grp->lg_ports; port != NULL; port = port->lp_next) - (void) aggr_port_notify_link(grp, port, B_FALSE); + for (port = grp->lg_ports; port != NULL; port = port->lp_next) { + if (aggr_port_notify_link(grp, port, B_FALSE)) + link_state_changed = B_TRUE; + } + + if (link_state_changed) + mac_link_update(grp->lg_mh, grp->lg_link_state); /* add new group to hash table */ err = mod_hash_insert(aggr_grp_hash, GRP_HASH_KEY(key), @@ -907,9 +912,8 @@ * the remaining consistuent ports according to the new MAC * address of the group. */ - if (mac_addr_changed) - link_state_changed = link_state_changed || - aggr_grp_update_ports_mac(grp); + if (mac_addr_changed && aggr_grp_update_ports_mac(grp)) + link_state_changed = B_TRUE; done: if (mac_addr_changedp != NULL) @@ -1306,8 +1310,8 @@ AGGR_PORT_REFHOLD(port); if (port->lp_started) { if (aggr_port_promisc(port, on) != 0) { - link_state_changed = link_state_changed || - aggr_grp_detach_port(grp, port); + if (aggr_grp_detach_port(grp, port)) + link_state_changed = B_TRUE; } else { /* * If a port was detached because of a previous @@ -1316,8 +1320,8 @@ * the promiscuity now, and this might cause * the link state of the aggregation to change. */ - link_state_changed = link_state_changed || - aggr_grp_attach_port(grp, port); + if (aggr_grp_attach_port(grp, port)) + link_state_changed = B_TRUE; } } rw_exit(&port->lp_lock);
--- a/usr/src/uts/common/io/aggr/aggr_lacp.c Thu Sep 20 00:59:05 2007 -0700 +++ b/usr/src/uts/common/io/aggr/aggr_lacp.c Thu Sep 20 01:07:16 2007 -0700 @@ -19,7 +19,7 @@ * CDDL HEADER END */ /* - * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -132,22 +132,6 @@ mutex_destroy(&lacp_sel_lock); } -static int -inst_num(char *devname) -{ - int inst = 0; - int fact = 1; - char *p = &devname[strlen(devname)-1]; - - while (*p >= '0' && *p <= '9' && p >= devname) { - inst += (*p - '0') * fact; - fact *= 10; - p--; - } - - return (inst); -} - /* * Set the port LACP state to SELECTED. Returns B_FALSE if the operation * could not be performed due to a memory allocation error, B_TRUE otherwise. @@ -196,23 +180,13 @@ { aggr_grp_t *aggrp = portp->lp_grp; aggr_lacp_port_t *pl = &portp->lp_lacp; - uint16_t offset; - uint32_t instance; ASSERT(AGGR_LACP_LOCK_HELD(aggrp)); ASSERT(RW_LOCK_HELD(&aggrp->lg_lock)); ASSERT(RW_LOCK_HELD(&portp->lp_lock)); - /* - * Port numbers must be unique. For now, we encode the first two - * characters into the top byte of the port number. This will work - * with multiple types of NICs provided that the first two - * characters are unique. - */ - offset = ((portp->lp_devname[0] + portp->lp_devname[1]) << 8); - instance = inst_num(portp->lp_devname); /* actor port # */ - pl->ActorPortNumber = offset + instance; + pl->ActorPortNumber = portp->lp_portid; AGGR_LACP_DBG(("aggr_lacp_init_port(%s): " "ActorPortNumber = 0x%x\n", portp->lp_devname, pl->ActorPortNumber)); @@ -297,7 +271,7 @@ /* reset operational port state */ pl->ActorOperPortState.bit.timeout = - pl->ActorAdminPortState.bit.timeout; + pl->ActorAdminPortState.bit.timeout; pl->ActorOperPortState.bit.sync = B_FALSE; pl->ActorOperPortState.bit.collecting = B_FALSE; @@ -1007,8 +981,8 @@ (mode == AGGR_LACP_ACTIVE); port->lp_lacp.ActorAdminPortState.bit.timeout = - port->lp_lacp.ActorOperPortState.bit.timeout = - (timer == AGGR_LACP_TIMER_SHORT); + port->lp_lacp.ActorOperPortState.bit.timeout = + (timer == AGGR_LACP_TIMER_SHORT); if (grp->lg_lacp_mode == AGGR_LACP_OFF) { /* Turn ON Collector_Distributor */ @@ -1775,7 +1749,7 @@ (ntohs(lacp->partner_info.port_priority) == pl->ActorPortPriority) && (ether_cmp(&lacp->partner_info.system_id, - (struct ether_addr *)&aggrp->lg_addr) == 0) && + (struct ether_addr *)&aggrp->lg_addr) == 0) && (ntohs(lacp->partner_info.system_priority) == aggrp->aggr.ActorSystemPriority) && (ntohs(lacp->partner_info.key) == pl->ActorOperPortKey) &&
--- a/usr/src/uts/common/io/aggr/aggr_port.c Thu Sep 20 00:59:05 2007 -0700 +++ b/usr/src/uts/common/io/aggr/aggr_port.c Thu Sep 20 01:07:16 2007 -0700 @@ -36,6 +36,7 @@ #include <sys/sysmacros.h> #include <sys/conf.h> #include <sys/cmn_err.h> +#include <sys/id_space.h> #include <sys/list.h> #include <sys/ksynch.h> #include <sys/kmem.h> @@ -52,6 +53,8 @@ #include <sys/aggr_impl.h> static kmem_cache_t *aggr_port_cache; +static id_space_t *aggr_portids; + static void aggr_port_notify_cb(void *, mac_notify_type_t); /*ARGSUSED*/ @@ -81,6 +84,14 @@ aggr_port_cache = kmem_cache_create("aggr_port_cache", sizeof (aggr_port_t), 0, aggr_port_constructor, aggr_port_destructor, NULL, NULL, NULL, 0); + + /* + * Allocate a id space to manage port identification. The range of + * the arena will be from 1 to UINT16_MAX, because the LACP protocol + * uses it to be a 16 bits unique identfication. + */ + aggr_portids = id_space_create("aggr_portids", 1, UINT16_MAX); + ASSERT(aggr_portids != NULL); } void @@ -92,6 +103,7 @@ * ports when this function is invoked. */ kmem_cache_destroy(aggr_port_cache); + id_space_destroy(aggr_portids); } mac_resource_handle_t @@ -120,6 +132,7 @@ int err; mac_handle_t mh; aggr_port_t *port; + uint16_t portid; uint_t i; const mac_info_t *mip; char driver[MAXNAMELEN]; @@ -139,7 +152,13 @@ return (EINVAL); } + if ((portid = (uint16_t)id_alloc(aggr_portids)) == 0) { + mac_close(mh); + return (ENOMEM); + } + if (!mac_active_set(mh)) { + id_free(aggr_portids, portid); mac_close(mh); return (EBUSY); } @@ -167,6 +186,7 @@ port->lp_started = B_FALSE; port->lp_tx_enabled = B_FALSE; port->lp_promisc_on = B_FALSE; + port->lp_portid = portid; /* * Save the current statistics of the port. They will be used @@ -215,6 +235,8 @@ if (port->lp_grp != NULL) AGGR_GRP_REFRELE(port->lp_grp); port->lp_grp = NULL; + id_free(aggr_portids, port->lp_portid); + port->lp_portid = 0; kmem_cache_free(aggr_port_cache, port); } @@ -336,10 +358,8 @@ * the group, update the MAC address of the constituent * ports. */ - if (mac_addr_changed) { - link_state_changed = link_state_changed || - aggr_grp_update_ports_mac(grp); - } + if (mac_addr_changed && aggr_grp_update_ports_mac(grp)) + link_state_changed = B_TRUE; done: *mac_addr_changedp = mac_addr_changed;
--- a/usr/src/uts/common/io/dls/dls.c Thu Sep 20 00:59:05 2007 -0700 +++ b/usr/src/uts/common/io/dls/dls.c Thu Sep 20 01:07:16 2007 -0700 @@ -458,8 +458,7 @@ * with the same dls_link_t. */ mutex_enter(&dlp->dl_promisc_lock); - if (dlp->dl_npromisc == 0 && - (flags & (DLS_PROMISC_MULTI|DLS_PROMISC_PHYS))) { + if ((dlp->dl_npromisc == 0) && (flags & DLS_PROMISC_PHYS)) { ASSERT(dlp->dl_mth == NULL); dlp->dl_mth = mac_txloop_add(dlp->dl_mh, dlp->dl_txloop, dlp); } @@ -469,19 +468,19 @@ */ if (flags & DLS_PROMISC_MULTI) { if (!(dip->di_promisc & DLS_PROMISC_MULTI)) { - err = mac_promisc_set(dip->di_mh, B_TRUE, MAC_PROMISC); - if (err != 0) + if ((err = mac_promisc_set(dip->di_mh, B_TRUE, + MAC_DEVPROMISC)) != 0) { goto done; + } dip->di_promisc |= DLS_PROMISC_MULTI; - dlp->dl_npromisc++; } } else { if (dip->di_promisc & DLS_PROMISC_MULTI) { - err = mac_promisc_set(dip->di_mh, B_FALSE, MAC_PROMISC); - if (err != 0) + if ((err = mac_promisc_set(dip->di_mh, B_FALSE, + MAC_DEVPROMISC)) != 0) { goto done; + } dip->di_promisc &= ~DLS_PROMISC_MULTI; - dlp->dl_npromisc--; } }
--- a/usr/src/uts/common/io/sundlpi.c Thu Sep 20 00:59:05 2007 -0700 +++ b/usr/src/uts/common/io/sundlpi.c Thu Sep 20 01:07:16 2007 -0700 @@ -2,9 +2,8 @@ * CDDL HEADER START * * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. @@ -20,7 +19,7 @@ * CDDL HEADER END */ /* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -134,7 +133,7 @@ dlp->uderror_ind.dl_unix_errno = unix_errno; dlp->uderror_ind.dl_errno = error; bcopy((caddr_t)buf, - (caddr_t)(mp->b_rptr + sizeof (dl_uderror_ind_t)), addrlen); + (caddr_t)(mp->b_rptr + sizeof (dl_uderror_ind_t)), addrlen); qreply(wq, mp); } @@ -189,7 +188,7 @@ { union DL_primitives *dlp; - if ((mp = mexchange(wq, mp, sizeof (dl_ok_ack_t), M_PROTO, + if ((mp = mexchange(wq, mp, sizeof (dl_notify_ack_t), M_PROTO, DL_NOTIFY_ACK)) == NULL) return; dlp = (union DL_primitives *)mp->b_rptr;
--- a/usr/src/uts/common/sys/aggr_impl.h Thu Sep 20 00:59:05 2007 -0700 +++ b/usr/src/uts/common/sys/aggr_impl.h Thu Sep 20 01:07:16 2007 -0700 @@ -19,7 +19,7 @@ * CDDL HEADER END */ /* - * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -56,6 +56,7 @@ struct aggr_port_s *lp_next; struct aggr_grp_s *lp_grp; /* back ptr to group */ char lp_devname[MAXNAMELEN + 1]; + uint16_t lp_portid; uint8_t lp_addr[ETHERADDRL]; /* port MAC address */ uint32_t lp_refs; /* refcount */ aggr_port_state_t lp_state;