From patchwork Tue Sep 19 10:41:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guoshuai Li X-Patchwork-Id: 815419 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=) 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 3xxKF11n2Hz9s82 for ; Tue, 19 Sep 2017 20:41:56 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 91B5DB01; Tue, 19 Sep 2017 10:41:53 +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 69CDD900 for ; Tue, 19 Sep 2017 10:41:51 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from smtp2203-239.mail.aliyun.com (smtp2203-239.mail.aliyun.com [121.197.203.239]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 91200CA for ; Tue, 19 Sep 2017 10:41:49 +0000 (UTC) X-Alimail-AntiSpam: AC=CONTINUE; BC=0.07674246|-1; FP=0|0|0|0|0|-1|-1|-1; HT=e02c03293; MF=ligs@dtdream.com; NM=1; PH=DS; RN=2; RT=2; SR=0; TI=SMTPD_---.8wciWoU_1505817706; Received: from localhost.localdomain(mailfrom:ligs@dtdream.com ip:222.128.6.212) by smtp.aliyun-inc.com(10.147.40.233); Tue, 19 Sep 2017 18:41:46 +0800 From: Guoshuai Li To: dev@openvswitch.org Date: Tue, 19 Sep 2017 18:41:33 +0800 Message-Id: <20170919104133.11960-1-ligs@dtdream.com> X-Mailer: git-send-email 2.13.2.windows.1 X-Spam-Status: No, score=0.0 required=5.0 tests=UNPARSEABLE_RELAY 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] ovn: Fix remote not receive GARP, when localnet Port has vlan tag. 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 When sending a localnet port with vlan, the GARP packet needs push_vlan. --- ovn/controller/pinctrl.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/ovn/controller/pinctrl.c b/ovn/controller/pinctrl.c index 469a35586..cf4f1331a 100644 --- a/ovn/controller/pinctrl.c +++ b/ovn/controller/pinctrl.c @@ -1264,6 +1264,7 @@ struct garp_data { long long int announce_time; /* Next announcement in ms. */ int backoff; /* Backoff for the next announcement. */ ofp_port_t ofport; /* ofport used to output this GARP. */ + int64_t tag; }; /* Contains GARPs to be sent. */ @@ -1286,7 +1287,7 @@ destroy_send_garps(void) } static void -add_garp(const char *name, ofp_port_t ofport, +add_garp(const char *name, ofp_port_t ofport, int64_t tag, const struct eth_addr ea, ovs_be32 ip) { struct garp_data *garp = xmalloc(sizeof *garp); @@ -1295,6 +1296,7 @@ add_garp(const char *name, ofp_port_t ofport, garp->announce_time = time_msec() + 1000; garp->backoff = 1; garp->ofport = ofport; + garp->tag = tag; shash_add(&send_garp_data, name, garp); } @@ -1313,6 +1315,7 @@ send_garp_update(const struct sbrec_port_binding *binding_rec, } ofp_port_t ofport = u16_to_ofp(simap_get(localnet_ofports, ld->localnet_port->logical_port)); + int64_t tag = ld->localnet_port->n_tag ? *(ld->localnet_port->tag) : 0; volatile struct garp_data *garp = NULL; /* Update GARP for NAT IP if it exists. Consider port bindings with type @@ -1332,7 +1335,7 @@ send_garp_update(const struct sbrec_port_binding *binding_rec, if (garp) { garp->ofport = ofport; } else { - add_garp(name, ofport, laddrs->ea, + add_garp(name, ofport, tag, laddrs->ea, laddrs->ipv4_addrs[i].addr); } free(name); @@ -1359,7 +1362,7 @@ send_garp_update(const struct sbrec_port_binding *binding_rec, continue; } - add_garp(binding_rec->logical_port, ofport, + add_garp(binding_rec->logical_port, ofport, tag, laddrs.ea, laddrs.ipv4_addrs[0].addr); destroy_lport_addresses(&laddrs); @@ -1389,6 +1392,11 @@ send_garp(struct garp_data *garp, long long int current_time) compose_arp(&packet, ARP_OP_REQUEST, garp->ea, eth_addr_zero, true, garp->ipv4, garp->ipv4); + /* Compose a GARP request packet's vlan if exist. */ + if (garp->tag) { + eth_push_vlan(&packet, htons(ETH_TYPE_VLAN), htons(garp->tag)); + } + /* Compose actions. The garp request is output on localnet ofport. */ uint64_t ofpacts_stub[4096 / 8]; struct ofpbuf ofpacts = OFPBUF_STUB_INITIALIZER(ofpacts_stub);