tcp_subr.c (d4c22202e61fe1c5cad7120ddb56d095cecf3472) tcp_subr.c (587d67c008444a7d35d918763708b7aba40a9509)
1/*-
2 * Copyright (c) 1982, 1986, 1988, 1990, 1993, 1995
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

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

1182 /* Initialise cc_var struct for this tcpcb. */
1183 tp->ccv = &tm->ccv;
1184 tp->ccv->type = IPPROTO_TCP;
1185 tp->ccv->ccvc.tcp = tp;
1186 rw_rlock(&tcp_function_lock);
1187 tp->t_fb = tcp_func_set_ptr;
1188 refcount_acquire(&tp->t_fb->tfb_refcnt);
1189 rw_runlock(&tcp_function_lock);
1/*-
2 * Copyright (c) 1982, 1986, 1988, 1990, 1993, 1995
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

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

1182 /* Initialise cc_var struct for this tcpcb. */
1183 tp->ccv = &tm->ccv;
1184 tp->ccv->type = IPPROTO_TCP;
1185 tp->ccv->ccvc.tcp = tp;
1186 rw_rlock(&tcp_function_lock);
1187 tp->t_fb = tcp_func_set_ptr;
1188 refcount_acquire(&tp->t_fb->tfb_refcnt);
1189 rw_runlock(&tcp_function_lock);
1190 if (tp->t_fb->tfb_tcp_fb_init) {
1191 (*tp->t_fb->tfb_tcp_fb_init)(tp);
1192 }
1193 /*
1194 * Use the current system default CC algorithm.
1195 */
1196 CC_LIST_RLOCK();
1197 KASSERT(!STAILQ_EMPTY(&cc_list), ("cc_list is empty!"));
1198 CC_ALGO(tp) = CC_DEFAULT();
1199 CC_LIST_RUNLOCK();
1200
1201 if (CC_ALGO(tp)->cb_init != NULL)
1202 if (CC_ALGO(tp)->cb_init(tp->ccv) > 0) {
1203 if (tp->t_fb->tfb_tcp_fb_fini)
1190 /*
1191 * Use the current system default CC algorithm.
1192 */
1193 CC_LIST_RLOCK();
1194 KASSERT(!STAILQ_EMPTY(&cc_list), ("cc_list is empty!"));
1195 CC_ALGO(tp) = CC_DEFAULT();
1196 CC_LIST_RUNLOCK();
1197
1198 if (CC_ALGO(tp)->cb_init != NULL)
1199 if (CC_ALGO(tp)->cb_init(tp->ccv) > 0) {
1200 if (tp->t_fb->tfb_tcp_fb_fini)
1204 (*tp->t_fb->tfb_tcp_fb_fini)(tp);
1201 (*tp->t_fb->tfb_tcp_fb_fini)(tp, 1);
1205 refcount_release(&tp->t_fb->tfb_refcnt);
1206 uma_zfree(V_tcpcb_zone, tm);
1207 return (NULL);
1208 }
1209
1210 tp->osd = &tm->osd;
1211 if (khelp_init_osd(HELPER_CLASS_TCP, tp->osd)) {
1212 if (tp->t_fb->tfb_tcp_fb_fini)
1202 refcount_release(&tp->t_fb->tfb_refcnt);
1203 uma_zfree(V_tcpcb_zone, tm);
1204 return (NULL);
1205 }
1206
1207 tp->osd = &tm->osd;
1208 if (khelp_init_osd(HELPER_CLASS_TCP, tp->osd)) {
1209 if (tp->t_fb->tfb_tcp_fb_fini)
1213 (*tp->t_fb->tfb_tcp_fb_fini)(tp);
1210 (*tp->t_fb->tfb_tcp_fb_fini)(tp, 1);
1214 refcount_release(&tp->t_fb->tfb_refcnt);
1215 uma_zfree(V_tcpcb_zone, tm);
1216 return (NULL);
1217 }
1218
1219#ifdef VIMAGE
1220 tp->t_vnet = inp->inp_vnet;
1221#endif

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

1266 inp->inp_ip_ttl = V_ip_defttl;
1267 inp->inp_ppcb = tp;
1268#ifdef TCPPCAP
1269 /*
1270 * Init the TCP PCAP queues.
1271 */
1272 tcp_pcap_tcpcb_init(tp);
1273#endif
1211 refcount_release(&tp->t_fb->tfb_refcnt);
1212 uma_zfree(V_tcpcb_zone, tm);
1213 return (NULL);
1214 }
1215
1216#ifdef VIMAGE
1217 tp->t_vnet = inp->inp_vnet;
1218#endif

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

1263 inp->inp_ip_ttl = V_ip_defttl;
1264 inp->inp_ppcb = tp;
1265#ifdef TCPPCAP
1266 /*
1267 * Init the TCP PCAP queues.
1268 */
1269 tcp_pcap_tcpcb_init(tp);
1270#endif
1271 if (tp->t_fb->tfb_tcp_fb_init) {
1272 (*tp->t_fb->tfb_tcp_fb_init)(tp);
1273 }
1274 return (tp); /* XXX */
1275}
1276
1277/*
1278 * Switch the congestion control algorithm back to NewReno for any active
1279 * control blocks using an algorithm which is about to go away.
1280 * This ensures the CC framework can allow the unload to proceed without leaving
1281 * any dangling pointers which would trigger a panic.

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

1479
1480 khelp_destroy_osd(tp->osd);
1481
1482 CC_ALGO(tp) = NULL;
1483 inp->inp_ppcb = NULL;
1484 if (tp->t_timers->tt_draincnt == 0) {
1485 /* We own the last reference on tcpcb, let's free it. */
1486 if (tp->t_fb->tfb_tcp_fb_fini)
1274 return (tp); /* XXX */
1275}
1276
1277/*
1278 * Switch the congestion control algorithm back to NewReno for any active
1279 * control blocks using an algorithm which is about to go away.
1280 * This ensures the CC framework can allow the unload to proceed without leaving
1281 * any dangling pointers which would trigger a panic.

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

1479
1480 khelp_destroy_osd(tp->osd);
1481
1482 CC_ALGO(tp) = NULL;
1483 inp->inp_ppcb = NULL;
1484 if (tp->t_timers->tt_draincnt == 0) {
1485 /* We own the last reference on tcpcb, let's free it. */
1486 if (tp->t_fb->tfb_tcp_fb_fini)
1487 (*tp->t_fb->tfb_tcp_fb_fini)(tp);
1487 (*tp->t_fb->tfb_tcp_fb_fini)(tp, 1);
1488 refcount_release(&tp->t_fb->tfb_refcnt);
1489 tp->t_inpcb = NULL;
1490 uma_zfree(V_tcpcb_zone, tp);
1491 released = in_pcbrele_wlocked(inp);
1492 KASSERT(!released, ("%s: inp %p should not have been released "
1493 "here", __func__, inp));
1494 }
1495}

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

1508 __func__, tp));
1509 INP_WLOCK(inp);
1510 KASSERT((tp->t_timers->tt_flags & TT_STOPPED) != 0,
1511 ("%s: tcpcb has to be stopped here", __func__));
1512 tp->t_timers->tt_draincnt--;
1513 if (tp->t_timers->tt_draincnt == 0) {
1514 /* We own the last reference on this tcpcb, let's free it. */
1515 if (tp->t_fb->tfb_tcp_fb_fini)
1488 refcount_release(&tp->t_fb->tfb_refcnt);
1489 tp->t_inpcb = NULL;
1490 uma_zfree(V_tcpcb_zone, tp);
1491 released = in_pcbrele_wlocked(inp);
1492 KASSERT(!released, ("%s: inp %p should not have been released "
1493 "here", __func__, inp));
1494 }
1495}

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

1508 __func__, tp));
1509 INP_WLOCK(inp);
1510 KASSERT((tp->t_timers->tt_flags & TT_STOPPED) != 0,
1511 ("%s: tcpcb has to be stopped here", __func__));
1512 tp->t_timers->tt_draincnt--;
1513 if (tp->t_timers->tt_draincnt == 0) {
1514 /* We own the last reference on this tcpcb, let's free it. */
1515 if (tp->t_fb->tfb_tcp_fb_fini)
1516 (*tp->t_fb->tfb_tcp_fb_fini)(tp);
1516 (*tp->t_fb->tfb_tcp_fb_fini)(tp, 1);
1517 refcount_release(&tp->t_fb->tfb_refcnt);
1518 tp->t_inpcb = NULL;
1519 uma_zfree(V_tcpcb_zone, tp);
1520 if (in_pcbrele_wlocked(inp)) {
1521 INP_INFO_RUNLOCK(&V_tcbinfo);
1522 CURVNET_RESTORE();
1523 return;
1524 }

--- 1569 unchanged lines hidden ---
1517 refcount_release(&tp->t_fb->tfb_refcnt);
1518 tp->t_inpcb = NULL;
1519 uma_zfree(V_tcpcb_zone, tp);
1520 if (in_pcbrele_wlocked(inp)) {
1521 INP_INFO_RUNLOCK(&V_tcbinfo);
1522 CURVNET_RESTORE();
1523 return;
1524 }

--- 1569 unchanged lines hidden ---