From patchwork Tue Nov 10 02:34:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ihar Hrachyshka X-Patchwork-Id: 1397233 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.136; helo=silver.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=jREsSNal; dkim-atps=neutral Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CVX6N2hqTz9sRK for ; Tue, 10 Nov 2020 13:35:52 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 31C31203CC; Tue, 10 Nov 2020 02:35:50 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id kxW-RQnMRNTt; Tue, 10 Nov 2020 02:35:47 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by silver.osuosl.org (Postfix) with ESMTP id 936FD20355; Tue, 10 Nov 2020 02:35:47 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 6B99BC088B; Tue, 10 Nov 2020 02:35:47 +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 41D98C016F for ; Tue, 10 Nov 2020 02:35:46 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 27E3786771 for ; Tue, 10 Nov 2020 02:35:46 +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 yV5+dkdSH06C for ; Tue, 10 Nov 2020 02:35:44 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by whitealder.osuosl.org (Postfix) with ESMTPS id 6C5AA8676C for ; Tue, 10 Nov 2020 02:35:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604975743; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=AFHzTj/HDq8mlJ7ubAumhD2GqaSAfItZEMgqsnAFS0o=; b=jREsSNalql49OvHjkp9fx+tLsMhv4jMOeCQdksZ+EaDKTwWcTZafWE3sTJW8/B+EAikORG o42dMuBMBPTljrpOo6/dyjtVYpGKlqayjNWGyLdsuWt5GDCFaFyc66AeeU3ZERgEPO3c9w f/YDaTraA2Q4zFZWF++KumBjjEGtV5w= Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-9-uq8GCcYuNyGJzRj9AmNgVw-1; Mon, 09 Nov 2020 21:35:38 -0500 X-MC-Unique: uq8GCcYuNyGJzRj9AmNgVw-1 Received: by mail-qk1-f198.google.com with SMTP id x2so7559976qkd.23 for ; Mon, 09 Nov 2020 18:35:38 -0800 (PST) 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:mime-version :content-transfer-encoding; bh=AFHzTj/HDq8mlJ7ubAumhD2GqaSAfItZEMgqsnAFS0o=; b=aTvHqKiE9cmQzLZs1DBXxaymPh51+/QevwihGhlCn/i7bPvifiMmvQUnG58ET3PNmi J39MVE+ZBKNIk6XmswpFkaYxne68Jzub15HtqnQLkRNv1BSSEUCKaW/wACEwHCA1/tYp 1yHyXy2DmMrbX3EpEXFuAhxov3oJn7IJJL2ZnvXGpDvm7MPMQS7cM1KPtydaoXKbV2DT nZ5RwYOwjIyWN3zjCIbms6hmP+DCKSaqT2IgiAcGuZ/f44SbmDcuKPnE62cIDAUf8Yiy 4bFrbOdS60rGabfVudVYperf3wjO3go5BQFBA6yjWMtQ0wxpDck402wkLI1HYdITiEbn eqyQ== X-Gm-Message-State: AOAM5309dyNn9ooFCCSwh4FHpsZPyxOAKP5npXUmiAovuUxO9D4nQJRE XZQq9THlJV/L0C072wZbNUrsydQ8VgwE60YDj6Jmtru/T3p4kXdLVXU5pRARGBQ1dUEnESTTwji p88RVCfdZGfgeiU+0tnxbSkU0m4UWJ18h6K4bW9Yri2LSNwaXPSSq7GjQ8V3kmfDg X-Received: by 2002:a05:620a:c06:: with SMTP id l6mr1951047qki.334.1604975737478; Mon, 09 Nov 2020 18:35:37 -0800 (PST) X-Google-Smtp-Source: ABdhPJwnXB0B9Apdw2Np21q6HT2VBZm7/8z7FgFeFSsOuGWIVTJRvpv0d8rBhLpaTHTIGJs67wOboA== X-Received: by 2002:a05:620a:c06:: with SMTP id l6mr1951030qki.334.1604975737089; Mon, 09 Nov 2020 18:35:37 -0800 (PST) Received: from localhost.localdomain.com (cpe-172-73-180-250.carolina.res.rr.com. [172.73.180.250]) by smtp.googlemail.com with ESMTPSA id q15sm2722544qki.13.2020.11.09.18.35.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Nov 2020 18:35:35 -0800 (PST) From: Ihar Hrachyshka To: dev@openvswitch.org Date: Mon, 9 Nov 2020 21:34:49 -0500 Message-Id: <20201110023449.194642-1-ihrachys@redhat.com> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=ihrachys@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [ovs-dev] [PATCH ovn] Allow VLAN traffic when LS:vlan-passthru=true 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: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" A new other_config:vlan-passthru knob is added to Logical-Switches. When true, VLAN tagged incoming traffic is allowed. This option can be used to implement OpenStack Network VLAN transparency API extension [1]. [1] https://docs.openstack.org/api-ref/network/v2/index.html#vlan-transparency-extension Signed-off-by: Ihar Hrachyshka --- NEWS | 2 + northd/ovn-northd.c | 14 +++++-- ovn-nb.xml | 7 ++++ tests/ovn.at | 93 +++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 113 insertions(+), 3 deletions(-) diff --git a/NEWS b/NEWS index 47ffc27b8..601023067 100644 --- a/NEWS +++ b/NEWS @@ -6,6 +6,8 @@ Post-v20.09.0 removed. See ovn-nb(5) for advice on how to update your config if needed. - Add IPv4 iPXE support introducing "bootfile_name_alt" option to ovn dhcp server. + - Support other_config:vlan-passthru=true to allow VLAN tagged incoming + traffic. OVN v20.09.0 - 28 Sep 2020 -------------------------- diff --git a/northd/ovn-northd.c b/northd/ovn-northd.c index dbe5fa676..8f134a048 100644 --- a/northd/ovn-northd.c +++ b/northd/ovn-northd.c @@ -6803,6 +6803,12 @@ build_drop_arp_nd_flows_for_unbound_router_ports(struct ovn_port *op, ds_destroy(&match); } +static bool +is_vlan_transparent(const struct ovn_datapath *od) +{ + return smap_get_bool(&od->nbs->other_config, "vlan-passthru", false); +} + static void build_lswitch_flows(struct hmap *datapaths, struct hmap *ports, struct hmap *port_groups, struct hmap *lflows, @@ -6850,9 +6856,11 @@ build_lswitch_flows(struct hmap *datapaths, struct hmap *ports, continue; } - /* Logical VLANs not supported. */ - ovn_lflow_add(lflows, od, S_SWITCH_IN_PORT_SEC_L2, 100, "vlan.present", - "drop;"); + if (!is_vlan_transparent(od)) { + /* Block logical VLANs. */ + ovn_lflow_add(lflows, od, S_SWITCH_IN_PORT_SEC_L2, 100, + "vlan.present", "drop;"); + } /* Broadcast/multicast source address is invalid. */ ovn_lflow_add(lflows, od, S_SWITCH_IN_PORT_SEC_L2, 100, "eth.src[40]", diff --git a/ovn-nb.xml b/ovn-nb.xml index 5e8635992..5704eabea 100644 --- a/ovn-nb.xml +++ b/ovn-nb.xml @@ -525,6 +525,13 @@ + + + Determines whether VLAN tagged incoming traffic should be allowed. + + + See External IDs at the beginning of this document. diff --git a/tests/ovn.at b/tests/ovn.at index 1c29cdf26..3d3811888 100644 --- a/tests/ovn.at +++ b/tests/ovn.at @@ -2984,6 +2984,99 @@ OVN_CLEANUP([hv-1],[hv-2]) AT_CLEANUP +AT_SETUP([ovn -- VLAN transparency, passthru=true]) +ovn_start + +ovn-nbctl ls-add ls +ovn-nbctl --wait=sb add Logical-Switch ls other_config vlan-passthru=true +for i in 1 2; do + ovn-nbctl lsp-add ls lsp$i + ovn-nbctl lsp-set-addresses lsp$i f0:00:00:00:00:0$i + #ovn-nbctl lsp-set-port-security lsp$i f0:00:00:00:00:0$i +done + +net_add physnet +ovs-vsctl add-br br-phys +ovs-vsctl set open . external-ids:ovn-bridge-mappings=physnet:br-phys +ovn_attach physnet br-phys 192.168.0.1 + +for i in 1 2; do + ovs-vsctl add-port br-int vif$i -- set Interface vif$i external-ids:iface-id=lsp$i \ + options:tx_pcap=vif$i-tx.pcap \ + options:rxq_pcap=vif$i-rx.pcap \ + ofport-request=$i + OVS_WAIT_UNTIL([test x`ovn-nbctl lsp-get-up lsp$i` = xup]) +done + +test_packet() { + local inport=$1 dst=$2 src=$3 eth=$4 eout=$5 lout=$6 + + # First try tracing the packet. + uflow="inport==\"lsp$inport\" && eth.dst==$dst && eth.src==$src && eth.type==0x$eth && vlan.present==1" + echo "output(\"$lout\");" > expout + AT_CAPTURE_FILE([trace]) + AT_CHECK([ovn-trace --all ls "$uflow" | tee trace | sed '1,/Minimal trace/d'], [0], [expout]) + + # Then actually send a packet, for an end-to-end test. + local packet=$(echo $dst$src | sed 's/://g')${eth}fefefefe + vif=vif$inport + ovs-appctl netdev-dummy/receive $vif $packet + echo $packet >> ${eout#lsp}.expected +} + +test_packet 1 f0:00:00:00:00:02 f0:00:00:00:00:01 8100 lsp2 lsp2 +test_packet 2 f0:00:00:00:00:01 f0:00:00:00:00:02 8100 lsp1 lsp1 +for i in 1 2; do + OVN_CHECK_PACKETS_REMOVE_BROADCAST([vif$i-tx.pcap], [$i.expected]) +done + +AT_CLEANUP + +AT_SETUP([ovn -- VLAN transparency, passthru=false]) +ovn_start + +ovn-nbctl ls-add ls +ovn-nbctl --wait=sb add Logical-Switch ls other_config vlan-passthru=false +for i in 1 2; do + ovn-nbctl lsp-add ls lsp$i + ovn-nbctl lsp-set-addresses lsp$i f0:00:00:00:00:0$i +done + +net_add physnet +ovs-vsctl add-br br-phys +ovs-vsctl set open . external-ids:ovn-bridge-mappings=physnet:br-phys +ovn_attach physnet br-phys 192.168.0.1 + +for i in 1 2; do + ovs-vsctl add-port br-int vif$i -- set Interface vif$i external-ids:iface-id=lsp$i \ + options:tx_pcap=vif$i-tx.pcap \ + options:rxq_pcap=vif$i-rx.pcap \ + ofport-request=$i + OVS_WAIT_UNTIL([test x`ovn-nbctl lsp-get-up lsp$i` = xup]) + + : > $i.expected +done + +test_packet() { + local inport=$1 dst=$2 src=$3 eth=$4 eout=$5 lout=$6 + + # First try tracing the packet. + uflow="inport==\"lsp$inport\" && eth.dst==$dst && eth.src==$src && eth.type==0x$eth && vlan.present==1" + AT_CHECK([ovn-trace --all ls "$uflow" | grep drop], [0], [ignore]) + + # Then actually send a packet, for an end-to-end test. + local packet=$(echo $dst$src | sed 's/://g')${eth}fefefefe + ovs-appctl netdev-dummy/receive vif$inport $packet +} + +test_packet 1 f0:00:00:00:00:02 f0:00:00:00:00:01 8100 lsp2 lsp2 +test_packet 2 f0:00:00:00:00:01 f0:00:00:00:00:02 8100 lsp1 lsp1 +for i in 1 2; do + OVN_CHECK_PACKETS_REMOVE_BROADCAST([vif$i-tx.pcap], [$i.expected]) +done + +AT_CLEANUP + AT_SETUP([ovn -- 2 HVs, 1 LS, no switching between multiple localnet ports with different tags]) ovn_start