Respect the upstream interface mtu instead of always setting
mtu 1500.
Using upstream interface mtu is probably not the best solution
for tether offload pmtu but it at least respects the upstream
interface mtu which may be less than 1500.
Test: manual test
1. Connect to carrier Taiwan Star.
2. Enable tethering and check the mtu 1434 in dumpsys.
IPv4 Upstream: proto [inDstMac] iif(iface) src -> nat ->
dst [outDstMac] pmtu age
udp [02:10:45:32:ef:35] 54(54) 192.168.72.125:39034
-> 15(rmnet1) 100.83.189.11:39034
-> 142.251.43.14:443 [00:00:00:00:00:00] 1434 69657ms
IPv4 Downstream: proto [inDstMac] iif(iface) src -> nat
-> dst [outDstMac] pmtu age
udp [00:00:00:00:00:00] 15(rmnet1) 142.251.43.14:443
-> 54(54) 100.83.189.11:39034
-> 192.168.72.125:39034 [9a:8a:4d:ec:a4:7c] 1434 69633ms
Bug: 262860312
Test: atest BpfCoordinatorTest
Change-Id: Ic6dcb95ed76d5306053e4645b6baebc67ff082cf
Both CONNECTIVITY_ACTION and UpstreamNetworkMonitor monitor the
upstream connection status. The upstream status should be monitored
in one place and deprecated the duplicate one since U+ device.
Once CONNECTIVITY_ACTION is removed, CMD_UPSTREAM_CHANGED won't be
triggered anymore. For non-dun upstream netowrk , upstream
re-evaluation is triggered by EVENT_DEFAULT_SWITCHED and
EVENT_ON_LOST. For dun upstream re-evaluation, re-evaluation is
triggered by EVENT_ON_LINKPROPERTIES and EVENT_ON_LOST.
Changes:
1. Deprecate the CONNECTIVITY_ACTION broadcast.
2. Re-evaluate possible upstream selection on the event
UpstreamNetworkMonitor.EVENT_ON_LOST.
Note that EVENT_DEFAULT_SWITCHED and EVENT_ON_LINKPROPERTIES have
already triggered the upstream re-evaluation and keep as it.
Bug: 257408654
Bug: 257941865
Test: atest ConnectivityCoverageTests
Change-Id: I8b75cfb2fec51fb5bc4e2d13ad6b54daf8efc71e
This establishes the main Wear connection manager class,
and enforces T+ requirement.
Bug: 245972418
Change-Id: Ia60925ce4dc2a25ac61c4b9bae1d022dc74f5b05
Those static method and constants are better to fit in
NetlinkUitls. Replace the usage.
Test: m
Test: atest FrameworksNetTests NetworkStackTests
Change-Id: I81e27b8264e39764a44a4ba87344e9ac940d920a
This change introduces a limited library for dependencies on
framework-connectivity from Tethering,
connectivity-internal-api-util, where all classes are annotated with
@RequiresApi(S) to ensure proper API checks are done before usage.
Bug: 245972418
Change-Id: I82bafd9063341adc71d07f0858e6d68283d081f0
If we run an iterations test, TCP connections opened by previous tests
won't be closed immediately. They will stay in the TIME_WAIT state for
120 seconds before closed. Netfilter socket listens to both
NF_NETLINK_CONNTRACK_NEW and NF_NETLINK_CONNTRACK_DESTROY groups.
There is a tiny time gap between socket creation and sending dump
request to kernel. If an old TCP connection happened to be closed in
this time gap, listening socket would see a DESTROY message before
seeing the NEW messages triggered by dump request.
The current test only parsing the first contrack message in the read
buffer, so it will only find the DESTROY message and ignore all of the
following NEW messages. It does a netfilter socket dump, but does not
check whether the dump produces reasonable output. Now that we have
the ability to parse conntrack messages, do more in-depth checking.
Bug: 254608655
Test: atest ConntrackSocketTest --iteration 500
Change-Id: Icf95adb9d9390d598e9c6bdb4e245c5fce764e3e
mRaemon only be created at BaseServingState#enter() and set to null at
BaseServingState#exit(). Thus, updateUpstreamIPv6LinkProperties just be
no-op in InitialState.
Test: atest TetheringTests MtsTetheringTestLatestSdk CtsTetheringTest
Change-Id: I0b8403a2acffb1aa0f40d2ad8721d4eff7c63ff0
Simply the upstream selection since U+ device for tethering refactor.
Changes:
1. Support automatic mode only on U+ device.
2. Add two tethering tests to make sure that the resource config can't
control automatic mode anymore. Expect that always automatic mode
on U+ device. Also limit some existing tethering tests for R, S,
or T.
Changes of TetheringTest:
- testAutomaticUpstreamSelectionWithConfigDisabled (U+) [new]
- testLegacyUpstreamSelection (T-)
- testChooseDunUpstreamByLegacyMode (T-)
- testChooseDunUpstreamByAutomaticModeWithConfigDisabled (U+) [new]
3. Add two tethering configuration tests to make sure that automatic
mode is always enabled no mater what the resource config or flag
are on U+ device. Also limit some existing tethering tests for R,
S, or T.
Changes of TetheringConfiguration:
- testChooseUpstreamAutomatically (T-)
- testChooseUpstreamAutomaticallyAfterT (U+) [new]
- testChooseUpstreamAutomatically_FlagOverride (R)
- testChooseUpstreamAutomatically_FlagOverrideOnSAndT (S, T)
(Renamed from testChooseUpstreamAutomatically_FlagOverrideAfterR)
- testChooseUpstreamAutomatically_FlagOverrideAfterT (U+) [new]
Bug: 257941865
Bug: 257408654
Test: atest TetheringTest
Change-Id: I7ace317a1529177a84557741dc07d732b7f8cf89
This is no-op change. Tethering shouldn't use connectivity namespace
because it already be used for NetworkStack module. The new feature
should check isTetheringFeatureEnabled instead.
Bug: 238274852
Test: atest TetheringTests
Change-Id: I009f654d0bf8df7051b822e666e3206dd70a5523
Android T allows apps to declare a runtime receiver as not exported
by invoking registerReceiver with a new RECEIVER_NOT_EXPORTED flag;
receivers registered with this flag will only receive broadcasts from
the platform and the app itself. However to ensure developers can
properly protect their receivers, all apps targeting a future
platform release and registering a receiver for non-system
broadcasts must specify either the exported or not exported flag
when invoking #registerReceiver; if one of these flags is not
provided, the platform will throw a SecurityException. This commit
adds the RECEIVER_NOT_EXPORTED flag to the receiver in
EntitlementManager since this broadcast is sent as a PendingIntent
alarm.
Bug: 234659204
Test: atest com.android.networkstack.tethering.EntitlementManagerTest
Change-Id: I46c2df038ccf7669636166f50fe0331efcc42e4b
This commit is part of a large scale change to fix errorprone
errors that have been downgraded to warnings in the android
source tree, so that they can be promoted to errors again.
The full list of changes include the following, but not all
will be present in any one individual commit:
BadAnnotationImplementation
BadShiftAmount
BanJNDI
BoxedPrimitiveEquality
ComparableType
ComplexBooleanConstant
CollectionToArraySafeParameter
ConditionalExpressionNumericPromotion
DangerousLiteralNull
DoubleBraceInitialization
DurationFrom
DurationTemporalUnit
EmptyTopLevelDeclaration
EqualsNull
EqualsReference
FormatString
FromTemporalAccessor
GetClassOnAnnotation
GetClassOnClass
HashtableContains
IdentityBinaryExpression
IdentityHashMapBoxing
InstantTemporalUnit
InvalidTimeZoneID
InvalidZoneId
IsInstanceIncompatibleType
JUnitParameterMethodNotFound
LockOnBoxedPrimitive
MathRoundIntLong
MislabeledAndroidString
MisusedDayOfYear
MissingSuperCall
MisusedWeekYear
ModifyingCollectionWithItself
NoCanIgnoreReturnValueOnClasses
NonRuntimeAnnotation
NullableOnContainingClass
NullTernary
OverridesJavaxInjectableMethod
ParcelableCreator
PeriodFrom
PreconditionsInvalidPlaceholder
ProtoBuilderReturnValueIgnored
ProtoFieldNullComparison
RandomModInteger
RectIntersectReturnValueIgnored
ReturnValueIgnored
SelfAssignment
SelfComparison
SelfEquals
SizeGreaterThanOrEqualsZero
StringBuilderInitWithChar
TreeToString
TryFailThrowable
UnnecessaryCheckNotNull
UnusedCollectionModifiedInPlace
XorPower
See https://errorprone.info/bugpatterns for more
information on the checks.
Bug: 253827323
Test: m RUN_ERROR_PRONE=true javac-check
Change-Id: I7625fa386afe93823b97cb2ecb8fd09a5856c05b
Needed because default Ipv6ForwardingRule#toString doesn't dump
actual data. It is hard to know why two rule comparison failed
in the test failure.
Bug: 250552545
Test: atest BpfCoordinatorTest
Change-Id: Iaf29c888238573c7c9a0a4e0bd65fbe468084e51
Ignore stopping monitoring if the monitor has never started
for a given IpServer.
Also fix the related bug in
BpfCoordinator#testStartStopConntrackMonitoring.
Bug: 250552545
Test: atest BpfCoordinatorTest
Change-Id: I7ac71f0ed52bf52244aadaa3c90ca8df239873e4
aosp/1536721 is merged, so this code duplication should not be needed any more.
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ic05adfc46495086d7f681322aac7acddc30a2260
Currently, production code uses BpfMap type and TestBpfMap extends
BpfMap but this makes it diffcult to test because TestBpfMap loads the
JNI.
This CL updates to use IBpfMap type in the production code.
Upcoming CL updates TestBpfMap to implement IBpfMap instead of extending
BpfMap so that test can still use TestBpfMap but tests do not need to
load JNI.
Bug: 217624062
Test: atest BpfCoordinatorTest BpfNetMapsTest
Change-Id: Ie67e14bf5519fb4427474ecc0fda441877a9555f
There are three configuration could affect tethering allowed:
1. user restriction
2. tether_supported settings
3. ro.tether.denied system properties
When user restricted or tether supported setting change, updating
supported downstreams.
ro.tether.denied is read only properties, so it won't be changed runtime.
Also correct the unit test that there is no TetheringConfiguration change when settings or user restriction change.
Bug: 184996041
Bug: 239500515
Test: atest TetheringTests
Change-Id: I8dfcc42de9787a5e9ba19b69db9444c14ace56f0
Also just use 'int' for ifindex. The kernel allocates these in order,
if we ever exceed 2 billion, we'll have other problems to worry about.
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I33eb46185fde90cd4d158bb74f8f9c17b41434fb
These are allocated in order by the kernel, if we go
over 2 billion, we've got other problems... besides
U32 to S32 conversion will work just fine anyway.
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ifbb7139e9118dd2d0c52e83c5874132e03760b30
* changes:
BpfCoordinator: dump IPv6 BPF downstream rules
BpfCoordinator: change function name and format for dumping IPv6 rules
add header on ipv6 forwarding rulesdump
add header on ipv6 upstream bpf map dump
Used for test interface upstream can replace existing non-test
upstream interface, like ethernet on cuttlefish.
This helps to fix the flaky test when we are using test interface on
cuttlefish. Because the ethernet and test interface upstream update
event order can't be guaranteed.
Bug: 237369591
Bug: 242067530
Test: atest ConnectivityCoverageTests
Change-Id: I9da71ee116bf1ebc9831f61f25acf42e328a8370
The forwarding pairs may use the same downstream. Ex: 464xlat
tethering has rmnet0:ncm0, v4-rmnet0:ncm0 forwarding pairs.
Need to avoid duplicate downstream program.
Bug: 241106456
Test: atest BpfCoordinatorTest
Change-Id: Ic41b3ad856e4876808f8497a760081afcfd04988