Tcp port selection for IPV6.
Subsystems (4)
PATCH 1/1 Tcp port selection for IPV6.
This patch makes TCP over IPV6 select ports the same way the current TCPv4 code does. It uses a hash function to provide a starting offset and a free running counter to provide seed.
This changes the port selection semantics to match TCPv4 as well. If the port is in use but to a different remote address, it will get reused. It looks like the TCPv6 code was not updated when the TCPv4 code changed. Now the code in ipv4/tcp_ipv4.c and ipv6/tcp_ipv6.c are almost identical for tcp_hash_connect.
drivers/char/random.c +15 -0
@@ -2283,6 +2283,21 @@return halfMD4Transform (hash, keyptr->secret); } +#if defined(CONFIG_IPV6 ) || defined(CONFIG_IPV6_MODULE ) +u32 secure_tcpv6_port_ephemeral (const __u32 *saddr,const __u32 *daddr,__u16 dport) +{ +struct keydata *keyptr =get_keyptr (); +u32 hash[12 ]; + +memcpy (hash, saddr,16 ); + hash[4 ] = dport; +memcpy (&hash[5 ],keyptr->secret,sizeof (__u32) *7 ); + +return twothirdsMD4Transform (daddr, hash); +} +EXPORT_SYMBOL (secure_tcpv6_port_ephemeral); +#endif +#ifdef CONFIG_SYN_COOKIES /* * Secure SYN cookie computation. This is the algorithm worked out by
include/linux/random.h +2 -0
@@ -53,6 +53,8 @@extern __u32 secure_ip_id (__u32 daddr);extern u32 secure_tcp_port_ephemeral (__u32 saddr,__u32 daddr,__u16 dport); +extern u32 secure_tcpv6_port_ephemeral (const __u32 *saddr,const __u32 *daddr, +__u16 dport);extern __u32 secure_tcp_sequence_number (__u32 saddr,__u32 daddr,__u16 sport,__u16 dport); extern __u32 secure_tcp_syn_cookie(__u32 saddr, __u32 daddr,
net/ipv4/tcp_ipv4.c +1 -0
@@ -2663,4 +2663,5 @@EXPORT_SYMBOL (sysctl_local_port_range);EXPORT_SYMBOL (sysctl_max_syn_backlog);EXPORT_SYMBOL (sysctl_tcp_low_latency); +EXPORT_SYMBOL (sysctl_tcp_tw_reuse);
net/ipv6/tcp_ipv6.c +104 -23
180 lines not on this page · raw message
Quoted 2 lines · Stephen Hemminger
Now the code in
ipv4/tcp_ipv4.candipv6/tcp_ipv6.care almost identical fortcp_hash_connect.
Humm, dccp_hash_connect is almost identical to tcp_hash_connect too... /me adds an entry to his TODO list... :-)
- Arnaldo
David S. Miller
maintainerQuoted 11 lines · On Thu, 20 Jan 2005 16:45:29 -0800 Stephen Hemminger <[email protected]>…
This patch makes TCP over IPV6 select ports the same way the current TCPv4 code does. It uses a hash function to provide a starting offset and a free running counter to provide seed.
This changes the port selection semantics to match TCPv4 as well. If the port is in use but to a different remote address, it will get reused. It looks like the TCPv6 code was not updated when the TCPv4 code changed. Now the code in
ipv4/tcp_ipv4.candipv6/tcp_ipv6.care almost identical fortcp_hash_connect.Signed-off-by Stephen Hemminger <[email protected]>
Looks good, sorry for taking so long to review.
I think I'll push this into my 2.6.12 pending queue since 2.6.11 is very much in a bug-fix-only type mode.
David S. Miller
maintainerQuoted 11 lines · On Thu, 20 Jan 2005 16:45:29 -0800 Stephen Hemminger <[email protected]>…
This patch makes TCP over IPV6 select ports the same way the current TCPv4 code does. It uses a hash function to provide a starting offset and a free running counter to provide seed.
This changes the port selection semantics to match TCPv4 as well. If the port is in use but to a different remote address, it will get reused. It looks like the TCPv6 code was not updated when the TCPv4 code changed. Now the code in
ipv4/tcp_ipv4.candipv6/tcp_ipv6.care almost identical fortcp_hash_connect.Signed-off-by Stephen Hemminger <[email protected]>
I've tossed this into my 2.6.12-pending tree.