From patchwork Fri Mar 10 07:46:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gurucharan Shetty X-Patchwork-Id: 737507 X-Patchwork-Delegate: blp@nicira.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 3vfw9H1JM7z9s7n for ; Sat, 11 Mar 2017 05:03:15 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 3878F982; Fri, 10 Mar 2017 18:02:46 +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 EF9EA941 for ; Fri, 10 Mar 2017 18:02:44 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-pg0-f68.google.com (mail-pg0-f68.google.com [74.125.83.68]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id C827316F for ; Fri, 10 Mar 2017 18:02:43 +0000 (UTC) Received: by mail-pg0-f68.google.com with SMTP id 77so10993484pgc.0 for ; Fri, 10 Mar 2017 10:02:43 -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:subject:date:message-id:in-reply-to :references; bh=WJdm+PAhtLYbDAtbcx76qB2WhlljTEveFNqAvbTgEls=; b=p7rdSg0EKX0r4eguPyn8y2NDJk5CCqgPbTtvdFr6LZ61hAx81S5c2HUempbh2NXddI Jehwp1sct/fxUHkBe2YRgLKRxBEmzn0XPUiaj9yk6yPwt6oQGwzV1p5iDoZoEUEFdTQe WiNa2Yn02LhUOjLc29ttNnxGSjkeFvjgdyqV4aogu5p6fxtATPimW13E028fkEeOEYk1 c6D+ewDvoCKIJ43T4HqSVlTculIfIbVZ5qErZA+wo1u6WWnA1TCb5XCtheT0cmizma9s oiVVSghZ4Bv4M3Pr6/SeYVH1dwSPBcuWEnBjpxq35g8k8VUTXjItQaeQ11H+O1OZj2JE jQJQ== X-Gm-Message-State: AMke39k+W2TJ2Jf/3hj27T3smzHbP/1hCH4m4jHa7fh9VX6qtCwOJBOhF0msIE62YBifuw== X-Received: by 10.84.128.100 with SMTP id 91mr27105869pla.94.1489168963126; Fri, 10 Mar 2017 10:02:43 -0800 (PST) Received: from ubuntu.eng.vmware.com ([208.91.1.34]) by smtp.gmail.com with ESMTPSA id i15sm19951872pfj.0.2017.03.10.10.02.42 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 10 Mar 2017 10:02:42 -0800 (PST) From: Gurucharan Shetty To: dev@openvswitch.org Date: Thu, 9 Mar 2017 23:46:38 -0800 Message-Id: <1489131998-28461-2-git-send-email-guru@ovn.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1489131998-28461-1-git-send-email-guru@ovn.org> References: <1489131998-28461-1-git-send-email-guru@ovn.org> X-Spam-Status: No, score=0.1 required=5.0 tests=BAYES_00, DATE_IN_PAST_06_12, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM autolearn=no version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH 2/2] ovn-util: Allow /32 IP addresses for router ports. 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: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org On Google cloud, a VM gets a /32 IP address. When OVN is deployed on such VMs, the OVN gateway router's IP address becomes a /32 IP address. This commit allows such a configuration. Signed-off-by: Gurucharan Shetty Acked-by: Ben Pfaff --- ovn/lib/ovn-util.c | 7 +--- tests/ovn.at | 100 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 101 insertions(+), 6 deletions(-) diff --git a/ovn/lib/ovn-util.c b/ovn/lib/ovn-util.c index 99e4a0e..475fa97 100644 --- a/ovn/lib/ovn-util.c +++ b/ovn/lib/ovn-util.c @@ -171,7 +171,7 @@ extract_lrp_networks(const struct nbrec_logical_router_port *lrp, error = ip_parse_cidr(lrp->networks[i], &ip4, &plen); if (!error) { - if (!ip4 || plen == 32) { + if (!ip4) { static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(5, 1); VLOG_WARN_RL(&rl, "bad 'networks' %s", lrp->networks[i]); continue; @@ -184,11 +184,6 @@ extract_lrp_networks(const struct nbrec_logical_router_port *lrp, error = ipv6_parse_cidr(lrp->networks[i], &ip6, &plen); if (!error) { - if (plen == 128) { - static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(5, 1); - VLOG_WARN_RL(&rl, "bad 'networks' %s", lrp->networks[i]); - continue; - } add_ipv6_netaddr(laddrs, ip6, plen); } else { static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 1); diff --git a/tests/ovn.at b/tests/ovn.at index bbbec90..6cf8d0c 100644 --- a/tests/ovn.at +++ b/tests/ovn.at @@ -6660,3 +6660,103 @@ OVN_CHECK_PACKETS([hv2/vif1-tx.pcap], [hv2-vif1.expected]) OVN_CLEANUP([hv1],[hv2],[hv3]) AT_CLEANUP + +AT_SETUP([ovn -- /32 router IP address]) +AT_SKIP_IF([test $HAVE_PYTHON = no]) +ovn_start + +# Logical network: +# 2 LS 'foo' and 'alice' connected via router R1. +# R1 connects to 'alice' with a /32 IP address. We use static routes and +# nexthop to push traffic to a logical port in switch 'alice' + +ovn-nbctl lr-add R1 + +ovn-nbctl ls-add foo +ovn-nbctl ls-add alice + +# Connect foo to R1 +ovn-nbctl lrp-add R1 foo 00:00:00:01:02:03 192.168.1.1/24 +ovn-nbctl lsp-add foo rp-foo -- set Logical_Switch_Port rp-foo type=router \ + options:router-port=foo addresses=\"00:00:00:01:02:03\" + +# Connect alice to R1. +ovn-nbctl lrp-add R1 alice 00:00:00:01:02:04 172.16.1.1/32 +ovn-nbctl lsp-add alice rp-alice -- set Logical_Switch_Port rp-alice \ + type=router options:router-port=alice addresses=\"00:00:00:01:02:04\" + +# Create logical port foo1 in foo +ovn-nbctl lsp-add foo foo1 \ +-- lsp-set-addresses foo1 "f0:00:00:01:02:03 192.168.1.2" + +# Create logical port alice1 in alice +ovn-nbctl lsp-add alice alice1 \ +-- lsp-set-addresses alice1 "f0:00:00:01:02:04 10.0.0.2" + +#install default route in R1 to use alice1's IP address as nexthop +ovn-nbctl lr-route-add R1 0.0.0.0/0 10.0.0.2 alice + +# Create two hypervisor and create OVS ports corresponding to logical ports. +net_add n1 + +sim_add hv1 +as hv1 +ovs-vsctl add-br br-phys +ovn_attach n1 br-phys 192.168.0.1 +ovs-vsctl -- add-port br-int hv1-vif1 -- \ + set interface hv1-vif1 external-ids:iface-id=foo1 \ + options:tx_pcap=hv1/vif1-tx.pcap \ + options:rxq_pcap=hv1/vif1-rx.pcap \ + ofport-request=1 + +sim_add hv2 +as hv2 +ovs-vsctl add-br br-phys +ovn_attach n1 br-phys 192.168.0.2 +ovs-vsctl -- add-port br-int hv2-vif1 -- \ + set interface hv2-vif1 external-ids:iface-id=alice1 \ + options:tx_pcap=hv2/vif1-tx.pcap \ + options:rxq_pcap=hv2/vif1-rx.pcap \ + ofport-request=1 + + +# Pre-populate the hypervisors' ARP tables so that we don't lose any +# packets for ARP resolution (native tunneling doesn't queue packets +# for ARP resolution). +ovn_populate_arp + +# Allow some time for ovn-northd and ovn-controller to catch up. +# XXX This should be more systematic. +sleep 1 + +ip_to_hex() { + printf "%02x%02x%02x%02x" "$@" +} + +# Send ip packets between foo1 and alice1 +src_mac="f00000010203" +dst_mac="000000010203" +src_ip=`ip_to_hex 192 168 1 2` +dst_ip=`ip_to_hex 10 0 0 2` +packet=${dst_mac}${src_mac}08004500001c0000000040110000${src_ip}${dst_ip}0035111100080000 + +# Send the first packet to trigger a ARP response and population of +# mac_bindings table. +as hv1 ovs-appctl netdev-dummy/receive hv1-vif1 $packet +OVS_WAIT_UNTIL([test `ovn-sbctl find mac_binding ip="10.0.0.2" | wc -l` -gt 0]) + +# Send the second packet to reach the destination. +as hv1 ovs-appctl netdev-dummy/receive hv1-vif1 $packet + +# Packet to Expect at 'alice1' +src_mac="000000010204" +dst_mac="f00000010204" +src_ip=`ip_to_hex 192 168 1 2` +dst_ip=`ip_to_hex 10 0 0 2` +echo "${dst_mac}${src_mac}08004500001c000000003f110100${src_ip}${dst_ip}0035111100080000" > expected + +OVN_CHECK_PACKETS([hv2/vif1-tx.pcap], [expected]) + +OVN_CLEANUP([hv1],[hv2]) + +AT_CLEANUP