Deleted Added
full compact
sctp_pcb.c (163974) sctp_pcb.c (163996)
1/*-
2 * Copyright (c) 2001-2006, Cisco Systems, Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 *
7 * a) Redistributions of source code must retain the above copyright notice,
8 * this list of conditions and the following disclaimer.

--- 17 unchanged lines hidden (view full) ---

26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
28 * THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31/* $KAME: sctp_pcb.c,v 1.38 2005/03/06 16:04:18 itojun Exp $ */
32
33#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2001-2006, Cisco Systems, Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 *
7 * a) Redistributions of source code must retain the above copyright notice,
8 * this list of conditions and the following disclaimer.

--- 17 unchanged lines hidden (view full) ---

26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
28 * THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31/* $KAME: sctp_pcb.c,v 1.38 2005/03/06 16:04:18 itojun Exp $ */
32
33#include <sys/cdefs.h>
34__FBSDID("$FreeBSD: head/sys/netinet/sctp_pcb.c 163974 2006-11-04 05:39:39Z jb $");
34__FBSDID("$FreeBSD: head/sys/netinet/sctp_pcb.c 163996 2006-11-05 13:25:18Z rrs $");
35
36#include "opt_ipsec.h"
37#include "opt_compat.h"
38#include "opt_inet6.h"
39#include "opt_inet.h"
40#include "opt_sctp.h"
41
42#include <sys/param.h>

--- 3343 unchanged lines hidden (view full) ---

3386 * lock exchange below to grab all the locks to do the final take
3387 * out. to prevent this we increment the count, which will start a
3388 * timer and blow out above thus assuring us that we hold exclusive
3389 * killing of the asoc. Note that after getting back the TCB lock we
3390 * will go ahead and increment the counter back up and stop any
3391 * timer a passing stranger may have started :-S
3392 */
3393 if (from_inpcbfree == 0) {
35
36#include "opt_ipsec.h"
37#include "opt_compat.h"
38#include "opt_inet6.h"
39#include "opt_inet.h"
40#include "opt_sctp.h"
41
42#include <sys/param.h>

--- 3343 unchanged lines hidden (view full) ---

3386 * lock exchange below to grab all the locks to do the final take
3387 * out. to prevent this we increment the count, which will start a
3388 * timer and blow out above thus assuring us that we hold exclusive
3389 * killing of the asoc. Note that after getting back the TCB lock we
3390 * will go ahead and increment the counter back up and stop any
3391 * timer a passing stranger may have started :-S
3392 */
3393 if (from_inpcbfree == 0) {
3394 atomic_add_16(&stcb->asoc.refcnt, 1);
3394 atomic_add_int(&stcb->asoc.refcnt, 1);
3395
3396 SCTP_TCB_UNLOCK(stcb);
3397
3398 SCTP_ITERATOR_LOCK();
3399 SCTP_INP_INFO_WLOCK();
3400 SCTP_INP_WLOCK(inp);
3401 SCTP_TCB_LOCK(stcb);
3402 }
3403 /* Stop any timer someone may have started */
3404 callout_stop(&asoc->strreset_timer.timer);
3405 /*
3406 * Make it invalid too, that way if its about to run it will abort
3407 * and return.
3408 */
3409 asoc->strreset_timer.type = SCTP_TIMER_TYPE_NONE;
3410 sctp_iterator_asoc_being_freed(inp, stcb);
3411 /* re-increment the lock */
3412 if (from_inpcbfree == 0) {
3395
3396 SCTP_TCB_UNLOCK(stcb);
3397
3398 SCTP_ITERATOR_LOCK();
3399 SCTP_INP_INFO_WLOCK();
3400 SCTP_INP_WLOCK(inp);
3401 SCTP_TCB_LOCK(stcb);
3402 }
3403 /* Stop any timer someone may have started */
3404 callout_stop(&asoc->strreset_timer.timer);
3405 /*
3406 * Make it invalid too, that way if its about to run it will abort
3407 * and return.
3408 */
3409 asoc->strreset_timer.type = SCTP_TIMER_TYPE_NONE;
3410 sctp_iterator_asoc_being_freed(inp, stcb);
3411 /* re-increment the lock */
3412 if (from_inpcbfree == 0) {
3413 atomic_add_16(&stcb->asoc.refcnt, -1);
3413 atomic_add_int(&stcb->asoc.refcnt, -1);
3414 }
3415 /* now restop the timers to be sure - this is paranoia at is finest! */
3416 callout_stop(&asoc->hb_timer.timer);
3417 callout_stop(&asoc->dack_timer.timer);
3418 callout_stop(&asoc->strreset_timer.timer);
3419 callout_stop(&asoc->asconf_timer.timer);
3420 callout_stop(&asoc->shut_guard_timer.timer);
3421 callout_stop(&asoc->autoclose_timer.timer);

--- 952 unchanged lines hidden (view full) ---

4374 stcb->asoc.ecn_allowed = 0;
4375 TAILQ_FOREACH(net, &stcb->asoc.nets, sctp_next) {
4376 /* mark all addresses that we have currently on the list */
4377 net->dest_state |= SCTP_ADDR_NOT_IN_ASSOC;
4378 }
4379 /* does the source address already exist? if so skip it */
4380 l_inp = inp = stcb->sctp_ep;
4381
3414 }
3415 /* now restop the timers to be sure - this is paranoia at is finest! */
3416 callout_stop(&asoc->hb_timer.timer);
3417 callout_stop(&asoc->dack_timer.timer);
3418 callout_stop(&asoc->strreset_timer.timer);
3419 callout_stop(&asoc->asconf_timer.timer);
3420 callout_stop(&asoc->shut_guard_timer.timer);
3421 callout_stop(&asoc->autoclose_timer.timer);

--- 952 unchanged lines hidden (view full) ---

4374 stcb->asoc.ecn_allowed = 0;
4375 TAILQ_FOREACH(net, &stcb->asoc.nets, sctp_next) {
4376 /* mark all addresses that we have currently on the list */
4377 net->dest_state |= SCTP_ADDR_NOT_IN_ASSOC;
4378 }
4379 /* does the source address already exist? if so skip it */
4380 l_inp = inp = stcb->sctp_ep;
4381
4382 atomic_add_16(&stcb->asoc.refcnt, 1);
4382 atomic_add_int(&stcb->asoc.refcnt, 1);
4383 stcb_tmp = sctp_findassociation_ep_addr(&inp, sa, &net_tmp, local_sa, stcb);
4383 stcb_tmp = sctp_findassociation_ep_addr(&inp, sa, &net_tmp, local_sa, stcb);
4384 atomic_add_16(&stcb->asoc.refcnt, -1);
4384 atomic_add_int(&stcb->asoc.refcnt, -1);
4385
4386 if ((stcb_tmp == NULL && inp == stcb->sctp_ep) || inp == NULL) {
4387 /* we must add the source address */
4388 /* no scope set here since we have a tcb already. */
4389 if ((sa->sa_family == AF_INET) &&
4390 (stcb->asoc.ipv4_addr_legal)) {
4391 if (sctp_add_remote_addr(stcb, sa, 0, 2)) {
4392 return (-1);

--- 42 unchanged lines hidden (view full) ---

4435 if (plen != sizeof(struct sctp_ipv4addr_param) ||
4436 phdr == NULL) {
4437 return (-5);
4438 }
4439 p4 = (struct sctp_ipv4addr_param *)phdr;
4440 sin.sin_addr.s_addr = p4->addr;
4441 sa = (struct sockaddr *)&sin;
4442 inp = stcb->sctp_ep;
4385
4386 if ((stcb_tmp == NULL && inp == stcb->sctp_ep) || inp == NULL) {
4387 /* we must add the source address */
4388 /* no scope set here since we have a tcb already. */
4389 if ((sa->sa_family == AF_INET) &&
4390 (stcb->asoc.ipv4_addr_legal)) {
4391 if (sctp_add_remote_addr(stcb, sa, 0, 2)) {
4392 return (-1);

--- 42 unchanged lines hidden (view full) ---

4435 if (plen != sizeof(struct sctp_ipv4addr_param) ||
4436 phdr == NULL) {
4437 return (-5);
4438 }
4439 p4 = (struct sctp_ipv4addr_param *)phdr;
4440 sin.sin_addr.s_addr = p4->addr;
4441 sa = (struct sockaddr *)&sin;
4442 inp = stcb->sctp_ep;
4443 atomic_add_16(&stcb->asoc.refcnt, 1);
4443 atomic_add_int(&stcb->asoc.refcnt, 1);
4444 stcb_tmp = sctp_findassociation_ep_addr(&inp, sa, &net,
4445 local_sa, stcb);
4444 stcb_tmp = sctp_findassociation_ep_addr(&inp, sa, &net,
4445 local_sa, stcb);
4446 atomic_add_16(&stcb->asoc.refcnt, -1);
4446 atomic_add_int(&stcb->asoc.refcnt, -1);
4447
4448 if ((stcb_tmp == NULL && inp == stcb->sctp_ep) ||
4449 inp == NULL) {
4450 /* we must add the source address */
4451 /*
4452 * no scope set since we have a tcb
4453 * already
4454 */

--- 42 unchanged lines hidden (view full) ---

4497 phdr == NULL) {
4498 return (-14);
4499 }
4500 p6 = (struct sctp_ipv6addr_param *)phdr;
4501 memcpy((caddr_t)&sin6.sin6_addr, p6->addr,
4502 sizeof(p6->addr));
4503 sa = (struct sockaddr *)&sin6;
4504 inp = stcb->sctp_ep;
4447
4448 if ((stcb_tmp == NULL && inp == stcb->sctp_ep) ||
4449 inp == NULL) {
4450 /* we must add the source address */
4451 /*
4452 * no scope set since we have a tcb
4453 * already
4454 */

--- 42 unchanged lines hidden (view full) ---

4497 phdr == NULL) {
4498 return (-14);
4499 }
4500 p6 = (struct sctp_ipv6addr_param *)phdr;
4501 memcpy((caddr_t)&sin6.sin6_addr, p6->addr,
4502 sizeof(p6->addr));
4503 sa = (struct sockaddr *)&sin6;
4504 inp = stcb->sctp_ep;
4505 atomic_add_16(&stcb->asoc.refcnt, 1);
4505 atomic_add_int(&stcb->asoc.refcnt, 1);
4506 stcb_tmp = sctp_findassociation_ep_addr(&inp, sa, &net,
4507 local_sa, stcb);
4506 stcb_tmp = sctp_findassociation_ep_addr(&inp, sa, &net,
4507 local_sa, stcb);
4508 atomic_add_16(&stcb->asoc.refcnt, -1);
4508 atomic_add_int(&stcb->asoc.refcnt, -1);
4509 if (stcb_tmp == NULL && (inp == stcb->sctp_ep ||
4510 inp == NULL)) {
4511 /*
4512 * we must validate the state again
4513 * here
4514 */
4515 if (stcb->asoc.state == 0) {
4516 /* the assoc was freed? */

--- 767 unchanged lines hidden ---
4509 if (stcb_tmp == NULL && (inp == stcb->sctp_ep ||
4510 inp == NULL)) {
4511 /*
4512 * we must validate the state again
4513 * here
4514 */
4515 if (stcb->asoc.state == 0) {
4516 /* the assoc was freed? */

--- 767 unchanged lines hidden ---