From patchwork Wed Jun 24 20:58:23 2020
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Yifeng Sun
X-Patchwork-Id: 1316581
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=fail (p=none dis=none) header.from=gmail.com
Authentication-Results: ozlabs.org;
dkim=fail reason="signature verification failed" (2048-bit key;
unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256
header.s=20161025 header.b=kM+F0uQ/;
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 49sb8n5VrSz9sTN
for ; Thu, 25 Jun 2020 06:58:33 +1000 (AEST)
Received: from localhost (localhost [127.0.0.1])
by fraxinus.osuosl.org (Postfix) with ESMTP id 4502C86C5E;
Wed, 24 Jun 2020 20:58:32 +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 amH1ZdFp6gsu; Wed, 24 Jun 2020 20:58:31 +0000 (UTC)
Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56])
by fraxinus.osuosl.org (Postfix) with ESMTP id AABCF86B11;
Wed, 24 Jun 2020 20:58:31 +0000 (UTC)
Received: from lf-lists.osuosl.org (localhost [127.0.0.1])
by lists.linuxfoundation.org (Postfix) with ESMTP id 789D8C0888;
Wed, 24 Jun 2020 20:58:31 +0000 (UTC)
X-Original-To: dev@openvswitch.org
Delivered-To: ovs-dev@lists.linuxfoundation.org
Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137])
by lists.linuxfoundation.org (Postfix) with ESMTP id 7F40FC016F
for ; Wed, 24 Jun 2020 20:58:30 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
by fraxinus.osuosl.org (Postfix) with ESMTP id 77E9686C23
for ; Wed, 24 Jun 2020 20:58:30 +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 tesrnUD57AFx for ;
Wed, 24 Jun 2020 20:58:30 +0000 (UTC)
X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6
Received: from mail-pg1-f195.google.com (mail-pg1-f195.google.com
[209.85.215.195])
by fraxinus.osuosl.org (Postfix) with ESMTPS id F290086B11
for ; Wed, 24 Jun 2020 20:58:29 +0000 (UTC)
Received: by mail-pg1-f195.google.com with SMTP id z5so2034404pgb.6
for ; Wed, 24 Jun 2020 13:58:29 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
h=from:to:cc:subject:date:message-id;
bh=zclUiqCkALs3GfUp7FQgXo1QEFmoRapCA243tGaNVEA=;
b=kM+F0uQ/YB9q6KvRpkfISt62io6aW+wDqevJnXhpkoni85GdCMQ8ww3HxFX23Vidpz
GucgmGohmVwb5+QFsphpLY2/bezCnu5kelw36lhf26wXQ64rxks9sBqHMhq/gTM8NHVc
jYhQzbS4Ug1gDBoi/oQqDJEfEFiNKZ+YhlVy/8P556sLW8FTctuqJUOT8VciqJqcF5Ci
4iiiavHjV/4J1AJHFM7okRKp8uhUh8s2xYiXqcmvEk47HbZ3cF4CRiCcM4u1cgpzhSe0
iL5IY3oAdCQUq6/eGIv6yWVE7sKlxhMveLXDfstRcUrqbX0TPAtXxaspbJQagffW/kTD
Dh/w==
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=zclUiqCkALs3GfUp7FQgXo1QEFmoRapCA243tGaNVEA=;
b=fK87sNhkEh3oh7nZBIELBnqfheKrd7kdTbMzrEokbJHChdnRmR5oVNqb1+HLY1r+Ic
JKrNwrUgE/Z+vWiwhN3keAUvL2d1w1Ka4XLowld/c196rLddBTVsPNwcqP49hl8FjBMN
7oNrTArU0VkS9gTZzD6mGwRtUZ8cNmsEEPK3r0KVnkZaUcnHjNEUGZFzfVkN2qHC54lj
fU/fZ1IlnFSVLZzcYW7TCvjiJVzLJLIADGPfAHCQgxpzPe/CyQu0hTBVjvlqAkznun/N
yowRe+ydrJwFVUyAEQHvow92kbL1AJJgxEpk0XTGqwH568y9/s9bJR6NTkPhhthcTxfe
wgyQ==
X-Gm-Message-State: AOAM5331wDqC0yRHogDFgoKMboKFdD+B3iYB0dSrH+5RtvrBVtCA2U+6
g0fkhFW90JTui2WV8GhvrdQH94HRZlA=
X-Google-Smtp-Source:
ABdhPJxheqJRoV/UgzdDjwjX3l+cEPxs8D9SDqOwM4eAsbqaYfkVRkFmYiLyLfpkyWrx6PuutH6pLA==
X-Received: by 2002:a62:ed02:: with SMTP id u2mr30622016pfh.283.1593032309291;
Wed, 24 Jun 2020 13:58:29 -0700 (PDT)
Received: from kern417.eng.vmware.com ([66.170.99.1])
by smtp.gmail.com with ESMTPSA id l63sm21258189pfd.122.2020.06.24.13.58.28
(version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128);
Wed, 24 Jun 2020 13:58:28 -0700 (PDT)
From: Yifeng Sun
To: dev@openvswitch.org
Date: Wed, 24 Jun 2020 13:58:23 -0700
Message-Id: <1593032303-26749-1-git-send-email-pkusunyifeng@gmail.com>
X-Mailer: git-send-email 2.7.4
Subject: [ovs-dev] [PATCH] bfd: Support overlay BFD
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: ,
MIME-Version: 1.0
Errors-To: ovs-dev-bounces@openvswitch.org
Sender: "dev"
Current OVS intercepts and processes all BFD packets, thus VM-2-VM
BFD packets get lost and the recipient VM never sees them.
This patch fixes it by only intercepting and processing BFD packets
destined to a configured BFD instance, and other BFD packets are made
available to the OVS flow table for forwarding.
This patch keeps BFD's backward compatibility.
Signed-off-by: Yifeng Sun
---
lib/bfd.c | 16 +++++++++++++---
vswitchd/vswitch.xml | 7 +++++++
2 files changed, 20 insertions(+), 3 deletions(-)
diff --git a/lib/bfd.c b/lib/bfd.c
index cc8c6857afa4..3c965699ace3 100644
--- a/lib/bfd.c
+++ b/lib/bfd.c
@@ -149,6 +149,9 @@ BUILD_ASSERT_DECL(BFD_PACKET_LEN == sizeof(struct msg));
#define FLAGS_MASK 0x3f
#define DEFAULT_MULT 3
+#define BFD_DEFAULT_SRC_IP 0xA9FE0101 /* 169.254.1.1 */
+#define BFD_DEFAULT_DST_IP 0xA9FE0100 /* 169.254.1.0 */
+
struct bfd {
struct hmap_node node; /* In 'all_bfds'. */
uint32_t disc; /* bfd.LocalDiscr. Key in 'all_bfds' hmap. */
@@ -457,9 +460,9 @@ bfd_configure(struct bfd *bfd, const char *name, const struct smap *cfg,
&bfd->rmt_eth_dst);
bfd_lookup_ip(smap_get_def(cfg, "bfd_src_ip", ""),
- htonl(0xA9FE0101) /* 169.254.1.1 */, &bfd->ip_src);
+ htonl(BFD_DEFAULT_SRC_IP), &bfd->ip_src);
bfd_lookup_ip(smap_get_def(cfg, "bfd_dst_ip", ""),
- htonl(0xA9FE0100) /* 169.254.1.0 */, &bfd->ip_dst);
+ htonl(BFD_DEFAULT_DST_IP), &bfd->ip_dst);
forwarding_if_rx = smap_get_bool(cfg, "forwarding_if_rx", false);
if (bfd->forwarding_if_rx != forwarding_if_rx) {
@@ -674,7 +677,14 @@ bfd_should_process_flow(const struct bfd *bfd_, const struct flow *flow,
memset(&wc->masks.nw_proto, 0xff, sizeof wc->masks.nw_proto);
if (flow->nw_proto == IPPROTO_UDP
&& !(flow->nw_frag & FLOW_NW_FRAG_LATER)
- && tp_dst_equals(flow, BFD_DEST_PORT, wc)) {
+ && tp_dst_equals(flow, BFD_DEST_PORT, wc)
+ && (bfd->ip_src == htonl(BFD_DEFAULT_SRC_IP)
+ || bfd->ip_src == flow->nw_dst)) {
+
+ if (bfd->ip_src == flow->nw_dst) {
+ memset(&wc->masks.nw_dst, 0xffffffff, sizeof wc->masks.nw_dst);
+ }
+
bool check_tnl_key;
atomic_read_relaxed(&bfd->check_tnl_key, &check_tnl_key);
diff --git a/vswitchd/vswitch.xml b/vswitchd/vswitch.xml
index b6acb34ca1b8..e1f895134ff2 100644
--- a/vswitchd/vswitch.xml
+++ b/vswitchd/vswitch.xml
@@ -3662,6 +3662,13 @@ ovs-vsctl add-port br0 p0 -- set Interface p0 type=patch options:peer=p1 \
optional Authentication or ``Echo Mode'' features.
+
+ OVS 2.13 and earlier intercepted and processed all BFD packets.
+ OVS 2.14 and later only intercept and process BFD packets destined
+ to a configured BFD instance, and other BFD packets are made available
+ to the OVS flow table for forwarding.
+
+
A controller sets up key-value pairs in the