From patchwork Wed Sep 20 03:59:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Darrell Ball X-Patchwork-Id: 815998 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; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="nWhMn+oQ"; dkim-atps=neutral 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 3xxmG824DPz9s2G for ; Wed, 20 Sep 2017 13:59:28 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 9774ECB0; Wed, 20 Sep 2017 03:59:19 +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 6502FC33 for ; Wed, 20 Sep 2017 03:59:18 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-pf0-f195.google.com (mail-pf0-f195.google.com [209.85.192.195]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id E12E4469 for ; Wed, 20 Sep 2017 03:59:17 +0000 (UTC) Received: by mail-pf0-f195.google.com with SMTP id f84so706114pfj.3 for ; Tue, 19 Sep 2017 20:59:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id; bh=NweoReEhh+/HxH0Ru5r9wXsjz50Cz8SSoKaFSjqTzmg=; b=nWhMn+oQyP5mpOfluAUuvhf6p9OpOpOyC6cya2AjsJgxMUXIifWU2gMppcvidLe2qY CdS+qS5LOgipiV8HOtAGxExoYBp7BKAvULhqHnH/clZHGX13EJ94fS3oIJX+PsXtrc46 XMGPNGu5S0wp2AE5j0oQkfYnqeBSPc9qFclI12DyEN69WjEE+HAnFDMc+8Y3F4sn6HVK bOVwDCIbUmxVIiPX5nHgDi5tcTvu/t/6QT6sgM7YX+zb6pjzlpQ6DLldt2QCfLjR4Q3z 8gsYTbazW5K28uehgFyV/g6f24Ka/2bdVcx8vwAu22aNoJJE4EbrMbXEmAxKzUmJrFMf B5DA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id; bh=NweoReEhh+/HxH0Ru5r9wXsjz50Cz8SSoKaFSjqTzmg=; b=HTTl1eDl8b0573Zlsi/O/OEg/YEdQnGpJqLuIL1BMmXTKVN2NVziKmI9CRNmFt1wdk 1MrLy4Y4JXEmxOvqrTQwIbuV/6q0PrCN5dg0Z4HL4at16SvZUmXVDnJ4vskpgNNi9R3h 2xA0uCAwyRhaFqYhFrOv0dePmE0DVXcTqKbyvKB9XNs54BXfHDSJlovf1Q8+XKycErH+ xwZYow4u6e3hZZc2Q7TTHfKMh/9vrwrnXFzJDEa8AunCEUjr1hgCNEoha8XANQ1at0M1 w+DWEcfYCxi8D+VVnZxuHEU/Y/V7u6SamSbIVcsa46wj3LEqU172WlFQ0/BFbL6H0z0c rBWA== X-Gm-Message-State: AHPjjUh1oB0lgSS1boPOmVaJwlSXmRygcZ3TL0pxuWp/VMXULtA7rMhI tkL0leG3odE+XHNKmAe2ShU= X-Google-Smtp-Source: AOwi7QA3sRNlZ1m2tZxH5G5URgMHx0PSwSS6+k0NdS3fLJHKSvzUfqI9C4C4kc/gixP0AyJdAOwj3g== X-Received: by 10.98.74.4 with SMTP id x4mr793774pfa.222.1505879957525; Tue, 19 Sep 2017 20:59:17 -0700 (PDT) Received: from ubuntu.localdomain ([208.91.2.2]) by smtp.gmail.com with ESMTPSA id 195sm4983033pgg.42.2017.09.19.20.59.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 19 Sep 2017 20:59:17 -0700 (PDT) From: Darrell Ball To: dlu998@gmail.com, dev@openvswitch.org Date: Tue, 19 Sep 2017 20:59:06 -0700 Message-Id: <1505879948-112145-1-git-send-email-dlu998@gmail.com> X-Mailer: git-send-email 1.9.1 X-Spam-Status: No, score=0.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM autolearn=disabled version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [patch v1 1/3] conntrack: Fix clang static analysis reports. 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 These warnings do not affect functionality. In one case, a local variable could be removed and in another case, the working pointer should be used rather than the start pointer. Fixes: bd5e81a0e596 ("Userspace Datapath: Add ALG infra and FTP.") Reported-by: Bhanuprakash Bodireddy Signed-off-by: Darrell Ball --- lib/conntrack.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/lib/conntrack.c b/lib/conntrack.c index 419cb1d..59d3c4e 100644 --- a/lib/conntrack.c +++ b/lib/conntrack.c @@ -2617,7 +2617,7 @@ process_ftp_ctl_v4(struct conntrack *ct, char *ftp = ftp_msg; enum ct_alg_mode mode; - if (!strncasecmp(ftp_msg, FTP_PORT_CMD, strlen(FTP_PORT_CMD))) { + if (!strncasecmp(ftp, FTP_PORT_CMD, strlen(FTP_PORT_CMD))) { ftp = ftp_msg + strlen(FTP_PORT_CMD); mode = CT_FTP_MODE_ACTIVE; } else { @@ -2763,7 +2763,7 @@ process_ftp_ctl_v6(struct conntrack *ct, char *ftp = ftp_msg; struct in6_addr ip6_addr; - if (!strncasecmp(ftp_msg, FTP_EPRT_CMD, strlen(FTP_EPRT_CMD))) { + if (!strncasecmp(ftp, FTP_EPRT_CMD, strlen(FTP_EPRT_CMD))) { ftp = ftp_msg + strlen(FTP_EPRT_CMD); ftp = skip_non_digits(ftp); if (*ftp != FTP_AF_V6 || isdigit(ftp[1])) { @@ -2906,10 +2906,8 @@ handle_ftp_ctl(struct conntrack *ct, const struct conn_lookup_ctx *ctx, struct ovs_16aligned_ip6_hdr *nh6 = dp_packet_l3(pkt); int64_t seq_skew = 0; - bool seq_skew_dir; if (ftp_ctl == CT_FTP_CTL_OTHER) { seq_skew = conn_for_expectation->seq_skew; - seq_skew_dir = conn_for_expectation->seq_skew_dir; } else if (ftp_ctl == CT_FTP_CTL_INTEREST) { enum ftp_ctl_pkt rc; if (ctx->key.dl_type == htons(ETH_TYPE_IPV6)) { @@ -2933,18 +2931,16 @@ handle_ftp_ctl(struct conntrack *ct, const struct conn_lookup_ctx *ctx, seq_skew = repl_ftp_v6_addr(pkt, v6_addr_rep, ftp_data_start, addr_offset_from_ftp_data_start, addr_size, mode); - seq_skew_dir = ctx->reply; if (seq_skew) { ip_len = ntohs(nh6->ip6_ctlun.ip6_un1.ip6_un1_plen); ip_len += seq_skew; nh6->ip6_ctlun.ip6_un1.ip6_un1_plen = htons(ip_len); conn_seq_skew_set(ct, &conn_for_expectation->key, now, - seq_skew, seq_skew_dir); + seq_skew, ctx->reply); } } else { seq_skew = repl_ftp_v4_addr(pkt, v4_addr_rep, ftp_data_start, addr_offset_from_ftp_data_start); - seq_skew_dir = ctx->reply; ip_len = ntohs(l3_hdr->ip_tot_len); if (seq_skew) { ip_len += seq_skew; @@ -2952,7 +2948,7 @@ handle_ftp_ctl(struct conntrack *ct, const struct conn_lookup_ctx *ctx, l3_hdr->ip_tot_len, htons(ip_len)); l3_hdr->ip_tot_len = htons(ip_len); conn_seq_skew_set(ct, &conn_for_expectation->key, now, - seq_skew, seq_skew_dir); + seq_skew, ctx->reply); } } } else { From patchwork Wed Sep 20 03:59:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Darrell Ball X-Patchwork-Id: 815999 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; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="duzkkiNk"; dkim-atps=neutral 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 3xxmH6486Kz9s2G for ; Wed, 20 Sep 2017 14:00:18 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 22A1DCD4; Wed, 20 Sep 2017 03:59:21 +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 D6AC6C7C for ; Wed, 20 Sep 2017 03:59:18 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-pg0-f66.google.com (mail-pg0-f66.google.com [74.125.83.66]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 90CC0203 for ; Wed, 20 Sep 2017 03:59:18 +0000 (UTC) Received: by mail-pg0-f66.google.com with SMTP id i130so971832pgc.0 for ; Tue, 19 Sep 2017 20:59:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references; bh=tFzR70uQ/EKerM6Ozg9vMOFA9ZtyfcIV3O/v5ua/vm4=; b=duzkkiNk+LReszCodkXyxXH8jPvtGjw5l9bhKe23F+EvjCWqXJ85IYi8h8aOsL2Cju sr07Psr0P5xljO4KoZK9Ev3XZXl73srMFjATESFrKlvR8d5gpOdmB2u3HuYbW5/eW6Uc ra9q5P2k0szJAOH+ot18sEmjBXCyRDuKEoNDVMHvbPDCjIQFEMFe/liGy9LalyQ3Rnar Lf52CXsc58FGKd1vq89yrCwn7kXxn1kQmKX7WUy2l6mlgtuO+rWCZpWf/WAG4u7LTj/a 4DUKO8rWFB4djmA5A5riAiGYwtASho1AQ7FPXaQF+Wkx1UQrLK7FncoEvK1P4bBkwhNq gtYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=tFzR70uQ/EKerM6Ozg9vMOFA9ZtyfcIV3O/v5ua/vm4=; b=ps/O2viAXlsJ39VLxuJQpW2YeNePDIWZQve7R0mUnlrRtlYjwAle5A5wNliWjuSwif ps3Iv4P01VWI35s4211HF8Igb0xHuxzm2ctbGweHojIE3Fx5vQf0Ay8M7IQtMhJYl3Rk aiSHq2ANX4zlddnNTvEnSnW0z3fhvmXAY3Cp3TIuFHkk/OPRKPlcu77ifPM7lkCgqKy5 xUpPc1PeD011OmAR5oBj9xSldY/TPPyXtmTAKU5ksV5sbZAroFJvgRLqRQ6xP/fbirfo 7dUNXqp+f2YABiyR/9WUWakRfcUbYKo9ZLeJ9rIFmH9KQ2BtAKn/iKTxrcu0EP7CAS6u wxJg== X-Gm-Message-State: AHPjjUhlZ8Erg3Pt2GV+NSDehtopX8BiGDFQEJ6T2UabG5SqB01M5GwH zqt7QQykcji7497Sh8R2IRg= X-Google-Smtp-Source: AOwi7QBbtQYU2ySTq0wA6p7aD1RUji/RxN1KyAIxNkjWKmqnS/L9L7X3bD88GilAo/V5IjGhh9cTTA== X-Received: by 10.98.214.131 with SMTP id a3mr785918pfl.115.1505879958221; Tue, 19 Sep 2017 20:59:18 -0700 (PDT) Received: from ubuntu.localdomain ([208.91.2.2]) by smtp.gmail.com with ESMTPSA id 195sm4983033pgg.42.2017.09.19.20.59.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 19 Sep 2017 20:59:17 -0700 (PDT) From: Darrell Ball To: dlu998@gmail.com, dev@openvswitch.org Date: Tue, 19 Sep 2017 20:59:07 -0700 Message-Id: <1505879948-112145-2-git-send-email-dlu998@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1505879948-112145-1-git-send-email-dlu998@gmail.com> References: <1505879948-112145-1-git-send-email-dlu998@gmail.com> X-Spam-Status: No, score=0.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM autolearn=disabled version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [patch v1 2/3] conntrack: Add defensive check for existing reverse conn. 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 A defensive check is added for a reverse conn in the case of alg support and associated info logs are added to catch rare conditions, in case this might be relevant. Signed-off-by: Darrell Ball --- lib/conntrack.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 50 insertions(+), 2 deletions(-) diff --git a/lib/conntrack.c b/lib/conntrack.c index 59d3c4e..c68c6df 100644 --- a/lib/conntrack.c +++ b/lib/conntrack.c @@ -861,6 +861,40 @@ conn_update_state(struct conntrack *ct, struct dp_packet *pkt, } static void +print_conn_ip_addresses(struct conn *nc) +{ + if (nc->key.dl_type == htons(ETH_TYPE_IP)) { + VLOG_INFO("src addr "IP_FMT " dst addr "IP_FMT + " rev src addr "IP_FMT " rev dst addr "IP_FMT, + IP_ARGS(nc->key.src.addr.ipv4_aligned), + IP_ARGS(nc->key.dst.addr.ipv4_aligned), + IP_ARGS(nc->rev_key.src.addr.ipv4_aligned), + IP_ARGS(nc->rev_key.dst.addr.ipv4_aligned)); + } else { + + VLOG_INFO("src addr 0x%x:%x:%x:%x; dst addr 0x%x:%x:%x:%x; " + "rev src addr 0x%x:%x:%x:%x; " + "rev dst addr 0x%x:%x:%x:%x", + ntohl(nc->key.src.addr.ipv6_aligned.s6_addr32[0]), + ntohl(nc->key.src.addr.ipv6_aligned.s6_addr32[1]), + ntohl(nc->key.src.addr.ipv6_aligned.s6_addr32[2]), + ntohl(nc->key.src.addr.ipv6_aligned.s6_addr32[3]), + ntohl(nc->key.dst.addr.ipv6_aligned.s6_addr32[0]), + ntohl(nc->key.dst.addr.ipv6_aligned.s6_addr32[1]), + ntohl(nc->key.dst.addr.ipv6_aligned.s6_addr32[2]), + ntohl(nc->key.dst.addr.ipv6_aligned.s6_addr32[3]), + ntohl(nc->rev_key.src.addr.ipv6_aligned.s6_addr32[0]), + ntohl(nc->rev_key.src.addr.ipv6_aligned.s6_addr32[1]), + ntohl(nc->rev_key.src.addr.ipv6_aligned.s6_addr32[2]), + ntohl(nc->rev_key.src.addr.ipv6_aligned.s6_addr32[3]), + ntohl(nc->rev_key.dst.addr.ipv6_aligned.s6_addr32[0]), + ntohl(nc->rev_key.dst.addr.ipv6_aligned.s6_addr32[1]), + ntohl(nc->rev_key.dst.addr.ipv6_aligned.s6_addr32[2]), + ntohl(nc->rev_key.dst.addr.ipv6_aligned.s6_addr32[3])); + } +} + +static void create_un_nat_conn(struct conntrack *ct, struct conn *conn_for_un_nat_copy, long long now, bool alg_un_nat) { @@ -873,8 +907,17 @@ create_un_nat_conn(struct conntrack *ct, struct conn *conn_for_un_nat_copy, struct conn *rev_conn = conn_lookup(ct, &nc->key, now); if (alg_un_nat) { - hmap_insert(&ct->buckets[un_nat_conn_bucket].connections, - &nc->node, un_nat_hash); + if (!rev_conn) { + hmap_insert(&ct->buckets[un_nat_conn_bucket].connections, + &nc->node, un_nat_hash); + } else { + VLOG_INFO("Unusual condition for un_nat conn create for alg: " + "Ports %d/%d/%d/%d; rev conn %p ", nc->key.src.port, + nc->key.dst.port, nc->rev_key.src.port, + nc->rev_key.dst.port, rev_conn); + print_conn_ip_addresses(nc); + free(nc); + } } else { ct_rwlock_rdlock(&ct->resources_lock); @@ -886,6 +929,11 @@ create_un_nat_conn(struct conntrack *ct, struct conn *conn_for_un_nat_copy, hmap_insert(&ct->buckets[un_nat_conn_bucket].connections, &nc->node, un_nat_hash); } else { + VLOG_INFO("Unusual condition for un_nat conn create: " + "Ports %d/%d/%d/%d; nat_conn_key_node/rev_conn %p/%p", + nc->key.src.port, nc->key.dst.port, nc->rev_key.src.port, + nc->rev_key.dst.port, nat_conn_key_node, rev_conn); + print_conn_ip_addresses(nc); free(nc); } ct_rwlock_unlock(&ct->resources_lock); From patchwork Wed Sep 20 03:59:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Darrell Ball X-Patchwork-Id: 816000 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; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="ajubEoIn"; dkim-atps=neutral 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 3xxmHl0CVwz9s2G for ; Wed, 20 Sep 2017 14:00:51 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 0BC5CCE4; Wed, 20 Sep 2017 03:59:22 +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 716F7C7C for ; Wed, 20 Sep 2017 03:59:19 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-pg0-f66.google.com (mail-pg0-f66.google.com [74.125.83.66]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 47605203 for ; Wed, 20 Sep 2017 03:59:19 +0000 (UTC) Received: by mail-pg0-f66.google.com with SMTP id m30so957082pgn.5 for ; Tue, 19 Sep 2017 20:59:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references; bh=fwsuWJabx6uNSTHDx2cCN6YFJGm5FPLkKQSvTXVAbeQ=; b=ajubEoInp7e9UJn/m5ftpVJqwWmI9ApvF5lY0xMzfUv+4eE7sKejkUa0BG1ybGnxdd X/AQkwD2muxGxiyn9ZsPnltQGfYrH3Z3a8O/GavAYusMZ5032jqp03O1nPxMPBDhGTUR P5TBjh7TZOtRBPGE01SR8S62KR9KGrhn/4CO06XB/QbmJoWPZseMwlIsypm6Pc4E/tAb UTEWjla/A68+DtoyjaD5CsYewA1s4RoD3L2qLQT46lp6kxkYkrMOlfcxpPChBfUiknoq +EgjQJjkPq7Aou9JCvsgAinrvbfhqFuTSFxgiCbNR9QjGfeF3o9r3qL2mcRewEv1ffF3 u+ug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=fwsuWJabx6uNSTHDx2cCN6YFJGm5FPLkKQSvTXVAbeQ=; b=pPD2qumcjboblTlLgzeeUjpJ9DE8i3oOP5opKDpT94z2b61kF+k87Q0j/b7txfRxVY 37AxLUAlEcHmZnCJ94+LQJFJjri5+Yuykt+74wzbeAecIFLQ80c3THWxNHP71LT83amE hI3oOHgp2Ndx+Gnd0bgCI0LeOATAspkgfku5p92IzlURQKzgofBDscyoSJH5y8bSjwGB be/p6Tv7w9Qlz3t6TxQjxL2mE99p8+b2ETIqiM3Xrf3bEDTC+GiOfbsAx0upwethlN9j R09UgcwQGLqG4WkttmO6RFvFAisvGHeXDibRjLlf1UoPG+6mup8GLaKY5yv2b5Rl2y7l mBHA== X-Gm-Message-State: AHPjjUipy6XfvJ8KLCtr8f9ew/9mcdrCA6f4HgaUxFuKlKmpWm8avMec d8yy2h/hTNTYDZUwTngqaXg= X-Google-Smtp-Source: AOwi7QB9dCWgt+2EiyHwXtgTNLO02b0+Ak/FhFwYjgv/j/4Zmjn5XZw3cOcfNF9rNx09poUIoPMB7Q== X-Received: by 10.159.247.131 with SMTP id e3mr768708pls.296.1505879958981; Tue, 19 Sep 2017 20:59:18 -0700 (PDT) Received: from ubuntu.localdomain ([208.91.2.2]) by smtp.gmail.com with ESMTPSA id 195sm4983033pgg.42.2017.09.19.20.59.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 19 Sep 2017 20:59:18 -0700 (PDT) From: Darrell Ball To: dlu998@gmail.com, dev@openvswitch.org Date: Tue, 19 Sep 2017 20:59:08 -0700 Message-Id: <1505879948-112145-3-git-send-email-dlu998@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1505879948-112145-1-git-send-email-dlu998@gmail.com> References: <1505879948-112145-1-git-send-email-dlu998@gmail.com> X-Spam-Status: No, score=0.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM autolearn=disabled version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [patch v1 3/3] conntrack: Minor performance enhancement. 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 Add an OVS_UNLIKELY and reorder a few variable condition checks. Signed-off-by: Darrell Ball --- lib/conntrack.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/conntrack.c b/lib/conntrack.c index c68c6df..6b6a2a6 100644 --- a/lib/conntrack.c +++ b/lib/conntrack.c @@ -1152,7 +1152,7 @@ process_one(struct conntrack *ct, struct dp_packet *pkt, bool tftp_ctl = is_tftp_ctl(pkt); struct conn conn_for_expectation; - if (conn && (ftp_ctl || tftp_ctl)) { + if (OVS_UNLIKELY((ftp_ctl || tftp_ctl) && conn)) { conn_for_expectation = *conn; } @@ -1163,10 +1163,10 @@ process_one(struct conntrack *ct, struct dp_packet *pkt, } /* FTP control packet handling with expectation creation. */ - if (OVS_UNLIKELY(conn && ftp_ctl)) { + if (OVS_UNLIKELY(ftp_ctl && conn)) { handle_ftp_ctl(ct, ctx, pkt, &conn_for_expectation, now, CT_FTP_CTL_INTEREST, !!nat_action_info); - } else if (OVS_UNLIKELY(conn && tftp_ctl)) { + } else if (OVS_UNLIKELY(tftp_ctl && conn)) { handle_tftp_ctl(ct, &conn_for_expectation, now); } }