From patchwork Tue Sep 15 23:54:21 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jarno Rajahalme X-Patchwork-Id: 518140 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from archives.nicira.com (li376-54.members.linode.com [96.126.127.54]) by ozlabs.org (Postfix) with ESMTP id E6C01140187 for ; Wed, 16 Sep 2015 09:54:37 +1000 (AEST) Received: from archives.nicira.com (localhost [127.0.0.1]) by archives.nicira.com (Postfix) with ESMTP id 7E9EF10A91; Tue, 15 Sep 2015 16:54:33 -0700 (PDT) X-Original-To: dev@openvswitch.org Delivered-To: dev@openvswitch.org Received: from mx3v1.cudamail.com (mx3.cudamail.com [64.34.241.5]) by archives.nicira.com (Postfix) with ESMTPS id 0F86210A67 for ; Tue, 15 Sep 2015 16:54:32 -0700 (PDT) Received: from bar4.cudamail.com (bar2 [192.168.15.2]) by mx3v1.cudamail.com (Postfix) with ESMTP id 8FB476180D9 for ; Tue, 15 Sep 2015 17:54:31 -0600 (MDT) X-ASG-Debug-ID: 1442361270-03dc2135eb00950001-byXFYA Received: from mx3-pf1.cudamail.com ([192.168.14.2]) by bar4.cudamail.com with ESMTP id OARuwHEJhbkkHysC (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Tue, 15 Sep 2015 17:54:30 -0600 (MDT) X-Barracuda-Envelope-From: jrajahalme@nicira.com X-Barracuda-RBL-Trusted-Forwarder: 192.168.14.2 Received: from unknown (HELO mail-pa0-f43.google.com) (209.85.220.43) by mx3-pf1.cudamail.com with ESMTPS (RC4-SHA encrypted); 15 Sep 2015 23:54:30 -0000 Received-SPF: unknown (mx3-pf1.cudamail.com: Multiple SPF records returned) X-Barracuda-RBL-Trusted-Forwarder: 209.85.220.43 Received: by pacex6 with SMTP id ex6so190502171pac.0 for ; Tue, 15 Sep 2015 16:54:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=BhoNBKzTsqBM0Un23AMiwJkjt2DwF5LnX8613t4Sg3s=; b=dwOn/ub+svndZjiIyq6nWM5YDAMq/THF2dNwoqD5e2xbw1PfNZ8B/dtXnmqvLezDjn R2ErVdiZz6qN33v05YNxyCbO0r5ERgYYv6iRdhgzwnY8IjMeVrQrcN9+vpKHk/Xz0y4y +xK6k6A0B+eDSdocRA4/owuJIREggUMsGW4eua3z03vsQgoWKMH/Fi+IdXWdOhxuxTme 9/cb21yMLMJ2rydNRShMfmy1VngAdX3AF6WQOAcRiPyCtVRwofHutzxJ+N612thpIbr5 mFT+0+PEYSW5hAHz4bfsoTjU7HecKo5HzK4YoAeH293jocH8ftm5MzIo32gkufeXkX4r Pgiw== X-Gm-Message-State: ALoCoQl9mHX5AeBdDsv2YzbW0Ade8qgWQ+2uQxCiQPLxBu1Iu6R/scUo8gJhli10Uk78DasXnLGC X-Received: by 10.68.114.196 with SMTP id ji4mr53175202pbb.46.1442361270221; Tue, 15 Sep 2015 16:54:30 -0700 (PDT) Received: from sc9-mailhost1.vmware.com ([208.91.1.34]) by smtp.gmail.com with ESMTPSA id sb6sm18898231pbc.12.2015.09.15.16.54.29 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 15 Sep 2015 16:54:29 -0700 (PDT) X-CudaMail-Envelope-Sender: jrajahalme@nicira.com X-Barracuda-Apparent-Source-IP: 208.91.1.34 From: Jarno Rajahalme To: dev@openvswitch.org X-CudaMail-Whitelist-To: dev@openvswitch.org X-CudaMail-MID: CM-V1-914070117 X-CudaMail-DTE: 091515 X-CudaMail-Originating-IP: 209.85.220.43 Date: Tue, 15 Sep 2015 16:54:21 -0700 X-ASG-Orig-Subj: [##CM-V1-914070117##][PATCH v2 2/2] ofproto-dpif-upcall: Use flow_wildcards_has_extra(). Message-Id: <1442361261-8974-2-git-send-email-jrajahalme@nicira.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1442361261-8974-1-git-send-email-jrajahalme@nicira.com> References: <1442361261-8974-1-git-send-email-jrajahalme@nicira.com> X-Barracuda-Connect: UNKNOWN[192.168.14.2] X-Barracuda-Start-Time: 1442361270 X-Barracuda-Encrypted: DHE-RSA-AES256-SHA 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 v2 2/2] ofproto-dpif-upcall: Use flow_wildcards_has_extra(). 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" Update the comment in ukey_revalidate() to reflect the fact that the mask in ukey is not the datapath mask, but the originally translated flow wildcards. Use flow_wildcards_has_extra() instead of open coding equivalent (but different) functionality. The old form and the code in flow_wildcards_has_extra() ((dp | wc != dp) and (dp & wc != wc), respecively) give the same result: dp wc (dp | wc != dp) (dp & wc != wc) ------------------------------------------------------- 0 0 (0 | 0 != 0) (false) (0 & 0 != 0) (false) 0 1 (0 | 1 != 0) (true) (0 & 1 != 1) (true) 1 0 (1 | 0 != 1) (false) (1 & 0 != 0) (false) 1 1 (1 | 1 != 1) (false) (1 & 1 != 1) (false) Signed-off-by: Jarno Rajahalme Acked-by: Ben Pfaff --- ofproto/ofproto-dpif-upcall.c | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/ofproto/ofproto-dpif-upcall.c b/ofproto/ofproto-dpif-upcall.c index 8a43bbf..428258a 100644 --- a/ofproto/ofproto-dpif-upcall.c +++ b/ofproto/ofproto-dpif-upcall.c @@ -1769,15 +1769,13 @@ revalidate_ukey(struct udpif *udpif, struct udpif_key *ukey, struct netflow *netflow; struct ofproto_dpif *ofproto; struct dpif_flow_stats push; - struct flow flow, dp_mask; - struct flow_wildcards wc; + struct flow flow; + struct flow_wildcards dp_mask, wc; enum reval_result result; - uint64_t *dp64, *xout64; ofp_port_t ofp_in_port; struct xlate_in xin; long long int last_used; int error; - size_t i; bool need_revalidate; result = UKEY_DELETE; @@ -1854,21 +1852,18 @@ revalidate_ukey(struct udpif *udpif, struct udpif_key *ukey, } if (odp_flow_key_to_mask(ukey->mask, ukey->mask_len, ukey->key, - ukey->key_len, &dp_mask, &flow) == ODP_FIT_ERROR) { + ukey->key_len, &dp_mask.masks, &flow) + == ODP_FIT_ERROR) { goto exit; } - /* Since the kernel is free to ignore wildcarded bits in the mask, we can't - * directly check that the masks are the same. Instead we check that the - * mask in the kernel is more specific i.e. less wildcarded, than what - * we've calculated here. This guarantees we don't catch any packets we - * shouldn't with the megaflow. */ - dp64 = (uint64_t *) &dp_mask; - xout64 = (uint64_t *) &wc.masks; - for (i = 0; i < FLOW_U64S; i++) { - if ((dp64[i] | xout64[i]) != dp64[i]) { - goto exit; - } + /* Do not modify if any bit is wildcarded by the installed datapath flow, + * but not the newly revalidated wildcard mask (wc), i.e., if revalidation + * tells that the datapath flow is now too generic and must be narrowed + * down. Note that we do not know if the datapath has ignored any of the + * wildcarded bits, so we may be overtly conservative here. */ + if (flow_wildcards_has_extra(&dp_mask, &wc)) { + goto exit; } if (!ofpbuf_equal(odp_actions,