]> git.ipfire.org Git - people/ms/network.git/blobdiff - src/networkd/port.c
ports: Do not expect to come back after creating links
[people/ms/network.git] / src / networkd / port.c
index a7cbab63c0c6775cbdadb81e76a14c8817d5caaa..c87ed599db74c3a74af34c1fb8934f3adb6b0fb7 100644 (file)
@@ -168,8 +168,8 @@ static int nw_port_setup(nw_port* port) {
                goto ERROR;
 
        // Call any custom initialization
-       if (port->ops.config_read) {
-               r = port->ops.config_read(port);
+       if (NW_PORT_OPS(port)->config_read) {
+               r = NW_PORT_OPS(port)->config_read(port);
                if (r)
                        goto ERROR;
        }
@@ -201,11 +201,11 @@ int nw_port_create(nw_port** port, nw_daemon* daemon, nw_port_type_t type, const
        // Set operations
        switch (p->type) {
                case NW_PORT_DUMMY:
-                       p->ops = nw_port_ops_dummy;
+                       p->info = &nw_port_info_dummy;
                        break;
 
                case NW_PORT_VLAN:
-                       p->ops = nw_port_ops_vlan;
+                       p->info = &nw_port_info_vlan;
                        break;
        }
 
@@ -339,8 +339,8 @@ int nw_port_save(nw_port* port) {
        int r;
 
        // Call the custom handler
-       if (port->ops.config_write) {
-               r = port->ops.config_write(port);
+       if (NW_PORT_OPS(port)->config_write) {
+               r = NW_PORT_OPS(port)->config_write(port);
                if (r)
                        goto ERROR;
        }
@@ -429,11 +429,11 @@ static nw_link* nw_port_get_parent_link(nw_port* port) {
        nw_link* link = NULL;
 
        // Do nothing if not implemented
-       if (!port->ops.get_parent_port)
+       if (!NW_PORT_OPS(port)->get_parent_port)
                goto ERROR;
 
        // Fetch the parent
-       parent = port->ops.get_parent_port(port);
+       parent = NW_PORT_OPS(port)->get_parent_port(port);
        if (!parent)
                goto ERROR;
 
@@ -502,14 +502,14 @@ static int nw_port_create_link(nw_port* port) {
                goto ERROR;
 
        // Run the custom setup
-       if (port->ops.create_link) {
-               r = sd_netlink_message_open_container_union(m, IFLA_INFO_DATA, port->ops.kind);
+       if (NW_PORT_OPS(port)->create_link) {
+               r = sd_netlink_message_open_container_union(m, IFLA_INFO_DATA, NW_PORT_INFO(port)->kind);
                if (r < 0) {
                        ERROR("Could not open IFLA_INFO_DATA container: %s\n", strerror(-r));
                        goto ERROR;
                }
 
-               r = port->ops.create_link(port, m);
+               r = NW_PORT_OPS(port)->create_link(port, m);
                if (r) {
                        ERROR("Could not create port %s: %m\n", port->name);
                        goto ERROR;
@@ -522,7 +522,7 @@ static int nw_port_create_link(nw_port* port) {
 
        // Just set IFLA_INFO_KIND if there is no custom function
        } else {
-               r = sd_netlink_message_append_string(m, IFLA_INFO_KIND, port->ops.kind);
+               r = sd_netlink_message_append_string(m, IFLA_INFO_KIND, NW_PORT_INFO(port)->kind);
                if (r < 0)
                        goto ERROR;
        }
@@ -566,11 +566,8 @@ int nw_port_reconfigure(nw_port* port) {
        }
 
        // If there is no link, we will try to create it
-       if (!port->link) {
-               r = nw_port_create_link(port);
-               if (r)
-                       return r;
-       }
+       if (!port->link)
+               return nw_port_create_link(port);
 
        // XXX TODO