From owner-freebsd-net@FreeBSD.ORG Thu Feb 24 02:36:39 2011 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9F6BB1065675 for ; Thu, 24 Feb 2011 02:36:39 +0000 (UTC) (envelope-from huangdenghui@gmail.com) Received: from mail-fx0-f54.google.com (mail-fx0-f54.google.com [209.85.161.54]) by mx1.freebsd.org (Postfix) with ESMTP id 291138FC12 for ; Thu, 24 Feb 2011 02:36:38 +0000 (UTC) Received: by fxm19 with SMTP id 19so123936fxm.13 for ; Wed, 23 Feb 2011 18:36:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:date:message-id:subject:from:to :content-type; bh=XzYzosSySB5LdISI9ItZ3sF9n11DgGgu+H697aGGlc4=; b=sPIbleTGz+0NhVnJvinFVqklKv/WN6sRvmqEn5AMRpTwok7ttYhV9gqwpdPXQdNlg8 EDYaYUH5inWlV8rHCe5tekgY9vusNDGIHE1FcCt5kNhXwZvWHcz5B0PPzrFu2z8i26DH m3L8STzM7LXa5ozokHS3nh1q8dO76X9SC/yvM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=LVzQdy8pbP5V2FB02MIZNeENRsqpFFSwUt3IFLDVKn+oOFc5N0jCgcUJ5FvRiI8jfn osi9DM1L/AHt2LWt2c9qTN9dwDwayfKYprAZuHc//pMBq6zIHzVh/Ff2ndjB42IhaxQk 2Tp5Y8SGEfpTPDDeY/kJowwrvOoB94ResHo98= MIME-Version: 1.0 Received: by 10.223.111.137 with SMTP id s9mr244953fap.98.1298513396721; Wed, 23 Feb 2011 18:09:56 -0800 (PST) Received: by 10.223.102.135 with HTTP; Wed, 23 Feb 2011 18:09:56 -0800 (PST) Date: Thu, 24 Feb 2011 10:09:56 +0800 Message-ID: From: =?GB2312?B?u8a1x7vU?= To: freebsd-net@freebsd.org X-Mailman-Approved-At: Thu, 24 Feb 2011 04:03:55 +0000 Content-Type: text/plain; charset=ISO-8859-1 X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Subject: question about freebsd sctp sctp_asconf_iterator_stcb function. X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Feb 2011 02:36:39 -0000 Hi I have a little about the following code section of sctp_asconf_iterator_stcb function. if (type == SCTP_ADD_IP_ADDRESS) { /* prevent this address from being used as a source */ sctp_add_local_addr_restricted(stcb, ifa); } else if (type == SCTP_DEL_IP_ADDRESS) { struct sctp_nets *net; TAILQ_FOREACH(net, &stcb->asoc.nets, sctp_next) { sctp_rtentry_t *rt; /* delete this address if cached */ if (net->ro._s_addr == ifa) { sctp_free_ifa(net->ro._s_addr); net->ro._s_addr = NULL; net->src_addr_selected = 0; rt = net->ro.ro_rt; if (rt) { RTFREE(rt); net->ro.ro_rt = NULL; } /* * Now we deleted our src address, * should we not also now reset the * cwnd/rto to start as if its a new * address? */ stcb->asoc.cc_functions.sctp_set_initial_cc_param(stcb, net); net->RTO = 0; } } } else if (type == SCTP_SET_PRIM_ADDR) { if ((stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_BOUNDALL) == 0) { /* must validate the ifa is in the ep */ if (sctp_is_addr_in_ep(stcb->sctp_ep, ifa) == 0) { continue; } } else { /* Need to check scopes for this guy */ if (sctp_is_address_in_scope(ifa, stcb->asoc.ipv4_addr_legal, stcb->asoc.ipv6_addr_legal, stcb->asoc.loopback_scope, stcb->asoc.ipv4_local_scope, stcb->asoc.local_scope, stcb->asoc.site_scope, 0) == 0) { continue; } } } /* queue an asconf for this address add/delete */ if (sctp_is_feature_on(inp, SCTP_PCB_FLAGS_DO_ASCONF) && stcb->asoc.peer_supports_asconf) { /* queue an asconf for this addr */ status = sctp_asconf_queue_add(stcb, ifa, type); /* * if queued ok, and in the open state, update the * count of queued params. If in the non-open * state, these get sent when the assoc goes open. */ if (SCTP_GET_STATE(&stcb->asoc) == SCTP_STATE_OPEN) { if (status >= 0) { num_queued++; } } } should change like this: if (sctp_is_feature_on(inp, SCTP_PCB_FLAGS_DO_ASCONF) && stcb->asoc.peer_supports_asconf) { if (type == SCTP_ADD_IP_ADDRESS) { /* prevent this address from being used as a source */ sctp_add_local_addr_restricted(stcb, ifa); } else if (type == SCTP_DEL_IP_ADDRESS) { struct sctp_nets *net; TAILQ_FOREACH(net, &stcb->asoc.nets, sctp_next) { sctp_rtentry_t *rt; /* delete this address if cached */ if (net->ro._s_addr == ifa) { sctp_free_ifa(net->ro._s_addr); net->ro._s_addr = NULL; net->src_addr_selected = 0; rt = net->ro.ro_rt; if (rt) { RTFREE(rt); net->ro.ro_rt = NULL; } /* * Now we deleted our src address, * should we not also now reset the * cwnd/rto to start as if its a new * address? */ stcb->asoc.cc_functions.sctp_set_initial_cc_param(stcb, net); net->RTO = 0; } } } else if (type == SCTP_SET_PRIM_ADDR) { if ((stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_BOUNDALL) == 0) { /* must validate the ifa is in the ep */ if (sctp_is_addr_in_ep(stcb->sctp_ep, ifa) == 0) { continue; } } else { /* Need to check scopes for this guy */ if (sctp_is_address_in_scope(ifa, stcb->asoc.ipv4_addr_legal, stcb->asoc.ipv6_addr_legal, stcb->asoc.loopback_scope, stcb->asoc.ipv4_local_scope, stcb->asoc.local_scope, stcb->asoc.site_scope, 0) == 0) { continue; } } } /* queue an asconf for this address add/delete */ /* queue an asconf for this addr */ status = sctp_asconf_queue_add(stcb, ifa, type); /* * if queued ok, and in the open state, update the * count of queued params. If in the non-open * state, these get sent when the assoc goes open. */ if (SCTP_GET_STATE(&stcb->asoc) == SCTP_STATE_OPEN) { if (status >= 0) { num_queued++; } } } because i think put some address into restricted address list is used to dynamic address configuration. So first we need to make sure this feature SCTP_PCB_FLAGS_DO_ASCONF is on and peer endpoint also support this feature. If i am wrong, experts please give some comments.