Linux 5.10 compat: remove set_fs()

This commit is contained in:
Rin Cat
2020-11-19 19:56:00 -05:00
parent 61a2ab6ce4
commit 64d833c13d
4 changed files with 44 additions and 0 deletions

View File

@@ -4250,7 +4250,9 @@ static int route_dump(u32 *gw_addr , int *gw_index)
struct msghdr msg;
struct iovec iov;
struct sockaddr_nl nladdr;
#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0))
mm_segment_t oldfs;
#endif
char *pg;
int size = 0;
@@ -4289,14 +4291,18 @@ static int route_dump(u32 *gw_addr , int *gw_index)
msg.msg_controllen = 0;
msg.msg_flags = MSG_DONTWAIT;
#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0))
oldfs = get_fs();
set_fs(KERNEL_DS);
#endif
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 1, 0))
err = sock_sendmsg(sock, &msg);
#else
err = sock_sendmsg(sock, &msg, sizeof(req));
#endif
#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0))
set_fs(oldfs);
#endif
if (err < 0)
goto out_sock;
@@ -4321,14 +4327,18 @@ restart:
iov_iter_init(&msg.msg_iter, READ, &iov, 1, PAGE_SIZE);
#endif
#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0))
oldfs = get_fs();
set_fs(KERNEL_DS);
#endif
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0))
err = sock_recvmsg(sock, &msg, MSG_DONTWAIT);
#else
err = sock_recvmsg(sock, &msg, PAGE_SIZE, MSG_DONTWAIT);
#endif
#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0))
set_fs(oldfs);
#endif
if (err < 0)
goto out_sock_pg;
@@ -4399,14 +4409,18 @@ done:
msg.msg_controllen = 0;
msg.msg_flags = MSG_DONTWAIT;
#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0))
oldfs = get_fs();
set_fs(KERNEL_DS);
#endif
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 1, 0))
err = sock_sendmsg(sock, &msg);
#else
err = sock_sendmsg(sock, &msg, sizeof(req));
#endif
#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0))
set_fs(oldfs);
#endif
if (err > 0)
goto restart;