Use the protocol family constants for the domain argument validation.

Return immediately when the socket() failed.

Approved by:	kib (mentor)
MFC after:	1 month
This commit is contained in:
Dmitry Chagin 2009-05-16 18:44:56 +00:00
parent d4dd69c46c
commit 6994ea543f

View file

@ -602,10 +602,12 @@ linux_socket(struct thread *td, struct linux_socket_args *args)
return (EAFNOSUPPORT);
retval_socket = socket(td, &bsd_args);
if (retval_socket)
return (retval_socket);
if (bsd_args.type == SOCK_RAW
&& (bsd_args.protocol == IPPROTO_RAW || bsd_args.protocol == 0)
&& bsd_args.domain == AF_INET
&& retval_socket >= 0) {
&& bsd_args.domain == PF_INET) {
/* It's a raw IP socket: set the IP_HDRINCL option. */
int hdrincl;
@ -620,7 +622,7 @@ linux_socket(struct thread *td, struct linux_socket_args *args)
* default and some apps depend on this. So, set V6ONLY to 0
* for Linux apps if the sysctl value is set to 1.
*/
if (bsd_args.domain == PF_INET6 && retval_socket >= 0
if (bsd_args.domain == PF_INET6
#ifndef KLD_MODULE
/*
* XXX: Avoid undefined symbol error with an IPv4 only