get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/756275/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 756275,
    "url": "http://patchwork.ozlabs.org/api/patches/756275/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/openvswitch/patch/1493370083-7385-5-git-send-email-azhou@ovn.org/",
    "project": {
        "id": 47,
        "url": "http://patchwork.ozlabs.org/api/projects/47/?format=api",
        "name": "Open vSwitch",
        "link_name": "openvswitch",
        "list_id": "ovs-dev.openvswitch.org",
        "list_email": "ovs-dev@openvswitch.org",
        "web_url": "http://openvswitch.org/",
        "scm_url": "git@github.com:openvswitch/ovs.git",
        "webscm_url": "https://github.com/openvswitch/ovs",
        "list_archive_url": "",
        "list_archive_url_format": "",
        "commit_url_format": ""
    },
    "msgid": "<1493370083-7385-5-git-send-email-azhou@ovn.org>",
    "list_archive_url": null,
    "date": "2017-04-28T09:01:23",
    "name": "[ovs-dev,action,upcall,meter,v2,5/5] ofproto: Meter slowpath action when action upcall meters are configured",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "3cd23bc05518a90c99f4b99143f28cff7c99b9a6",
    "submitter": {
        "id": 67699,
        "url": "http://patchwork.ozlabs.org/api/people/67699/?format=api",
        "name": "Andy Zhou",
        "email": "azhou@ovn.org"
    },
    "delegate": null,
    "mbox": "http://patchwork.ozlabs.org/project/openvswitch/patch/1493370083-7385-5-git-send-email-azhou@ovn.org/mbox/",
    "series": [],
    "comments": "http://patchwork.ozlabs.org/api/patches/756275/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/756275/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<ovs-dev-bounces@openvswitch.org>",
        "X-Original-To": [
            "incoming@patchwork.ozlabs.org",
            "dev@openvswitch.org"
        ],
        "Delivered-To": [
            "patchwork-incoming@bilbo.ozlabs.org",
            "ovs-dev@mail.linuxfoundation.org"
        ],
        "Received": [
            "from mail.linuxfoundation.org (mail.linuxfoundation.org\n\t[140.211.169.12])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3wDntq55Ssz9s89\n\tfor <incoming@patchwork.ozlabs.org>;\n\tFri, 28 Apr 2017 19:04:19 +1000 (AEST)",
            "from mail.linux-foundation.org (localhost [127.0.0.1])\n\tby mail.linuxfoundation.org (Postfix) with ESMTP id 3EC56B8C;\n\tFri, 28 Apr 2017 09:01:47 +0000 (UTC)",
            "from smtp1.linuxfoundation.org (smtp1.linux-foundation.org\n\t[172.17.192.35])\n\tby mail.linuxfoundation.org (Postfix) with ESMTPS id 54DFEB61\n\tfor <dev@openvswitch.org>; Fri, 28 Apr 2017 09:01:43 +0000 (UTC)",
            "from mail-pg0-f68.google.com (mail-pg0-f68.google.com\n\t[74.125.83.68])\n\tby smtp1.linuxfoundation.org (Postfix) with ESMTPS id DDE3315B\n\tfor <dev@openvswitch.org>; Fri, 28 Apr 2017 09:01:42 +0000 (UTC)",
            "by mail-pg0-f68.google.com with SMTP id v1so4399746pgv.3\n\tfor <dev@openvswitch.org>; Fri, 28 Apr 2017 02:01:42 -0700 (PDT)",
            "from centos.hsd1.ca.comcast.net.\n\t([2601:647:4280:45d0:d6be:d9ff:fe69:1f8d])\n\tby smtp.gmail.com with ESMTPSA id\n\ts68sm9307944pfj.77.2017.04.28.02.01.41\n\t(version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\n\tFri, 28 Apr 2017 02:01:41 -0700 (PDT)"
        ],
        "X-Greylist": "whitelisted by SQLgrey-1.7.6",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references:content-transfer-encoding;\n\tbh=WIfa5Z6JhRjQoKo/MWvsPlYAOOxXQen5m0ZwvMRsdgY=;\n\tb=t0DD/nXU1Mtsej9KqFMmO2PuNBMR1WXiLfdKH/iMRokqFGMoXFHapkXOedxhI6yFIe\n\tcKfjpTaAyBh3GZHU3+kHBn7iqTBtPatlapRLXiM9rdxwTZjcoh0CVQG4cwIibNtr6Sma\n\t2ubkoxk+1UnBsSGehFwXEdATsSk/EqU0rKUfJxgDhSLL1TrHX//MSQ3RWvCCRTlQwZgU\n\t7rHTY4GslRUmGcY/CwhetnpjyA27UMaF+8X4B5Qynw+ng3pJj9v8Au/Cl5nGcZxNYY4d\n\tcOf/KxZf750hqoAMSWDRc5by4+8VylaDR4RAMtvSRjSUrtuLCNcMrVwftjOqN3Y2TlqX\n\tWaWA==",
        "X-Gm-Message-State": "AN3rC/6fYifwKBoPuo0JrKIPGqzg+dwEsqvFIZD/BC8M/yz3xNGU6Bh/\n\t5jwbjkDPiWK0tg==",
        "X-Received": "by 10.84.238.143 with SMTP id v15mr13718964plk.102.1493370102414;\n\tFri, 28 Apr 2017 02:01:42 -0700 (PDT)",
        "From": "Andy Zhou <azhou@ovn.org>",
        "To": "dev@openvswitch.org",
        "Date": "Fri, 28 Apr 2017 02:01:23 -0700",
        "Message-Id": "<1493370083-7385-5-git-send-email-azhou@ovn.org>",
        "X-Mailer": "git-send-email 1.8.3.1",
        "In-Reply-To": "<1493370083-7385-1-git-send-email-azhou@ovn.org>",
        "References": "<1493370083-7385-1-git-send-email-azhou@ovn.org>",
        "X-Spam-Status": "No, score=-1.4 required=5.0 tests=BAYES_00,FREEMAIL_FROM,\n\tRCVD_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\n\tsmtp1.linux-foundation.org",
        "Subject": "[ovs-dev] [action upcall meter v2 5/5] ofproto: Meter slowpath\n\taction when action upcall meters are configured",
        "X-BeenThere": "ovs-dev@openvswitch.org",
        "X-Mailman-Version": "2.1.12",
        "Precedence": "list",
        "List-Id": "<ovs-dev.openvswitch.org>",
        "List-Unsubscribe": "<https://mail.openvswitch.org/mailman/options/ovs-dev>,\n\t<mailto:ovs-dev-request@openvswitch.org?subject=unsubscribe>",
        "List-Archive": "<http://mail.openvswitch.org/pipermail/ovs-dev/>",
        "List-Post": "<mailto:ovs-dev@openvswitch.org>",
        "List-Help": "<mailto:ovs-dev-request@openvswitch.org?subject=help>",
        "List-Subscribe": "<https://mail.openvswitch.org/mailman/listinfo/ovs-dev>,\n\t<mailto:ovs-dev-request@openvswitch.org?subject=subscribe>",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain; charset=\"us-ascii\"",
        "Content-Transfer-Encoding": "7bit",
        "Sender": "ovs-dev-bounces@openvswitch.org",
        "Errors-To": "ovs-dev-bounces@openvswitch.org"
    },
    "content": "If a slow path action is a controller action, meter it when the\ncontroller meter is configured.  For other kinds of slow path actions,\nmeter it when the slowpath meter is configured.\n\nNote, this patch only considers the meters configuration of the\npacket's input bridge, which may not be the same bridge that the\naction is generated.\n\nSigned-off-by: Andy Zhou <azhou@ovn.org>\n\n---\nv1->v2:  fix style issues\n         in test, dump and verify meter stats\n---\n ofproto/ofproto-dpif-upcall.c | 34 +++++++++++++++++++++++++++++++---\n tests/ofproto-dpif.at         | 38 ++++++++++++++++++++++++++++++++++++++\n 2 files changed, 69 insertions(+), 3 deletions(-)",
    "diff": "diff --git a/ofproto/ofproto-dpif-upcall.c b/ofproto/ofproto-dpif-upcall.c\nindex a3b650d38050..185d8acbc9a3 100644\n--- a/ofproto/ofproto-dpif-upcall.c\n+++ b/ofproto/ofproto-dpif-upcall.c\n@@ -1025,7 +1025,8 @@ classify_upcall(enum dpif_upcall_type type, const struct nlattr *userdata)\n static void\n compose_slow_path(struct udpif *udpif, struct xlate_out *xout,\n                   const struct flow *flow, odp_port_t odp_in_port,\n-                  struct ofpbuf *buf)\n+                  struct ofpbuf *buf, uint32_t slowpath_meter_id,\n+                  uint32_t controller_meter_id)\n {\n     union user_action_cookie cookie;\n     odp_port_t port;\n@@ -1039,8 +1040,28 @@ compose_slow_path(struct udpif *udpif, struct xlate_out *xout,\n         ? ODPP_NONE\n         : odp_in_port;\n     pid = dpif_port_get_pid(udpif->dpif, port, flow_hash_5tuple(flow, 0));\n+\n+    size_t offset;\n+    size_t ac_offset;\n+    uint32_t meter_id = xout->slow & SLOW_CONTROLLER ? controller_meter_id\n+                                                     : slowpath_meter_id;\n+\n+    if (meter_id != UINT32_MAX) {\n+        /* If slowpath meter is configured, generate clone(meter, userspace)\n+         * action.   */\n+        offset = nl_msg_start_nested(buf, OVS_ACTION_ATTR_SAMPLE);\n+        nl_msg_put_u32(buf, OVS_SAMPLE_ATTR_PROBABILITY, UINT32_MAX);\n+        ac_offset = nl_msg_start_nested(buf, OVS_SAMPLE_ATTR_ACTIONS);\n+        nl_msg_put_u32(buf, OVS_ACTION_ATTR_METER, meter_id);\n+    }\n+\n     odp_put_userspace_action(pid, &cookie, sizeof cookie.slow_path,\n                              ODPP_NONE, false, buf);\n+\n+    if (meter_id != UINT32_MAX) {\n+        nl_msg_end_nested(buf, ac_offset);\n+        nl_msg_end_nested(buf, offset);\n+    }\n }\n \n /* If there is no error, the upcall must be destroyed with upcall_uninit()\n@@ -1143,10 +1164,12 @@ upcall_xlate(struct udpif *udpif, struct upcall *upcall,\n         ofpbuf_use_const(&upcall->put_actions,\n                          odp_actions->data, odp_actions->size);\n     } else {\n+        uint32_t smid = upcall->ofproto->up.slowpath_meter_id;\n+        uint32_t cmid = upcall->ofproto->up.controller_meter_id;\n         /* upcall->put_actions already initialized by upcall_receive(). */\n         compose_slow_path(udpif, &upcall->xout, upcall->flow,\n                           upcall->flow->in_port.odp_port,\n-                          &upcall->put_actions);\n+                          &upcall->put_actions, smid, cmid);\n     }\n \n     /* This function is also called for slow-pathed flows.  As we are only\n@@ -1972,9 +1995,14 @@ revalidate_ukey__(struct udpif *udpif, const struct udpif_key *ukey,\n     }\n \n     if (xoutp->slow) {\n+        struct ofproto_dpif *ofproto;\n+        ofproto = xlate_lookup_ofproto(udpif->backer, &ctx.flow, NULL);\n+        uint32_t smid= ofproto->up.slowpath_meter_id;\n+        uint32_t cmid= ofproto->up.controller_meter_id;\n+\n         ofpbuf_clear(odp_actions);\n         compose_slow_path(udpif, xoutp, &ctx.flow, ctx.flow.in_port.odp_port,\n-                          odp_actions);\n+                          odp_actions, smid, cmid);\n     }\n \n     if (odp_flow_key_to_mask(ukey->mask, ukey->mask_len, &dp_mask, &ctx.flow)\ndiff --git a/tests/ofproto-dpif.at b/tests/ofproto-dpif.at\nindex 22cb533b57bb..06c4e3bbf5f8 100644\n--- a/tests/ofproto-dpif.at\n+++ b/tests/ofproto-dpif.at\n@@ -1658,6 +1658,44 @@ NXT_PACKET_IN (xid=0x0): cookie=0x0 total_len=14 in_port=1 (via action) data_len\n vlan_tci=0x0000,dl_src=50:54:00:00:00:09,dl_dst=50:54:00:00:00:0a,dl_type=0x1234\n ])\n \n+AT_CHECK([ovs-appctl revalidator/purge])\n+AT_CHECK([ovs-ofctl monitor br0 65534 invalid_ttl -P nxt_packet_in --detach --no-chdir --pidfile 2> ofctl_monitor.log])\n+\n+dnl Add a controller meter.\n+AT_CHECK([ovs-ofctl -O OpenFlow13 add-meter br0 'meter=controller pktps stats bands=type=drop rate=1'])\n+\n+dnl Advance time by 1 second.\n+AT_CHECK([ovs-appctl time/warp 1000], [0], [ignore])\n+\n+for i in `seq 1 8`; do\n+    AT_CHECK([ovs-appctl netdev-dummy/receive p1 'in_port(1),eth(src=50:54:00:00:00:09,dst=50:54:00:00:00:0a),eth_type(0x4321)'])\n+done\n+\n+AT_CHECK([ovs-appctl dpctl/dump-flows | sed 's/.*\\(packets:\\)/\\1/' | sed 's/used:[[0-9]].[[0-9]]*s/used:0.001s/'], [0], [dnl\n+flow-dump from non-dpdk interfaces:\n+packets:7, bytes:98, used:0.001s, actions:sample(sample=100.0%,actions(meter(0),userspace(pid=0,slow_path(controller))))\n+])\n+\n+AT_CHECK([ovs-appctl time/warp 1], [0], [ignore])\n+OVS_WAIT_UNTIL([ovs-appctl -t ovs-ofctl exit])\n+\n+dnl Out of 8 packets we sent, one executes the controller action via\n+dnl miss upcall. Another one got passed the rate limiter.\n+dnl The rest of packets are blocked by the rate limiter.\n+AT_CHECK([cat ofctl_monitor.log], [0], [dnl\n+NXT_PACKET_IN (xid=0x0): cookie=0x0 total_len=14 in_port=1 (via action) data_len=14 (unbuffered)\n+vlan_tci=0x0000,dl_src=50:54:00:00:00:09,dl_dst=50:54:00:00:00:0a,dl_type=0x4321\n+NXT_PACKET_IN (xid=0x0): cookie=0x0 total_len=14 in_port=1 (via action) data_len=14 (unbuffered)\n+vlan_tci=0x0000,dl_src=50:54:00:00:00:09,dl_dst=50:54:00:00:00:0a,dl_type=0x4321\n+])\n+dnl Check meter stats to make it gives the same picture;\n+dnl 7 packets hit the meter, but 6 packets are dropped by band0.\n+AT_CHECK([ovs-ofctl -O OpenFlow13 meter-stats br0], [0], [dnl\n+OFPST_METER reply (OF1.3) (xid=0x2):\n+meter:controller flow_count:0 packet_in_count:7 byte_in_count:98 duration:1.054s bands:\n+0: packet_count:6 byte_count:84\n+])\n+\n OVS_VSWITCHD_STOP\n AT_CLEANUP\n \n",
    "prefixes": [
        "ovs-dev",
        "action",
        "upcall",
        "meter",
        "v2",
        "5/5"
    ]
}