简体   繁体   English

Android 实际上在哪里调用“ip link”或“ifconfig”来启动接口?

[英]Where does Android actually invoke "ip link" or "ifconfig" to bring an interface up?

I've spent a few hours reading the AOSP source to try to find how and where "ip link" or "ifconfig" is invoked when eth0 needs to be brought up.我花了几个小时阅读 AOSP 源代码,试图找出在需要启动 eth0 时如何以及在何处调用“ip link”或“ifconfig”。

Does Android 10 use "ip link" or "ifconfig" to set the address and bring up eth0? Android 10 是否使用“ip link”或“ifconfig”设置地址并调出eth0?

Or does it manipulate the network interfaces in some other way?或者它是否以其他方式操纵网络接口?

Since you mentioned eth0 , I'll assume you're interested in Ethernet interfaces.既然您提到了eth0 ,我假设您对以太网接口感兴趣。 Each transport type has its own way for managing IP provisioning.每种传输类型都有自己的方式来管理 IP 配置。 For ethernet interfaces, you can find the owning class at EthernetNetworkFactory link .对于以太网接口,您可以在EthernetNetworkFactory 链接找到拥有的 class。 The method you are interested in seeing how this works is EthernetNetworkFactory#provisionIpClient link .您有兴趣了解其工作原理的方法是EthernetNetworkFactory#provisionIpClient link

Ultimately if you follow the code, you'll see this eventually arrive at netd here in NetdNativeService#interfaceAddAddress link .最终,如果您按照代码进行操作,您将看到它最终到达 netd 的NetdNativeService NetdNativeService#interfaceAddAddress 链接 At this point we're in the native layer.此时我们处于原生层。

This then ultimately arrives at ifc_utils#ifc_act_on_address link .然后最终到达ifc_utils#ifc_act_on_address 链接 This is where the ip address will ultimately be added to the ethernet interface.这是 ip 地址最终将添加到以太网接口的地方。 After all of this detective work, we see in this function that a socket is opened to send a NETLINK_ROUTE message link to set the ip address.在完成所有这些检测工作之后,我们在此 function 中看到打开了一个socket以发送NETLINK_ROUTE消息链接以设置 ip 地址。

1467 cdsmbase or csdmbase. 1467 cdsmbase 或 csdmbase。 Anyway to remove this?无论如何要删除这个? Android a10 e Samsung Android a10 e三星

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM