From patchwork Tue Nov 24 21:23: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: 548283 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from archives.nicira.com (unknown [IPv6:2600:3c00::f03c:91ff:fe6e:bdf7]) by ozlabs.org (Postfix) with ESMTP id 14B4414010F for ; Wed, 25 Nov 2015 08:24:55 +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=pooxSUQX; dkim-atps=neutral Received: from archives.nicira.com (localhost [127.0.0.1]) by archives.nicira.com (Postfix) with ESMTP id 19AD9109D4; Tue, 24 Nov 2015 13:24:54 -0800 (PST) X-Original-To: dev@openvswitch.org Delivered-To: dev@openvswitch.org Received: from mx1e3.cudamail.com (mx1.cudamail.com [69.90.118.67]) by archives.nicira.com (Postfix) with ESMTPS id 414DB109D3 for ; Tue, 24 Nov 2015 13:24:52 -0800 (PST) Received: from bar5.cudamail.com (localhost [127.0.0.1]) by mx1e3.cudamail.com (Postfix) with ESMTPS id A58B0420096 for ; Tue, 24 Nov 2015 14:24:51 -0700 (MST) X-ASG-Debug-ID: 1448400290-09eadd53d2369090001-byXFYA Received: from mx1-pf1.cudamail.com ([192.168.24.1]) by bar5.cudamail.com with ESMTP id eLJ2mcwkyj82hTHM (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Tue, 24 Nov 2015 14:24:50 -0700 (MST) X-Barracuda-Envelope-From: zhouhan@gmail.com X-Barracuda-RBL-Trusted-Forwarder: 192.168.24.1 Received: from unknown (HELO mail-pa0-f41.google.com) (209.85.220.41) by mx1-pf1.cudamail.com with ESMTPS (RC4-SHA encrypted); 24 Nov 2015 21:24:50 -0000 Received-SPF: pass (mx1-pf1.cudamail.com: SPF record at _netblocks.google.com designates 209.85.220.41 as permitted sender) X-Barracuda-RBL-Trusted-Forwarder: 209.85.220.41 Received: by pacdm15 with SMTP id dm15so33697890pac.3 for ; Tue, 24 Nov 2015 13:24:49 -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=yutwIc3lDL7oe6GQie65+WEKltqhtDLybkaq6qCt77M=; b=pooxSUQXhLptBtvHWDhK8at/KUe5OBZmbepbvI3aDv9GXcphiboEmT39WhJq0rUy2q 4KZ77ccatrCcQJzT7nhKzRIJMQy2QDW5plUI7VV3MaBlMPWpdoxHaVe56Mk7aGmgatL9 hnOPmja4eLZc2oQqp+7JS7mW6c7W74irXXrRhm4B+LSySdf0KEjlAWq7jYhb3NcA4b5Q 9nA13GTSaMtNIvLUMuh/HJ3B3vvCHm5dwAK8gJm7f9aVy5nffq0eUei2odnrywsuNRSD q63Pq/bCQkGzlUjVCaEof7MdpvFW8E/tRneNMTJQrJ1NvXz8qHdXnokZe16tbYJyMw1L GOKQ== X-Received: by 10.66.158.129 with SMTP id wu1mr46195179pab.146.1448400289831; Tue, 24 Nov 2015 13:24:49 -0800 (PST) Received: from localhost.localdomain.localdomain (c-50-185-229-130.hsd1.ca.comcast.net. [50.185.229.130]) by smtp.gmail.com with ESMTPSA id h19sm16234595pfd.79.2015.11.24.13.24.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Nov 2015 13:24:49 -0800 (PST) X-CudaMail-Envelope-Sender: zhouhan@gmail.com X-Barracuda-Apparent-Source-IP: 50.185.229.130 From: Han Zhou To: dev@openvswitch.org X-CudaMail-MID: CM-E1-1123089812 X-CudaMail-DTE: 112415 X-CudaMail-Originating-IP: 209.85.220.41 Date: Tue, 24 Nov 2015 13:23:50 -0800 X-ASG-Orig-Subj: [##CM-E1-1123089812##][PATCH v3] ovn: support ARP response for known IPs Message-Id: <1448400230-12719-1-git-send-email-zhouhan@gmail.com> X-Mailer: git-send-email 2.1.0 X-GBUdb-Analysis: 0, 209.85.220.41, Ugly c=0.425302 p=-0.580645 Source Normal X-MessageSniffer-Rules: 0-0-0-6041-c X-Barracuda-Connect: UNKNOWN[192.168.24.1] X-Barracuda-Start-Time: 1448400290 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.24691 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 v3] 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() v2->v3: update ovn-northd.8.xml to describe the new flows 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) {