Pages: [1]
  Print  
Author Topic: Linux dedicated server IP address bug (?)  (Read 11276 times)
Speaker
Half-Nub


Cakes 0
Posts: 68



« on: November 20, 2008, 04:48:43 AM »

Hi,

I had some problems with starting a dedicated server under Linux. The server could not determine the correct IP address to use even when I specified it in the 'net_ip' Cvar in the config file.

System:
MSI KT6V MB
AMD Sempron 1800 CPU
512 MB RAM
Abit Siluro Geforce4 video card
Seagate 80 GB IDE HD
Vector Linux 5.9

I don't know if the bug appears on other systems (I had no way to test this).

Checking the source code I found the following code in 'net_ip.c':

---------------------------------------
void NET_OpenIP( void ) {
   int i;
   int err;
   int port;
   int port6;

   net_ip = Cvar_Get( "net_ip", "0.0.0.0", CVAR_LATCH );
---------------------------------------

 It appears that the Cvar 'net_ip' is not read from the config and defaults to '0.0.0.0'  This is OK for the client because in 'Sys_StringToSockaddr' the string '0.0.0.0' will result in the IP addrres 127.0.0.1, i.e. the localhost). However, it is wrong  for dedicated servers that should use the default address of the host or the address specified in 'net_ip'.

I replaced the code with the following:

---------------------------------------
void NET_OpenIP( void ) {
  int i;
  int err;
  int port;
  int port6;
  char hostname[256], *hnp;

   hnp = &hostname[0];

#if defined DEDICATED
  gethostname(hnp, 255);    // use our hostname for resolving the IP address
#else
  strcpy(hostname, "0.0.0.0");    // original way of resolving
#endif

  net_ip = Cvar_Get( "net_ip", hnp, CVAR_LATCH );
---------------------------------------

This works, but is not perfect because it does not solve the problem of not reading 'net_ip' correctly. It may still fail when multiple servers use several network cards with different IP addresses on a single machine. However,  I do  not have the time (or motive) to correct the Cvar reading code. My server works now and that's good enough for me :-)

I don't know if this is the right place for this report. Should I submit it to the ioq3 developers? Can anyone here at OA do anything about it?
Logged
sago007
Posts a lot
*

Cakes 62
Posts: 1664


Open Arena Developer


WWW
« Reply #1 on: November 20, 2008, 09:15:56 AM »

Have you tried to start the dedicated server with "+set net_ip X.X.X.X"?

Some CVARs can only be set from the command line and are made read-only before the config file is read.
Logged

There are nothing offending in my posts.
Speaker
Half-Nub


Cakes 0
Posts: 68



« Reply #2 on: November 20, 2008, 03:20:16 PM »

Have you tried to start the dedicated server with "+set net_ip X.X.X.X"?

Some CVARs can only be set from the command line and are made read-only before the config file is read.

Thanks for the tip. However, I have just  tried that, and it does not work. Actually, 'net_ip' is of type CVAR_LATCH i.e. 'will only change when C code next does a Cvar_Get(), so it can't be changed without proper initialization.  modified will be set, even though the value hasn't changed yet' (comment taken from 'q_shared.h' where Cvar types are defined). The command-line-only Cvar you mentioned would be of type CVAR_INIT.
Logged
damocles
Bigger member


Cakes 0
Posts: 158


May cause drowsiness


« Reply #3 on: November 21, 2008, 02:58:58 PM »

What does the end of the log output say?

0.0.0.0 (or localhost or the other addresses it is able to find) should be correct in most cases, unless you really do have your own IP address or interface and know what you want.

./oa_ded.i386
Code:
--- Common Initialization Complete ---
IP: 127.0.0.1
IP: 192.168.0.1
IP6: ::1
IP6: ...
Opening IP socket: 0.0.0.0:27960


./oa_ded.i386 +set net_ip 192.168.0.1
Code:
...
Opening IP socket: 192.168.0.1:27960
Logged
Speaker
Half-Nub


Cakes 0
Posts: 68



« Reply #4 on: November 22, 2008, 02:43:17 AM »

@damocles:

Unfortunately, specifying the IP address on the command line does not work for me. It is a bit strange, since the log says 'Opening IP socket:  X.X.X.X:27960' as it should, but I cannot connect to the server from another machine on the LAN. When I run my new server version (with the code as shown in the first post above), the log says 'Opening IP socket: ABCD:27960' where 'ABCD' is the correct hostname of my server machine, and in this case I can connect to the server.

Well, I will have to have a closer look at the network code. I suspect that the error occurs in 'Sys_StringToSockaddress' (net_ip.c). It calls 'getaddrinfo' which is a POSIX socket library function, but as far as I could determine, this function will not accept numeric IP address strings unless a flag is set in one of the structures used as argument (rather complicated). And it seems to me that in the ioq3 code it is not done properly.

I guess it is better if I take this issue to the ioq3 forum, because here at OA probably nobody can do anything about this. This is not meant as criticism: I realize that OA depends on the ioq3 source releases and only the absolutely necessary changes are applied here.
Logged
sago007
Posts a lot
*

Cakes 62
Posts: 1664


Open Arena Developer


WWW
« Reply #5 on: November 22, 2008, 05:08:17 AM »

Have you tried "+set net_ip HOSTNAME"?

Normally binding to 0.0.0.0 should bind to all interfaces and that is what most people want, especially when running a listening server.
Logged

There are nothing offending in my posts.
Cacatoes
Banned for leasing own account
Posts a lot
*

Cakes 73
Posts: 1427


also banned for baiting another to violate rules


« Reply #6 on: November 22, 2008, 06:20:11 AM »

Just to add some guy I helped on another forum had an issue with net_ip, if he did things well, adding "net_ip" as a command line parameter didn't help and opening of sockets were always attempt at  0.0.0.0. He was running Windows XP, though. I tried on Win XP too but had no issue.
Logged

Todo: Walk the cat.
Speaker
Half-Nub


Cakes 0
Posts: 68



« Reply #7 on: November 23, 2008, 02:17:25 AM »

@sago007:

I just tested using the host name on the command line, and it does not work.

@Cacatoes:

I have not tried this under Win XP. but if my suspicion turns out to be correct, the same bug should appear. Maybe I will do a little testing later.

Did you run the latest version (0.8.1) under XP? I ask this because the bug is most probably version specific, it may not show up in earlier versions of OA. Apparently, starting with OA version 0.8.0 a quite recent branch of the ioq3 source has been used. with lots of changes as compared to earlier versions.
Logged
Cacatoes
Banned for leasing own account
Posts a lot
*

Cakes 73
Posts: 1427


also banned for baiting another to violate rules


« Reply #8 on: November 23, 2008, 03:37:50 AM »

I had 0.8.1, IP reading from command-line worked fine.
But he had 0.7.6, then updated to 0.8.1.
I'll post if I have further infos Wink
Logged

Todo: Walk the cat.
damocles
Bigger member


Cakes 0
Posts: 158


May cause drowsiness


« Reply #9 on: November 23, 2008, 03:54:29 PM »

Have you tried the legacy binaries (there is different net code with those, no IPv6, etc.)?
Logged
Speaker
Half-Nub


Cakes 0
Posts: 68



« Reply #10 on: November 24, 2008, 01:11:12 AM »

@Cacatoes:

Thanks, I would appreciate any additional info.

@damocles:

Not yet, so far all my testing was done under Linux (no legacy version). But it is a good idea.
Logged
Pages: [1]
  Print  
 
Jump to: