Deleted Added
full compact
sctp_timer.c (197288) sctp_timer.c (208160)
1/*-
2 * Copyright (c) 2001-2007, by 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_timer.c,v 1.29 2005/03/06 16:04:18 itojun Exp $ */
32
33#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2001-2007, by 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_timer.c,v 1.29 2005/03/06 16:04:18 itojun Exp $ */
32
33#include <sys/cdefs.h>
34__FBSDID("$FreeBSD: head/sys/netinet/sctp_timer.c 197288 2009-09-17 15:11:12Z rrs $");
34__FBSDID("$FreeBSD: head/sys/netinet/sctp_timer.c 208160 2010-05-16 17:03:56Z rrs $");
35
36#define _IP_VHL
37#include <netinet/sctp_os.h>
38#include <netinet/sctp_pcb.h>
39#ifdef INET6
40#endif
41#include <netinet/sctp_var.h>
42#include <netinet/sctp_sysctl.h>

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

1875 asoc->sctp_autoclose_ticks -= ticks_gone_by;
1876 sctp_timer_start(SCTP_TIMER_TYPE_AUTOCLOSE, inp, stcb,
1877 net);
1878 /* restore the real tick value */
1879 asoc->sctp_autoclose_ticks = tmp;
1880 }
1881 }
1882}
35
36#define _IP_VHL
37#include <netinet/sctp_os.h>
38#include <netinet/sctp_pcb.h>
39#ifdef INET6
40#endif
41#include <netinet/sctp_var.h>
42#include <netinet/sctp_sysctl.h>

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

1875 asoc->sctp_autoclose_ticks -= ticks_gone_by;
1876 sctp_timer_start(SCTP_TIMER_TYPE_AUTOCLOSE, inp, stcb,
1877 net);
1878 /* restore the real tick value */
1879 asoc->sctp_autoclose_ticks = tmp;
1880 }
1881 }
1882}
1883
1884void
1885sctp_iterator_timer(struct sctp_iterator *it)
1886{
1887 int iteration_count = 0;
1888 int inp_skip = 0;
1889
1890 /*
1891 * only one iterator can run at a time. This is the only way we can
1892 * cleanly pull ep's from underneath all the running interators when
1893 * a ep is freed.
1894 */
1895 SCTP_ITERATOR_LOCK();
1896 if (it->inp == NULL) {
1897 /* iterator is complete */
1898done_with_iterator:
1899 SCTP_ITERATOR_UNLOCK();
1900 SCTP_INP_INFO_WLOCK();
1901 TAILQ_REMOVE(&SCTP_BASE_INFO(iteratorhead), it, sctp_nxt_itr);
1902 /* stopping the callout is not needed, in theory */
1903 SCTP_INP_INFO_WUNLOCK();
1904 (void)SCTP_OS_TIMER_STOP(&it->tmr.timer);
1905 if (it->function_atend != NULL) {
1906 (*it->function_atend) (it->pointer, it->val);
1907 }
1908 SCTP_FREE(it, SCTP_M_ITER);
1909 return;
1910 }
1911select_a_new_ep:
1912 SCTP_INP_WLOCK(it->inp);
1913 while (((it->pcb_flags) &&
1914 ((it->inp->sctp_flags & it->pcb_flags) != it->pcb_flags)) ||
1915 ((it->pcb_features) &&
1916 ((it->inp->sctp_features & it->pcb_features) != it->pcb_features))) {
1917 /* endpoint flags or features don't match, so keep looking */
1918 if (it->iterator_flags & SCTP_ITERATOR_DO_SINGLE_INP) {
1919 SCTP_INP_WUNLOCK(it->inp);
1920 goto done_with_iterator;
1921 }
1922 SCTP_INP_WUNLOCK(it->inp);
1923 it->inp = LIST_NEXT(it->inp, sctp_list);
1924 if (it->inp == NULL) {
1925 goto done_with_iterator;
1926 }
1927 SCTP_INP_WLOCK(it->inp);
1928 }
1929 if ((it->inp->inp_starting_point_for_iterator != NULL) &&
1930 (it->inp->inp_starting_point_for_iterator != it)) {
1931 SCTP_PRINTF("Iterator collision, waiting for one at %p\n",
1932 it->inp);
1933 SCTP_INP_WUNLOCK(it->inp);
1934 goto start_timer_return;
1935 }
1936 /* mark the current iterator on the endpoint */
1937 it->inp->inp_starting_point_for_iterator = it;
1938 SCTP_INP_WUNLOCK(it->inp);
1939 SCTP_INP_RLOCK(it->inp);
1940 /* now go through each assoc which is in the desired state */
1941 if (it->done_current_ep == 0) {
1942 if (it->function_inp != NULL)
1943 inp_skip = (*it->function_inp) (it->inp, it->pointer, it->val);
1944 it->done_current_ep = 1;
1945 }
1946 if (it->stcb == NULL) {
1947 /* run the per instance function */
1948 it->stcb = LIST_FIRST(&it->inp->sctp_asoc_list);
1949 }
1950 SCTP_INP_RUNLOCK(it->inp);
1951 if ((inp_skip) || it->stcb == NULL) {
1952 if (it->function_inp_end != NULL) {
1953 inp_skip = (*it->function_inp_end) (it->inp,
1954 it->pointer,
1955 it->val);
1956 }
1957 goto no_stcb;
1958 }
1959 if ((it->stcb) &&
1960 (it->stcb->asoc.stcb_starting_point_for_iterator == it)) {
1961 it->stcb->asoc.stcb_starting_point_for_iterator = NULL;
1962 }
1963 while (it->stcb) {
1964 SCTP_TCB_LOCK(it->stcb);
1965 if (it->asoc_state && ((it->stcb->asoc.state & it->asoc_state) != it->asoc_state)) {
1966 /* not in the right state... keep looking */
1967 SCTP_TCB_UNLOCK(it->stcb);
1968 goto next_assoc;
1969 }
1970 /* mark the current iterator on the assoc */
1971 it->stcb->asoc.stcb_starting_point_for_iterator = it;
1972 /* see if we have limited out the iterator loop */
1973 iteration_count++;
1974 if (iteration_count > SCTP_ITERATOR_MAX_AT_ONCE) {
1975 start_timer_return:
1976 /* set a timer to continue this later */
1977 if (it->stcb)
1978 SCTP_TCB_UNLOCK(it->stcb);
1979 sctp_timer_start(SCTP_TIMER_TYPE_ITERATOR,
1980 (struct sctp_inpcb *)it, NULL, NULL);
1981 SCTP_ITERATOR_UNLOCK();
1982 return;
1983 }
1984 /* run function on this one */
1985 (*it->function_assoc) (it->inp, it->stcb, it->pointer, it->val);
1986
1987 /*
1988 * we lie here, it really needs to have its own type but
1989 * first I must verify that this won't effect things :-0
1990 */
1991 if (it->no_chunk_output == 0)
1992 sctp_chunk_output(it->inp, it->stcb, SCTP_OUTPUT_FROM_T3, SCTP_SO_NOT_LOCKED);
1993
1994 SCTP_TCB_UNLOCK(it->stcb);
1995next_assoc:
1996 it->stcb = LIST_NEXT(it->stcb, sctp_tcblist);
1997 if (it->stcb == NULL) {
1998 if (it->function_inp_end != NULL) {
1999 inp_skip = (*it->function_inp_end) (it->inp,
2000 it->pointer,
2001 it->val);
2002 }
2003 }
2004 }
2005no_stcb:
2006 /* done with all assocs on this endpoint, move on to next endpoint */
2007 it->done_current_ep = 0;
2008 SCTP_INP_WLOCK(it->inp);
2009 it->inp->inp_starting_point_for_iterator = NULL;
2010 SCTP_INP_WUNLOCK(it->inp);
2011 if (it->iterator_flags & SCTP_ITERATOR_DO_SINGLE_INP) {
2012 it->inp = NULL;
2013 } else {
2014 SCTP_INP_INFO_RLOCK();
2015 it->inp = LIST_NEXT(it->inp, sctp_list);
2016 SCTP_INP_INFO_RUNLOCK();
2017 }
2018 if (it->inp == NULL) {
2019 goto done_with_iterator;
2020 }
2021 goto select_a_new_ep;
2022}