+ return true;
+}
+
+void
+interface_add(struct interface *iface, struct blob_attr *config)
+{
+ __interface_add(iface, config, false);
+}
+
+bool
+interface_add_alias(struct interface *iface, struct blob_attr *config)
+{
+ if (iface->proto_handler->flags & PROTO_FLAG_NODEV)
+ return false;
+
+ return __interface_add(iface, config, true);
+}
+
+void
+interface_set_l3_dev(struct interface *iface, struct device *dev)
+{
+ bool enabled = iface->config_ip.enabled;
+ bool claimed = iface->l3_dev.claimed;
+
+ if (iface->l3_dev.dev == dev)
+ return;
+
+ interface_ip_set_enabled(&iface->config_ip, false);
+ interface_ip_flush(&iface->proto_ip);
+ device_add_user(&iface->l3_dev, dev);
+
+ if (dev) {
+ if (claimed)
+ device_claim(&iface->l3_dev);
+ interface_ip_set_enabled(&iface->config_ip, enabled);
+ }
+}
+
+void
+interface_set_main_dev(struct interface *iface, struct device *dev)
+{
+ bool set_l3 = (iface->main_dev.dev == iface->l3_dev.dev);
+ bool claimed = iface->l3_dev.claimed;
+
+ if (iface->main_dev.dev == dev)
+ return;
+
+ if (set_l3)
+ interface_set_l3_dev(iface, dev);
+
+ device_add_user(&iface->main_dev, dev);
+ if (claimed)
+ device_claim(&iface->l3_dev);
+
+ if (!iface->l3_dev.dev)
+ interface_set_l3_dev(iface, dev);