Commit graph

114,354 commits

Message SHA1
Generate java code for VCN metrics
Add genrule for VCN metrics atoms and add wrapper utility class for logging using the generated java code, which currently has func for logging safe mode and VCN network validation states.

Bug: 288600040
Flag: EXEMPT METRICS
Test: atest CtsVcnTestCases, FrameworksVcnTests
Change-Id: Ia0f42c3435752399eb3ed480bfe62ffac31ccc1e

Hnin Naing   commited 2025-09-02 19:31:50 +00:00
340990fd30
Merge "Provide offload service information update from DiscoveryManager" into main
Paul Hu   authored and   Android (Google) Code Review   commited 2025-08-28 07:37:56 -07:00
9111ff26d4
Merge "Tethering: Enable TETHERING_AND_P2P_GO_LOCAL_AGENT for 25Q4+" into main
Treehugger Robot   authored and   Android (Google) Code Review   commited 2025-08-28 07:25:48 -07:00
3f16f0df11
bpf/progs/tcpAccECN.c: use static const for another local constant
Likely not needed for kernel verifier happiness,
since even 1 'static' constant prevents .rodata from being
entirely empty/automatic and thus BTF-less.

Trivial follow up to go/ag/35341088

Bug: 441356399
Bug: 441436401
Test: TreeHugger
Flag: EXEMPT mainline/bug fix
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I396d1a4f2d47225707348f7c7dc3548cbba125a0

Maciej Żenczykowski   commited 2025-08-27 23:01:24 -07:00
4203f5008e
Tethering: Enable TETHERING_AND_P2P_GO_LOCAL_AGENT for 25Q4+
This change enables the TETHERING_AND_P2P_GO_LOCAL_AGENT feature
on devices running Android 25Q4 or newer, in addition to being
controlled by the existing feature flag.

A new SdkUtil.isAtLeast25Q4() method is introduced to check for
the specific SDK version.

Flag: com.android.tethering.mainline.beta.tethering_and_p2p_go_local_agent
Test: atest ConnectivityCoverageTests --update-device \
      --test-filter '.*Tethering.*'
Test: TH
Bug: 420590461
Fix: 428098654
Fix: 420592689
Change-Id: I7ef79a201116de84f2c4973c4c360fd3d1ef0c4c

Junyu Lai   commited 2025-08-28 11:56:55 +08:00
bf75afdcd1
Merge "jni tests: set min_sdk_version=33" into main
Maciej Żenczykowski   authored and   Android (Google) Code Review   commited 2025-08-27 15:01:01 -07:00
4a4c1c4485
bpf/progs/tcpAccECN.c: use static const for local constants
loading BTF fails on 5.10 for tcpAccECN due to https://lore.kernel.org/bpf/20210119153519.3901963-1-yhs@fb.com

We're hitting the same problem on 5.10:
  ...
  NetBpfLoad: [381] DATASEC .rodata size=40 vlen=0 vlen == 0
  ...
  NetBpfLoad: libbpf: Error loading .BTF into kernel: -22. BTF is optional, ignoring.
  NetBpfLoad: libbpf: map 'sk_storage': failed to create: Invalid argument(-22)
  NetBpfLoad: libbpf: failed to load object '/apex/com.android.tethering/etc/bpf/mainline/netd.o'
  NetBpfLoad: Failed to load object: /apex/com.android.tethering/etc/bpf/mainline/netd.o, libbpf: 1
  NetBpfLoad: === CRITICAL FAILURE LOADING BPF PROGRAMS ===

so BTF fails, but SK_STORAGE *requires* BTF.

This is a kernel BTF verified failure fixed in later kernels.

step 1. Adjust the bpf helper definitions to more closely match kernel uabi in include/uapi/linux/bpf.h:
 * long bpf_sock_ops_cb_flags_set(struct bpf_sock_ops *bpf_sock, int argval)
 * long bpf_reserve_hdr_opt(struct bpf_sock_ops *skops, u32 len, u64 flags)
 * long bpf_store_hdr_opt(struct bpf_sock_ops *skops, const void *from, u32 len, u64 flags)

(some for consistency, but what matters is the 'const' addition)

Dump current .rodata via:
  adb pull /apex/com.android.tethering/etc/bpf/mainline/netd.o && llvm-objdump -s -j .rodata netd.o
  m netd.o && llvm-objdump -s -j .rodata /android/out/soong/.intermediates/packages/modules/Connectivity/bpf/progs/netd.o/android_common/obj/unstripped/packages/modules/Connectivity/bpf/progs/netd.o

.../netd.o:  file format elf64-bpf
Contents of section .rodata:
 0000 ae0b0000 00000000 00000000 00000000  ................
 0010 00000000 00000000 01000000 00000000  ................
 0020 01000000 00000000                    ........

which lines up with:

  #define CUSTOM_TCP_OPTION_KIND 174  // 0xAE
  #define CUSTOM_TCP_OPTION_SIZE 11   // 0x0B
  #define TCPHDR_SYN 0x02

            struct {
                __u8 kind;
                __u8 length;
                __u8 data[CUSTOM_TCP_OPTION_SIZE - 2];
            } __attribute__((packed)) tcp_option = {
                .kind = CUSTOM_TCP_OPTION_KIND,    // 0xAE
                .length = CUSTOM_TCP_OPTION_SIZE,  // 0x0B
                .data = {0},                       // 9 bytes
            };                                     // 5 byte alignment pad

and

  typedef struct{
    uint64_t ceb;
    uint64_t e0b;
    uint64_t e1b;
  } EcnByteCounters;
  STRUCT_SIZE(EcnByteCounters, 8 * 3);  <-- 24 bytes

  {
                        EcnByteCounters new_cnt = {
                            .ceb = 0,
                            .e0b = 1,
                            .e1b = 1,
                        };
                        bpf_l4s_accecn_byte_map_update_elem(&flow_key, &new_cnt, 0);
  }

Which matches the final 24 bytes.

So we convert those to 'static const' which hopefully will get them debug info.
(following the comment in the last line of the above linked patch)

Bug: 441356399
Bug: 441436401
Test: TreeHugger
Flag: EXEMPT mainline/bug fix
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I7d871c54ecccf2abc7834fde3c63c073cad29004

Maciej Żenczykowski   commited 2025-08-27 14:35:43 -07:00
157e8cd78b
Merge "tcpAccECN: increase min required kernel to 6.1" into main
Maciej Żenczykowski   authored and   Android (Google) Code Review   commited 2025-08-27 13:06:37 -07:00
76939cb1d0
tcpAccECN: increase min required kernel to 6.1
Appear to be failing on pixel 7 U (which is 5.10)

Flag: EXEMPT mainline
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I12d70659a994fd2a9f57597fd4aaa1aea6bbe1c7

Maciej Żenczykowski   commited 2025-08-27 13:06:28 -07:00
74d3460f5d
Merge "netjniutils: delete support for android R" into main
Maciej Żenczykowski   authored and   Android (Google) Code Review   commited 2025-08-27 13:05:29 -07:00
8aa8a4f1d1
Merge "Mock QuiConnectionCloser in ConnectivityServiceTest" into main
Treehugger Robot   authored and   Android (Google) Code Review   commited 2025-08-27 10:05:46 -07:00
0705d728b0
Merge "Revert "Add alint hook to Connectivity repo"" into main
Doğancan Emek   authored and   Android (Google) Code Review   commited 2025-08-27 05:22:35 -07:00
410585e22e
Merge "Ensure flag restoration logic is always executed in SetFeatureFlagsRule." into main
Treehugger Robot   authored and   Android (Google) Code Review   commited 2025-08-27 05:08:59 -07:00
8edee1e3e6
Merge "bpf_existence_test: remove support for Android R" into main
Maciej Żenczykowski   authored and   Android (Google) Code Review   commited 2025-08-27 04:22:27 -07:00
717a18c65c
Revert "Add alint hook to Connectivity repo"
This reverts commit 9fecf5dee1.

Reason for revert: <Removing alint hook from individual repos as we get ready to roll it out with a global flag>

Bug: 441250579
Change-Id: I12c4c31caa9e8881f4703a1022b607c6744a0c36

Doğancan Emek   authored and   Android (Google) Code Review   commited 2025-08-27 03:31:04 -07:00
4c46b200b7
Mock QuiConnectionCloser in ConnectivityServiceTest
ConnectivityServiceTest can not start QuicConnectionCloser and was
getting the following error.
The interaction between ConnectivityService and QuicConnectionCloser is
already covered by CSDestroySocketTest.
```
08-26 18:53:53.469 6243 11101 E QuicConnectionCloser: [SkDestroyListener] ERROR Failed to create rtnetlink socket: socket failed: EACCES (Permission denied)
08-26 18:53:53.469 6243 11101 E QuicConnectionCloser: android.system.ErrnoException: socket failed: EACCES (Permission denied)
08-26 18:53:53.469 6243 11101 E QuicConnectionCloser: at libcore.io.Linux.socket(Native Method)
08-26 18:53:53.469 6243 11101 E QuicConnectionCloser: at libcore.io.ForwardingOs.socket(ForwardingOs.java:821)
08-26 18:53:53.469 6243 11101 E QuicConnectionCloser: at libcore.io.BlockGuardOs.socket(BlockGuardOs.java:402)
08-26 18:53:53.469 6243 11101 E QuicConnectionCloser: at libcore.io.ForwardingOs.socket(ForwardingOs.java:821)
08-26 18:53:53.469 6243 11101 E QuicConnectionCloser: at android.system.Os.socket(Os.java:834)
08-26 18:53:53.469 6243 11101 E QuicConnectionCloser: at android.net.connectivity.com.android.net.module.util.ip.NetlinkMonitor.createFd(NetlinkMonitor.java:127)
08-26 18:53:53.469 6243 11101 E QuicConnectionCloser: at android.net.connectivity.com.android.net.module.util.FdEventsReader.createAndRegisterFd(FdEventsReader.java:217)
08-26 18:53:53.469 6243 11101 E QuicConnectionCloser: at android.net.connectivity.com.android.net.module.util.FdEventsReader.start(FdEventsReader.java:111)
08-26 18:53:53.469 6243 11101 E QuicConnectionCloser: at android.net.connectivity.com.android.server.connectivity.QuicConnectionCloser$$ExternalSyntheticLambda1.run(D8$$SyntheticClass:0)
08-26 18:53:53.469 6243 11101 E QuicConnectionCloser: at android.os.Handler.handleCallback(Handler.java:959)
08-26 18:53:53.469 6243 11101 E QuicConnectionCloser: at android.os.Handler.dispatchMessage(Handler.java:100)
08-26 18:53:53.469 6243 11101 E QuicConnectionCloser: at android.os.Looper.loopOnce(Looper.java:232)
08-26 18:53:53.469 6243 11101 E QuicConnectionCloser: at android.os.Looper.loop(Looper.java:317)
08-26 18:53:53.469 6243 11101 E QuicConnectionCloser: at android.os.HandlerThread.run(HandlerThread.java:85)
```

Bug: 311792075
Test: atest ConnectivityServiceTest
Flag: EXEMPT test only change
Change-Id: I8ae1033b2ea655ebc26300aac19ec4d8cbdc047d

Motomu Utsumi   commited 2025-08-27 01:17:10 -07:00
a74f8c7782
Ensure flag restoration logic is always executed in SetFeatureFlagsRule.
`base.evaluate()` can be interrupted by other rules in the chain, such
as DevSdkIgnoreRule, if an assumption fails. This prevents
SetFeatureFlagsRule from executing its flag value restoration logic,
leading to an inconsistent state. This change ensures the restoration
logic runs regardless of exceptions.

Flag: EXEMPT mainline
Bug: 440618747
Test: TH
Change-Id: Iba4483b45f11aeed8ae565f8080b2bebd299046c

Xiao Ma   commited 2025-08-27 16:55:12 +09:00
bda151cd67
Merge "Skip testCallbacks when unrestricted interfaces are present" into main
Patrick Rohr   authored and   Android (Google) Code Review   commited 2025-08-26 20:42:47 -07:00
41a8778165
Provide offload service information update from DiscoveryManager
With this change, the OffloadEngine can receive updates when
offload service information changes from DiscoveryManager. This
allows the OffloadEngine to maintain offload services and to
adjust its behavior accordingly.

Bug: 410734687
Test: atest ConnectivityCoverageTests
Flag: com.android.tethering.mainline.beta.nsd_selective_mdns_response_offload
Change-Id: I6c6ba4e76b4a2a94cbfef37bec9d6f87357bec5f

Paul Hu   commited 2025-08-27 02:13:32 +00:00
f1ae69a950
Merge "Set min_sdk_version for FrameworksNetTests." into main
Treehugger Robot   authored and   Android (Google) Code Review   commited 2025-08-26 16:34:00 -07:00
06fd2ba600
Skip testCallbacks when unrestricted interfaces are present
The old assumption check ran the test on devices with unrestricted
interfaces which were configured in the overlay. Apparently, this is
a common configuration on automotive devices.

There are likely other tests that are broken which need to be moved to
the new assumption check.

Test: TH
Flag: EXEMPT mainline
Change-Id: I504534920ea2c083a05bf217bec17a084a829184

Patrick Rohr   commited 2025-08-26 15:37:47 -07:00
2a8b4670a3
Merge "Set min_sdk_version for FrameworksNetSmokeTests." into main
Maciej Żenczykowski   authored and   Android (Google) Code Review   commited 2025-08-26 14:57:00 -07:00
03f8b6449b
Merge "bpf: build tcpAccECN into netd.o" into main
Maciej Żenczykowski   authored and   Android (Google) Code Review   commited 2025-08-26 13:00:18 -07:00
b21ed8fb38
Set min_sdk_version for FrameworksNetTests.
This change specifies that FrameworksNetTests requires a minimum SDK version of 31.

Test: TreeHugger
Flag: EXEMPT mainline
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ib47c879bc9c15196a7b0dbf5380d73eb94027356

Maciej Żenczykowski   commited 2025-08-26 12:26:45 -07:00
0078ef9d14
Set min_sdk_version for FrameworksNetSmokeTests.
This change sets the minimum SDK version for the FrameworksNetSmokeTests to 31.

Test: TreeHugger
Flag: EXEMPT mainline
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ib49bca2cf8e04593f2ab5758e7aaf709058029b2

Maciej Żenczykowski   commited 2025-08-26 12:25:02 -07:00
96edc9907c
Merge "netbpfload.35rc: grant capability SYSLOG if available" into main
Maciej Żenczykowski   authored and   Android (Google) Code Review   commited 2025-08-26 11:32:13 -07:00
439770c5e2
bpf: build tcpAccECN into netd.o
Note that currently bpfloader is *still* always <25Q4 (and thus <26Q2).

With this change:
  $ adb shell find /sys/fs/bpf/ | egrep -i tcp
is empty.

With the 26Q2 changed to 25Q3 it is not:
  $ adbz shell find /sys/fs/bpf/ | egrep -i tcp
  /sys/fs/bpf/netd_shared/prog_tcpAccECN_schedcls_egress_accecn_rawip
  /sys/fs/bpf/netd_shared/prog_tcpAccECN_schedcls_ingress_accecn_rawip
  /sys/fs/bpf/netd_shared/prog_tcpAccECN_schedcls_egress_accecn_eth
  /sys/fs/bpf/netd_shared/prog_tcpAccECN_schedcls_ingress_accecn_eth
  /sys/fs/bpf/netd_shared/prog_tcpAccECN_sockops_accecn_option
  /sys/fs/bpf/netd_shared/map_tcpAccECN_l4s_accecn_mss_map
  /sys/fs/bpf/netd_shared/map_tcpAccECN_l4s_accecn_byte_map
  /sys/fs/bpf/netd_shared/map_tcpAccECN_l4s_accecn_ce_map

Test: TreeHugger
Flag: EXEMPT mainline / noop
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I1c95a51e0774a2840fc906a2128ed5d71097dab6

Maciej Żenczykowski   commited 2025-08-26 09:59:20 -07:00
23057f4db5
bpf_existence_test: remove support for Android R
As of M-2025-11 mainline is only being pushed to S+

Test: TreeHugger
Flag: EXEMPT test only
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Id0cf9d2cce27fb90ce076fcdd0f6ee0a95ea9741

Maciej Żenczykowski   commited 2025-08-26 09:56:45 -07:00
1780108641
netjniutils: delete support for android R
Mainline M-2025-11 drops support for android R,
thus making the new minimum Android 12 / S (api 31)

Once we get this to pass tests, we can merge it,
then we need to bump min sdk to 31, then we can
probably get rid of the dlsym stuff and just link it directly.

Test: TreeHugger
Flag: EXEMPT mainline
Signed-off-by: Maciej Żenczykowski <maze@google.com
Change-Id: I9d68ea9f4aa180b3ec24d252bcd49593e19cf475

Maciej Żenczykowski   commited 2025-08-26 09:56:44 -07:00
94d800d96f
Don't set setPollOnOpen in SatelliteCoarseUsageMetricsCollector.
This is not safe to do in system server because it affects all
system server callers of NetworkStatsManager, including ones
that frequently call into NetworkStatsService, such as
NetworkPolicyManagerService.

Also, setPollOnOpen is unnecessary because data usage is only collected when processing the `onLost` callback, which is triggered after ConnectivityService forces a poll.

Fix: 427909947
Flag: EXEMPT BUGFIX
Test: covered by existing tests
Change-Id: I2fb25f4529d46dfc14b00b0aa69c5145317ca9dd

Lorenzo Colitti   commited 2025-08-26 03:05:26 -07:00
9a0b0d4156
Merge "Add metrics for BPF shim initialization error" into main
Jimi Chen   authored and   Android (Google) Code Review   commited 2025-08-25 23:54:35 -07:00
6b09ae0ace
tcpAccECN: Add to the dependency of the tethering apex
This CL also sorts bpf targets in Android.bp

Test: m
Bug: 440448408
Flag: EXEMPT tcpAccECN is not used
Change-Id: I4a662870333f3da02d4d6cfcb3fca8c0af452d34

Motomu Utsumi   commited 2025-08-26 10:21:53 +09:00
95ab63a373
Merge "Pass trackingReason directly" into main
Treehugger Robot   authored and   Android (Google) Code Review   commited 2025-08-25 13:13:28 -07:00
320ffc7a45
Pass trackingReason directly
This seemed to have been an oversight in the original change. There is
no need to call getInterfaceTrackingReason here; it can just use the
tracking reason that is passed to the function (and passed to
addInterface above).

Test: TH
Flag: EXEMPT mainline
Change-Id: I33322c5bfeaaf8f11f3251aff1b1ccac845a993b

Patrick Rohr   commited 2025-08-25 11:14:45 -07:00
5b27c39564
Merge "NetBpfLoad: use macro for mainline beta flag" into main
Maciej Żenczykowski   authored and   Android (Google) Code Review   commited 2025-08-25 10:54:37 -07:00
c528cbf687
Merge "tcpAccECN: remove duplicated definitions of load_word and load_half" into main
Maciej Żenczykowski   authored and   Android (Google) Code Review   commited 2025-08-25 10:52:10 -07:00
bfd1b36ea0
Merge "tcpAccECN: add build target" into main
Maciej Żenczykowski   authored and   Android (Google) Code Review   commited 2025-08-25 10:51:00 -07:00
96694e36ca
Merge "tcpAccECN: update DEFINE_BPF_PROG to follow the current syntax" into main
Maciej Żenczykowski   authored and   Android (Google) Code Review   commited 2025-08-25 10:50:16 -07:00
0562b55916
Merge "tcpAccECN: remove CRITICAL" into main
Maciej Żenczykowski   authored and   Android (Google) Code Review   commited 2025-08-25 10:49:28 -07:00
e77c943066
Merge "tcpAccECN: define required macros" into main
Maciej Żenczykowski   authored and   Android (Google) Code Review   commited 2025-08-25 10:49:01 -07:00
c36345cfdf
Merge "tcpAccECN: remove carriage returns" into main
Maciej Żenczykowski   authored and   Android (Google) Code Review   commited 2025-08-25 10:48:05 -07:00
23215028c4
Merge "NetBpfLoad: Add default map flag for BPF_MAP_TYPE_LRU_HASH" into main
Maciej Żenczykowski   authored and   Android (Google) Code Review   commited 2025-08-25 10:47:16 -07:00
2de52a3d0b
NetBpfLoad: use macro for mainline beta flag
Flag: com.android.tethering.readonly.flags.use_libbpf
Bug: 428792764
Test: Enable/Disable flag, boot, adb shell logcat
Change-Id: I40e6124f6c96cf09ce50f38d786f15847ec6f69d

Motomu Utsumi   commited 2025-08-25 20:54:37 +09:00
aa8717db44
tcpAccECN: remove duplicated definitions of load_word and load_half
bpf_helpers.h has the same definitions

Test: m tcpAccECN.o
Bug: 440448408
Flag: EXEMPT tcpAccECN is not used
Change-Id: Ie5b47bdcbc2aa8d4563cf3ec0806f8dfc6861801

Motomu Utsumi   commited 2025-08-25 16:10:56 +09:00
5cb1506a75
tcpAccECN: add build target
Test: m tcpAccECN.o
Bug: 440448408
Flag: EXEMPT tcpAccECN is not used
Change-Id: Id8f5e3cfb55b3b698b496dbb4beee857a5a4c87a

Motomu Utsumi   commited 2025-08-25 16:02:04 +09:00
86a3a4a7ca
Add metrics for BPF shim initialization error
```
statsd_testdrive 979

metric_id: 1111
event_metrics {
  data {
    aggregated_atom_info {
      atom {
        979: {
          1: 15
        }
      }
      elapsed_timestamp_nanos: 66003587918
      elapsed_timestamp_nanos: 66004273970
      elapsed_timestamp_nanos: 72331748965
      elapsed_timestamp_nanos: 72332440169
      elapsed_timestamp_nanos: 77164965823
      elapsed_timestamp_nanos: 77165560176
    }
  }
}
is_active: true
estimated_data_bytes: 60
```

Flag: EXEMPT mainline
Bug: 430428550
Test: statsd_testdrive
Change-Id: I3bc5975545589ab51af5312038830b94251c11ee

Jimi Chen   commited 2025-08-25 04:13:38 +00:00
95c9e42669
tcpAccECN: update DEFINE_BPF_PROG to follow the current syntax
This CL also sets the min kver to 5.10.
skb_tcp_flags field in bpf_sock_ops was introduced on 5.10 kernel

Test: TH
Bug: 440448408
Flag: EXEMPT tcpAccECN is not used
Change-Id: I71696e0bf3b36296c5f2e7fd5b692406d96ddf97

Motomu Utsumi   commited 2025-08-25 13:04:48 +09:00
bf24fdbcc2
tcpAccECN: remove CRITICAL
CRITICAL section was removed by ag/33605170

Test: TH
Bug: 440448408
Flag: EXEMPT tcpAccECN is not used
Change-Id: I6de89edd7547ede1ecdd18b5ee80fb9bc1977915

Motomu Utsumi   commited 2025-08-25 12:55:14 +09:00
9d5f30d8d6
tcpAccECN: define required macros
Test: TH
Bug: 440448408
Flag: EXEMPT tcpAccECN is not used
Change-Id: I9fbbd03d5bf2d6955082dfdb6f7e9279ad840b61

Motomu Utsumi   commited 2025-08-25 12:55:14 +09:00
4f585bdfac
tcpAccECN: remove carriage returns
$ sed -i 's/\r$//g' bpf/progs/tcpAccECN.c
$ sed -i 's/\r$//g' bpf/progs/tcpAccECN.h

Test: TH
Bug: 440448408
Flag: EXEMPT tcpAccECN is not used
Change-Id: Iffde87607e95920dc839e6901e0ba40912f83a49

Motomu Utsumi   commited 2025-08-25 12:55:14 +09:00
c2c0572ae8