diff options
| author | 2022-03-31 00:31:12 +0800 | |
|---|---|---|
| committer | 2022-03-31 03:41:20 +0800 | |
| commit | 806c30f5554bc6efc9cf81e9bbe6a9dc382ea8e9 (patch) | |
| tree | ed133a4a482b16de2fc6e196bc87631b0d87d7bd | |
| parent | 171a64a823952b0ab210688a1d342e9882078400 (diff) | |
Update data type and comments on tagSocket/untagSocket APIs
- Use uint32_t for tag
- Document some possible error codes
- Explain what the tag is used for
Bug: 223423155
Test: CtsNetTestCases:android.net.TrafficStatsTest
Test: CtsNativeNetPlatformTestCases
Change-Id: Ib5b95f7d8e2158cc31183c2d5a4964244e295eb2
| -rw-r--r-- | include/android/multinetwork.h | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/include/android/multinetwork.h b/include/android/multinetwork.h index 4c83a14728..ee392fc401 100644 --- a/include/android/multinetwork.h +++ b/include/android/multinetwork.h @@ -235,7 +235,7 @@ void android_res_cancel(int nsend_fd) __INTRODUCED_IN(29); * * Available since API level 33. */ -int android_tag_socket_with_uid(int sockfd, int tag, uid_t uid) __INTRODUCED_IN(33); +int android_tag_socket_with_uid(int sockfd, uint32_t tag, uid_t uid) __INTRODUCED_IN(33); /* * Set the socket tag for traffic statistics on the specified socket. @@ -245,14 +245,26 @@ int android_tag_socket_with_uid(int sockfd, int tag, uid_t uid) __INTRODUCED_IN( * opened by another UID or was previously tagged by another UID. Subsequent * calls always replace any existing parameters. The socket tag is kept when the * socket is sent to another process using binder IPCs or other mechanisms such - * as UNIX socket fd passing. + * as UNIX socket fd passing. The tag is a value defined by the caller and used + * together with uid for data traffic accounting, so that the function callers + * can account different types of data usage for a uid. * * Returns 0 on success, or a negative POSIX error code (see errno.h) on * failure. * + * Some possible error codes: + * -EBADF Bad socketfd. + * -EPERM No permission. + * -EAFNOSUPPORT Socket family is neither AF_INET nor AF_INET6. + * -EPROTONOSUPPORT Socket protocol is neither IPPROTO_UDP nor IPPROTO_TCP. + * -EMFILE Too many stats entries. + * There are still other error codes that may provided by -errno of + * [getsockopt()](https://man7.org/linux/man-pages/man2/getsockopt.2.html) or by + * BPF maps read/write sys calls, which are set appropriately. + * * Available since API level 33. */ -int android_tag_socket(int sockfd, int tag) __INTRODUCED_IN(33); +int android_tag_socket(int sockfd, uint32_t tag) __INTRODUCED_IN(33); /* * Untag a network socket. @@ -267,6 +279,12 @@ int android_tag_socket(int sockfd, int tag) __INTRODUCED_IN(33); * Returns 0 on success, or a negative POSIX error code (see errno.h) on * failure. * + * One of possible error code: + * -EBADF Bad socketfd. + * Other error codes are either provided by -errno of + * [getsockopt()](https://man7.org/linux/man-pages/man2/getsockopt.2.html) or by + * BPF map element deletion sys call, which are set appropriately. + * * Available since API level 33. */ int android_untag_socket(int sockfd) __INTRODUCED_IN(33); |