From patchwork Wed Jun 7 18:54:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 103307 Delivered-To: patch@linaro.org Received: by 10.140.91.77 with SMTP id y71csp2084132qgd; Wed, 7 Jun 2017 11:55:09 -0700 (PDT) X-Received: by 10.84.128.67 with SMTP id 61mr30151142pla.246.1496861709345; Wed, 07 Jun 2017 11:55:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1496861709; cv=none; d=google.com; s=arc-20160816; b=fcsHqF0Ob0JirnYIsnhxKAKQjBRcVdpYVZraXUBEWPysptcjJjBglkhQ+jdg62vBDv yTBoc3Xf72ouOx3nsJIFf//a0eP00JPrKhKE5225pn+0RgwyPS+KheHDFPdQ8fMSC041 RsbRv5XB0a2+eflX7q8nimsIh9iTxaq5R8nYLsI7v4pt6GKURs4D7slM61OGerjsSb+G 1EshSoLvMgUrnPCBgNcNWLWu/pu6aDSUqHTR7HMlb6IxtYMos1Gzulyl005G/h3q6eP9 KXMRI4nZrjgL+Mcbegpbn4RlcqbSOYDcuShV0NqMyMi8TJn8WcnWJBgsVTi+DX7nEg2i pZGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=anrsNZd9wcjk8ZLJW70RzN1pLiYpwDqb+7OdNn/wDZA=; b=zQyG+1pUnik+I8n3GYt71yZedRwWjQfzx60EfCsFNEOZRJLuMu3PDXjXgWVIKIk954 vv26xL2sZa4wivF9bttpzvr1OJJZRAmtFip+Iqmr+Zo65goPbHtUyJrY06VTEWDy4TLO YZiA82qjlBpVX+gtuqAxtWzp89Z0WH3Fyu4xYTc0YjN0Rhozd0WitGcdarq+hRslbm06 qT3pahzwwBBuzPpWwj6kzQjSSkk9ibwcHLVuSJXkjyl7HGnh7vht3vpM6iDbDc9pBbm1 NBS7AeQrQq27eWvu+y3TSxiwsum3iEpX2vK1+A0FInV6H5F6YVVWCaYeZSg/Uhy16+S1 7b+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n127si2436833pga.135.2017.06.07.11.55.08; Wed, 07 Jun 2017 11:55:09 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751901AbdFGSzH (ORCPT + 10 others); Wed, 7 Jun 2017 14:55:07 -0400 Received: from mail-pf0-f172.google.com ([209.85.192.172]:36125 "EHLO mail-pf0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751722AbdFGSzG (ORCPT ); Wed, 7 Jun 2017 14:55:06 -0400 Received: by mail-pf0-f172.google.com with SMTP id x63so8642737pff.3 for ; Wed, 07 Jun 2017 11:55:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=ZDli+ju3xukeebpOdUnUQQczHAQ9qeVy1KSorxXQB1Y=; b=jb8YK22x9n2eWIJezyGGXzj9wgu0YVTLke4hSiUzhFA+DrPf9frYwKoWGhVN6KUyAs b0mbNe7/jkUgUZ/8kuK8Rj5DZz153wENnroAA202DRFppCedX32OL0lNikVFi0WVrYPg haWu93TyiIP8cpGGYL7fUZlU4iMtmHgLXhBkU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=ZDli+ju3xukeebpOdUnUQQczHAQ9qeVy1KSorxXQB1Y=; b=KIlH1vpFy/Qby6II9sAV+K7Msc1Ac3KDOgS3PMWv1e7K1yT1cu4heCWpSH2bqsv0zx 3bNS1oJ9xlfDgXNW6RegDuqd45ZsNfQNmijn/2GuCfD7cHA6Rkm9YhSR0UCf2/XNaWAT uMguu70bYR1Q8tAmB1Lv7fXitf+66pDCNsxD/a736Iz2xDWDasWo1L2vCU6JinRVmRJA fC/+018y0XdGm990HEt6g66RP6N1nYr9mFado0liN3ztGuPTJprcbhd5OJIDTdUiiuEt kPkuJQDPWofBnsdoL7M+vlRDJM5apya+caJshZWqQ/8zjCUIXNqsEL070rga0RZWFt7a tRjg== X-Gm-Message-State: AODbwcAD4klc+rd0LLfBmBgHzytwneNZnmK7QgX2lQy+HJDH5apFJkvE XkDziMe4iGOYJStx X-Received: by 10.84.134.34 with SMTP id 31mr30286041plg.51.1496861705660; Wed, 07 Jun 2017 11:55:05 -0700 (PDT) Received: from localhost.localdomain (ip68-111-217-79.sd.sd.cox.net. [68.111.217.79]) by smtp.gmail.com with ESMTPSA id u73sm5355149pfi.105.2017.06.07.11.55.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 07 Jun 2017 11:55:04 -0700 (PDT) From: Bjorn Andersson To: "David S. Miller" Cc: Arun Kumar Neelakantam , netdev@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Courtney Cavin Subject: [PATCH 1/4] net: qrtr: Refactor packet allocation Date: Wed, 7 Jun 2017 11:54:58 -0700 Message-Id: <20170607185501.6000-1-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.12.0 Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Extract the allocation and filling in the control message header fields to a separate function in order to reuse this in subsequent patches. Cc: Courtney Cavin Signed-off-by: Bjorn Andersson --- net/qrtr/qrtr.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) -- 2.12.0 -- To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/net/qrtr/qrtr.c b/net/qrtr/qrtr.c index a9a8c7d5a4a9..86d35ed50da9 100644 --- a/net/qrtr/qrtr.c +++ b/net/qrtr/qrtr.c @@ -245,14 +245,11 @@ int qrtr_endpoint_post(struct qrtr_endpoint *ep, const void *data, size_t len) } EXPORT_SYMBOL_GPL(qrtr_endpoint_post); -/* Allocate and construct a resume-tx packet. */ -static struct sk_buff *qrtr_alloc_resume_tx(u32 src_node, - u32 dst_node, u32 port) +static struct sk_buff *qrtr_alloc_ctrl_packet(u32 type, size_t pkt_len, + u32 src_node, u32 dst_node) { - const int pkt_len = 20; struct qrtr_hdr *hdr; struct sk_buff *skb; - __le32 *buf; skb = alloc_skb(QRTR_HDR_SIZE + pkt_len, GFP_KERNEL); if (!skb) @@ -261,7 +258,7 @@ static struct sk_buff *qrtr_alloc_resume_tx(u32 src_node, hdr = (struct qrtr_hdr *)skb_put(skb, QRTR_HDR_SIZE); hdr->version = cpu_to_le32(QRTR_PROTO_VER); - hdr->type = cpu_to_le32(QRTR_TYPE_RESUME_TX); + hdr->type = cpu_to_le32(type); hdr->src_node_id = cpu_to_le32(src_node); hdr->src_port_id = cpu_to_le32(QRTR_PORT_CTRL); hdr->confirm_rx = cpu_to_le32(0); @@ -269,6 +266,22 @@ static struct sk_buff *qrtr_alloc_resume_tx(u32 src_node, hdr->dst_node_id = cpu_to_le32(dst_node); hdr->dst_port_id = cpu_to_le32(QRTR_PORT_CTRL); + return skb; +} + +/* Allocate and construct a resume-tx packet. */ +static struct sk_buff *qrtr_alloc_resume_tx(u32 src_node, + u32 dst_node, u32 port) +{ + const int pkt_len = 20; + struct sk_buff *skb; + __le32 *buf; + + skb = qrtr_alloc_ctrl_packet(QRTR_TYPE_RESUME_TX, pkt_len, + src_node, dst_node); + if (!skb) + return NULL; + buf = (__le32 *)skb_put(skb, pkt_len); memset(buf, 0, pkt_len); buf[0] = cpu_to_le32(QRTR_TYPE_RESUME_TX); From patchwork Wed Jun 7 18:54:59 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 103308 Delivered-To: patch@linaro.org Received: by 10.140.91.77 with SMTP id y71csp2084140qgd; Wed, 7 Jun 2017 11:55:10 -0700 (PDT) X-Received: by 10.98.150.199 with SMTP id s68mr14338181pfk.206.1496861710430; Wed, 07 Jun 2017 11:55:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1496861710; cv=none; d=google.com; s=arc-20160816; b=ySyR7KFasLmPbYJIacoVweA/pOrjxJGiVKVtHg8r8hClbuk7RhGEg66SpUxCq+zbvW St1B6RbCm9zWIEj1BchYr2eNKH3HEZVfHw+fe1RL9nXwKDOGj3G4wYadcfqHYfLsaOO8 eLAhuTb/KI7x+w2YNPX4xjW9cdy8V93CFy/xwoz/61xp8hiEu4uhYslCC3uK1xVm8cw8 o2JDr5c40ONBivp1eGkJ/KIb3DTu9csBb88GmBgsYQi+rsLgIJZMQKqXl9bsDfeU38Zm bhhVGg9C5So3fznp8zXuJYJUVYyMkVLpTDs7xA8KZMnbExEYG1Rrr6X9HguA2hbySQDo uqwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=om9s3L+N5fiGngHo9LJjKb/je5ECXCBPdDzNVHHp5kQ=; b=dyrca2XtJ9vENLFXDZ5l2uMQt9YzHFMSBbaQK4I1j5MfUp7Hml6YkBpfvRmKf5Jjer Tcc/KGYfvSZZ3ql/RYftiorAaJ0ZtBxW2A55JbOowQeuhtiYVJgrynwQ1hBliqyZCpi/ w4Hw+m/12JXuK5FjBEuYZBdKlIpXQho7X+5i4YIL6nH4AXTqUL+r/IdNaiyyE5ggELpB 3sM/SFeMqzXAKMHyYSLOAbPPKco8JUG5rfCDmd5jbLMxoPfLzPhdHeFTC8befjpW2MMh 6DvemawuE4S0p0zbyszZ+2iDwCbLfFF/iDriN8+zku5ksEAGA4CVuglSY1wgAsgeRRdY iZHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n127si2436833pga.135.2017.06.07.11.55.10; Wed, 07 Jun 2017 11:55:10 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751934AbdFGSzI (ORCPT + 10 others); Wed, 7 Jun 2017 14:55:08 -0400 Received: from mail-pf0-f180.google.com ([209.85.192.180]:36130 "EHLO mail-pf0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751900AbdFGSzH (ORCPT ); Wed, 7 Jun 2017 14:55:07 -0400 Received: by mail-pf0-f180.google.com with SMTP id x63so8642890pff.3 for ; Wed, 07 Jun 2017 11:55:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=trZPSTIv0LkvQ3VvBzlArdmueRgUpcWdE8yr6CsIiZA=; b=ZpjW0vchhh5VkGg5iTq1lXgZsJeCLVw8jVcWoXpzVpGYbU2j69I54D6ME4Mpmvgp+e wAnVLHrjLJOwkOxvStjQ7GaXLfZjc+27OdhmbHLKeIV+QCGxSjDyrKc0PS5PFKsomvwu A7gLCMV6g8+0NQpvO9NEhzCujYlAjq91Wzw2M= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=trZPSTIv0LkvQ3VvBzlArdmueRgUpcWdE8yr6CsIiZA=; b=AW4W/hw3/7Y69zwuzpw4IrMQ7kxIRCoQ12hC5XnkdoOVa3wPrSA3NaBjJPhJXvhmmA PFx64OPFoM/0SKg6vE1ArAopCICp/o2NVGGpAJ2jwENQ1ayxLoTr0npuu6ebJ7+BhdV6 QYqJW4PIdEdeHwPQAA4lkiMdY5yi+ZQPlptY9yI91q6/S6fHc3BclQEN38bzICtKDY3c Law3ECmj3FOYV6qfbvsziLJ76JArvSHAiuAT21Sm6vXOLqKfnCJ5a1Z5ZXHdGcT+lMgk uYt6YeWVrjWvHreH1m4flOf89RiLdctc9pJ9h+cwi3l6JF1KKJhPDX/Vr3kqmFZ7UP28 A7EQ== X-Gm-Message-State: AODbwcAee9ceRC9KxnHA385vP9QKqU69U0FMpIuf0+S3Iv3XCDtEGXxy qwNblywFe4gSW/Ak X-Received: by 10.84.229.70 with SMTP id d6mr29410005pln.263.1496861706668; Wed, 07 Jun 2017 11:55:06 -0700 (PDT) Received: from localhost.localdomain (ip68-111-217-79.sd.sd.cox.net. [68.111.217.79]) by smtp.gmail.com with ESMTPSA id u73sm5355149pfi.105.2017.06.07.11.55.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 07 Jun 2017 11:55:06 -0700 (PDT) From: Bjorn Andersson To: "David S. Miller" Cc: Arun Kumar Neelakantam , netdev@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Courtney Cavin Subject: [PATCH 2/4] net: qrtr: Inject BYE on remote termination Date: Wed, 7 Jun 2017 11:54:59 -0700 Message-Id: <20170607185501.6000-2-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20170607185501.6000-1-bjorn.andersson@linaro.org> References: <20170607185501.6000-1-bjorn.andersson@linaro.org> Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Per the QMUX protocol specification a terminating node can send a BYE control message to signal that the link is going down, upon receiving this all information about remote services should be discarded and local clients should be notified. In the event that the link was brought down abruptly the router is supposed to act like a BYE message has arrived. As there is no harm in receiving an extra BYE from the remote this patch implements the latter by injecting a BYE when the link to the remote is unregistered. The name service will receive the BYE and can implement the notification to the local clients. Cc: Courtney Cavin Signed-off-by: Bjorn Andersson --- net/qrtr/qrtr.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) -- 2.12.0 -- To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/net/qrtr/qrtr.c b/net/qrtr/qrtr.c index 86d35ed50da9..e8cbab23d667 100644 --- a/net/qrtr/qrtr.c +++ b/net/qrtr/qrtr.c @@ -111,6 +111,8 @@ struct qrtr_node { struct list_head item; }; +static int qrtr_local_enqueue(struct qrtr_node *node, struct sk_buff *skb); + /* Release node resources and free the node. * * Do not call directly, use qrtr_node_release. To be used with @@ -291,6 +293,25 @@ static struct sk_buff *qrtr_alloc_resume_tx(u32 src_node, return skb; } +/* Allocate and construct a BYE message to signal remote termination */ +static struct sk_buff *qrtr_alloc_local_bye(u32 src_node) +{ + const int pkt_len = 20; + struct sk_buff *skb; + __le32 *buf; + + skb = qrtr_alloc_ctrl_packet(QRTR_TYPE_BYE, pkt_len, + src_node, qrtr_local_nid); + if (!skb) + return NULL; + + buf = (__le32 *)skb_put(skb, pkt_len); + memset(buf, 0, pkt_len); + buf[0] = cpu_to_le32(QRTR_TYPE_BYE); + + return skb; +} + static struct qrtr_sock *qrtr_port_lookup(int port); static void qrtr_port_put(struct qrtr_sock *ipc); @@ -382,11 +403,17 @@ EXPORT_SYMBOL_GPL(qrtr_endpoint_register); void qrtr_endpoint_unregister(struct qrtr_endpoint *ep) { struct qrtr_node *node = ep->node; + struct sk_buff *skb; mutex_lock(&node->ep_lock); node->ep = NULL; mutex_unlock(&node->ep_lock); + /* Notify the local controller about the event */ + skb = qrtr_alloc_local_bye(node->nid); + if (skb) + qrtr_local_enqueue(NULL, skb); + qrtr_node_release(node); ep->node = NULL; }