Fix UDP socket bug (XCC)
authorBarret Rhoden <brho@cs.berkeley.edu>
Fri, 23 Oct 2015 18:26:07 +0000 (14:26 -0400)
committerBarret Rhoden <brho@cs.berkeley.edu>
Wed, 28 Oct 2015 16:05:14 +0000 (12:05 -0400)
All UDP sockets were pointing at conversation 0.  We would successfully
clone a new UDP conversation, but when we attempted to read the ctl
file, we'd get an empty string back instead of the conversation ID.
That worked if our conversation happened to be 0, but otherwise would
fail.

The root cause was that we advanced the offset by 7 when we wrote the
"headers" command for UDP sockets.  We need to reset the chan back to 0
before reading.

Rebuild glibc.

Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
tools/compilers/gcc-glibc/glibc-2.19-akaros/sysdeps/akaros/socket.c

index f75fbc4..39e38bd 100644 (file)
@@ -43,8 +43,9 @@ int __socket(int domain, int type, int protocol)
                                case SOCK_DGRAM:
                                        net = "udp";
                                        cfd = open("/net/udp/clone", open_flags);
-                                       /* All BSD UDP sockets are in 'headers' mode, where each packet has
-                                        * the remote addr:port, local addr:port and other info. */
+                                       /* All BSD UDP sockets are in 'headers' mode, where each
+                                        * packet has the remote addr:port, local addr:port and
+                                        * other info. */
                                        if (!(cfd < 0)) {
                                                n = snprintf(msg, sizeof(msg), "headers");
                                                n = write(cfd, msg, n);
@@ -52,6 +53,10 @@ int __socket(int domain, int type, int protocol)
                                                        perror("UDP socket headers failed");
                                                        return -1;
                                                }
+                                               if (lseek(cfd, 0, SEEK_SET) != 0) {
+                                                       perror("UDP socket seek failed");
+                                                       return -1;
+                                               }
                                        }
                                        break;
                                case SOCK_STREAM: