From nobody Tue Apr 30 21:08:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 15198426468529.9703279843568; Wed, 28 Feb 2018 10:30:46 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E03A1757C4; Wed, 28 Feb 2018 18:30:42 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1E6E05E1D8; Wed, 28 Feb 2018 18:30:42 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 4FB8E4A46D; Wed, 28 Feb 2018 18:30:40 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w1SIUbX0018677 for ; Wed, 28 Feb 2018 13:30:38 -0500 Received: by smtp.corp.redhat.com (Postfix) id B50F010AF9CA; Wed, 28 Feb 2018 18:30:37 +0000 (UTC) Received: from vhost2.laine.org (ovpn-116-187.phx2.redhat.com [10.3.116.187]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4D5CB10AF9DA for ; Wed, 28 Feb 2018 18:30:37 +0000 (UTC) From: Laine Stump To: libvir-list@redhat.com Date: Wed, 28 Feb 2018 13:30:25 -0500 Message-Id: <20180228183026.31725-2-laine@laine.org> In-Reply-To: <20180228183026.31725-1-laine@laine.org> References: <20180228183026.31725-1-laine@laine.org> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-loop: libvir-list@redhat.com Subject: [libvirt] [tck PATCH 1/2] new helper function get_network_ip() X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Wed, 28 Feb 2018 18:30:43 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This function gets the first IP address for the named virtual network. Signed-off-by: Laine Stump --- lib/Sys/Virt/TCK/NetworkHelpers.pm | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/Sys/Virt/TCK/NetworkHelpers.pm b/lib/Sys/Virt/TCK/NetworkH= elpers.pm index 5f563e5..03bc87a 100644 --- a/lib/Sys/Virt/TCK/NetworkHelpers.pm +++ b/lib/Sys/Virt/TCK/NetworkHelpers.pm @@ -9,6 +9,16 @@ sub get_first_macaddress { return $mac; } =20 +sub get_network_ip { + my $conn =3D shift; + my $netname =3D shift; + diag "getting ip for network $netname"; + my $net =3D $conn->get_network_by_name($netname); + my $net_ip =3D xpath($net, "string(/network/ip[1]/\@address"); + return $net_ip; +} + + sub get_ip_from_leases{ my $conn =3D shift; my $netname =3D shift; --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue Apr 30 21:08:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1519842659606716.1641980319415; Wed, 28 Feb 2018 10:30:59 -0800 (PST) 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 mx1.redhat.com (Postfix) with ESMTPS id 68375C04BE06; Wed, 28 Feb 2018 18:30:58 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 36F1B620A8; Wed, 28 Feb 2018 18:30:58 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id E6E3E4A471; Wed, 28 Feb 2018 18:30:57 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w1SIUc8A018686 for ; Wed, 28 Feb 2018 13:30:38 -0500 Received: by smtp.corp.redhat.com (Postfix) id 6A9D110AF9CA; Wed, 28 Feb 2018 18:30:38 +0000 (UTC) Received: from vhost2.laine.org (ovpn-116-187.phx2.redhat.com [10.3.116.187]) by smtp.corp.redhat.com (Postfix) with ESMTP id 03E4910AF9D1 for ; Wed, 28 Feb 2018 18:30:37 +0000 (UTC) From: Laine Stump To: libvir-list@redhat.com Date: Wed, 28 Feb 2018 13:30:26 -0500 Message-Id: <20180228183026.31725-3-laine@laine.org> In-Reply-To: <20180228183026.31725-1-laine@laine.org> References: <20180228183026.31725-1-laine@laine.org> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-loop: libvir-list@redhat.com Subject: [libvirt] [tck PATCH 2/2] set CTRL_IP_LEARNING and DHCPSERVER in filter during no-ip-spoofing test X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Wed, 28 Feb 2018 18:30:58 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Adding these parameters to the clean-traffic filter causes a significant extra piece of code to be executed (a separate thread is started up, which uses libpcap to capture DHCP traffic and learn the IP address of the guest / test appliance), so let's get some test coverage on that code. Signed-off-by: Laine Stump --- lib/Sys/Virt/TCK.pm | 11 ++++++++--- lib/Sys/Virt/TCK/DomainBuilder.pm | 8 +++++++- scripts/nwfilter/220-no-ip-spoofing.t | 9 ++++++++- 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/lib/Sys/Virt/TCK.pm b/lib/Sys/Virt/TCK.pm index 3f650a8..0e2e639 100644 --- a/lib/Sys/Virt/TCK.pm +++ b/lib/Sys/Virt/TCK.pm @@ -767,6 +767,7 @@ sub generic_machine_domain { my $ostype =3D exists $params{ostype} ? $params{ostype} : "hvm"; my $fullos =3D exists $params{fullos} ? $params{fullos} : 0; my $filterref =3D exists $params{filterref} ? $params{filterref} : und= ef; + my %filterparams =3D exists $params{filterparams} ? %{$params{filterpa= rams}} : undef; =20 if ($fullos) { my %config =3D $self->get_image($caps, $ostype); @@ -793,7 +794,8 @@ sub generic_machine_domain { source =3D> "default", model =3D> "virtio", mac =3D> "52:54:00:11:11:11", - filterref =3D> $filterref); + filterref =3D> $filterref, + filterparams =3D> \%filterparams); my $xml =3D $b->as_xml(); # Cleanup the temporary interface $b->rminterface(); @@ -898,6 +900,7 @@ sub generic_domain { my $fullos =3D exists $params{fullos} ? $params{fullos} : 0; my $netmode =3D exists $params{netmode} ? $params{netmode} : undef; my $filterref =3D exists $params{filterref} ? $params{filterref} : und= ef; + my %filterparams =3D exists $params{filterparams} ? %{$params{filterpa= rams}} : undef; =20 my $caps =3D Sys::Virt::TCK::Capabilities->new(xml =3D> $self->conn->g= et_capabilities); =20 @@ -918,7 +921,8 @@ sub generic_domain { caps =3D> $caps, ostype =3D> $ostype, fullos =3D> $fullos, - filterref =3D> $filterref); + filterref =3D> $filterref, + filterparams =3D> \%filterparam= s); } if ($netmode) { if ($netmode eq "vepa") { @@ -934,7 +938,8 @@ sub generic_domain { source =3D> "default", model =3D> "virtio", mac =3D> "52:54:00:11:11:11", - filterref =3D> $filterref); + filterref =3D> $filterref, + filterparams =3D> \%filterparams); } } return $b; diff --git a/lib/Sys/Virt/TCK/DomainBuilder.pm b/lib/Sys/Virt/TCK/DomainBui= lder.pm index fb9a31f..83cea15 100644 --- a/lib/Sys/Virt/TCK/DomainBuilder.pm +++ b/lib/Sys/Virt/TCK/DomainBuilder.pm @@ -459,8 +459,14 @@ sub as_xml { type =3D> $interface->{model}); } if ($interface->{filterref}) { - $w->emptyTag("filterref", + $w->startTag("filterref", filter =3D> $interface->{filterref}); + foreach my $paramname (keys %{$interface->{filterparams}}) { + $w->emptyTag("parameter", + name =3D> $paramname, + value =3D> $interface->{filterparams}->{$para= mname}); + } + $w->endTag("filterref"); } $w->endTag("interface"); } diff --git a/scripts/nwfilter/220-no-ip-spoofing.t b/scripts/nwfilter/220-n= o-ip-spoofing.t index 9e1bb70..5a82526 100644 --- a/scripts/nwfilter/220-no-ip-spoofing.t +++ b/scripts/nwfilter/220-no-ip-spoofing.t @@ -42,10 +42,17 @@ END { $tck->cleanup if $tck; } =20 +my $networkip =3D get_network_ip($conn, "default"); +diag "network ip is $networkip"; + # create first domain and start it my $xml =3D $tck->generic_domain(name =3D> "tck", fullos =3D> 1, netmode =3D> "network", - filterref =3D> "clean-traffic")->as_xml(); + filterref =3D> "clean-traffic", + filterparams =3D> { + CTRL_IP_LEARNING =3D> "dhcp", + DHCPSERVER =3D> $networkip + })->as_xml(); =20 my $dom; ok_domain(sub { $dom =3D $conn->define_domain($xml) }, "created persistent= domain object"); --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list