Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 10 Feb 2011 14:46:37 +0000 (UTC)
From:      Michael Tuexen <tuexen@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r218521 - head/sys/netinet
Message-ID:  <201102101446.p1AEkbCm025234@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: tuexen
Date: Thu Feb 10 14:46:37 2011
New Revision: 218521
URL: http://svn.freebsd.org/changeset/base/218521

Log:
  Remove addresses from endpoint when there are no associations.
  This fixes a bug reported by brucec@.
  
  MFC after: 3 months.

Modified:
  head/sys/netinet/sctp_asconf.c

Modified: head/sys/netinet/sctp_asconf.c
==============================================================================
--- head/sys/netinet/sctp_asconf.c	Thu Feb 10 14:29:34 2011	(r218520)
+++ head/sys/netinet/sctp_asconf.c	Thu Feb 10 14:46:37 2011	(r218521)
@@ -3104,6 +3104,7 @@ sctp_addr_mgmt_ep_sa(struct sctp_inpcb *
     uint32_t type, uint32_t vrf_id, struct sctp_ifa *sctp_ifap)
 {
 	struct sctp_ifa *ifa;
+	struct sctp_laddr *laddr, *nladdr;
 
 	if (sa->sa_len == 0) {
 		SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_ASCONF, EINVAL);
@@ -3124,8 +3125,6 @@ sctp_addr_mgmt_ep_sa(struct sctp_inpcb *
 		if (type == SCTP_ADD_IP_ADDRESS) {
 			sctp_add_local_addr_ep(inp, ifa, type);
 		} else if (type == SCTP_DEL_IP_ADDRESS) {
-			struct sctp_laddr *laddr;
-
 			if (inp->laddr_count < 2) {
 				/* can't delete the last local address */
 				SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_ASCONF, EINVAL);
@@ -3139,11 +3138,19 @@ sctp_addr_mgmt_ep_sa(struct sctp_inpcb *
 				}
 			}
 		}
-		if (!LIST_EMPTY(&inp->sctp_asoc_list)) {
+		if (LIST_EMPTY(&inp->sctp_asoc_list)) {
 			/*
 			 * There is no need to start the iterator if the inp
 			 * has no associations.
 			 */
+			if (type == SCTP_DEL_IP_ADDRESS) {
+				LIST_FOREACH_SAFE(laddr, &inp->sctp_addr_list, sctp_nxt_addr, nladdr) {
+					if (laddr->ifa == ifa) {
+						sctp_del_local_addr_ep(inp, ifa);
+					}
+				}
+			}
+		} else {
 			struct sctp_asconf_iterator *asc;
 			struct sctp_laddr *wi;
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201102101446.p1AEkbCm025234>