From patchwork Sat Jun 6 11:24:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gabriele Cerami X-Patchwork-Id: 1304502 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=Rg4XYobo; 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 49fHGz0xQxz9sSF for ; Sat, 6 Jun 2020 21:24:42 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 0A5D320656; Sat, 6 Jun 2020 11:24:40 +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 EUcGRh90Dozm; Sat, 6 Jun 2020 11:24:35 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by silver.osuosl.org (Postfix) with ESMTP id AF725204D0; Sat, 6 Jun 2020 11:24:35 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 70FECC088D; Sat, 6 Jun 2020 11:24:35 +0000 (UTC) X-Original-To: ovs-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 8D3EBC016E for ; Sat, 6 Jun 2020 11:24:34 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 75BEF8690F for ; Sat, 6 Jun 2020 11:24:34 +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 3be9Q82Pp-qq for ; Sat, 6 Jun 2020 11:24:33 +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 whitealder.osuosl.org (Postfix) with ESMTPS id 13DBE85BBF for ; Sat, 6 Jun 2020 11:24:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591442671; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type; bh=EDdZAot4H+WZYuF65ez1cfONT8nmxphUJ/1aEh5jz1U=; b=Rg4XYoboYWyD1xE3Bn2imzR/HmOva+Hvvbu3NJJeZPSyI14jbmRGTOvKPRodjxAQn6aD4v xjmVTjooXq4/9Ba36zr2f+mopH5wJouUXOkF2ovZKNXHQS2GkTRqVb11UUAELqK9Emqenq +0YkZFZmDjkFZ/DbFGMnQ0KkpqHkRfc= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-180-BTtpEhCaOt-5dm8qAmqLaw-1; Sat, 06 Jun 2020 07:24:28 -0400 X-MC-Unique: BTtpEhCaOt-5dm8qAmqLaw-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2C7FD107ACCA for ; Sat, 6 Jun 2020 11:24:27 +0000 (UTC) Received: from localhost (unknown [10.36.110.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id B6AF05D9C5 for ; Sat, 6 Jun 2020 11:24:26 +0000 (UTC) Date: Sat, 6 Jun 2020 12:24:25 +0100 From: Gabriele Cerami To: ovs-dev@openvswitch.org Message-ID: <20200606112425.c5mykpnm4ehvtv6a@localhost> MIME-Version: 1.0 User-Agent: NeoMutt/20170113 (1.7.2) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Subject: [ovs-dev] [PATCH ovn] Honour router_preference for solicited RA 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" Replies to router solicitation follow a different flow than periodic RA. This flow currently does not honour the router_preference configuration. This patch modifies the flow to honour the flag, and send router preference indications in the reply RA following RFC4191 specifications Reported-at: https://bugzilla.redhat.com/show_bug.cgi?id=1804576 Signed-off-by: Gabriele Cerami --- lib/actions.c | 30 +++++++++++++++++++++++++++--- lib/ovn-l7.h | 5 +++++ northd/ovn-northd.c | 6 ++++++ tests/ovn.at | 16 +++++++++++----- 4 files changed, 49 insertions(+), 8 deletions(-) diff --git a/lib/actions.c b/lib/actions.c index c50615177..38a3c0ef0 100644 --- a/lib/actions.c +++ b/lib/actions.c @@ -2535,6 +2535,12 @@ parse_put_nd_ra_opts(struct action_context *ctx, const struct expr_field *dst, } break; + case ND_RA_FLAG_PRF: + ok = (c->string && (!strcmp(c->string, "MEDIUM") || + !strcmp(c->string, "HIGH") || + !strcmp(c->string, "LOW"))); + break; + case ND_OPT_SOURCE_LINKADDR: ok = c->format == LEX_F_ETHERNET; slla_present = true; @@ -2583,15 +2589,27 @@ encode_put_nd_ra_option(const struct ovnact_gen_option *o, struct ofpbuf *ofpacts, ptrdiff_t ra_offset) { const union expr_constant *c = o->value.values; + struct ovs_ra_msg *ra = ofpbuf_at(ofpacts, ra_offset, sizeof *ra); switch (o->option->code) { case ND_RA_FLAG_ADDR_MODE: { - struct ovs_ra_msg *ra = ofpbuf_at(ofpacts, ra_offset, sizeof *ra); if (!strcmp(c->string, "dhcpv6_stateful")) { - ra->mo_flags = IPV6_ND_RA_FLAG_MANAGED_ADDR_CONFIG; + ra->mo_flags |= IPV6_ND_RA_FLAG_MANAGED_ADDR_CONFIG; } else if (!strcmp(c->string, "dhcpv6_stateless")) { - ra->mo_flags = IPV6_ND_RA_FLAG_OTHER_ADDR_CONFIG; + ra->mo_flags |= IPV6_ND_RA_FLAG_OTHER_ADDR_CONFIG; + } + break; + } + + case ND_RA_FLAG_PRF: + { + if (!strcmp(c->string, "LOW")) { + ra->mo_flags |= IPV6_ND_RA_OPT_PRF_LOW; + } else if (!strcmp(c->string, "HIGH")) { + ra->mo_flags |= IPV6_ND_RA_OPT_PRF_HIGH; + } else { + ra->mo_flags |= IPV6_ND_RA_OPT_PRF_NORMAL; } break; } @@ -2640,6 +2658,12 @@ encode_put_nd_ra_option(const struct ovnact_gen_option *o, break; } } + + /* RFC4191 section 2.2 */ + if (ntohs(ra->router_lifetime) == 0x0) { + ra->mo_flags &= IPV6_ND_RA_OPT_PRF_RESET_MASK; + } + } static void diff --git a/lib/ovn-l7.h b/lib/ovn-l7.h index cc63d822d..d5c6feaeb 100644 --- a/lib/ovn-l7.h +++ b/lib/ovn-l7.h @@ -309,6 +309,9 @@ nd_ra_opts_destroy(struct hmap *nd_ra_opts) #define ND_RA_FLAG_ADDR_MODE 0 +/* all small numbers seems to be all already taken but nothing guarantees this + * code will not be assigned by IANA to another option */ +#define ND_RA_FLAG_PRF 255 /* Default values of various IPv6 Neighbor Discovery protocol options and @@ -330,11 +333,13 @@ nd_ra_opts_destroy(struct hmap *nd_ra_opts) #define IPV6_ND_RA_OPT_PRF_NORMAL 0x00 #define IPV6_ND_RA_OPT_PRF_HIGH 0x08 #define IPV6_ND_RA_OPT_PRF_LOW 0x18 +#define IPV6_ND_RA_OPT_PRF_RESET_MASK 0xe7 static inline void nd_ra_opts_init(struct hmap *nd_ra_opts) { nd_ra_opt_add(nd_ra_opts, "addr_mode", ND_RA_FLAG_ADDR_MODE, "str"); + nd_ra_opt_add(nd_ra_opts, "router_preference", ND_RA_FLAG_PRF, "str"); nd_ra_opt_add(nd_ra_opts, "slla", ND_OPT_SOURCE_LINKADDR, "mac"); nd_ra_opt_add(nd_ra_opts, "prefix", ND_OPT_PREFIX_INFORMATION, "ipv6"); nd_ra_opt_add(nd_ra_opts, "mtu", ND_OPT_MTU, "uint32"); diff --git a/northd/ovn-northd.c b/northd/ovn-northd.c index eb78f317e..e7815bfc3 100644 --- a/northd/ovn-northd.c +++ b/northd/ovn-northd.c @@ -9452,6 +9452,12 @@ build_lrouter_flows(struct hmap *datapaths, struct hmap *ports, ds_put_format(&actions, ", mtu = %u", mtu); } + const char *prf = smap_get_def( + &op->nbrp->ipv6_ra_configs, "router_preference", "MEDIUM"); + if (strcmp(prf, "MEDIUM")) { + ds_put_format(&actions, ", router_preference = \"%s\"", prf); + } + bool add_rs_response_flow = false; for (size_t i = 0; i < op->lrp_networks.n_ipv6_addrs; i++) { diff --git a/tests/ovn.at b/tests/ovn.at index 15b40ca1e..029027586 100644 --- a/tests/ovn.at +++ b/tests/ovn.at @@ -10619,13 +10619,16 @@ reset_pcap_file hv1-vif1 hv1/vif1 reset_pcap_file hv1-vif2 hv1/vif2 reset_pcap_file hv1-vif3 hv1/vif3 -# Set the MTU to 1500 +# Set the MTU to 1500, send_periodic to false, preference to LOW ovn-nbctl --wait=hv set Logical_Router_Port lrp0 ipv6_ra_configs:mtu=1500 +ovn-nbctl --wait=hv set Logical_Router_Port lrp0 ipv6_ra_configs:send_periodic="false" +ovn-nbctl --wait=hv set Logical_Router_Port lrp0 ipv6_ra_configs:router_preference="LOW" # Make sure that ovn-controller has installed the corresponding OF Flow. OVS_WAIT_UNTIL([test 1 = `as hv1 ovs-ofctl dump-flows br-int | grep -c "ipv6_dst=ff02::2,nw_ttl=255,icmp_type=133,icmp_code=0"`]) -addr_mode=00 +# addr_mode byte also includes router preference information +addr_mode=18 default_prefix_option_config=030440c0ffffffffffffffff00000000 src_mac=fa163e000003 src_lla=fe80000000000000f8163efffe000003 @@ -10650,12 +10653,14 @@ reset_pcap_file hv1-vif1 hv1/vif1 reset_pcap_file hv1-vif2 hv1/vif2 reset_pcap_file hv1-vif3 hv1/vif3 -# Set the address mode to dhcpv6_stateful +# Set the address mode to dhcpv6_stateful, router_preference to HIGH ovn-nbctl --wait=hv set Logical_Router_Port lrp0 ipv6_ra_configs:address_mode=dhcpv6_stateful +ovn-nbctl --wait=hv set Logical_Router_Port lrp0 ipv6_ra_configs:router_preference="HIGH" # Make sure that ovn-controller has installed the corresponding OF Flow. OVS_WAIT_UNTIL([test 1 = `as hv1 ovs-ofctl dump-flows br-int | grep -c "ipv6_dst=ff02::2,nw_ttl=255,icmp_type=133,icmp_code=0"`]) -addr_mode=80 +# addr_mode byte also includes router preference information +addr_mode=88 default_prefix_option_config=03044080ffffffffffffffff00000000 src_mac=fa163e000004 src_lla=fe80000000000000f8163efffe000004 @@ -10680,8 +10685,9 @@ reset_pcap_file hv1-vif1 hv1/vif1 reset_pcap_file hv1-vif2 hv1/vif2 reset_pcap_file hv1-vif3 hv1/vif3 -# Set the address mode to dhcpv6_stateless +# Set the address mode to dhcpv6_stateless, reset router preference to default ovn-nbctl --wait=hv set Logical_Router_Port lrp0 ipv6_ra_configs:address_mode=dhcpv6_stateless +ovn-nbctl --wait=hv set Logical_Router_Port lrp0 ipv6_ra_configs:router_preference="MEDIUM" # Make sure that ovn-controller has installed the corresponding OF Flow. OVS_WAIT_UNTIL([test 1 = `as hv1 ovs-ofctl dump-flows br-int | grep -c "ipv6_dst=ff02::2,nw_ttl=255,icmp_type=133,icmp_code=0"`])