From patchwork Wed Dec 27 11:15:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mohammad Heib X-Patchwork-Id: 1880509 X-Patchwork-Delegate: horms@verge.net.au 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=jHfivV5m; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.136; helo=smtp3.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=patchwork.ozlabs.org) Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (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 4T0TbB52y2z23dT for ; Wed, 27 Dec 2023 22:15:50 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id D0A2060F92; Wed, 27 Dec 2023 11:15:47 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org D0A2060F92 Authentication-Results: smtp3.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=jHfivV5m X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 91txq-2Oh2kK; Wed, 27 Dec 2023 11:15:46 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp3.osuosl.org (Postfix) with ESMTPS id 765AE60F71; Wed, 27 Dec 2023 11:15:45 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 765AE60F71 Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 2B427C007C; Wed, 27 Dec 2023 11:15:45 +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 23297C0072 for ; Wed, 27 Dec 2023 11:15:44 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 0ADF381EEE for ; Wed, 27 Dec 2023 11:15:44 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 0ADF381EEE Authentication-Results: smtp1.osuosl.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=jHfivV5m 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 GPQyPI3yDFHn for ; Wed, 27 Dec 2023 11:15:42 +0000 (UTC) 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 A8CD481EBC for ; Wed, 27 Dec 2023 11:15:42 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org A8CD481EBC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1703675741; 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: in-reply-to:in-reply-to:references:references; bh=WwPBx6KnhaN6pJKzD5N1A3JfBcOicMWupdxJ7tbFzXY=; b=jHfivV5mCpVzpWbt/e22NtDuyx0nAsGuyOL+jKA3ZJNSAgqpXsx23m+xcUWHpSBKaVYIHL Kgbt9uSctWEFy54LbOpp3gyYyIqA9kNNKQCYCv2vSXe63aktzgJg0FBvazabcl2VIfZg7a DJdERyQuXBwZvEPW2ulVa/GWB0emS9M= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-302-Xza7DZygM_G_KJxiNyDLeQ-1; Wed, 27 Dec 2023 06:15:39 -0500 X-MC-Unique: Xza7DZygM_G_KJxiNyDLeQ-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (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 8C5F88350E3 for ; Wed, 27 Dec 2023 11:15:39 +0000 (UTC) Received: from mheiblap.localdomain (unknown [10.47.238.119]) by smtp.corp.redhat.com (Postfix) with ESMTP id DE87B40C6EB9; Wed, 27 Dec 2023 11:15:38 +0000 (UTC) From: Mohammad Heib To: dev@openvswitch.org Date: Wed, 27 Dec 2023 13:15:23 +0200 Message-Id: <20231227111523.3061395-2-mheib@redhat.com> In-Reply-To: <20231227111523.3061395-1-mheib@redhat.com> References: <20231227111523.3061395-1-mheib@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.2 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [ovs-dev] [PATCH v6 2/2] mcast-snooping: Add group protocol to mdb/show output. 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" Expose the mcast group protocol via the mdb/show command output. Signed-off-by: Mohammad Heib --- lib/mcast-snooping.c | 24 ++++++++ lib/mcast-snooping.h | 1 + ofproto/ofproto-dpif.c | 9 ++- tests/mcast-snooping.at | 130 ++++++++++++++++++++++++++++++++-------- tests/stp.at | 6 +- 5 files changed, 139 insertions(+), 31 deletions(-) diff --git a/lib/mcast-snooping.c b/lib/mcast-snooping.c index 995216a4b..60ef8381e 100644 --- a/lib/mcast-snooping.c +++ b/lib/mcast-snooping.c @@ -57,6 +57,30 @@ mcast_snooping_flood_unreg(const struct mcast_snooping *ms) return ms->flood_unreg; } +char * +mcast_snooping_group_protocol_str(mcast_group_proto grp_proto) +{ + switch (grp_proto) { + case MCAST_GROUP_IGMPV1: + return "IGMPv1"; + break; + case MCAST_GROUP_IGMPV2: + return "IGMPv2"; + break; + case MCAST_GROUP_IGMPV3: + return "IGMPv3"; + break; + case MCAST_GROUP_MLDV1: + return "MLDv1"; + break; + case MCAST_GROUP_MLDV2: + return "MLDv2"; + break; + default: + return "UNKNOWN"; + } +} + bool mcast_snooping_is_query(ovs_be16 igmp_type) { diff --git a/lib/mcast-snooping.h b/lib/mcast-snooping.h index 8cc8fb0fb..acd9fdb68 100644 --- a/lib/mcast-snooping.h +++ b/lib/mcast-snooping.h @@ -224,6 +224,7 @@ bool mcast_snooping_add_mrouter(struct mcast_snooping *ms, uint16_t vlan, OVS_REQ_WRLOCK(ms->rwlock); bool mcast_snooping_is_query(ovs_be16 igmp_type); bool mcast_snooping_is_membership(ovs_be16 igmp_type); +char * mcast_snooping_group_protocol_str(mcast_group_proto grp_proto); /* Flush. */ void mcast_snooping_mdb_flush(struct mcast_snooping *ms); diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c index 6e62ed1f9..434ea1670 100644 --- a/ofproto/ofproto-dpif.c +++ b/ofproto/ofproto-dpif.c @@ -6172,7 +6172,7 @@ ofproto_unixctl_mcast_snooping_show(struct unixctl_conn *conn, return; } - ds_put_cstr(&ds, " port VLAN GROUP Age\n"); + ds_put_cstr(&ds, " port VLAN protocol GROUP Age\n"); ovs_rwlock_rdlock(&ofproto->ms->rwlock); LIST_FOR_EACH (grp, group_node, &ofproto->ms->group_lru) { LIST_FOR_EACH(b, bundle_node, &grp->bundle_lru) { @@ -6181,7 +6181,9 @@ ofproto_unixctl_mcast_snooping_show(struct unixctl_conn *conn, bundle = b->port; ofputil_port_to_string(ofbundle_get_a_port(bundle)->up.ofp_port, NULL, name, sizeof name); - ds_put_format(&ds, "%5s %4d ", name, grp->vlan); + ds_put_format(&ds, "%5s %4d %8s ", name, grp->vlan, + mcast_snooping_group_protocol_str( + grp->protocol_version)); ipv6_format_mapped(&grp->addr, &ds); ds_put_format(&ds, " %3d\n", mcast_bundle_age(ofproto->ms, b)); @@ -6195,8 +6197,9 @@ ofproto_unixctl_mcast_snooping_show(struct unixctl_conn *conn, bundle = mrouter->port; ofputil_port_to_string(ofbundle_get_a_port(bundle)->up.ofp_port, NULL, name, sizeof name); - ds_put_format(&ds, "%5s %4d querier %3d\n", + ds_put_format(&ds, "%5s %4d %8s querier %3d\n", name, mrouter->vlan, + mcast_snooping_group_protocol_str(-1), mcast_mrouter_age(ofproto->ms, mrouter)); } ovs_rwlock_unlock(&ofproto->ms->rwlock); diff --git a/tests/mcast-snooping.at b/tests/mcast-snooping.at index 890e6aca0..800a77504 100644 --- a/tests/mcast-snooping.at +++ b/tests/mcast-snooping.at @@ -44,9 +44,9 @@ AT_CHECK([ovs-appctl netdev-dummy/receive p2 \ '01005e0000015c8a38552552810006c0080046c000240000000001027c00ac111c01e0000001940400001164ec1e00000000027d000000000000000000000000']) AT_CHECK([ovs-appctl mdb/show br0], [0], [dnl - port VLAN GROUP Age - 2 1725 querier 0 - 2 1728 querier 0 + port VLAN protocol GROUP Age + 2 1725 UNKNOWN querier 0 + 2 1728 UNKNOWN querier 0 ]) AT_CHECK([ovs-vsctl set Interface p2 options:tx_pcap=p2.pcap]) @@ -75,7 +75,7 @@ AT_CHECK([ovs-appctl netdev-dummy/receive p2 \ '01005e0000015c8a38552552810006bd080046c000240000000001027f00ac111901e0000001940400001164ec1000000000027d000000000000000000000000']) AT_CHECK([ovs-appctl mdb/show br0], [0], [dnl - port VLAN GROUP Age + port VLAN protocol GROUP Age ]) @@ -87,8 +87,8 @@ AT_CHECK([ovs-appctl netdev-dummy/receive p2 \ '3333ff0e4c67000c290e4c6786dd600000000020000100000000000000000000000000000000ff0200000000000000000001ff0e4c673a000502000001008300e7b800000000ff0200000000000000000001ff0e4c67']) AT_CHECK([ovs-appctl mdb/show br0], [0], [dnl - port VLAN GROUP Age - 2 0 ff02::1:ff0e:4c67 0 + port VLAN protocol GROUP Age + 2 0 MLDv1 ff02::1:ff0e:4c67 0 ]) AT_CHECK([ovs-appctl mdb/flush br0], [0], [dnl @@ -99,7 +99,7 @@ AT_CHECK([ovs-appctl netdev-dummy/receive p2 \ '3333ff0e4c67000c290e4c6786dd600000000020000100000000000000000000000000000000ff0200000000000000000001ff0e4c673a000502000001008300e7b000000000ff0200000000000000000001ff0e4c67']) AT_CHECK([ovs-appctl mdb/show br0], [0], [dnl - port VLAN GROUP Age + port VLAN protocol GROUP Age ]) OVS_VSWITCHD_STOP @@ -154,8 +154,8 @@ AT_CHECK([ '01005E010101000C29A027A108004500001C000100004002CBAEAC10221EE001010112140CE9E0010101' ], [0]) AT_CHECK([ovs-appctl mdb/show br0], [0], [dnl - port VLAN GROUP Age - 1 0 224.1.1.1 0 + port VLAN protocol GROUP Age + 1 0 IGMPv1 224.1.1.1 0 ]) AT_CHECK([ovs-appctl ofproto/trace "in_port(3),eth(src=aa:55:aa:55:00:ff,dst=01:00:5e:01:01:01),eth_type(0x0800),ipv4(src=10.0.0.1,dst=224.1.1.1,proto=17,tos=0,ttl=64,frag=no),udp(src=0,dst=8000)"], [0], [dnl @@ -467,19 +467,19 @@ AT_CHECK([ ], [0]) AT_CHECK([ovs-appctl mdb/show br0], [0], [dnl - port VLAN GROUP Age - 1 1 224.1.1.1 0 - 1 2 224.1.1.1 0 - 3 1 querier 0 - 3 2 querier 0 + port VLAN protocol GROUP Age + 1 1 IGMPv1 224.1.1.1 0 + 1 2 IGMPv1 224.1.1.1 0 + 3 1 UNKNOWN querier 0 + 3 2 UNKNOWN querier 0 ]) AT_CHECK([ovs-vsctl set port p3 tag=2], [0]) AT_CHECK([ovs-appctl mdb/show br0], [0], [dnl - port VLAN GROUP Age - 1 1 224.1.1.1 0 - 1 2 224.1.1.1 0 + port VLAN protocol GROUP Age + 1 1 IGMPv1 224.1.1.1 0 + 1 2 IGMPv1 224.1.1.1 0 ]) AT_CLEANUP @@ -522,19 +522,19 @@ AT_CHECK([ ], [0]) AT_CHECK([ovs-appctl mdb/show br0], [0], [dnl - port VLAN GROUP Age - 1 1 224.1.1.1 0 - 1 2 224.1.1.1 0 - 2 1 querier 0 - 2 2 querier 0 + port VLAN protocol GROUP Age + 1 1 IGMPv1 224.1.1.1 0 + 1 2 IGMPv1 224.1.1.1 0 + 2 1 UNKNOWN querier 0 + 2 2 UNKNOWN querier 0 ]) AT_CHECK([ovs-vsctl del-port br0 p2], [0]) AT_CHECK([ovs-appctl mdb/show br0], [0], [dnl - port VLAN GROUP Age - 1 1 224.1.1.1 0 - 1 2 224.1.1.1 0 + port VLAN protocol GROUP Age + 1 1 IGMPv1 224.1.1.1 0 + 1 2 IGMPv1 224.1.1.1 0 ]) AT_CLEANUP @@ -605,3 +605,83 @@ recirc_id(),in_port(1),ct_state(+new-inv+trk),eth_type(0x0800),ipv4(prot ]) AT_CLEANUP + +AT_SETUP([mcast - mcast_group protocol updated in mdb]) +OVS_VSWITCHD_START([]) + +AT_CHECK([ + ovs-vsctl set bridge br0 \ + datapath_type=dummy \ + mcast_snooping_enable=true \ +], [0]) + +AT_CHECK([ovs-ofctl add-flow br0 action=normal]) + +AT_CHECK([ + ovs-vsctl add-port br0 p1 -- set Interface p1 type=dummy \ + other-config:hwaddr=aa:55:aa:55:00:01 ofport_request=1 \ +], [0]) + +# Send IGMPv1 report packet. +AT_CHECK([ + ovs-appctl netdev-dummy/receive p1 \ + '01005E010101000C29A027A18100000008004500001C000100004002CBAEAC10221EE001010112140CE9E0010101' +], [0]) + +# Send IGMPv2 report packet. +AT_CHECK([ + ovs-appctl netdev-dummy/receive p1 \ + '01005e010102505400000103080046c00020000040000102f8110a000103e001010294040000160008fce0010102' +], [0]) + +# Send IGMPv3 report packet. +AT_CHECK([ + ovs-appctl netdev-dummy/receive p1 \ + '01005e000016505400000003080046c00028000040000102f9f60a000003e0000016940400002200e3e10000000104000000e9360ce6' +], [0]) + +# Check that all the ipv4 mcast groups were updated in +# the mdb with the appropriate protocol. +AT_CHECK([ovs-appctl mdb/show br0], [0], [dnl + port VLAN protocol GROUP Age + 1 0 IGMPv1 224.1.1.1 0 + 1 0 IGMPv2 224.1.1.2 0 + 1 0 IGMPv3 233.54.12.230 0 +]) + +# Send IGMPv1 report packet to address 224.1.1.2 +# and make sure that the protocol will be updated to +# IGMPV1. +AT_CHECK([ + ovs-appctl netdev-dummy/receive p1 \ + '01005e010102505400000103080046c00020000040000102f8110a000103e00101029404000012000cfce0010102' +], [0]) + +AT_CHECK([ovs-appctl mdb/show br0], [0], [dnl + port VLAN protocol GROUP Age + 1 0 IGMPv1 224.1.1.1 0 + 1 0 IGMPv3 233.54.12.230 0 + 1 0 IGMPv1 224.1.1.2 0 +]) + +# Flush the mdb. +AT_CHECK([ovs-appctl mdb/flush br0], [0], [dnl +table successfully flushed +]) + +# Send MLDV2 packet. +AT_CHECK([ovs-appctl netdev-dummy/receive p1 \ +'333300000016d0509956ddf986dd60000000001c3a01fe80000000000000712065589886fa88ff0200000000000000000000000000168f00134d0000000104000000ff0200000000000000000001ff52f3e1']) + +# Send MLDV1 packet. +AT_CHECK([ovs-appctl netdev-dummy/receive p1 \ +'3333ff0e4c67000c290e4c6786dd600000000020000100000000000000000000000000000000ff0200000000000000000001ff0e4c673a000502000001008300e7b800000000ff0200000000000000000001ff0e4c67']) + +# Check that all the ipv6 mcast groups were updated in +# the mdb with the appropriate protocol. +AT_CHECK([ovs-appctl mdb/show br0], [0], [dnl + port VLAN protocol GROUP Age + 1 0 MLDv2 ff02::1:ff52:f3e1 0 + 1 0 MLDv1 ff02::1:ff0e:4c67 0 +]) +AT_CLEANUP diff --git a/tests/stp.at b/tests/stp.at index a6b6465d1..e7bf3958a 100644 --- a/tests/stp.at +++ b/tests/stp.at @@ -583,13 +583,13 @@ AT_CHECK([ovs-appctl fdb/show br2], [0], [dnl ]) AT_CHECK([ovs-appctl mdb/show br0], [0], [dnl - port VLAN GROUP Age + port VLAN protocol GROUP Age ]) AT_CHECK([ovs-appctl mdb/show br1], [0], [dnl - port VLAN GROUP Age + port VLAN protocol GROUP Age ]) AT_CHECK([ovs-appctl mdb/show br2], [0], [dnl - port VLAN GROUP Age + port VLAN protocol GROUP Age ]) AT_CLEANUP