summaryrefslogtreecommitdiffstats
path: root/sys/netinet/tcp_output.c
diff options
context:
space:
mode:
authorglebius <glebius@FreeBSD.org>2007-02-28 12:41:49 +0000
committerglebius <glebius@FreeBSD.org>2007-02-28 12:41:49 +0000
commit481c8d8b0ba0478c1e817b9518acf7c1a389bad2 (patch)
treeb16880b8645064f3583830f98c3561dc373c17d3 /sys/netinet/tcp_output.c
parentdd2bbfcd28e7c2ed7673c5f39349b0d3eaf840aa (diff)
downloadFreeBSD-src-481c8d8b0ba0478c1e817b9518acf7c1a389bad2.zip
FreeBSD-src-481c8d8b0ba0478c1e817b9518acf7c1a389bad2.tar.gz
Toss the code, that handles errors from ip_output(), to make it more
readable: - Merge two embedded if() into one. - Introduce switch() block to handle different kinds of errors. Reviewed by: rwatson, bms
Diffstat (limited to 'sys/netinet/tcp_output.c')
-rw-r--r--sys/netinet/tcp_output.c56
1 files changed, 26 insertions, 30 deletions
diff --git a/sys/netinet/tcp_output.c b/sys/netinet/tcp_output.c
index fdfe735..85f149c 100644
--- a/sys/netinet/tcp_output.c
+++ b/sys/netinet/tcp_output.c
@@ -1214,39 +1214,32 @@ timer:
* XXX: It is a POLA question whether calling tcp_drop right
* away would be the really correct behavior instead.
*/
- if (error != EPERM && ((tp->t_flags & TF_FORCEDATA) == 0 ||
- !callout_active(tp->tt_persist))) {
- /*
- * No need to check for TH_FIN here because
- * the TF_SENTFIN flag handles that case.
- */
- if ((flags & TH_SYN) == 0) {
- if (sack_rxmit) {
- p->rxmit -= len;
- tp->sackhint.sack_bytes_rexmit -= len;
- KASSERT(tp->sackhint.sack_bytes_rexmit
- >= 0,
- ("sackhint bytes rtx >= 0"));
- } else
- tp->snd_nxt -= len;
- }
- }
- if (error == EPERM) {
- tp->t_softerror = error;
- return (error);
+ if (((tp->t_flags & TF_FORCEDATA) == 0 ||
+ !callout_active(tp->tt_persist)) &&
+ ((flags & TH_SYN) == 0) &&
+ (error != EPERM)) {
+ if (sack_rxmit) {
+ p->rxmit -= len;
+ tp->sackhint.sack_bytes_rexmit -= len;
+ KASSERT(tp->sackhint.sack_bytes_rexmit >= 0,
+ ("sackhint bytes rtx >= 0"));
+ } else
+ tp->snd_nxt -= len;
}
-
out:
SOCKBUF_UNLOCK_ASSERT(&so->so_snd); /* Check gotos. */
- if (error == ENOBUFS) {
+ switch (error) {
+ case EPERM:
+ tp->t_softerror = error;
+ return (error);
+ case ENOBUFS:
if (!callout_active(tp->tt_rexmt) &&
!callout_active(tp->tt_persist))
callout_reset(tp->tt_rexmt, tp->t_rxtcur,
tcp_timer_rexmt, tp);
tp->snd_cwnd = tp->t_maxseg;
return (0);
- }
- if (error == EMSGSIZE) {
+ case EMSGSIZE:
/*
* For some reason the interface we used initially
* to send segments changed to another or lowered
@@ -1265,14 +1258,17 @@ out:
if (tso)
tp->t_flags &= ~TF_TSO;
tcp_mtudisc(tp->t_inpcb, 0);
- return 0;
- }
- if ((error == EHOSTUNREACH || error == ENETDOWN)
- && TCPS_HAVERCVDSYN(tp->t_state)) {
- tp->t_softerror = error;
return (0);
+ case EHOSTUNREACH:
+ case ENETDOWN:
+ if (TCPS_HAVERCVDSYN(tp->t_state)) {
+ tp->t_softerror = error;
+ return (0);
+ }
+ /* FALLTHROUGH */
+ default:
+ return (error);
}
- return (error);
}
tcpstat.tcps_sndtotal++;
OpenPOWER on IntegriCloud