---------------------------------------------------------------------- r14776: kmacy | 2008-03-26 11:08:52 -0700 add inp_apply_all function to safely apply a function to all inpcbs in the global list ---------------------------------------------------------------------- === local/iwarp_crash_fix/sys/dev/cxgb/ulp/tom/cxgb_tom.c ================================================================== --- local/iwarp_crash_fix/sys/dev/cxgb/ulp/tom/cxgb_tom.c (revision 14775) +++ local/iwarp_crash_fix/sys/dev/cxgb/ulp/tom/cxgb_tom.c (revision 14776) @@ -88,6 +88,7 @@ #include #include #include +#include @@ -1395,19 +1396,19 @@ } static void +cxgb_toe_listen_start_handler(struct inpcb *inp, void *arg) +{ + struct tcpcb *tp = intotcpcb(inp); + + if (tp->t_state == TCPS_LISTEN) + cxgb_toe_listen_start(NULL, tp); +} + +static void cxgb_register_listeners(void) { - struct inpcb *inp; - struct tcpcb *tp; - - INP_INFO_RLOCK(&tcbinfo); - LIST_FOREACH(inp, tcbinfo.ipi_listhead, inp_list) { - tp = intotcpcb(inp); - if (tp->t_state == TCPS_LISTEN) - cxgb_toe_listen_start(NULL, tp); - } - INP_INFO_RUNLOCK(&tcbinfo); + inp_apply_all(cxgb_toe_listen_start_handler, NULL); } static int === local/iwarp_crash_fix/sys/dev/cxgb/ulp/tom/cxgb_tcp_offload.c ================================================================== --- local/iwarp_crash_fix/sys/dev/cxgb/ulp/tom/cxgb_tcp_offload.c (revision 14775) +++ local/iwarp_crash_fix/sys/dev/cxgb/ulp/tom/cxgb_tcp_offload.c (revision 14776) @@ -94,3 +94,17 @@ return (tp); } + +void +inp_apply_all(void (*func)(struct inpcb *, void *), void *arg) +{ + struct inpcb *inp; + + INP_INFO_RLOCK(&tcbinfo); + LIST_FOREACH(inp, tcbinfo.ipi_listhead, inp_list) { + INP_LOCK(inp); + func(inp, arg); + INP_UNLOCK(inp); + } + INP_INFO_RUNLOCK(&tcbinfo); +} === local/iwarp_crash_fix/sys/dev/cxgb/ulp/tom/cxgb_tcp_offload.h ================================================================== --- local/iwarp_crash_fix/sys/dev/cxgb/ulp/tom/cxgb_tcp_offload.h (revision 14775) +++ local/iwarp_crash_fix/sys/dev/cxgb/ulp/tom/cxgb_tcp_offload.h (revision 14776) @@ -5,4 +5,7 @@ struct tcpcb *tcp_offload_close(struct tcpcb *tp); struct tcpcb *tcp_offload_drop(struct tcpcb *tp, int error); +void inp_apply_all(void (*func)(struct inpcb *, void *), void *arg); + + #endif /* CXGB_TCP_OFFLOAD_H_ */