Skip to content

Commit 28a94d8

Browse files
tomratbertdavem330
authored andcommitted
net: Allow MSG_EOR in each msghdr of sendmmsg
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 <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent f4a00aa commit 28a94d8

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

net/socket.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1875,7 +1875,8 @@ static int copy_msghdr_from_user(struct msghdr *kmsg,
18751875

18761876
static int ___sys_sendmsg(struct socket *sock, struct user_msghdr __user *msg,
18771877
struct msghdr *msg_sys, unsigned int flags,
1878-
struct used_address *used_address)
1878+
struct used_address *used_address,
1879+
unsigned int allowed_msghdr_flags)
18791880
{
18801881
struct compat_msghdr __user *msg_compat =
18811882
(struct compat_msghdr __user *)msg;
@@ -1901,6 +1902,7 @@ static int ___sys_sendmsg(struct socket *sock, struct user_msghdr __user *msg,
19011902

19021903
if (msg_sys->msg_controllen > INT_MAX)
19031904
goto out_freeiov;
1905+
flags |= (msg_sys->msg_flags & allowed_msghdr_flags);
19041906
ctl_len = msg_sys->msg_controllen;
19051907
if ((MSG_CMSG_COMPAT & flags) && ctl_len) {
19061908
err =
@@ -1979,7 +1981,7 @@ long __sys_sendmsg(int fd, struct user_msghdr __user *msg, unsigned flags)
19791981
if (!sock)
19801982
goto out;
19811983

1982-
err = ___sys_sendmsg(sock, msg, &msg_sys, flags, NULL);
1984+
err = ___sys_sendmsg(sock, msg, &msg_sys, flags, NULL, 0);
19831985

19841986
fput_light(sock->file, fput_needed);
19851987
out:
@@ -2024,15 +2026,15 @@ int __sys_sendmmsg(int fd, struct mmsghdr __user *mmsg, unsigned int vlen,
20242026
while (datagrams < vlen) {
20252027
if (MSG_CMSG_COMPAT & flags) {
20262028
err = ___sys_sendmsg(sock, (struct user_msghdr __user *)compat_entry,
2027-
&msg_sys, flags, &used_address);
2029+
&msg_sys, flags, &used_address, MSG_EOR);
20282030
if (err < 0)
20292031
break;
20302032
err = __put_user(err, &compat_entry->msg_len);
20312033
++compat_entry;
20322034
} else {
20332035
err = ___sys_sendmsg(sock,
20342036
(struct user_msghdr __user *)entry,
2035-
&msg_sys, flags, &used_address);
2037+
&msg_sys, flags, &used_address, MSG_EOR);
20362038
if (err < 0)
20372039
break;
20382040
err = put_user(err, &entry->msg_len);

0 commit comments

Comments
 (0)