Thread: Network Patch to specify IP Address to Bind to

Network Patch to specify IP Address to Bind to

From
"James A. Pattie"
Date:
I created a patch for the postgres/postmaster program so that I could
specify an IP Address to bind to.  This was needed for getting
PostgreSQL to work under the FreeVSD project (http://www.freevsd.org).

The behaviour is to specify argument -I IP_Address as part of the
options.  I just modified the call to StreamServerPort to take the IP
Address instead of the hostName.  I default the IP Address to "0.0.0.0"
which causes the default behaviour to occurr if you don't specify the -I
option.  In StreamServerPort I do some checking and then use
gethostbyname to give me the correct structure for the IP Address and
then set the correct values.  This code is currently only allocating 17
char's for the IP Address, so if anyone wants to specify a host name
they should change it to a longer value, etc.

I also modified the reset_shared function to add the current pid to the
calculation for ipc_key so that we have uniqueness even when using the
same port.

I am attaching the patch just for this feature.  If anyone is interested
in the work I did to get the FreeVSD project to automatically support
PostgreSQL, e-mail me and I'll send you the patches.

--
James A. Pattie
james@pcxperience.com

Linux  --  SysAdmin / Programmer
PC & Web Xperience, Inc.
http://www.pcxperience.com/




Re: Network Patch to specify IP Address to Bind to

From
Bruce Momjian
Date:
We have a more general solution from someone at uunet.  I will try to
merge it into the current cvs tree before beta starts.  If you want to
try it, I can send it over.


> I created a patch for the postgres/postmaster program so that I could
> specify an IP Address to bind to.  This was needed for getting
> PostgreSQL to work under the FreeVSD project (http://www.freevsd.org).
>
> The behaviour is to specify argument -I IP_Address as part of the
> options.  I just modified the call to StreamServerPort to take the IP
> Address instead of the hostName.  I default the IP Address to "0.0.0.0"
> which causes the default behaviour to occurr if you don't specify the -I
> option.  In StreamServerPort I do some checking and then use
> gethostbyname to give me the correct structure for the IP Address and
> then set the correct values.  This code is currently only allocating 17
> char's for the IP Address, so if anyone wants to specify a host name
> they should change it to a longer value, etc.
>
> I also modified the reset_shared function to add the current pid to the
> calculation for ipc_key so that we have uniqueness even when using the
> same port.
>
> I am attaching the patch just for this feature.  If anyone is interested
> in the work I did to get the FreeVSD project to automatically support
> PostgreSQL, e-mail me and I'll send you the patches.
>
> --
> James A. Pattie
> james@pcxperience.com
>
> Linux  --  SysAdmin / Programmer
> PC & Web Xperience, Inc.
> http://www.pcxperience.com/
>
>
>
>


--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026