tcp_v4_get_port() and ephemeral ports
Quoted 4 lines
It's tempting to patch
tcp_v4_get_port()to checksk->rcv_saddr, and if it's nonzero, allow the
same ephemeral port number to be reused on different interfaces.
Try this patch instead. It doesn't do load balancing for local aliases, but it'll reuse ports if the remote address is unique. It'll theoretically do more than the old code, but in practice the rover variable does a good job at balancing the hash buckets so the cost is similar (assuming user code doesn't do explicit binds before connect, which is usually not the case)
-Andi
net/tcp.h renamed from net/tcp.h-TCPHASH +4 -5
@@ -568,9 +568,7 @@struct sk_buff *skb, struct open_request *req, struct dst_entry *dst); - -int (*hash_connecting) (struct sock *sk); - +int (*remember_stamp) (struct sock *sk);__u16 net_header_len;
@@ -774,8 +772,9 @@struct sockaddr *uaddr, int addr_len); -extern int tcp_connect (struct sock *sk, -struct sk_buff *skb); +extern void tcp_connect_init (struct sock *sk); + +extern void tcp_connect_send (struct sock *sk,struct sk_buff *skb); extern struct sk_buff * tcp_make_synack(struct sock *sk, struct dst_entry *dst,
ipv4/tcp_ipv4.c renamed from ipv4/tcp_ipv4.c-TCPHASH +154 -70
354 lines not on this page · raw message
ipv4/tcp_output.c renamed from ipv4/tcp_output.c-TCPHASH +17 -19
@@ -1157,14 +1157,15 @@return skb; } -int tcp_connect (struct sock *sk,struct sk_buff *buff) +/* +* Do all connect socket setups that can be done AF independent. +* Could be inlined. +*/ +void tcp_connect_init (struct sock *sk) {struct dst_entry *dst =__sk_dst_get (sk);struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp); -/* Reserve space for headers. */ -skb_reserve (buff,MAX_TCP_HEADER ); -/* We'll fix this up when we get a response from the other end. * See tcp_input.c:tcp_rcv_state_process case TCP_SYN_SENT. */
@@ -1191,14 +1192,6 @@ tp->rcv_ssthresh = tp->rcv_wnd; -/* Socket identity change complete, no longer -* in TCP_CLOSE, so enter ourselves into the -* hash tables. -*/ -tcp_set_state (sk,TCP_SYN_SENT ); -if (tp->af_specific->hash_connecting (sk)) - goto err_out; - sk->err =0 ; sk->done =0 ; tp->snd_wnd =0 ;
@@ -1212,9 +1205,20 @@ tp->rto =TCP_TIMEOUT_INIT ; tp->retransmits =0 ;tcp_clear_retrans (tp); +} + +/* +* Build a SYN and send it off. +*/ +void tcp_connect_send (struct sock *sk,struct sk_buff *buff) +{ +struct tcp_opt *tp = &(sk->tp_pinfo.af_tcp); + +/* Reserve space for headers. */ +skb_reserve (buff,MAX_TCP_HEADER );TCP_SKB_CB (buff)->flags =TCPCB_FLAG_SYN ; -TCP_ECN_send_syn (tp, buff); +TCP_ECN_send_syn (tp, buff);TCP_SKB_CB (buff)->sacked =0 ; buff->csum =0 ;TCP_SKB_CB (buff)->seq = tp->write_seq++;
@@ -1233,12 +1237,6 @@/* Timer for repeating the SYN until an answer. */ tcp_reset_xmit_timer (sk,TCP_TIME_RETRANS , tp->rto); -return 0 ; - -err_out: -tcp_set_state (sk,TCP_CLOSE ); -kfree_skb (buff); -return -EADDRNOTAVAIL ; }/* Send out a delayed ack, the caller does the policy checking
ipv6/tcp_ipv6.c renamed from ipv6/tcp_ipv6.c-TCPHASH +29 -16
84 lines not on this page · raw message