Merge changes from topic "v6_tether"

* changes:
  switch bpf programs to group network_stack
  Add tethering programs for upstream.
diff --git a/Tethering/apishim/31/com/android/networkstack/tethering/apishim/api31/BpfCoordinatorShimImpl.java b/Tethering/apishim/31/com/android/networkstack/tethering/apishim/api31/BpfCoordinatorShimImpl.java
index 78fa533..c0d85ae 100644
--- a/Tethering/apishim/31/com/android/networkstack/tethering/apishim/api31/BpfCoordinatorShimImpl.java
+++ b/Tethering/apishim/31/com/android/networkstack/tethering/apishim/api31/BpfCoordinatorShimImpl.java
@@ -69,7 +69,7 @@
 
     public BpfCoordinatorShimImpl(@NonNull final Dependencies deps) {
         mLog = deps.getSharedLog().forSubComponent(TAG);
-        mBpfDownstream6Map = deps.getBpfIngressMap();
+        mBpfDownstream6Map = deps.getBpfDownstream6Map();
         mBpfStatsMap = deps.getBpfStatsMap();
         mBpfLimitMap = deps.getBpfLimitMap();
     }
diff --git a/Tethering/src/com/android/networkstack/tethering/BpfCoordinator.java b/Tethering/src/com/android/networkstack/tethering/BpfCoordinator.java
index fac5725..f9a819e 100644
--- a/Tethering/src/com/android/networkstack/tethering/BpfCoordinator.java
+++ b/Tethering/src/com/android/networkstack/tethering/BpfCoordinator.java
@@ -73,7 +73,7 @@
 public class BpfCoordinator {
     private static final String TAG = BpfCoordinator.class.getSimpleName();
     private static final int DUMP_TIMEOUT_MS = 10_000;
-    private static final String TETHER_INGRESS_FS_PATH =
+    private static final String TETHER_DOWNSTREAM6_FS_PATH =
             "/sys/fs/bpf/map_offload_tether_downstream6_map";
     private static final String TETHER_STATS_MAP_PATH =
             "/sys/fs/bpf/map_offload_tether_stats_map";
@@ -190,13 +190,14 @@
             return SdkLevel.isAtLeastS();
         }
 
-        /** Get ingress BPF map. */
-        @Nullable public BpfMap<TetherDownstream6Key, TetherDownstream6Value> getBpfIngressMap() {
+        /** Get downstream6 BPF map. */
+        @Nullable public BpfMap<TetherDownstream6Key, TetherDownstream6Value>
+                getBpfDownstream6Map() {
             try {
-                return new BpfMap<>(TETHER_INGRESS_FS_PATH,
+                return new BpfMap<>(TETHER_DOWNSTREAM6_FS_PATH,
                     BpfMap.BPF_F_RDWR, TetherDownstream6Key.class, TetherDownstream6Value.class);
             } catch (ErrnoException e) {
-                Log.e(TAG, "Cannot create ingress map: " + e);
+                Log.e(TAG, "Cannot create downstream6 map: " + e);
                 return null;
             }
         }
diff --git a/Tethering/tests/privileged/src/com/android/networkstack/tethering/BpfMapTest.java b/Tethering/tests/privileged/src/com/android/networkstack/tethering/BpfMapTest.java
index bff204b..5520f30 100644
--- a/Tethering/tests/privileged/src/com/android/networkstack/tethering/BpfMapTest.java
+++ b/Tethering/tests/privileged/src/com/android/networkstack/tethering/BpfMapTest.java
@@ -51,7 +51,7 @@
 public final class BpfMapTest {
     // Sync from packages/modules/Connectivity/Tethering/bpf_progs/offload.c.
     private static final int TEST_MAP_SIZE = 16;
-    private static final String TETHER_INGRESS_FS_PATH =
+    private static final String TETHER_DOWNSTREAM6_FS_PATH =
             "/sys/fs/bpf/tethering/map_test_tether_downstream6_map";
 
     private ArrayMap<TetherDownstream6Key, TetherDownstream6Value> mTestData;
@@ -88,7 +88,7 @@
 
     private BpfMap<TetherDownstream6Key, TetherDownstream6Value> getTestMap() throws Exception {
         return new BpfMap<>(
-                TETHER_INGRESS_FS_PATH, BpfMap.BPF_F_RDWR,
+                TETHER_DOWNSTREAM6_FS_PATH, BpfMap.BPF_F_RDWR,
                 TetherDownstream6Key.class, TetherDownstream6Value.class);
     }
 
@@ -122,7 +122,7 @@
 
     @Test
     public void testGetFd() throws Exception {
-        try (BpfMap readOnlyMap = new BpfMap<>(TETHER_INGRESS_FS_PATH, BpfMap.BPF_F_RDONLY,
+        try (BpfMap readOnlyMap = new BpfMap<>(TETHER_DOWNSTREAM6_FS_PATH, BpfMap.BPF_F_RDONLY,
                 TetherDownstream6Key.class, TetherDownstream6Value.class)) {
             assertNotNull(readOnlyMap);
             try {
@@ -132,7 +132,7 @@
                 assertEquals(OsConstants.EPERM, expected.errno);
             }
         }
-        try (BpfMap writeOnlyMap = new BpfMap<>(TETHER_INGRESS_FS_PATH, BpfMap.BPF_F_WRONLY,
+        try (BpfMap writeOnlyMap = new BpfMap<>(TETHER_DOWNSTREAM6_FS_PATH, BpfMap.BPF_F_WRONLY,
                 TetherDownstream6Key.class, TetherDownstream6Value.class)) {
             assertNotNull(writeOnlyMap);
             try {
@@ -142,7 +142,7 @@
                 assertEquals(OsConstants.EPERM, expected.errno);
             }
         }
-        try (BpfMap readWriteMap = new BpfMap<>(TETHER_INGRESS_FS_PATH, BpfMap.BPF_F_RDWR,
+        try (BpfMap readWriteMap = new BpfMap<>(TETHER_DOWNSTREAM6_FS_PATH, BpfMap.BPF_F_RDWR,
                 TetherDownstream6Key.class, TetherDownstream6Value.class)) {
             assertNotNull(readWriteMap);
         }
diff --git a/Tethering/tests/unit/src/android/net/ip/IpServerTest.java b/Tethering/tests/unit/src/android/net/ip/IpServerTest.java
index 048b756..6668402 100644
--- a/Tethering/tests/unit/src/android/net/ip/IpServerTest.java
+++ b/Tethering/tests/unit/src/android/net/ip/IpServerTest.java
@@ -296,7 +296,8 @@
                     }
 
                     @Nullable
-                    public BpfMap<TetherDownstream6Key, TetherDownstream6Value> getBpfIngressMap() {
+                    public BpfMap<TetherDownstream6Key, TetherDownstream6Value>
+                            getBpfDownstream6Map() {
                         return mBpfDownstream6Map;
                     }
 
@@ -770,13 +771,13 @@
     }
 
     @NonNull
-    private static TetherDownstream6Key makeIngressKey(int upstreamIfindex,
+    private static TetherDownstream6Key makeDownstream6Key(int upstreamIfindex,
             @NonNull final InetAddress dst) {
         return new TetherDownstream6Key(upstreamIfindex, dst.getAddress());
     }
 
     @NonNull
-    private static TetherDownstream6Value makeIngressValue(@NonNull final MacAddress dstMac) {
+    private static TetherDownstream6Value makeDownstream6Value(@NonNull final MacAddress dstMac) {
         return new TetherDownstream6Value(TEST_IFACE_PARAMS.index, dstMac,
                 TEST_IFACE_PARAMS.macAddr, ETH_P_IPV6, NetworkStackConstants.ETHER_MTU);
     }
@@ -793,7 +794,7 @@
             @NonNull final InetAddress dst, @NonNull final MacAddress dstMac) throws Exception {
         if (mBpfDeps.isAtLeastS()) {
             verifyWithOrder(inOrder, mBpfDownstream6Map).updateEntry(
-                    makeIngressKey(upstreamIfindex, dst), makeIngressValue(dstMac));
+                    makeDownstream6Key(upstreamIfindex, dst), makeDownstream6Value(dstMac));
         } else {
             verifyWithOrder(inOrder, mNetd).tetherOffloadRuleAdd(matches(upstreamIfindex, dst,
                     dstMac));
@@ -803,8 +804,9 @@
     private void verifyNeverTetherOffloadRuleAdd(int upstreamIfindex,
             @NonNull final InetAddress dst, @NonNull final MacAddress dstMac) throws Exception {
         if (mBpfDeps.isAtLeastS()) {
-            verify(mBpfDownstream6Map, never()).updateEntry(makeIngressKey(upstreamIfindex, dst),
-                    makeIngressValue(dstMac));
+            verify(mBpfDownstream6Map, never()).updateEntry(
+                    makeDownstream6Key(upstreamIfindex, dst),
+                    makeDownstream6Value(dstMac));
         } else {
             verify(mNetd, never()).tetherOffloadRuleAdd(matches(upstreamIfindex, dst, dstMac));
         }
@@ -821,8 +823,8 @@
     private void verifyTetherOffloadRuleRemove(@Nullable InOrder inOrder, int upstreamIfindex,
             @NonNull final InetAddress dst, @NonNull final MacAddress dstMac) throws Exception {
         if (mBpfDeps.isAtLeastS()) {
-            verifyWithOrder(inOrder, mBpfDownstream6Map).deleteEntry(makeIngressKey(upstreamIfindex,
-                    dst));
+            verifyWithOrder(inOrder, mBpfDownstream6Map).deleteEntry(makeDownstream6Key(
+                    upstreamIfindex, dst));
         } else {
             // |dstMac| is not required for deleting rules. Used bacause tetherOffloadRuleRemove
             // uses a whole rule to be a argument.
diff --git a/Tethering/tests/unit/src/com/android/networkstack/tethering/BpfCoordinatorTest.java b/Tethering/tests/unit/src/com/android/networkstack/tethering/BpfCoordinatorTest.java
index 09167a9..c934d07 100644
--- a/Tethering/tests/unit/src/com/android/networkstack/tethering/BpfCoordinatorTest.java
+++ b/Tethering/tests/unit/src/com/android/networkstack/tethering/BpfCoordinatorTest.java
@@ -194,7 +194,8 @@
                     }
 
                     @Nullable
-                    public BpfMap<TetherDownstream6Key, TetherDownstream6Value> getBpfIngressMap() {
+                    public BpfMap<TetherDownstream6Key, TetherDownstream6Value>
+                            getBpfDownstream6Map() {
                         return mBpfDownstream6Map;
                     }
 
@@ -846,7 +847,7 @@
     private void checkBpfDisabled() throws Exception {
         // The caller may mock the global dependencies |mDeps| which is used in
         // #makeBpfCoordinator for testing.
-        // See #testBpfDisabledbyNoBpfIngressMap.
+        // See #testBpfDisabledbyNoBpfDownstream6Map.
         final BpfCoordinator coordinator = makeBpfCoordinator();
         coordinator.startPolling();
 
@@ -909,9 +910,9 @@
 
     @Test
     @IgnoreUpTo(Build.VERSION_CODES.R)
-    public void testBpfDisabledbyNoBpfIngressMap() throws Exception {
+    public void testBpfDisabledbyNoBpfDownstream6Map() throws Exception {
         setupFunctioningNetdInterface();
-        doReturn(null).when(mDeps).getBpfIngressMap();
+        doReturn(null).when(mDeps).getBpfDownstream6Map();
 
         checkBpfDisabled();
     }