[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[UNIKRAFT/LIBLWIP PATCH v3 16/16] plat/linuxu: Convert linux errno to unikraft errno



There are differences in errno between linux and unikraft. This patch
converts EAGAIN which is 11 in linux to unikraft which is 35.

Signed-off-by: Sharan Santhanam <sharan.santhanam@xxxxxxxxx>
---
 plat/linuxu/tap_io.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/plat/linuxu/tap_io.c b/plat/linuxu/tap_io.c
index edef18ed..efacf5f9 100644
--- a/plat/linuxu/tap_io.c
+++ b/plat/linuxu/tap_io.c
@@ -116,7 +116,10 @@ ssize_t tap_read(int fd, void *buf, size_t count)
        while (rc == -EINTR)
                rc = sys_read(fd, buf, count);
 
-       if (rc < 0)
+       if (rc == -11)
+               /* Explicitly added since linux errno has -11 for EAGAIN */
+               rc = -EWOULDBLOCK;
+       else if (rc < 0)
                uk_pr_err("Failed(%ld) to read from the tap device\n", rc);
 
        return rc;
@@ -131,7 +134,16 @@ ssize_t tap_write(int fd, const void *buf, size_t count)
                rc = sys_write(fd, buf + written, count);
                if (rc == -EINTR)
                        continue;
-               else if (rc < 0) {
+               else if (rc == -11) {
+                       /*
+                        * Explicitly added since linux errno has -11 for
+                        * EAGAIN.
+                        * FIXME: EAGAIN is not the only error code affected by
+                        * this issue (eg EDESTADDRREQ, EDQUOT). We should think
+                        * of a more generic solution to address it.
+                        */
+                       rc = -EAGAIN;
+               } else if (rc < 0) {
                        uk_pr_err("Failed(%ld) to write to the tap device\n",
                                  rc);
                        return rc;
-- 
2.20.1




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.