From patchwork Tue Jun 18 14:29:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Maximets X-Patchwork-Id: 1117969 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; dmarc=fail (p=none dis=none) header.from=samsung.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=samsung.com header.i=@samsung.com header.b="YYuQiSku"; 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 45Sr7s2fMsz9sNy for ; Wed, 19 Jun 2019 00:29:44 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id D96BCE3D; Tue, 18 Jun 2019 14:29:41 +0000 (UTC) X-Original-To: ovs-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 69001B4B for ; Tue, 18 Jun 2019 14:29:40 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 1FD045D4 for ; Tue, 18 Jun 2019 14:29:38 +0000 (UTC) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20190618142937euoutp02ce90a2a1d9d6e891a7bddbe5e02d51a3~pUVZT-MmW2415224152euoutp027 for ; Tue, 18 Jun 2019 14:29:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20190618142937euoutp02ce90a2a1d9d6e891a7bddbe5e02d51a3~pUVZT-MmW2415224152euoutp027 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1560868177; bh=X8Sy5MNWvXfNFf24+iYgnkiVcYVBJkDJio7ZqGk2wqE=; h=From:To:Cc:Subject:Date:References:From; b=YYuQiSkuvPZyAM89E39i21jIESWjXHGiv1UBRSwnJAJ86gZl3ikmkycu7xHZSzbBA ih8YIQZk+p6vYRI3ozn+oljb6AxIUIskBaxWIFL3I12fhtKG6zcZ5vJ0v4Ei+w3kFq 71y001BY3hqd39yM7uvyJHOj+q13/XIxm0h6sejk= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20190618142936eucas1p14a8b19ce1c990b045d69b7750fef7b6c~pUVYwJ5ya0988709887eucas1p18; Tue, 18 Jun 2019 14:29:36 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id E4.65.04377.055F80D5; Tue, 18 Jun 2019 15:29:36 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20190618142935eucas1p13f7d66540e1cdb57b69b227c077fab48~pUVX6PaG50988209882eucas1p1q; Tue, 18 Jun 2019 14:29:35 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20190618142935eusmtrp11822b355b20d38d10d67abe2c4710ca5~pUVXquAsN2409824098eusmtrp1I; Tue, 18 Jun 2019 14:29:35 +0000 (GMT) X-AuditID: cbfec7f4-113ff70000001119-e2-5d08f5509181 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 1C.36.04140.F45F80D5; Tue, 18 Jun 2019 15:29:35 +0100 (BST) Received: from imaximets.rnd.samsung.ru (unknown [106.109.129.180]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20190618142934eusmtip1cf8d0324e3f33b56a7e6ce5d5e21dced~pUVXS3c9E2608226082eusmtip1L; Tue, 18 Jun 2019 14:29:34 +0000 (GMT) From: Ilya Maximets To: ovs-dev@openvswitch.org Date: Tue, 18 Jun 2019 17:29:30 +0300 Message-Id: <20190618142930.27624-1-i.maximets@samsung.com> X-Mailer: git-send-email 2.17.1 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrIIsWRmVeSWpSXmKPExsWy7djP87oBXzliDZb/Zbd4NbmB0eJK+092 i7mfnjM6MHs8u/mf0eP5tR4Wj74tqxgDmKO4bFJSczLLUov07RK4Mk4+vcBW8MGi4tKH3AbG Ds0uRk4OCQETiY/bOpm6GLk4hARWMEr83fWXFcL5wihx9d5vZgjnM6PE3Rez2WFazrQ3QrUs Z5RY9LcBquoHo8Ss57uZQKrYBHQkTq0+wghiiwhIS7zufcMKYjMLOEtsuzgDLC4sEClx7OBF sHoWAVWJnd/+gsV5Bawl/k1+wQixTV5i9YYDYAskBFawSbz+tB/qDBeJKb0H2SBsYYlXx7dA xWUkTk/uYYGw6yXut7xkhGjuYJSYfugfE0TCXmLL63NADRxAF2lKrN+lDxF2lFj96S4zSFhC gE/ixltBiJv5JCZtmw4V5pXoaBOCqFaR+H1wOTOELSVx891nqAs8JF48/AN2gZBArMTc808Y JzDKzULYtYCRcRWjeGppcW56arFRXmq5XnFibnFpXrpecn7uJkZgRJ/+d/zLDsZdf5IOMQpw MCrx8Ap85ogVYk0sK67MPcQowcGsJMI71RgoxJuSWFmVWpQfX1Sak1p8iFGag0VJnLea4UG0 kEB6YklqdmpqQWoRTJaJg1OqgbHhRt7rGMMPdyqcSn2fLGzIkqt40sJYouR4o4u1M8tg1rbi lYpl/Nb9NiZc0XnJZRX7Kpzcjdabr99iJli66r3qno+Zqyt7JpsG/ukOKigxMyng7DLJWbWp 6uza2kbzmv9Tnx43V7Nb5iR2dmGoc7bR7YOlbtfiqycmyF+M7KvZXutemnpCiaU4I9FQi7mo OBEAY6BfbeQCAAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrOLMWRmVeSWpSXmKPExsVy+t/xu7r+XzliDa6d5LF4NbmB0eJK+092 i7mfnjM6MHs8u/mf0eP5tR4Wj74tqxgDmKP0bIryS0tSFTLyi0tslaINLYz0DC0t9IxMLPUM jc1jrYxMlfTtbFJSczLLUov07RL0Mk4+vcBW8MGi4tKH3AbGDs0uRk4OCQETiTPtjUxdjFwc QgJLGSX+X+1lgUhISfz4dYEVwhaW+HOtiw2i6BujxIk/E9hAEmwCOhKnVh9hBLFFBKQlXve+ AWtgFnCV+L6gGaxGWCBcYveLuUwgNouAqsTOb3/B6nkFrCX+TX7BCLFAXmL1hgPMExh5FjAy rGIUSS0tzk3PLTbSK07MLS7NS9dLzs/dxAgMpG3Hfm7Zwdj1LvgQowAHoxIPb0Ere6wQa2JZ cWXuIUYJDmYlEd6pxhyxQrwpiZVVqUX58UWlOanFhxhNgZZPZJYSTc4HBnleSbyhqaG5haWh ubG5sZmFkjhvh8DBGCGB9MSS1OzU1ILUIpg+Jg5OqQZG2zqHdfNEb536+VVhtWDSh8b/s5pe +fZsWrA/gUFr8+qNggtetp/UMr79P21i/91SodKJ21bZhnvLSu1lmDStZ7mfzBXur37CXxyC S1fVqWoIupybfkThtsjxDAGxqfHyMypEZp3Kul41NeZol0zjyfdPs/cvTXIpWCbE/mOZsO/m jBLuZOZOJZbijERDLeai4kQAMevfTzoCAAA= X-CMS-MailID: 20190618142935eucas1p13f7d66540e1cdb57b69b227c077fab48 X-Msg-Generator: CA X-RootMTR: 20190618142935eucas1p13f7d66540e1cdb57b69b227c077fab48 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20190618142935eucas1p13f7d66540e1cdb57b69b227c077fab48 References: X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Cc: Ilya Maximets Subject: [ovs-dev] [RFC] ofproto-dpif-xlate: Flood the updates for learning tables through peers. 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 Consider following setup: br0: phy-port random-port patch-to-br-int br-int: port-1 port-2 patch-to-br0 And the expected traffic pattern: phy-port ---> port-1 ---> port-2 ---> phy-port For example, this could be done if 'port-1' and 'port-2' are ports of two VMs and we have some service chain PHY --> VM1 --> VM2 --> PHY. In case we have a unidirectional packet stream (UDP), VM1 will never send packets outside the integration bridge (br-int). This will lead to situation where the physical bridge (br0) will expire the mac of 'port-1' from the mac learning table after some time and will never know it again, causing constant flooding inside the physical bridge (br0): # ovs-appctl ofproto/trace \ br0 "in_port=phy-port,ip,eth_src=,eth_dst=" Flow: ip,in_port=1,dl_src=,dl_dst= bridge("br0") ----------------- 0. priority 0 NORMAL -> no learned MAC for destination, flooding bridge("br-int") ---------------- 0. in_port=patch-to-br0, priority 0 NORMAL -> forwarding to learned port Final flow: unchanged Megaflow: recirc_id=0,eth,ip,in_port=phy-port,dl_src=,dl_dst= Datapath actions: br0,random-port,port-1 This is unwanted because 'br-int' knows that the desired mac is behind the 'port-1' and sends packets directly, while 'br0' keeps flooding the packets to all the ports significantly reducing performance. Since bridges connected via patch ports are almost the same L2 bridge, they should share L2 learning information in order to avoid such conditions. This could be implemented by flooding of the mac learning information over the patch ports while updating the learning tables. Signed-off-by: Ilya Maximets --- Not fully tested. ofproto/ofproto-dpif-xlate.c | 66 ++++++++++++++++++++++++++++++++---- 1 file changed, 59 insertions(+), 7 deletions(-) diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c index 73966a4e8..11d04e049 100644 --- a/ofproto/ofproto-dpif-xlate.c +++ b/ofproto/ofproto-dpif-xlate.c @@ -34,6 +34,7 @@ #include "csum.h" #include "dp-packet.h" #include "dpif.h" +#include "hmapx.h" #include "in-band.h" #include "lacp.h" #include "learn.h" @@ -544,7 +545,7 @@ static void xlate_table_action(struct xlate_ctx *, ofp_port_t in_port, bool is_last_action, xlate_actions_handler *); static bool input_vid_is_valid(const struct xlate_ctx *, - uint16_t vid, struct xbundle *); + uint16_t vid, const struct xbundle *); static void xvlan_copy(struct xvlan *dst, const struct xvlan *src); static void xvlan_pop(struct xvlan *src); static void xvlan_push_uninit(struct xvlan *src); @@ -2181,7 +2182,7 @@ mirror_ingress_packet(struct xlate_ctx *ctx) * 0...4095. */ static bool input_vid_is_valid(const struct xlate_ctx *ctx, - uint16_t vid, struct xbundle *in_xbundle) + uint16_t vid, const struct xbundle *in_xbundle) { /* Allow any VID on the OFPP_NONE port. */ if (in_xbundle == &ofpp_none_bundle) { @@ -2554,7 +2555,8 @@ is_admissible(struct xlate_ctx *ctx, struct xport *in_port, static bool update_learning_table__(const struct xbridge *xbridge, - struct xbundle *in_xbundle, struct eth_addr dl_src, + const struct xbundle *in_xbundle, + struct eth_addr dl_src, int vlan, bool is_grat_arp) { return (in_xbundle == &ofpp_none_bundle @@ -2565,10 +2567,48 @@ update_learning_table__(const struct xbridge *xbridge, } static void -update_learning_table(const struct xlate_ctx *ctx, - struct xbundle *in_xbundle, struct eth_addr dl_src, - int vlan, bool is_grat_arp) +update_learning_table_with_flood(struct xlate_ctx *ctx, + const struct xbundle *in_xbundle, + struct eth_addr dl_src, + const struct xvlan *xvlan, bool is_grat_arp, + struct hmapx *updated_bridges) { + struct xport *xport; + int vlan = xvlan->v[0].vid; + + /* Prevent updating the same bridge twice. */ + hmapx_add(updated_bridges, CONST_CAST(void *, ctx->xbridge)); + + /* Flooding the mac updates through the peers. */ + HMAP_FOR_EACH (xport, ofp_node, &ctx->xbridge->xports) { + if (xport->peer + && !hmapx_contains(updated_bridges, xport->peer->xbridge) + && xport->xbundle + && xport->xbundle != in_xbundle + && xport->xbundle->ofbundle != in_xbundle->ofbundle + && xbundle_includes_vlan(xport->xbundle, xvlan) + && xport->xbundle->floodable + && !xbundle_mirror_out(ctx->xbridge, xport->xbundle)) { + + const struct xbridge *xbridge_orig = ctx->xbridge; + const struct xbundle *peer_xbundle = xport->peer->xbundle; + struct xvlan out_xvlan, peer_xvlan; + + xvlan_output_translate(xport->xbundle, xvlan, &out_xvlan); + if (!input_vid_is_valid(ctx, out_xvlan.v[0].vid, peer_xbundle)) { + continue; + } + xvlan_input_translate(peer_xbundle, &out_xvlan, &peer_xvlan); + + ctx->xbridge = xport->peer->xbridge; + update_learning_table_with_flood(ctx, peer_xbundle, dl_src, + &peer_xvlan, is_grat_arp, + updated_bridges); + ctx->xbridge = xbridge_orig; + } + } + + /* Update the current bridge. */ if (!update_learning_table__(ctx->xbridge, in_xbundle, dl_src, vlan, is_grat_arp)) { xlate_report_debug(ctx, OFT_DETAIL, "learned that "ETH_ADDR_FMT" is " @@ -2577,6 +2617,18 @@ update_learning_table(const struct xlate_ctx *ctx, } } +static void +update_learning_table(struct xlate_ctx *ctx, + const struct xbundle *in_xbundle, struct eth_addr dl_src, + const struct xvlan *xvlan, bool is_grat_arp) +{ + struct hmapx updated_bridges = HMAPX_INITIALIZER(&updated_bridges); + + update_learning_table_with_flood(ctx, in_xbundle, dl_src, xvlan, + is_grat_arp, &updated_bridges); + hmapx_destroy(&updated_bridges); +} + /* Updates multicast snooping table 'ms' given that a packet matching 'flow' * was received on 'in_xbundle' in 'vlan' and is either Report or Query. */ static void @@ -2984,7 +3036,7 @@ xlate_normal(struct xlate_ctx *ctx) && flow->packet_type == htonl(PT_ETH) && in_port->pt_mode != NETDEV_PT_LEGACY_L3 ) { - update_learning_table(ctx, in_xbundle, flow->dl_src, vlan, + update_learning_table(ctx, in_xbundle, flow->dl_src, &xvlan, is_grat_arp); } if (ctx->xin->xcache && in_xbundle != &ofpp_none_bundle) {