remote-android/redroid-doc

how to write ipv6 address and gateway/DNS into /data/misc/ethernet/ipconfig.txt?

jimtangshfx opened this issue · 2 comments

Hello, @zhouziyang
thank you for your contribution to redroid project, I really appreciate that.
I am testing ipv6 connection in redroid container and I can get successful ipv6 connection to internet by manually adding IPv6 address and ip route using ip command, however, I didn't find a good way to auto enable the ipv6 configuration on booting?
the code of vendor_redroid/ipconfigstore/main.cc seems will write ipv4 addr and gateway only into /data/misc/ethernet/ipconfig.txt? I wonder if it's feasible to change the code to write ipv6 addr and gateway into ipconfig.txt as well?
To do that, I need to know the format of ipconfig.txt and figure out how to pack ipv6 addr value into ipconfig.txt.
I searched internet but didn't find any explanation of what's the format/definition of key/value for ipv6 in ipconfig.txt?
This project https://github.com/jhswartz/ipconfigstore shows exmaple of writing config into ipconfig.txt but it's for ipv4 only as well.
do you know the correct format to acheive that? or is there any other way to auto set ipv6 on booting?
Thanks.

Check https://android.googlesource.com/platform/packages/modules/Connectivity/+/refs/tags/android-13.0.0_r83/service-t/src/com/android/server/net/IpConfigStore.java#309

Seems only ipv4 supported.

if (parsedLinkAddress.getAddress() instanceof Inet4Address
        && linkAddress == null) {
    linkAddress = parsedLinkAddress;
} else {
    loge("Non-IPv4 or duplicate address: " + parsedLinkAddress);
}

Thank you @zhouziyang
I checked the android source code of EthernetConfigStore.java/IpConfigStore.java/StaticIpConfiguration.java, and you are right, it supports ipv4 only.