Re: port limitation to int16

Johannes Wienke <[email protected]> Thu, 08 Aug 2013 15:41:48 +0200
Newsgroups gmane.network.spread.user
Message-ID <[email protected]>
Hi,

On 07.08.13 16:04 schrieb John Schultz:
> I see it.  It looks like that limitation was removed with 4.3.0.
> 
> I think you can safely remove that check from your version or upgrade to 4.3.

I just tried this with version 4.3 with mixed results. If I use e.g.
48000@localhost in the SP_connect call, the connection succeeds.
However, if I try to use a local socket by providing only the port
number connection does not work. Attached is a test program which
demonstrates this problem.

The connection problems in the case of socket communication are actually
caused by the daemon itself. Looking at the output at start I can see:

Conf_load_conf_file: My name: localhost, id: 127.0.0.1, port: -17536
Membership id is ( 2130706433, 1375968222)
--------------------
Configuration at localhost is:
Num Segments 1
	1	127.0.0.255       -17536
		localhost           	127.0.0.1
====================

Notice the negative port numbers. There is an integer overflow in the
daemon and this does not only exist in the printing. Actually the socket
file in /tmp is really called -17536. The client API doesn't seem to
have this overflow and tries to correctly find a file with name 48000.

Strangely, the TCP listen port is constructed without this overflow and
the daemon correctly listens on 48000:

languitar@miles:~$ lsof -i tcp:48000
COMMAND   PID      USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
spread  72864 languitar    6u  IPv4 0x665a353ce83db745      0t0  TCP
*:nimcontroller (LISTEN)

Kind regards,
Johannes

_______________________________________________
Spread-users mailing list
[email protected]
http://lists.spread.org/mailman/listinfo/spread-users
main.cpp (text/plain, 577 B)
#include <sp.h>
#include <iostream>

using namespace std;

int main() {

    cout << "SPREAD_VERSION: " << (SPREAD_VERSION >> 24) << "." << ((SPREAD_VERSION >> 16) & 0xFF) << "." << (SPREAD_VERSION & 0xFF) << endl;

    mailbox con;
    char spreadPrivateGroup[MAX_GROUP_NAME];
    int code = SP_connect("48000", 0, 0, 0, &con, spreadPrivateGroup);
    cout << "connect only port return code: " << code << endl;
    code = SP_connect("48000@localhost", 0, 0, 0, &con, spreadPrivateGroup);
    cout << "connect host and port return code: " << code << endl;
    return 0;    

}
spread.conf (text/plain, 60 B)
Spread_Segment  127.0.0.255:48000 {
	localhost		127.0.0.1
}
signature.asc (application/pgp-signature, 260 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.14 (Darwin)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iEYEARECAAYFAlIDoB4ACgkQBFcR5UV/ccJ10gCffj3DuUm1nfzOHnQgdIb8qbzj
C2MAoJmHn0M41ii3Fb4Ug4laKjVbfqzw
=xEp1
-----END PGP SIGNATURE-----