From patchwork Thu Apr 24 12:16:27 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Toshiaki Makita X-Patchwork-Id: 342390 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id A7056140128 for ; Thu, 24 Apr 2014 22:16:50 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753284AbaDXMQo (ORCPT ); Thu, 24 Apr 2014 08:16:44 -0400 Received: from tama500.ecl.ntt.co.jp ([129.60.39.148]:48068 "EHLO tama500.ecl.ntt.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753183AbaDXMQn (ORCPT ); Thu, 24 Apr 2014 08:16:43 -0400 Received: from mfs5.rdh.ecl.ntt.co.jp (mfs5.rdh.ecl.ntt.co.jp [129.60.39.144]) by tama500.ecl.ntt.co.jp (8.13.8/8.13.8) with ESMTP id s3OCGXsO023230; Thu, 24 Apr 2014 21:16:33 +0900 Received: from mfs5.rdh.ecl.ntt.co.jp (localhost.localdomain [127.0.0.1]) by mfs5.rdh.ecl.ntt.co.jp (Postfix) with ESMTP id F39F1E013F; Thu, 24 Apr 2014 21:16:32 +0900 (JST) Received: from imail3.m.ecl.ntt.co.jp (imail3.m.ecl.ntt.co.jp [129.60.5.248]) by mfs5.rdh.ecl.ntt.co.jp (Postfix) with ESMTP id E7A4FE013E; Thu, 24 Apr 2014 21:16:32 +0900 (JST) Received: from [192.168.157.130] ([129.60.241.132]) by imail3.m.ecl.ntt.co.jp (8.13.8/8.13.8) with ESMTP id s3OCGWu7000800; Thu, 24 Apr 2014 21:16:32 +0900 Message-ID: <1398341787.4171.16.camel@ubuntu-vm-makita> Subject: [PATCH net] bridge: Handle IFLA_ADDRESS correctly when creating bridge device From: Toshiaki Makita To: "David S. Miller" , Stephen Hemminger Cc: netdev , bridge , "C. R. Oldham" , Tom Gundersen Date: Thu, 24 Apr 2014 21:16:27 +0900 In-Reply-To: <1398341177.4171.11.camel@ubuntu-vm-makita> References: <1398341177.4171.11.camel@ubuntu-vm-makita> X-Mailer: Evolution 3.6.4-0ubuntu1 Mime-Version: 1.0 X-TM-AS-MML: No Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org When bridge device is created with IFLA_ADDRESS, we are not calling br_stp_change_bridge_id(), which leads to incorrect local fdb management and bridge id calculation, and prevents us from receiving frames on the bridge device. Reported-by: Tom Gundersen Signed-off-by: Toshiaki Makita --- net/bridge/br_netlink.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/net/bridge/br_netlink.c b/net/bridge/br_netlink.c index e74b6d53..a8b664e 100644 --- a/net/bridge/br_netlink.c +++ b/net/bridge/br_netlink.c @@ -445,6 +445,25 @@ static int br_validate(struct nlattr *tb[], struct nlattr *data[]) return 0; } +static int br_dev_newlink(struct net *src_net, struct net_device *dev, + struct nlattr *tb[], struct nlattr *data[]) +{ + int err; + struct net_bridge *br = netdev_priv(dev); + + if (tb[IFLA_ADDRESS]) { + spin_lock_bh(&br->lock); + br_stp_change_bridge_id(br, nla_data(tb[IFLA_ADDRESS])); + spin_unlock_bh(&br->lock); + } + + err = register_netdevice(dev); + if (err) + return err; + + return 0; +} + static size_t br_get_link_af_size(const struct net_device *dev) { struct net_port_vlans *pv; @@ -473,6 +492,7 @@ struct rtnl_link_ops br_link_ops __read_mostly = { .priv_size = sizeof(struct net_bridge), .setup = br_dev_setup, .validate = br_validate, + .newlink = br_dev_newlink, .dellink = br_dev_delete, };