question about freebsd sctp sctp_asconf_iterator_stcb function.
黄登辉
huangdenghui at gmail.com
Thu Feb 24 02:36:39 UTC 2011
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.
More information about the freebsd-net
mailing list