Use the stacked wireless driver in init.vsoc.rc

This renames eth0 to buried_eth0 and cannibalizes that device to create
a wlan0 network device.

Bug: 112047055
Test: ran cf_x86_[auto, phone]-userdedebug
Change-Id: I2d20722ee0d4c25c2f1547c220d444d8162647ca
(cherry picked from commit 8860c11abfd000ef8a8e5ab51f2611fd879387cf)
diff --git a/shared/config/init.vsoc.rc b/shared/config/init.vsoc.rc
index fb99007..b6294d6 100644
--- a/shared/config/init.vsoc.rc
+++ b/shared/config/init.vsoc.rc
@@ -31,8 +31,13 @@
     mount_all /vendor/etc/fstab.${ro.hardware}
     restorecon_recursive /vendor
 
-    # works around framework netiface enumeration issue
     start rename_eth0
+    # works around framework netiface enumeration issue
+    start rename_eth1
+
+    # wait until rename_eth0 is done before attempting to stack wifi
+    wait /proc/self/net/xt_qtaguid/iface_stat/buried_eth0
+    start create_wifi
 
     # TODO(ender): Find better way to talk to serial port.
     chmod 622 /dev/kmsg
@@ -71,7 +76,15 @@
     start socket_forward_proxy
 
 
-service rename_eth0 /vendor/bin/rename_netiface eth0 rmnet0
+service rename_eth0 /vendor/bin/rename_netiface eth0 buried_eth0
+    oneshot
+
+
+service rename_eth1 /vendor/bin/rename_netiface eth1 rmnet0
+    oneshot
+
+
+service create_wifi /vendor/bin/ip_link_add virt_wifi buried_eth0 wlan0
     oneshot
 
 
diff --git a/shared/sepolicy/file_contexts b/shared/sepolicy/file_contexts
index 5c0e9af..d295828 100644
--- a/shared/sepolicy/file_contexts
+++ b/shared/sepolicy/file_contexts
@@ -30,3 +30,4 @@
 /vendor/bin/hw/android\.hardware\.bluetooth@1\.0-service\.sim             u:object_r:hal_bluetooth_sim_exec:s0
 /vendor/bin/hw/android\.hardware\.dumpstate@1\.0-service\.cuttlefish      u:object_r:hal_dumpstate_impl_exec:s0
 /vendor/bin/hw/android\.hardware\.health@2\.0-service.cuttlefish          u:object_r:hal_health_default_exec:s0
+/vendor/bin/ip_link_add    u:object_r:ip_link_add_exec:s0
diff --git a/shared/sepolicy/ip_link_add.te b/shared/sepolicy/ip_link_add.te
new file mode 100644
index 0000000..a1c13e2
--- /dev/null
+++ b/shared/sepolicy/ip_link_add.te
@@ -0,0 +1,10 @@
+type ip_link_add, domain;
+type ip_link_add_exec, exec_type, vendor_file_type, file_type;
+
+init_daemon_domain(ip_link_add)
+
+allow ip_link_add self:capability { net_admin net_raw sys_module };
+allow ip_link_add self:udp_socket { create ioctl };
+allow ip_link_add self:netlink_route_socket { bind create nlmsg_write read write };
+
+allow ip_link_add kernel:system module_request;