From patchwork Mon Oct 18 19:07:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mike Pattrick X-Patchwork-Id: 1542847 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.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=W31KPpC1; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::137; helo=smtp4.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from smtp4.osuosl.org (smtp4.osuosl.org [IPv6:2605:bc80:3010::137]) (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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4HY5yJ1Mcmz9sR4 for ; Tue, 19 Oct 2021 06:08:51 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 7383E40190; Mon, 18 Oct 2021 19:08:46 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id MxevK7suHyeJ; Mon, 18 Oct 2021 19:08:45 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp4.osuosl.org (Postfix) with ESMTPS id 6FFBF404C4; Mon, 18 Oct 2021 19:08:13 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 5BBDFC000F; Mon, 18 Oct 2021 19:08:09 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by lists.linuxfoundation.org (Postfix) with ESMTP id 1EE6AC000D for ; Mon, 18 Oct 2021 19:08:05 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 0F6C34045C for ; Mon, 18 Oct 2021 19:08:01 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id JfQe4taFvW6X for ; Mon, 18 Oct 2021 19:07:58 +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 smtp4.osuosl.org (Postfix) with ESMTPS id 0A2A24022B for ; Mon, 18 Oct 2021 19:07:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1634584072; 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=jltJlTZgloI2AeQVi8jBI769QzlFcNKuGRSe/kDLNX4=; b=W31KPpC1uA+KhQ75to5gZw8nnqmR2AEh/Eva3lOh8HpqG8Qhze7ggiwnqMiI9IJJeotKGI GJmFCesZmP7+ChVu7SGuW3QUUcM+e2lAy5VJPIGfqpjBBnOSI25J2hrWvHQuWlCOgJB80a V0Q6MNHrDRTsWAM/1bnIvYnC9OK4TLg= Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-395-IHjdliziP5idjhDZl6uqAg-1; Mon, 18 Oct 2021 15:07:51 -0400 X-MC-Unique: IHjdliziP5idjhDZl6uqAg-1 Received: by mail-qt1-f198.google.com with SMTP id l14-20020ac8458e000000b002a7829805b8so11258977qtn.22 for ; Mon, 18 Oct 2021 12:07:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:subject:from:to:date:user-agent :mime-version:content-transfer-encoding; bh=jltJlTZgloI2AeQVi8jBI769QzlFcNKuGRSe/kDLNX4=; b=vYZcXUFU11u2qTg0+dK4ObyhK4zTYMcrra2ydetK5whVRTqU6zaXwDRxKJ1HV1if+H pCCPXiyBg3ewLuAcSyjrp8c45AG1X11wOMcXqJoPe68nOPmwI+5fP2ZUSh1lf5smzsTV 5Z2xOwIKRdq2bSOn4izyFc3NIyFmRzbMJfbz4NeVjIEcUugnx0GTkpfvvMdas1dHMx1v EVrqIpbQKFwtyAwYjmvBkK47Wi5i6p45tUfrTKI/SYosbBY2c4L5QMqJPuv/g8cyO62a xOOXEJLJCa7ugJ25gmAlVt+Rx0PlFX3nKLd7c3zXPtS5pfuafwr3fB1meNtnFO2ThShn PE0Q== X-Gm-Message-State: AOAM532/zaewlW183k1IQs2cKNH+llywrfyrilhsXLPpLwic12UtgroM XiXu3bjeY+PhOR5iMQm9ZT3cV7hFzqxrOZn1H7IUy/lu7yiZHJ5VGOuMVT6/ODmec5QItM9Ehn+ gLgfX45lRtL/rZBd7ohUKgo2e/8DorentFsxLmPQ0kIwvizUNLj5JioVSkA== X-Received: by 2002:a05:622a:1748:: with SMTP id l8mr27856795qtk.271.1634584070981; Mon, 18 Oct 2021 12:07:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxqaIP4tiEEkVmIKj1weKKHhE3P/GBtyZUn0AtoNlyBDKBa9BuHpQNNyHxygGXrUfBlz5uHzQ== X-Received: by 2002:a05:622a:1748:: with SMTP id l8mr27856764qtk.271.1634584070624; Mon, 18 Oct 2021 12:07:50 -0700 (PDT) Received: from [10.20.239.127] (199-167-117-1.ppp.storm.ca. [199.167.117.1]) by smtp.googlemail.com with ESMTPSA id f42sm2990342qtb.7.2021.10.18.12.07.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Oct 2021 12:07:50 -0700 (PDT) Message-ID: From: Mike Pattrick To: "dev@openvswitch.org" Date: Mon, 18 Oct 2021 15:07:48 -0400 User-Agent: Evolution 3.40.0-1 MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mkp@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [ovs-dev] [PATCH] netdev-linux: Ingress policing to use matchall if basic is not available. 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" Currently ingress policing uses the basic classifier to apply traffic control filters if hardware offload is not enabled, else it uses matchall. This change enables fallback onto the matchall classifier for cases when the kernel is not built with basic support and hardware  offload is not in use. Basic is still selected first. The system tests are modified to allow either basic or matchall classification on the ingestion filter, and to allow either 10000 or 10240 packets for the packet burst filter. 10000 is accurate for kernel 5.14 and the most recent iproute2, however, 10240 is left for compatibility with older kernels. Signed-off-by: Mike Pattrick --- lib/netdev-linux.c | 21 ++++++++++++++------- tests/system-offloads-traffic.at | 20 +++++++++----------- 2 files changed, 23 insertions(+), 18 deletions(-) diff --git a/lib/netdev-linux.c b/lib/netdev-linux.c index 97bd21be4..cb7ce1d2f 100644 --- a/lib/netdev-linux.c +++ b/lib/netdev-linux.c @@ -2776,8 +2776,7 @@ netdev_linux_set_policing(struct netdev *netdev_, uint32_t kbits_rate, error = tc_add_matchall_policer(netdev_, kbits_rate, kbits_burst, kpkts_rate, kpkts_burst); } - ovs_mutex_unlock(&netdev->mutex); - return error; + goto out; } error = get_ifindex(netdev_, &ifindex); @@ -2803,6 +2802,12 @@ netdev_linux_set_policing(struct netdev *netdev_, uint32_t kbits_rate, error = tc_add_policer(netdev_, kbits_rate, kbits_burst, kpkts_rate, kpkts_burst); + if (error == ENOENT) { + /* This error is returned when the basic classifier is missing. + * Fall back to the matchall classifier. */ + error = tc_add_matchall_policer(netdev_, kbits_rate, kbits_burst, + kpkts_rate, kpkts_burst); + } if (error){ VLOG_WARN_RL(&rl, "%s: adding policing action failed: %s", netdev_name, ovs_strerror(error)); @@ -2810,12 +2815,14 @@ netdev_linux_set_policing(struct netdev *netdev_, uint32_t kbits_rate, } } - netdev->kbits_rate = kbits_rate; - netdev->kbits_burst = kbits_burst; - netdev->kpkts_rate = kpkts_rate; - netdev->kpkts_burst = kpkts_burst; - out: + if (!error) { + netdev->kbits_rate = kbits_rate; + netdev->kbits_burst = kbits_burst; + netdev->kpkts_rate = kpkts_rate; + netdev->kpkts_burst = kpkts_burst; + } + if (!error || error == ENODEV) { netdev->netdev_policing_error = error; netdev->cache_valid |= VALID_POLICING; diff --git a/tests/system-offloads-traffic.at b/tests/system-offloads-traffic.at index be63057bb..80bc1dd5c 100644 --- a/tests/system-offloads-traffic.at +++ b/tests/system-offloads-traffic.at @@ -89,10 +89,8 @@ AT_CHECK([tc -o -s -d filter show dev ovs-p0 ingress | [0],[dnl rate 100Kbit burst 1280b ]) -AT_CHECK([tc -s -d filter show dev ovs-p0 ingress | grep basic | - sed -n 's/.*\(basic\).*/\1/; T; p; q'], [0], [dnl -basic -]) +AT_CHECK([tc -s -d filter show dev ovs-p0 ingress | + egrep "basic|matchall" > /dev/null], [0]) OVS_TRAFFIC_VSWITCHD_STOP AT_CLEANUP @@ -135,14 +133,13 @@ AT_CHECK([ovs-vsctl --columns=other_config list open], [0], [dnl other_config : {hw-offload="false"} ]) AT_CHECK([tc -o -s -d filter show dev ovs-p0 ingress | - sed -n 's/.*\(pkts_rate [[0-9]]*[[a-zA-Z]]* pkts_burst [[0-9]]*[[a-zA-Z]]*\).*/\1/; T; p; q'], + sed -n 's/.*\(pkts_rate [[0-9]]*[[a-zA-Z]]* pkts_burst [[0-9]]*[[a-zA-Z]]*\).*/\1/; T; p; q' | + sed -e 's/10240/10000/'], [0],[dnl -pkts_rate 100000 pkts_burst 10240 +pkts_rate 100000 pkts_burst 10000 ]) AT_CHECK([tc -s -d filter show dev ovs-p0 ingress | - sed -n 's/.*\(basic\).*/\1/; T; p; q'], [0], [dnl -basic -]) + egrep "basic|matchall" > /dev/null], [0]) OVS_TRAFFIC_VSWITCHD_STOP AT_CLEANUP @@ -160,9 +157,10 @@ AT_CHECK([ovs-vsctl --columns=other_config list open], [0], [dnl other_config : {hw-offload="true"} ]) AT_CHECK([tc -o -s -d filter show dev ovs-p0 ingress | - sed -n 's/.*\(pkts_rate [[0-9]]*[[a-zA-Z]]* pkts_burst [[0-9]]*[[a-zA-Z]]*\).*/\1/; T; p; q'], + sed -n 's/.*\(pkts_rate [[0-9]]*[[a-zA-Z]]* pkts_burst [[0-9]]*[[a-zA-Z]]*\).*/\1/; T; p; q' | + sed -e 's/10240/10000/'], [0],[dnl -pkts_rate 100000 pkts_burst 10240 +pkts_rate 100000 pkts_burst 10000 ]) AT_CHECK([tc -s -d filter show dev ovs-p0 ingress | sed -n 's/.*\(matchall\).*/\1/; T; p; q'], [0], [dnl