]> git.proxmox.com Git - mirror_kronosnet.git/commitdiff
[tx] Don't Clear out msghdr for all transports.
authorChristine Caulfield <ccaulfie@redhat.com>
Wed, 22 Jan 2020 15:15:49 +0000 (15:15 +0000)
committerFabio M. Di Nitto <fdinitto@redhat.com>
Fri, 31 Jan 2020 08:53:37 +0000 (09:53 +0100)
When sending a message to multiple links, if one of those links
is not connection-oriented then msg_name & msg_namelen would be cleared,
thus breaking the send to any subsequent non-connection-oriented links.

So now, if we need to clear out msg_name & msg_namelen, we take a copy of the
msghdr and edit that instead,

libknet/transport_common.c

index edd664971d86c5f5866cdd86e0aa27a1ee2863ed..1e4b09585103e4c60b2761af1946fca3f0717e37 100644 (file)
@@ -64,13 +64,19 @@ int _sendmmsg(int sockfd, int connection_oriented, struct knet_mmsghdr *msgvec,
 {
        int savederrno = 0, err = 0;
        unsigned int i;
+       struct msghdr temp_msg;
+       struct msghdr *use_msghdr;
 
        for (i = 0; i < vlen; i++) {
                if (connection_oriented == TRANSPORT_PROTO_IS_CONNECTION_ORIENTED) {
-                       msgvec[i].msg_hdr.msg_name = NULL;
-                       msgvec[i].msg_hdr.msg_namelen = 0;
+                       memcpy(&temp_msg, &msgvec[i].msg_hdr, sizeof(struct msghdr));
+                       temp_msg.msg_name = NULL;
+                       temp_msg.msg_namelen = 0;
+                       use_msghdr = &temp_msg;
+               } else {
+                       use_msghdr = &msgvec[i].msg_hdr;
                }
-               err = sendmsg(sockfd, &msgvec[i].msg_hdr, flags);
+               err = sendmsg(sockfd, use_msghdr, flags);
                savederrno = errno;
                if (err < 0) {
                        break;