From patchwork Thu Mar 29 02:33:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: lidejun1@huawei.com X-Patchwork-Id: 892549 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=huawei.com Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40BTNt6g5Hz9ryk for ; Thu, 29 Mar 2018 13:34:54 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 4A36DCBF; Thu, 29 Mar 2018 02:34:51 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 2FB11CBD for ; Thu, 29 Mar 2018 02:34:50 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from huawei.com (unknown [45.249.212.35]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id E9DC25E2 for ; Thu, 29 Mar 2018 02:34:48 +0000 (UTC) Received: from DGGEMS414-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 1CA1227D66A35 for ; Thu, 29 Mar 2018 10:34:45 +0800 (CST) Received: from localhost (10.175.104.206) by DGGEMS414-HUB.china.huawei.com (10.3.19.214) with Microsoft SMTP Server id 14.3.361.1; Thu, 29 Mar 2018 10:34:35 +0800 From: To: Date: Thu, 29 Mar 2018 10:33:56 +0800 Message-ID: <1522290836-52146-1-git-send-email-lidejun1@huawei.com> X-Mailer: git-send-email 1.8.3.1 MIME-Version: 1.0 X-Originating-IP: [10.175.104.206] X-CFilter-Loop: Reflected X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, T_RP_MATCHES_RCVD autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Cc: l00397770 Subject: [ovs-dev] [PATCH] bridge: fix crash when more than 32767 ports added X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org From: l00397770 When creating a port using ovs-vsctl, its Openflow port number is automatically assigned, and the max value is 32767. After adding 32767 ports, subsequent ports' number are all 65535, and they are all inserted into a bridge's ifaces hmap, but when these ports are deleted, their hamp_nodes are not removed by iface_destroy__, this can cause ovs crash in the following call path: bridge_reconfigure ---> bridge_add_ports ---> bridge_add_ports__ ---> iface_create ---> hmap_insert_at ---> hmap_expand_at ---> resize ---> hmap_insert_fast, the bridge's ifaces hmap bucket is corrupted. To fix the above issue, we check Openflow port number in iface_do_create: if the port number is 65535, report an error and do not add this port into a bridge. Signed-off-by: lidejun1@huawei.com Acked-By: jerry.lilijun@huawei.com --- vswitchd/bridge.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c index d90997e..6f6314c 100644 --- a/vswitchd/bridge.c +++ b/vswitchd/bridge.c @@ -1802,6 +1802,11 @@ iface_do_create(const struct bridge *br, iface_cfg->name, ovs_strerror(error)); goto error; } + if (*ofp_portp == OFPP_NONE) { + VLOG_WARN("could not add network device %s to ofproto", iface_cfg->name); + error = ERANGE; + goto error; + } VLOG_INFO("bridge %s: added interface %s on port %d", br->name, iface_cfg->name, *ofp_portp);