From patchwork Mon Feb 12 16:11:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Xavier Simonart X-Patchwork-Id: 1897794 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.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=E0CeCR2S; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.138; helo=smtp1.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=patchwork.ozlabs.org) Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TYTx82YYKz23hw for ; Tue, 13 Feb 2024 03:11:56 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 2806F83CF7; Mon, 12 Feb 2024 16:11:54 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id FQd-84R2nxC8; Mon, 12 Feb 2024 16:11:52 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=140.211.9.56; helo=lists.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver= DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 37C9483BBA Authentication-Results: smtp1.osuosl.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=E0CeCR2S Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp1.osuosl.org (Postfix) with ESMTPS id 37C9483BBA; Mon, 12 Feb 2024 16:11:51 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id BFC71C0072; Mon, 12 Feb 2024 16:11:51 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp1.osuosl.org (smtp1.osuosl.org [IPv6:2605:bc80:3010::138]) by lists.linuxfoundation.org (Postfix) with ESMTP id E8997C0037 for ; Mon, 12 Feb 2024 16:11:49 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id CF08B83BD3 for ; Mon, 12 Feb 2024 16:11:49 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id FcvwZOZsJ-LY for ; Mon, 12 Feb 2024 16:11:49 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=170.10.133.124; helo=us-smtp-delivery-124.mimecast.com; envelope-from=xsimonar@redhat.com; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp1.osuosl.org B524A83BBA Authentication-Results: smtp1.osuosl.org; dmarc=pass (p=none dis=none) header.from=redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org B524A83BBA Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by smtp1.osuosl.org (Postfix) with ESMTPS id B524A83BBA for ; Mon, 12 Feb 2024 16:11:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707754307; 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; bh=rM80zUwEUGWQgz6ShFnBJ5Olug1YQhkF9mcLsVXov30=; b=E0CeCR2SFLisTiFfneNqOduJp8YCAuOt7eFtegM7MPWtwV9qWXXPaSyhFr1CMrmAzyJhBD k0whe7qoyZ427QXuhjgNj1pqdCKHWsZzp7h40gbULOs/7feOcjop19M1fW9mea1U9PTvtQ 04BxksRps/E1xRJx3tsx4yDfOBVz8Ng= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-286-MTWOQU61MMmQGR9VVVvCMQ-1; Mon, 12 Feb 2024 11:11:45 -0500 X-MC-Unique: MTWOQU61MMmQGR9VVVvCMQ-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id ED9BC282D3CA for ; Mon, 12 Feb 2024 16:11:44 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.39.193.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 77214111D792; Mon, 12 Feb 2024 16:11:44 +0000 (UTC) From: Xavier Simonart To: xsimonar@redhat.com, dev@openvswitch.org Date: Mon, 12 Feb 2024 17:11:43 +0100 Message-ID: <20240212161143.384232-1-xsimonar@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.3 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [ovs-dev] [PATCH ovn] pinctrl: Fix prefix delegation. 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" Prefix delegation suffered from potential issues: - An unicast SOLICIT message was sometimes sent instead of a RENEW. - Pînctrl was sometimes not waking up as expected when timers such as T1 or T2 expired. - If reply was not received for a REQUEST, no new SOLICIT was sent. - State update to RENEW, done by ipv6_prefixd_should_inject, was sometimes done before send_ipv6_prefixd (as part of may_inject), and sometimes not, depending for instance of garp. This influenced how T1 and T2 were calculated. State change was also influenced by other prefixes (e.g. another prefix in SOLICIT might skip an update to RENEW). This patch fixes those issue by: [1] Do not try to send RENEW in PENDING state as this resulted in SOLICIT sent unicast. [2] Make sure to wake up in DONE, PENDING, RENEW and REBIND states. [3] Make sure to wake up and send REQUEST in REQUEST state in case no reply received. [4] Ensure that RENEW and REBIND states are updated indeoendently of other network elements such as garps or other prefixes. The patch also modifies the "IPv6 prefix delegation" system test to test scenarios 1 and 2, and reduces renewal-time to reduce test duration. This issue was highlighted by frequent failures of "IPv6 prefix delegation" test in Build_and_Test ovsrobot. Signed-off-by: Xavier Simonart Acked-by: Ales Musil --- controller/pinctrl.c | 38 +++++++++++++++++++++++++++++------ tests/system-common-macros.at | 38 ++++++++++++++++++++++------------- 2 files changed, 56 insertions(+), 20 deletions(-) diff --git a/controller/pinctrl.c b/controller/pinctrl.c index 98b29de9f..3f041b295 100644 --- a/controller/pinctrl.c +++ b/controller/pinctrl.c @@ -1171,7 +1171,7 @@ ipv6_prefixd_send(struct rconn *swconn, struct ipv6_prefixd_state *pfd) return pfd->next_announce; } - if (pfd->state == PREFIX_DONE) { + if ((pfd->state == PREFIX_PENDING) || (pfd->state == PREFIX_DONE)) { goto out; } @@ -1222,33 +1222,58 @@ static bool ipv6_prefixd_should_inject(void) struct ipv6_prefixd_state *pfd = iter->data; long long int cur_time = time_msec(); - if (pfd->state == PREFIX_SOLICIT) { + if (pfd->state == PREFIX_SOLICIT || pfd->state == PREFIX_REQUEST) { return true; } if (pfd->state == PREFIX_DONE && cur_time > pfd->last_complete + pfd->t1) { - pfd->state = PREFIX_RENEW; return true; } if (pfd->state == PREFIX_RENEW && cur_time > pfd->last_complete + pfd->t2) { - pfd->state = PREFIX_REBIND; pfd->uuid.len = 0; return true; } if (pfd->state == PREFIX_REBIND && cur_time > pfd->last_complete + pfd->vlife_time) { - pfd->state = PREFIX_SOLICIT; return true; } } return false; } +static void ipv6_prefixd_update_state(struct ipv6_prefixd_state *pfd) +{ + long long int cur_time = time_msec(); + + if (pfd->state == PREFIX_DONE && + cur_time > pfd->last_complete + pfd->t1) { + pfd->state = PREFIX_RENEW; + return; + } + if (pfd->state == PREFIX_RENEW && + cur_time > pfd->last_complete + pfd->t2) { + pfd->state = PREFIX_REBIND; + pfd->uuid.len = 0; + return; + } + if (pfd->state == PREFIX_REBIND && + cur_time > pfd->last_complete + pfd->vlife_time) { + pfd->state = PREFIX_SOLICIT; + return; + } +} + static void ipv6_prefixd_wait(long long int timeout) { - if (ipv6_prefixd_should_inject()) { + /* We need to wake up in all states : + * - In SOLICIT and REQUEST states we need to wakeup to handle + * next_announce timer. + * - In DONE, PENDING, RENEW and REBIND states, we need to wake up to + * handle T1, T2 timers. + */ + if (!shash_is_empty(&ipv6_prefixd)) { poll_timer_wait_until(timeout); } } @@ -1266,6 +1291,7 @@ send_ipv6_prefixd(struct rconn *swconn, long long int *send_prefixd_time) if (*send_prefixd_time > next_msg) { *send_prefixd_time = next_msg; } + ipv6_prefixd_update_state(pfd); } } diff --git a/tests/system-common-macros.at b/tests/system-common-macros.at index 4bfc74582..9e7f40176 100644 --- a/tests/system-common-macros.at +++ b/tests/system-common-macros.at @@ -418,15 +418,14 @@ ovn-nbctl lsp-add public public1 \ ovn-nbctl set logical_router_port rp-public options:prefix_delegation=true ovn-nbctl set logical_router_port rp-public options:prefix=true ovn-nbctl set logical_router_port rp-sw0 options:prefix=true -ovn-nbctl set logical_router_port rp-sw1 options:prefix=true OVN_POPULATE_ARP ovn-nbctl --wait=hv sync cat > /etc/dhcp/dhcpd.conf < /tmp/rp-public -ovn-nbctl set logical_router_port rp-sw0 options:prefix=false -ovn-nbctl set logical_router_port rp-sw1 options:prefix=false -# Renew message -NS_CHECK_EXEC([server], [tcpdump -c 1 -nni s1 ip6[[48:1]]=0x05 and ip6[[113:4]]=0x${prefix} > renew.pcap &]) + +# Wait for 2 renew on each port. +NS_CHECK_EXEC([server], [tcpdump -c 4 -nni s1 ip6[[48:1]]=0x05 and ip6[[113:4]]=0x${prefix} > renew.pcap &]) # Reply message with Status OK -NS_CHECK_EXEC([server], [tcpdump -c 1 -nni s1 ip6[[48:1]]=0x07 and ip6[[81:4]]=0x${prefix} > reply.pcap &]) +NS_CHECK_EXEC([server], [tcpdump -c 4 -nni s1 ip6[[48:1]]=0x07 and ip6[[81:4]]=0x${prefix} > reply.pcap &]) OVS_WAIT_UNTIL([ total_pkts=$(cat renew.pcap | wc -l) - test "${total_pkts}" = "1" + test "${total_pkts}" = "4" ]) OVS_WAIT_UNTIL([ total_pkts=$(cat reply.pcap | wc -l) - test "${total_pkts}" = "1" + test "${total_pkts}" = "4" +]) + +ovn-nbctl set logical_router_port rp-public options:prefix=false +ovn-nbctl set logical_router_port rp-sw0 options:prefix=false +ovn-nbctl --wait=hv set logical_router_port rp-sw1 options:prefix=true +sleep_sb +NS_CHECK_EXEC([server], [tcpdump -c 2 -nni s1 ip6[[48:1]]=0x05 and ip6[[113:4]]=0x${prefix} > renew.pcap &]) + +# Sleep enough to have solicit and renew being sent, then wait for 2 renew. +# The reply to the request will usually be received as sb is sleeping. +# Hence, the reply to the first renew will be received when sb is ro. +sleep 10 +wake_up_sb +OVS_WAIT_UNTIL([ + total_pkts=$(cat renew.pcap | wc -l) + test "${total_pkts}" = "2" ]) kill $(pidof tcpdump)