manish wrote:
> I am still unable to find an exact solution for this. Below are the
> suggestions that I got from James. My requirement is to open two IPv6 sockets
> and bind wildcard addresses to a fixed port.
This is not possible in Solaris. Solaris does not allow two
sockets in the same address family bind() to the same port and
same address (wildcard address in your case). No socket option
allows an app to bypass this rule. If both sockets bind() to
the same address/port, when the stack needs to deliver an
incoming packet destined to that address and port, which socket
will get it? This rule is to avoid this ambiguity. And this is
why Jim suggested to have one IPv4 socket and one IPv6 socket
with the IPV6_V6ONLY option set. I believe this suggestion works
in other platforms too.
Could you please explain why your app cannot have one IPv4 socket
and one IPv6 socket?
> /*****************************************************************************/
> I tried the TCP_EXCLBIND option but still i am unable to open and bind two
> sockets with the same IP:Port. Below is my program
>
> #include<stdio.h>
> #include<sys/socket.h>
> #include <netinet/in.h>
> #include <netinet/tcp.h>
> #include<sys/types.h>
> int main(){
> struct sockaddr_in6 sa;
> struct sockaddr_in6 sa1;
> int a,b,optval=1;
> int family=AF_INET6;
> memset(&sa,0,sizeof(struct sockaddr_in6));
> memset(&sa1,0,sizeof(struct sockaddr_in6));
> sa.sin6_port=htons(11304);
> sa1.sin6_port=htons(11304);
> sa.sin6_family=sa1.sin6_family=family;
> a=socket(AF_INET6,SOCK_STREAM,0);
> b=socket(AF_INET6,SOCK_STREAM,0);
> printf("Opened socket 1 = %d\n",a);
> printf("Opened socket 2 = %d\n",b);
>
> if((setsockopt(a,SOL_SOCKET,SO_REUSEADDR,&optval,sizeof(optval)))==-1)
> perror("Setsockopt failed :");
> else printf("optval = %d\n",optval);
> if((setsockopt(b,SOL_SOCKET,SO_REUSEADDR,&optval,sizeof(optval)))==-1)
> perror("Setsockopt failed :");
> else printf("optval = %d\n",optval);
>
> if((setsockopt(a,IPPROTO_TCP,TCP_EXCLBIND,&optval,sizeof(optval)))==-1)
> perror("Setsockopt failed :");
> else printf("optval = %d\n",optval);
> if((setsockopt(b,IPPROTO_TCP,TCP_EXCLBIND,&optval,sizeof(optval)))==-1)
> perror("Setsockopt failed :");
> else printf("optval = %d\n",optval);
>
> if(bind(a,(struct sockaddr *)&sa,sizeof(struct sockaddr_in6))==-1)
> perror("Bind 1 failed :");
> else
> printf("Bind 1 success\n");
> if(bind(b,(struct sockaddr *)&sa1,sizeof(struct sockaddr_in6))==-1)
> perror("Bind 2 failed :");
> else
> printf("Bind 2 success\n");
>
> printf("Done everything\n");
> close(a);
> close(b);
> return 0;
> }
>
>
>
> I also found an option SO_EXCLBIND in sun docs, but this is not defined in
> any of the headers. I am working on Solaris 10.
>
> /*******************************************************************************************/
> Manish Katiyar writes:
>> I tried the TCP_EXCLBIND option but still i am unable to open and bind two
>> sockets with the same IP:Port. Below is my program
>
> If you set TCP_EXCLBIND, then you can't bind two sockets to the same
> port. Solaris doesn't have the concept of a port "user" who is
> exempted from the port-binding rules.
>
> Why do you need to do that?
>
>> I also found an option SO_EXCLBIND in sun docs, but this is not defined in
>> any of the headers. I am working on Solaris 10.
>
> sys/socket.h has SO_EXCLBIND, but you'll only find it in Nevada, not
> S10. It was added by CR 6445396.
> /********************************************************************************************/
> Thanks James for the reply,
>
> I am seeing the docs from below url
>
> http://docs.sun.com/app/docs/doc/819-2244/6n4i17pdo?l=zh_TW&a=view
>
> We have a RPC application which we are porting for IPv6. Initially when we
> had only IPv4 we could use a wildcard address and a fixed port and add to our
> list of open descriptors along with some other info. So now we need to open
> these descriptors twice , once for IPv4 and IPv6. Since IPv6 sockets are able
> to handle IPv4 too we open V4 sockets too with family AF_INET6 and add it to
> list.
>
> But once we have opened for IPv4 it is not allowing to bind the fixed port to
> wildcard addresses for IPv6. For other platforms we used SO_REUSEPORT option
> to achieve this and thus want to implement the same in Solaris.
>
> We need to open it twice since while adding to the list we store a lot more
> stuff which is specific to that protocol.
>
> Hope I am clear.
>
> Thanks again.
> ******************************************************************************************
> Manish Katiyar writes:
>> We have a RPC application which we are porting for IPv6. Initially when we
>> had only IPv4 we could use a wildcard address and a fixed port and add to
>> our list of open descriptors along with some other info. So now we need to
>> open these descriptors twice , once for IPv4 and IPv6. Since IPv6 sockets
>> are able to handle IPv4 too we open V4 sockets too with family AF_INET6 and
>> add it to list.
>
> Use IPV6_V6ONLY.
> /*********************************************************************************/
> Using this option would mean that I will not be able to accept IPv4 mapped
> addresses on IPv6 sockets, and that would break our existing functionality on
> other platforms.
>
> Currently for other platforms we accept input of following form from client
> side.
>
> 1) ./client ncacn_ip_tcp:9.182.192.169 (Internally we treat this as mapped
> address since socket is opened on AF_INET6)
> 2) ./client ncacn_ipv6_tcp:::ffff: 9.182.192.169
> 3) ./client ncacn_ipv6_tcp:fe80::209:6bff:feeb:70b3
>
> Thus you can see we support all kind of addresses,( even though mapped
> addresses have some security risk, but we are not so much concerned about
> it). That is why i need to bind wildcard address to same port twice, one for
> ncacn_ip_tcp string and other for ncacn_ipv6_tcp string. because this is the
> way our server daemon listens on all other platforms.
> so basically i am looking for some way by which i can simulate the behaviour
> of SO_REUSEPORT on solaris.
>
> any suggestions??
>
> Thanks a lot for your inputs
> /*******************************************************************************************/
> Manish Katiyar writes:
>> Using this option would mean that I will not be able to accept IPv4 mapped
>> addresses on IPv6 sockets, and that would break our existing functionality
>> on other platforms.
>
> I don't think you want to use IPv4-mapped addresses; the IPv6 folks
> have not tried hard to make those interfaces work well at all.
> They're intended as a minimally-functional migration mechanism,
> nothing more.
>
> We've discussed some of the issues involved with IPv4-mapped addresses
> before,
> Using that option would (as far as I know) make your application work
> right on both Solaris and other platforms, minus the mapped address
> issue.
>
>> Thus you can see we support all kind of addresses,( even though mapped
>> addresses have some security risk, but we are not so much concerned about
>> it). That is why i need to bind wildcard address to same port twice, one for
>> ncacn_ip_tcp string and other for ncacn_ipv6_tcp string. because this is the
>> way our server daemon listens on all other platforms.
>
> The issue you're having isn't just with SO_REUSEPORT. It is:
>
> - Solaris IPv6 has only minimal support for IPv4-mapped, but you
> observe that it (apparently) works well on other platforms. How
> can anyone write portable applications if Solaris doesn't have
> equivalent support?
>
> - Solaris doesn't respect the current-UID mechanism that BSD has for
> determining port conflicts, so rebinding hurts.
>
>> so basically i am looking for some way by which i can simulate the behaviour
>> of SO_REUSEPORT on solaris.
>>
>> any suggestions??
>
> I would bind two separate sockets: one open on IPv4, and the other on
> IPv6 with the option set.
>
> /**************************************************************************************/
>
>
> This message posted from opensolaris.org
> _______________________________________________
> networking-discuss mailing list
> [email protected]
--
K. Poon.
[EMAIL PROTECTED]
_______________________________________________
networking-discuss mailing list
[email protected]