From patchwork Fri Mar 10 07:46:37 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gurucharan Shetty X-Patchwork-Id: 737506 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 3vfw8m3PThz9s7x for ; Sat, 11 Mar 2017 05:02:48 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 4286E259; Fri, 10 Mar 2017 18:02:45 +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 243CF905 for ; Fri, 10 Mar 2017 18:02:44 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-pf0-f196.google.com (mail-pf0-f196.google.com [209.85.192.196]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 9ACF2168 for ; Fri, 10 Mar 2017 18:02:43 +0000 (UTC) Received: by mail-pf0-f196.google.com with SMTP id v190so11549806pfb.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; bh=5iQCroiMBXC+AosfMK+w5X8gcrmCgUuknA1YMQ8pDR8=; b=EwnTSnuPHEiclGfTG+gR6hJ8YC85IGBh9L+SYa77JKcDD7Ep5KbbICCQ/RSuD/U8sY JG1vqAqPrJhsT0S2q+EzVe4/975av6NDio3HCJisHoodB5dDGd5ylv8qdAAHjr4FKlKo h3XSR1FYoahSgCHFYJOI1+FbIWiOJPseaaUTSV8icPb4Tf7/TOylkT5p7muec3pLnauZ vyj9iNUYXX5BCbFxKv5WBHM/GId1ORTyisqYnTNJwQ4uR+VKanWHFDwK/+pHuB4W4qUY vDIbv1mf1TurVyqPcdDkRuZks60NwnwOeTbfBALYU9fTO3Nf+UnyrNw9qexPUiXtqZ9O XmQA== X-Gm-Message-State: AMke39ms6SmYlZqOwjydPvF2TkERrey4pGI41BfJlbD+iZKxxICXqfZ9ipK7uBsy1Fl2uQ== X-Received: by 10.84.241.130 with SMTP id b2mr27631983pll.32.1489168962203; Fri, 10 Mar 2017 10:02:42 -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.41 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 10 Mar 2017 10:02:41 -0800 (PST) From: Gurucharan Shetty To: dev@openvswitch.org Date: Thu, 9 Mar 2017 23:46:37 -0800 Message-Id: <1489131998-28461-1-git-send-email-guru@ovn.org> X-Mailer: git-send-email 1.9.1 X-Spam-Status: No, score=-0.6 required=5.0 tests=BAYES_00, DATE_IN_PAST_06_12, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, 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 1/2] ovn-northd: Allow static routes with nexthop in different subnet. 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 There are cases where the default gateway of a interface is in a different subnet than its IP address. Linux allows such configuration. For e.g, one could set the IP address of a Linux interface as 172.16.1.2/32 and then give it a default gateway of 172.16.1.1. This can be done for e.g. by running the following commands. ifconfig eth0 172.16.1.2 netmask 255.255.255.255 broadcast 172.16.1.2 route add 172.16.1.1 dev eth0 route add default gw 172.16.1.1 The above configuration is what google cloud uses for its VMs. In OVN static routes, we currently have the ability to specify the router port via which the packet needs to be pushed out to reach a next hop. But when support for IPv6 was added, we only allowed nexthops to be in the same subnet as one of the router's IP addresses. This commit relaxes that restriction. When a outport is specified in static routes and when a nexthop is in a different subnet than any of the router IP addresses, we will assume that it is reachable from the first IP address of the router. Since this is a corner case, we just go with the first IP address. If it turns out that there are more cases, we can let users choose the IP address via which the destination is reachable. Signed-off-by: Gurucharan Shetty Acked-by: Ben Pfaff --- Patch2 of the series includes a unit test that also covers this case. --- ovn/northd/ovn-northd.c | 17 +++++++++++++++++ ovn/ovn-nb.xml | 5 ++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/ovn/northd/ovn-northd.c b/ovn/northd/ovn-northd.c index cc9b934..59ebc05 100644 --- a/ovn/northd/ovn-northd.c +++ b/ovn/northd/ovn-northd.c @@ -3697,6 +3697,23 @@ build_static_route_flow(struct hmap *lflows, struct ovn_datapath *od, goto free_prefix_s; } lrp_addr_s = find_lrp_member_ip(out_port, route->nexthop); + if (!lrp_addr_s) { + /* There are no IP networks configured on the router's port via + * which 'route->nexthop' is theoretically reachable. But since + * 'out_port' has been specified, we honor it by trying to reach + * 'route->nexthop' via the first IP address of 'out_port'. + * (There are cases, e.g in GCE, where each VM gets a /32 IP + * address and the default gateway is still reachable from it.) */ + if (is_ipv4) { + if (out_port->lrp_networks.n_ipv4_addrs) { + lrp_addr_s = out_port->lrp_networks.ipv4_addrs[0].addr_s; + } + } else { + if (out_port->lrp_networks.n_ipv6_addrs) { + lrp_addr_s = out_port->lrp_networks.ipv6_addrs[0].addr_s; + } + } + } } else { /* output_port is not specified, find the * router port matching the next hop. */ diff --git a/ovn/ovn-nb.xml b/ovn/ovn-nb.xml index 88a6082..c1f4e1f 100644 --- a/ovn/ovn-nb.xml +++ b/ovn/ovn-nb.xml @@ -1264,7 +1264,10 @@ The name of the via which the packet needs to be sent out. This is optional and when not specified, OVN will automatically figure this out based on the - . + . When this is specified and there are + multiple IP addresses on the router port and none of them are in the + same subnet of , OVN chooses the first IP + address as the one via which the is reachable.