From patchwork Thu Nov 14 11:38:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 1194762 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.169.12; helo=mail.linuxfoundation.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.b="BM/hxaGg"; dkim-atps=neutral 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 47DKJx1Rxhz9sNT for ; Thu, 14 Nov 2019 22:39:45 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id E5D5FFB7; Thu, 14 Nov 2019 11:39:16 +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 03473F9C for ; Thu, 14 Nov 2019 11:39:16 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by smtp1.linuxfoundation.org (Postfix) with ESMTP id D8A2482B for ; Thu, 14 Nov 2019 11:39:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1573731551; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Kd2O2UoXy71QeMPVqB68yq1ZUKMzMlgVwsrnlBWyzOs=; b=BM/hxaGgcUEwt0jdfbo9p48+M8J87TciuDrw4Ao9GjyWBB7qgYZOpxev2uKtK1HuaI/ow8 b7XU4crqT27CYKuNCzfT+u0p+qIpC5bWXUDhSh3zytxGrtxDk3GLgau2s7T6pObaqkNPsc 0iPgZU94RerwRpAhwrOGrYRM925zthc= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-28-_9fMU3A3NfCUYAYMf5R0Cg-1; Thu, 14 Nov 2019 06:39:07 -0500 Received: by mail-wr1-f70.google.com with SMTP id y3so4221752wrm.12 for ; Thu, 14 Nov 2019 03:39:07 -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:mime-version:content-transfer-encoding; bh=TwVbzt8Fd0xbEvTG8EzwvAm40YlrqYedWVQFb21zlcY=; b=OvZNlR7Sc7E/JKRPndAnuaa9EaPgFTtp7qa2cTEIVmtzZg4qMgwyKZ6nbLY0WuzvJX myScPcSybZk22v5RCuxg3zE4EB9EGjjdmfRS/ohRMLeC3xWEKcDeYkRqsEfRTE0qUYUe bGLENI7Bv6MGunydQ5rWDD5ssVNnbzMgmjtOf2Z3KIfYZvJOKTDDSOjszCPkERdHc4aY Ay3SQz2aada62hnojfG9MCMNLi71U9jUpSU+FAIwH2a3EqAWSeAXxYwAbE1haMobB9rM W1CkA8+EJzJ+OrzMGuXXkzIi5Bz96+6lotR5I/BrGM5nF11d3OtYSk7q6C3Czici3xfE OFNg== X-Gm-Message-State: APjAAAVWwBR2AJKPtD/sOo7k7PVln/22vkJ/te3XjLb0R4sfjcbyFiUn w2PG6Z7pjuHLMfKu6tWxv3fCT3u2oyWiqMSqahlerX0z3zavui2N15Td7jL8+ZrRn9fi195V68K y4/gOTgmZ/rLI X-Received: by 2002:a5d:5284:: with SMTP id c4mr7414617wrv.376.1573731546437; Thu, 14 Nov 2019 03:39:06 -0800 (PST) X-Google-Smtp-Source: APXvYqzulSMBk/+G/iSTqHSGw4/eimfaWIrYD2Cph0N1Uwxxm6XG67VNDquOMygYa/RHH3m4SDjyZQ== X-Received: by 2002:a5d:5284:: with SMTP id c4mr7414589wrv.376.1573731546103; Thu, 14 Nov 2019 03:39:06 -0800 (PST) Received: from localhost.localdomain.com ([77.139.212.74]) by smtp.gmail.com with ESMTPSA id x8sm6809342wrm.7.2019.11.14.03.39.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Nov 2019 03:39:05 -0800 (PST) From: Lorenzo Bianconi To: dev@openvswitch.org Date: Thu, 14 Nov 2019 13:38:48 +0200 Message-Id: <7f49dc40eaf25dcc35de5ee6208789eefb7f378a.1573731441.git.lorenzo.bianconi@redhat.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: References: MIME-Version: 1.0 X-MC-Unique: _9fMU3A3NfCUYAYMf5R0Cg-1 X-Mimecast-Spam-Score: 0 X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH ovn 1/2] Add support to Default Router Preference (PRF) - RFC 4191 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: , Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org Introduce support for Default Router Preference (PRF) in IPv6 Router Advertisement according to RFC 4191 Signed-off-by: Lorenzo Bianconi --- controller/pinctrl.c | 20 +++++++++++++++++--- lib/ovn-l7.h | 4 ++++ northd/ovn-northd.c | 7 +++++++ ovn-nb.xml | 12 ++++++++++++ tests/ovn.at | 13 +++++++++---- 5 files changed, 49 insertions(+), 7 deletions(-) diff --git a/controller/pinctrl.c b/controller/pinctrl.c index a90ee73d6..b736b60ad 100644 --- a/controller/pinctrl.c +++ b/controller/pinctrl.c @@ -2263,10 +2263,10 @@ ipv6_ra_update_config(const struct sbrec_port_binding *pb) goto fail; } if (!strcmp(address_mode, "dhcpv6_stateless")) { - config->mo_flags = IPV6_ND_RA_FLAG_OTHER_ADDR_CONFIG; + config->mo_flags |= IPV6_ND_RA_FLAG_OTHER_ADDR_CONFIG; config->la_flags |= IPV6_ND_RA_OPT_PREFIX_AUTONOMOUS; } else if (!strcmp(address_mode, "dhcpv6_stateful")) { - config->mo_flags = IPV6_ND_RA_FLAG_MANAGED_ADDR_CONFIG; + config->mo_flags |= IPV6_ND_RA_FLAG_MANAGED_ADDR_CONFIG; } else if (!strcmp(address_mode, "slaac")) { config->la_flags |= IPV6_ND_RA_OPT_PREFIX_AUTONOMOUS; } else { @@ -2274,6 +2274,13 @@ ipv6_ra_update_config(const struct sbrec_port_binding *pb) goto fail; } + const char *prf = smap_get(&pb->options, "ipv6_ra_prf"); + if (!strcmp(prf, "HIGH")) { + config->mo_flags |= IPV6_ND_RA_OPT_PRF_HIGH; + } else if (!strcmp(prf, "LOW")) { + config->mo_flags |= IPV6_ND_RA_OPT_PRF_LOW; + } + const char *prefixes = smap_get(&pb->options, "ipv6_ra_prefixes"); if (prefixes && !extract_ip_addresses(prefixes, &config->prefixes)) { VLOG_WARN("Invalid IPv6 prefixes: %s", prefixes); @@ -2423,10 +2430,17 @@ ipv6_ra_send(struct rconn *swconn, struct ipv6_ra_state *ra) uint64_t packet_stub[128 / 8]; struct dp_packet packet; + uint16_t router_lt = IPV6_ND_RA_LIFETIME; + + if (!router_lt) { + /* Reset PRF to MEDIUM if router lifetime is not set */ + ra->config->mo_flags &= ~IPV6_ND_RA_OPT_PRF_LOW; + } + dp_packet_use_stub(&packet, packet_stub, sizeof packet_stub); compose_nd_ra(&packet, ra->config->eth_src, ra->config->eth_dst, &ra->config->ipv6_src, &ra->config->ipv6_dst, - 255, ra->config->mo_flags, htons(IPV6_ND_RA_LIFETIME), 0, 0, + 255, ra->config->mo_flags, htons(router_lt), 0, 0, ra->config->mtu); for (int i = 0; i < ra->config->prefixes.n_ipv6_addrs; i++) { diff --git a/lib/ovn-l7.h b/lib/ovn-l7.h index 5fc370bf5..fd898b0dc 100644 --- a/lib/ovn-l7.h +++ b/lib/ovn-l7.h @@ -287,6 +287,10 @@ nd_ra_opts_destroy(struct hmap *nd_ra_opts) #define IPV6_ND_RA_OPT_PREFIX_VALID_LIFETIME 0xffffffff #define IPV6_ND_RA_OPT_PREFIX_PREFERRED_LIFETIME 0xffffffff +#define IPV6_ND_RA_OPT_PRF_NORMAL 0x00 +#define IPV6_ND_RA_OPT_PRF_HIGH 0x08 +#define IPV6_ND_RA_OPT_PRF_LOW 0x18 + static inline void nd_ra_opts_init(struct hmap *nd_ra_opts) { diff --git a/northd/ovn-northd.c b/northd/ovn-northd.c index d6beb9768..a1eaa9071 100644 --- a/northd/ovn-northd.c +++ b/northd/ovn-northd.c @@ -6757,6 +6757,13 @@ copy_ra_to_sb(struct ovn_port *op, const char *address_mode) smap_add(&options, "ipv6_ra_src_eth", op->lrp_networks.ea_s); + const char *prf = smap_get(&op->nbrp->ipv6_ra_configs, "prf"); + if (!prf || (strcmp(prf, "HIGH") && strcmp(prf, "LOW"))) { + smap_add(&options, "ipv6_ra_prf", "MEDIUM"); + } else { + smap_add(&options, "ipv6_ra_prf", prf); + } + sbrec_port_binding_set_options(op->sb, &options); smap_destroy(&options); } diff --git a/ovn-nb.xml b/ovn-nb.xml index d8f3237fc..89d23ad7b 100644 --- a/ovn-nb.xml +++ b/ovn-nb.xml @@ -1859,6 +1859,18 @@ + + Default Router Preference (PRF) indicates whether to prefer this + router over other default routers (RFC 4191). + Possible values are: + +
    +
  • HIGH: mapped to 0x01 in RA PRF field
  • +
  • MEDIUM: mapped to 0x00 in RA PRF field
  • +
  • LOW: mapped to 0x11 in RA PRF field
  • +
+
+ The recommended MTU for the link. Default is 0, which means no MTU Option will be included in RA packet replied by ovn-controller. diff --git a/tests/ovn.at b/tests/ovn.at index 4a10a11e9..85d539c78 100644 --- a/tests/ovn.at +++ b/tests/ovn.at @@ -11504,23 +11504,28 @@ ra_test 000005dc 00 0 0 c0 40 aef00000000000000000000000000000 ovn-nbctl --wait=hv set Logical_Router_port ro-sw networks='aef0\:\:1/64 fd0f\:\:1/48' ra_test 000005dc 00 0 0 c0 40 aef00000000000000000000000000000 30 fd0f0000000000000000000000000000 +# Test PRF for default gw +ovn-nbctl --wait=hv set Logical_Router_port ro-sw ipv6_ra_configs:prf="LOW" +ra_test 000005dc 18 0 0 c0 40 aef00000000000000000000000000000 30 fd0f0000000000000000000000000000 + # Now test for RDNSS ovn-nbctl --wait=hv set Logical_Router_port ro-sw ipv6_ra_configs:rdnss='aef0::11' dns_addr=aef00000000000000000000000000011 -ra_test 000005dc 00 $dns_addr 0 c0 40 aef00000000000000000000000000000 30 fd0f0000000000000000000000000000 +ra_test 000005dc 18 $dns_addr 0 c0 40 aef00000000000000000000000000000 30 fd0f0000000000000000000000000000 # Now test for DNSSL ovn-nbctl --wait=hv set Logical_Router_port ro-sw ipv6_ra_configs:dnssl="aa.bb.cc" +ovn-nbctl --wait=hv set Logical_Router_port ro-sw ipv6_ra_configs:prf="HIGH" dnssl=02616102626202636300000000000000 -ra_test 000005dc 00 $dns_addr $dnssl c0 40 aef00000000000000000000000000000 30 fd0f0000000000000000000000000000 +ra_test 000005dc 08 $dns_addr $dnssl c0 40 aef00000000000000000000000000000 30 fd0f0000000000000000000000000000 ## Test a different address mode now ovn-nbctl --wait=hv set Logical_Router_Port ro-sw ipv6_ra_configs:address_mode=dhcpv6_stateful -ra_test 000005dc 80 $dns_addr $dnssl 80 40 aef00000000000000000000000000000 30 fd0f0000000000000000000000000000 +ra_test 000005dc 88 $dns_addr $dnssl 80 40 aef00000000000000000000000000000 30 fd0f0000000000000000000000000000 # And the other address mode ovn-nbctl --wait=hv set Logical_Router_Port ro-sw ipv6_ra_configs:address_mode=dhcpv6_stateless -ra_test 000005dc 40 $dns_addr $dnssl c0 40 aef00000000000000000000000000000 30 fd0f0000000000000000000000000000 +ra_test 000005dc 48 $dns_addr $dnssl c0 40 aef00000000000000000000000000000 30 fd0f0000000000000000000000000000 OVN_CLEANUP([hv1],[hv2]) AT_CLEANUP