From patchwork Thu Oct 25 10:32:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: piaojun X-Patchwork-Id: 10655695 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id ED9EB13B5 for ; Thu, 25 Oct 2018 10:32:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DC0F12B4AF for ; Thu, 25 Oct 2018 10:32:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D02BA2B5F2; Thu, 25 Oct 2018 10:32:48 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from userp2130.oracle.com (userp2130.oracle.com [156.151.31.86]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3E4E42B5E8 for ; Thu, 25 Oct 2018 10:32:48 +0000 (UTC) Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w9PATurO170364; Thu, 25 Oct 2018 10:32:39 GMT Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by userp2130.oracle.com with ESMTP id 2n7usugrds-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 25 Oct 2018 10:32:39 +0000 Received: from oss.oracle.com (oss-old-reserved.oracle.com [137.254.22.2]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w9PAWcNL028835 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 25 Oct 2018 10:32:38 GMT Received: from localhost ([127.0.0.1] helo=lb-oss.oracle.com) by oss.oracle.com with esmtp (Exim 4.63) (envelope-from ) id 1gFcwQ-00029c-8N; Thu, 25 Oct 2018 03:32:38 -0700 Received: from aserv0021.oracle.com ([141.146.126.233]) by oss.oracle.com with esmtp (Exim 4.63) (envelope-from ) id 1gFcwO-00029O-NJ for ocfs2-devel@oss.oracle.com; Thu, 25 Oct 2018 03:32:36 -0700 Received: from userp2040.oracle.com (userp2040.oracle.com [156.151.31.90]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w9PAWauk011210 (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 25 Oct 2018 10:32:36 GMT Received: from pps.filterd (userp2040.oracle.com [127.0.0.1]) by userp2040.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w9PAUKaw010397 for ; Thu, 25 Oct 2018 10:32:36 GMT Received: from huawei.com (szxga05-in.huawei.com [45.249.212.191]) by userp2040.oracle.com with ESMTP id 2nb98uv7de-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Thu, 25 Oct 2018 10:32:35 +0000 Received: from DGGEMS405-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 114E4D02A19BF; Thu, 25 Oct 2018 18:32:29 +0800 (CST) Received: from [10.177.253.249] (10.177.253.249) by smtp.huawei.com (10.3.19.205) with Microsoft SMTP Server id 14.3.408.0; Thu, 25 Oct 2018 18:32:28 +0800 To: "akpm@linux-foundation.org" , "mark@fasheh.com" , Joel Becker , Junxiao Bi , Joseph Qi From: piaojun Message-ID: <5BD19BBA.5000707@huawei.com> Date: Thu, 25 Oct 2018 18:32:26 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 X-Originating-IP: [10.177.253.249] X-CFilter-Loop: Reflected X-CLX-Shades: MLX X-CLX-Response: 1TFkXGBIaEQpMehcbEhkRCllNF2dmchEKWUkXGnEaEBp3BhgcGnEdExoQGnc GGBoGGhEKWV4XaG55EQpJRhdFWEtJRk91WlhFTl9JXkNFRBl1T0sRCkNOFx9ZYkIaZkF/ZlhTYG ZlUHBmRhl9QHJIE39YX3NhHmh1EQpYXBcfBBoEGx8bB0gaSBwTSUwfBRsaBBsaGgQeEgQbEBseG h8aEQpeWRd+aBpoTxEKTVwXHhsfEQpMWhdoaU1NXREKQ1oXHh8EGB4TBBgbGAQbExsRCkJeFxsR CkReFx0RCkRJFxgRCkJGF2kdGRxzbWBcZ09YEQpCXBcaEQpCRRdmXGx7cGRiehJ8QxEKQk4XbEJ IWVMaTWV4eB0RCkJMF29LGRISRFl5WxtfEQpCbBdjBUJSZkBiXlp7UhEKQkAXYENNe11ka0Z8R0 4RCkJYF2J9b3kBTxgZcHB7EQpaWBcbEQpwaBdjGx0eaURkRl9TYRAZGhEKcGgXaWR4exhHYE98Z WsQGRoRCnBoF2EBa2JiR2NyWXpiEBkaEQpwaBdnAWVQHlBmWn8eHhAZGhEKcGgXZ3xcZBlTcm9O UxkQGRoRCnBsF2FJeUN6c0l4Z2xiEBkaEQptfhcaEQpYTRdLESA= X-PDR: PASS X-Source-IP: 45.249.212.191 X-ServerName: szxga05-in.huawei.com X-Proofpoint-SPF-Result: pass X-Proofpoint-SPF-Record: v=spf1 ip4:45.249.212.32 ip4:45.249.212.35 ip4:119.145.14.93 ip4:58.251.152.93 ip4:194.213.3.17 ip4:206.16.17.72 ip4:45.249.212.255 ip4:45.249.212.187/29 ip4:45.249.212.191 ip4:185.176.76.210 ~all X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9056 signatures=668683 X-Proofpoint-DMARC-Record: none X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=183 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=280 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810250094 X-Spam: Clean Cc: "ocfs2-devel@oss.oracle.com" Subject: [Ocfs2-devel] [PATCH 1/5] ocfs2/cluster: add configfs attributes for IPv6 address and port X-BeenThere: ocfs2-devel@oss.oracle.com X-Mailman-Version: 2.1.9 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: ocfs2-devel-bounces@oss.oracle.com Errors-To: ocfs2-devel-bounces@oss.oracle.com X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9056 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810250094 X-Virus-Scanned: ClamAV using ClamSMTP IPv6 address is not compatibile with IPv4, so add configfs attributes for IPv6 configure. Signed-off-by: Jun Piao --- fs/ocfs2/cluster/nodemanager.c | 45 ++++++++++++++++++++++++++++++++++-------- fs/ocfs2/cluster/nodemanager.h | 3 +++ 2 files changed, 40 insertions(+), 8 deletions(-) diff --git a/fs/ocfs2/cluster/nodemanager.c b/fs/ocfs2/cluster/nodemanager.c index da64c3a..a3c4e61 100644 --- a/fs/ocfs2/cluster/nodemanager.c +++ b/fs/ocfs2/cluster/nodemanager.c @@ -192,8 +192,10 @@ static struct o2nm_cluster *to_o2nm_cluster_from_node(struct o2nm_node *node) enum { O2NM_NODE_ATTR_NUM = 0, - O2NM_NODE_ATTR_PORT, - O2NM_NODE_ATTR_ADDRESS, + O2NM_NODE_ATTR_IPV4_PORT, + O2NM_NODE_ATTR_IPV6_PORT, + O2NM_NODE_ATTR_IPV4_ADDRESS, + O2NM_NODE_ATTR_IPV6_ADDRESS, }; static ssize_t o2nm_node_num_store(struct config_item *item, const char *page, @@ -216,8 +218,8 @@ static ssize_t o2nm_node_num_store(struct config_item *item, const char *page, * node number and try to use our address and port attributes * to connect to this node.. make sure that they've been set * before writing the node attribute? */ - if (!test_bit(O2NM_NODE_ATTR_ADDRESS, &node->nd_set_attributes) || - !test_bit(O2NM_NODE_ATTR_PORT, &node->nd_set_attributes)) + if (!test_bit(O2NM_NODE_ATTR_IPV4_ADDRESS, &node->nd_set_attributes) || + !test_bit(O2NM_NODE_ATTR_IPV4_PORT, &node->nd_set_attributes)) return -EINVAL; /* XXX */ o2nm_lock_subsystem(); @@ -267,7 +269,7 @@ static ssize_t o2nm_node_ipv4_port_store(struct config_item *item, if (tmp >= (u16)-1) return -ERANGE; - if (test_and_set_bit(O2NM_NODE_ATTR_PORT, &node->nd_set_attributes)) + if (test_and_set_bit(O2NM_NODE_ATTR_IPV4_PORT, &node->nd_set_attributes)) return -EBUSY; node->nd_ipv4_port = htons(tmp); @@ -312,7 +314,7 @@ static ssize_t o2nm_node_ipv4_address_store(struct config_item *item, write_lock(&cluster->cl_nodes_lock); if (o2nm_node_ip_tree_lookup(cluster, ipv4_addr, &p, &parent)) ret = -EEXIST; - else if (test_and_set_bit(O2NM_NODE_ATTR_ADDRESS, + else if (test_and_set_bit(O2NM_NODE_ATTR_IPV4_ADDRESS, &node->nd_set_attributes)) ret = -EBUSY; else { @@ -330,6 +332,29 @@ static ssize_t o2nm_node_ipv4_address_store(struct config_item *item, return count; } +static ssize_t o2nm_node_ipv6_port_show(struct config_item *item, char *page) +{ + return 0; +} + +static ssize_t o2nm_node_ipv6_port_store(struct config_item *item, + const char *page, size_t count) +{ + return 0; +} + +static ssize_t o2nm_node_ipv6_address_show(struct config_item *item, char *page) +{ + return 0; +} + +static ssize_t o2nm_node_ipv6_address_store(struct config_item *item, + const char *page, + size_t count) +{ + return 0; +} + static ssize_t o2nm_node_local_show(struct config_item *item, char *page) { return sprintf(page, "%d\n", to_o2nm_node(item)->nd_local); @@ -352,9 +377,9 @@ static ssize_t o2nm_node_local_store(struct config_item *item, const char *page, /* setting local turns on networking rx for now so we require having * set everything else first */ - if (!test_bit(O2NM_NODE_ATTR_ADDRESS, &node->nd_set_attributes) || + if (!test_bit(O2NM_NODE_ATTR_IPV4_ADDRESS, &node->nd_set_attributes) || !test_bit(O2NM_NODE_ATTR_NUM, &node->nd_set_attributes) || - !test_bit(O2NM_NODE_ATTR_PORT, &node->nd_set_attributes)) + !test_bit(O2NM_NODE_ATTR_IPV4_PORT, &node->nd_set_attributes)) return -EINVAL; /* XXX */ o2nm_lock_subsystem(); @@ -400,13 +425,17 @@ static ssize_t o2nm_node_local_store(struct config_item *item, const char *page, CONFIGFS_ATTR(o2nm_node_, num); CONFIGFS_ATTR(o2nm_node_, ipv4_port); +CONFIGFS_ATTR(o2nm_node_, ipv6_port); CONFIGFS_ATTR(o2nm_node_, ipv4_address); +CONFIGFS_ATTR(o2nm_node_, ipv6_address); CONFIGFS_ATTR(o2nm_node_, local); static struct configfs_attribute *o2nm_node_attrs[] = { &o2nm_node_attr_num, &o2nm_node_attr_ipv4_port, + &o2nm_node_attr_ipv6_port, &o2nm_node_attr_ipv4_address, + &o2nm_node_attr_ipv6_address, &o2nm_node_attr_local, NULL, }; diff --git a/fs/ocfs2/cluster/nodemanager.h b/fs/ocfs2/cluster/nodemanager.h index 09ea2d3..55fdb81 100644 --- a/fs/ocfs2/cluster/nodemanager.h +++ b/fs/ocfs2/cluster/nodemanager.h @@ -45,8 +45,11 @@ struct o2nm_node { char nd_name[O2NM_MAX_NAME_LEN+1]; /* replace? */ __u8 nd_num; /* only one address per node, as attributes, for now. */ + unsigned nd_ipnet_type:1; /* 0-ipv4, 1-ipv6 */ __be32 nd_ipv4_address; + __u8 nd_ipv6_address[16]; __be16 nd_ipv4_port; + __be16 nd_ipv6_port; struct rb_node nd_ip_node; /* there can be only one local node for now */ int nd_local; From patchwork Thu Oct 25 10:34:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: piaojun X-Patchwork-Id: 10655697 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 07E2114BB for ; Thu, 25 Oct 2018 10:34:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E8F1328478 for ; Thu, 25 Oct 2018 10:34:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DD500284B5; Thu, 25 Oct 2018 10:34:33 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from userp2130.oracle.com (userp2130.oracle.com [156.151.31.86]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3A8DC28478 for ; Thu, 25 Oct 2018 10:34:33 +0000 (UTC) Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w9PAYPhM173833; Thu, 25 Oct 2018 10:34:25 GMT Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by userp2130.oracle.com with ESMTP id 2n7usugrma-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 25 Oct 2018 10:34:25 +0000 Received: from oss.oracle.com (oss-old-reserved.oracle.com [137.254.22.2]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w9PAYOOW005381 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 25 Oct 2018 10:34:24 GMT Received: from localhost ([127.0.0.1] helo=lb-oss.oracle.com) by oss.oracle.com with esmtp (Exim 4.63) (envelope-from ) id 1gFcy8-0002DK-Ce; Thu, 25 Oct 2018 03:34:24 -0700 Received: from aserv0022.oracle.com ([141.146.126.234]) by oss.oracle.com with esmtp (Exim 4.63) (envelope-from ) id 1gFcy6-0002D7-H6 for ocfs2-devel@oss.oracle.com; Thu, 25 Oct 2018 03:34:22 -0700 Received: from userp2040.oracle.com (userp2040.oracle.com [156.151.31.90]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w9PAYMBf000307 (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 25 Oct 2018 10:34:22 GMT Received: from pps.filterd (userp2040.oracle.com [127.0.0.1]) by userp2040.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w9PAYKhp016872 for ; Thu, 25 Oct 2018 10:34:22 GMT Received: from huawei.com (szxga07-in.huawei.com [45.249.212.35]) by userp2040.oracle.com with ESMTP id 2nb98uv8bn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Thu, 25 Oct 2018 10:34:21 +0000 Received: from DGGEMS408-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id D50851AFEFA48; Thu, 25 Oct 2018 18:34:15 +0800 (CST) Received: from [10.177.253.249] (10.177.253.249) by smtp.huawei.com (10.3.19.208) with Microsoft SMTP Server id 14.3.408.0; Thu, 25 Oct 2018 18:34:13 +0800 To: "akpm@linux-foundation.org" , "mark@fasheh.com" , Joel Becker , Junxiao Bi , Joseph Qi From: piaojun Message-ID: <5BD19C23.4000405@huawei.com> Date: Thu, 25 Oct 2018 18:34:11 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 X-Originating-IP: [10.177.253.249] X-CFilter-Loop: Reflected X-CLX-Shades: MLX X-CLX-Response: 1TFkXGRsYEQpMehcYGh8RCllNF2dmchEKWUkXGnEaEBp3BhgTGHESGR4QGnc GGBoGGhEKWV4XaG55EQpJRhdFWEtJRk91WlhFTl9JXkNFRBl1T0sRCkNOF2VwS2t5Y0YeExoHWn xPHkRNeGBzfxxkUG5hQUYfWR5rEQpYXBcfBBoEGx8bB0gaSBwTSUwfBRsaBBsaGgQeEgQfEBseG h8aEQpeWRd+aBpuYxEKTVwXHx4YEQpMWhdoaU1NXREKQ1oXHh8EGB4TBBgbGAQZHxEKQl4XGxEK RF4XHREKREkXGBEKQkYXel9DbRpLTwV7QmgRCkJcFxoRCkJFF2ZcbHtwZGJ6EnxDEQpCThdsQkh ZUxpNZXh4HREKQkwXb0sZEhJEWXlbG18RCkJsF2MFQlJmQGJeWntSEQpCQBdtT11dHU1Fa21CSR EKQlgXYn1veQFPGBlwcHsRClpYFxgRCnBoF2kbSE1jXFB+eBxQEBoRCnBoF2xdQkB8RlJbSEUcE BoRCnBoF2xiHmJrQVgZGFhHEBoRCnBoF2R/EgVBU2caTE0FEBoRCnBoF2V5ZHxZZW9nYlhkEBoR CnBsF2FJeUN6c0l4Z2xiEBkaEQptfhcaEQpYTRdLESA= X-PDR: PASS X-Source-IP: 45.249.212.35 X-ServerName: szxga07-in.huawei.com X-Proofpoint-SPF-Result: pass X-Proofpoint-SPF-Record: v=spf1 ip4:45.249.212.32 ip4:45.249.212.35 ip4:119.145.14.93 ip4:58.251.152.93 ip4:194.213.3.17 ip4:206.16.17.72 ip4:45.249.212.255 ip4:45.249.212.187/29 ip4:45.249.212.191 ip4:185.176.76.210 ~all X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9056 signatures=668683 X-Proofpoint-DMARC-Record: none X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=205 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=312 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810250095 X-Spam: Clean Cc: "ocfs2-devel@oss.oracle.com" Subject: [Ocfs2-devel] [PATCH 2/5] ocfs2/cluster: implement show & store method for IPv6 attribute X-BeenThere: ocfs2-devel@oss.oracle.com X-Mailman-Version: 2.1.9 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: ocfs2-devel-bounces@oss.oracle.com Errors-To: ocfs2-devel-bounces@oss.oracle.com X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9056 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810250095 X-Virus-Scanned: ClamAV using ClamSMTP Implement o2nm_node_ipv6_port_show(), o2nm_node_ipv6_port_store(), o2nm_node_ipv6_address_show and o2nm_node_ipv6_address_store which used for configuring IPv6 node information. Signed-off-by: Jun Piao --- fs/ocfs2/cluster/nodemanager.c | 108 ++++++++++++++++++++++++++++++++++------- fs/ocfs2/cluster/nodemanager.h | 6 +++ 2 files changed, 96 insertions(+), 18 deletions(-) diff --git a/fs/ocfs2/cluster/nodemanager.c b/fs/ocfs2/cluster/nodemanager.c index a3c4e61..292f5dd 100644 --- a/fs/ocfs2/cluster/nodemanager.c +++ b/fs/ocfs2/cluster/nodemanager.c @@ -78,7 +78,7 @@ int o2nm_configured_node_map(unsigned long *map, unsigned bytes) EXPORT_SYMBOL_GPL(o2nm_configured_node_map); static struct o2nm_node *o2nm_node_ip_tree_lookup(struct o2nm_cluster *cluster, - __be32 ip_needle, + u8 ip_needle[], struct rb_node ***ret_p, struct rb_node **ret_parent) { @@ -91,9 +91,12 @@ static struct o2nm_node *o2nm_node_ip_tree_lookup(struct o2nm_cluster *cluster, parent = *p; node = rb_entry(parent, struct o2nm_node, nd_ip_node); - - cmp = memcmp(&ip_needle, &node->nd_ipv4_address, - sizeof(ip_needle)); + if (node->nd_ipnet_type == IPV4_TYPE) + cmp = memcmp(ip_needle, &node->nd_ipv4_address, + sizeof(node->nd_ipv4_address)); + else + cmp = memcmp(ip_needle, node->nd_ipv6_address, + sizeof(node->nd_ipv6_address)); if (cmp < 0) p = &(*p)->rb_left; else if (cmp > 0) @@ -121,7 +124,7 @@ struct o2nm_node *o2nm_get_node_by_ip(__be32 addr) goto out; read_lock(&cluster->cl_nodes_lock); - node = o2nm_node_ip_tree_lookup(cluster, addr, NULL, NULL); + node = o2nm_node_ip_tree_lookup(cluster, (u8 *)&addr, NULL, NULL); if (node) config_item_get(&node->nd_item); read_unlock(&cluster->cl_nodes_lock); @@ -218,9 +221,14 @@ static ssize_t o2nm_node_num_store(struct config_item *item, const char *page, * node number and try to use our address and port attributes * to connect to this node.. make sure that they've been set * before writing the node attribute? */ - if (!test_bit(O2NM_NODE_ATTR_IPV4_ADDRESS, &node->nd_set_attributes) || - !test_bit(O2NM_NODE_ATTR_IPV4_PORT, &node->nd_set_attributes)) - return -EINVAL; /* XXX */ + if ((node->nd_ipnet_type == IPV4_TYPE) && + (!test_bit(O2NM_NODE_ATTR_IPV4_ADDRESS, &node->nd_set_attributes) || + !test_bit(O2NM_NODE_ATTR_IPV4_PORT, &node->nd_set_attributes))) + return -EINVAL; + else if ((node->nd_ipnet_type == IPV6_TYPE) && + (!test_bit(O2NM_NODE_ATTR_IPV6_ADDRESS, &node->nd_set_attributes) || + !test_bit(O2NM_NODE_ATTR_IPV6_PORT, &node->nd_set_attributes))) + return -EINVAL; o2nm_lock_subsystem(); cluster = to_o2nm_cluster_from_node(node); @@ -312,7 +320,7 @@ static ssize_t o2nm_node_ipv4_address_store(struct config_item *item, ret = 0; write_lock(&cluster->cl_nodes_lock); - if (o2nm_node_ip_tree_lookup(cluster, ipv4_addr, &p, &parent)) + if (o2nm_node_ip_tree_lookup(cluster, (u8 *)&ipv4_addr, &p, &parent)) ret = -EEXIST; else if (test_and_set_bit(O2NM_NODE_ATTR_IPV4_ADDRESS, &node->nd_set_attributes)) @@ -328,31 +336,86 @@ static ssize_t o2nm_node_ipv4_address_store(struct config_item *item, return ret; memcpy(&node->nd_ipv4_address, &ipv4_addr, sizeof(ipv4_addr)); + node->nd_ipnet_type = IPV4_TYPE; return count; } static ssize_t o2nm_node_ipv6_port_show(struct config_item *item, char *page) { - return 0; + return sprintf(page, "%u\n", ntohs(to_o2nm_node(item)->nd_ipv6_port)); } static ssize_t o2nm_node_ipv6_port_store(struct config_item *item, const char *page, size_t count) { - return 0; + struct o2nm_node *node = to_o2nm_node(item); + unsigned long tmp; + char *p = (char *)page; + + tmp = simple_strtoul(p, &p, 0); + if (!p || (*p && (*p != '\n'))) + return -EINVAL; + + if (tmp == 0) + return -EINVAL; + if (tmp >= (u16)-1) + return -ERANGE; + + if (test_and_set_bit(O2NM_NODE_ATTR_IPV6_PORT, &node->nd_set_attributes)) + return -EBUSY; + node->nd_ipv6_port = htons(tmp); + + return count; } static ssize_t o2nm_node_ipv6_address_show(struct config_item *item, char *page) { - return 0; + return sprintf(page, "%pI6\n", to_o2nm_node(item)->nd_ipv6_address); } static ssize_t o2nm_node_ipv6_address_store(struct config_item *item, const char *page, size_t count) { - return 0; + struct o2nm_node *node = to_o2nm_node(item); + struct o2nm_cluster *cluster; + int ret; + struct rb_node **p, *parent; + u8 ipv6_addr[16] = {0}; + + ret = in6_pton((const char *)page, count, ipv6_addr, -1, NULL); + if (ret != 1) + return -EINVAL; + + o2nm_lock_subsystem(); + cluster = to_o2nm_cluster_from_node(node); + if (!cluster) { + o2nm_unlock_subsystem(); + return -EINVAL; + } + + ret = 0; + write_lock(&cluster->cl_nodes_lock); + if (o2nm_node_ip_tree_lookup(cluster, ipv6_addr, &p, &parent)) + ret = -EEXIST; + else if (test_and_set_bit(O2NM_NODE_ATTR_IPV6_ADDRESS, + &node->nd_set_attributes)) + ret = -EBUSY; + else { + rb_link_node(&node->nd_ip_node, parent, p); + rb_insert_color(&node->nd_ip_node, &cluster->cl_node_ip_tree); + } + write_unlock(&cluster->cl_nodes_lock); + o2nm_unlock_subsystem(); + + if (ret) + return ret; + + memcpy(node->nd_ipv6_address, ipv6_addr, sizeof(ipv6_addr)); + node->nd_ipnet_type = IPV6_TYPE; + + return count; } static ssize_t o2nm_node_local_show(struct config_item *item, char *page) @@ -377,10 +440,16 @@ static ssize_t o2nm_node_local_store(struct config_item *item, const char *page, /* setting local turns on networking rx for now so we require having * set everything else first */ - if (!test_bit(O2NM_NODE_ATTR_IPV4_ADDRESS, &node->nd_set_attributes) || - !test_bit(O2NM_NODE_ATTR_NUM, &node->nd_set_attributes) || - !test_bit(O2NM_NODE_ATTR_IPV4_PORT, &node->nd_set_attributes)) - return -EINVAL; /* XXX */ + if (!test_bit(O2NM_NODE_ATTR_NUM, &node->nd_set_attributes)) + return -EINVAL; + if ((node->nd_ipnet_type == IPV4_TYPE) && + (!test_bit(O2NM_NODE_ATTR_IPV4_ADDRESS, &node->nd_set_attributes) || + !test_bit(O2NM_NODE_ATTR_IPV4_PORT, &node->nd_set_attributes))) + return -EINVAL; + else if ((node->nd_ipnet_type == IPV6_TYPE) && + (!test_bit(O2NM_NODE_ATTR_IPV6_ADDRESS, &node->nd_set_attributes) || + !test_bit(O2NM_NODE_ATTR_IPV6_PORT, &node->nd_set_attributes))) + return -EINVAL; o2nm_lock_subsystem(); cluster = to_o2nm_cluster_from_node(node); @@ -649,6 +718,7 @@ static void o2nm_node_group_drop_item(struct config_group *group, { struct o2nm_node *node = to_o2nm_node(item); struct o2nm_cluster *cluster = to_o2nm_cluster(group->cg_item.ci_parent); + u8 ipv6_addr[16] = {0}; o2net_disconnect_node(node); @@ -664,7 +734,9 @@ static void o2nm_node_group_drop_item(struct config_group *group, write_lock(&cluster->cl_nodes_lock); /* XXX sloppy */ - if (node->nd_ipv4_address) + if ((node->nd_ipnet_type == IPV4_TYPE && node->nd_ipv4_address) || + (node->nd_ipnet_type == IPV6_TYPE && + memcmp(ipv6_addr, node->nd_ipv6_address, sizeof(ipv6_addr)))) rb_erase(&node->nd_ip_node, &cluster->cl_node_ip_tree); /* nd_num might be 0 if the node number hasn't been set.. */ diff --git a/fs/ocfs2/cluster/nodemanager.h b/fs/ocfs2/cluster/nodemanager.h index 55fdb81..1f3cfc5 100644 --- a/fs/ocfs2/cluster/nodemanager.h +++ b/fs/ocfs2/cluster/nodemanager.h @@ -39,6 +39,12 @@ enum o2nm_fence_method { O2NM_FENCE_METHODS, /* Number of fence methods */ }; +enum ipnet_type { + IPV4_TYPE = 0, + IPV6_TYPE, + INVALID_IPNET_TYPE, +}; + struct o2nm_node { spinlock_t nd_lock; struct config_item nd_item; From patchwork Thu Oct 25 10:35:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: piaojun X-Patchwork-Id: 10655699 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 080A013B5 for ; Thu, 25 Oct 2018 10:35:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E873A283C5 for ; Thu, 25 Oct 2018 10:35:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DC4DF286D4; Thu, 25 Oct 2018 10:35:24 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from aserp2120.oracle.com (aserp2120.oracle.com [141.146.126.78]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C38B9283C5 for ; Thu, 25 Oct 2018 10:35:23 +0000 (UTC) Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w9PAYUmj179267; Thu, 25 Oct 2018 10:35:15 GMT Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by aserp2120.oracle.com with ESMTP id 2n7vaq8q04-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 25 Oct 2018 10:35:15 +0000 Received: from oss.oracle.com (oss-old-reserved.oracle.com [137.254.22.2]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w9PAZDxu002888 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 25 Oct 2018 10:35:13 GMT Received: from localhost ([127.0.0.1] helo=lb-oss.oracle.com) by oss.oracle.com with esmtp (Exim 4.63) (envelope-from ) id 1gFcyv-0002FR-G1; Thu, 25 Oct 2018 03:35:13 -0700 Received: from aserv0021.oracle.com ([141.146.126.233]) by oss.oracle.com with esmtp (Exim 4.63) (envelope-from ) id 1gFcyt-0002FD-QL for ocfs2-devel@oss.oracle.com; Thu, 25 Oct 2018 03:35:11 -0700 Received: from userp2030.oracle.com (userp2030.oracle.com [156.151.31.89]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w9PAZBkL017694 (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 25 Oct 2018 10:35:11 GMT Received: from pps.filterd (userp2030.oracle.com [127.0.0.1]) by userp2030.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w9PAXo4E009176 for ; Thu, 25 Oct 2018 10:35:11 GMT Received: from huawei.com (szxga07-in.huawei.com [45.249.212.35]) by userp2030.oracle.com with ESMTP id 2nbc61r18h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Thu, 25 Oct 2018 10:35:10 +0000 Received: from DGGEMS405-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 77B6512096559; Thu, 25 Oct 2018 18:35:06 +0800 (CST) Received: from [10.177.253.249] (10.177.253.249) by smtp.huawei.com (10.3.19.205) with Microsoft SMTP Server id 14.3.408.0; Thu, 25 Oct 2018 18:35:04 +0800 To: "akpm@linux-foundation.org" , "mark@fasheh.com" , Joel Becker , Junxiao Bi , Joseph Qi From: piaojun Message-ID: <5BD19C56.5040201@huawei.com> Date: Thu, 25 Oct 2018 18:35:02 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 X-Originating-IP: [10.177.253.249] X-CFilter-Loop: Reflected X-CLX-Shades: MLX X-CLX-Response: 1TFkXGRsYEQpMehcYGh8RCllNF2dmchEKWUkXGnEaEBp3BhgTGHESGR4QGnc GGBoGGhEKWV4XaG55EQpJRhdFWEtJRk91WlhFTl9JXkNFRBl1T0sRCkNOFxkTS2dnGXBkWx9kZG RFE2ZzZ0duGlhIXR9pZnMdB3pnEQpYXBcfBBoEGx8bB0gaSBwTSUwfBRsaBBsaGgQeEgQfEBseG h8aEQpeWRd+aBpuHBEKTVwXGB0YEQpMWhdoaU1NXREKQ1oXHh8EGB4TBBgbGAQZHxEKQl4XGxEK RF4XHREKREkXGBEKQkYXY0FPAVJ8QE5/WVgRCkJcFxoRCkJFF2ZcbHtwZGJ6EnxDEQpCThdsQkh ZUxpNZXh4HREKQkwXb0sZEhJEWXlbG18RCkJsF2MFQlJmQGJeWntSEQpCQBdpSBNPR14SelBnXh EKQlgXYn1veQFPGBlwcHsRCk1eFxsRClpYFxgRCnBoF2doZW0BQnxaTF5zEBoRCnBoF2QBSV5cG xp9Zl5TEBoRCnBoF2VoZksTQV0cYl0BEBoRCnBoF29wUGUZRkkeTXhSEBoRCnBoF2sbYkFBGxp/ EntEEBoRCnBsF2FJeUN6c0l4Z2xiEBkaEQptfhcbEQpYTRdLESA= X-PDR: PASS X-Source-IP: 45.249.212.35 X-ServerName: szxga07-in.huawei.com X-Proofpoint-SPF-Result: pass X-Proofpoint-SPF-Record: v=spf1 ip4:45.249.212.32 ip4:45.249.212.35 ip4:119.145.14.93 ip4:58.251.152.93 ip4:194.213.3.17 ip4:206.16.17.72 ip4:45.249.212.255 ip4:45.249.212.187/29 ip4:45.249.212.191 ip4:185.176.76.210 ~all X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9056 signatures=668683 X-Proofpoint-DMARC-Record: none X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=205 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=312 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810250095 X-Spam: Clean Cc: "ocfs2-devel@oss.oracle.com" Subject: [Ocfs2-devel] [PATCH 3/5] ocfs2/cluster: support IPv6 socket connection between nodes X-BeenThere: ocfs2-devel@oss.oracle.com X-Mailman-Version: 2.1.9 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: ocfs2-devel-bounces@oss.oracle.com Errors-To: ocfs2-devel-bounces@oss.oracle.com X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9056 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810250095 X-Virus-Scanned: ClamAV using ClamSMTP Both IPv4 and IPv6 will be supported when connecting or accepting other nodes in cluster according to configuration by uppper user. Signed-off-by: Jun Piao --- fs/ocfs2/cluster/nodemanager.c | 4 +- fs/ocfs2/cluster/nodemanager.h | 2 +- fs/ocfs2/cluster/tcp.c | 190 ++++++++++++++++++++++++++++++----------- 3 files changed, 141 insertions(+), 55 deletions(-) diff --git a/fs/ocfs2/cluster/nodemanager.c b/fs/ocfs2/cluster/nodemanager.c index 292f5dd..6813517 100644 --- a/fs/ocfs2/cluster/nodemanager.c +++ b/fs/ocfs2/cluster/nodemanager.c @@ -115,7 +115,7 @@ static struct o2nm_node *o2nm_node_ip_tree_lookup(struct o2nm_cluster *cluster, return ret; } -struct o2nm_node *o2nm_get_node_by_ip(__be32 addr) +struct o2nm_node *o2nm_get_node_by_ip(u8 addr[]) { struct o2nm_node *node = NULL; struct o2nm_cluster *cluster = o2nm_single_cluster; @@ -124,7 +124,7 @@ struct o2nm_node *o2nm_get_node_by_ip(__be32 addr) goto out; read_lock(&cluster->cl_nodes_lock); - node = o2nm_node_ip_tree_lookup(cluster, (u8 *)&addr, NULL, NULL); + node = o2nm_node_ip_tree_lookup(cluster, addr, NULL, NULL); if (node) config_item_get(&node->nd_item); read_unlock(&cluster->cl_nodes_lock); diff --git a/fs/ocfs2/cluster/nodemanager.h b/fs/ocfs2/cluster/nodemanager.h index 1f3cfc5..e5f8701 100644 --- a/fs/ocfs2/cluster/nodemanager.h +++ b/fs/ocfs2/cluster/nodemanager.h @@ -85,7 +85,7 @@ struct o2nm_cluster { int o2nm_configured_node_map(unsigned long *map, unsigned bytes); struct o2nm_node *o2nm_get_node_by_num(u8 node_num); -struct o2nm_node *o2nm_get_node_by_ip(__be32 addr); +struct o2nm_node *o2nm_get_node_by_ip(u8 addr[]); void o2nm_node_get(struct o2nm_node *node); void o2nm_node_put(struct o2nm_node *node); diff --git a/fs/ocfs2/cluster/tcp.c b/fs/ocfs2/cluster/tcp.c index 1296f78..82fa8da 100644 --- a/fs/ocfs2/cluster/tcp.c +++ b/fs/ocfs2/cluster/tcp.c @@ -1583,10 +1583,13 @@ static void o2net_start_connect(struct work_struct *work) struct o2net_sock_container *sc = NULL; struct o2nm_node *node = NULL, *mynode = NULL; struct socket *sock = NULL; + struct sockaddr *mysa = NULL, *remotesa = NULL; struct sockaddr_in myaddr = {0, }, remoteaddr = {0, }; - int ret = 0, stop; + struct sockaddr_in6 myaddr6 = {0, }, remoteaddr6 = {0, }; + int ret = 0, stop, addr_len; unsigned int timeout; unsigned int noio_flag; + unsigned short sa_family; /* * sock_create allocates the sock with GFP_KERNEL. We must set @@ -1633,7 +1636,33 @@ static void o2net_start_connect(struct work_struct *work) goto out; } - ret = sock_create(PF_INET, SOCK_STREAM, IPPROTO_TCP, &sock); + if (mynode->nd_ipnet_type == IPV4_TYPE) { + myaddr.sin_family = sa_family = AF_INET; + myaddr.sin_addr.s_addr = mynode->nd_ipv4_address; + myaddr.sin_port = htons(0); /* any port */ + mysa = (struct sockaddr *)&myaddr; + + remoteaddr.sin_family = AF_INET; + remoteaddr.sin_addr.s_addr = node->nd_ipv4_address; + remoteaddr.sin_port = node->nd_ipv4_port; + remotesa = (struct sockaddr *)&remoteaddr; + addr_len = sizeof(myaddr); + } else { + myaddr6.sin6_family = sa_family = AF_INET6; + memcpy(&myaddr6.sin6_addr, mynode->nd_ipv6_address, + sizeof(mynode->nd_ipv6_address)); + myaddr6.sin6_port = htons(0); /* any port */ + mysa = (struct sockaddr *)&myaddr6; + + remoteaddr6.sin6_family = AF_INET6; + memcpy(&remoteaddr6.sin6_addr, node->nd_ipv6_address, + sizeof(node->nd_ipv6_address)); + remoteaddr6.sin6_port = node->nd_ipv6_port; + remotesa = (struct sockaddr *)&remoteaddr6; + addr_len = sizeof(myaddr6); + } + + ret = sock_create(sa_family, SOCK_STREAM, IPPROTO_TCP, &sock); if (ret < 0) { mlog(0, "can't create socket: %d\n", ret); goto out; @@ -1642,15 +1671,14 @@ static void o2net_start_connect(struct work_struct *work) sock->sk->sk_allocation = GFP_ATOMIC; - myaddr.sin_family = AF_INET; - myaddr.sin_addr.s_addr = mynode->nd_ipv4_address; - myaddr.sin_port = htons(0); /* any port */ - - ret = sock->ops->bind(sock, (struct sockaddr *)&myaddr, - sizeof(myaddr)); + ret = sock->ops->bind(sock, mysa, addr_len); if (ret) { - mlog(ML_ERROR, "bind failed with %d at address %pI4\n", - ret, &mynode->nd_ipv4_address); + if (mynode->nd_ipnet_type == IPV4_TYPE) + mlog(ML_ERROR, "bind failed with %d at address %pI4\n", + ret, &mynode->nd_ipv4_address); + else + mlog(ML_ERROR, "bind failed with %d at address %pI6\n", + ret, mynode->nd_ipv6_address); goto out; } @@ -1673,13 +1701,9 @@ static void o2net_start_connect(struct work_struct *work) o2net_set_nn_state(nn, sc, 0, 0); spin_unlock(&nn->nn_lock); - remoteaddr.sin_family = AF_INET; - remoteaddr.sin_addr.s_addr = node->nd_ipv4_address; - remoteaddr.sin_port = node->nd_ipv4_port; - ret = sc->sc_sock->ops->connect(sc->sc_sock, - (struct sockaddr *)&remoteaddr, - sizeof(remoteaddr), + remotesa, + addr_len, O_NONBLOCK); if (ret == -EINPROGRESS) ret = 0; @@ -1819,11 +1843,13 @@ int o2net_register_hb_callbacks(void) static int o2net_accept_one(struct socket *sock, int *more) { - int ret; + int ret, slen; + struct sockaddr *sa = NULL; struct sockaddr_in sin; + struct sockaddr_in6 sin6; struct socket *new_sock = NULL; struct o2nm_node *node = NULL; - struct o2nm_node *local_node = NULL; + struct o2nm_node *local_node = o2nm_get_node_by_num(o2nm_this_node()); struct o2net_sock_container *sc = NULL; struct o2net_node *nn; unsigned int noio_flag; @@ -1864,22 +1890,39 @@ static int o2net_accept_one(struct socket *sock, int *more) goto out; } - ret = new_sock->ops->getname(new_sock, (struct sockaddr *) &sin, 1); + if (local_node->nd_ipnet_type == IPV4_TYPE) { + sa = (struct sockaddr *)&sin; + slen = sizeof(sin); + } else { + sa = (struct sockaddr *)&sin6; + slen = sizeof(sin6); + } + ret = new_sock->ops->getname(new_sock, sa, 1); if (ret < 0) goto out; - node = o2nm_get_node_by_ip(sin.sin_addr.s_addr); - if (node == NULL) { - printk(KERN_NOTICE "o2net: Attempt to connect from unknown " - "node at %pI4:%d\n", &sin.sin_addr.s_addr, - ntohs(sin.sin_port)); - ret = -EINVAL; - goto out; + if (local_node->nd_ipnet_type == IPV4_TYPE) { + node = o2nm_get_node_by_ip((u8 *)&sin.sin_addr.s_addr); + if (node == NULL) { + printk(KERN_NOTICE "o2net: Attempt to connect from unknown " + "node at %pI4:%d\n", &sin.sin_addr.s_addr, + ntohs(sin.sin_port)); + ret = -EINVAL; + goto out; + } + } else { + node = o2nm_get_node_by_ip(sin6.sin6_addr.s6_addr); + if (node == NULL) { + printk(KERN_NOTICE "o2net: Attempt to connect from unknown " + "node at %pI6:%d\n", sin6.sin6_addr.s6_addr, + ntohs(sin6.sin6_port)); + ret = -EINVAL; + goto out; + } } if (o2nm_this_node() >= node->nd_num) { - local_node = o2nm_get_node_by_num(o2nm_this_node()); - if (local_node) + if (local_node->nd_ipnet_type == IPV4_TYPE) printk(KERN_NOTICE "o2net: Unexpected connect attempt " "seen at node '%s' (%u, %pI4:%d) from " "node '%s' (%u, %pI4:%d)\n", @@ -1889,6 +1932,16 @@ static int o2net_accept_one(struct socket *sock, int *more) node->nd_name, node->nd_num, &sin.sin_addr.s_addr, ntohs(sin.sin_port)); + else + printk(KERN_NOTICE "o2net: Unexpected connect attempt " + "seen at node '%s' (%u, %pI6:%d) from " + "node '%s' (%u, %pI6:%d)\n", + local_node->nd_name, local_node->nd_num, + local_node->nd_ipv6_address, + ntohs(local_node->nd_ipv6_port), + node->nd_name, + node->nd_num, sin6.sin6_addr.s6_addr, + ntohs(sin6.sin6_port)); ret = -EINVAL; goto out; } @@ -1896,10 +1949,16 @@ static int o2net_accept_one(struct socket *sock, int *more) /* this happens all the time when the other node sees our heartbeat * and tries to connect before we see their heartbeat */ if (!o2hb_check_node_heartbeating_from_callback(node->nd_num)) { - mlog(ML_CONN, "attempt to connect from node '%s' at " - "%pI4:%d but it isn't heartbeating\n", - node->nd_name, &sin.sin_addr.s_addr, - ntohs(sin.sin_port)); + if (local_node->nd_ipnet_type == IPV4_TYPE) + mlog(ML_CONN, "attempt to connect from node '%s' at " + "%pI4:%d but it isn't heartbeating\n", + node->nd_name, &sin.sin_addr.s_addr, + ntohs(sin.sin_port)); + else + mlog(ML_CONN, "attempt to connect from node '%s' at " + "%pI6:%d but it isn't heartbeating\n", + node->nd_name, sin6.sin6_addr.s6_addr, + ntohs(sin6.sin6_port)); ret = -EINVAL; goto out; } @@ -1913,10 +1972,16 @@ static int o2net_accept_one(struct socket *sock, int *more) ret = 0; spin_unlock(&nn->nn_lock); if (ret) { - printk(KERN_NOTICE "o2net: Attempt to connect from node '%s' " - "at %pI4:%d but it already has an open connection\n", - node->nd_name, &sin.sin_addr.s_addr, - ntohs(sin.sin_port)); + if (local_node->nd_ipnet_type == IPV4_TYPE) + printk(KERN_NOTICE "o2net: Attempt to connect from node '%s' " + "at %pI4:%d but it already has an open connection\n", + node->nd_name, &sin.sin_addr.s_addr, + ntohs(sin.sin_port)); + else + printk(KERN_NOTICE "o2net: Attempt to connect from node '%s' " + "at %pI6:%d but it already has an open connection\n", + node->nd_name, sin6.sin6_addr.s6_addr, + ntohs(sin6.sin6_port)); goto out; } @@ -2022,17 +2087,30 @@ static void o2net_listen_data_ready(struct sock *sk) ready(sk); } -static int o2net_open_listening_sock(__be32 addr, __be16 port) +static int o2net_open_listening_sock(struct o2nm_node *node) { struct socket *sock = NULL; - int ret; - struct sockaddr_in sin = { - .sin_family = PF_INET, - .sin_addr = { .s_addr = addr }, - .sin_port = port, - }; + int ret, addr_len; + struct sockaddr *sa = NULL; + struct sockaddr_in sin; + struct sockaddr_in6 sin6; + unsigned short sa_family; + + if (node->nd_ipnet_type == IPV4_TYPE) { + sin.sin_family = sa_family = PF_INET; + sin.sin_addr.s_addr = node->nd_ipv4_address; + sin.sin_port = node->nd_ipv4_port; + sa = (struct sockaddr *)&sin; + addr_len = sizeof(sin); + } else { + sin6.sin6_family = sa_family = PF_INET6; + memcpy(&sin6.sin6_addr, node->nd_ipv6_address, sizeof(sin6.sin6_addr)); + sin6.sin6_port = node->nd_ipv6_port; + sa = (struct sockaddr *)&sin6; + addr_len = sizeof(sin6); + } - ret = sock_create(PF_INET, SOCK_STREAM, IPPROTO_TCP, &sock); + ret = sock_create(sa_family, SOCK_STREAM, IPPROTO_TCP, &sock); if (ret < 0) { printk(KERN_ERR "o2net: Error %d while creating socket\n", ret); goto out; @@ -2049,17 +2127,26 @@ static int o2net_open_listening_sock(__be32 addr, __be16 port) INIT_WORK(&o2net_listen_work, o2net_accept_many); sock->sk->sk_reuse = SK_CAN_REUSE; - ret = sock->ops->bind(sock, (struct sockaddr *)&sin, sizeof(sin)); + ret = sock->ops->bind(sock, sa, addr_len); if (ret < 0) { - printk(KERN_ERR "o2net: Error %d while binding socket at " - "%pI4:%u\n", ret, &addr, ntohs(port)); + if (node->nd_ipnet_type == IPV4_TYPE) + printk(KERN_ERR "o2net: Error %d while binding socket at " + "%pI4:%u\n", ret, &sin.sin_addr.s_addr, ntohs(sin.sin_port)); + else + printk(KERN_ERR "o2net: Error %d while binding socket at " + "%pI6:%u\n", ret, sin6.sin6_addr.s6_addr, ntohs(sin6.sin6_port)); goto out; } ret = sock->ops->listen(sock, 64); - if (ret < 0) - printk(KERN_ERR "o2net: Error %d while listening on %pI4:%u\n", - ret, &addr, ntohs(port)); + if (ret < 0) { + if (node->nd_ipnet_type == IPV4_TYPE) + printk(KERN_ERR "o2net: Error %d while listening on %pI4:%u\n", + ret, &sin.sin_addr.s_addr, ntohs(sin.sin_port)); + else + printk(KERN_ERR "o2net: Error %d while listening on %pI6:%u\n", + ret, sin6.sin6_addr.s6_addr, ntohs(sin6.sin6_port)); + } out: if (ret) { @@ -2091,8 +2178,7 @@ int o2net_start_listening(struct o2nm_node *node) return -ENOMEM; /* ? */ } - ret = o2net_open_listening_sock(node->nd_ipv4_address, - node->nd_ipv4_port); + ret = o2net_open_listening_sock(node); if (ret) { destroy_workqueue(o2net_wq); o2net_wq = NULL; From patchwork Thu Oct 25 10:35:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: piaojun X-Patchwork-Id: 10655701 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BF10C13B5 for ; Thu, 25 Oct 2018 10:36:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A9AFE2866D for ; Thu, 25 Oct 2018 10:36:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9A915286D4; Thu, 25 Oct 2018 10:36:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from userp2130.oracle.com (userp2130.oracle.com [156.151.31.86]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 00F342866D for ; Thu, 25 Oct 2018 10:36:09 +0000 (UTC) Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w9PAYOcV173827; Thu, 25 Oct 2018 10:36:02 GMT Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp2130.oracle.com with ESMTP id 2n7usugrtq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 25 Oct 2018 10:36:02 +0000 Received: from oss.oracle.com (oss-old-reserved.oracle.com [137.254.22.2]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w9PAa1fI005535 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 25 Oct 2018 10:36:01 GMT Received: from localhost ([127.0.0.1] helo=lb-oss.oracle.com) by oss.oracle.com with esmtp (Exim 4.63) (envelope-from ) id 1gFczh-0002IB-L9; Thu, 25 Oct 2018 03:36:01 -0700 Received: from aserv0021.oracle.com ([141.146.126.233]) by oss.oracle.com with esmtp (Exim 4.63) (envelope-from ) id 1gFczg-0002Hw-95 for ocfs2-devel@oss.oracle.com; Thu, 25 Oct 2018 03:36:00 -0700 Received: from userp2030.oracle.com (userp2030.oracle.com [156.151.31.89]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w9PAZxN1019967 (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 25 Oct 2018 10:36:00 GMT Received: from pps.filterd (userp2030.oracle.com [127.0.0.1]) by userp2030.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w9PAY5Cu009736 for ; Thu, 25 Oct 2018 10:35:59 GMT Received: from huawei.com (szxga06-in.huawei.com [45.249.212.32]) by userp2030.oracle.com with ESMTP id 2nbc61r1q7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Thu, 25 Oct 2018 10:35:59 +0000 Received: from DGGEMS402-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id CC8FD39A5341; Thu, 25 Oct 2018 18:35:53 +0800 (CST) Received: from [10.177.253.249] (10.177.253.249) by smtp.huawei.com (10.3.19.202) with Microsoft SMTP Server id 14.3.408.0; Thu, 25 Oct 2018 18:35:53 +0800 To: "akpm@linux-foundation.org" , "mark@fasheh.com" , Joel Becker , Junxiao Bi , Joseph Qi From: piaojun Message-ID: <5BD19C86.1090805@huawei.com> Date: Thu, 25 Oct 2018 18:35:50 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 X-Originating-IP: [10.177.253.249] X-CFilter-Loop: Reflected X-CLX-Shades: MLX X-CLX-Response: 1TFkXGRsYEQpMehcYGh8RCllNF2dmchEKWUkXGnEaEBp3BhgTGHESGR4QGnc GGBoGGhEKWV4XaG55EQpJRhdFWEtJRk91WlhFTl9JXkNFRBl1T0sRCkNOF3VHeV9dcGFvRUt8fG 59YkJNHn9wQHJ8Z21GemBOQWYYEQpYXBcfBBoEGx8bB0gaSBwTSUwfBRsaBBsaGgQeEgQfEBseG h8aEQpeWRd+aBpvWxEKTVwXGRgZEQpMWhdoaU1NXREKQ1oXHh8EGB4TBBgbGAQZGBEKQl4XGxEK RF4XHREKREkXGBEKQkYXYkR7Xn1NTH9sU2URCkJcFxoRCkJFF2ZcbHtwZGJ6EnxDEQpCThdsQkh ZUxpNZXh4HREKQkwXb0sZEhJEWXlbG18RCkJsF2MFQlJmQGJeWntSEQpCQBdgWV9ucnJlfWZ5XB EKQlgXYn1veQFPGBlwcHsRClpYFxgRCnBoF2Z+HlhBWwFpT2VrEBoRCnBoF2dgbW9FH29pBWdhE BoRCnBoF2hkQh5aQ2NgBW5yEBoRCnBoF2l9eU1EchJhXlhOEBoRCnBoF2UFTWBhSXlvYnBMEBoR CnBsF2FJeUN6c0l4Z2xiEB4SEQptfhcaEQpYTRdLESA= X-PDR: PASS X-Source-IP: 45.249.212.32 X-ServerName: szxga06-in.huawei.com X-Proofpoint-SPF-Result: pass X-Proofpoint-SPF-Record: v=spf1 ip4:45.249.212.32 ip4:45.249.212.35 ip4:119.145.14.93 ip4:58.251.152.93 ip4:194.213.3.17 ip4:206.16.17.72 ip4:45.249.212.255 ip4:45.249.212.187/29 ip4:45.249.212.191 ip4:185.176.76.210 ~all X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9056 signatures=668683 X-Proofpoint-DMARC-Record: none X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=205 malwarescore=0 suspectscore=2 phishscore=0 bulkscore=0 spamscore=0 clxscore=312 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810250095 X-Spam: Clean Cc: "ocfs2-devel@oss.oracle.com" Subject: [Ocfs2-devel] [PATCH 4/5] ocfs2/dlm: modify DLM_QUERY_NODEINFO message to adapt IPv6 node X-BeenThere: ocfs2-devel@oss.oracle.com X-Mailman-Version: 2.1.9 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: ocfs2-devel-bounces@oss.oracle.com Errors-To: ocfs2-devel-bounces@oss.oracle.com X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9056 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810250095 X-Virus-Scanned: ClamAV using ClamSMTP Add IPv6 node info to dlm_query_nodeinfo, and distinguish with IPv4 by qn_ipnet_type. DLM_QUERY_NODEINFO message is compitibile with the old version. Signed-off-by: Jun Piao --- fs/ocfs2/cluster/tcp.c | 6 ++-- fs/ocfs2/cluster/tcp.h | 2 +- fs/ocfs2/dlm/dlmcommon.h | 12 +++++-- fs/ocfs2/dlm/dlmdomain.c | 93 ++++++++++++++++++++++++++++++++++-------------- 4 files changed, 80 insertions(+), 33 deletions(-) diff --git a/fs/ocfs2/cluster/tcp.c b/fs/ocfs2/cluster/tcp.c index 82fa8da..31157a8 100644 --- a/fs/ocfs2/cluster/tcp.c +++ b/fs/ocfs2/cluster/tcp.c @@ -409,7 +409,7 @@ static void sc_kref_release(struct kref *kref) o2net_debug_del_sc(sc); if (sc->sc_page) - __free_page(sc->sc_page); + __free_pages(sc->sc_page, 1); kfree(sc); } @@ -429,7 +429,7 @@ static struct o2net_sock_container *sc_alloc(struct o2nm_node *node) struct page *page = NULL; int status = 0; - page = alloc_page(GFP_NOFS); + page = alloc_pages(GFP_NOFS, 1); sc = kzalloc(sizeof(*sc), GFP_NOFS); if (sc == NULL || page == NULL) goto out; @@ -462,7 +462,7 @@ static struct o2net_sock_container *sc_alloc(struct o2nm_node *node) out: if (page) - __free_page(page); + __free_pages(page, 1); kfree(sc); return ret; diff --git a/fs/ocfs2/cluster/tcp.h b/fs/ocfs2/cluster/tcp.h index c571e84..002b267 100644 --- a/fs/ocfs2/cluster/tcp.h +++ b/fs/ocfs2/cluster/tcp.h @@ -55,7 +55,7 @@ typedef int (o2net_msg_handler_func)(struct o2net_msg *msg, u32 len, void *data, typedef void (o2net_post_msg_handler_func)(int status, void *data, void *ret_data); -#define O2NET_MAX_PAYLOAD_BYTES (4096 - sizeof(struct o2net_msg)) +#define O2NET_MAX_PAYLOAD_BYTES (4096 * 2 - sizeof(struct o2net_msg)) /* same as hb delay, we're waiting for another node to recognize our hb */ #define O2NET_RECONNECT_DELAY_MS_DEFAULT 2000 diff --git a/fs/ocfs2/dlm/dlmcommon.h b/fs/ocfs2/dlm/dlmcommon.h index d06e27e..ba391ec 100644 --- a/fs/ocfs2/dlm/dlmcommon.h +++ b/fs/ocfs2/dlm/dlmcommon.h @@ -747,15 +747,21 @@ struct dlm_query_region { struct dlm_node_info { u8 ni_nodenum; u8 pad1; - __be16 ni_ipv4_port; - __be32 ni_ipv4_address; + union { + __be16 ni_ipv4_port; + __be16 ni_ipv6_port; + } ip_port; + union { + __be32 ni_ipv4_address; + u8 ni_ipv6_address[16]; + } ip_addr; }; struct dlm_query_nodeinfo { u8 qn_nodenum; u8 qn_numnodes; u8 qn_namelen; - u8 pad1; + u8 qn_ipnet_type; /* 0-IPv4, 1-IPv6 */ u8 qn_domain[O2NM_MAX_NAME_LEN]; struct dlm_node_info qn_nodes[O2NM_MAX_NODES]; }; diff --git a/fs/ocfs2/dlm/dlmdomain.c b/fs/ocfs2/dlm/dlmdomain.c index 2acd58b..49d60a9 100644 --- a/fs/ocfs2/dlm/dlmdomain.c +++ b/fs/ocfs2/dlm/dlmdomain.c @@ -1176,10 +1176,16 @@ static int dlm_match_nodes(struct dlm_ctxt *dlm, struct dlm_query_nodeinfo *qn) int i, j; int status = 0; - for (j = 0; j < qn->qn_numnodes; ++j) - mlog(0, "Node %3d, %pI4:%u\n", qn->qn_nodes[j].ni_nodenum, - &(qn->qn_nodes[j].ni_ipv4_address), - ntohs(qn->qn_nodes[j].ni_ipv4_port)); + if (qn->qn_ipnet_type == IPV4_TYPE) + for (j = 0; j < qn->qn_numnodes; ++j) + mlog(0, "Node %3d, %pI4:%u\n", qn->qn_nodes[j].ni_nodenum, + &(qn->qn_nodes[j].ip_addr.ni_ipv4_address), + ntohs(qn->qn_nodes[j].ip_port.ni_ipv4_port)); + else + for (j = 0; j < qn->qn_numnodes; ++j) + mlog(0, "Node %3d, %pI6:%u\n", qn->qn_nodes[j].ni_nodenum, + qn->qn_nodes[j].ip_addr.ni_ipv6_address, + ntohs(qn->qn_nodes[j].ip_port.ni_ipv6_port)); for (i = 0; i < O2NM_MAX_NODES && !status; ++i) { local = o2nm_get_node_by_num(i); @@ -1198,27 +1204,53 @@ static int dlm_match_nodes(struct dlm_ctxt *dlm, struct dlm_query_nodeinfo *qn) status = -EINVAL; if (!status && - ((remote->ni_nodenum != local->nd_num) || - (remote->ni_ipv4_port != local->nd_ipv4_port) || - (remote->ni_ipv4_address != local->nd_ipv4_address))) + (remote->ni_nodenum != local->nd_num)) + status = -EINVAL; + + if (!status && (local->nd_ipnet_type == IPV4_TYPE) && + ((remote->ip_port.ni_ipv4_port != local->nd_ipv4_port) || + (remote->ip_addr.ni_ipv4_address != local->nd_ipv4_address))) + status = -EINVAL; + else if (!status && (local->nd_ipnet_type == IPV6_TYPE) && + ((remote->ip_port.ni_ipv6_port != local->nd_ipv6_port) || + memcmp(remote->ip_addr.ni_ipv6_address, local->nd_ipv6_address, + sizeof(local->nd_ipv6_address)))) status = -EINVAL; if (status) { - if (remote && !local) - mlog(ML_ERROR, "Domain %s: Node %d (%pI4:%u) " - "registered in joining node %d but not in " - "local node %d\n", qn->qn_domain, - remote->ni_nodenum, - &(remote->ni_ipv4_address), - ntohs(remote->ni_ipv4_port), - qn->qn_nodenum, dlm->node_num); - if (local && !remote) - mlog(ML_ERROR, "Domain %s: Node %d (%pI4:%u) " - "registered in local node %d but not in " - "joining node %d\n", qn->qn_domain, - local->nd_num, &(local->nd_ipv4_address), - ntohs(local->nd_ipv4_port), - dlm->node_num, qn->qn_nodenum); + if (local->nd_ipnet_type == IPV4_TYPE) { + if (remote && !local) + mlog(ML_ERROR, "Domain %s: Node %d (%pI4:%u) " + "registered in joining node %d but not in " + "local node %d\n", qn->qn_domain, + remote->ni_nodenum, + &(remote->ip_addr.ni_ipv4_address), + ntohs(remote->ip_port.ni_ipv4_port), + qn->qn_nodenum, dlm->node_num); + if (local && !remote) + mlog(ML_ERROR, "Domain %s: Node %d (%pI4:%u) " + "registered in local node %d but not in " + "joining node %d\n", qn->qn_domain, + local->nd_num, &(local->nd_ipv4_address), + ntohs(local->nd_ipv4_port), + dlm->node_num, qn->qn_nodenum); + } else { + if (remote && !local) + mlog(ML_ERROR, "Domain %s: Node %d (%pI6:%u) " + "registered in joining node %d but not in " + "local node %d\n", qn->qn_domain, + remote->ni_nodenum, + remote->ip_addr.ni_ipv6_address, + ntohs(remote->ip_port.ni_ipv6_port), + qn->qn_nodenum, dlm->node_num); + if (local && !remote) + mlog(ML_ERROR, "Domain %s: Node %d (%pI6:%u) " + "registered in local node %d but not in " + "joining node %d\n", qn->qn_domain, + local->nd_num, local->nd_ipv6_address, + ntohs(local->nd_ipv6_port), + dlm->node_num, qn->qn_nodenum); + } BUG_ON((!local && !remote)); } @@ -1249,11 +1281,20 @@ static int dlm_send_nodeinfo(struct dlm_ctxt *dlm, unsigned long *node_map) node = o2nm_get_node_by_num(i); if (!node) continue; + qn->qn_ipnet_type = node->nd_ipnet_type; qn->qn_nodes[count].ni_nodenum = node->nd_num; - qn->qn_nodes[count].ni_ipv4_port = node->nd_ipv4_port; - qn->qn_nodes[count].ni_ipv4_address = node->nd_ipv4_address; - mlog(0, "Node %3d, %pI4:%u\n", node->nd_num, - &(node->nd_ipv4_address), ntohs(node->nd_ipv4_port)); + if (qn->qn_ipnet_type == IPV4_TYPE) { + qn->qn_nodes[count].ip_port.ni_ipv4_port = node->nd_ipv4_port; + qn->qn_nodes[count].ip_addr.ni_ipv4_address = node->nd_ipv4_address; + mlog(0, "Node %3d, %pI4:%u\n", node->nd_num, + &(node->nd_ipv4_address), ntohs(node->nd_ipv4_port)); + } else { + qn->qn_nodes[count].ip_port.ni_ipv6_port = node->nd_ipv6_port; + memcpy(qn->qn_nodes[count].ip_addr.ni_ipv6_address, + node->nd_ipv6_address, sizeof(node->nd_ipv6_address)); + mlog(0, "Node %3d, %pI6:%u\n", node->nd_num, + node->nd_ipv6_address, ntohs(node->nd_ipv6_port)); + } ++count; o2nm_node_put(node); } From patchwork Thu Oct 25 10:36:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: piaojun X-Patchwork-Id: 10655703 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A284714BB for ; Thu, 25 Oct 2018 10:36:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8BB3E27968 for ; Thu, 25 Oct 2018 10:36:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7F36D283C5; Thu, 25 Oct 2018 10:36:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from aserp2120.oracle.com (aserp2120.oracle.com [141.146.126.78]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C69EC27968 for ; Thu, 25 Oct 2018 10:36:56 +0000 (UTC) Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w9PAYOaK178953; Thu, 25 Oct 2018 10:36:49 GMT Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by aserp2120.oracle.com with ESMTP id 2n7vaq8q4u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 25 Oct 2018 10:36:49 +0000 Received: from oss.oracle.com (oss-old-reserved.oracle.com [137.254.22.2]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w9PAalwJ007381 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 25 Oct 2018 10:36:48 GMT Received: from localhost ([127.0.0.1] helo=lb-oss.oracle.com) by oss.oracle.com with esmtp (Exim 4.63) (envelope-from ) id 1gFd0R-0002KO-QD; Thu, 25 Oct 2018 03:36:47 -0700 Received: from userv0022.oracle.com ([156.151.31.74]) by oss.oracle.com with esmtp (Exim 4.63) (envelope-from ) id 1gFd0P-0002K8-1m for ocfs2-devel@oss.oracle.com; Thu, 25 Oct 2018 03:36:45 -0700 Received: from userp2030.oracle.com (userp2030.oracle.com [156.151.31.89]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w9PAaiJB010513 (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 25 Oct 2018 10:36:44 GMT Received: from pps.filterd (userp2030.oracle.com [127.0.0.1]) by userp2030.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w9PAYo2E010365 for ; Thu, 25 Oct 2018 10:36:44 GMT Received: from huawei.com (szxga06-in.huawei.com [45.249.212.32]) by userp2030.oracle.com with ESMTP id 2nbc61r257-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Thu, 25 Oct 2018 10:36:44 +0000 Received: from DGGEMS406-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 6FB1ECEA4DEFF; Thu, 25 Oct 2018 18:36:38 +0800 (CST) Received: from [10.177.253.249] (10.177.253.249) by smtp.huawei.com (10.3.19.206) with Microsoft SMTP Server id 14.3.408.0; Thu, 25 Oct 2018 18:36:36 +0800 To: "akpm@linux-foundation.org" , "mark@fasheh.com" , Joel Becker , Junxiao Bi , Joseph Qi From: piaojun Message-ID: <5BD19CB1.3070202@huawei.com> Date: Thu, 25 Oct 2018 18:36:33 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 X-Originating-IP: [10.177.253.249] X-CFilter-Loop: Reflected X-CLX-Shades: MLX X-CLX-Response: 1TFkXGRsYEQpMehcYGh8RCllNF2dmchEKWUkXGnEaEBp3BhgTGHESGR4QGnc GGBoGGhEKWV4XaG55EQpJRhdFWEtJRk91WlhFTl9JXkNFRBl1T0sRCkNOF1l5eBIaQHNzEmNNa3 xeG0FhYB1SREBFT2IHG2BoGBpSEQpYXBcfBBoEGx8bB0gaSBwTSUwfBRsaBBsaGgQeEgQfEBseG h8aEQpeWRd+aBpschEKTVwXGR4TEQpMWhdoaU1NXREKQ1oXHh8EGB4TBBgbGAQZGBEKQl4XGxEK RF4XHREKREkXGBEKQkYXYXBIb254fm1fRkURCkJcFxoRCkJFF2ZcbHtwZGJ6EnxDEQpCThdsQkh ZUxpNZXh4HREKQkwXb0sZEhJEWXlbG18RCkJsF2MFQlJmQGJeWntSEQpCQBd6HFxQGhx4SWhNbx EKQlgXYn1veQFPGBlwcHsRClpYFxgRCnBoF2tmE3h4Hn0SSVhNEBoRCnBoF2BYX0xeZk8BbGhzE BoRCnBoF2RPen5EclwafFNuEBoRCnBoF3pnX19pZR8ZeE5uEBoRCnBoF2dQXn4bE1hSE2cFEBoR CnBsF2FJeUN6c0l4Z2xiEB4SEQptfhcaEQpYTRdLESA= X-PDR: PASS X-Source-IP: 45.249.212.32 X-ServerName: szxga06-in.huawei.com X-Proofpoint-SPF-Result: pass X-Proofpoint-SPF-Record: v=spf1 ip4:45.249.212.32 ip4:45.249.212.35 ip4:119.145.14.93 ip4:58.251.152.93 ip4:194.213.3.17 ip4:206.16.17.72 ip4:45.249.212.255 ip4:45.249.212.187/29 ip4:45.249.212.191 ip4:185.176.76.210 ~all X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9056 signatures=668683 X-Proofpoint-DMARC-Record: none X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=205 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=312 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810250095 X-Spam: Clean Cc: "ocfs2-devel@oss.oracle.com" Subject: [Ocfs2-devel] [PATCH 5/5] ocfs2/cluster: modify socket container macro to adapt IPv6 X-BeenThere: ocfs2-devel@oss.oracle.com X-Mailman-Version: 2.1.9 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: ocfs2-devel-bounces@oss.oracle.com Errors-To: ocfs2-devel-bounces@oss.oracle.com X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9056 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810250095 X-Virus-Scanned: ClamAV using ClamSMTP SC_NODEF_FMT, SC_NODEF_ARGS, SC_PRE_NODEF_ARGS only support IPv4. Add SC_IPV6_NODEF_FMT, SC_IPV6_NODEF_ARGS, SC_IPV6_PRE_NODEF_ARGS to adapt IPV6 node's log. Signed-off-by: Jun Piao --- fs/ocfs2/cluster/tcp.c | 127 ++++++++++++++++++++++++++++++++++++------------- 1 file changed, 93 insertions(+), 34 deletions(-) diff --git a/fs/ocfs2/cluster/tcp.c b/fs/ocfs2/cluster/tcp.c index 31157a8..fcdfde7 100644 --- a/fs/ocfs2/cluster/tcp.c +++ b/fs/ocfs2/cluster/tcp.c @@ -79,6 +79,11 @@ &sc->sc_node->nd_ipv4_address, \ ntohs(sc->sc_node->nd_ipv4_port) +#define SC_IPV6_NODEF_FMT "node %s (num %u) at %pI6:%u" +#define SC_IPV6_NODEF_ARGS(sc) sc->sc_node->nd_name, sc->sc_node->nd_num, \ + sc->sc_node->nd_ipv6_address, \ + ntohs(sc->sc_node->nd_ipv6_port) + /* * In the following two log macros, the whitespace after the ',' just * before ##args is intentional. Otherwise, gcc 2.95 will eat the @@ -542,19 +547,30 @@ static void o2net_set_nn_state(struct o2net_node *nn, } if (was_valid && !valid) { - if (old_sc) - printk(KERN_NOTICE "o2net: No longer connected to " - SC_NODEF_FMT "\n", SC_NODEF_ARGS(old_sc)); + if (old_sc) { + if (old_sc->sc_node->nd_ipnet_type == IPV4_TYPE) + printk(KERN_NOTICE "o2net: No longer connected to " + SC_NODEF_FMT "\n", SC_NODEF_ARGS(old_sc)); + else + printk(KERN_NOTICE "o2net: No longer connected to " + SC_IPV6_NODEF_FMT "\n", SC_IPV6_NODEF_ARGS(old_sc)); + } o2net_complete_nodes_nsw(nn); } if (!was_valid && valid) { o2quo_conn_up(o2net_num_from_nn(nn)); cancel_delayed_work(&nn->nn_connect_expired); - printk(KERN_NOTICE "o2net: %s " SC_NODEF_FMT "\n", - o2nm_this_node() > sc->sc_node->nd_num ? - "Connected to" : "Accepted connection from", - SC_NODEF_ARGS(sc)); + if (sc->sc_node->nd_ipnet_type == IPV4_TYPE) + printk(KERN_NOTICE "o2net: %s " SC_NODEF_FMT "\n", + o2nm_this_node() > sc->sc_node->nd_num ? + "Connected to" : "Accepted connection from", + SC_NODEF_ARGS(sc)); + else + printk(KERN_NOTICE "o2net: %s " SC_IPV6_NODEF_FMT "\n", + o2nm_this_node() > sc->sc_node->nd_num ? + "Connected to" : "Accepted connection from", + SC_IPV6_NODEF_ARGS(sc)); } /* trigger the connecting worker func as long as we're not valid, @@ -642,9 +658,14 @@ static void o2net_state_change(struct sock *sk) o2net_sc_queue_work(sc, &sc->sc_connect_work); break; default: - printk(KERN_INFO "o2net: Connection to " SC_NODEF_FMT - " shutdown, state %d\n", - SC_NODEF_ARGS(sc), sk->sk_state); + if (sc->sc_node->nd_ipnet_type == IPV4_TYPE) + printk(KERN_INFO "o2net: Connection to " SC_NODEF_FMT + " shutdown, state %d\n", + SC_NODEF_ARGS(sc), sk->sk_state); + else + printk(KERN_INFO "o2net: Connection to " SC_IPV6_NODEF_FMT + " shutdown, state %d\n", + SC_IPV6_NODEF_ARGS(sc), sk->sk_state); o2net_sc_queue_work(sc, &sc->sc_shutdown_work); break; } @@ -961,13 +982,21 @@ static void o2net_sendpage(struct o2net_sock_container *sc, if (ret == size) break; if (ret == (ssize_t)-EAGAIN) { - mlog(0, "sendpage of size %zu to " SC_NODEF_FMT - " returned EAGAIN\n", size, SC_NODEF_ARGS(sc)); + if (sc->sc_node->nd_ipnet_type == IPV4_TYPE) + mlog(0, "sendpage of size %zu to " SC_NODEF_FMT + " returned EAGAIN\n", size, SC_NODEF_ARGS(sc)); + else + mlog(0, "sendpage of size %zu to " SC_IPV6_NODEF_FMT + " returned EAGAIN\n", size, SC_IPV6_NODEF_ARGS(sc)); cond_resched(); continue; } - mlog(ML_ERROR, "sendpage of size %zu to " SC_NODEF_FMT - " failed with %zd\n", size, SC_NODEF_ARGS(sc), ret); + if (sc->sc_node->nd_ipnet_type == IPV4_TYPE) + mlog(ML_ERROR, "sendpage of size %zu to " SC_NODEF_FMT + " failed with %zd\n", size, SC_NODEF_ARGS(sc), ret); + else + mlog(ML_ERROR, "sendpage of size %zu to " SC_IPV6_NODEF_FMT + " failed with %zd\n", size, SC_IPV6_NODEF_ARGS(sc), ret); o2net_ensure_shutdown(nn, sc, 0); break; } @@ -1275,11 +1304,18 @@ static int o2net_check_handshake(struct o2net_sock_container *sc) struct o2net_node *nn = o2net_nn_from_num(sc->sc_node->nd_num); if (hand->protocol_version != cpu_to_be64(O2NET_PROTOCOL_VERSION)) { - printk(KERN_NOTICE "o2net: " SC_NODEF_FMT " Advertised net " - "protocol version %llu but %llu is required. " - "Disconnecting.\n", SC_NODEF_ARGS(sc), - (unsigned long long)be64_to_cpu(hand->protocol_version), - O2NET_PROTOCOL_VERSION); + if (sc->sc_node->nd_ipnet_type == IPV4_TYPE) + printk(KERN_NOTICE "o2net: " SC_NODEF_FMT " Advertised net " + "protocol version %llu but %llu is required. " + "Disconnecting.\n", SC_NODEF_ARGS(sc), + (unsigned long long)be64_to_cpu(hand->protocol_version), + O2NET_PROTOCOL_VERSION); + else + printk(KERN_NOTICE "o2net: " SC_IPV6_NODEF_FMT " Advertised net " + "protocol version %llu but %llu is required. " + "Disconnecting.\n", SC_IPV6_NODEF_ARGS(sc), + (unsigned long long)be64_to_cpu(hand->protocol_version), + O2NET_PROTOCOL_VERSION); /* don't bother reconnecting if its the wrong version. */ o2net_ensure_shutdown(nn, sc, -ENOTCONN); @@ -1293,22 +1329,36 @@ static int o2net_check_handshake(struct o2net_sock_container *sc) */ if (be32_to_cpu(hand->o2net_idle_timeout_ms) != o2net_idle_timeout()) { - printk(KERN_NOTICE "o2net: " SC_NODEF_FMT " uses a network " - "idle timeout of %u ms, but we use %u ms locally. " - "Disconnecting.\n", SC_NODEF_ARGS(sc), - be32_to_cpu(hand->o2net_idle_timeout_ms), - o2net_idle_timeout()); + if (sc->sc_node->nd_ipnet_type == IPV4_TYPE) + printk(KERN_NOTICE "o2net: " SC_NODEF_FMT " uses a network " + "idle timeout of %u ms, but we use %u ms locally. " + "Disconnecting.\n", SC_NODEF_ARGS(sc), + be32_to_cpu(hand->o2net_idle_timeout_ms), + o2net_idle_timeout()); + else + printk(KERN_NOTICE "o2net: " SC_IPV6_NODEF_FMT " uses a network " + "idle timeout of %u ms, but we use %u ms locally. " + "Disconnecting.\n", SC_IPV6_NODEF_ARGS(sc), + be32_to_cpu(hand->o2net_idle_timeout_ms), + o2net_idle_timeout()); o2net_ensure_shutdown(nn, sc, -ENOTCONN); return -1; } if (be32_to_cpu(hand->o2net_keepalive_delay_ms) != o2net_keepalive_delay()) { - printk(KERN_NOTICE "o2net: " SC_NODEF_FMT " uses a keepalive " - "delay of %u ms, but we use %u ms locally. " - "Disconnecting.\n", SC_NODEF_ARGS(sc), - be32_to_cpu(hand->o2net_keepalive_delay_ms), - o2net_keepalive_delay()); + if (sc->sc_node->nd_ipnet_type == IPV4_TYPE) + printk(KERN_NOTICE "o2net: " SC_NODEF_FMT " uses a keepalive " + "delay of %u ms, but we use %u ms locally. " + "Disconnecting.\n", SC_NODEF_ARGS(sc), + be32_to_cpu(hand->o2net_keepalive_delay_ms), + o2net_keepalive_delay()); + else + printk(KERN_NOTICE "o2net: " SC_IPV6_NODEF_FMT " uses a keepalive " + "delay of %u ms, but we use %u ms locally. " + "Disconnecting.\n", SC_IPV6_NODEF_ARGS(sc), + be32_to_cpu(hand->o2net_keepalive_delay_ms), + o2net_keepalive_delay()); o2net_ensure_shutdown(nn, sc, -ENOTCONN); return -1; } @@ -1528,9 +1578,14 @@ static void o2net_idle_timer(struct timer_list *t) unsigned long msecs = o2net_idle_timeout(); #endif - printk(KERN_NOTICE "o2net: Connection to " SC_NODEF_FMT " has been " - "idle for %lu.%lu secs.\n", - SC_NODEF_ARGS(sc), msecs / 1000, msecs % 1000); + if (sc->sc_node->nd_ipnet_type == IPV4_TYPE) + printk(KERN_NOTICE "o2net: Connection to " SC_NODEF_FMT " has been " + "idle for %lu.%lu secs.\n", + SC_NODEF_ARGS(sc), msecs / 1000, msecs % 1000); + else + printk(KERN_NOTICE "o2net: Connection to " SC_IPV6_NODEF_FMT " has been " + "idle for %lu.%lu secs.\n", + SC_IPV6_NODEF_ARGS(sc), msecs / 1000, msecs % 1000); /* idle timerout happen, don't shutdown the connection, but * make fence decision. Maybe the connection can recover before @@ -1710,8 +1765,12 @@ static void o2net_start_connect(struct work_struct *work) out: if (ret && sc) { - printk(KERN_NOTICE "o2net: Connect attempt to " SC_NODEF_FMT - " failed with errno %d\n", SC_NODEF_ARGS(sc), ret); + if (sc->sc_node->nd_ipnet_type == IPV4_TYPE) + printk(KERN_NOTICE "o2net: Connect attempt to " SC_NODEF_FMT + " failed with errno %d\n", SC_NODEF_ARGS(sc), ret); + else + printk(KERN_NOTICE "o2net: Connect attempt to " SC_IPV6_NODEF_FMT + " failed with errno %d\n", SC_IPV6_NODEF_ARGS(sc), ret); /* 0 err so that another will be queued and attempted * from set_nn_state */ o2net_ensure_shutdown(nn, sc, 0);