Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IPv6 multicasting stopped to work in Android for [email protected] #6

Closed
vikulin opened this issue Aug 26, 2024 · 21 comments
Closed

Comments

@vikulin
Copy link

vikulin commented Aug 26, 2024

See my comment here:
e684438#r145827457

@wlynxg
Copy link
Owner

wlynxg commented Aug 26, 2024

Do you mean the public method to get the value of apiLevel?

@vikulin
Copy link
Author

vikulin commented Aug 26, 2024

Do you mean the public method to get the value of apiLevel?

Correct.

@vikulin
Copy link
Author

vikulin commented Aug 26, 2024

Do you mean the public method to get the value of apiLevel?

I suspect the apiLevel is not getting correct value for a real device.

@wlynxg
Copy link
Owner

wlynxg commented Aug 27, 2024

You can call apiLevel = int(C.android_get_device_api_level()) externally to test whether the obtained value is correct.
I have verified that the obtained value is correct on several different versions of Android phones in my hands.

@vikulin
Copy link
Author

vikulin commented Aug 27, 2024

You can call apiLevel = int(C.android_get_device_api_level()) externally to test whether the obtained value is correct. I have verified that the obtained value is correct on several different versions of Android phones in my hands.

In other words speaking - "do it yourself". Anyway I will.

vikulin added a commit to vikulin/anet that referenced this issue Aug 29, 2024
@vikulin vikulin changed the title Add public getter for Android API level value IPv6 multicasting stopped to work in Android for [email protected] Aug 29, 2024
@vikulin
Copy link
Author

vikulin commented Aug 29, 2024

@wlynxg I was suspecting the issue was caused by incorrect API Level values in apiLevelvariable. These changes helped to fix multicasting feature:
https://github.com/vikulin/anet/blob/main/interface_android.go#L43
https://github.com/vikulin/anet/blob/main/interface_android.go#L100

@wlynxg
Copy link
Owner

wlynxg commented Aug 30, 2024

What do you mean by IPv6 multicast stops working?
Is it this golang/go#68082 issue?
Can you provide your reproduction conditions?
If it is golang/go#68082 issue, I use your https://github.com/vikulin/gomobile repository and use the following code:

package mobile

import (
	"fmt"
	"log"
	"net"
	"net/netip"

	"github.com/wlynxg/anet"
)

func Run() {
	allifaces, err := anet.Interfaces()
	if err != nil {
		log.Printf("get interfacess error: %s!\n", err)
	}

	for _, iface := range allifaces {
		addrs, err := anet.InterfaceAddrsByInterface(&iface)
		if err != nil {
			log.Printf("get [%s] addrs error: %s\n", iface.Name, err)
		} else {
			log.Printf("success get [%s] addrs: %s\n", iface.Name, addrs)
		}

		for _, addr := range addrs {
			parseAddr, err := netip.ParsePrefix(addr.String())
			if err != nil {
				continue
			}

			if parseAddr.Addr().Is4() || parseAddr.Addr().IsMulticast() {
				continue
			}

			addr := fmt.Sprintf("[%s%%%s]:0", parseAddr.Addr().String(), iface.Name)

			_, err = net.Listen("tcp", addr)
			if err != nil {
				log.Printf("listen %s error: %s\n", addr, err)
			} else {
				log.Printf("success listen %s!\n", addr)
			}
		}
	}
}

It works well on Android12 and Android14, and the running results are as follows:
image
image

@bobrofon
Copy link
Contributor

bobrofon commented Aug 30, 2024

I suspect the apiLevel is not getting correct value for a real device.

@vikulin Could you provide some minimal code (ideally the entire project) that reproduces the problem? I suspect the issue is not device-specific but rather depends on some context in which you call C.android_get_device_api_level(). This could relate to the thread you're using or the stage of the Android application lifecycle you're in (e.g. onCreate/onDestroy/etc.). If you could at least explain the context in which you encounter this bug, it may also help a lot in understanding its nature.

These changes helped to fix multicasting feature

@vikulin Do you mean this specific patch vikulin@99b8955 fixes the issue or is it the entire set of changes you made in that branch vikulin/anet@a79b5ca...99b8955 that fixes it? I'm asking because in vikulin/anet@a79b5ca...41ff359 (everything except the last commit) you basically disable C.android_get_device_api_level() caching. If, for some reason, the C.android_get_device_api_level() call returns an error in a certain situation and that error is cached, it could actually break multicasting.
@vikulin Could you please confirm whether the commit vikulin@99b8955 is essential for resolving the issue or not?

I think that if caching is the problem, it may be worth to try checking the result of C.android_get_device_api_level() and not caching it in case of an error. @wlynxg what do you think?

@wlynxg
Copy link
Owner

wlynxg commented Aug 30, 2024

We can wait for him to provide an environment that can reproduce the problem and then consider how to solve it.

@vikulin
Copy link
Author

vikulin commented Aug 31, 2024

@wlynxg Please learn what is "IPv6 Multicast". The code which was affected hasn't been debugged clearly but what I noticed in logs most probably socket write failed and did not send multicast beacon.
See: https://github.com/RiV-chain/RiV-mesh/blob/develop/src/multicast/multicast.go#L340
@bobrofon minimal code construction would require a day for debugging which I'm not having. Please refer the line of code and find exact method where the code was not working.

Could you please confirm whether the commit vikulin@99b8955

Yes, that's correct.

@bobrofon
Copy link
Contributor

Could you please confirm whether the commit vikulin@99b8955

Yes, that's correct.

Well, at least we know the problem isn't related to android_get_device_api_level. That's something.

@vikulin do you have the golang.org/x/net package in your project (as a direct or indirect dependency)? Maybe you can show the go.sum file (at least the lines related to golang.org/x/net)?

zoneCacheX in this commit vikulin@99b8955 replaces golang.org/x/net/internal/socket.zoneCache symbol. And maybe it's not compatible with some version of golang.org/x/net for some reason. It sounds unlikely, but I don't see any other reasonable explanations for now.

@vikulin
Copy link
Author

vikulin commented Aug 31, 2024

Could you please confirm whether the commit vikulin@99b8955

Yes, that's correct.

Well, at least we know the problem isn't related to android_get_device_api_level. That's something.

@vikulin do you have the golang.org/x/net package in your project (as a direct or indirect dependency)? Maybe you can show the go.sum file (at least the lines related to golang.org/x/net)?

zoneCacheX in this commit vikulin@99b8955 replaces golang.org/x/net/internal/socket.zoneCache symbol. And maybe it's not compatible with some version of golang.org/x/net for some reason. It sounds unlikely, but I don't see any other reasonable explanations for now.

Yes, it does:
https://github.com/RiV-chain/RiV-mesh/blob/develop/go.sum#L105

@bobrofon
Copy link
Contributor

bobrofon commented Sep 1, 2024

I tried to build https://github.com/RiV-chain/crispa-android/tree/8f85b6303ae038815c19b7338cef3773f6653499 with https://github.com/RiV-chain/RiV-mesh/tree/23ab7e81764ed6bf18d88f9245986c7a14783476 and then ran it on my Android device (LinageOS 20 based on AOSP 13).
In the logcat I saw repeated selinux errors usually indicating golang/go#68082:

GoLog                   org.rivchain.app.crispa              I  Build name: mesh-develop
GoLog                   org.rivchain.app.crispa              I  Build version: 0.4.7.12
hain.app.crispa         org.rivchain.app.crispa              W  type=1400 audit(0.0:5029): avc: denied { read } for name="somaxconn" dev="proc" ino=953400 scontext=u:r:untrusted_app_29:s0:c240,c256,c512,c768 tcontext=u:object_r:proc_net:s0 tclass=file permissive=0 app=org.rivchain.app.crispa
hain.app.crispa         org.rivchain.app.crispa              W  type=1400 audit(0.0:5030): avc: denied { bind } for scontext=u:r:untrusted_app_29:s0:c240,c256,c512,c768 tcontext=u:r:untrusted_app_29:s0:c240,c256,c512,c768 tclass=netlink_route_socket permissive=0 app=org.rivchain.app.crispa
hain.app.crispa         org.rivchain.app.crispa              W  type=1400 audit(0.0:5031): avc: denied { bind } for scontext=u:r:untrusted_app_29:s0:c240,c256,c512,c768 tcontext=u:r:untrusted_app_29:s0:c240,c256,c512,c768 tclass=netlink_route_socket permissive=0 app=org.rivchain.app.crispa
GoLog                   org.rivchain.app.crispa              I  Starting multicasting
GoLog                   org.rivchain.app.crispa              I  Starting multicast module
GoLog                   org.rivchain.app.crispa              I  Started multicast module
GoLog                   org.rivchain.app.crispa              I  Multicast module started
GoLog                   org.rivchain.app.crispa              I  TLS listener started on [fe80::8cf2:ff0:e65:b98e%wlan0]:39869
GoLog                   org.rivchain.app.crispa              I  Started multicasting on wlan0
hain.app.crispa         org.rivchain.app.crispa              W  type=1400 audit(0.0:5032): avc: denied { bind } for scontext=u:r:untrusted_app_29:s0:c240,c256,c512,c768 tcontext=u:r:untrusted_app_29:s0:c240,c256,c512,c768 tclass=netlink_route_socket permissive=0 app=org.rivchain.app.crispa
hain.app.crispa         org.rivchain.app.crispa              W  type=1400 audit(0.0:5033): avc: denied { bind } for scontext=u:r:untrusted_app_29:s0:c240,c256,c512,c768 tcontext=u:r:untrusted_app_29:s0:c240,c256,c512,c768 tclass=netlink_route_socket permissive=0 app=org.rivchain.app.crispa
hain.app.crispa         org.rivchain.app.crispa              W  type=1400 audit(0.0:5034): avc: denied { bind } for scontext=u:r:untrusted_app_29:s0:c240,c256,c512,c768 tcontext=u:r:untrusted_app_29:s0:c240,c256,c512,c768 tclass=netlink_route_socket permissive=0 app=org.rivchain.app.crispa
hain.app.crispa         org.rivchain.app.crispa              W  type=1400 audit(0.0:5035): avc: denied { bind } for scontext=u:r:untrusted_app_29:s0:c240,c256,c512,c768 tcontext=u:r:untrusted_app_29:s0:c240,c256,c512,c768 tclass=netlink_route_socket permissive=0 app=org.rivchain.app.crispa
hain.app.crispa         org.rivchain.app.crispa              W  type=1400 audit(0.0:5036): avc: denied { bind } for scontext=u:r:untrusted_app_29:s0:c240,c256,c512,c768 tcontext=u:r:untrusted_app_29:s0:c240,c256,c512,c768 tclass=netlink_route_socket permissive=0 app=org.rivchain.app.crispa
hain.app.crispa         org.rivchain.app.crispa              W  type=1400 audit(0.0:5037): avc: denied { bind } for scontext=u:r:untrusted_app_29:s0:c240,c256,c512,c768 tcontext=u:r:untrusted_app_29:s0:c240,c256,c512,c768 tclass=netlink_route_socket permissive=0 app=org.rivchain.app.crispa
hain.app.crispa         org.rivchain.app.crispa              W  type=1400 audit(0.0:5038): avc: denied { bind } for scontext=u:r:untrusted_app_29:s0:c240,c256,c512,c768 tcontext=u:r:untrusted_app_29:s0:c240,c256,c512,c768 tclass=netlink_route_socket permissive=0 app=org.rivchain.app.crispa
GoLog                   org.rivchain.app.crispa              I  Starting http server listening on http://localhost:19019. Document root /data/app/~~YpmSwz6PrV-pXzXXTrZr8Q==/org.rivchain.app.crispa-bUDeCPYnxOQ1LgEG-dr0Mg==/base.apk on zipfs
hain.app.crispa         org.rivchain.app.crispa              W  type=1400 audit(0.0:5039): avc: denied { bind } for scontext=u:r:untrusted_app_29:s0:c240,c256,c512,c768 tcontext=u:r:untrusted_app_29:s0:c240,c256,c512,c768 tclass=netlink_route_socket permissive=0 app=org.rivchain.app.crispa
hain.app.crispa         org.rivchain.app.crispa              W  type=1400 audit(0.0:5040): avc: denied { bind } for scontext=u:r:untrusted_app_29:s0:c240,c256,c512,c768 tcontext=u:r:untrusted_app_29:s0:c240,c256,c512,c768 tclass=netlink_route_socket permissive=0 app=org.rivchain.app.crispa
hain.app.crispa         org.rivchain.app.crispa              W  type=1400 audit(0.0:5041): avc: denied { bind } for scontext=u:r:untrusted_app_29:s0:c240,c256,c512,c768 tcontext=u:r:untrusted_app_29:s0:c240,c256,c512,c768 tclass=netlink_route_socket permissive=0 app=org.rivchain.app.crispa
hain.app.crispa         org.rivchain.app.crispa              W  type=1400 audit(0.0:5042): avc: denied { bind } for scontext=u:r:untrusted_app_29:s0:c240,c256,c512,c768 tcontext=u:r:untrusted_app_29:s0:c240,c256,c512,c768 tclass=netlink_route_socket permissive=0 app=org.rivchain.app.crispa
hain.app.crispa         org.rivchain.app.crispa              W  type=1400 audit(0.0:5043): avc: denied { bind } for scontext=u:r:untrusted_app_29:s0:c240,c256,c512,c768 tcontext=u:r:untrusted_app_29:s0:c240,c256,c512,c768 tclass=netlink_route_socket permissive=0 app=org.rivchain.app.crispa
Mesh                    org.rivchain.app.crispa              D  Update Peers
TrafficStats            org.rivchain.app.crispa              D  tagSocket(6) with statsTag=0xffffffff, statsUid=-1
hain.app.crispa         org.rivchain.app.crispa              W  type=1400 audit(0.0:5044): avc: denied { bind } for scontext=u:r:untrusted_app_29:s0:c240,c256,c512,c768 tcontext=u:r:untrusted_app_29:s0:c240,c256,c512,c768 tclass=netlink_route_socket permissive=0 app=org.rivchain.app.crispa
hain.app.crispa         org.rivchain.app.crispa              W  type=1400 audit(0.0:5045): avc: denied { bind } for scontext=u:r:untrusted_app_29:s0:c240,c256,c512,c768 tcontext=u:r:untrusted_app_29:s0:c240,c256,c512,c768 tclass=netlink_route_socket permissive=0 app=org.rivchain.app.crispa
hain.app.crispa         org.rivchain.app.crispa              W  type=1400 audit(0.0:5046): avc: denied { bind } for scontext=u:r:untrusted_app_29:s0:c240,c256,c512,c768 tcontext=u:r:untrusted_app_29:s0:c240,c256,c512,c768 tclass=netlink_route_socket permissive=0 app=org.rivchain.app.crispa
hain.app.crispa         org.rivchain.app.crispa              W  type=1400 audit(0.0:5047): avc: denied { bind } for scontext=u:r:untrusted_app_29:s0:c240,c256,c512,c768 tcontext=u:r:untrusted_app_29:s0:c240,c256,c512,c768 tclass=netlink_route_socket permissive=0 app=org.rivchain.app.crispa
hain.app.crispa         org.rivchain.app.crispa              W  type=1400 audit(0.0:5048): avc: denied { bind } for scontext=u:r:untrusted_app_29:s0:c240,c256,c512,c768 tcontext=u:r:untrusted_app_29:s0:c240,c256,c512,c768 tclass=netlink_route_socket permissive=0 app=org.rivchain.app.crispa
Mesh                    org.rivchain.app.crispa              D  Update Peers

To confirm that the sending of multicast messages was not working, I tried to dump all incoming multicast packets using Wireshark from my laptop in the same network. And there were no incoming multicast messages.
It makes sense to me, because https://github.com/RiV-chain/RiV-mesh/tree/23ab7e81764ed6bf18d88f9245986c7a14783476 uses https://github.com/vikulin/anet/tree/99b8955b2cffbbff21367f7ecb17231aaa5dfe19 version of the anet library, where this patch #2 is essentially reverted.

So I decided to switch back to https://github.com/wlynxg/anet/tree/v0.0.4 and retest crispa-android again. This time, it kind of worked. I didn't find any selinux errors in the logs:

GoLog                   org.rivchain.app.crispa              I  Build name: mesh-develop
GoLog                   org.rivchain.app.crispa              I  Build version: 0.4.7.12
hain.app.crispa         org.rivchain.app.crispa              W  type=1400 audit(0.0:5015): avc: denied { read } for name="somaxconn" dev="proc" ino=916992 scontext=u:r:untrusted_app_29:s0:c240,c256,c512,c768 tcontext=u:object_r:proc_net:s0 tclass=file permissive=0 app=org.rivchain.app.crispa
GoLog                   org.rivchain.app.crispa              I  Starting multicasting
GoLog                   org.rivchain.app.crispa              I  Starting multicast module
GoLog                   org.rivchain.app.crispa              I  Started multicast module
GoLog                   org.rivchain.app.crispa              I  Multicast module started
GoLog                   org.rivchain.app.crispa              I  TLS listener started on [fe80::8cf2:ff0:e65:b98e%wlan0]:42459
GoLog                   org.rivchain.app.crispa              I  Started multicasting on wlan0
GoLog                   org.rivchain.app.crispa              I  Starting http server listening on http://localhost:19019. Document root /data/app/~~Ngp1b8LRfzFB4sUoMkcTBQ==/org.rivchain.app.crispa-s5T4an0X9we806n5lPnnDw==/base.apk on zipfs
Mesh                    org.rivchain.app.crispa              D  Update Peers
TrafficStats            org.rivchain.app.crispa              D  tagSocket(110) with statsTag=0xffffffff, statsUid=-1
Mesh                    org.rivchain.app.crispa              D  Update Peers
Mesh                    org.rivchain.app.crispa              D  Update Peers
Mesh                    org.rivchain.app.crispa              D  Update Peers

And I can see multicast messages from my phone in Wireshark.

For some reason, the outcome is completely opposite to what @vikulin is experiencing.

@vikulin
Copy link
Author

vikulin commented Sep 2, 2024

@bobrofon you ran incorrect Android client. Check this project out:
https://github.com/RiV-chain/CupLink
Corresponding RiV-mesh dependencies are published in GitHib Maven repo:
https://github.com/RiV-chain/artifact/tree/main/org/rivchain/mesh

@bobrofon
Copy link
Contributor

bobrofon commented Sep 2, 2024

The same result with CupLink. Multicasting works on my phone with https://github.com/wlynxg/anet/tree/v0.0.4 but with https://github.com/vikulin/anet/tree/99b8955b2cffbbff21367f7ecb17231aaa5dfe19 it doesn't (I see in Wireshark how my phone joins the multicast group but never sends anything).

anet v0.0.4:

MainService             org.rivchain.cuplink                 D  onStartCommand()
MainService             org.rivchain.cuplink                 D  onStartCommand() Received Start Foreground Intent
NetworkStateCallback    org.rivchain.cuplink                 D  onAvailable
NetworkStateCallback    org.rivchain.cuplink                 D  onAvailable
Compatibil...geReporter org.rivchain.cuplink                 D  Compat change id reported: 160794467; UID 10243; state: ENABLED
VPN service             org.rivchain.cuplink                 D  Connecting...
TrafficStats            org.rivchain.cuplink                 D  tagSocket(101) with statsTag=0xffffffff, statsUid=-1
VPN service             org.rivchain.cuplink                 D  Server listening on port 10001
VPN service             org.rivchain.cuplink                 D  getting Mesh configuration
GoLog                   org.rivchain.cuplink                 I  Build name: mesh-develop
GoLog                   org.rivchain.cuplink                 I  Build version: 0.4.7.12
GoLog                   org.rivchain.cuplink                 I  Starting multicasting
GoLog                   org.rivchain.cuplink                 I  Starting multicast module
GoLog                   org.rivchain.cuplink                 I  Started multicast module
GoLog                   org.rivchain.cuplink                 I  Multicast module started
GoLog                   org.rivchain.cuplink                 I  Document root get stat error:  stat : no such file or directory
ivchain.cuplink         org.rivchain.cuplink                 W  type=1400 audit(0.0:11265): avc: denied { read } for name="somaxconn" dev="proc" ino=2327825 scontext=u:r:untrusted_app:s0:c243,c256,c512,c768 tcontext=u:object_r:proc_net:s0 tclass=file permissive=0 app=org.rivchain.cuplink
GoLog                   org.rivchain.cuplink                 I  Starting http server listening on http://localhost:19019. Document root  not found
GoLog                   org.rivchain.cuplink                 I  TLS listener started on [fe80::8cf2:ff0:e65:b98e%wlan0]:42289
GoLog                   org.rivchain.cuplink                 I  Started multicasting on wlan0
StartActivity           org.rivchain.cuplink                 D  onServiceConnected
Compatibil...geReporter org.rivchain.cuplink                 D  Compat change id reported: 210923482; UID 10243; state: ENABLED
StartActivity           org.rivchain.cuplink                 D  init 2: choose peers
StartActivity           org.rivchain.cuplink                 D  init 3: check database
StartActivity           org.rivchain.cuplink                 D  init 4: check username
StartActivity           org.rivchain.cuplink                 D  init 5: check addresses
StartActivity           org.rivchain.cuplink                 D  init 6: check key pair
StartActivity           org.rivchain.cuplink                 D  init 7: test port
StartActivity           org.rivchain.cuplink                 D  init 8: check all permissions
StartActivity           org.rivchain.cuplink                 D  init 9: restart main service if needed
StartActivity           org.rivchain.cuplink                 D  init 10: start MainActivity
MainActivity            org.rivchain.cuplink                 D  onCreate()
MainActivity            org.rivchain.cuplink                 D  Change night mode to -1
Compatibil...geReporter org.rivchain.cuplink                 D  Compat change id reported: 171228096; UID 10243; state: ENABLED
MainActivity            org.rivchain.cuplink                 D  Power management fix enabled
MainActivity            org.rivchain.cuplink                 D  onServiceConnected()
MainActivity            org.rivchain.cuplink                 D  onResume()
MainActivity            org.rivchain.cuplink                 D  updateEventTabTitle()
Parcel                  org.rivchain.cuplink                 W  Expecting binder but got null!
ContactListFragment     org.rivchain.cuplink                 D  onCreateView
ContactListFragment     org.rivchain.cuplink                 D  onResume()
MainActivity            org.rivchain.cuplink                 D  pingContacts()
OpenGLRenderer          org.rivchain.cuplink                 E  Unable to match the desired swap behavior.
MainActivity            org.rivchain.cuplink                 D  onCreateOptionsMenu()
ContactListFragment     org.rivchain.cuplink                 D  trigger refreshContactList() from broadcast at RESUMED
ContactListFragment     org.rivchain.cuplink                 D  refreshContactList
ContactListFragment     org.rivchain.cuplink                 D  trigger refreshContactList() from broadcast at RESUMED
ContactListFragment     org.rivchain.cuplink                 D  refreshContactList
MainService             org.rivchain.cuplink                 D  onStartCommand()
MainService             org.rivchain.cuplink                 D  onStartCommand() Received Start Foreground Intent
VPN service             org.rivchain.cuplink                 D  Connecting...
MainService             org.rivchain.cuplink                 D  onStartCommand()
MainService             org.rivchain.cuplink                 D  onStartCommand() Received Start Foreground Intent
VPN service             org.rivchain.cuplink                 D  Connecting...
Compatibil...geReporter org.rivchain.cuplink                 D  Compat change id reported: 170188668; UID 10243; state: ENABLED
ProfileInstaller        org.rivchain.cuplink                 D  Installing profile for org.rivchain.cuplink
ivchain.cuplink         org.rivchain.cuplink                 W  Cleared Reference was only reachable from finalizer (only reported once)

anet 99b8955:

MainService             org.rivchain.cuplink                 D  onStartCommand()
MainService             org.rivchain.cuplink                 D  onStartCommand() Received Start Foreground Intent
NetworkStateCallback    org.rivchain.cuplink                 D  onAvailable
NetworkStateCallback    org.rivchain.cuplink                 D  onAvailable
Compatibil...geReporter org.rivchain.cuplink                 D  Compat change id reported: 160794467; UID 10243; state: ENABLED
VPN service             org.rivchain.cuplink                 D  Connecting...
TrafficStats            org.rivchain.cuplink                 D  tagSocket(100) with statsTag=0xffffffff, statsUid=-1
VPN service             org.rivchain.cuplink                 D  Server listening on port 10001
VPN service             org.rivchain.cuplink                 D  getting Mesh configuration
GoLog                   org.rivchain.cuplink                 I  Build name: mesh-develop
GoLog                   org.rivchain.cuplink                 I  Build version: 0.4.7.12
GoLog                   org.rivchain.cuplink                 I  Starting multicasting
GoLog                   org.rivchain.cuplink                 I  Starting multicast module
GoLog                   org.rivchain.cuplink                 I  Started multicast module
GoLog                   org.rivchain.cuplink                 I  Multicast module started
GoLog                   org.rivchain.cuplink                 I  Document root get stat error:  stat : no such file or directory
GoLog                   org.rivchain.cuplink                 I  Starting http server listening on http://localhost:19019. Document root  not found
ivchain.cuplink         org.rivchain.cuplink                 W  type=1400 audit(0.0:11287): avc: denied { read } for name="somaxconn" dev="proc" ino=2327825 scontext=u:r:untrusted_app:s0:c243,c256,c512,c768 tcontext=u:object_r:proc_net:s0 tclass=file permissive=0 app=org.rivchain.cuplink
GoLog                   org.rivchain.cuplink                 I  TLS listener started on [fe80::8cf2:ff0:e65:b98e%wlan0]:37041
GoLog                   org.rivchain.cuplink                 I  Started multicasting on wlan0
ivchain.cuplink         org.rivchain.cuplink                 W  type=1400 audit(0.0:11288): avc: denied { bind } for scontext=u:r:untrusted_app:s0:c243,c256,c512,c768 tcontext=u:r:untrusted_app:s0:c243,c256,c512,c768 tclass=netlink_route_socket permissive=0 bug=b/155595000 app=org.rivchain.cuplink
ivchain.cuplink         org.rivchain.cuplink                 W  type=1400 audit(0.0:11289): avc: denied { bind } for scontext=u:r:untrusted_app:s0:c243,c256,c512,c768 tcontext=u:r:untrusted_app:s0:c243,c256,c512,c768 tclass=netlink_route_socket permissive=0 bug=b/155595000 app=org.rivchain.cuplink
StartActivity           org.rivchain.cuplink                 D  onServiceConnected
Compatibil...geReporter org.rivchain.cuplink                 D  Compat change id reported: 210923482; UID 10243; state: ENABLED
StartActivity           org.rivchain.cuplink                 D  init 2: choose peers
StartActivity           org.rivchain.cuplink                 D  init 3: check database
StartActivity           org.rivchain.cuplink                 D  init 4: check username
StartActivity           org.rivchain.cuplink                 D  init 5: check addresses
StartActivity           org.rivchain.cuplink                 D  init 6: check key pair
StartActivity           org.rivchain.cuplink                 D  init 7: test port
StartActivity           org.rivchain.cuplink                 D  init 8: check all permissions
StartActivity           org.rivchain.cuplink                 D  init 9: restart main service if needed
StartActivity           org.rivchain.cuplink                 D  init 10: start MainActivity
MainActivity            org.rivchain.cuplink                 D  onCreate()
MainActivity            org.rivchain.cuplink                 D  Change night mode to -1
Compatibil...geReporter org.rivchain.cuplink                 D  Compat change id reported: 171228096; UID 10243; state: ENABLED
ivchain.cuplink         org.rivchain.cuplink                 W  type=1400 audit(0.0:11290): avc: denied { bind } for scontext=u:r:untrusted_app:s0:c243,c256,c512,c768 tcontext=u:r:untrusted_app:s0:c243,c256,c512,c768 tclass=netlink_route_socket permissive=0 bug=b/155595000 app=org.rivchain.cuplink
GoLog                   org.rivchain.cuplink                 I  ResolveTCPAddr failed on ?8644040a8edd0040c8114767dc49c664bced2fdafd8771c3f333998f4f63ab286322a2cdc5162bd239ad3dfc2fd12a928818e0d6a14751ba504e9115e68f83c9a85e667567d8:56447
MainActivity            org.rivchain.cuplink                 D  Power management fix enabled
MainActivity            org.rivchain.cuplink                 D  onServiceConnected()
MainActivity            org.rivchain.cuplink                 D  onResume()
MainActivity            org.rivchain.cuplink                 D  updateEventTabTitle()
Parcel                  org.rivchain.cuplink                 W  Expecting binder but got null!
ContactListFragment     org.rivchain.cuplink                 D  onCreateView
ContactListFragment     org.rivchain.cuplink                 D  onResume()
MainActivity            org.rivchain.cuplink                 D  pingContacts()
OpenGLRenderer          org.rivchain.cuplink                 E  Unable to match the desired swap behavior.
MainActivity            org.rivchain.cuplink                 D  onCreateOptionsMenu()
ContactListFragment     org.rivchain.cuplink                 D  trigger refreshContactList() from broadcast at RESUMED
ContactListFragment     org.rivchain.cuplink                 D  refreshContactList
ContactListFragment     org.rivchain.cuplink                 D  trigger refreshContactList() from broadcast at RESUMED
ContactListFragment     org.rivchain.cuplink                 D  refreshContactList
MainService             org.rivchain.cuplink                 D  onStartCommand()
MainService             org.rivchain.cuplink                 D  onStartCommand() Received Start Foreground Intent
VPN service             org.rivchain.cuplink                 D  Connecting...
MainService             org.rivchain.cuplink                 D  onStartCommand()
MainService             org.rivchain.cuplink                 D  onStartCommand() Received Start Foreground Intent
VPN service             org.rivchain.cuplink                 D  Connecting...
ivchain.cuplink         org.rivchain.cuplink                 W  type=1400 audit(0.0:11291): avc: denied { bind } for scontext=u:r:untrusted_app:s0:c243,c256,c512,c768 tcontext=u:r:untrusted_app:s0:c243,c256,c512,c768 tclass=netlink_route_socket permissive=0 bug=b/155595000 app=org.rivchain.cuplink
Compatibil...geReporter org.rivchain.cuplink                 D  Compat change id reported: 170188668; UID 10243; state: ENABLED
ivchain.cuplink         org.rivchain.cuplink                 W  type=1400 audit(0.0:11292): avc: denied { bind } for scontext=u:r:untrusted_app:s0:c243,c256,c512,c768 tcontext=u:r:untrusted_app:s0:c243,c256,c512,c768 tclass=netlink_route_socket permissive=0 bug=b/155595000 app=org.rivchain.cuplink
GoLog                   org.rivchain.cuplink                 I  ResolveTCPAddr failed on ?f3019bd78e2f004068e72a17c599dc76c97aae7c055e20dde4106a04c2c986d23b19f84192583227df8aff32cce8053c8a423931b1c89bad230dae3dc3918aea4672d04eec29:24043
ivchain.cuplink         org.rivchain.cuplink                 W  type=1400 audit(0.0:11293): avc: denied { bind } for scontext=u:r:untrusted_app:s0:c243,c256,c512,c768 tcontext=u:r:untrusted_app:s0:c243,c256,c512,c768 tclass=netlink_route_socket permissive=0 bug=b/155595000 app=org.rivchain.cuplink
ivchain.cuplink         org.rivchain.cuplink                 W  type=1400 audit(0.0:11294): avc: denied { bind } for scontext=u:r:untrusted_app:s0:c243,c256,c512,c768 tcontext=u:r:untrusted_app:s0:c243,c256,c512,c768 tclass=netlink_route_socket permissive=0 bug=b/155595000 app=org.rivchain.cuplink
GoLog                   org.rivchain.cuplink                 I  ResolveTCPAddr failed on ?f3019bd78e2f004068e72a17c599dc76c97aae7c055e20dde4106a04c2c986d23b19f84192583227df8aff32cce8053c8a423931b1c89bad230dae3dc3918aea4672d04eec29:24043
ivchain.cuplink         org.rivchain.cuplink                 W  type=1400 audit(0.0:11295): avc: denied { bind } for scontext=u:r:untrusted_app:s0:c243,c256,c512,c768 tcontext=u:r:untrusted_app:s0:c243,c256,c512,c768 tclass=netlink_route_socket permissive=0 bug=b/155595000 app=org.rivchain.cuplink
ivchain.cuplink         org.rivchain.cuplink                 W  type=1400 audit(0.0:11296): avc: denied { bind } for scontext=u:r:untrusted_app:s0:c243,c256,c512,c768 tcontext=u:r:untrusted_app:s0:c243,c256,c512,c768 tclass=netlink_route_socket permissive=0 bug=b/155595000 app=org.rivchain.cuplink
ivchain.cuplink         org.rivchain.cuplink                 W  type=1400 audit(0.0:11297): avc: denied { bind } for scontext=u:r:untrusted_app:s0:c243,c256,c512,c768 tcontext=u:r:untrusted_app:s0:c243,c256,c512,c768 tclass=netlink_route_socket permissive=0 bug=b/155595000 app=org.rivchain.cuplink
GoLog                   org.rivchain.cuplink                 I  ResolveTCPAddr failed on ?f3019bd78e2f004068e72a17c599dc76c97aae7c055e20dde4106a04c2c986d23b19f84192583227df8aff32cce8053c8a423931b1c89bad230dae3dc3918aea4672d04eec29:24043
ivchain.cuplink         org.rivchain.cuplink                 W  type=1400 audit(0.0:11298): avc: denied { bind } for scontext=u:r:untrusted_app:s0:c243,c256,c512,c768 tcontext=u:r:untrusted_app:s0:c243,c256,c512,c768 tclass=netlink_route_socket permissive=0 bug=b/155595000 app=org.rivchain.cuplink
ProfileInstaller        org.rivchain.cuplink                 D  Installing profile for org.rivchain.cuplink
ivchain.cuplink         org.rivchain.cuplink                 W  type=1400 audit(0.0:11299): avc: denied { bind } for scontext=u:r:untrusted_app:s0:c243,c256,c512,c768 tcontext=u:r:untrusted_app:s0:c243,c256,c512,c768 tclass=netlink_route_socket permissive=0 bug=b/155595000 app=org.rivchain.cuplink
ivchain.cuplink         org.rivchain.cuplink                 W  type=1400 audit(0.0:11300): avc: denied { bind } for scontext=u:r:untrusted_app:s0:c243,c256,c512,c768 tcontext=u:r:untrusted_app:s0:c243,c256,c512,c768 tclass=netlink_route_socket permissive=0 bug=b/155595000 app=org.rivchain.cuplink
GoLog                   org.rivchain.cuplink                 I  ResolveTCPAddr failed on ?f3019bd78e2f004068e72a17c599dc76c97aae7c055e20dde4106a04c2c986d23b19f84192583227df8aff32cce8053c8a423931b1c89bad230dae3dc3918aea4672d04eec29:24043
ivchain.cuplink         org.rivchain.cuplink                 W  type=1400 audit(0.0:11301): avc: denied { bind } for scontext=u:r:untrusted_app:s0:c243,c256,c512,c768 tcontext=u:r:untrusted_app:s0:c243,c256,c512,c768 tclass=netlink_route_socket permissive=0 bug=b/155595000 app=org.rivchain.cuplink
ivchain.cuplink         org.rivchain.cuplink                 W  type=1400 audit(0.0:11302): avc: denied { bind } for scontext=u:r:untrusted_app:s0:c243,c256,c512,c768 tcontext=u:r:untrusted_app:s0:c243,c256,c512,c768 tclass=netlink_route_socket permissive=0 bug=b/155595000 app=org.rivchain.cuplink
GoLog                   org.rivchain.cuplink                 I  ResolveTCPAddr failed on ?f3019bd78e2f004068e72a17c599dc76c97aae7c055e20dde4106a04c2c986d23b19f84192583227df8aff32cce8053c8a423931b1c89bad230dae3dc3918aea4672d04eec29:24043
ivchain.cuplink         org.rivchain.cuplink                 W  type=1400 audit(0.0:11303): avc: denied { bind } for scontext=u:r:untrusted_app:s0:c243,c256,c512,c768 tcontext=u:r:untrusted_app:s0:c243,c256,c512,c768 tclass=netlink_route_socket permissive=0 bug=b/155595000 app=org.rivchain.cuplink
ivchain.cuplink         org.rivchain.cuplink                 W  type=1400 audit(0.0:11304): avc: denied { bind } for scontext=u:r:untrusted_app:s0:c243,c256,c512,c768 tcontext=u:r:untrusted_app:s0:c243,c256,c512,c768 tclass=netlink_route_socket permissive=0 bug=b/155595000 app=org.rivchain.cuplink
GoLog                   org.rivchain.cuplink                 I  ResolveTCPAddr failed on ?8644040a8edd0040c8114767dc49c664bced2fdafd8771c3f333998f4f63ab286322a2cdc5162bd239ad3dfc2fd12a928818e0d6a14751ba504e9115e68f83c9a85e667567d8:56447
ivchain.cuplink         org.rivchain.cuplink                 W  type=1400 audit(0.0:11305): avc: denied { bind } for scontext=u:r:untrusted_app:s0:c243,c256,c512,c768 tcontext=u:r:untrusted_app:s0:c243,c256,c512,c768 tclass=netlink_route_socket permissive=0 bug=b/155595000 app=org.rivchain.cuplink
GoLog                   org.rivchain.cuplink                 I  ResolveTCPAddr failed on ?f3019bd78e2f004068e72a17c599dc76c97aae7c055e20dde4106a04c2c986d23b19f84192583227df8aff32cce8053c8a423931b1c89bad230dae3dc3918aea4672d04eec29:24043
ivchain.cuplink         org.rivchain.cuplink                 W  type=1400 audit(0.0:11306): avc: denied { bind } for scontext=u:r:untrusted_app:s0:c243,c256,c512,c768 tcontext=u:r:untrusted_app:s0:c243,c256,c512,c768 tclass=netlink_route_socket permissive=0 bug=b/155595000 app=org.rivchain.cuplink
ivchain.cuplink         org.rivchain.cuplink                 W  type=1400 audit(0.0:11307): avc: denied { bind } for scontext=u:r:untrusted_app:s0:c243,c256,c512,c768 tcontext=u:r:untrusted_app:s0:c243,c256,c512,c768 tclass=netlink_route_socket permissive=0 bug=b/155595000 app=org.rivchain.cuplink
ivchain.cuplink         org.rivchain.cuplink                 W  type=1400 audit(0.0:11308): avc: denied { bind } for scontext=u:r:untrusted_app:s0:c243,c256,c512,c768 tcontext=u:r:untrusted_app:s0:c243,c256,c512,c768 tclass=netlink_route_socket permissive=0 bug=b/155595000 app=org.rivchain.cuplink
GoLog                   org.rivchain.cuplink                 I  ResolveTCPAddr failed on ?f3019bd78e2f004068e72a17c599dc76c97aae7c055e20dde4106a04c2c986d23b19f84192583227df8aff32cce8053c8a423931b1c89bad230dae3dc3918aea4672d04eec29:24043

@vikulin Which version of Android are you using? Can you show logcat from your device?

@vikulin
Copy link
Author

vikulin commented Sep 6, 2024

@bobrofon Thank you for the debugging. I synced code (tag v0.4.7.16) with yggdrasil implementation for the multicasting related code where [email protected] is used. As result multicasting is not working and this is why I was updating link_tcp.go. I got following errors in Android CupLink client:

2024-09-06 16:58:29.448  1345-1345  ivchain.cuplink         org.rivchain.cuplink                 
W  type=1400 audit(0.0:1757410): avc:  denied  { bind } for  scontext=u:r:untrusted_app:s0:c188,c257,c512,c768 tcontext=u:r:untrusted_app:s0:c188,c257,c512,c768 tclass=netlink_route_socket permissive=0 bug=b/155595000 app=org.rivchain.cuplink
2024-09-06 16:58:29.451  1345-1549  GoLog                   org.rivchain.cuplink                 
I  Failed to dial TLS [fe80::33d6:4970:9c23:5f7c]:63579: interface "wlan0" not found
2024-09-06 16:58:30.474  1345-1549  GoLog                   org.rivchain.cuplink                 
I  Failed to dial TLS [fe80::33d6:4970:9c23:5f7c]:63579: interface "wlan0" not found

This is exactly what does yggdrasil in latest develop branch with anet lib update. Error occurs here:

RiV-mesh:
https://github.com/RiV-chain/RiV-mesh/blob/RIVM-145-1/src/core/link_tcp.go#L146

Yggdrasil:
https://github.com/yggdrasil-network/yggdrasil-go/blob/develop/src/core/link_tcp.go#L117

It seems like net.InterfaceByName(sintf) doesn't find interfaces by name after adding anet. Can you confirm Yggdrasil native lib patched with anet in develop branch works in Android?

vikulin added a commit to vikulin/gomobile that referenced this issue Sep 8, 2024
@vikulin
Copy link
Author

vikulin commented Sep 8, 2024

@bobrofon @wlynxg confirmed the issue in net.InterfaceByName. See errors in line:
https://github.com/vikulin/gomobile/blob/main/libmodule/src/go/mobile/hello.go#L24

_, err := net.InterfaceByName(s)
if err != nil {
     log.Printf("net: interface name %s not found, error %s", s, err)
}
2024-09-08_11h51_35

@wlynxg
Copy link
Owner

wlynxg commented Sep 8, 2024

Can you provide your Android phone model and Android version number?

@vikulin
Copy link
Author

vikulin commented Sep 8, 2024

Can you provide your Android phone model and Android version number?

Android 14, Pixel 7a

@vikulin
Copy link
Author

vikulin commented Sep 8, 2024

@wlynxg I suppose the net.InterfaceByName method has never been expected to work on Android 11+. This is why anet.InterfaceByName implemented in your lib.

@vikulin
Copy link
Author

vikulin commented Sep 9, 2024

I have fixed the issue and my change isn't related to anet itself. Thanks All!. Closing the issue.

@vikulin vikulin closed this as completed Sep 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants