Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F146621350
D44375.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D44375.diff
View Options
diff --git a/sys/compat/linux/linux.c b/sys/compat/linux/linux.c
--- a/sys/compat/linux/linux.c
+++ b/sys/compat/linux/linux.c
@@ -501,8 +501,8 @@
return (ENOENT);
}
-int
-linux_to_bsd_domain(int domain)
+sa_family_t
+linux_to_bsd_domain(sa_family_t domain)
{
switch (domain) {
@@ -523,11 +523,11 @@
case LINUX_AF_NETLINK:
return (AF_NETLINK);
}
- return (-1);
+ return (AF_UNKNOWN);
}
-int
-bsd_to_linux_domain(int domain)
+sa_family_t
+bsd_to_linux_domain(sa_family_t domain)
{
switch (domain) {
@@ -548,7 +548,7 @@
case AF_NETLINK:
return (LINUX_AF_NETLINK);
}
- return (-1);
+ return (AF_UNKNOWN);
}
/*
@@ -562,13 +562,13 @@
socklen_t len)
{
struct l_sockaddr *kosa;
- int bdom;
+ sa_family_t bdom;
*lsa = NULL;
if (len < 2 || len > UCHAR_MAX)
return (EINVAL);
bdom = bsd_to_linux_domain(sa->sa_family);
- if (bdom == -1)
+ if (bdom == AF_UNKNOWN)
return (EAFNOSUPPORT);
kosa = malloc(len, M_LINUX, M_WAITOK);
@@ -615,7 +615,7 @@
goto out;
bdom = linux_to_bsd_domain(kosa->sa_family);
- if (bdom == -1) {
+ if (bdom == AF_UNKNOWN) {
error = EAFNOSUPPORT;
goto out;
}
diff --git a/sys/compat/linux/linux_common.h b/sys/compat/linux/linux_common.h
--- a/sys/compat/linux/linux_common.h
+++ b/sys/compat/linux/linux_common.h
@@ -38,8 +38,9 @@
int linux_ifhwaddr(struct ifnet *ifp, struct l_sockaddr *lsa);
unsigned short bsd_to_linux_ifflags(int);
-int linux_to_bsd_domain(int domain);
-int bsd_to_linux_domain(int domain);
+sa_family_t linux_to_bsd_domain(sa_family_t domain);
+sa_family_t bsd_to_linux_domain(sa_family_t domain);
+#define AF_UNKNOWN UINT8_MAX
int bsd_to_linux_sockaddr(const struct sockaddr *sa,
struct l_sockaddr **lsa, socklen_t len);
int linux_to_bsd_sockaddr(const struct l_sockaddr *lsa,
diff --git a/sys/compat/linux/linux_socket.c b/sys/compat/linux/linux_socket.c
--- a/sys/compat/linux/linux_socket.c
+++ b/sys/compat/linux/linux_socket.c
@@ -870,7 +870,8 @@
int
linux_socket(struct thread *td, struct linux_socket_args *args)
{
- int domain, retval_socket, type;
+ int retval_socket, type;
+ sa_family_t domain;
type = args->type & LINUX_SOCK_TYPE_MASK;
if (type < 0 || type > LINUX_SOCK_MAX)
@@ -880,7 +881,7 @@
if (retval_socket != 0)
return (retval_socket);
domain = linux_to_bsd_domain(args->domain);
- if (domain == -1) {
+ if (domain == AF_UNKNOWN) {
/* Mask off SOCK_NONBLOCK / CLOEXEC for error messages. */
type = args->type & LINUX_SOCK_TYPE_MASK;
if (args->domain == LINUX_AF_NETLINK &&
@@ -2309,8 +2310,8 @@
name, &newval, UIO_SYSSPACE, &len);
if (error != 0)
return (error);
- newval = bsd_to_linux_domain(newval);
- if (newval == -1)
+ newval = bsd_to_linux_domain((sa_family_t)newval);
+ if (newval == AF_UNKNOWN)
return (ENOPROTOOPT);
return (linux_sockopt_copyout(td, &newval,
len, args));
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Mar 5, 4:34 AM (9 h, 14 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
29271313
Default Alt Text
D44375.diff (2 KB)
Attached To
Mode
D44375: linux: use sa_family_t for address family conversions
Attached
Detach File
Event Timeline
Log In to Comment