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
This commit is contained in:
Gleb Smirnoff 2007-02-28 12:41:49 +00:00
parent 975ab35963
commit 72757d9a53

@ -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 (((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;
}
if (error == EPERM) {
tp->t_softerror = error;
return (error);
}
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++;