Kaynağa Gözat

[LibOS, Pal/{Linux,Linux-SGX}] Add EAFNOSUPPORT error code

Some hosts do not support IPv6 (e.g., Docker can be configured without
it). In this case, socket() host syscall will return EAFNOSUPPORT.
Some applications rely on this error code (e.g., Redis), so Graphene must
propagate this error code all the way to the application. This commit
makes LibOS and Linux/Linux-SGX PALs aware of this error code.
jack.wxz 4 yıl önce
ebeveyn
işleme
d702477503

+ 1 - 0
LibOS/shim/src/shim_init.c

@@ -104,6 +104,7 @@ static int pal_errno_to_unix_errno [PAL_ERROR_NATIVE_COUNT + 1] = {
         /* PAL_ERROR_ZEROSIZE       */  0,
         /* PAL_ERROR_CONNFAILED     */  ECONNRESET,
         /* PAL_ERROR_ADDRNOTEXIST   */  EADDRNOTAVAIL,
+        /* PAL_ERROR_AFNOSUPPORT    */  EAFNOSUPPORT,
     };
 
 long convert_pal_errno (long err)

+ 2 - 2
Pal/src/host/Linux-SGX/pal_linux_error.h

@@ -34,8 +34,8 @@ static inline __attribute__((unused)) int unix_to_pal_error(int unix_errno) {
         case ECONNRESET:
         case EPIPE:
             return -PAL_ERROR_CONNFAILED;
-        case EPERM:
-            return -PAL_ERROR_DENIED;
+        case EAFNOSUPPORT:
+            return -PAL_ERROR_AFNOSUPPORT;
         default:
             return -PAL_ERROR_DENIED;
     }

+ 2 - 0
Pal/src/host/Linux/pal_linux_error.h

@@ -34,6 +34,8 @@ static inline __attribute__((unused)) int unix_to_pal_error(int unix_errno) {
         case ECONNRESET:
         case EPIPE:
             return -PAL_ERROR_CONNFAILED;
+        case EAFNOSUPPORT:
+            return -PAL_ERROR_AFNOSUPPORT;
         default:
             return -PAL_ERROR_DENIED;
     }

+ 1 - 0
Pal/src/pal_error.c

@@ -48,6 +48,7 @@ static const struct pal_error_description pal_error_list[] = {
     { PAL_ERROR_ZEROSIZE, "Zero size" },
     { PAL_ERROR_CONNFAILED, "Connection failed" },
     { PAL_ERROR_ADDRNOTEXIST, "Resource address does not exist" },
+    { PAL_ERROR_AFNOSUPPORT, "Address family not supported by protocol" },
 
     { PAL_ERROR_CRYPTO_FEATURE_UNAVAILABLE, "[Crypto] Feature not available" },
     { PAL_ERROR_CRYPTO_INVALID_CONTEXT, "[Crypto] Invalid context" },

+ 2 - 1
Pal/src/pal_error.h

@@ -52,8 +52,9 @@ typedef enum _pal_error_t {
     PAL_ERROR_ZEROSIZE,
     PAL_ERROR_CONNFAILED,
     PAL_ERROR_ADDRNOTEXIST,
+    PAL_ERROR_AFNOSUPPORT,
 
-#define PAL_ERROR_NATIVE_COUNT PAL_ERROR_ADDRNOTEXIST
+#define PAL_ERROR_NATIVE_COUNT PAL_ERROR_AFNOSUPPORT
 #define PAL_ERROR_CRYPTO_START PAL_ERROR_CRYPTO_FEATURE_UNAVAILABLE
 
     /* Crypto error constants and their descriptions are adapted from mbedtls. */