From patchwork Thu Aug 18 21:50:09 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Stringer X-Patchwork-Id: 660547 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from archives.nicira.com (archives.nicira.com [96.126.127.54]) by ozlabs.org (Postfix) with ESMTP id 3sFfsW2xS7z9sCY for ; Fri, 19 Aug 2016 07:50:23 +1000 (AEST) Received: from archives.nicira.com (localhost [127.0.0.1]) by archives.nicira.com (Postfix) with ESMTP id 9F54F10AC1; Thu, 18 Aug 2016 14:50:22 -0700 (PDT) X-Original-To: dev@openvswitch.org Delivered-To: dev@openvswitch.org Received: from mx1e4.cudamail.com (mx1.cudamail.com [69.90.118.67]) by archives.nicira.com (Postfix) with ESMTPS id B7BDA10874 for ; Thu, 18 Aug 2016 14:50:21 -0700 (PDT) Received: from bar5.cudamail.com (unknown [192.168.21.12]) by mx1e4.cudamail.com (Postfix) with ESMTPS id 3F6371E013A for ; Thu, 18 Aug 2016 15:50:21 -0600 (MDT) X-ASG-Debug-ID: 1471557020-09eadd4c6551f20001-byXFYA Received: from mx1-pf1.cudamail.com ([192.168.24.1]) by bar5.cudamail.com with ESMTP id tI3sPhQG3E1pRDZe (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Thu, 18 Aug 2016 15:50:20 -0600 (MDT) X-Barracuda-Envelope-From: joe@ovn.org X-Barracuda-RBL-Trusted-Forwarder: 192.168.24.1 Received: from unknown (HELO relay6-d.mail.gandi.net) (217.70.183.198) by mx1-pf1.cudamail.com with ESMTPS (DHE-RSA-AES256-SHA encrypted); 18 Aug 2016 21:50:20 -0000 Received-SPF: pass (mx1-pf1.cudamail.com: SPF record at ovn.org designates 217.70.183.198 as permitted sender) X-Barracuda-Apparent-Source-IP: 217.70.183.198 X-Barracuda-RBL-IP: 217.70.183.198 Received: from mfilter48-d.gandi.net (mfilter48-d.gandi.net [217.70.178.179]) by relay6-d.mail.gandi.net (Postfix) with ESMTP id 10284FB882; Thu, 18 Aug 2016 23:50:19 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at mfilter48-d.gandi.net Received: from relay6-d.mail.gandi.net ([IPv6:::ffff:217.70.183.198]) by mfilter48-d.gandi.net (mfilter48-d.gandi.net [::ffff:10.0.15.180]) (amavisd-new, port 10024) with ESMTP id AvH7OLUSBapk; Thu, 18 Aug 2016 23:50:17 +0200 (CEST) X-Originating-IP: 208.91.1.34 Received: from archer.eng.vmware.com (unknown [208.91.1.34]) (Authenticated sender: joe@ovn.org) by relay6-d.mail.gandi.net (Postfix) with ESMTPSA id BB1FBFB89E; Thu, 18 Aug 2016 23:50:16 +0200 (CEST) X-CudaMail-Envelope-Sender: joe@ovn.org From: Joe Stringer To: dev@openvswitch.org X-CudaMail-Whitelist-To: dev@openvswitch.org X-CudaMail-MID: CM-E1-817072134 X-CudaMail-DTE: 081816 X-CudaMail-Originating-IP: 217.70.183.198 Date: Thu, 18 Aug 2016 14:50:09 -0700 X-ASG-Orig-Subj: [##CM-E1-817072134##][PATCH] upcall: Log failure to flow_put for dpif-netlink. Message-Id: <20160818215009.31964-1-joe@ovn.org> X-Mailer: git-send-email 2.9.2 X-Barracuda-Connect: UNKNOWN[192.168.24.1] X-Barracuda-Start-Time: 1471557020 X-Barracuda-Encrypted: ECDHE-RSA-AES256-GCM-SHA384 X-Barracuda-URL: https://web.cudamail.com:443/cgi-mod/mark.cgi X-ASG-Whitelist: Header =?UTF-8?B?eFwtY3VkYW1haWxcLXdoaXRlbGlzdFwtdG8=?= X-Virus-Scanned: by bsmtpd at cudamail.com X-Barracuda-BRTS-Status: 1 Subject: [ovs-dev] [PATCH] upcall: Log failure to flow_put for dpif-netlink. X-BeenThere: dev@openvswitch.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dev-bounces@openvswitch.org Sender: "dev" Previously these errors were only logged for dpif-netdev. Make it consistent by merging the code for both datapaths. Signed-off-by: Joe Stringer Acked-by: Jarno Rajahalme --- This could be handy for debugging on v2.6, so modulo any objections I intend to apply it there too. --- ofproto/ofproto-dpif-upcall.c | 57 +++++++++++++++++++++---------------------- 1 file changed, 28 insertions(+), 29 deletions(-) diff --git a/ofproto/ofproto-dpif-upcall.c b/ofproto/ofproto-dpif-upcall.c index c83df9ea8648..9e1730b2c6d5 100644 --- a/ofproto/ofproto-dpif-upcall.c +++ b/ofproto/ofproto-dpif-upcall.c @@ -1133,6 +1133,32 @@ upcall_uninit(struct upcall *upcall) } } +/* If there are less flows than the limit, and this is a miss upcall which + * + * - Has no recirc_id, OR + * - Has a recirc_id and we can get a reference on the recirc ctx, + * + * Then we should install the flow (true). Otherwise, return false. */ +static bool should_install_flow(struct udpif *udpif, struct upcall *upcall) +{ + unsigned int flow_limit; + + if (upcall->type != DPIF_UC_MISS) { + return false; + } else if (upcall->recirc && !upcall->have_recirc_ref) { + VLOG_WARN_RL(&rl, "upcall: no reference for recirc flow"); + return false; + } + + atomic_read_relaxed(&udpif->flow_limit, &flow_limit); + if (udpif_get_n_flows(udpif) >= flow_limit) { + VLOG_WARN_RL(&rl, "upcall: datapath flow limit reached"); + return false; + } + + return true; +} + static int upcall_cb(const struct dp_packet *packet, const struct flow *flow, ovs_u128 *ufid, unsigned pmd_id, enum dpif_upcall_type type, @@ -1141,13 +1167,11 @@ upcall_cb(const struct dp_packet *packet, const struct flow *flow, ovs_u128 *ufi { static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 1); struct udpif *udpif = aux; - unsigned int flow_limit; struct upcall upcall; bool megaflow; int error; atomic_read_relaxed(&enable_megaflows, &megaflow); - atomic_read_relaxed(&udpif->flow_limit, &flow_limit); error = upcall_receive(&upcall, udpif->backer, packet, type, userdata, flow, 0, ufid, pmd_id); @@ -1169,16 +1193,7 @@ upcall_cb(const struct dp_packet *packet, const struct flow *flow, ovs_u128 *ufi flow_wildcards_init_for_packet(wc, flow); } - if (udpif_get_n_flows(udpif) >= flow_limit) { - VLOG_WARN_RL(&rl, "upcall_cb failure: datapath flow limit reached"); - error = ENOSPC; - goto out; - } - - /* Prevent miss flow installation if the key has recirculation ID but we - * were not able to get a reference on it. */ - if (type == DPIF_UC_MISS && upcall.recirc && !upcall.have_recirc_ref) { - VLOG_WARN_RL(&rl, "upcall_cb failure: no reference for recirc flow"); + if (!should_install_flow(udpif, &upcall)) { error = ENOSPC; goto out; } @@ -1297,13 +1312,7 @@ handle_upcalls(struct udpif *udpif, struct upcall *upcalls, { struct dpif_op *opsp[UPCALL_MAX_BATCH * 2]; struct ukey_op ops[UPCALL_MAX_BATCH * 2]; - unsigned int flow_limit; size_t n_ops, n_opsp, i; - bool may_put; - - atomic_read_relaxed(&udpif->flow_limit, &flow_limit); - - may_put = udpif_get_n_flows(udpif) < flow_limit; /* Handle the packets individually in order of arrival. * @@ -1321,17 +1330,7 @@ handle_upcalls(struct udpif *udpif, struct upcall *upcalls, const struct dp_packet *packet = upcall->packet; struct ukey_op *op; - /* Do not install a flow into the datapath if: - * - * - The datapath already has too many flows. - * - * - We received this packet via some flow installed in the kernel - * already. - * - * - Upcall was a recirculation but we do not have a reference to - * to the recirculation ID. */ - if (may_put && upcall->type == DPIF_UC_MISS && - (!upcall->recirc || upcall->have_recirc_ref)) { + if (should_install_flow(udpif, upcall)) { struct udpif_key *ukey = upcall->ukey; upcall->ukey_persists = true;