From patchwork Mon Apr 17 21:11:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yi-Hung Wei X-Patchwork-Id: 751550 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3w6LZY2vm3z9s2s for ; Tue, 18 Apr 2017 07:12:53 +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="opXJMu4+"; dkim-atps=neutral Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id EC003C14; Mon, 17 Apr 2017 21:12:51 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id D4814B5A for ; Mon, 17 Apr 2017 21:12:50 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-pg0-f65.google.com (mail-pg0-f65.google.com [74.125.83.65]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 6499F1B9 for ; Mon, 17 Apr 2017 21:12:50 +0000 (UTC) Received: by mail-pg0-f65.google.com with SMTP id g2so29616255pge.2 for ; Mon, 17 Apr 2017 14:12:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=FfWW7dVrOfemLnn1C+mvyDWyW3bWFX5mrZ/NfItbqiM=; b=opXJMu4+Wl2Ch0Nui9hMC3DvEcyj/oFk09hP9YiVu32GRyNDdFD/P/kiED9Wx6K9W5 RS9/hnxYmVLLi3yN2fANaj49cj1ebEgeCdG40+wt4t//4W2g7FhHMDmUsCLJS49Frv/I KZi/u/1UQT+LUnncZoZ1YKoW5H+AFGfMYeMGlc42oy1qL+FuzPFFtj4fJ3SaOQe2tK67 iG9zOkuMUGcHkPtJCDH2MvJByY7lpK7KYMeT/PAKuBXkmrkV4lN9yyhMYYb/fG/zSZAW Zx4FYF+/8u7l+cAvQhzboLPjSn1GL38AWTfG6a1cVFd50nO0butLONKZlpMChMn7VVgT LJoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=FfWW7dVrOfemLnn1C+mvyDWyW3bWFX5mrZ/NfItbqiM=; b=KRJMuw+d8PN8j6wW9IHd6TI4o2CUiIaxqD6ngPpza8VyBcXeu6Qoq8KROxAO5qqWct Z27NEyL9bCvDboDC8VU0wDv8kr91d5glf2Xvy6nG0e5p1o2NIftcmqdthtvzUv6pdWdy 5nCkzDLXkt64f8rHrE5WC6YDWGtoBBM8cIDZU8m+ZYOYrN7Xl8/030Qv+Tm5jytzYEUh rOSjDpF1ULOEU7YspolIPs/xRySNhThfcXvpougBgHs2ul2cVGJRJJK+Xh5dqZoc6zLr 3qdqxeUbTAuM3zyLPeHoag2UuSJT2EIdNPD4PiJQ3LG231K+vcQPijNOQJhelId8Q+qu FUZA== X-Gm-Message-State: AN3rC/4d1kpj/ctV8r3xk3Xpak0rAqxStIry80Tlhz9G59R8OI/jiCEn eDwDawDudaq1Ott4Eww= X-Received: by 10.84.137.165 with SMTP id 34mr18078103pln.125.1492463569799; Mon, 17 Apr 2017 14:12:49 -0700 (PDT) Received: from sc9-mailhost3.vmware.com ([208.91.1.34]) by smtp.gmail.com with ESMTPSA id r77sm19776523pfe.105.2017.04.17.14.12.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 17 Apr 2017 14:12:49 -0700 (PDT) From: Yi-Hung Wei To: dev@openvswitch.org Date: Mon, 17 Apr 2017 14:11:29 -0700 Message-Id: <1492463490-10251-1-git-send-email-yihung.wei@gmail.com> X-Mailer: git-send-email 2.7.4 X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM autolearn=no version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH 1/2] connmgr: Fix internal packet-in reason code mask X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org Starting from OpenFlow 1.4+, OFPR_ACTION is split into four more descriptive reasons, OFPR_APPLY_ACTION, OFPR_ACTION_SET, OFPR_GROUP, and OFPR_PACKET_OUT. OVS maintains the new reason code internally, and it currently supports the first three reason code. If the version of an established OpenFlow connection is less than 1.4, OVS coverts the internal reason code back to OFPR_ACTION to be backward compatible. However, the internal packet-in reason code mask is not properly maintained for the older OpenFlow version that may omit the packet-in messages wth the new reason code. It is because OVS does not enable the new reason code internally in the reason code mask for older OpenFlow version. This commit tries to address the aforementioned issue. Signed-off-by: Yi-Hung Wei --- include/openflow/openflow-common.h | 9 +++++++-- ofproto/connmgr.c | 10 ++++++++++ tests/ofproto.at | 23 ++++++++++++++++++++--- 3 files changed, 37 insertions(+), 5 deletions(-) diff --git a/include/openflow/openflow-common.h b/include/openflow/openflow-common.h index 530c105286ac..5936e3f096c5 100644 --- a/include/openflow/openflow-common.h +++ b/include/openflow/openflow-common.h @@ -291,9 +291,14 @@ enum ofp_packet_in_reason { #define OFPR10_BITS \ ((1u << OFPR_NO_MATCH) | (1u << OFPR_ACTION) | (1u << OFPR_INVALID_TTL)) + +/* From OF1.4+, OFPR_ACTION is split into four more descriptive reasons, + * OFPR_APPLY_ACTION, OFPR_ACTION_SET, OFPR_GROUP, and OFPR_PACKET_OUT. + * OFPR_APPLY_ACTION shares the same number as OFPR_ACTION. */ +#define OFPR14_ACTION_BITS \ + ((1u << OFPR_ACTION_SET) | (1u << OFPR_GROUP) | (1u << OFPR_PACKET_OUT)) #define OFPR14_BITS \ - (OFPR10_BITS | \ - (1u << OFPR_ACTION_SET) | (1u << OFPR_GROUP) | (1u << OFPR_PACKET_OUT)) + (OFPR10_BITS | OFPR14_ACTION_BITS) /* Nonstandard reason--not exposed via OpenFlow. */ OFPR_EXPLICIT_MISS, diff --git a/ofproto/connmgr.c b/ofproto/connmgr.c index 854868e7be78..2b0b78f6192d 100644 --- a/ofproto/connmgr.c +++ b/ofproto/connmgr.c @@ -1092,6 +1092,16 @@ ofconn_set_async_config(struct ofconn *ofconn, ofconn->async_cfg = xmalloc(sizeof *ofconn->async_cfg); } *ofconn->async_cfg = *ac; + + if (ofputil_protocol_to_ofp_version(ofconn_get_protocol(ofconn)) + < OFP14_VERSION) { + if (ofconn->async_cfg->master[OAM_PACKET_IN] & (1u << OFPR_ACTION)) { + ofconn->async_cfg->master[OAM_PACKET_IN] |= OFPR14_ACTION_BITS; + } + if (ofconn->async_cfg->slave[OAM_PACKET_IN] & (1u << OFPR_ACTION)) { + ofconn->async_cfg->slave[OAM_PACKET_IN] |= OFPR14_ACTION_BITS; + } + } } struct ofputil_async_cfg diff --git a/tests/ofproto.at b/tests/ofproto.at index 5c0d0762390f..fbd9a8c21683 100644 --- a/tests/ofproto.at +++ b/tests/ofproto.at @@ -3361,7 +3361,9 @@ OVS_VSWITCHD_STOP AT_CLEANUP AT_SETUP([ofproto - asynchronous message control (OpenFlow 1.3)]) -OVS_VSWITCHD_START +OVS_VSWITCHD_START([dnl + add-port br0 p1 -- set Interface p1 type=dummy ofport_request=10 +]) AT_CHECK([ovs-ofctl -O OpenFlow13 -P standard monitor br0 --detach --no-chdir --pidfile]) check_async () { printf '\n\n--- check_async %d ---\n\n\n' $1 @@ -3373,10 +3375,15 @@ check_async () { : > expout # OFPT_PACKET_IN, OFPR_ACTION (controller_id=0) + # OFPR_ACTION_SET is treated as OFPR_ACTION in OpenFlow 1.3 ovs-ofctl -O OpenFlow13 -v packet-out br0 none controller '0001020304050010203040501234' + ovs-ofctl -O OpenFlow13 add-flow br0 'in_port=10 actions=write_actions(output(CONTROLLER))' + ovs-appctl netdev-dummy/receive p1 'in_port(10),eth(src=00:10:20:30:40:50,dst=00:01:02:03:04:05),eth_type(0x1234)' if test X"$1" = X"OFPR_ACTION"; then shift; echo >>expout "OFPT_PACKET_IN (OF1.3): total_len=14 in_port=ANY (via action) data_len=14 (unbuffered) vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x1234" + echo >>expout "OFPT_PACKET_IN (OF1.3): cookie=0x0 total_len=14 in_port=10 (via action) data_len=14 (unbuffered) +vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x1234" fi # OFPT_PACKET_IN, OFPR_NO_MATCH (controller_id=123) @@ -3470,7 +3477,9 @@ OVS_VSWITCHD_STOP AT_CLEANUP AT_SETUP([ofproto - asynchronous message control (OpenFlow 1.4)]) -OVS_VSWITCHD_START +OVS_VSWITCHD_START([dnl + add-port br0 p1 -- set Interface p1 type=dummy ofport_request=10 +]) AT_CHECK([ovs-ofctl -O OpenFlow14 -P standard monitor br0 --detach --no-chdir --pidfile]) check_async () { printf '\n\n--- check_async %d ---\n\n\n' $1 @@ -3488,6 +3497,14 @@ check_async () { vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x1234" fi + # OFPT_PACKET_IN, OFPR_ACTION_SET (controller_id=0) + ovs-ofctl -O OpenFlow14 add-flow br0 'in_port=10 actions=write_actions(output(CONTROLLER))' + ovs-appctl netdev-dummy/receive p1 'in_port(10),eth(src=00:10:20:30:40:50,dst=00:01:02:03:04:05),eth_type(0x1234)' + if test X"$1" = X"OFPR_ACTION_SET"; then shift; + echo >>expout "OFPT_PACKET_IN (OF1.4): cookie=0x0 total_len=14 in_port=10 (via action_set) data_len=14 (unbuffered) +vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x1234" + fi + # OFPT_PACKET_IN, OFPR_NO_MATCH (controller_id=123) ovs-ofctl -O OpenFlow14 -v packet-out br0 none 'controller(reason=no_match,id=123)' '0001020304050010203040501234' if test X"$1" = X"OFPR_NO_MATCH"; then shift; @@ -3644,7 +3661,7 @@ check_async 1 # Set miss_send_len to 128, turning on packet-ins for our service connection. ovs-appctl -t ovs-ofctl ofctl/send 0509000c0123456700000080 -check_async 2 OFPR_ACTION OFPPR_ADD OFPPR_MODIFY OFPPR_DELETE OFPRR_DELETE OFPRR_GROUP_DELETE +check_async 2 OFPR_ACTION OFPR_ACTION_SET OFPPR_ADD OFPPR_MODIFY OFPPR_DELETE OFPRR_DELETE OFPRR_GROUP_DELETE # Become slave (OF 1.4), which should disable everything except port status. ovs-appctl -t ovs-ofctl ofctl/send 051800180000000200000003000000000000000000000001