spx_usrreq.c (139485) | spx_usrreq.c (139579) |
---|---|
1/* 2 * Copyright (c) 2004 Robert N. M. Watson 3 * Copyright (c) 1995, Mike Mitchell 4 * Copyright (c) 1984, 1985, 1986, 1987, 1993 5 * The Regents of the University of California. All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 22 unchanged lines hidden (view full) --- 31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33 * SUCH DAMAGE. 34 * 35 * @(#)spx_usrreq.h 36 */ 37 38#include <sys/cdefs.h> | 1/* 2 * Copyright (c) 2004 Robert N. M. Watson 3 * Copyright (c) 1995, Mike Mitchell 4 * Copyright (c) 1984, 1985, 1986, 1987, 1993 5 * The Regents of the University of California. All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 22 unchanged lines hidden (view full) --- 31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33 * SUCH DAMAGE. 34 * 35 * @(#)spx_usrreq.h 36 */ 37 38#include <sys/cdefs.h> |
39__FBSDID("$FreeBSD: head/sys/netipx/spx_usrreq.c 139485 2004-12-31 17:05:37Z rwatson $"); | 39__FBSDID("$FreeBSD: head/sys/netipx/spx_usrreq.c 139579 2005-01-02 14:03:47Z rwatson $"); |
40 41#include <sys/param.h> 42#include <sys/lock.h> 43#include <sys/malloc.h> 44#include <sys/mbuf.h> 45#include <sys/mutex.h> 46#include <sys/proc.h> 47#include <sys/protosw.h> --- 277 unchanged lines hidden (view full) --- 325 m->m_len -= sizeof(struct ipx); 326 m->m_pkthdr.len -= sizeof(struct ipx); 327 m->m_data += sizeof(struct ipx); 328 329 if (spx_reass(cb, si)) { 330 m_freem(m); 331 } 332 if (cb->s_force || (cb->s_flags & (SF_ACKNOW|SF_WIN|SF_RXT))) | 40 41#include <sys/param.h> 42#include <sys/lock.h> 43#include <sys/malloc.h> 44#include <sys/mbuf.h> 45#include <sys/mutex.h> 46#include <sys/proc.h> 47#include <sys/protosw.h> --- 277 unchanged lines hidden (view full) --- 325 m->m_len -= sizeof(struct ipx); 326 m->m_pkthdr.len -= sizeof(struct ipx); 327 m->m_data += sizeof(struct ipx); 328 329 if (spx_reass(cb, si)) { 330 m_freem(m); 331 } 332 if (cb->s_force || (cb->s_flags & (SF_ACKNOW|SF_WIN|SF_RXT))) |
333 spx_output(cb, (struct mbuf *)NULL); | 333 spx_output(cb, NULL); |
334 cb->s_flags &= ~(SF_WIN|SF_RXT); 335 return; 336 337dropwithreset: 338 if (dropsocket) { 339 struct socket *head; 340 ACCEPT_LOCK(); 341 KASSERT((so->so_qstate & SQ_INCOMP) != 0, --- 64 unchanged lines hidden (view full) --- 406 cb->s_dupacks = 0; 407 else if (++cb->s_dupacks == spxrexmtthresh) { 408 u_short onxt = cb->s_snxt; 409 int cwnd = cb->s_cwnd; 410 411 cb->s_snxt = si->si_ack; 412 cb->s_cwnd = CUNIT; 413 cb->s_force = 1 + SPXT_REXMT; | 334 cb->s_flags &= ~(SF_WIN|SF_RXT); 335 return; 336 337dropwithreset: 338 if (dropsocket) { 339 struct socket *head; 340 ACCEPT_LOCK(); 341 KASSERT((so->so_qstate & SQ_INCOMP) != 0, --- 64 unchanged lines hidden (view full) --- 406 cb->s_dupacks = 0; 407 else if (++cb->s_dupacks == spxrexmtthresh) { 408 u_short onxt = cb->s_snxt; 409 int cwnd = cb->s_cwnd; 410 411 cb->s_snxt = si->si_ack; 412 cb->s_cwnd = CUNIT; 413 cb->s_force = 1 + SPXT_REXMT; |
414 spx_output(cb, (struct mbuf *)NULL); | 414 spx_output(cb, NULL); |
415 cb->s_timer[SPXT_REXMT] = cb->s_rxtcur; 416 cb->s_rtt = 0; 417 if (cwnd >= 4 * CUNIT) 418 cb->s_cwnd = cwnd / 2; 419 if (SSEQ_GT(onxt, cb->s_snxt)) 420 cb->s_snxt = onxt; 421 return (1); 422 } --- 105 unchanged lines hidden (view full) --- 528 } else 529 spxstat.spxs_rcvpackafterwin++; 530 if (si->si_cc & SPX_OB) { 531 if (SSEQ_GT(si->si_seq, cb->s_alo + 60)) { 532 m_freem(dtom(si)); 533 return (0); 534 } /* else queue this packet; */ 535 } else { | 415 cb->s_timer[SPXT_REXMT] = cb->s_rxtcur; 416 cb->s_rtt = 0; 417 if (cwnd >= 4 * CUNIT) 418 cb->s_cwnd = cwnd / 2; 419 if (SSEQ_GT(onxt, cb->s_snxt)) 420 cb->s_snxt = onxt; 421 return (1); 422 } --- 105 unchanged lines hidden (view full) --- 528 } else 529 spxstat.spxs_rcvpackafterwin++; 530 if (si->si_cc & SPX_OB) { 531 if (SSEQ_GT(si->si_seq, cb->s_alo + 60)) { 532 m_freem(dtom(si)); 533 return (0); 534 } /* else queue this packet; */ 535 } else { |
536#ifdef BROKEN 537 /* 538 * XXXRW: This is broken on at least one count: 539 * spx_close() will free the ipxp and related parts, 540 * which are then touched by spx_input() after the 541 * return from spx_reass(). 542 */ |
|
536 /*register struct socket *so = cb->s_ipxpcb->ipxp_socket; 537 if (so->so_state && SS_NOFDREF) { 538 spx_close(cb); 539 } else 540 would crash system*/ | 543 /*register struct socket *so = cb->s_ipxpcb->ipxp_socket; 544 if (so->so_state && SS_NOFDREF) { 545 spx_close(cb); 546 } else 547 would crash system*/ |
548#endif |
|
541 spx_istat.notyet++; 542 m_freem(dtom(si)); 543 return (0); 544 } 545 } 546 /* 547 * If this is a system packet, we don't need to 548 * queue it up, and won't update acknowledge # --- 149 unchanged lines hidden (view full) --- 698 699static int 700spx_output(cb, m0) 701 register struct spxpcb *cb; 702 struct mbuf *m0; 703{ 704 struct socket *so = cb->s_ipxpcb->ipxp_socket; 705 register struct mbuf *m; | 549 spx_istat.notyet++; 550 m_freem(dtom(si)); 551 return (0); 552 } 553 } 554 /* 555 * If this is a system packet, we don't need to 556 * queue it up, and won't update acknowledge # --- 149 unchanged lines hidden (view full) --- 706 707static int 708spx_output(cb, m0) 709 register struct spxpcb *cb; 710 struct mbuf *m0; 711{ 712 struct socket *so = cb->s_ipxpcb->ipxp_socket; 713 register struct mbuf *m; |
706 register struct spx *si = (struct spx *)NULL; | 714 register struct spx *si = NULL; |
707 register struct sockbuf *sb = &so->so_snd; 708 int len = 0, win, rcv_win; 709 short span, off, recordp = 0; 710 u_short alo; 711 int error = 0, sendalot; 712#ifdef notdef 713 int idle; 714#endif --- 361 unchanged lines hidden (view full) --- 1076 } else 1077 si->si_sum = 0xffff; 1078 1079 cb->s_outx = 4; 1080 if (so->so_options & SO_DEBUG || traceallspxs) 1081 spx_trace(SA_OUTPUT, cb->s_state, cb, si, 0); 1082 1083 if (so->so_options & SO_DONTROUTE) | 715 register struct sockbuf *sb = &so->so_snd; 716 int len = 0, win, rcv_win; 717 short span, off, recordp = 0; 718 u_short alo; 719 int error = 0, sendalot; 720#ifdef notdef 721 int idle; 722#endif --- 361 unchanged lines hidden (view full) --- 1084 } else 1085 si->si_sum = 0xffff; 1086 1087 cb->s_outx = 4; 1088 if (so->so_options & SO_DEBUG || traceallspxs) 1089 spx_trace(SA_OUTPUT, cb->s_state, cb, si, 0); 1090 1091 if (so->so_options & SO_DONTROUTE) |
1084 error = ipx_outputfl(m, (struct route *)NULL, IPX_ROUTETOIF); | 1092 error = ipx_outputfl(m, NULL, IPX_ROUTETOIF); |
1085 else 1086 error = ipx_outputfl(m, &cb->s_ipxpcb->ipxp_route, 0); 1087 } 1088 if (error) { 1089 return (error); 1090 } 1091 spxstat.spxs_sndtotal++; 1092 /* --- 295 unchanged lines hidden (view full) --- 1388 struct ipxpcb *ipxp; 1389 struct spxpcb *cb; 1390 1391 ipxp = sotoipxpcb(so); 1392 cb = ipxtospxpcb(ipxp); 1393 1394 s = splnet(); 1395 if (ipxp->ipxp_lport == 0) { | 1093 else 1094 error = ipx_outputfl(m, &cb->s_ipxpcb->ipxp_route, 0); 1095 } 1096 if (error) { 1097 return (error); 1098 } 1099 spxstat.spxs_sndtotal++; 1100 /* --- 295 unchanged lines hidden (view full) --- 1396 struct ipxpcb *ipxp; 1397 struct spxpcb *cb; 1398 1399 ipxp = sotoipxpcb(so); 1400 cb = ipxtospxpcb(ipxp); 1401 1402 s = splnet(); 1403 if (ipxp->ipxp_lport == 0) { |
1396 error = ipx_pcbbind(ipxp, (struct sockaddr *)NULL, td); | 1404 error = ipx_pcbbind(ipxp, NULL, td); |
1397 if (error) 1398 goto spx_connect_end; 1399 } 1400 error = ipx_pcbconnect(ipxp, nam, td); 1401 if (error) 1402 goto spx_connect_end; 1403 soisconnecting(so); 1404 spxstat.spxs_connattempt++; --- 6 unchanged lines hidden (view full) --- 1411 * Other party is required to respond to 1412 * the port I send from, but he is not 1413 * required to answer from where I am sending to, 1414 * so allow wildcarding. 1415 * original port I am sending to is still saved in 1416 * cb->s_dport. 1417 */ 1418 ipxp->ipxp_fport = 0; | 1405 if (error) 1406 goto spx_connect_end; 1407 } 1408 error = ipx_pcbconnect(ipxp, nam, td); 1409 if (error) 1410 goto spx_connect_end; 1411 soisconnecting(so); 1412 spxstat.spxs_connattempt++; --- 6 unchanged lines hidden (view full) --- 1419 * Other party is required to respond to 1420 * the port I send from, but he is not 1421 * required to answer from where I am sending to, 1422 * so allow wildcarding. 1423 * original port I am sending to is still saved in 1424 * cb->s_dport. 1425 */ 1426 ipxp->ipxp_fport = 0; |
1419 error = spx_output(cb, (struct mbuf *)NULL); | 1427 error = spx_output(cb, NULL); |
1420spx_connect_end: 1421 splx(s); 1422 return (error); 1423} 1424 1425static int 1426spx_detach(so) 1427 struct socket *so; --- 47 unchanged lines hidden (view full) --- 1475 struct ipxpcb *ipxp; 1476 struct spxpcb *cb; 1477 1478 error = 0; 1479 ipxp = sotoipxpcb(so); 1480 cb = ipxtospxpcb(ipxp); 1481 1482 if (ipxp->ipxp_lport == 0) | 1428spx_connect_end: 1429 splx(s); 1430 return (error); 1431} 1432 1433static int 1434spx_detach(so) 1435 struct socket *so; --- 47 unchanged lines hidden (view full) --- 1483 struct ipxpcb *ipxp; 1484 struct spxpcb *cb; 1485 1486 error = 0; 1487 ipxp = sotoipxpcb(so); 1488 cb = ipxtospxpcb(ipxp); 1489 1490 if (ipxp->ipxp_lport == 0) |
1483 error = ipx_pcbbind(ipxp, (struct sockaddr *)NULL, td); | 1491 error = ipx_pcbbind(ipxp, NULL, td); |
1484 if (error == 0) 1485 cb->s_state = TCPS_LISTEN; 1486 return (error); 1487} 1488 1489/* 1490 * After a receive, possibly send acknowledgment 1491 * updating allocation. --- 7 unchanged lines hidden (view full) --- 1499 struct ipxpcb *ipxp; 1500 struct spxpcb *cb; 1501 1502 ipxp = sotoipxpcb(so); 1503 cb = ipxtospxpcb(ipxp); 1504 1505 s = splnet(); 1506 cb->s_flags |= SF_RVD; | 1492 if (error == 0) 1493 cb->s_state = TCPS_LISTEN; 1494 return (error); 1495} 1496 1497/* 1498 * After a receive, possibly send acknowledgment 1499 * updating allocation. --- 7 unchanged lines hidden (view full) --- 1507 struct ipxpcb *ipxp; 1508 struct spxpcb *cb; 1509 1510 ipxp = sotoipxpcb(so); 1511 cb = ipxtospxpcb(ipxp); 1512 1513 s = splnet(); 1514 cb->s_flags |= SF_RVD; |
1507 spx_output(cb, (struct mbuf *)NULL); | 1515 spx_output(cb, NULL); |
1508 cb->s_flags &= ~SF_RVD; 1509 splx(s); 1510 return (0); 1511} 1512 1513static int 1514spx_rcvoob(so, m, flags) 1515 struct socket *so; --- 74 unchanged lines hidden (view full) --- 1590 error = 0; 1591 ipxp = sotoipxpcb(so); 1592 cb = ipxtospxpcb(ipxp); 1593 1594 s = splnet(); 1595 socantsendmore(so); 1596 cb = spx_usrclosed(cb); 1597 if (cb != NULL) | 1516 cb->s_flags &= ~SF_RVD; 1517 splx(s); 1518 return (0); 1519} 1520 1521static int 1522spx_rcvoob(so, m, flags) 1523 struct socket *so; --- 74 unchanged lines hidden (view full) --- 1598 error = 0; 1599 ipxp = sotoipxpcb(so); 1600 cb = ipxtospxpcb(ipxp); 1601 1602 s = splnet(); 1603 socantsendmore(so); 1604 cb = spx_usrclosed(cb); 1605 if (cb != NULL) |
1598 error = spx_output(cb, (struct mbuf *)NULL); | 1606 error = spx_output(cb, NULL); |
1599 splx(s); 1600 return (error); 1601} 1602 1603static int 1604spx_sp_attach(so, proto, td) 1605 struct socket *so; 1606 int proto; --- 62 unchanged lines hidden (view full) --- 1669 m_freem(m); 1670 } 1671 m_free(dtom(cb->s_ipx)); 1672 FREE(cb, M_PCB); 1673 ipxp->ipxp_pcb = 0; 1674 soisdisconnected(so); 1675 ipx_pcbdetach(ipxp); 1676 spxstat.spxs_closed++; | 1607 splx(s); 1608 return (error); 1609} 1610 1611static int 1612spx_sp_attach(so, proto, td) 1613 struct socket *so; 1614 int proto; --- 62 unchanged lines hidden (view full) --- 1677 m_freem(m); 1678 } 1679 m_free(dtom(cb->s_ipx)); 1680 FREE(cb, M_PCB); 1681 ipxp->ipxp_pcb = 0; 1682 soisdisconnected(so); 1683 ipx_pcbdetach(ipxp); 1684 spxstat.spxs_closed++; |
1677 return ((struct spxpcb *)NULL); | 1685 return (NULL); |
1678} 1679 1680/* 1681 * Someday we may do level 3 handshaking 1682 * to close a connection or send a xerox style error. 1683 * For now, just close. 1684 */ 1685static struct spxpcb * --- 47 unchanged lines hidden (view full) --- 1733 int s = splnet(); 1734 1735 LIST_FOREACH(ipxp, &ipxpcb_list, ipxp_list) { 1736 if ((cb = (struct spxpcb *)ipxp->ipxp_pcb) != NULL && 1737 (cb->s_flags & SF_DELACK)) { 1738 cb->s_flags &= ~SF_DELACK; 1739 cb->s_flags |= SF_ACKNOW; 1740 spxstat.spxs_delack++; | 1686} 1687 1688/* 1689 * Someday we may do level 3 handshaking 1690 * to close a connection or send a xerox style error. 1691 * For now, just close. 1692 */ 1693static struct spxpcb * --- 47 unchanged lines hidden (view full) --- 1741 int s = splnet(); 1742 1743 LIST_FOREACH(ipxp, &ipxpcb_list, ipxp_list) { 1744 if ((cb = (struct spxpcb *)ipxp->ipxp_pcb) != NULL && 1745 (cb->s_flags & SF_DELACK)) { 1746 cb->s_flags &= ~SF_DELACK; 1747 cb->s_flags |= SF_ACKNOW; 1748 spxstat.spxs_delack++; |
1741 spx_output(cb, (struct mbuf *)NULL); | 1749 spx_output(cb, NULL); |
1742 } 1743 } 1744 1745 splx(s); 1746} 1747 1748/* 1749 * spx protocol timeout routine called every 500 ms. --- 94 unchanged lines hidden (view full) --- 1844 * See very long discussion in tcp_timer.c about congestion 1845 * window and sstrhesh 1846 */ 1847 win = min(cb->s_swnd, (cb->s_cwnd/CUNIT)) / 2; 1848 if (win < 2) 1849 win = 2; 1850 cb->s_cwnd = CUNIT; 1851 cb->s_ssthresh = win * CUNIT; | 1750 } 1751 } 1752 1753 splx(s); 1754} 1755 1756/* 1757 * spx protocol timeout routine called every 500 ms. --- 94 unchanged lines hidden (view full) --- 1852 * See very long discussion in tcp_timer.c about congestion 1853 * window and sstrhesh 1854 */ 1855 win = min(cb->s_swnd, (cb->s_cwnd/CUNIT)) / 2; 1856 if (win < 2) 1857 win = 2; 1858 cb->s_cwnd = CUNIT; 1859 cb->s_ssthresh = win * CUNIT; |
1852 spx_output(cb, (struct mbuf *)NULL); | 1860 spx_output(cb, NULL); |
1853 break; 1854 1855 /* 1856 * Persistance timer into zero window. 1857 * Force a probe to be sent. 1858 */ 1859 case SPXT_PERSIST: 1860 spxstat.spxs_persisttimeo++; 1861 spx_setpersist(cb); | 1861 break; 1862 1863 /* 1864 * Persistance timer into zero window. 1865 * Force a probe to be sent. 1866 */ 1867 case SPXT_PERSIST: 1868 spxstat.spxs_persisttimeo++; 1869 spx_setpersist(cb); |
1862 spx_output(cb, (struct mbuf *)NULL); | 1870 spx_output(cb, NULL); |
1863 break; 1864 1865 /* 1866 * Keep-alive timer went off; send something 1867 * or drop connection if idle for too long. 1868 */ 1869 case SPXT_KEEP: 1870 spxstat.spxs_keeptimeo++; 1871 if (cb->s_state < TCPS_ESTABLISHED) 1872 goto dropit; 1873 if (cb->s_ipxpcb->ipxp_socket->so_options & SO_KEEPALIVE) { 1874 if (cb->s_idle >= SPXTV_MAXIDLE) 1875 goto dropit; 1876 spxstat.spxs_keepprobe++; | 1871 break; 1872 1873 /* 1874 * Keep-alive timer went off; send something 1875 * or drop connection if idle for too long. 1876 */ 1877 case SPXT_KEEP: 1878 spxstat.spxs_keeptimeo++; 1879 if (cb->s_state < TCPS_ESTABLISHED) 1880 goto dropit; 1881 if (cb->s_ipxpcb->ipxp_socket->so_options & SO_KEEPALIVE) { 1882 if (cb->s_idle >= SPXTV_MAXIDLE) 1883 goto dropit; 1884 spxstat.spxs_keepprobe++; |
1877 spx_output(cb, (struct mbuf *)NULL); | 1885 spx_output(cb, NULL); |
1878 } else 1879 cb->s_idle = 0; 1880 cb->s_timer[SPXT_KEEP] = SPXTV_KEEP; 1881 break; 1882 dropit: 1883 spxstat.spxs_keepdrops++; 1884 cb = spx_drop(cb, ETIMEDOUT); 1885 break; 1886 } 1887 return (cb); 1888} | 1886 } else 1887 cb->s_idle = 0; 1888 cb->s_timer[SPXT_KEEP] = SPXTV_KEEP; 1889 break; 1890 dropit: 1891 spxstat.spxs_keepdrops++; 1892 cb = spx_drop(cb, ETIMEDOUT); 1893 break; 1894 } 1895 return (cb); 1896} |