| 815 | } |
| 816 | |
| 817 | uint32_t |
| 818 | ctf_fixed_maxseg(struct tcpcb *tp) |
| 819 | { |
| 820 | int optlen; |
| 821 | |
| 822 | if (tp->t_flags & TF_NOOPT) |
| 823 | return (tp->t_maxseg); |
| 824 | |
| 825 | /* |
| 826 | * Here we have a simplified code from tcp_addoptions(), |
| 827 | * without a proper loop, and having most of paddings hardcoded. |
| 828 | * We only consider fixed options that we would send every |
| 829 | * time I.e. SACK is not considered. |
| 830 | * |
| 831 | */ |
| 832 | #define PAD(len) ((((len) / 4) + !!((len) % 4)) * 4) |
| 833 | if (TCPS_HAVEESTABLISHED(tp->t_state)) { |
| 834 | if (tp->t_flags & TF_RCVD_TSTMP) |
| 835 | optlen = TCPOLEN_TSTAMP_APPA; |
| 836 | else |
| 837 | optlen = 0; |
| 838 | #if defined(IPSEC_SUPPORT) || defined(TCP_SIGNATURE) |
| 839 | if (tp->t_flags & TF_SIGNATURE) |
| 840 | optlen += PAD(TCPOLEN_SIGNATURE); |
| 841 | #endif |
| 842 | } else { |
| 843 | if (tp->t_flags & TF_REQ_TSTMP) |
| 844 | optlen = TCPOLEN_TSTAMP_APPA; |
| 845 | else |
| 846 | optlen = PAD(TCPOLEN_MAXSEG); |
| 847 | if (tp->t_flags & TF_REQ_SCALE) |
| 848 | optlen += PAD(TCPOLEN_WINDOW); |
| 849 | #if defined(IPSEC_SUPPORT) || defined(TCP_SIGNATURE) |
| 850 | if (tp->t_flags & TF_SIGNATURE) |
| 851 | optlen += PAD(TCPOLEN_SIGNATURE); |
| 852 | #endif |
| 853 | if (tp->t_flags & TF_SACK_PERMIT) |
| 854 | optlen += PAD(TCPOLEN_SACK_PERMITTED); |
| 855 | } |
| 856 | #undef PAD |
| 857 | optlen = min(optlen, TCP_MAXOLEN); |
| 858 | return (tp->t_maxseg - optlen); |
| 859 | } |
| 860 | |
| 861 | void |
| 862 | ctf_log_sack_filter(struct tcpcb *tp, int num_sack_blks, struct sackblk *sack_blocks) |
no test coverage detected