Skip to content

Commit

Permalink
net: Allow MSG_EOR in each msghdr of sendmmsg
Browse files Browse the repository at this point in the history
This patch allows setting MSG_EOR in each individual msghdr passed
in sendmmsg. This allows a sendmmsg to send multiple messages when
using SOCK_SEQPACKET.

Signed-off-by: Tom Herbert <tom@herbertland.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Tom Herbert authored and David S. Miller committed Mar 9, 2016
1 parent f4a00aa commit 28a94d8
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions net/socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -1875,7 +1875,8 @@ static int copy_msghdr_from_user(struct msghdr *kmsg,

static int ___sys_sendmsg(struct socket *sock, struct user_msghdr __user *msg,
struct msghdr *msg_sys, unsigned int flags,
struct used_address *used_address)
struct used_address *used_address,
unsigned int allowed_msghdr_flags)
{
struct compat_msghdr __user *msg_compat =
(struct compat_msghdr __user *)msg;
Expand All @@ -1901,6 +1902,7 @@ static int ___sys_sendmsg(struct socket *sock, struct user_msghdr __user *msg,

if (msg_sys->msg_controllen > INT_MAX)
goto out_freeiov;
flags |= (msg_sys->msg_flags & allowed_msghdr_flags);
ctl_len = msg_sys->msg_controllen;
if ((MSG_CMSG_COMPAT & flags) && ctl_len) {
err =
Expand Down Expand Up @@ -1979,7 +1981,7 @@ long __sys_sendmsg(int fd, struct user_msghdr __user *msg, unsigned flags)
if (!sock)
goto out;

err = ___sys_sendmsg(sock, msg, &msg_sys, flags, NULL);
err = ___sys_sendmsg(sock, msg, &msg_sys, flags, NULL, 0);

fput_light(sock->file, fput_needed);
out:
Expand Down Expand Up @@ -2024,15 +2026,15 @@ int __sys_sendmmsg(int fd, struct mmsghdr __user *mmsg, unsigned int vlen,
while (datagrams < vlen) {
if (MSG_CMSG_COMPAT & flags) {
err = ___sys_sendmsg(sock, (struct user_msghdr __user *)compat_entry,
&msg_sys, flags, &used_address);
&msg_sys, flags, &used_address, MSG_EOR);
if (err < 0)
break;
err = __put_user(err, &compat_entry->msg_len);
++compat_entry;
} else {
err = ___sys_sendmsg(sock,
(struct user_msghdr __user *)entry,
&msg_sys, flags, &used_address);
&msg_sys, flags, &used_address, MSG_EOR);
if (err < 0)
break;
err = put_user(err, &entry->msg_len);
Expand Down

0 comments on commit 28a94d8

Please sign in to comment.