From patchwork Thu Jan 5 06:15:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Han Ding X-Patchwork-Id: 1721668 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::133; helo=smtp2.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from smtp2.osuosl.org (smtp2.osuosl.org [IPv6:2605:bc80:3010::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Nnbms3dW2z23fc for ; Thu, 5 Jan 2023 17:15:24 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id CB48D40B3B; Thu, 5 Jan 2023 06:15:21 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org CB48D40B3B X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id R0nMPuYBGvOP; Thu, 5 Jan 2023 06:15:21 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp2.osuosl.org (Postfix) with ESMTPS id EE13B4013D; Thu, 5 Jan 2023 06:15:19 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org EE13B4013D Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id C6244C0032; Thu, 5 Jan 2023 06:15:19 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp2.osuosl.org (smtp2.osuosl.org [IPv6:2605:bc80:3010::133]) by lists.linuxfoundation.org (Postfix) with ESMTP id 060AEC002D for ; Thu, 5 Jan 2023 06:15:18 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id CEBD14010E for ; Thu, 5 Jan 2023 06:15:17 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org CEBD14010E X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id le51IorOonO7 for ; Thu, 5 Jan 2023 06:15:16 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 0FB2C40017 Received: from chinatelecom.cn (prt-mail.chinatelecom.cn [42.123.76.219]) by smtp2.osuosl.org (Postfix) with ESMTP id 0FB2C40017 for ; Thu, 5 Jan 2023 06:15:14 +0000 (UTC) HMM_SOURCE_IP: 172.18.0.48:45742.378623582 HMM_ATTACHE_NUM: 0000 HMM_SOURCE_TYPE: SMTP Received: from clientip-10.133.8.238 (unknown [172.18.0.48]) by chinatelecom.cn (HERMES) with SMTP id 3666F2800CD for ; Thu, 5 Jan 2023 14:15:03 +0800 (CST) X-189-SAVE-TO-SEND: handing@chinatelecom.cn Received: from ([10.133.8.238]) by app0024 with ESMTP id 10439de286f243eabdb3432d79126fc9 for dev@openvswitch.org; Thu, 05 Jan 2023 14:15:05 CST X-Transaction-ID: 10439de286f243eabdb3432d79126fc9 X-Real-From: handing@chinatelecom.cn X-Receive-IP: 10.133.8.238 X-MEDUSA-Status: 0 Date: Thu, 5 Jan 2023 14:15:03 +0800 From: "Han Ding" To: dev X-Priority: 3 X-GUID: E162BB52-C4E8-4227-B570-FF0AEA70144A X-Has-Attach: no X-Mailer: Foxmail 7.2.20.269[cn] Mime-Version: 1.0 Message-ID: <202301051415026716003@chinatelecom.cn> X-Content-Filtered-By: Mailman/MimeDel 2.1.15 Subject: [ovs-dev] [PATCH v2] ofproto-dpif-xlate: Remove repeated function for judge garp X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" Function is_gratuitous_arp() and function is_garp() are all used to judge whether the flow is gratuitous arp. It is not necessary to use two functions to do the same thing and just keep one. Acked-by: Ilya Maximets Signed-off-by: Han Ding --- lib/flow.h | 3 ++- ofproto/ofproto-dpif-xlate.c | 32 ++------------------------------ 2 files changed, 4 insertions(+), 31 deletions(-) -- 2.27.0 diff --git a/lib/flow.h b/lib/flow.h index c647ad83c..ade64b52d 100644 --- a/lib/flow.h +++ b/lib/flow.h @@ -1132,7 +1132,8 @@ static inline bool is_arp(const struct flow *flow) static inline bool is_garp(const struct flow *flow, struct flow_wildcards *wc) { - if (is_arp(flow)) { + if (is_arp(flow) && + eth_addr_is_broadcast(FLOW_WC_GET_AND_MASK_WC(flow, wc, dl_dst))) { return (FLOW_WC_GET_AND_MASK_WC(flow, wc, nw_src) == FLOW_WC_GET_AND_MASK_WC(flow, wc, nw_dst)); } diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c index a9cf3cbee..b3c13f6bf 100644 --- a/ofproto/ofproto-dpif-xlate.c +++ b/ofproto/ofproto-dpif-xlate.c @@ -2543,34 +2543,6 @@ output_normal(struct xlate_ctx *ctx, const struct xbundle *out_xbundle, memcpy(&ctx->xin->flow.vlans, &old_vlans, sizeof(old_vlans)); } -/* A VM broadcasts a gratuitous ARP to indicate that it has resumed after - * migration. Older Citrix-patched Linux DomU used gratuitous ARP replies to - * indicate this; newer upstream kernels use gratuitous ARP requests. */ -static bool -is_gratuitous_arp(const struct flow *flow, struct flow_wildcards *wc) -{ - if (flow->dl_type != htons(ETH_TYPE_ARP)) { - return false; - } - - memset(&wc->masks.dl_dst, 0xff, sizeof wc->masks.dl_dst); - if (!eth_addr_is_broadcast(flow->dl_dst)) { - return false; - } - - memset(&wc->masks.nw_proto, 0xff, sizeof wc->masks.nw_proto); - if (flow->nw_proto == ARP_OP_REPLY) { - return true; - } else if (flow->nw_proto == ARP_OP_REQUEST) { - memset(&wc->masks.nw_src, 0xff, sizeof wc->masks.nw_src); - memset(&wc->masks.nw_dst, 0xff, sizeof wc->masks.nw_dst); - - return flow->nw_src == flow->nw_dst; - } else { - return false; - } -} - /* Determines whether packets in 'flow' within 'xbridge' should be forwarded or * dropped. Returns true if they may be forwarded, false if they should be * dropped. @@ -2619,7 +2591,7 @@ is_admissible(struct xlate_ctx *ctx, struct xport *in_port, mac = mac_learning_lookup(xbridge->ml, flow->dl_src, vlan); if (mac && mac_entry_get_port(xbridge->ml, mac) != in_xbundle->ofbundle - && (!is_gratuitous_arp(flow, ctx->wc) + && (!is_garp(flow, ctx->wc) || mac_entry_is_grat_arp_locked(mac))) { ovs_rwlock_unlock(&xbridge->ml->rwlock); xlate_report(ctx, OFT_DETAIL, @@ -3062,7 +3034,7 @@ xlate_normal(struct xlate_ctx *ctx) } /* Learn source MAC. */ - bool is_grat_arp = is_gratuitous_arp(flow, wc); + bool is_grat_arp = is_garp(flow, wc); if (ctx->xin->allow_side_effects && flow->packet_type == htonl(PT_ETH) && in_port && in_port->pt_mode != NETDEV_PT_LEGACY_L3