From patchwork Wed Mar 8 11:53:10 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: nickcooper-zhangtonghao X-Patchwork-Id: 736548 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 3vdX3y2Kvjz9s9Z for ; Wed, 8 Mar 2017 22:53:49 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 63680AB9; Wed, 8 Mar 2017 11:53:46 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp2.linuxfoundation.org (smtp2.linux-foundation.org [172.17.192.36]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 9D14541C for ; Wed, 8 Mar 2017 11:53:44 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from smtpbg65.qq.com (smtpbg65.qq.com [103.7.28.233]) by smtp2.linuxfoundation.org (Postfix) with ESMTPS id DF9401DDE8 for ; Wed, 8 Mar 2017 11:53:41 +0000 (UTC) X-QQ-mid: bizesmtp16t1488974006tmzvevd8 Received: from local.opencloud.tech.localdomai (unknown [106.120.127.11]) by esmtp4.qq.com (ESMTP) with id ; Wed, 08 Mar 2017 19:53:20 +0800 (CST) X-QQ-SSF: 01100000002000F0FF80B00A0000000 X-QQ-FEAT: ueeW6WFna0KPFSdhD/tj2fj05TyTr3Y7bLj0hdqY5lacWVcsF262Y5x46yGI5 eXQLLiNSt34cKuXXZeyCiWXd75RFFDScJ7BqeJcOvQNVE+w4JURD5dQ96R1EHP+N8AwOTvq snFaOxde1JeQfp9mQRAla7fo6Ii4vBlpTcZ+YWdleR7vNivPcub/S12HdwGCb0OqQT205oo gi6pFDrcGxJlDFGRaQFEGDH9CbQOKk25catir+D0DpCFAPvrjevChXp0ORGmP8Mi3X+kTlQ YC28gZDNmcS/0h X-QQ-GoodBg: 0 From: nickcooper-zhangtonghao To: dev@openvswitch.org Date: Wed, 8 Mar 2017 03:53:10 -0800 Message-Id: <1488973990-62421-1-git-send-email-nic@opencloud.tech> X-Mailer: git-send-email 1.8.3.1 X-QQ-SENDSIZE: 520 X-QQ-Bgrelay: 1 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp2.linux-foundation.org Subject: [ovs-dev] [PATCH] stp: Set time of BPDU packet. 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 The OvS BPDU packets have not right format. The STP works well in OvS bridges when stp enabled, because they set the time(e.g. max age, hello time and forward delay) in ticks. But they should be sec. If so, OvS STP can work well with other type of bridge using STP. Signed-off-by: nickcooper-zhangtonghao --- lib/stp.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/lib/stp.c b/lib/stp.c index d828c64..b9eac1c 100644 --- a/lib/stp.c +++ b/lib/stp.c @@ -1065,13 +1065,14 @@ stp_transmit_config(struct stp_port *p) OVS_REQUIRES(mutex) if (root) { config.message_age = htons(0); } else { - config.message_age = htons(stp->root_port->message_age_timer.value - + MESSAGE_AGE_INCREMENT); + config.message_age = + htons(timer_to_ms(stp->root_port->message_age_timer.value) / 1000 + + MESSAGE_AGE_INCREMENT); } - config.max_age = htons(stp->max_age); - config.hello_time = htons(stp->hello_time); - config.forward_delay = htons(stp->forward_delay); - if (ntohs(config.message_age) < stp->max_age) { + config.max_age = htons(timer_to_ms(stp->max_age) / 1000); + config.hello_time = htons(timer_to_ms(stp->hello_time) / 1000); + config.forward_delay = htons(timer_to_ms(stp->forward_delay) / 1000); + if (ntohs(config.message_age) < timer_to_ms(stp->max_age) / 1000) { p->topology_change_ack = false; p->config_pending = false; VLOG_DBG_RL(&stp_rl, "bridge: %s, port: %s, transmit config bpdu", @@ -1108,7 +1109,8 @@ stp_record_config_information(struct stp_port *p, p->designated_cost = ntohl(config->root_path_cost); p->designated_bridge = ntohll(config->bridge_id); p->designated_port = ntohs(config->port_id); - stp_start_timer(&p->message_age_timer, ntohs(config->message_age)); + stp_start_timer(&p->message_age_timer, + ms_to_timer(ntohs(config->message_age) * 1000)); } static void @@ -1116,9 +1118,9 @@ stp_record_config_timeout_values(struct stp *stp, const struct stp_config_bpdu *config) OVS_REQUIRES(mutex) { - stp->max_age = ntohs(config->max_age); - stp->hello_time = ntohs(config->hello_time); - stp->forward_delay = ntohs(config->forward_delay); + stp->max_age = ms_to_timer(ntohs(config->max_age) * 1000); + stp->hello_time = ms_to_timer(ntohs(config->hello_time) * 1000); + stp->forward_delay = ms_to_timer(ntohs(config->forward_delay) * 1000); stp->topology_change = config->flags & STP_CONFIG_TOPOLOGY_CHANGE; }