将synproxy移植到用户空间

问题描述 投票:0回答:1

我已将内核的synproxy代码移植到用户空间。我将它用作客户端和Web服务器之间的透明代理。当我请求一个网页时,它工作正常(网页低于512kbit)。但是,如果我访问一个巨大的文件(4Gbit或更高),它将在3Gbits传输后继续传输。

我已经调整了服务器发送给客户端的“确认”和从客户端发送到服务器的“seq”。同时,还调整了从客户端发送到服务器的tcp选项“sack”。

 if(tcpinp->state == CONNTRACK_SYN_SENT){              
    if(tcphdr->tcp_flags == (TCP_SYN_FLAG|TCP_ACK_FLAG)){ 
        synproxy_parse_options(tcphdr, &opts);            
        tcpinp->tsoff = opts.tsval - tcpinp->its;         
    }                                                     

    swap(opts.tsval, opts.tsecr);                         
    synproxy_send_server_ack(iphdr,tcphdr, &opts);      
    /* send client ack,update tcp window */               
    swap(opts.tsval, opts.tsecr);      
 /*                                          
  * update window to client                  
  *                                          
  * dir:server -> client   
  *                           
  * save isn_off =  client.ISN1 - server.ISN2   
  */                                                                                                           
    tcpinp->isn_off = tcpinp->isn - tcphdr->seq;                
    synproxy_send_client_ack(tcpinp, &opts);     
    tcpinp->state = CONNTRACK_ESTABLISHED;            
    return 0;                                             
}                                                         

   if(tcpinp->dir == IP_CT_DIR_REPLY){                                      
       tcphdr->sent_seq = htonl(ntohl(tcphdr->sent_seq) + tcpinp->isn_off);                                
   }else if(tcpinp->dir == IP_CT_DIR_ORIGINAL){                             
       tcphdr->recv_ack = htonl(ntohl(tcphdr->recv_ack) - tcpinp->isn_off); 
       nf_ct_sack_adjust(tcph, other_way);                
   }   


除了seq / ack和sack之外我应该调整什么?

c kernel netfilter
1个回答
0
投票

---我发现客户端tcp'win'选项已增加到'828800'然后它没有改变。

我已经解决了,需要'mss'总是一样的。

© www.soinside.com 2019 - 2024. All rights reserved.