From patchwork Wed Feb 28 08:00:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Justin Pettit X-Patchwork-Id: 878982 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ovn.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 3zrp2T6SS7z9s0q for ; Wed, 28 Feb 2018 19:02:41 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 2B8F1DC2; Wed, 28 Feb 2018 08:01:57 +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 A52819CE for ; Wed, 28 Feb 2018 08:01:53 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 8AD46477 for ; Wed, 28 Feb 2018 08:01:52 +0000 (UTC) X-Originating-IP: 98.234.50.139 Received: from localhost.localdomain (unknown [98.234.50.139]) (Authenticated sender: jpettit@ovn.org) by relay5-d.mail.gandi.net (Postfix) with ESMTPSA id E158E41C0A3 for ; Wed, 28 Feb 2018 09:01:50 +0100 (CET) From: Justin Pettit To: dev@openvswitch.org Date: Wed, 28 Feb 2018 00:00:56 -0800 Message-Id: <1519804863-73126-2-git-send-email-jpettit@ovn.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1519804863-73126-1-git-send-email-jpettit@ovn.org> References: <1519804863-73126-1-git-send-email-jpettit@ovn.org> X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [shadow 1/8] Don't shadow global VLOG "rl" definition. 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 Signed-off-by: Justin Pettit Acked-by: Ben Pfaff --- lib/netdev-linux.c | 8 ++++---- lib/ofp-actions.c | 18 +++++++++--------- lib/ofp-port.c | 4 ++-- ofproto/connmgr.c | 4 ++-- ofproto/ofproto-dpif-upcall.c | 15 ++++++++------- ofproto/ofproto-dpif.c | 12 ++++++------ ofproto/ofproto.c | 4 ++-- 7 files changed, 33 insertions(+), 32 deletions(-) diff --git a/lib/netdev-linux.c b/lib/netdev-linux.c index 4e0473cf331f..b3ef0f7c0615 100644 --- a/lib/netdev-linux.c +++ b/lib/netdev-linux.c @@ -635,7 +635,6 @@ netdev_linux_run(const struct netdev_class *netdev_class OVS_UNUSED) } do { - static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5); uint64_t buf_stub[4096 / 8]; struct ofpbuf buf; @@ -686,7 +685,8 @@ netdev_linux_run(const struct netdev_class *netdev_class OVS_UNUSED) } shash_destroy(&device_shash); } else if (error != EAGAIN) { - VLOG_WARN_RL(&rl, "error reading or parsing netlink (%s)", + static struct vlog_rate_limit rll = VLOG_RATE_LIMIT_INIT(1, 5); + VLOG_WARN_RL(&rll, "error reading or parsing netlink (%s)", ovs_strerror(error)); } ofpbuf_uninit(&buf); @@ -789,8 +789,8 @@ netdev_linux_common_construct(struct netdev *netdev_) struct netdev_linux *netdev = netdev_linux_cast(netdev_); const char *name = netdev_->name; if (!strcmp(name, "default") || !strcmp(name, "all")) { - static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 1); - VLOG_WARN_RL(&rl, "%s: Linux forbids network device with this name", + static struct vlog_rate_limit rll = VLOG_RATE_LIMIT_INIT(1, 1); + VLOG_WARN_RL(&rll, "%s: Linux forbids network device with this name", name); return EINVAL; } diff --git a/lib/ofp-actions.c b/lib/ofp-actions.c index 7c076f65f985..db857162e566 100644 --- a/lib/ofp-actions.c +++ b/lib/ofp-actions.c @@ -1318,7 +1318,7 @@ decode_bundle(bool load, const struct nx_action_bundle *nab, const struct vl_mff_map *vl_mff_map, uint64_t *tlv_bitmap, struct ofpbuf *ofpacts) { - static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5); + static struct vlog_rate_limit rll = VLOG_RATE_LIMIT_INIT(1, 5); struct ofpact_bundle *bundle; uint32_t slave_type; size_t slaves_size, i; @@ -1335,20 +1335,20 @@ decode_bundle(bool load, const struct nx_action_bundle *nab, error = OFPERR_OFPBAC_BAD_ARGUMENT; if (!flow_hash_fields_valid(bundle->fields)) { - VLOG_WARN_RL(&rl, "unsupported fields %d", (int) bundle->fields); + VLOG_WARN_RL(&rll, "unsupported fields %d", (int) bundle->fields); } else if (bundle->n_slaves > BUNDLE_MAX_SLAVES) { - VLOG_WARN_RL(&rl, "too many slaves"); + VLOG_WARN_RL(&rll, "too many slaves"); } else if (bundle->algorithm != NX_BD_ALG_HRW && bundle->algorithm != NX_BD_ALG_ACTIVE_BACKUP) { - VLOG_WARN_RL(&rl, "unsupported algorithm %d", (int) bundle->algorithm); + VLOG_WARN_RL(&rll, "unsupported algorithm %d", (int) bundle->algorithm); } else if (slave_type != mf_nxm_header(MFF_IN_PORT)) { - VLOG_WARN_RL(&rl, "unsupported slave type %"PRIu32, slave_type); + VLOG_WARN_RL(&rll, "unsupported slave type %"PRIu32, slave_type); } else { error = 0; } if (!is_all_zeros(nab->zero, sizeof nab->zero)) { - VLOG_WARN_RL(&rl, "reserved field is nonzero"); + VLOG_WARN_RL(&rll, "reserved field is nonzero"); error = OFPERR_OFPBAC_BAD_ARGUMENT; } @@ -1362,19 +1362,19 @@ decode_bundle(bool load, const struct nx_action_bundle *nab, } if (bundle->dst.n_bits < 16) { - VLOG_WARN_RL(&rl, "bundle_load action requires at least 16 bit " + VLOG_WARN_RL(&rll, "bundle_load action requires at least 16 bit " "destination."); error = OFPERR_OFPBAC_BAD_ARGUMENT; } } else { if (nab->ofs_nbits || nab->dst) { - VLOG_WARN_RL(&rl, "bundle action has nonzero reserved fields"); + VLOG_WARN_RL(&rll, "bundle action has nonzero reserved fields"); error = OFPERR_OFPBAC_BAD_ARGUMENT; } } if (slaves_size < bundle->n_slaves * sizeof(ovs_be16)) { - VLOG_WARN_RL(&rl, "Nicira action %s only has %"PRIuSIZE" bytes " + VLOG_WARN_RL(&rll, "Nicira action %s only has %"PRIuSIZE" bytes " "allocated for slaves. %"PRIuSIZE" bytes are required " "for %u slaves.", load ? "bundle_load" : "bundle", slaves_size, diff --git a/lib/ofp-port.c b/lib/ofp-port.c index 86562c9b47a5..cff37290eb33 100644 --- a/lib/ofp-port.c +++ b/lib/ofp-port.c @@ -91,8 +91,8 @@ ofputil_port_from_ofp11(ovs_be32 ofp11_port, ofp_port_t *ofp10_port) } else { *ofp10_port = OFPP_NONE; - static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5); - VLOG_WARN_RL(&rl, "port %"PRIu32" is outside the supported " + static struct vlog_rate_limit rll = VLOG_RATE_LIMIT_INIT(1, 5); + VLOG_WARN_RL(&rll, "port %"PRIu32" is outside the supported " "range 0 through %d or 0x%"PRIx32" through 0x%"PRIx32, ofp11_port_h, ofp_to_u16(OFPP_MAX) - 1, ofp11_to_u32(OFPP11_MAX), UINT32_MAX); diff --git a/ofproto/connmgr.c b/ofproto/connmgr.c index e0e78a1e1a78..bf43fbd73182 100644 --- a/ofproto/connmgr.c +++ b/ofproto/connmgr.c @@ -1761,9 +1761,9 @@ do_send_packet_ins(struct ofconn *ofconn, struct ovs_list *txq) LIST_FOR_EACH_POP (pin, list_node, txq) { if (rconn_send_with_limit(ofconn->rconn, pin, ofconn->packet_in_counter, 100) == EAGAIN) { - static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(5, 5); + static struct vlog_rate_limit rll = VLOG_RATE_LIMIT_INIT(5, 5); - VLOG_INFO_RL(&rl, "%s: dropping packet-in due to queue overflow", + VLOG_INFO_RL(&rll, "%s: dropping packet-in due to queue overflow", rconn_get_name(ofconn->rconn)); } } diff --git a/ofproto/ofproto-dpif-upcall.c b/ofproto/ofproto-dpif-upcall.c index 23e459b06c66..e282a437e84a 100644 --- a/ofproto/ofproto-dpif-upcall.c +++ b/ofproto/ofproto-dpif-upcall.c @@ -1252,7 +1252,6 @@ upcall_cb(const struct dp_packet *packet, const struct flow *flow, ovs_u128 *ufi const struct nlattr *userdata, struct ofpbuf *actions, struct flow_wildcards *wc, struct ofpbuf *put_actions, void *aux) { - static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 1); struct udpif *udpif = aux; struct upcall upcall; bool megaflow; @@ -1287,7 +1286,8 @@ upcall_cb(const struct dp_packet *packet, const struct flow *flow, ovs_u128 *ufi } if (upcall.ukey && !ukey_install(udpif, upcall.ukey)) { - VLOG_WARN_RL(&rl, "upcall_cb failure: ukey installation fails"); + static struct vlog_rate_limit rll = VLOG_RATE_LIMIT_INIT(1, 1); + VLOG_WARN_RL(&rll, "upcall_cb failure: ukey installation fails"); error = ENOSPC; } out: @@ -2355,9 +2355,8 @@ push_dp_ops(struct udpif *udpif, struct ukey_op *ops, size_t n_ops) error = xlate_key(udpif, key, key_len, push, &ctx); if (error) { - static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5); - - VLOG_WARN_RL(&rl, "xlate_key failed (%s)!", + static struct vlog_rate_limit rll = VLOG_RATE_LIMIT_INIT(1, 5); + VLOG_WARN_RL(&rll, "xlate_key failed (%s)!", ovs_strerror(error)); } else { xlate_out_uninit(&ctx.xout); @@ -2390,13 +2389,15 @@ push_ukey_ops(struct udpif *udpif, struct umap *umap, static void log_unexpected_flow(const struct dpif_flow *flow, int error) { - static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(10, 60); struct ds ds = DS_EMPTY_INITIALIZER; ds_put_format(&ds, "Failed to acquire udpif_key corresponding to " "unexpected flow (%s): ", ovs_strerror(error)); odp_format_ufid(&flow->ufid, &ds); - VLOG_WARN_RL(&rl, "%s", ds_cstr(&ds)); + + static struct vlog_rate_limit rll = VLOG_RATE_LIMIT_INIT(10, 60); + VLOG_WARN_RL(&rll, "%s", ds_cstr(&ds)); + ds_destroy(&ds); } diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c index 0fee6f9c5065..e28ce64c1934 100644 --- a/ofproto/ofproto-dpif.c +++ b/ofproto/ofproto-dpif.c @@ -3210,7 +3210,6 @@ bundle_remove(struct ofport *port_) static void send_pdu_cb(void *port_, const void *pdu, size_t pdu_size) { - static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 10); struct ofport_dpif *port = port_; struct eth_addr ea; int error; @@ -3228,7 +3227,8 @@ send_pdu_cb(void *port_, const void *pdu, size_t pdu_size) ofproto_dpif_send_packet(port, false, &packet); dp_packet_uninit(&packet); } else { - VLOG_ERR_RL(&rl, "port %s: cannot obtain Ethernet address of iface " + static struct vlog_rate_limit rll = VLOG_RATE_LIMIT_INIT(1, 10); + VLOG_ERR_RL(&rll, "port %s: cannot obtain Ethernet address of iface " "%s (%s)", port->bundle->name, netdev_get_name(port->up.netdev), ovs_strerror(error)); } @@ -3275,8 +3275,8 @@ bundle_send_learning_packets(struct ofbundle *bundle) } if (n_errors) { - static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5); - VLOG_WARN_RL(&rl, "bond %s: %d errors sending %d gratuitous learning " + static struct vlog_rate_limit rll = VLOG_RATE_LIMIT_INIT(1, 5); + VLOG_WARN_RL(&rll, "bond %s: %d errors sending %d gratuitous learning " "packets, last error was: %s", bundle->name, n_errors, n_packets, ovs_strerror(error)); } else { @@ -4296,8 +4296,8 @@ check_mask(struct ofproto_dpif *ofproto, const struct miniflow *flow) static void report_unsupported_act(const char *action, const char *detail) { - static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5); - VLOG_WARN_RL(&rl, "Rejecting %s action because datapath does not support" + static struct vlog_rate_limit rll = VLOG_RATE_LIMIT_INIT(1, 5); + VLOG_WARN_RL(&rll, "Rejecting %s action because datapath does not support" "%s%s (your kernel module may be out of date)", action, detail ? " " : "", detail ? detail : ""); } diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c index a982de9d8db4..0e73d4e82dd5 100644 --- a/ofproto/ofproto.c +++ b/ofproto/ofproto.c @@ -5131,8 +5131,8 @@ ofproto_flow_mod_learn(struct ofproto_flow_mod *ofm, bool keep_ref, ofproto_flow_mod_learn_finish(ofm, NULL); } } else { - static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5); - VLOG_INFO_RL(&rl, "Learn limit for flow %"PRIu64" reached.", + static struct vlog_rate_limit rll = VLOG_RATE_LIMIT_INIT(1, 5); + VLOG_INFO_RL(&rll, "Learn limit for flow %"PRIu64" reached.", rule->flow_cookie); ofproto_flow_mod_uninit(ofm); From patchwork Wed Feb 28 08:00:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Justin Pettit X-Patchwork-Id: 878983 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ovn.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 3zrp396rwNz9ryL for ; Wed, 28 Feb 2018 19:03:17 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 259FFE28; Wed, 28 Feb 2018 08:01:58 +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 ECBCE9CD for ; Wed, 28 Feb 2018 08:01:53 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 8CF762F0 for ; Wed, 28 Feb 2018 08:01:53 +0000 (UTC) X-Originating-IP: 98.234.50.139 Received: from localhost.localdomain (unknown [98.234.50.139]) (Authenticated sender: jpettit@ovn.org) by relay5-d.mail.gandi.net (Postfix) with ESMTPSA id DCF4341C088 for ; Wed, 28 Feb 2018 09:01:51 +0100 (CET) From: Justin Pettit To: dev@openvswitch.org Date: Wed, 28 Feb 2018 00:00:57 -0800 Message-Id: <1519804863-73126-3-git-send-email-jpettit@ovn.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1519804863-73126-1-git-send-email-jpettit@ovn.org> References: <1519804863-73126-1-git-send-email-jpettit@ovn.org> X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [shadow 2/8] cmap: Allow CMAP_FOR_EACH to be nested without shadowing variables. 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 Signed-off-by: Justin Pettit Acked-by: Ben Pfaff --- lib/cmap.h | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/cmap.h b/lib/cmap.h index 5a72b65bec5e..2427a6293b64 100644 --- a/lib/cmap.h +++ b/lib/cmap.h @@ -233,11 +233,20 @@ struct cmap_cursor { struct cmap_cursor cmap_cursor_start(const struct cmap *); void cmap_cursor_advance(struct cmap_cursor *); -#define CMAP_FOR_EACH(NODE, MEMBER, CMAP) \ - for (struct cmap_cursor cursor__ = cmap_cursor_start(CMAP); \ - CMAP_CURSOR_FOR_EACH__(NODE, &cursor__, MEMBER); \ +/* Generate a unique name for the cursor with the __COUNTER__ macro to + * allow nesting of CMAP_FOR_EACH loops. */ +#define CURSOR_JOIN2(x,y) x##y +#define CURSOR_JOIN(x, y) CURSOR_JOIN2(x,y) +#define CURSOR_NAME CURSOR_JOIN(cursor_, __COUNTER__) + +#define CMAP_FOR_EACH__(NODE, MEMBER, CMAP, CURSOR_NAME) \ + for (struct cmap_cursor CURSOR_NAME = cmap_cursor_start(CMAP); \ + CMAP_CURSOR_FOR_EACH__(NODE, &CURSOR_NAME, MEMBER); \ ) +#define CMAP_FOR_EACH(NODE, MEMBER, CMAP) \ + CMAP_FOR_EACH__(NODE, MEMBER, CMAP, CURSOR_NAME) + static inline struct cmap_node *cmap_first(const struct cmap *); /* Another, less preferred, form of iteration, for use in situations where it From patchwork Wed Feb 28 08:00:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Justin Pettit X-Patchwork-Id: 878984 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ovn.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 3zrp3n2wtXz9s0q for ; Wed, 28 Feb 2018 19:03:49 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 4AD78E4F; Wed, 28 Feb 2018 08:01:59 +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 D4034C13 for ; Wed, 28 Feb 2018 08:01:55 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 9432A2F0 for ; Wed, 28 Feb 2018 08:01:54 +0000 (UTC) X-Originating-IP: 98.234.50.139 Received: from localhost.localdomain (unknown [98.234.50.139]) (Authenticated sender: jpettit@ovn.org) by relay5-d.mail.gandi.net (Postfix) with ESMTPSA id D56D641C0A6 for ; Wed, 28 Feb 2018 09:01:52 +0100 (CET) From: Justin Pettit To: dev@openvswitch.org Date: Wed, 28 Feb 2018 00:00:58 -0800 Message-Id: <1519804863-73126-4-git-send-email-jpettit@ovn.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1519804863-73126-1-git-send-email-jpettit@ovn.org> References: <1519804863-73126-1-git-send-email-jpettit@ovn.org> X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [shadow 3/8] dp-packet: Add index to DP_PACKET_BATCH_FOR_EACH to prevent shadowing. 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 Signed-off-by: Justin Pettit --- lib/conntrack.c | 2 +- lib/dp-packet.h | 16 ++++++++-------- lib/dpif-netdev.c | 24 +++++++++++------------- lib/netdev-dpdk.c | 2 +- lib/netdev-dummy.c | 2 +- lib/netdev-linux.c | 4 ++-- lib/netdev.c | 2 +- lib/odp-execute.c | 26 +++++++++++++------------- tests/test-conntrack.c | 4 ++-- 9 files changed, 40 insertions(+), 42 deletions(-) diff --git a/lib/conntrack.c b/lib/conntrack.c index c05b3901d7af..82229fa01853 100644 --- a/lib/conntrack.c +++ b/lib/conntrack.c @@ -1312,7 +1312,7 @@ conntrack_execute(struct conntrack *ct, struct dp_packet_batch *pkt_batch, struct dp_packet *packet; struct conn_lookup_ctx ctx; - DP_PACKET_BATCH_FOR_EACH (packet, pkt_batch) { + DP_PACKET_BATCH_FOR_EACH (i, packet, pkt_batch) { if (!conn_key_extract(ct, packet, dl_type, &ctx, zone)) { packet->md.ct_state = CS_INVALID; write_ct_md(packet, zone, NULL, NULL, NULL); diff --git a/lib/dp-packet.h b/lib/dp-packet.h index b4b721cec241..21c8ca525ffb 100644 --- a/lib/dp-packet.h +++ b/lib/dp-packet.h @@ -759,9 +759,9 @@ dp_packet_batch_is_empty(const struct dp_packet_batch *batch) return !dp_packet_batch_size(batch); } -#define DP_PACKET_BATCH_FOR_EACH(PACKET, BATCH) \ - for (size_t i = 0; i < dp_packet_batch_size(BATCH); i++) \ - if (PACKET = BATCH->packets[i], true) +#define DP_PACKET_BATCH_FOR_EACH(IDX, PACKET, BATCH) \ + for (size_t IDX = 0; IDX < dp_packet_batch_size(BATCH); IDX++) \ + if (PACKET = BATCH->packets[IDX], true) /* Use this macro for cases where some packets in the 'BATCH' may be * dropped after going through each packet in the 'BATCH'. @@ -785,7 +785,7 @@ dp_packet_batch_clone(struct dp_packet_batch *dst, struct dp_packet *packet; dp_packet_batch_init(dst); - DP_PACKET_BATCH_FOR_EACH (packet, src) { + DP_PACKET_BATCH_FOR_EACH (i, packet, src) { dp_packet_batch_add(dst, dp_packet_clone(packet)); } dst->trunc = src->trunc; @@ -797,7 +797,7 @@ dp_packet_delete_batch(struct dp_packet_batch *batch, bool may_steal) if (may_steal) { struct dp_packet *packet; - DP_PACKET_BATCH_FOR_EACH (packet, batch) { + DP_PACKET_BATCH_FOR_EACH (i, packet, batch) { dp_packet_delete(packet); } dp_packet_batch_init(batch); @@ -809,7 +809,7 @@ dp_packet_batch_init_packet_fields(struct dp_packet_batch *batch) { struct dp_packet *packet; - DP_PACKET_BATCH_FOR_EACH (packet, batch) { + DP_PACKET_BATCH_FOR_EACH (i, packet, batch) { dp_packet_reset_cutlen(packet); packet->packet_type = htonl(PT_ETH); } @@ -821,7 +821,7 @@ dp_packet_batch_apply_cutlen(struct dp_packet_batch *batch) if (batch->trunc) { struct dp_packet *packet; - DP_PACKET_BATCH_FOR_EACH (packet, batch) { + DP_PACKET_BATCH_FOR_EACH (i, packet, batch) { dp_packet_set_size(packet, dp_packet_get_send_len(packet)); dp_packet_reset_cutlen(packet); } @@ -835,7 +835,7 @@ dp_packet_batch_reset_cutlen(struct dp_packet_batch *batch) if (batch->trunc) { struct dp_packet *packet; - DP_PACKET_BATCH_FOR_EACH (packet, batch) { + DP_PACKET_BATCH_FOR_EACH (i, packet, batch) { dp_packet_reset_cutlen(packet); } batch->trunc = false; diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c index d49c986c806d..c0959050d47c 100644 --- a/lib/dpif-netdev.c +++ b/lib/dpif-netdev.c @@ -4223,7 +4223,6 @@ dp_netdev_run_meter(struct dp_netdev *dp, struct dp_packet_batch *packets_, struct dp_packet *packet; long long int long_delta_t; /* msec */ uint32_t delta_t; /* msec */ - int i; const size_t cnt = dp_packet_batch_size(packets_); uint32_t bytes, volume; int exceeded_band[NETDEV_MAX_BURST]; @@ -4257,7 +4256,7 @@ dp_netdev_run_meter(struct dp_netdev *dp, struct dp_packet_batch *packets_, meter->used = now; meter->packet_count += cnt; bytes = 0; - DP_PACKET_BATCH_FOR_EACH (packet, packets_) { + DP_PACKET_BATCH_FOR_EACH (i, packet, packets_) { bytes += dp_packet_size(packet); } meter->byte_count += bytes; @@ -4299,7 +4298,7 @@ dp_netdev_run_meter(struct dp_netdev *dp, struct dp_packet_batch *packets_, /* Update the exceeding band for each exceeding packet. * (Only one band will be fired by a packet, and that * can be different for each packet.) */ - for (i = band_exceeded_pkt; i < cnt; i++) { + for (int i = band_exceeded_pkt; i < cnt; i++) { if (band->up.rate > exceeded_rate[i]) { exceeded_rate[i] = band->up.rate; exceeded_band[i] = m; @@ -4308,7 +4307,7 @@ dp_netdev_run_meter(struct dp_netdev *dp, struct dp_packet_batch *packets_, } else { /* Packet sizes differ, must process one-by-one. */ band_exceeded_pkt = cnt; - DP_PACKET_BATCH_FOR_EACH (packet, packets_) { + DP_PACKET_BATCH_FOR_EACH (i, packet, packets_) { uint32_t bits = dp_packet_size(packet) * 8; if (band->bucket >= bits) { @@ -5147,9 +5146,8 @@ fast_path_processing(struct dp_netdev_pmd_thread *pmd, int upcall_ok_cnt = 0, upcall_fail_cnt = 0; int lookup_cnt = 0, add_lookup_cnt; bool any_miss; - size_t i; - for (i = 0; i < cnt; i++) { + for (size_t i = 0; i < cnt; i++) { /* Key length is needed in all the cases, hash computed on demand. */ keys[i].len = netdev_flow_key_size(miniflow_n_values(&keys[i].mf)); } @@ -5168,7 +5166,7 @@ fast_path_processing(struct dp_netdev_pmd_thread *pmd, ofpbuf_use_stub(&actions, actions_stub, sizeof actions_stub); ofpbuf_use_stub(&put_actions, slow_stub, sizeof slow_stub); - DP_PACKET_BATCH_FOR_EACH (packet, packets_) { + DP_PACKET_BATCH_FOR_EACH (i, packet, packets_) { struct dp_netdev_flow *netdev_flow; if (OVS_LIKELY(rules[i])) { @@ -5200,7 +5198,7 @@ fast_path_processing(struct dp_netdev_pmd_thread *pmd, ofpbuf_uninit(&put_actions); fat_rwlock_unlock(&dp->upcall_rwlock); } else if (OVS_UNLIKELY(any_miss)) { - DP_PACKET_BATCH_FOR_EACH (packet, packets_) { + DP_PACKET_BATCH_FOR_EACH (i, packet, packets_) { if (OVS_UNLIKELY(!rules[i])) { dp_packet_delete(packet); upcall_fail_cnt++; @@ -5208,7 +5206,7 @@ fast_path_processing(struct dp_netdev_pmd_thread *pmd, } } - DP_PACKET_BATCH_FOR_EACH (packet, packets_) { + DP_PACKET_BATCH_FOR_EACH (i, packet, packets_) { struct dp_netdev_flow *flow; if (OVS_UNLIKELY(!rules[i])) { @@ -5495,7 +5493,7 @@ dp_execute_cb(void *aux_, struct dp_packet_batch *packets_, pmd->n_output_batches++; } - DP_PACKET_BATCH_FOR_EACH (packet, packets_) { + DP_PACKET_BATCH_FOR_EACH (i, packet, packets_) { p->output_pkts_rxqs[dp_packet_batch_size(&p->output_pkts)] = pmd->ctx.last_rxq; dp_packet_batch_add(&p->output_pkts, packet); @@ -5535,7 +5533,7 @@ dp_execute_cb(void *aux_, struct dp_packet_batch *packets_, } struct dp_packet *packet; - DP_PACKET_BATCH_FOR_EACH (packet, packets_) { + DP_PACKET_BATCH_FOR_EACH (i, packet, packets_) { packet->md.in_port.odp_port = portno; } @@ -5572,7 +5570,7 @@ dp_execute_cb(void *aux_, struct dp_packet_batch *packets_, } struct dp_packet *packet; - DP_PACKET_BATCH_FOR_EACH (packet, packets_) { + DP_PACKET_BATCH_FOR_EACH (i, packet, packets_) { flow_extract(packet, &flow); dpif_flow_hash(dp->dpif, &flow, sizeof flow, &ufid); dp_execute_userspace_action(pmd, packet, may_steal, &flow, @@ -5600,7 +5598,7 @@ dp_execute_cb(void *aux_, struct dp_packet_batch *packets_, } struct dp_packet *packet; - DP_PACKET_BATCH_FOR_EACH (packet, packets_) { + DP_PACKET_BATCH_FOR_EACH (i, packet, packets_) { packet->md.recirc_id = nl_attr_get_u32(a); } diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c index 94fb163708a3..af9843a943f1 100644 --- a/lib/netdev-dpdk.c +++ b/lib/netdev-dpdk.c @@ -3297,7 +3297,7 @@ netdev_dpdk_ring_send(struct netdev *netdev, int qid, * the rss hash field is clear. This is because the same mbuf may be * modified by the consumer of the ring and return into the datapath * without recalculating the RSS hash. */ - DP_PACKET_BATCH_FOR_EACH (packet, batch) { + DP_PACKET_BATCH_FOR_EACH (i, packet, batch) { dp_packet_mbuf_rss_flag_reset(packet); } diff --git a/lib/netdev-dummy.c b/lib/netdev-dummy.c index 0d05759e4945..8af9e1a03166 100644 --- a/lib/netdev-dummy.c +++ b/lib/netdev-dummy.c @@ -1081,7 +1081,7 @@ netdev_dummy_send(struct netdev *netdev, int qid OVS_UNUSED, int error = 0; struct dp_packet *packet; - DP_PACKET_BATCH_FOR_EACH(packet, batch) { + DP_PACKET_BATCH_FOR_EACH(i, packet, batch) { const void *buffer = dp_packet_data(packet); size_t size = dp_packet_size(packet); diff --git a/lib/netdev-linux.c b/lib/netdev-linux.c index b3ef0f7c0615..7ea40a891152 100644 --- a/lib/netdev-linux.c +++ b/lib/netdev-linux.c @@ -1203,7 +1203,7 @@ netdev_linux_sock_batch_send(int sock, int ifindex, struct iovec *iov = xmalloc(sizeof(*iov) * size); struct dp_packet *packet; - DP_PACKET_BATCH_FOR_EACH (packet, batch) { + DP_PACKET_BATCH_FOR_EACH (i, packet, batch) { iov[i].iov_base = dp_packet_data(packet); iov[i].iov_len = dp_packet_size(packet); mmsg[i].msg_hdr = (struct msghdr) { .msg_name = &sll, @@ -1252,7 +1252,7 @@ netdev_linux_tap_batch_send(struct netdev *netdev_, return 0; } - DP_PACKET_BATCH_FOR_EACH (packet, batch) { + DP_PACKET_BATCH_FOR_EACH (i, packet, batch) { size_t size = dp_packet_size(packet); ssize_t retval; int error; diff --git a/lib/netdev.c b/lib/netdev.c index be05dc64024a..5a97ce53eb7a 100644 --- a/lib/netdev.c +++ b/lib/netdev.c @@ -854,7 +854,7 @@ netdev_push_header(const struct netdev *netdev, const struct ovs_action_push_tnl *data) { struct dp_packet *packet; - DP_PACKET_BATCH_FOR_EACH (packet, batch) { + DP_PACKET_BATCH_FOR_EACH (i, packet, batch) { netdev->netdev_class->push_header(packet, data); pkt_metadata_init(&packet->md, data->out_port); } diff --git a/lib/odp-execute.c b/lib/odp-execute.c index 12bba83ea32c..1969f0266361 100644 --- a/lib/odp-execute.c +++ b/lib/odp-execute.c @@ -737,7 +737,7 @@ odp_execute_actions(void *dp, struct dp_packet_batch *batch, bool steal, struct flow flow; uint32_t hash; - DP_PACKET_BATCH_FOR_EACH (packet, batch) { + DP_PACKET_BATCH_FOR_EACH (i, packet, batch) { /* RSS hash can be used here instead of 5tuple for * performance reasons. */ if (dp_packet_rss_valid(packet)) { @@ -759,14 +759,14 @@ odp_execute_actions(void *dp, struct dp_packet_batch *batch, bool steal, case OVS_ACTION_ATTR_PUSH_VLAN: { const struct ovs_action_push_vlan *vlan = nl_attr_get(a); - DP_PACKET_BATCH_FOR_EACH (packet, batch) { + DP_PACKET_BATCH_FOR_EACH (i, packet, batch) { eth_push_vlan(packet, vlan->vlan_tpid, vlan->vlan_tci); } break; } case OVS_ACTION_ATTR_POP_VLAN: - DP_PACKET_BATCH_FOR_EACH (packet, batch) { + DP_PACKET_BATCH_FOR_EACH (i, packet, batch) { eth_pop_vlan(packet); } break; @@ -774,32 +774,32 @@ odp_execute_actions(void *dp, struct dp_packet_batch *batch, bool steal, case OVS_ACTION_ATTR_PUSH_MPLS: { const struct ovs_action_push_mpls *mpls = nl_attr_get(a); - DP_PACKET_BATCH_FOR_EACH (packet, batch) { + DP_PACKET_BATCH_FOR_EACH (i, packet, batch) { push_mpls(packet, mpls->mpls_ethertype, mpls->mpls_lse); } break; } case OVS_ACTION_ATTR_POP_MPLS: - DP_PACKET_BATCH_FOR_EACH (packet, batch) { + DP_PACKET_BATCH_FOR_EACH (i, packet, batch) { pop_mpls(packet, nl_attr_get_be16(a)); } break; case OVS_ACTION_ATTR_SET: - DP_PACKET_BATCH_FOR_EACH (packet, batch) { + DP_PACKET_BATCH_FOR_EACH (i, packet, batch) { odp_execute_set_action(packet, nl_attr_get(a)); } break; case OVS_ACTION_ATTR_SET_MASKED: - DP_PACKET_BATCH_FOR_EACH(packet, batch) { + DP_PACKET_BATCH_FOR_EACH(i, packet, batch) { odp_execute_masked_set_action(packet, nl_attr_get(a)); } break; case OVS_ACTION_ATTR_SAMPLE: - DP_PACKET_BATCH_FOR_EACH (packet, batch) { + DP_PACKET_BATCH_FOR_EACH (i, packet, batch) { odp_execute_sample(dp, packet, steal && last_action, a, dp_execute_action); } @@ -816,7 +816,7 @@ odp_execute_actions(void *dp, struct dp_packet_batch *batch, bool steal, nl_attr_get_unspec(a, sizeof *trunc); batch->trunc = true; - DP_PACKET_BATCH_FOR_EACH (packet, batch) { + DP_PACKET_BATCH_FOR_EACH (i, packet, batch) { dp_packet_set_cutlen(packet, trunc->max_len); } break; @@ -837,7 +837,7 @@ odp_execute_actions(void *dp, struct dp_packet_batch *batch, bool steal, case OVS_ACTION_ATTR_PUSH_ETH: { const struct ovs_action_push_eth *eth = nl_attr_get(a); - DP_PACKET_BATCH_FOR_EACH (packet, batch) { + DP_PACKET_BATCH_FOR_EACH (i, packet, batch) { push_eth(packet, ð->addresses.eth_dst, ð->addresses.eth_src); } @@ -845,7 +845,7 @@ odp_execute_actions(void *dp, struct dp_packet_batch *batch, bool steal, } case OVS_ACTION_ATTR_POP_ETH: - DP_PACKET_BATCH_FOR_EACH (packet, batch) { + DP_PACKET_BATCH_FOR_EACH (i, packet, batch) { pop_eth(packet); } break; @@ -855,7 +855,7 @@ odp_execute_actions(void *dp, struct dp_packet_batch *batch, bool steal, struct nsh_hdr *nsh_hdr = ALIGNED_CAST(struct nsh_hdr *, buffer); nsh_reset_ver_flags_ttl_len(nsh_hdr); odp_nsh_hdr_from_attr(nl_attr_get(a), nsh_hdr, NSH_HDR_MAX_LEN); - DP_PACKET_BATCH_FOR_EACH (packet, batch) { + DP_PACKET_BATCH_FOR_EACH (i, packet, batch) { push_nsh(packet, nsh_hdr); } break; @@ -874,7 +874,7 @@ odp_execute_actions(void *dp, struct dp_packet_batch *batch, bool steal, break; } case OVS_ACTION_ATTR_CT_CLEAR: - DP_PACKET_BATCH_FOR_EACH (packet, batch) { + DP_PACKET_BATCH_FOR_EACH (i, packet, batch) { conntrack_clear(packet); } break; diff --git a/tests/test-conntrack.c b/tests/test-conntrack.c index 76bca2e59576..b6920e876289 100644 --- a/tests/test-conntrack.c +++ b/tests/test-conntrack.c @@ -162,7 +162,7 @@ pcap_batch_execute_conntrack(struct conntrack *ct, /* pkt_batch contains packets with different 'dl_type'. We have to * call conntrack_execute() on packets with the same 'dl_type'. */ struct dp_packet *packet; - DP_PACKET_BATCH_FOR_EACH (packet, pkt_batch) { + DP_PACKET_BATCH_FOR_EACH (i, packet, pkt_batch) { struct flow flow; /* This also initializes the l3 and l4 pointers. */ @@ -231,7 +231,7 @@ test_pcap(struct ovs_cmdl_context *ctx) } pcap_batch_execute_conntrack(&ct, batch); - DP_PACKET_BATCH_FOR_EACH (packet, batch) { + DP_PACKET_BATCH_FOR_EACH (i, packet, batch) { struct ds ds = DS_EMPTY_INITIALIZER; total_count++; From patchwork Wed Feb 28 08:00:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Justin Pettit X-Patchwork-Id: 878985 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ovn.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 3zrp4K4LY6z9s0q for ; Wed, 28 Feb 2018 19:04:17 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 77435EF3; Wed, 28 Feb 2018 08:02:00 +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 E3C6EC9F for ; Wed, 28 Feb 2018 08:01:55 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 71F01151 for ; Wed, 28 Feb 2018 08:01:55 +0000 (UTC) X-Originating-IP: 98.234.50.139 Received: from localhost.localdomain (unknown [98.234.50.139]) (Authenticated sender: jpettit@ovn.org) by relay5-d.mail.gandi.net (Postfix) with ESMTPSA id CB93841C097 for ; Wed, 28 Feb 2018 09:01:53 +0100 (CET) From: Justin Pettit To: dev@openvswitch.org Date: Wed, 28 Feb 2018 00:00:59 -0800 Message-Id: <1519804863-73126-5-git-send-email-jpettit@ovn.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1519804863-73126-1-git-send-email-jpettit@ovn.org> References: <1519804863-73126-1-git-send-email-jpettit@ovn.org> X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [shadow 4/8] Don't shadow iterator values. 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 Signed-off-by: Justin Pettit --- lib/dpif-netdev.c | 4 ++-- lib/nx-match.c | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c index c0959050d47c..b07fc6b8b327 100644 --- a/lib/dpif-netdev.c +++ b/lib/dpif-netdev.c @@ -3536,7 +3536,7 @@ rxq_scheduling(struct dp_netdev *dp, bool pinned) OVS_REQUIRES(dp->port_mutex) struct rr_numa_list rr; struct rr_numa *non_local_numa = NULL; struct dp_netdev_rxq ** rxqs = NULL; - int i, n_rxqs = 0; + int n_rxqs = 0; struct rr_numa *numa = NULL; int numa_id; @@ -3589,7 +3589,7 @@ rxq_scheduling(struct dp_netdev *dp, bool pinned) OVS_REQUIRES(dp->port_mutex) rr_numa_list_populate(dp, &rr); /* Assign the sorted queues to pmds in round robin. */ - for (i = 0; i < n_rxqs; i++) { + for (int i = 0; i < n_rxqs; i++) { numa_id = netdev_get_numa_id(rxqs[i]->port->netdev); numa = rr_numa_list_lookup(&rr, numa_id); if (!numa) { diff --git a/lib/nx-match.c b/lib/nx-match.c index 005c4a6ac09d..a8edb2e9d245 100644 --- a/lib/nx-match.c +++ b/lib/nx-match.c @@ -1025,7 +1025,6 @@ nx_put_raw(struct ofpbuf *b, enum ofp_version oxm, const struct match *match, ovs_be16 dl_type = get_dl_type(flow); ovs_be32 spi_mask; int match_len; - int i; BUILD_ASSERT_DECL(FLOW_WC_SEQ == 40); @@ -1182,12 +1181,12 @@ nx_put_raw(struct ofpbuf *b, enum ofp_version oxm, const struct match *match, /* Registers. */ if (oxm < OFP15_VERSION) { - for (i = 0; i < FLOW_N_REGS; i++) { + for (int i = 0; i < FLOW_N_REGS; i++) { nxm_put_32m(&ctx, MFF_REG0 + i, oxm, htonl(flow->regs[i]), htonl(match->wc.masks.regs[i])); } } else { - for (i = 0; i < FLOW_N_XREGS; i++) { + for (int i = 0; i < FLOW_N_XREGS; i++) { nxm_put_64m(&ctx, MFF_XREG0 + i, oxm, htonll(flow_get_xreg(flow, i)), htonll(flow_get_xreg(&match->wc.masks, i))); From patchwork Wed Feb 28 08:01:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Justin Pettit X-Patchwork-Id: 878986 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ovn.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 3zrp4y6Q2yz9s0q for ; Wed, 28 Feb 2018 19:04:50 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id B43FDF37; Wed, 28 Feb 2018 08:02:04 +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 D81B0D08 for ; Wed, 28 Feb 2018 08:01:56 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 793A5151 for ; Wed, 28 Feb 2018 08:01:56 +0000 (UTC) X-Originating-IP: 98.234.50.139 Received: from localhost.localdomain (unknown [98.234.50.139]) (Authenticated sender: jpettit@ovn.org) by relay5-d.mail.gandi.net (Postfix) with ESMTPSA id C755F41C0A3 for ; Wed, 28 Feb 2018 09:01:54 +0100 (CET) From: Justin Pettit To: dev@openvswitch.org Date: Wed, 28 Feb 2018 00:01:00 -0800 Message-Id: <1519804863-73126-6-git-send-email-jpettit@ovn.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1519804863-73126-1-git-send-email-jpettit@ovn.org> References: <1519804863-73126-1-git-send-email-jpettit@ovn.org> X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [shadow 5/8] db-ctl-base: Don't shadow 'invalidate_cache' callback. 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 Signed-off-by: Justin Pettit --- lib/db-ctl-base.c | 8 ++++---- lib/db-ctl-base.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/db-ctl-base.c b/lib/db-ctl-base.c index ae7b6cde27f4..bfd7a54a8b5a 100644 --- a/lib/db-ctl-base.c +++ b/lib/db-ctl-base.c @@ -793,8 +793,8 @@ is_condition_satisfied(const struct ovsdb_idl_table_class *table, static void invalidate_cache(struct ctl_context *ctx) { - if (ctx->invalidate_cache) { - (ctx->invalidate_cache)(ctx); + if (ctx->invalidate_cache_cb) { + (ctx->invalidate_cache_cb)(ctx); } } @@ -2250,7 +2250,7 @@ void ctl_context_init(struct ctl_context *ctx, struct ctl_command *command, struct ovsdb_idl *idl, struct ovsdb_idl_txn *txn, struct ovsdb_symbol_table *symtab, - void (*invalidate_cache)(struct ctl_context *)) + void (*invalidate_cache_cb)(struct ctl_context *)) { if (command) { ctl_context_init_command(ctx, command); @@ -2258,7 +2258,7 @@ ctl_context_init(struct ctl_context *ctx, struct ctl_command *command, ctx->idl = idl; ctx->txn = txn; ctx->symtab = symtab; - ctx->invalidate_cache = invalidate_cache; + ctx->invalidate_cache_cb = invalidate_cache_cb; } /* Completes processing of 'command' within 'ctx'. */ diff --git a/lib/db-ctl-base.h b/lib/db-ctl-base.h index a2f91abfb31e..eb444270535b 100644 --- a/lib/db-ctl-base.h +++ b/lib/db-ctl-base.h @@ -231,7 +231,7 @@ struct ctl_context { /* For implementation with a cache of the contents of the database, * this function will be called when the database is changed and the * change makes the cache no longer valid. */ - void (*invalidate_cache)(struct ctl_context *); + void (*invalidate_cache_cb)(struct ctl_context *); /* A command may set this member to true if some prerequisite is not met * and the caller should wait for something to change and then retry. */ From patchwork Wed Feb 28 08:01:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Justin Pettit X-Patchwork-Id: 878987 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ovn.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 3zrp5S27yKz9s0q for ; Wed, 28 Feb 2018 19:05:15 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id A0F4D12A3; Wed, 28 Feb 2018 08:02:05 +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 E9AA5D1F for ; Wed, 28 Feb 2018 08:01:57 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 647C9151 for ; Wed, 28 Feb 2018 08:01:57 +0000 (UTC) X-Originating-IP: 98.234.50.139 Received: from localhost.localdomain (unknown [98.234.50.139]) (Authenticated sender: jpettit@ovn.org) by relay5-d.mail.gandi.net (Postfix) with ESMTPSA id BC4D341C0AC for ; Wed, 28 Feb 2018 09:01:55 +0100 (CET) From: Justin Pettit To: dev@openvswitch.org Date: Wed, 28 Feb 2018 00:01:01 -0800 Message-Id: <1519804863-73126-7-git-send-email-jpettit@ovn.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1519804863-73126-1-git-send-email-jpettit@ovn.org> References: <1519804863-73126-1-git-send-email-jpettit@ovn.org> X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [shadow 6/8] ovs-numa: Prevent shadowing 'dummy_config'. 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 Signed-off-by: Justin Pettit --- lib/ovs-numa.c | 34 ++++++++++------------------------ lib/ovs-numa.h | 2 +- 2 files changed, 11 insertions(+), 25 deletions(-) diff --git a/lib/ovs-numa.c b/lib/ovs-numa.c index 98e97cb33fdd..24edeab2a8d9 100644 --- a/lib/ovs-numa.c +++ b/lib/ovs-numa.c @@ -122,8 +122,9 @@ insert_new_cpu_core(struct numa_node *n, unsigned core_id) return c; } -/* Has the same effect as discover_numa_and_core(), but instead of reading - * sysfs entries, extracts the info from 'dummy_config'. +/* Has the same effect as discover_numa_and_core(), but instead of + * reading sysfs entries, extracts the info from the global variable + * 'dummy_config', which is set with ovs_numa_set_dummy(). * * 'dummy_config' lists the numa_ids of each CPU separated by a comma, e.g. * - "0,0,0,0": four cores on numa socket 0. @@ -132,7 +133,7 @@ insert_new_cpu_core(struct numa_node *n, unsigned core_id) * * The different numa ids must be consecutives or the function will abort. */ static void -discover_numa_and_core_dummy(const char *dummy_config) +discover_numa_and_core_dummy(void) { char *conf = xstrdup(dummy_config); char *id, *saveptr = NULL; @@ -268,19 +269,19 @@ get_numa_by_numa_id(int numa_id) } - -static bool -ovs_numa_init__(const char *dummy_config) +/* Initializes the numa module. */ +void +ovs_numa_init(void) { static struct ovsthread_once once = OVSTHREAD_ONCE_INITIALIZER; if (ovsthread_once_start(&once)) { const struct numa_node *n; - if (!dummy_config) { - discover_numa_and_core(); + if (dummy_numa) { + discover_numa_and_core_dummy(); } else { - discover_numa_and_core_dummy(dummy_config); + discover_numa_and_core(); } HMAP_FOR_EACH(n, hmap_node, &all_numa_nodes) { @@ -296,10 +297,6 @@ ovs_numa_init__(const char *dummy_config) } ovsthread_once_done(&once); - - return true; - } else { - return false; } } @@ -317,17 +314,6 @@ ovs_numa_set_dummy(const char *config) dummy_config = xstrdup(config); } -/* Initializes the numa module. */ -void -ovs_numa_init(void) -{ - if (dummy_numa) { - ovs_numa_init__(dummy_config); - } else { - ovs_numa_init__(NULL); - } -} - bool ovs_numa_numa_id_is_valid(int numa_id) { diff --git a/lib/ovs-numa.h b/lib/ovs-numa.h index 6946cdc0889a..088fcb8c3b42 100644 --- a/lib/ovs-numa.h +++ b/lib/ovs-numa.h @@ -47,7 +47,7 @@ struct ovs_numa_info_numa { }; void ovs_numa_init(void); -void ovs_numa_set_dummy(const char *dummy_config); +void ovs_numa_set_dummy(const char *config); bool ovs_numa_numa_id_is_valid(int numa_id); bool ovs_numa_core_id_is_valid(unsigned core_id); int ovs_numa_get_n_numas(void); From patchwork Wed Feb 28 08:01:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Justin Pettit X-Patchwork-Id: 878989 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ovn.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 3zrp6T4QnGz9s31 for ; Wed, 28 Feb 2018 19:06:09 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 8191112E4; Wed, 28 Feb 2018 08:02:07 +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 F1883EF3 for ; Wed, 28 Feb 2018 08:01:59 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 6A02E151 for ; Wed, 28 Feb 2018 08:01:58 +0000 (UTC) X-Originating-IP: 98.234.50.139 Received: from localhost.localdomain (unknown [98.234.50.139]) (Authenticated sender: jpettit@ovn.org) by relay5-d.mail.gandi.net (Postfix) with ESMTPSA id AC21941C080 for ; Wed, 28 Feb 2018 09:01:56 +0100 (CET) From: Justin Pettit To: dev@openvswitch.org Date: Wed, 28 Feb 2018 00:01:02 -0800 Message-Id: <1519804863-73126-8-git-send-email-jpettit@ovn.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1519804863-73126-1-git-send-email-jpettit@ovn.org> References: <1519804863-73126-1-git-send-email-jpettit@ovn.org> X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [shadow 7/8] Don't shadow variables. 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 Rename the remaining variables that were shadowing another definition. Signed-off-by: Justin Pettit Acked-by: Ben Pfaff --- lib/daemon-unix.c | 62 +++++++++++++++++++++---------------------- lib/route-table.c | 9 ++++--- ofproto/ofproto-dpif-upcall.c | 50 +++++++++++++++------------------- ofproto/ofproto-dpif.c | 2 -- ovn/controller/ofctrl.c | 12 ++++----- ovn/controller/pinctrl.c | 10 +++---- ovn/northd/ovn-northd.c | 8 +++--- tests/test-classifier.c | 4 +-- tests/test-conntrack.c | 16 +++++------ utilities/ovs-ofctl.c | 24 ++++++++--------- 10 files changed, 95 insertions(+), 102 deletions(-) diff --git a/lib/daemon-unix.c b/lib/daemon-unix.c index adb549c98920..04c6a874e7ac 100644 --- a/lib/daemon-unix.c +++ b/lib/daemon-unix.c @@ -572,7 +572,7 @@ lock_pidfile(FILE *file, int command) } static pid_t -read_pidfile__(const char *pidfile, bool delete_if_stale) +read_pidfile__(const char *pidfile_, bool delete_if_stale) { struct stat s, s2; struct flock lck; @@ -581,7 +581,7 @@ read_pidfile__(const char *pidfile, bool delete_if_stale) int error; if ((pidfile_ino || pidfile_dev) - && !stat(pidfile, &s) + && !stat(pidfile_, &s) && s.st_ino == pidfile_ino && s.st_dev == pidfile_dev) { /* It's our own pidfile. We can't afford to open it, because closing * *any* fd for a file that a process has locked also releases all the @@ -591,19 +591,19 @@ read_pidfile__(const char *pidfile, bool delete_if_stale) return getpid(); } - file = fopen(pidfile, "r+"); + file = fopen(pidfile_, "r+"); if (!file) { if (errno == ENOENT && delete_if_stale) { return 0; } error = errno; - VLOG_WARN("%s: open: %s", pidfile, ovs_strerror(error)); + VLOG_WARN("%s: open: %s", pidfile_, ovs_strerror(error)); goto error; } error = lock_pidfile__(file, F_GETLK, &lck); if (error) { - VLOG_WARN("%s: fcntl: %s", pidfile, ovs_strerror(error)); + VLOG_WARN("%s: fcntl: %s", pidfile_, ovs_strerror(error)); goto error; } if (lck.l_type == F_UNLCK) { @@ -616,7 +616,7 @@ read_pidfile__(const char *pidfile, bool delete_if_stale) * pidfile locked, and only that process has the right to unlink it. */ if (!delete_if_stale) { error = ESRCH; - VLOG_DBG("%s: pid file is stale", pidfile); + VLOG_DBG("%s: pid file is stale", pidfile_); goto error; } @@ -624,28 +624,28 @@ read_pidfile__(const char *pidfile, bool delete_if_stale) error = lock_pidfile(file, F_SETLK); if (error) { /* We lost a race with someone else doing the same thing. */ - VLOG_WARN("%s: lost race to lock pidfile", pidfile); + VLOG_WARN("%s: lost race to lock pidfile", pidfile_); goto error; } - /* Is the file we have locked still named 'pidfile'? */ - if (stat(pidfile, &s) || fstat(fileno(file), &s2) + /* Is the file we have locked still named 'pidfile_'? */ + if (stat(pidfile_, &s) || fstat(fileno(file), &s2) || s.st_ino != s2.st_ino || s.st_dev != s2.st_dev) { /* No. We lost a race with someone else who got the lock before * us, deleted the pidfile, and closed it (releasing the lock). */ error = EALREADY; - VLOG_WARN("%s: lost race to delete pidfile", pidfile); + VLOG_WARN("%s: lost race to delete pidfile", pidfile_); goto error; } /* We won the right to delete the stale pidfile. */ - if (unlink(pidfile)) { + if (unlink(pidfile_)) { error = errno; VLOG_WARN("%s: failed to delete stale pidfile (%s)", - pidfile, ovs_strerror(error)); + pidfile_, ovs_strerror(error)); goto error; } - VLOG_DBG("%s: deleted stale pidfile", pidfile); + VLOG_DBG("%s: deleted stale pidfile", pidfile_); fclose(file); return 0; } @@ -653,10 +653,10 @@ read_pidfile__(const char *pidfile, bool delete_if_stale) if (!fgets(line, sizeof line, file)) { if (ferror(file)) { error = errno; - VLOG_WARN("%s: read: %s", pidfile, ovs_strerror(error)); + VLOG_WARN("%s: read: %s", pidfile_, ovs_strerror(error)); } else { error = ESRCH; - VLOG_WARN("%s: read: unexpected end of file", pidfile); + VLOG_WARN("%s: read: unexpected end of file", pidfile_); } goto error; } @@ -667,7 +667,7 @@ read_pidfile__(const char *pidfile, bool delete_if_stale) * preparing to delete it. */ error = ESRCH; VLOG_WARN("%s: stale pidfile for pid %s being deleted by pid %ld", - pidfile, line, (long int) lck.l_pid); + pidfile_, line, (long int) lck.l_pid); goto error; } @@ -681,12 +681,12 @@ error: return -error; } -/* Opens and reads a PID from 'pidfile'. Returns the positive PID if +/* Opens and reads a PID from 'pidfile_'. Returns the positive PID if * successful, otherwise a negative errno value. */ pid_t -read_pidfile(const char *pidfile) +read_pidfile(const char *pidfile_) { - return read_pidfile__(pidfile, false); + return read_pidfile__(pidfile_, false); } /* Checks whether a process with the given 'pidfile' is already running and, @@ -730,22 +730,22 @@ gid_matches(gid_t expected, gid_t value) } static bool -gid_verify(gid_t gid) +gid_verify(gid_t gid_) { gid_t r, e; r = getgid(); e = getegid(); - return (gid_matches(gid, r) && - gid_matches(gid, e)); + return (gid_matches(gid_, r) && + gid_matches(gid_, e)); } static void -daemon_switch_group(gid_t gid) +daemon_switch_group(gid_t gid_) { - if ((setgid(gid) == -1) || !gid_verify(gid)) { + if ((setgid(gid_) == -1) || !gid_verify(gid_)) { VLOG_FATAL("%s: fail to switch group to gid as %d, aborting", - pidfile, gid); + pidfile, gid_); } } @@ -756,22 +756,22 @@ uid_matches(uid_t expected, uid_t value) } static bool -uid_verify(const uid_t uid) +uid_verify(const uid_t uid_) { uid_t r, e; r = getuid(); e = geteuid(); - return (uid_matches(uid, r) && - uid_matches(uid, e)); + return (uid_matches(uid_, r) && + uid_matches(uid_, e)); } static void -daemon_switch_user(const uid_t uid, const char *user) +daemon_switch_user(const uid_t uid_, const char *user_) { - if ((setuid(uid) == -1) || !uid_verify(uid)) { + if ((setuid(uid_) == -1) || !uid_verify(uid_)) { VLOG_FATAL("%s: fail to switch user to %s, aborting", - pidfile, user); + pidfile, user_); } } diff --git a/lib/route-table.c b/lib/route-table.c index 97a0be5c573a..2ee45e5c9dd5 100644 --- a/lib/route-table.c +++ b/lib/route-table.c @@ -155,7 +155,7 @@ static int route_table_reset(void) { struct nl_dump dump; - struct rtgenmsg *rtmsg; + struct rtgenmsg *rtgenmsg; uint64_t reply_stub[NL_DUMP_BUFSIZE / 8]; struct ofpbuf request, reply, buf; @@ -166,10 +166,11 @@ route_table_reset(void) ofpbuf_init(&request, 0); - nl_msg_put_nlmsghdr(&request, sizeof *rtmsg, RTM_GETROUTE, NLM_F_REQUEST); + nl_msg_put_nlmsghdr(&request, sizeof *rtgenmsg, RTM_GETROUTE, + NLM_F_REQUEST); - rtmsg = ofpbuf_put_zeros(&request, sizeof *rtmsg); - rtmsg->rtgen_family = AF_UNSPEC; + rtgenmsg = ofpbuf_put_zeros(&request, sizeof *rtgenmsg); + rtgenmsg->rtgen_family = AF_UNSPEC; nl_dump_start(&dump, NETLINK_ROUTE, &request); ofpbuf_uninit(&request); diff --git a/ofproto/ofproto-dpif-upcall.c b/ofproto/ofproto-dpif-upcall.c index e282a437e84a..526be7760e0a 100644 --- a/ofproto/ofproto-dpif-upcall.c +++ b/ofproto/ofproto-dpif-upcall.c @@ -534,18 +534,15 @@ udpif_stop_threads(struct udpif *udpif) /* Starts the handler and revalidator threads, must be enclosed in * ovsrcu quiescent state. */ static void -udpif_start_threads(struct udpif *udpif, size_t n_handlers, - size_t n_revalidators) +udpif_start_threads(struct udpif *udpif, size_t n_handlers_, + size_t n_revalidators_) { - if (udpif && n_handlers && n_revalidators) { - size_t i; - bool enable_ufid; - - udpif->n_handlers = n_handlers; - udpif->n_revalidators = n_revalidators; + if (udpif && n_handlers_ && n_revalidators_) { + udpif->n_handlers = n_handlers_; + udpif->n_revalidators = n_revalidators_; udpif->handlers = xzalloc(udpif->n_handlers * sizeof *udpif->handlers); - for (i = 0; i < udpif->n_handlers; i++) { + for (size_t i = 0; i < udpif->n_handlers; i++) { struct handler *handler = &udpif->handlers[i]; handler->udpif = udpif; @@ -554,8 +551,7 @@ udpif_start_threads(struct udpif *udpif, size_t n_handlers, "handler", udpif_upcall_handler, handler); } - enable_ufid = udpif->backer->rt_support.ufid; - atomic_init(&udpif->enable_ufid, enable_ufid); + atomic_init(&udpif->enable_ufid, udpif->backer->rt_support.ufid); dpif_enable_upcall(udpif->dpif); ovs_barrier_init(&udpif->reval_barrier, udpif->n_revalidators); @@ -564,7 +560,7 @@ udpif_start_threads(struct udpif *udpif, size_t n_handlers, udpif->pause = false; udpif->revalidators = xzalloc(udpif->n_revalidators * sizeof *udpif->revalidators); - for (i = 0; i < udpif->n_revalidators; i++) { + for (size_t i = 0; i < udpif->n_revalidators; i++) { struct revalidator *revalidator = &udpif->revalidators[i]; revalidator->udpif = udpif; @@ -598,33 +594,33 @@ udpif_resume_revalidators(struct udpif *udpif) } /* Tells 'udpif' how many threads it should use to handle upcalls. - * 'n_handlers' and 'n_revalidators' can never be zero. 'udpif''s + * 'n_handlers_' and 'n_revalidators_' can never be zero. 'udpif''s * datapath handle must have packet reception enabled before starting * threads. */ void -udpif_set_threads(struct udpif *udpif, size_t n_handlers, - size_t n_revalidators) +udpif_set_threads(struct udpif *udpif, size_t n_handlers_, + size_t n_revalidators_) { ovs_assert(udpif); - ovs_assert(n_handlers && n_revalidators); + ovs_assert(n_handlers_ && n_revalidators_); ovsrcu_quiesce_start(); - if (udpif->n_handlers != n_handlers - || udpif->n_revalidators != n_revalidators) { + if (udpif->n_handlers != n_handlers_ + || udpif->n_revalidators != n_revalidators_) { udpif_stop_threads(udpif); } if (!udpif->handlers && !udpif->revalidators) { int error; - error = dpif_handlers_set(udpif->dpif, n_handlers); + error = dpif_handlers_set(udpif->dpif, n_handlers_); if (error) { VLOG_ERR("failed to configure handlers in dpif %s: %s", dpif_name(udpif->dpif), ovs_strerror(error)); return; } - udpif_start_threads(udpif, n_handlers, n_revalidators); + udpif_start_threads(udpif, n_handlers_, n_revalidators_); } ovsrcu_quiesce_end(); } @@ -639,12 +635,12 @@ udpif_synchronize(struct udpif *udpif) /* This is stronger than necessary. It would be sufficient to ensure * (somehow) that each handler and revalidator thread had passed through * its main loop once. */ - size_t n_handlers = udpif->n_handlers; - size_t n_revalidators = udpif->n_revalidators; + size_t n_handlers_ = udpif->n_handlers; + size_t n_revalidators_ = udpif->n_revalidators; ovsrcu_quiesce_start(); udpif_stop_threads(udpif); - udpif_start_threads(udpif, n_handlers, n_revalidators); + udpif_start_threads(udpif, n_handlers_, n_revalidators_); ovsrcu_quiesce_end(); } @@ -682,16 +678,14 @@ udpif_get_memory_usage(struct udpif *udpif, struct simap *usage) void udpif_flush(struct udpif *udpif) { - size_t n_handlers, n_revalidators; - - n_handlers = udpif->n_handlers; - n_revalidators = udpif->n_revalidators; + size_t n_handlers_ = udpif->n_handlers; + size_t n_revalidators_ = udpif->n_revalidators; ovsrcu_quiesce_start(); udpif_stop_threads(udpif); dpif_flow_flush(udpif->dpif); - udpif_start_threads(udpif, n_handlers, n_revalidators); + udpif_start_threads(udpif, n_handlers_, n_revalidators_); ovsrcu_quiesce_end(); } diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c index e28ce64c1934..c92c5bea1725 100644 --- a/ofproto/ofproto-dpif.c +++ b/ofproto/ofproto-dpif.c @@ -5239,8 +5239,6 @@ dpif_set_support(struct dpif_backer_support *rt_support, #undef ODP_SUPPORT_FIELD if (!name) { - struct shash_node *node; - SHASH_FOR_EACH (node, &all_fields) { display_support_field(node->name, node->data, ds); } diff --git a/ovn/controller/ofctrl.c b/ovn/controller/ofctrl.c index 897ff3694bfa..293b00f6714d 100644 --- a/ovn/controller/ofctrl.c +++ b/ovn/controller/ofctrl.c @@ -587,9 +587,9 @@ static ovs_be32 queue_msg(struct ofpbuf *msg) { const struct ofp_header *oh = msg->data; - ovs_be32 xid = oh->xid; + ovs_be32 xid_ = oh->xid; rconn_send(swconn, msg, tx_counter); - return xid; + return xid_; } static void @@ -1038,7 +1038,7 @@ ofctrl_put(struct hmap *flow_table, struct shash *pending_ct_zones, /* Add a barrier to the list of messages. */ struct ofpbuf *barrier = ofputil_encode_barrier_request(OFP13_VERSION); const struct ofp_header *oh = barrier->data; - ovs_be32 xid = oh->xid; + ovs_be32 xid_ = oh->xid; ovs_list_push_back(&msgs, &barrier->list_node); /* Queue the messages. */ @@ -1051,7 +1051,7 @@ ofctrl_put(struct hmap *flow_table, struct shash *pending_ct_zones, SHASH_FOR_EACH(iter, pending_ct_zones) { struct ct_zone_pending_entry *ctzpe = iter->data; if (ctzpe->state == CT_ZONE_OF_SENT && !ctzpe->of_xid) { - ctzpe->of_xid = xid; + ctzpe->of_xid = xid_; } } @@ -1076,7 +1076,7 @@ ofctrl_put(struct hmap *flow_table, struct shash *pending_ct_zones, * so that we don't send a notification that we're up-to-date * until we're really caught up. */ VLOG_DBG("advanced xid target for nb_cfg=%"PRId64, nb_cfg); - fup->xid = xid; + fup->xid = xid_; goto done; } else { break; @@ -1086,7 +1086,7 @@ ofctrl_put(struct hmap *flow_table, struct shash *pending_ct_zones, /* Add a flow update. */ fup = xmalloc(sizeof *fup); ovs_list_push_back(&flow_updates, &fup->list_node); - fup->xid = xid; + fup->xid = xid_; fup->nb_cfg = nb_cfg; done:; } else if (!ovs_list_is_empty(&flow_updates)) { diff --git a/ovn/controller/pinctrl.c b/ovn/controller/pinctrl.c index e34916f5c387..95ccd54e4e9b 100644 --- a/ovn/controller/pinctrl.c +++ b/ovn/controller/pinctrl.c @@ -119,9 +119,9 @@ queue_msg(struct ofpbuf *msg) return xid; } -/* Sets up 'swconn', a newly (re)connected connection to a switch. */ +/* Sets up global 'swconn', a newly (re)connected connection to a switch. */ static void -pinctrl_setup(struct rconn *swconn) +pinctrl_setup(void) { /* Fetch the switch configuration. The response later will allow us to * change the miss_send_len to UINT16_MAX, so that we can enable @@ -135,10 +135,10 @@ pinctrl_setup(struct rconn *swconn) } static void -set_switch_config(struct rconn *swconn, +set_switch_config(struct rconn *swconn_, const struct ofputil_switch_config *config) { - enum ofp_version version = rconn_get_version(swconn); + enum ofp_version version = rconn_get_version(swconn_); struct ofpbuf *request = ofputil_encode_set_config(config, version); queue_msg(request); } @@ -1078,7 +1078,7 @@ pinctrl_run(struct controller_ctx *ctx, } if (conn_seq_no != rconn_get_connection_seqno(swconn)) { - pinctrl_setup(swconn); + pinctrl_setup(); conn_seq_no = rconn_get_connection_seqno(swconn); flush_put_mac_bindings(); } diff --git a/ovn/northd/ovn-northd.c b/ovn/northd/ovn-northd.c index dcaa77dbf939..d83681c4f809 100644 --- a/ovn/northd/ovn-northd.c +++ b/ovn/northd/ovn-northd.c @@ -440,10 +440,10 @@ struct macam_node { }; static void -cleanup_macam(struct hmap *macam) +cleanup_macam(struct hmap *macam_) { struct macam_node *node; - HMAP_FOR_EACH_POP (node, hmap_node, macam) { + HMAP_FOR_EACH_POP (node, hmap_node, macam_) { free(node); } } @@ -4463,9 +4463,9 @@ add_router_lb_flow(struct hmap *lflows, struct ovn_datapath *od, while (ip_str && ip_str[0]) { char *ip_address = NULL; uint16_t port = 0; - int addr_family; + int addr_family_; ip_address_and_port_from_lb_key(ip_str, &ip_address, &port, - &addr_family); + &addr_family_); if (!ip_address) { break; } diff --git a/tests/test-classifier.c b/tests/test-classifier.c index 909260d11c00..6d53d016de60 100644 --- a/tests/test-classifier.c +++ b/tests/test-classifier.c @@ -1495,11 +1495,11 @@ benchmark(bool use_wc) static uint32_t random_value(void) { - static const uint32_t values[] = + static const uint32_t values_[] = { 0xffffffff, 0xaaaaaaaa, 0x55555555, 0x80000000, 0x00000001, 0xface0000, 0x00d00d1e, 0xdeadbeef }; - return values[random_range(ARRAY_SIZE(values))]; + return values_[random_range(ARRAY_SIZE(values_))]; } static bool diff --git a/tests/test-conntrack.c b/tests/test-conntrack.c index b6920e876289..12017ea83b46 100644 --- a/tests/test-conntrack.c +++ b/tests/test-conntrack.c @@ -150,7 +150,7 @@ test_benchmark(struct ovs_cmdl_context *ctx) } static void -pcap_batch_execute_conntrack(struct conntrack *ct, +pcap_batch_execute_conntrack(struct conntrack *ct_, struct dp_packet_batch *pkt_batch) { struct dp_packet_batch new_batch; @@ -173,7 +173,7 @@ pcap_batch_execute_conntrack(struct conntrack *ct, } if (flow.dl_type != dl_type) { - conntrack_execute(ct, &new_batch, dl_type, false, true, 0, + conntrack_execute(ct_, &new_batch, dl_type, false, true, 0, NULL, NULL, 0, 0, NULL, NULL, now); dp_packet_batch_init(&new_batch); } @@ -181,7 +181,7 @@ pcap_batch_execute_conntrack(struct conntrack *ct, } if (!dp_packet_batch_is_empty(&new_batch)) { - conntrack_execute(ct, &new_batch, dl_type, false, true, 0, NULL, NULL, + conntrack_execute(ct_, &new_batch, dl_type, false, true, 0, NULL, NULL, 0, 0, NULL, NULL, now); } @@ -190,7 +190,7 @@ pcap_batch_execute_conntrack(struct conntrack *ct, static void test_pcap(struct ovs_cmdl_context *ctx) { - size_t total_count, batch_size; + size_t total_count, batch_size_; FILE *pcap; int err = 0; @@ -199,10 +199,10 @@ test_pcap(struct ovs_cmdl_context *ctx) return; } - batch_size = 1; + batch_size_ = 1; if (ctx->argc > 2) { - batch_size = strtoul(ctx->argv[2], NULL, 0); - if (batch_size == 0 || batch_size > NETDEV_MAX_BURST) { + batch_size_ = strtoul(ctx->argv[2], NULL, 0); + if (batch_size_ == 0 || batch_size_ > NETDEV_MAX_BURST) { ovs_fatal(0, "batch_size must be between 1 and NETDEV_MAX_BURST(%u)", NETDEV_MAX_BURST); @@ -219,7 +219,7 @@ test_pcap(struct ovs_cmdl_context *ctx) struct dp_packet_batch *batch = &pkt_batch_; dp_packet_batch_init(batch); - for (int i = 0; i < batch_size; i++) { + for (int i = 0; i < batch_size_; i++) { err = ovs_pcap_read(pcap, &packet, NULL); if (err) { break; diff --git a/utilities/ovs-ofctl.c b/utilities/ovs-ofctl.c index 386e4f0d269c..d439677cdc87 100644 --- a/utilities/ovs-ofctl.c +++ b/utilities/ovs-ofctl.c @@ -653,17 +653,17 @@ dump_transaction(struct vconn *vconn, struct ofpbuf *request) "OpenFlow packet receive failed"); recv_xid = ((struct ofp_header *) reply->data)->xid; if (send_xid == recv_xid) { - enum ofpraw raw; + enum ofpraw ofpraw; ofp_print(stdout, reply->data, reply->size, ports_to_show(vconn_get_name(vconn)), tables_to_show(vconn_get_name(vconn)), verbosity + 1); - ofpraw_decode(&raw, reply->data); - if (ofptype_from_ofpraw(raw) == OFPTYPE_ERROR) { + ofpraw_decode(&ofpraw, reply->data); + if (ofptype_from_ofpraw(ofpraw) == OFPTYPE_ERROR) { done = true; - } else if (raw == reply_raw) { + } else if (ofpraw == reply_raw) { done = !ofpmp_more(reply->data); } else { ovs_fatal(0, "received bad reply: %s", @@ -693,13 +693,13 @@ dump_transaction(struct vconn *vconn, struct ofpbuf *request) } static void -dump_trivial_transaction(const char *vconn_name, enum ofpraw raw) +dump_trivial_transaction(const char *vconn_name, enum ofpraw ofpraw) { struct ofpbuf *request; struct vconn *vconn; open_vconn(vconn_name, &vconn); - request = ofpraw_alloc(raw, vconn_get_version(vconn), 0); + request = ofpraw_alloc(ofpraw, vconn_get_version(vconn), 0); dump_transaction(vconn, request); vconn_close(vconn); } @@ -1223,10 +1223,10 @@ table_iterator_init(struct table_iterator *ti, struct vconn *vconn) ? TI_STATS : TI_FEATURES); ti->more = true; - enum ofpraw raw = (ti->variant == TI_STATS - ? OFPRAW_OFPST_TABLE_REQUEST - : OFPRAW_OFPST13_TABLE_FEATURES_REQUEST); - struct ofpbuf *rq = ofpraw_alloc(raw, vconn_get_version(vconn), 0); + enum ofpraw ofpraw = (ti->variant == TI_STATS + ? OFPRAW_OFPST_TABLE_REQUEST + : OFPRAW_OFPST13_TABLE_FEATURES_REQUEST); + struct ofpbuf *rq = ofpraw_alloc(ofpraw, vconn_get_version(vconn), 0); ti->send_xid = ((struct ofp_header *) rq->data)->xid; send_openflow_buffer(ti->vconn, rq); } @@ -4645,7 +4645,7 @@ ofctl_encode_error_reply(struct ovs_cmdl_context *ctx) static void ofctl_ofp_print(struct ovs_cmdl_context *ctx) { - int verbosity = ctx->argc > 2 ? atoi(ctx->argv[2]) : 2; + int verbosity_ = ctx->argc > 2 ? atoi(ctx->argv[2]) : 2; struct ofpbuf packet; ofpbuf_init(&packet, 0); @@ -4674,7 +4674,7 @@ ofctl_ofp_print(struct ovs_cmdl_context *ctx) ovs_fatal(0, "trailing garbage following hex bytes"); } free(buffer); - ofp_print(stdout, packet.data, packet.size, NULL, NULL, verbosity); + ofp_print(stdout, packet.data, packet.size, NULL, NULL, verbosity_); ofpbuf_uninit(&packet); } From patchwork Wed Feb 28 08:01:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Justin Pettit X-Patchwork-Id: 878988 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ovn.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 3zrp601B1fz9s0W for ; Wed, 28 Feb 2018 19:05:44 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 87B9012D9; Wed, 28 Feb 2018 08:02:06 +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 AA6FCF37 for ; Wed, 28 Feb 2018 08:01:59 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 5C48B2F0 for ; Wed, 28 Feb 2018 08:01:59 +0000 (UTC) X-Originating-IP: 98.234.50.139 Received: from localhost.localdomain (unknown [98.234.50.139]) (Authenticated sender: jpettit@ovn.org) by relay5-d.mail.gandi.net (Postfix) with ESMTPSA id AEE1441C090 for ; Wed, 28 Feb 2018 09:01:57 +0100 (CET) From: Justin Pettit To: dev@openvswitch.org Date: Wed, 28 Feb 2018 00:01:03 -0800 Message-Id: <1519804863-73126-9-git-send-email-jpettit@ovn.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1519804863-73126-1-git-send-email-jpettit@ovn.org> References: <1519804863-73126-1-git-send-email-jpettit@ovn.org> X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [shadow 8/8] Add -Wshadow for compilers that support it. 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 Signed-off-by: Justin Pettit Acked-by: Ben Pfaff --- configure.ac | 1 + 1 file changed, 1 insertion(+) diff --git a/configure.ac b/configure.ac index 84fed062cfa3..9940a1a453a0 100644 --- a/configure.ac +++ b/configure.ac @@ -168,6 +168,7 @@ OVS_ENABLE_OPTION([-Wbool-compare]) OVS_ENABLE_OPTION([-Wshift-negative-value]) OVS_ENABLE_OPTION([-Wduplicated-cond]) OVS_ENABLE_OPTION([-Qunused-arguments]) +OVS_ENABLE_OPTION([-Wshadow]) OVS_CONDITIONAL_CC_OPTION([-Wno-unused], [HAVE_WNO_UNUSED]) OVS_CONDITIONAL_CC_OPTION([-Wno-unused-parameter], [HAVE_WNO_UNUSED_PARAMETER]) OVS_ENABLE_WERROR