From patchwork Wed Nov 11 19:39:52 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Stringer X-Patchwork-Id: 543059 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from archives.nicira.com (unknown [IPv6:2600:3c00::f03c:91ff:fe6e:bdf7]) by ozlabs.org (Postfix) with ESMTP id 61B221402D1 for ; Thu, 12 Nov 2015 06:40:33 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=nicira_com.20150623.gappssmtp.com header.i=@nicira_com.20150623.gappssmtp.com header.b=h028SzEs; dkim-atps=neutral Received: from archives.nicira.com (localhost [127.0.0.1]) by archives.nicira.com (Postfix) with ESMTP id 2273722C3AC; Wed, 11 Nov 2015 11:40:11 -0800 (PST) X-Original-To: dev@openvswitch.org Delivered-To: dev@openvswitch.org Received: from mx1e3.cudamail.com (mx1.cudamail.com [69.90.118.67]) by archives.nicira.com (Postfix) with ESMTPS id 5EE9122C39D for ; Wed, 11 Nov 2015 11:40:09 -0800 (PST) Received: from bar2.cudamail.com (localhost [127.0.0.1]) by mx1e3.cudamail.com (Postfix) with ESMTPS id 91D694201B3 for ; Wed, 11 Nov 2015 12:40:08 -0700 (MST) X-ASG-Debug-ID: 1447270807-03dc5308822d1150001-byXFYA Received: from mx1-pf1.cudamail.com ([192.168.24.1]) by bar2.cudamail.com with ESMTP id qkcfdHAnDl0Np3Ra (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Wed, 11 Nov 2015 12:40:08 -0700 (MST) X-Barracuda-Envelope-From: joestringer@nicira.com X-Barracuda-RBL-Trusted-Forwarder: 192.168.24.1 Received: from unknown (HELO mail-pa0-f43.google.com) (209.85.220.43) by mx1-pf1.cudamail.com with ESMTPS (RC4-SHA encrypted); 11 Nov 2015 19:40:07 -0000 Received-SPF: unknown (mx1-pf1.cudamail.com: Multiple SPF records returned) X-Barracuda-RBL-Trusted-Forwarder: 209.85.220.43 Received: by pasz6 with SMTP id z6so40716834pas.2 for ; Wed, 11 Nov 2015 11:40:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nicira_com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=5CmbCHSsumqdesQXLLUYFyYfAe92utetsu4HHyByoME=; b=h028SzEsaSu9gruDESr7qDj83kaHFVw0oTvdq7g8KCGkCa/uNldpSaW7IrMKIn+AXu MUGUqX8QMxY87GXjaJD4bRklX8HVcXKYJe4kA1QUm5TKi3rBK6MLG045kBfO1FZI+PZg qLuSrWZ+s2+TEKpc7AAzhFyHgr1zn4BDwy6T/T1zG65lAXs8zsX+Qcv9DGU0HN1owooE Z+BB4RHQtfpJwqOlKwS1192dtCGGsf/K8kvF8gJ/jJ2xsdCyDjE3ulb6TSrCXgk5qjyQ 9UqUQSD2cljzNdt/rS0JX1iNKRSn9rlaZbgp1kigCG2f++I22faUai3liz6l2VH7sgyg FCBQ== 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=5CmbCHSsumqdesQXLLUYFyYfAe92utetsu4HHyByoME=; b=GApS3NdP0ndHs985yc3i7l46KYrfJqVXYv579xAdpEhqyZl5w5PACURBv0MRi9Skgk afaugyK5LmtjjZq3PKU3PHBd1sFCo75Uc8RkQUL/96wZgMnY+oUMlBEKDiz2Hw9/O57v n24PondGshmkbLNeZf4R1g48KNIlGDDPjwX2BTs6WtenlcnhKF5jiYcxCRbq4TftEk6C 2bKUOyHZyBTum8E/oqJVF6+D+5+Qfa56GC5FRKbHCFsStdppcSt5ra7FCGOvyf56l6/K rdGiBH5al3NJE7/mMesapEY7/8kD4+ro920hTvGPR2uqXk9hDuNKB1Tzix/oVXl9q4J3 83Aw== X-Gm-Message-State: ALoCoQkpVCWEhV5RGoY/eVsIxH8FBDqe4IJTxQaVeihpG6KKpD21k2natnhP34m3sHlpM3AoSsRS X-Received: by 10.66.142.106 with SMTP id rv10mr17317616pab.29.1447270806974; Wed, 11 Nov 2015 11:40:06 -0800 (PST) Received: from localhost.localdomain ([208.91.2.4]) by smtp.gmail.com with ESMTPSA id fn4sm1720587pab.46.2015.11.11.11.40.05 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 11 Nov 2015 11:40:06 -0800 (PST) X-CudaMail-Envelope-Sender: joestringer@nicira.com X-Barracuda-Apparent-Source-IP: 208.91.2.4 From: Joe Stringer To: dev@openvswitch.org X-CudaMail-Whitelist-To: dev@openvswitch.org X-CudaMail-MID: CM-E1-1110068700 X-CudaMail-DTE: 111115 X-CudaMail-Originating-IP: 209.85.220.43 Date: Wed, 11 Nov 2015 11:39:52 -0800 X-ASG-Orig-Subj: [##CM-E1-1110068700##][PATCHv2 4/6] ofp-actions: Refactor ofpact_get_mf_dst(). Message-Id: <1447270794-21103-5-git-send-email-joestringer@nicira.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1447270794-21103-1-git-send-email-joestringer@nicira.com> References: <1447270794-21103-1-git-send-email-joestringer@nicira.com> X-Barracuda-Connect: UNKNOWN[192.168.24.1] X-Barracuda-Start-Time: 1447270808 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] [PATCHv2 4/6] ofp-actions: Refactor ofpact_get_mf_dst(). 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" This function finds the mf destination field for any ofpact, returning NULL if not applicable. It will be used by the next patch to properly reject OpenFlow flows with conntrack actions when conntrack is unsupported by the datapath. Signed-off-by: Joe Stringer Acked-by: Jarno Rajahalme --- lib/ofp-actions.c | 18 +++++++++++------- lib/ofp-actions.h | 1 + 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/lib/ofp-actions.c b/lib/ofp-actions.c index 5f72fda16154..625e7b8168a8 100644 --- a/lib/ofp-actions.c +++ b/lib/ofp-actions.c @@ -6270,16 +6270,20 @@ ofpacts_check_consistency(struct ofpact ofpacts[], size_t ofpacts_len, : 0); } -static const struct mf_field * -ofpact_get_mf_field(enum ofpact_type type, const void *ofpact) +/* Returns the destination field that 'ofpact' would write to, or NULL + * if the action would not write to an mf_field. */ +const struct mf_field * +ofpact_get_mf_dst(const struct ofpact *ofpact) { - if (type == OFPACT_SET_FIELD) { - const struct ofpact_set_field *orl = ofpact; + if (ofpact->type == OFPACT_SET_FIELD) { + const struct ofpact_set_field *orl; + orl = CONTAINER_OF(ofpact, struct ofpact_set_field, ofpact); return orl->field; - } else if (type == OFPACT_REG_MOVE) { - const struct ofpact_reg_move *orm = ofpact; + } else if (ofpact->type == OFPACT_REG_MOVE) { + const struct ofpact_reg_move *orm; + orm = CONTAINER_OF(ofpact, struct ofpact_reg_move, ofpact); return orm->dst.field; } @@ -6304,7 +6308,7 @@ field_requires_ct(enum mf_field_id field) static enum ofperr ofpacts_verify_nested(const struct ofpact *a, enum ofpact_type outer_action) { - const struct mf_field *field = ofpact_get_mf_field(a->type, a); + const struct mf_field *field = ofpact_get_mf_dst(a); if (field && field_requires_ct(field->id) && outer_action != OFPACT_CT) { VLOG_WARN("cannot set CT fields outside of ct action"); diff --git a/lib/ofp-actions.h b/lib/ofp-actions.h index 773b6170474d..6d893eafc83e 100644 --- a/lib/ofp-actions.h +++ b/lib/ofp-actions.h @@ -821,6 +821,7 @@ bool ofpacts_output_to_group(const struct ofpact[], size_t ofpacts_len, uint32_t group_id); bool ofpacts_equal(const struct ofpact a[], size_t a_len, const struct ofpact b[], size_t b_len); +const struct mf_field *ofpact_get_mf_dst(const struct ofpact *ofpact); uint32_t ofpacts_get_meter(const struct ofpact[], size_t ofpacts_len); /* Formatting and parsing ofpacts. */