From b0f26a1f0bce13cd8785fefdb004d178768e201a Mon Sep 17 00:00:00 2001 From: Aleksander Morgado Date: Wed, 24 Feb 2021 01:01:55 +0100 Subject: [PATCH] bearer-qmi: bring master interface up on connection attempt The user of the ModemManager API will bring up the data network interface exposed in the Bearer IP settings (i.e. the link interface when using multiplexing). But for instantiated network links, we also need to have the master interface brought up before any traffic can go through the link interface. We don't check whether the master interface is already up before attempting to bring it up, we just attempt to bring it up. --- src/mm-bearer-qmi.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/src/mm-bearer-qmi.c b/src/mm-bearer-qmi.c index ab3059fe..c0a8889a 100644 --- a/src/mm-bearer-qmi.c +++ b/src/mm-bearer-qmi.c @@ -417,6 +417,7 @@ typedef enum { CONNECT_STEP_OPEN_QMI_PORT, CONNECT_STEP_SETUP_DATA_FORMAT, CONNECT_STEP_SETUP_LINK, + CONNECT_STEP_SETUP_LINK_MASTER_UP, CONNECT_STEP_IP_METHOD, CONNECT_STEP_IPV4, CONNECT_STEP_WDS_CLIENT_IPV4, @@ -1335,6 +1336,27 @@ qmi_port_allocate_client_ready (MMPortQmi *qmi, connect_context_step (task); } +static void +master_interface_up_ready (MMPortNet *link, + GAsyncResult *res, + GTask *task) +{ + ConnectContext *ctx; + GError *error = NULL; + + ctx = g_task_get_task_data (task); + + if (!mm_port_net_link_setup_finish (link, res, &error)) { + g_prefix_error (&error, "Couldn't bring master interface up: "); + complete_connect (task, NULL, error); + return; + } + + /* Keep on */ + ctx->step++; + connect_context_step (task); +} + static void wait_link_port_ready (MMBaseModem *modem, GAsyncResult *res, @@ -1551,6 +1573,21 @@ connect_context_step (GTask *task) ctx->step++; /* fall through */ + case CONNECT_STEP_SETUP_LINK_MASTER_UP: + /* if the connection is done through a new link, we need to ifup the master interface */ + if (ctx->link) { + mm_obj_dbg (self, "bringing master interface %s up...", mm_port_get_device (ctx->data)); + mm_port_net_link_setup (MM_PORT_NET (ctx->data), + TRUE, + 0, /* ignore */ + g_task_get_cancellable (task), + (GAsyncReadyCallback) master_interface_up_ready, + task); + return; + } + ctx->step++; + /* fall through */ + case CONNECT_STEP_IP_METHOD: /* Once the QMI port is open, we decide the IP method we're going * to request. If the LLP is raw-ip, we force Static IP, because not