From patchwork Thu Nov 19 22:08:50 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Han Zhou X-Patchwork-Id: 546721 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from archives.nicira.com (li376-54.members.linode.com [96.126.127.54]) by ozlabs.org (Postfix) with ESMTP id 0D225140D16 for ; Fri, 20 Nov 2015 09:09:54 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=oYqa82mt; dkim-atps=neutral Received: from archives.nicira.com (localhost [127.0.0.1]) by archives.nicira.com (Postfix) with ESMTP id 26D9410683; Thu, 19 Nov 2015 14:09:54 -0800 (PST) X-Original-To: dev@openvswitch.org Delivered-To: dev@openvswitch.org Received: from mx1e4.cudamail.com (mx1.cudamail.com [69.90.118.67]) by archives.nicira.com (Postfix) with ESMTPS id BF5E91065E for ; Thu, 19 Nov 2015 14:09:52 -0800 (PST) Received: from bar5.cudamail.com (unknown [192.168.21.12]) by mx1e4.cudamail.com (Postfix) with ESMTPS id 44B641E0148 for ; Thu, 19 Nov 2015 15:09:52 -0700 (MST) X-ASG-Debug-ID: 1447970991-09eadd53cfb90a0001-byXFYA Received: from mx1-pf2.cudamail.com ([192.168.24.2]) by bar5.cudamail.com with ESMTP id v9ykepGxiUxZgBhl (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 19 Nov 2015 15:09:51 -0700 (MST) X-Barracuda-Envelope-From: zhouhan@gmail.com X-Barracuda-RBL-Trusted-Forwarder: 192.168.24.2 Received: from unknown (HELO mail-pa0-f44.google.com) (209.85.220.44) by mx1-pf2.cudamail.com with ESMTPS (RC4-SHA encrypted); 19 Nov 2015 22:09:51 -0000 Received-SPF: pass (mx1-pf2.cudamail.com: SPF record at _netblocks.google.com designates 209.85.220.44 as permitted sender) X-Barracuda-RBL-Trusted-Forwarder: 209.85.220.44 Received: by pabfh17 with SMTP id fh17so96883227pab.0 for ; Thu, 19 Nov 2015 14:09:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=CLMGqEc31s8PoOEp8e9N7HwfOYutaKK9h5LIpEb1oJs=; b=oYqa82mthraElSjUaWBAhbEaBdM7QUubnnnL/hcR/sB0qFqkQR1rev+giQCHbUXQ1y 5Yf63GzrWiEMPoMT6HM0BjFFB7DzUG+djJYfvYjcMMQqVZCxLkgwHe3gHDrDFV1wVi9x XPfjfhWw3cixF75kUjZf12shFd5foKgSyOTvfmkA32WPkSMgIOh/lblKlwqyDP8KyjOH MKeANp+YDyG9VxxEefyMFYQ0WMvb4sS2zzwQEahpAUdI9WHICzKQXlvwT6AESQIw0wMR ekvCYV+Xae8kDsDcILmfdlYuP3XU+J/7eY/3gD4KQTf+aXR75HSZNt7B2d/RAmSgjd/e eh3w== X-Received: by 10.66.150.228 with SMTP id ul4mr14153816pab.15.1447970990841; Thu, 19 Nov 2015 14:09:50 -0800 (PST) Received: from localhost.localdomain.localdomain ([216.113.160.70]) by smtp.gmail.com with ESMTPSA id j5sm12603910pbq.74.2015.11.19.14.09.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 19 Nov 2015 14:09:50 -0800 (PST) X-CudaMail-Envelope-Sender: zhouhan@gmail.com X-Barracuda-Apparent-Source-IP: 216.113.160.70 From: Han Zhou To: dev@openvswitch.org X-CudaMail-MID: CM-E2-1118086920 X-CudaMail-DTE: 111915 X-CudaMail-Originating-IP: 209.85.220.44 Date: Thu, 19 Nov 2015 14:08:50 -0800 X-ASG-Orig-Subj: [##CM-E2-1118086920##][PATCH v2] ovn: support ARP response for known IPs Message-Id: <1447970930-7772-1-git-send-email-zhouhan@gmail.com> X-Mailer: git-send-email 2.1.0 X-GBUdb-Analysis: 0, 209.85.220.44, Ugly c=0.437809 p=-0.6 Source Normal X-MessageSniffer-Rules: 0-0-0-5875-c X-Barracuda-Connect: UNKNOWN[192.168.24.2] X-Barracuda-Start-Time: 1447970991 X-Barracuda-Encrypted: DHE-RSA-AES256-SHA X-Barracuda-URL: https://web.cudamail.com:443/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at cudamail.com X-Barracuda-BRTS-Status: 1 X-Barracuda-Spam-Score: 0.60 X-Barracuda-Spam-Status: No, SCORE=0.60 using per-user scores of TAG_LEVEL=3.5 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=4.0 tests=BSF_SC5_MJ1963, DKIM_SIGNED, RDNS_NONE X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.24546 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- 0.00 DKIM_SIGNED Domain Keys Identified Mail: message has a signature 0.10 RDNS_NONE Delivered to trusted network by a host with no rDNS 0.50 BSF_SC5_MJ1963 Custom Rule MJ1963 Subject: [ovs-dev] [PATCH v2] ovn: support ARP response for known IPs X-BeenThere: dev@openvswitch.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dev-bounces@openvswitch.org Sender: "dev" For lswitch ports with known IPs, ARP is responded directly from local ovn-controller to avoid flooding. Signed-off-by: Han Zhou --- Notes: v1->v2: remove the extra arg of xasprintf() ovn/northd/ovn-northd.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/ovn/northd/ovn-northd.c b/ovn/northd/ovn-northd.c index 8fe0c2c..ec13171 100644 --- a/ovn/northd/ovn-northd.c +++ b/ovn/northd/ovn-northd.c @@ -1151,6 +1151,44 @@ build_lswitch_flows(struct hmap *datapaths, struct hmap *ports, ds_destroy(&match); } + /* Ingress table 3: Destination lookup, ARP reply for known IPs. + * (priority 150). */ + HMAP_FOR_EACH (op, key_node, ports) { + if (!op->nbs) { + continue; + } + + for (size_t i = 0; i < op->nbs->n_addresses; i++) { + struct eth_addr ea; + ovs_be32 ip; + + if (ovs_scan(op->nbs->addresses[i], + ETH_ADDR_SCAN_FMT" "IP_SCAN_FMT, + ETH_ADDR_SCAN_ARGS(ea), IP_SCAN_ARGS(&ip))) { + char *match = xasprintf( + "arp.tpa == "IP_FMT" && arp.op == 1", IP_ARGS(ip)); + char *actions = xasprintf( + "eth.dst = eth.src; " + "eth.src = "ETH_ADDR_FMT"; " + "arp.op = 2; /* ARP reply */ " + "arp.tha = arp.sha; " + "arp.sha = "ETH_ADDR_FMT"; " + "arp.tpa = arp.spa; " + "arp.spa = "IP_FMT"; " + "outport = inport; " + "inport = \"\"; /* Allow sending out inport. */ " + "output;", + ETH_ADDR_ARGS(ea), + ETH_ADDR_ARGS(ea), + IP_ARGS(ip)); + ovn_lflow_add(lflows, op->od, S_SWITCH_IN_L2_LKUP, 150, + match, actions); + free(match); + free(actions); + } + } + } + /* Ingress table 3: Destination lookup, broadcast and multicast handling * (priority 100). */ HMAP_FOR_EACH (op, key_node, ports) {