From patchwork Mon Jan 13 03:56:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Li,Rongqing via dev" X-Patchwork-Id: 1221926 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.137; helo=fraxinus.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=openvswitch.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ericsson.com header.i=@ericsson.com header.a=rsa-sha256 header.s=selector1 header.b=ZL3t6HW5; dkim-atps=neutral Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47x0mY64Bvz9sP6 for ; Mon, 13 Jan 2020 15:22:19 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 198C785625; Mon, 13 Jan 2020 04:22:17 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Vk1KP7bipKrS; Mon, 13 Jan 2020 04:22:16 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by fraxinus.osuosl.org (Postfix) with ESMTP id 1CF04854E7; Mon, 13 Jan 2020 04:22:16 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id DD026C18DD; Mon, 13 Jan 2020 04:22:15 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by lists.linuxfoundation.org (Postfix) with ESMTP id 1E4C3C077D for ; Mon, 13 Jan 2020 04:22:15 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 023F084483 for ; Mon, 13 Jan 2020 04:22:15 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Q7w2PhdkTLwR for ; Mon, 13 Jan 2020 04:22:13 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-eopbgr70041.outbound.protection.outlook.com [40.107.7.41]) by whitealder.osuosl.org (Postfix) with ESMTPS id 62B0584016 for ; Mon, 13 Jan 2020 04:22:13 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cii1XEZTQUytaRUOJLQJ9kYcrcrexmbV49TYqN2uTISeh8eODt+COBH4JKFXO/xk/v8qBo02wIyqjWqY9P1zH7oC7VIyVEbE4X/5A1S8aOL5wBJ5bWn7I6KxcGg7bbqA9GKDlAmkLTK30umVH5NuECmA+BxEtkGr274EkZTSoKP6fezjcMmTmjxVm3f8kV5EUqrLDYnpYjmxpKm6v5bUy4oh1JjKphUzKZob0HNVQ01v/368IN8yLdfbpMXpvg4BiMAVmilbWGlMmw9jlYTnDWuytlDXxmQPSilYVZtrjKtyZ7BNU7waQ2zNdlWz3GFzYS48gDNqGVLt8sJ8cXD6Yg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=96Ip3PtiZpVEg/HgjSSXUAqPE/oIVi+XmqP1AE4Umfc=; b=HDNcvCl05jY0p2TKqZ5c5EwQnB38EklKHoa1jRNyeQOynugML9bDDf+mcuFdbA7HFAuyvnsItrdGG91xmQTw82CirghideLvm3Vw2lO+8dO9nYMW6PY5/gbLzqqR1ZG6sAsfB7w1ozdrha7SnIJUtPjy6NCavzCUP9Z2y8heyAAs+kEaNei8VpKo4GAwId3cd9j6rOQQ27V+KKPgWRNLA2/42efG9R6W3KgLPVIj3ntxJrbihnFLQLfyBu1vH7UCjZ02OFDEFflsL4dmrBQkWxNH7K23OGcm4m7XaxnlmpYoTG5pgT3gk/OCyMH5EIJWoUQ4fBGlo1eufz2ry7mmSQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 192.176.1.74) smtp.rcpttodomain=openvswitch.org smtp.mailfrom=ericsson.com; dmarc=pass (p=reject sp=none pct=100) action=none header.from=ericsson.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ericsson.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=96Ip3PtiZpVEg/HgjSSXUAqPE/oIVi+XmqP1AE4Umfc=; b=ZL3t6HW5SqwMiETzGcUaFP0GW2Zym62DLVhZpD4974mDheFhy6isysd/JoSvOVin9tK4sUm7UO8zG59wb9T0IZNSDDHTqfzwz3bhPR0GTOTOeXdFP8njuZ/N19FlZB7/kGoSNmFLFPQfwEzA+cSinBiwkX3Bof20okj92NWkMps= Received: from HE1PR07CA0005.eurprd07.prod.outlook.com (2603:10a6:7:67::15) by VI1PR07MB3360.eurprd07.prod.outlook.com (2603:10a6:802:1c::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2644.10; Mon, 13 Jan 2020 04:06:17 +0000 Received: from HE1EUR02FT021.eop-EUR02.prod.protection.outlook.com (2a01:111:f400:7e05::207) by HE1PR07CA0005.outlook.office365.com (2603:10a6:7:67::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2644.6 via Frontend Transport; Mon, 13 Jan 2020 04:06:17 +0000 Authentication-Results: spf=pass (sender IP is 192.176.1.74) smtp.mailfrom=ericsson.com; openvswitch.org; dkim=none (message not signed) header.d=none;openvswitch.org; dmarc=pass action=none header.from=ericsson.com; Received-SPF: Pass (protection.outlook.com: domain of ericsson.com designates 192.176.1.74 as permitted sender) receiver=protection.outlook.com; client-ip=192.176.1.74; helo=oa.msg.ericsson.com; Received: from oa.msg.ericsson.com (192.176.1.74) by HE1EUR02FT021.mail.protection.outlook.com (10.152.10.85) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.20.2623.9 via Frontend Transport; Mon, 13 Jan 2020 04:06:16 +0000 Received: from ESESSMB501.ericsson.se (153.88.183.162) by ESESBMR504.ericsson.se (153.88.183.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5; Mon, 13 Jan 2020 05:06:16 +0100 Received: from localhost.localdomain (153.88.183.153) by ESESSMB501.ericsson.se (153.88.183.162) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5; Mon, 13 Jan 2020 05:06:15 +0100 To: Date: Mon, 13 Jan 2020 09:26:49 +0530 Message-ID: <1578887809-29492-1-git-send-email-vishal.deep.ajmera@ericsson.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 X-Originating-IP: [153.88.183.153] X-ClientProxiedBy: ESESSMB501.ericsson.se (153.88.183.162) To ESESSMB501.ericsson.se (153.88.183.162) X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:192.176.1.74; IPV:; CTRY:SE; EFV:NLI; SFV:NSPM; SFS:(10009020)(4636009)(376002)(346002)(39860400002)(136003)(396003)(189003)(199004)(2906002)(956004)(8936002)(2616005)(70206006)(26005)(356004)(4326008)(36756003)(54906003)(7636002)(107886003)(8676002)(186003)(316002)(478600001)(16526019)(6916009)(86362001)(336012)(6666004)(70586007)(5660300002)(246002); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR07MB3360; H:oa.msg.ericsson.com; FPR:; SPF:Pass; LANG:en; PTR:office365.se.ericsson.net; MX:1; A:1; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1c9d7210-e61d-4ff9-1789-08d797ddf00e X-MS-TrafficTypeDiagnostic: VI1PR07MB3360: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1751; X-Forefront-PRVS: 028166BF91 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: eodVGMUEZG96Ob0f/ppGC2YP2sVgyaNElxGybAwc2Ntjq2IIBOba4ZwVDqrTea1xqkaUMiydDd4EYbeKogZg2sJQbGeuKvA5DWPlDvqCF1CBptZJx+7sYhtb9HgFGlBPxiIAnpo8wHlLLp8hb2/h0LiEtVOBS1InzMiU29i8F9Sb6VBylIbv5iT19dj8VC2lQW7vGMcwKaCkMeOqj2zWajp2ECt9nipTHoRQEkHM8Rdg2PhTu1/OGjYgqu1Jo7BCdmzcKYra/U7tO/oz5snlpZEdHVOj9PwPau4NyV1dDC+hebQJs/lGM1JwZihLAQRxevMeYCJbum9Ofo0JUA+d9GThbaz+TCRbDSpuUVo35Y9ybVLk+G289fMZvoVa3buRqz3mTc6rEFE9Ee+mlfyxnET9LXpWAsTqpEZ2pQ6l0NQhlaQMEgQHmz0BgMAm18Cq X-OriginatorOrg: ericsson.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jan 2020 04:06:16.6916 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1c9d7210-e61d-4ff9-1789-08d797ddf00e X-MS-Exchange-CrossTenant-Id: 92e84ceb-fbfd-47ab-be52-080c6b87953f X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=92e84ceb-fbfd-47ab-be52-080c6b87953f; Ip=[192.176.1.74]; Helo=[oa.msg.ericsson.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR07MB3360 Subject: [ovs-dev] [PATCH] ofproto: Add support to watch controller port liveness in fast-failover group X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Vishal Deep Ajmera via dev From: "Li,Rongqing via dev" Reply-To: Vishal Deep Ajmera Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" Currently fast-failover group does not support checking liveness of controller port (OFPP_CONTROLLER). However this feature can be useful for selecting alternate pipeline when controller connection itself is down for e.g. by using local DHCP server to reply for any DHCP request originating from VMs. This patch adds the support for watching controller port liveness in fast- failover group. Controller port is considered live when atleast one of-connection is alive. Example usage: ovs-ofctl add-group br-int 'group_id=1234,type=ff, bucket=watch_port:CONTROLLER,actions:, bucket=watch_port:1,actions: Signed-off-by: Vishal Deep Ajmera --- lib/ofp-group.c | 3 ++- ofproto/ofproto-dpif-xlate.c | 5 ++++- ofproto/ofproto-dpif.c | 10 ++++++++++ ofproto/ofproto-dpif.h | 3 +++ ofproto/ofproto.c | 3 ++- 5 files changed, 21 insertions(+), 3 deletions(-) diff --git a/lib/ofp-group.c b/lib/ofp-group.c index b675e80..bf0f8af 100644 --- a/lib/ofp-group.c +++ b/lib/ofp-group.c @@ -660,7 +660,8 @@ parse_bucket_str(struct ofputil_bucket *bucket, char *str_, } else if (!strcasecmp(key, "watch_port")) { if (!ofputil_port_from_string(value, port_map, &bucket->watch_port) || (ofp_to_u16(bucket->watch_port) >= ofp_to_u16(OFPP_MAX) - && bucket->watch_port != OFPP_ANY)) { + && bucket->watch_port != OFPP_ANY + && bucket->watch_port != OFPP_CONTROLLER)) { error = xasprintf("%s: invalid watch_port", value); } } else if (!strcasecmp(key, "watch_group")) { diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c index 4407f9c..461e8aa 100644 --- a/ofproto/ofproto-dpif-xlate.c +++ b/ofproto/ofproto-dpif-xlate.c @@ -1884,9 +1884,12 @@ bucket_is_alive(const struct xlate_ctx *ctx, return (!ofputil_bucket_has_liveness(bucket) || (bucket->watch_port != OFPP_ANY + && bucket->watch_port != OFPP_CONTROLLER && odp_port_is_alive(ctx, bucket->watch_port)) || (bucket->watch_group != OFPG_ANY - && group_is_alive(ctx, bucket->watch_group, depth + 1))); + && group_is_alive(ctx, bucket->watch_group, depth + 1)) + || (bucket->watch_port == OFPP_CONTROLLER + && ofproto_is_alive(&ctx->xbridge->ofproto->up))); } static void diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c index d3cb392..818a077 100644 --- a/ofproto/ofproto-dpif.c +++ b/ofproto/ofproto-dpif.c @@ -1802,6 +1802,7 @@ run(struct ofproto *ofproto_) { struct ofproto_dpif *ofproto = ofproto_dpif_cast(ofproto_); uint64_t new_seq, new_dump_seq; + bool is_connected; if (mbridge_need_revalidate(ofproto->mbridge)) { ofproto->backer->need_revalidate = REV_RECONFIGURE; @@ -1870,6 +1871,15 @@ run(struct ofproto *ofproto_) ofproto->backer->need_revalidate = REV_MCAST_SNOOPING; } + /* Check if controller connection is toggled. */ + is_connected = ofproto_is_alive(&ofproto->up); + if (ofproto->is_controller_connected != is_connected) { + ofproto->is_controller_connected = is_connected; + /* Trigger revalidation as fast failover group monitoring + * controller port may need to check liveness again. */ + ofproto->backer->need_revalidate = REV_RECONFIGURE; + } + new_dump_seq = seq_read(udpif_dump_seq(ofproto->backer->udpif)); if (ofproto->dump_seq != new_dump_seq) { struct rule *rule, *next_rule; diff --git a/ofproto/ofproto-dpif.h b/ofproto/ofproto-dpif.h index c9d5df3..aee61d6 100644 --- a/ofproto/ofproto-dpif.h +++ b/ofproto/ofproto-dpif.h @@ -342,6 +342,9 @@ struct ofproto_dpif { struct guarded_list ams; /* Contains "struct ofproto_async_msgs"s. */ struct seq *ams_seq; /* For notifying 'ams' reception. */ uint64_t ams_seqno; + + bool is_controller_connected; /* True if any controller admitted this + * switch connection. */ }; struct ofproto_dpif *ofproto_dpif_lookup_by_name(const char *name); diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c index 08830d8..a155fad 100644 --- a/ofproto/ofproto.c +++ b/ofproto/ofproto.c @@ -1899,7 +1899,8 @@ ofproto_wait(struct ofproto *p) bool ofproto_is_alive(const struct ofproto *p) { - return connmgr_has_controllers(p->connmgr); + return (connmgr_has_controllers(p->connmgr) + && connmgr_is_any_controller_admitted(p->connmgr)); } /* Adds some memory usage statistics for 'ofproto' into 'usage', for use with