projects
/
unix-history
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
tags
|
clone url
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
nasty little bug in packet reassembly
[unix-history]
/
usr
/
src
/
sys
/
netinet
/
tcp_input.c
diff --git
a/usr/src/sys/netinet/tcp_input.c
b/usr/src/sys/netinet/tcp_input.c
index
d2ce8d1
..
d00ead0
100644
(file)
--- a/
usr/src/sys/netinet/tcp_input.c
+++ b/
usr/src/sys/netinet/tcp_input.c
@@
-1,4
+1,4
@@
-/* tcp_input.c 1.
62 82/03/19
*/
+/* tcp_input.c 1.
71 82/06/30
*/
#include "../h/param.h"
#include "../h/systm.h"
#include "../h/param.h"
#include "../h/systm.h"
@@
-7,6
+7,7
@@
#include "../h/socket.h"
#include "../h/socketvar.h"
#include "../net/in.h"
#include "../h/socket.h"
#include "../h/socketvar.h"
#include "../net/in.h"
+#include "../net/route.h"
#include "../net/in_pcb.h"
#include "../net/in_systm.h"
#include "../net/if.h"
#include "../net/in_pcb.h"
#include "../net/in_systm.h"
#include "../net/if.h"
@@
-19,7
+20,7
@@
#include "../net/tcp_var.h"
#include "../net/tcpip.h"
#include "../net/tcp_debug.h"
#include "../net/tcp_var.h"
#include "../net/tcpip.h"
#include "../net/tcp_debug.h"
-#include
"../errno.h"
+#include
<errno.h>
int tcpprintfs = 0;
int tcpcksum = 1;
int tcpprintfs = 0;
int tcpcksum = 1;
@@
-47,7
+48,6
@@
tcp_input(m0)
short ostate;
struct in_addr laddr;
short ostate;
struct in_addr laddr;
-COUNT(TCP_INPUT);
/*
* Get IP and TCP header together in first mbuf.
* Note: IP leaves IP header in first mbuf.
/*
* Get IP and TCP header together in first mbuf.
* Note: IP leaves IP header in first mbuf.
@@
-73,7
+73,7
@@
COUNT(TCP_INPUT);
ti->ti_next = ti->ti_prev = 0;
ti->ti_x1 = 0;
ti->ti_len = (u_short)tlen;
ti->ti_next = ti->ti_prev = 0;
ti->ti_x1 = 0;
ti->ti_len = (u_short)tlen;
-#if vax
+#if vax
|| pdp11
ti->ti_len = htons((u_short)ti->ti_len);
#endif
if (ti->ti_sum = in_cksum(m, len)) {
ti->ti_len = htons((u_short)ti->ti_len);
#endif
if (ti->ti_sum = in_cksum(m, len)) {
@@
-122,7
+122,7
@@
COUNT(TCP_INPUT);
m->m_off += off;
m->m_len -= off;
m->m_off += off;
m->m_len -= off;
-#if vax
+#if vax
|| pdp11
/*
* Convert TCP protocol specific fields to host format.
*/
/*
* Convert TCP protocol specific fields to host format.
*/
@@
-212,9
+212,9
@@
COUNT(TCP_INPUT);
if (tp->t_template == 0) {
in_pcbdisconnect(inp);
inp->inp_laddr = laddr;
if (tp->t_template == 0) {
in_pcbdisconnect(inp);
inp->inp_laddr = laddr;
+ tp = 0;
goto drop;
}
goto drop;
}
- in_setsockaddr(inp);
tp->iss = tcp_iss; tcp_iss += TCP_ISSINCR/2;
tp->irs = ti->ti_seq;
tcp_sendseqinit(tp);
tp->iss = tcp_iss; tcp_iss += TCP_ISSINCR/2;
tp->irs = ti->ti_seq;
tcp_sendseqinit(tp);
@@
-242,8
+242,10
@@
COUNT(TCP_INPUT);
SEQ_GT(ti->ti_ack, tp->snd_max)))
goto dropwithreset;
if (tiflags & TH_RST) {
SEQ_GT(ti->ti_ack, tp->snd_max)))
goto dropwithreset;
if (tiflags & TH_RST) {
- if (tiflags & TH_ACK)
+ if (tiflags & TH_ACK)
{
tcp_drop(tp, ECONNREFUSED);
tcp_drop(tp, ECONNREFUSED);
+ tp = 0;
+ }
goto drop;
}
if ((tiflags & TH_SYN) == 0)
goto drop;
}
if ((tiflags & TH_SYN) == 0)
@@
-378,9
+380,11
@@
trimthenstep6:
inp->inp_faddr.s_addr = 0;
inp->inp_fport = 0;
inp->inp_laddr.s_addr = 0; /* not quite right */
inp->inp_faddr.s_addr = 0;
inp->inp_fport = 0;
inp->inp_laddr.s_addr = 0; /* not quite right */
+ tp = 0;
goto drop;
}
tcp_drop(tp, ECONNREFUSED);
goto drop;
}
tcp_drop(tp, ECONNREFUSED);
+ tp = 0;
goto drop;
case TCPS_ESTABLISHED:
goto drop;
case TCPS_ESTABLISHED:
@@
-388,12
+392,14
@@
trimthenstep6:
case TCPS_FIN_WAIT_2:
case TCPS_CLOSE_WAIT:
tcp_drop(tp, ECONNRESET);
case TCPS_FIN_WAIT_2:
case TCPS_CLOSE_WAIT:
tcp_drop(tp, ECONNRESET);
+ tp = 0;
goto drop;
case TCPS_CLOSING:
case TCPS_LAST_ACK:
case TCPS_TIME_WAIT:
tcp_close(tp);
goto drop;
case TCPS_CLOSING:
case TCPS_LAST_ACK:
case TCPS_TIME_WAIT:
tcp_close(tp);
+ tp = 0;
goto drop;
}
goto drop;
}
@@
-493,7
+499,7
@@
trimthenstep6:
tp->snd_wnd -= acked;
acked = 0;
}
tp->snd_wnd -= acked;
acked = 0;
}
- if (
so->so_snd.sb_flags & SB_WAIT
)
+ if (
(so->so_snd.sb_flags & SB_WAIT) || so->so_snd.sb_sel
)
sowwakeup(so);
tp->snd_una = ti->ti_ack;
if (SEQ_LT(tp->snd_nxt, tp->snd_una))
sowwakeup(so);
tp->snd_una = ti->ti_ack;
if (SEQ_LT(tp->snd_nxt, tp->snd_una))
@@
-540,8
+546,10
@@
trimthenstep6:
* and return.
*/
case TCPS_LAST_ACK:
* and return.
*/
case TCPS_LAST_ACK:
- if (ourfinisacked)
+ if (ourfinisacked)
{
tcp_close(tp);
tcp_close(tp);
+ tp = 0;
+ }
goto drop;
/*
goto drop;
/*
@@
-573,7
+581,8
@@
step6:
/*
* Process segments with URG.
*/
/*
* Process segments with URG.
*/
- if ((tiflags & TH_URG) && TCPS_HAVERCVDFIN(tp->t_state) == 0) {
+ if ((tiflags & TH_URG) && ti->ti_urp &&
+ TCPS_HAVERCVDFIN(tp->t_state) == 0) {
/*
* If this segment advances the known urgent pointer,
* then mark the data stream. This should not happen
/*
* If this segment advances the known urgent pointer,
* then mark the data stream. This should not happen
@@
-690,6
+699,8
@@
dropafterack:
if ((tiflags&TH_RST) ||
tlen == 0 && (tiflags&(TH_SYN|TH_FIN)) == 0)
goto drop;
if ((tiflags&TH_RST) ||
tlen == 0 && (tiflags&(TH_SYN|TH_FIN)) == 0)
goto drop;
+ if (tp->t_inpcb->inp_socket->so_options & SO_DEBUG)
+ tcp_trace(TA_RESPOND, ostate, tp, &tcp_saveti, 0);
tcp_respond(tp, ti, tp->rcv_nxt, tp->snd_nxt, TH_ACK);
return;
tcp_respond(tp, ti, tp->rcv_nxt, tp->snd_nxt, TH_ACK);
return;
@@
-716,6
+727,8
@@
drop:
/*
* Drop space held by incoming segment and return.
*/
/*
* Drop space held by incoming segment and return.
*/
+ if (tp && (tp->t_inpcb->inp_socket->so_options & SO_DEBUG))
+ tcp_trace(TA_DROP, ostate, tp, &tcp_saveti, 0);
m_freem(m);
return;
}
m_freem(m);
return;
}
@@
-746,7
+759,7
@@
tcp_dooptions(tp, om)
if (optlen != 4)
continue;
tp->t_maxseg = *(u_short *)(cp + 2);
if (optlen != 4)
continue;
tp->t_maxseg = *(u_short *)(cp + 2);
-#if vax
+#if vax
|| pdp11
tp->t_maxseg = ntohs((u_short)tp->t_maxseg);
#endif
break;
tp->t_maxseg = ntohs((u_short)tp->t_maxseg);
#endif
break;
@@
-776,7
+789,7
@@
printf("bad seq\n");
tp->t_iobseq = cp[2];
tp->t_iobc = cp[3];
mark = *(tcp_seq *)(cp + 4);
tp->t_iobseq = cp[2];
tp->t_iobc = cp[3];
mark = *(tcp_seq *)(cp + 4);
-#if vax
+#if vax
|| pdp11
mark = ntohl(mark);
#endif
so->so_oobmark = so->so_rcv.sb_cc + (mark-tp->rcv_nxt);
mark = ntohl(mark);
#endif
so->so_oobmark = so->so_rcv.sb_cc + (mark-tp->rcv_nxt);
@@
-853,7
+866,6
@@
tcp_reass(tp, ti)
struct socket *so = tp->t_inpcb->inp_socket;
struct mbuf *m;
int flags;
struct socket *so = tp->t_inpcb->inp_socket;
struct mbuf *m;
int flags;
-COUNT(TCP_REASS);
/*
* Call with ti==0 after become established to
/*
* Call with ti==0 after become established to
@@
-883,7
+895,7
@@
COUNT(TCP_REASS);
if (i > 0) {
if (i >= ti->ti_len)
goto drop;
if (i > 0) {
if (i >= ti->ti_len)
goto drop;
- m_adj(dtom(t
p
), i);
+ m_adj(dtom(t
i
), i);
ti->ti_len -= i;
ti->ti_seq += i;
}
ti->ti_len -= i;
ti->ti_seq += i;
}