clat: just always set mark unconditionally, part 2
Setting SO_MARK to MARK_UNSET, ie. 0, is harmless,
since the default for a brand new socket is already 0.
See ClatCoordinator.java getFwMark() for the mark we actually pass in,
which is guaranteed to have at least 4 bits (16,17,18,19) set.
See also:
https://android-review.git.corp.google.com/c/platform/packages/modules/Connectivity/+/2392272
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I3b4eebc0a5ad20390a13efcc58cecf94868686ba
diff --git a/service/native/libs/libclat/clatutils.cpp b/service/native/libs/libclat/clatutils.cpp
index 64e5b91..c6a9781 100644
--- a/service/native/libs/libclat/clatutils.cpp
+++ b/service/native/libs/libclat/clatutils.cpp
@@ -29,9 +29,6 @@
#include "checksum.h"
}
-// Sync from system/netd/include/netid_client.h.
-#define MARK_UNSET 0u
-
namespace android {
namespace net {
namespace clat {
@@ -128,7 +125,7 @@
// Socket's mark affects routing decisions (network selection)
// An fwmark is necessary for clat to bypass the VPN during initialization.
- if ((mark != MARK_UNSET) && setsockopt(s, SOL_SOCKET, SO_MARK, &mark, sizeof(mark))) {
+ if (setsockopt(s, SOL_SOCKET, SO_MARK, &mark, sizeof(mark))) {
int ret = errno;
ALOGE("setsockopt(SOL_SOCKET, SO_MARK) failed: %s", strerror(errno));
close(s);
@@ -176,7 +173,7 @@
}
// Socket's mark affects routing decisions (network selection)
- if ((mark != MARK_UNSET) && setsockopt(s, SOL_SOCKET, SO_MARK, &mark, sizeof(mark))) {
+ if (setsockopt(s, SOL_SOCKET, SO_MARK, &mark, sizeof(mark))) {
int ret = errno;
ALOGE("setsockopt(SOL_SOCKET, SO_MARK) failed: %s", strerror(errno));
close(s);