From patchwork Wed May 25 15:03:43 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AZ X-Patchwork-Id: 626226 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from archives.nicira.com (archives.nicira.com [96.126.127.54]) by ozlabs.org (Postfix) with ESMTP id 3rFFsg4ncKz9t5W for ; Thu, 26 May 2016 01:03:51 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=bxnbA5or; dkim-atps=neutral Received: from archives.nicira.com (localhost [127.0.0.1]) by archives.nicira.com (Postfix) with ESMTP id E70D31087E; Wed, 25 May 2016 08:03:50 -0700 (PDT) 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 AC6FE1086F for ; Wed, 25 May 2016 08:03:49 -0700 (PDT) Received: from bar5.cudamail.com (localhost [127.0.0.1]) by mx1e3.cudamail.com (Postfix) with ESMTPS id 371A54203D5 for ; Wed, 25 May 2016 09:03:49 -0600 (MDT) X-ASG-Debug-ID: 1464188624-09eadd22dae07c0001-byXFYA Received: from mx3-pf2.cudamail.com ([192.168.14.1]) by bar5.cudamail.com with ESMTP id p9ensRDuRHY0kwzD (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Wed, 25 May 2016 09:03:44 -0600 (MDT) X-Barracuda-Envelope-From: ak47izatool@gmail.com X-Barracuda-RBL-Trusted-Forwarder: 192.168.14.1 Received: from unknown (HELO mail-io0-f194.google.com) (209.85.223.194) by mx3-pf2.cudamail.com with ESMTPS (AES128-SHA encrypted); 25 May 2016 15:03:43 -0000 Received-SPF: pass (mx3-pf2.cudamail.com: SPF record at _netblocks.google.com designates 209.85.223.194 as permitted sender) X-Barracuda-RBL-Trusted-Forwarder: 209.85.223.194 Received: by mail-io0-f194.google.com with SMTP id 190so5478368iow.2 for ; Wed, 25 May 2016 08:03:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to; bh=2UNrH5emYdoqrVdjPP9Z0LJmger2wBz0QMqWw/yNnqc=; b=bxnbA5orU7Brs2h63DQ1tLPTPFvx0XKgKNPUGrdBcHqxgIvdm2sNXTjOtguOOJaiSr iAy/MErozQtJxnusLgxuyd/4kG2i8A4OrnjxG01lJ+y2/DNnouw4/fC3Wl2B8z0N6Fr4 QnQ4m/3gqy+yc1NzjvMvXjVJXpz/Q02BUuVGj8apT51n974httEhKcCC+JwNlnZfjJRl RaiiulOHmSH18IKsx1FA1Mlz5KSoh5oL8Phtu9PmPvIFU7RiK4yMMpZkGECj4FLGjyJK dboLrIRx5+8cBaDiwoCfAvScDk2gRqKPP5CFu4H9t3lWydkU90J62v+xn9Ask3tFO27h i5Lg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:date:message-id:subject:from:to; bh=2UNrH5emYdoqrVdjPP9Z0LJmger2wBz0QMqWw/yNnqc=; b=jOrVnsfrqm10aYmtBSKQ8e9IjPCWk3ZhIr2AweRcX8+vP810zNpAJP5+FzYEIdw8LX OgahcJR7o04Sp2VofOJCWCjaggTPEIg8U9kz+t9XYVAJeS9VTggtP9VpJFdgfXFjlz+8 QdW6EsS5vsNFXtkbzRDRxcsCDM4jzxijpJuQE5WaJl89d8NX8f6fwECybEJkLrNkKMhn cNgxeR7+uWlULicKTkbWUEOGlmN/3vK982TX6hd7LDJuQ8UKVczooU9Tfmk/xbCOsOrk 5t8RTYMYwsceJHcenojWZUE3YjIgNpoW0MUNY/VvDVblXHlUTCUoI3BWlPnsOUJyNn2j jiqw== X-Gm-Message-State: ALyK8tLe9pDm2GfisRlP30SmbJi0M1yd/uY0zBDAu8lZyQSChJXiNV+g8qnh0fsLZYk0VJW7e4nzmOCoH+cPWg== MIME-Version: 1.0 X-Received: by 10.107.12.86 with SMTP id w83mr4671240ioi.114.1464188623045; Wed, 25 May 2016 08:03:43 -0700 (PDT) Received: by 10.107.181.130 with HTTP; Wed, 25 May 2016 08:03:43 -0700 (PDT) Date: Wed, 25 May 2016 21:03:43 +0600 Message-ID: X-CudaMail-MID: CM-V2-524022186 X-CudaMail-DTE: 052516 X-CudaMail-Originating-IP: 209.85.223.194 X-CudaMail-Envelope-Sender: ak47izatool@gmail.com X-ASG-Orig-Subj: [##CM-V2-524022186##]ofproto: update mtu when port is getting removed as well From: wisd0me To: dev@openvswitch.org X-GBUdb-Analysis: 0, 209.85.223.194, Ugly c=0.396759 p=-0.234043 Source Normal X-MessageSniffer-Rules: 0-0-0-12456-c X-Barracuda-Connect: UNKNOWN[192.168.14.1] X-Barracuda-Start-Time: 1464188624 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: 1.10 X-Barracuda-Spam-Status: No, SCORE=1.10 using global scores of TAG_LEVEL=3.5 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=4.0 tests=BSF_RULE7568M, BSF_SC5_MJ1963, DKIM_SIGNED, RDNS_NONE X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.29893 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- 0.00 DKIM_SIGNED Domain Keys Identified Mail: message has a signature 0.50 BSF_RULE7568M Custom Rule 7568M 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] ofproto: update mtu when port is getting removed as well 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: , Errors-To: dev-bounces@openvswitch.org Sender: "dev" When we're adding the port into ovs bridge, its mtu is updated to the minimal mtu of the included port. But when the port is getting removed, no such update is performed, which leads to bug. For example, when the port with minimal mtu is removed, bridge's mtu must adapt to new value, but it won't happen. How to reproduce the problem: $ ovs-vsctl add-br testing $ ip link add name gretap11 type gretap local 10.0.0.1 remote 10.0.0.100 $ ip link add name gretap12 type gretap local 10.0.0.1 remote 10.0.0.200 $ ip link set dev gretap12 mtu 1600 $ ovs-vsctl add-port testing gretap11 $ ovs-vsctl add-port testing gretap12 $ ip a sh testing 16: testing: mtu 1462 qdisc noop state DOWN group default qlen 1 link/ether 7a:42:95:00:96:40 brd ff:ff:ff:ff:ff:ff $ ovs-vsctl del-port gretap11 $ ip a sh testing 16: testing: mtu 1462 qdisc noop state DOWN group default qlen 1 link/ether 7a:42:95:00:96:40 brd ff:ff:ff:ff:ff:ff $## as we can see here, 'testing' bridge mtu is stuck, while it must adapt to new '1600' value, $## cause there is only one port 'gretap12' left, and it's mtu is '1600': $ ip a sh gretap12 19: gretap12@NONE: mtu 1600 qdisc noop master ovs-system state DOWN group default qlen 1000 link/ether b2:c6:1d:9f:be:0d brd ff:ff:ff:ff:ff:ff My commit fixes this problem - mtu update is performed on port removal as well. Signed-off-by: wisd0me --- ofproto/ofproto.c | 36 +++++++++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 7 deletions(-) static int init_ports(struct ofproto *); @@ -320,6 +321,7 @@ static uint64_t pick_datapath_id(const struct ofproto *); static uint64_t pick_fallback_dpid(void); static void ofproto_destroy__(struct ofproto *); static void update_mtu(struct ofproto *, struct ofport *); +static void update_mtu_ofproto(struct ofproto *); static void meter_delete(struct ofproto *, uint32_t first, uint32_t last); static void meter_insert_rule(struct rule *); @@ -2386,9 +2388,15 @@ error: static void ofport_remove(struct ofport *ofport) { + struct ofproto *p = ofport->ofproto; + bool is_internal = ofport_is_internal(ofport); + connmgr_send_port_status(ofport->ofproto->connmgr, NULL, &ofport->pp, OFPPR_DELETE); ofport_destroy(ofport, true); + if (!is_internal) { + update_mtu_ofproto(p); + } } /* If 'ofproto' contains an ofport named 'name', removes it from 'ofproto' and @@ -2666,6 +2674,12 @@ init_ports(struct ofproto *p) return 0; } +static inline bool +ofport_is_internal(const struct ofport *port) +{ + return strcmp(netdev_get_type(port->netdev), "internal") == 0; +} + /* Find the minimum MTU of all non-datapath devices attached to 'p'. * Returns ETH_PAYLOAD_MAX or the minimum of the ports. */ static int @@ -2680,7 +2694,7 @@ find_min_mtu(struct ofproto *p) /* Skip any internal ports, since that's what we're trying to * set. */ - if (!strcmp(netdev_get_type(netdev), "internal")) { + if (ofport_is_internal(ofport)) { continue; } @@ -2700,15 +2714,14 @@ find_min_mtu(struct ofproto *p) static void update_mtu(struct ofproto *p, struct ofport *port) { - struct ofport *ofport; struct netdev *netdev = port->netdev; - int dev_mtu, old_min; + int dev_mtu; if (netdev_get_mtu(netdev, &dev_mtu)) { port->mtu = 0; return; } - if (!strcmp(netdev_get_type(port->netdev), "internal")) { + if (ofport_is_internal(port)) { if (dev_mtu > p->min_mtu) { if (!netdev_set_mtu(port->netdev, p->min_mtu)) { dev_mtu = p->min_mtu; @@ -2718,9 +2731,18 @@ update_mtu(struct ofproto *p, struct ofport *port) return; } - /* For non-internal port find new min mtu. */ - old_min = p->min_mtu; port->mtu = dev_mtu; + /* For non-internal port find new min mtu. */ + update_mtu_ofproto(p); +} + +static void +update_mtu_ofproto(struct ofproto *p) +{ + /* For non-internal port find new min mtu. */ + struct ofport *ofport; + int old_min = p->min_mtu; + p->min_mtu = find_min_mtu(p); if (p->min_mtu == old_min) { return; @@ -2729,7 +2751,7 @@ update_mtu(struct ofproto *p, struct ofport *port) HMAP_FOR_EACH (ofport, hmap_node, &p->ports) { struct netdev *netdev = ofport->netdev; - if (!strcmp(netdev_get_type(netdev), "internal")) { + if (ofport_is_internal(ofport)) { if (!netdev_set_mtu(netdev, p->min_mtu)) { ofport->mtu = p->min_mtu; } -- 2.7.3 diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c index ae527a4..9aff687 100644 --- a/ofproto/ofproto.c +++ b/ofproto/ofproto.c @@ -219,6 +219,7 @@ static void learned_cookies_flush(struct ofproto *, struct ovs_list *dead_cookie /* ofport. */ static void ofport_destroy__(struct ofport *) OVS_EXCLUDED(ofproto_mutex); static void ofport_destroy(struct ofport *, bool del); +static inline bool ofport_is_internal(const struct ofport *); static int update_port(struct ofproto *, const char *devname);