[lowpan][lowpan-spinel-driver] Remove auto-added link-local addresses

Netstack will automatically add a link-local IPv6 address to all
interfaces that support IPv6 when brought online. However, OpenThread
uses its own link-local address, so we don't want to use the one
that is generated by netstack.

This change removes all automatically-added addresses from the
interface right after it is brought online. This gives the NCP a
clean slate to add addresses to.

Test: Verified manually.
Change-Id: Ib41d02cdde7de30a2def10382b759c2d10dfd76d
Reviewed-on: https://fuchsia-review.googlesource.com/c/fuchsia/+/453896
Fuchsia-Auto-Submit: Robert Quattlebaum <rquattle@google.com>
Reviewed-by: Jiaming (Charlie) Wang <jiamingw@google.com>
Testability-Review: Jiaming (Charlie) Wang <jiamingw@google.com>
Commit-Queue: Auto-Submit <auto-submit@fuchsia-infra.iam.gserviceaccount.com>
diff --git a/src/connectivity/lowpan/drivers/lowpan-spinel-driver/src/tun.rs b/src/connectivity/lowpan/drivers/lowpan-spinel-driver/src/tun.rs
index f2c177b..ffe2dfb 100644
--- a/src/connectivity/lowpan/drivers/lowpan-spinel-driver/src/tun.rs
+++ b/src/connectivity/lowpan/drivers/lowpan-spinel-driver/src/tun.rs
@@ -132,6 +132,20 @@
         fx_log_info!("Interface online: {:?}", online);
         if online {
             self.stack.enable_interface(self.id).await.squash_result()?;
+
+            // Get a list of all of the addresses that were automatically
+            // added to the interface (like the link local address).
+            let fnetstack::InterfaceInfo {
+                properties: fnetstack::InterfaceProperties { addresses, .. },
+                ..
+            } = self.stack.get_interface_info(self.id).await.squash_result()?;
+
+            // Now we remove all of those addresses so that the NCP has a
+            // clean slate to start from.
+            for mut subnet in addresses {
+                fx_log_info!("Removing automatically added address: {:?}", &subnet);
+                self.stack.del_interface_address(self.id, &mut subnet).await.squash_result()?;
+            }
         } else {
             self.stack.disable_interface(self.id).await.squash_result()?;
         }