From patchwork Mon Sep 20 13:20:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mohammad Heib X-Patchwork-Id: 1530101 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org 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=Mlyx6dse; dkim-atps=neutral Authentication-Results: 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=) 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 RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4HClYH38NGz9sPf for ; Mon, 20 Sep 2021 23:20:34 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 063C3828A5; Mon, 20 Sep 2021 13:20:32 +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 518bYwCBDaTD; Mon, 20 Sep 2021 13:20:31 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp1.osuosl.org (Postfix) with ESMTPS id 3D36E81DCA; Mon, 20 Sep 2021 13:20:30 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 1AB58C001C; Mon, 20 Sep 2021 13:20:30 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by lists.linuxfoundation.org (Postfix) with ESMTP id 09CFEC000F for ; Mon, 20 Sep 2021 13:20:28 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id E05D8823AA for ; Mon, 20 Sep 2021 13:20:27 +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 xG2RokFn4sgB for ; Mon, 20 Sep 2021 13:20:26 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by smtp1.osuosl.org (Postfix) with ESMTPS id 9D57081DCA for ; Mon, 20 Sep 2021 13:20:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1632144025; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=l6WZSbrLHlSgN7ZcK50OAThYyVBCzrKnplXaeD1ZsfU=; b=Mlyx6dse7cxMD74VaEsG7SEKO6+I4Px0pa2Sc6r6XMpa1aRcMsmjU4uwpaWtPTj/+OjO5Q 0XKI9pB5MGTG9J+S+Bs1agGpX26rxKlF36kcXDCRqbyi2IaHwkXrAHGXA5wQvz3vL5nPYn u2ZN0FH+lwgDI5SOn0vq+VjXzaKbO/k= 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-459-fVvHPqdAMCSFCB2DIdMOyg-1; Mon, 20 Sep 2021 09:20:23 -0400 X-MC-Unique: fVvHPqdAMCSFCB2DIdMOyg-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 391EEA0CAD for ; Mon, 20 Sep 2021 13:20:22 +0000 (UTC) Received: from mheib.bos.com (unknown [10.35.206.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1F0146D988; Mon, 20 Sep 2021 13:20:20 +0000 (UTC) From: mheib@redhat.com To: dev@openvswitch.org Date: Mon, 20 Sep 2021 16:20:01 +0300 Message-Id: <20210920132001.3675665-1-mheib@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mheib@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [ovs-dev] [PATCH ovn] ovn-northd: Virtual port add ND/ARP responder flows for IPv6 VIPs. 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" From: Mohammad Heib currently ovn-northd only handle virtual ports with VIP IPv4 and ignores virtual ports with VIP IPv6. This patch adds support for virtual ports with VIP IPv6 by adding lflows to the lsp_in_arp_rsp logical switch pipeline. Those lflows handle Neighbor Solicitations and Neighbor Advertisement requests that target the virtual port VIPs and bind the virtual port to the desired VIF. Reported-at: https://bugzilla.redhat.com/show_bug.cgi?id=2003091 Fixes: 054f4c85c413 ("Add a new logical switch port type - 'virtual'") Signed-off-by: Mohammad Heib --- northd/northd.c | 52 +++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 42 insertions(+), 10 deletions(-) diff --git a/northd/northd.c b/northd/northd.c index d1b87891c..d85036dcc 100644 --- a/northd/northd.c +++ b/northd/northd.c @@ -7386,16 +7386,30 @@ build_lswitch_arp_nd_responder_known_ips(struct ovn_port *op, * - ARP reply from the virtual ip which belongs to a logical * port of type 'virtual' and bind that port. * */ - ovs_be32 ip; + + union ip { + ovs_be32 ip; + ovs_u128 ipv6; + }ip; + const char *virtual_ip = smap_get(&op->nbsp->options, "virtual-ip"); const char *virtual_parents = smap_get(&op->nbsp->options, "virtual-parents"); - if (!virtual_ip || !virtual_parents || - !ip_parse(virtual_ip, &ip)) { + if (!virtual_ip || !virtual_parents) { return; } + bool is_ipv4 = strchr(virtual_ip, '.') ? true : false; + if (is_ipv4) { + if (!ip_parse(virtual_ip, &ip.ip)) { + return; + } + } else{ + if (!ipv6_parse(virtual_ip, (struct in6_addr *)&ip.ipv6)) + return; + } + char *tokstr = xstrdup(virtual_parents); char *save_ptr = NULL; char *vparent; @@ -7408,13 +7422,31 @@ build_lswitch_arp_nd_responder_known_ips(struct ovn_port *op, continue; } - ds_clear(match); - ds_put_format(match, "inport == \"%s\" && " - "((arp.op == 1 && arp.spa == %s && " - "arp.tpa == %s) || (arp.op == 2 && " - "arp.spa == %s))", - vparent, virtual_ip, virtual_ip, - virtual_ip); + if (is_ipv4) { + ds_clear(match); + ds_put_format(match, "inport == \"%s\" && " + "((arp.op == 1 && arp.spa == %s && " + "arp.tpa == %s) || (arp.op == 2 && " + "arp.spa == %s))", + vparent, virtual_ip, virtual_ip, + virtual_ip); + } else{ + struct ipv6_netaddr na; + /* Find VIP multicast group */ + in6_addr_solicited_node(&na.sn_addr, (struct in6_addr *)&ip.ipv6); + inet_ntop(AF_INET6, &na.sn_addr, na.sn_addr_s, sizeof na.sn_addr_s); + + ds_clear(match); + ds_put_format(match, "inport == \"%s\" && " + "((nd_ns && ip6.dst == {%s, %s} && nd.target == %s) ||" + "(nd_na && nd.target == %s))", + vparent, + virtual_ip, + na.sn_addr_s, + virtual_ip, + virtual_ip); + } + ds_clear(actions); ds_put_format(actions, "bind_vport(%s, inport); "