From patchwork Tue Sep 1 11:44:39 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: ambikaarora92@gmail.com X-Patchwork-Id: 512786 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 40447140761 for ; Tue, 1 Sep 2015 21:45:05 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=FeQeWtsm; dkim-atps=neutral Received: from archives.nicira.com (localhost [127.0.0.1]) by archives.nicira.com (Postfix) with ESMTP id B5369106D1; Tue, 1 Sep 2015 04:45:04 -0700 (PDT) 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 ABD82106D0 for ; Tue, 1 Sep 2015 04:45:03 -0700 (PDT) Received: from bar2.cudamail.com (localhost [127.0.0.1]) by mx1e3.cudamail.com (Postfix) with ESMTPS id EA7934204C5 for ; Tue, 1 Sep 2015 05:45:02 -0600 (MDT) X-ASG-Debug-ID: 1441107901-03dc53768c0c5a0001-byXFYA Received: from mx1-pf2.cudamail.com ([192.168.24.2]) by bar2.cudamail.com with ESMTP id 0gH0ncGtZfpAwpsV (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Tue, 01 Sep 2015 05:45:01 -0600 (MDT) X-Barracuda-Envelope-From: ambikaarora92@gmail.com X-Barracuda-RBL-Trusted-Forwarder: 192.168.24.2 Received: from unknown (HELO mail-pa0-f45.google.com) (209.85.220.45) by mx1-pf2.cudamail.com with ESMTPS (RC4-SHA encrypted); 1 Sep 2015 11:45:01 -0000 Received-SPF: pass (mx1-pf2.cudamail.com: SPF record at _netblocks.google.com designates 209.85.220.45 as permitted sender) X-Barracuda-RBL-Trusted-Forwarder: 209.85.220.45 Received: by pader10 with SMTP id er10so4315248pad.3 for ; Tue, 01 Sep 2015 04:45:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=JdScpUObwKycIZ8stqil7sUGLMsvBuXq0/BlOdPlMY8=; b=FeQeWtsmPhA7L1AHqlOBYuS+BWRIvEaxQ36fD0bN22jw0H6imB2XLgnQ+/XBE/ib4r 0NhPLCUQPhSX30Mg8JRyAZ2UydnofuanvZ1onMUvNXSLMJN7OmuUutGL6O3pvMzQkpm9 Is13ITx68ncOMs8VsuH2mV/rgjPSOSFSBZovOrqPYHGr07WaCW7TyIjEXuHMx9NfCott 9JWPuI2yQpRRWsw10nX+5Wf3RF1Nfd8HIB7FyeL4VgzOu7+Em+hMyHLj3Veqh77UUkW3 UPrlm3ZQdQ1sLS30Cg5/3Nk5Bexyd4imdbWFjAO24YDoT0ePVuBlWwsJDq5RQeETreX3 tGdg== X-Received: by 10.69.26.196 with SMTP id ja4mr44824531pbd.121.1441107900672; Tue, 01 Sep 2015 04:45:00 -0700 (PDT) Received: from localhost.localdomain ([117.247.167.187]) by smtp.gmail.com with ESMTPSA id mw3sm17897808pdb.76.2015.09.01.04.44.57 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 01 Sep 2015 04:44:59 -0700 (PDT) X-CudaMail-Envelope-Sender: ambikaarora92@gmail.com X-Barracuda-Apparent-Source-IP: 117.247.167.187 From: ambikaarora92@gmail.com X-Google-Original-From: ambika.arora@tcs.com To: dev@openvswitch.org X-CudaMail-MID: CM-E2-831010345 X-CudaMail-DTE: 090115 X-CudaMail-Originating-IP: 209.85.220.45 Date: Tue, 1 Sep 2015 17:14:39 +0530 X-ASG-Orig-Subj: [##CM-E2-831010345##][PATCH v1] ofproto: Implement OF1.4 error code for set-async-config Message-Id: <1441107879-15904-1-git-send-email-ambika.arora@tcs.com> X-Mailer: git-send-email 2.5.0 X-GBUdb-Analysis: 0, 209.85.220.45, Ugly c=0.457817 p=-0.482353 Source Normal X-MessageSniffer-Rules: 0-0-0-16416-c X-Barracuda-Connect: UNKNOWN[192.168.24.2] X-Barracuda-Start-Time: 1441107901 X-Barracuda-Encrypted: DHE-RSA-AES256-SHA X-Barracuda-URL: https://web.cudamail.com:443/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at cudamail.com X-Barracuda-BRTS-Status: 1 X-Barracuda-Spam-Score: 0.60 X-Barracuda-Spam-Status: No, SCORE=0.60 using per-user scores of TAG_LEVEL=3.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=3.0 tests=BSF_SC5_MJ1963, DKIM_SIGNED, NO_REAL_NAME, RDNS_NONE X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.22117 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- 0.00 NO_REAL_NAME From: does not include a real name 0.00 DKIM_SIGNED Domain Keys Identified Mail: message has a signature 0.10 RDNS_NONE Delivered to trusted network by a host with no rDNS 0.50 BSF_SC5_MJ1963 Custom Rule MJ1963 Cc: deepankar.gupta@tcs.com, partha.datta@tcs.com Subject: [ovs-dev] [PATCH v1] ofproto: Implement OF1.4 error code for set-async-config 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" From: Ambika Arora This patch adds support for Openflow1.4 error codes for set-async-config. In this patch, a new error type, OFPET_ASYNC_CONFIG_FAILED is introduced that enables the switch to properly inform the controller when controller tries to set invalid mask or unsupported configuration. Signed-off-by: Ambika Arora --- lib/ofp-errors.h | 13 +++++++++++++ lib/ofp-print.c | 14 +++++++++++++- lib/ofp-util.c | 49 ++++++++++++++++++++++++++++++++++++++++++++----- ofproto/ofproto.c | 6 +++++- tests/ofp-print.at | 24 ++++++++++++++++++++++++ 5 files changed, 99 insertions(+), 7 deletions(-) diff --git a/lib/ofp-errors.h b/lib/ofp-errors.h index c020f7a..9c108d0 100644 --- a/lib/ofp-errors.h +++ b/lib/ofp-errors.h @@ -623,6 +623,19 @@ enum ofperr { /* ONF1.3(4448), OF1.4+(14,8). Permissions error. */ OFPERR_OFPBPC_EPERM, +/* ## -------------------------- ## */ +/* ## OFPET_ASYNC_CONFIG_FAILED ## */ +/* ## -------------------------- ## */ + + /* OF1.4+(15,0). One mask is invalid. */ + OFPERR_OFPACFC_INVALID, + + /* OF1.4+(15,1). Requested configuration not supported. */ + OFPERR_OFPACFC_UNSUPPORTED, + + /* OF1.4+(15,2). Permissions error. */ + OFPERR_OFPACFC_EPERM, + /* ## -------------------- ## */ /* ## OFPET_BUNDLE_FAILED ## */ /* ## -------------------- ## */ diff --git a/lib/ofp-print.c b/lib/ofp-print.c index 6e32d4d..f19d9be 100644 --- a/lib/ofp-print.c +++ b/lib/ofp-print.c @@ -2070,10 +2070,22 @@ ofp_print_nxt_set_async_config(struct ds *string, } } else if (raw == OFPRAW_OFPT14_SET_ASYNC || raw == OFPRAW_OFPT14_GET_ASYNC_REPLY) { + enum ofperr error = 0; uint32_t role[2][OAM_N_TYPES] = {{0}}; uint32_t type; - ofputil_decode_set_async_config(oh, role[0], role[1], true); + if (raw == OFPRAW_OFPT14_GET_ASYNC_REPLY) { + error = ofputil_decode_set_async_config(oh, role[0], role[1], true); + } + else if (raw == OFPRAW_OFPT14_SET_ASYNC) { + error = ofputil_decode_set_async_config(oh, role[0], role[1], + false); + } + if (error) { + ofp_print_error(string, error); + return; + } + for (i = 0; i < 2; i++) { ds_put_format(string, "\n %s:\n", i == 0 ? "master" : "slave"); diff --git a/lib/ofp-util.c b/lib/ofp-util.c index 5331f8c..4bb38d1 100644 --- a/lib/ofp-util.c +++ b/lib/ofp-util.c @@ -9288,7 +9288,13 @@ ofputil_uninit_geneve_table(struct ovs_list *mappings) * treats unknown properties and values as an error, as a switch would want to * do when interpreting a configuration request made by a controller. * - * Returns 0 if successful, otherwise an OFPERR_* value. */ + * Returns 0 if successful, otherwise an OFPERR_* value. + * + * Returns error code OFPERR_OFPACFC_INVALID if the value of mask is not in + * the valid range of mask. + * + * Returns error code OFPERR_OFPACFC_UNSUPPORTED if the configuration is not + * supported.*/ enum ofperr ofputil_decode_set_async_config(const struct ofp_header *oh, uint32_t master[OAM_N_TYPES], @@ -9336,58 +9342,91 @@ ofputil_decode_set_async_config(const struct ofp_header *oh, switch (type) { case OFPACPT_PACKET_IN_SLAVE: + if (ntohl(msg->mask) > 63) { + return OFPERR_OFPACFC_INVALID; + } slave[OAM_PACKET_IN] = ntohl(msg->mask); break; case OFPACPT_PACKET_IN_MASTER: + if (ntohl(msg->mask) > 63) { + return OFPERR_OFPACFC_INVALID; + } master[OAM_PACKET_IN] = ntohl(msg->mask); break; case OFPACPT_PORT_STATUS_SLAVE: + if (ntohl(msg->mask) > 7) { + return OFPERR_OFPACFC_INVALID; + } slave[OAM_PORT_STATUS] = ntohl(msg->mask); break; case OFPACPT_PORT_STATUS_MASTER: + if (ntohl(msg->mask) > 7) { + return OFPERR_OFPACFC_INVALID; + } master[OAM_PORT_STATUS] = ntohl(msg->mask); break; case OFPACPT_FLOW_REMOVED_SLAVE: + if (ntohl(msg->mask) > 63) { + return OFPERR_OFPACFC_INVALID; + } slave[OAM_FLOW_REMOVED] = ntohl(msg->mask); break; case OFPACPT_FLOW_REMOVED_MASTER: + if (ntohl(msg->mask) > 63) { + return OFPERR_OFPACFC_INVALID; + } master[OAM_FLOW_REMOVED] = ntohl(msg->mask); break; case OFPACPT_ROLE_STATUS_SLAVE: + if (ntohl(msg->mask) > 7) { + return OFPERR_OFPACFC_INVALID; + } slave[OAM_ROLE_STATUS] = ntohl(msg->mask); break; case OFPACPT_ROLE_STATUS_MASTER: + if (ntohl(msg->mask) > 7) { + return OFPERR_OFPACFC_INVALID; + } master[OAM_ROLE_STATUS] = ntohl(msg->mask); break; case OFPACPT_TABLE_STATUS_SLAVE: + if (ntohl(msg->mask) < 8 || ntohl(msg->mask) > 24) { + return OFPERR_OFPACFC_INVALID; + } slave[OAM_TABLE_STATUS] = ntohl(msg->mask); break; case OFPACPT_TABLE_STATUS_MASTER: + if (ntohl(msg->mask) < 8 || ntohl(msg->mask) > 24) { + return OFPERR_OFPACFC_INVALID; + } master[OAM_TABLE_STATUS] = ntohl(msg->mask); break; case OFPACPT_REQUESTFORWARD_SLAVE: + if (ntohl(msg->mask) > 3) { + return OFPERR_OFPACFC_INVALID; + } slave[OAM_REQUESTFORWARD] = ntohl(msg->mask); break; case OFPACPT_REQUESTFORWARD_MASTER: + if (ntohl(msg->mask) > 3) { + return OFPERR_OFPACFC_INVALID; + } master[OAM_REQUESTFORWARD] = ntohl(msg->mask); break; default: - error = loose ? 0 : OFPERR_OFPBPC_BAD_TYPE; - break; - } - if (error) { + error = loose ? 0 : OFPERR_OFPACFC_UNSUPPORTED; return error; } } diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c index e6c0351..528310e 100644 --- a/ofproto/ofproto.c +++ b/ofproto/ofproto.c @@ -5385,10 +5385,14 @@ handle_nxt_set_packet_in_format(struct ofconn *ofconn, static enum ofperr handle_nxt_set_async_config(struct ofconn *ofconn, const struct ofp_header *oh) { + enum ofperr error; uint32_t master[OAM_N_TYPES] = {0}; uint32_t slave[OAM_N_TYPES] = {0}; - ofputil_decode_set_async_config(oh, master, slave, false); + error = ofputil_decode_set_async_config(oh, master, slave, false); + if (error) { + return error; + } ofconn_set_async_config(ofconn, master, slave); if (ofconn_get_type(ofconn) == OFCONN_SERVICE && diff --git a/tests/ofp-print.at b/tests/ofp-print.at index 35a6262..929628f 100644 --- a/tests/ofp-print.at +++ b/tests/ofp-print.at @@ -2778,6 +2778,30 @@ OFPT_SET_ASYNC (OF1.4) (xid=0x2): ]) AT_CLEANUP +AT_SETUP([OFPT_SET_ASYNC_CONFIG - invalid mask - OF1.4]) +AT_KEYWORDS([ofp-print]) +AT_CHECK([ovs-ofctl ofp-print "\ +05 1c 00 38 00 00 00 02 00 00 00 08 00 00 00 40 \ +00 01 00 08 00 00 00 02 00 02 00 08 00 00 00 02 \ +00 03 00 08 00 00 00 05 00 04 00 08 00 00 00 1c \ +00 05 00 08 00 00 00 05 \ +"], [0], [dnl +OFPT_SET_ASYNC (OF1.4) (xid=0x2): ***decode error: OFPACFC_INVALID*** +]) +AT_CLEANUP + +AT_SETUP([OFPT_SET_ASYNC_CONFIG - unsupported configuration - OF1.4]) +AT_KEYWORDS([ofp-print]) +AT_CHECK([ovs-ofctl ofp-print "\ +05 1c 00 38 00 00 00 02 00 00 00 08 00 00 00 05 \ +00 11 00 08 00 00 00 02 00 02 00 08 00 00 00 02 \ +00 03 00 08 00 00 00 05 00 04 00 08 00 00 00 1c \ +00 05 00 08 00 00 00 05\ +"], [0], [dnl +OFPT_SET_ASYNC (OF1.4) (xid=0x2): ***decode error: OFPACFC_UNSUPPORTED*** +]) +AT_CLEANUP + AT_SETUP([NXT_SET_CONTROLLER_ID]) AT_KEYWORDS([ofp-print]) AT_CHECK([ovs-ofctl ofp-print "\