About this list Date view Thread view Subject view Author view Attachment view

From: Bjoern Steinbrink (B.Steinbrink_at_gmx.de)
Date: Sat 28 Aug 2004 - 23:57:50 BST


Hello,

inside an vserver you can't bind to the same port multiple ip addresses.
For example, if the vserver has addresses 10.0.0.1 and 10.0.0.2 you
cannot bind to 10.0.0.1:80 and 10.0.0.2:80. It works if you use
0.0.0.0:80 but in cases where for example only 2 of 3 addresses should
be used this is not an option.
The problem is that the check within the kernel does always compare all
addresses available in a context to the one that is requested to be
bound, even if the socket in question only binds to a single address.
The patch below applies to 1.9.2.20 and fixes this.

Thanks to ntrs for reporting this and helping to test various things.

Bjoern

diff -NurpP --minimal linux-2.6.8.1-vs1.9.2.20/net/ipv4/tcp_ipv4.c
linux-2.6.8.1
-vs1.9.2.20-multi-bind-fix/net/ipv4/tcp_ipv4.c
--- linux-2.6.8.1-vs1.9.2.20/net/ipv4/tcp_ipv4.c 2004-08-22
00:39:08.0000
00000 +0200
+++ linux-2.6.8.1-vs1.9.2.20-multi-bind-fix/net/ipv4/tcp_ipv4.c
2004-08-29 00:20
:23.000000000 +0200
@@ -193,12 +193,17 @@ static inline int tcp_in_list(struct soc
                (sk->sk_socket?sk->sk_socket->flags:0));
 
        if (nxi) {
- int n = nxi->nbipv4;
- int i;
+ /* Socket is bound to a single address */
+ if (tcp_v4_rcv_saddr(sk)) {
+ return (tcp_v4_rcv_saddr(sk) == addr);
+ } else {
+ int n = nxi->nbipv4;
+ int i;
 
- for (i=0; i<n; i++)
- if (nxi->ipv4[i] == addr)
- return 1;
+ for (i=0; i<n; i++)
+ if (nxi->ipv4[i] == addr)
+ return 1;
+ }
        }
        else if (!tcp_v4_rcv_saddr(sk) || tcp_v4_rcv_saddr(sk) == addr)
                return 1;

_______________________________________________
Vserver mailing list
Vserver_at_list.linux-vserver.org
http://list.linux-vserver.org/mailman/listinfo/vserver


About this list Date view Thread view Subject view Author view Attachment view
[Next/Previous Months] [Main vserver Project Homepage] [Howto Subscribe/Unsubscribe] [Paul Sladen's vserver stuff]
Generated on Sat 28 Aug 2004 - 23:58:09 BST by hypermail 2.1.3