{"id":806152,"url":"http://patchwork.ozlabs.org/api/1.2/patches/806152/?format=json","web_url":"http://patchwork.ozlabs.org/project/netdev/patch/1503780970-10312-2-git-send-email-andrew@lunn.ch/","project":{"id":7,"url":"http://patchwork.ozlabs.org/api/1.2/projects/7/?format=json","name":"Linux network development","link_name":"netdev","list_id":"netdev.vger.kernel.org","list_email":"netdev@vger.kernel.org","web_url":null,"scm_url":null,"webscm_url":null,"list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<1503780970-10312-2-git-send-email-andrew@lunn.ch>","list_archive_url":null,"date":"2017-08-26T20:56:06","name":"[RFC,WIP,1/5] net: rtnetlink: Handle bridge port without upper device","commit_ref":null,"pull_url":null,"state":"rfc","archived":true,"hash":"7f8987d90143d38b5ca489f5226abdb8bea5d0d5","submitter":{"id":13608,"url":"http://patchwork.ozlabs.org/api/1.2/people/13608/?format=json","name":"Andrew Lunn","email":"andrew@lunn.ch"},"delegate":{"id":34,"url":"http://patchwork.ozlabs.org/api/1.2/users/34/?format=json","username":"davem","first_name":"David","last_name":"Miller","email":"davem@davemloft.net"},"mbox":"http://patchwork.ozlabs.org/project/netdev/patch/1503780970-10312-2-git-send-email-andrew@lunn.ch/mbox/","series":[],"comments":"http://patchwork.ozlabs.org/api/patches/806152/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/806152/checks/","tags":{},"related":[],"headers":{"Return-Path":"<netdev-owner@vger.kernel.org>","X-Original-To":"patchwork-incoming@ozlabs.org","Delivered-To":"patchwork-incoming@ozlabs.org","Authentication-Results":"ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=vger.kernel.org\n\t(client-ip=209.132.180.67; helo=vger.kernel.org;\n\tenvelope-from=netdev-owner@vger.kernel.org;\n\treceiver=<UNKNOWN>)","Received":["from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 3xfr2y4dmDz9sN7\n\tfor <patchwork-incoming@ozlabs.org>;\n\tSun, 27 Aug 2017 06:58:02 +1000 (AEST)","(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1751128AbdHZU6A (ORCPT <rfc822;patchwork-incoming@ozlabs.org>);\n\tSat, 26 Aug 2017 16:58:00 -0400","from vps0.lunn.ch ([178.209.37.122]:45140 \"EHLO vps0.lunn.ch\"\n\trhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP\n\tid S1751083AbdHZU57 (ORCPT <rfc822;netdev@vger.kernel.org>);\n\tSat, 26 Aug 2017 16:57:59 -0400","from andrew by vps0.lunn.ch with local (Exim 4.84_2)\n\t(envelope-from <andrew@lunn.ch>)\n\tid 1dli8H-0002h8-8z; Sat, 26 Aug 2017 22:56:41 +0200"],"From":"Andrew Lunn <andrew@lunn.ch>","To":"netdev <netdev@vger.kernel.org>","Cc":"Vivien Didelot <vivien.didelot@savoirfairelinux.com>,\n\tFlorian Fainelli <f.fainelli@gmail.com>,\n\tnikolay@cumulusnetworks.com, jiri@mellanox.com,\n\troopa@cumulusnetworks.com, stephen@networkplumber.org,\n\tbridge@lists.linux-foundation.org, Andrew Lunn <andrew@lunn.ch>","Subject":"[PATCH RFC WIP 1/5] net: rtnetlink: Handle bridge port without\n\tupper device","Date":"Sat, 26 Aug 2017 22:56:06 +0200","Message-Id":"<1503780970-10312-2-git-send-email-andrew@lunn.ch>","X-Mailer":"git-send-email 2.1.4","In-Reply-To":"<1503780970-10312-1-git-send-email-andrew@lunn.ch>","References":"<1503780970-10312-1-git-send-email-andrew@lunn.ch>","Sender":"netdev-owner@vger.kernel.org","Precedence":"bulk","List-ID":"<netdev.vger.kernel.org>","X-Mailing-List":"netdev@vger.kernel.org"},"content":"The brX interface will with a following patch becomes a member of the\nbridge. It however cannot be a slave interface, since it would have to\nbe a slave of itself. netdev_master_upper_dev_get() returns NULL as a\nresult. Handle this NULL, by knowing this bridge slave must also be\nthe master, i.e. what we are looking for.\n\nSigned-off-by: Andrew Lunn <andrew@lunn.ch>\n---\n net/core/rtnetlink.c | 23 +++++++++++++++++++++--\n 1 file changed, 21 insertions(+), 2 deletions(-)","diff":"diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c\nindex 9201e3621351..2673eb430b6f 100644\n--- a/net/core/rtnetlink.c\n+++ b/net/core/rtnetlink.c\n@@ -3093,8 +3093,12 @@ static int rtnl_fdb_add(struct sk_buff *skb, struct nlmsghdr *nlh,\n \tif ((!ndm->ndm_flags || ndm->ndm_flags & NTF_MASTER) &&\n \t    (dev->priv_flags & IFF_BRIDGE_PORT)) {\n \t\tstruct net_device *br_dev = netdev_master_upper_dev_get(dev);\n-\t\tconst struct net_device_ops *ops = br_dev->netdev_ops;\n+\t\tconst struct net_device_ops *ops;\n \n+\t\tif (!br_dev)\n+\t\t\tbr_dev = dev;\n+\n+\t\tops = br_dev->netdev_ops;\n \t\terr = ops->ndo_fdb_add(ndm, tb, dev, addr, vid,\n \t\t\t\t       nlh->nlmsg_flags);\n \t\tif (err)\n@@ -3197,7 +3201,12 @@ static int rtnl_fdb_del(struct sk_buff *skb, struct nlmsghdr *nlh,\n \tif ((!ndm->ndm_flags || ndm->ndm_flags & NTF_MASTER) &&\n \t    (dev->priv_flags & IFF_BRIDGE_PORT)) {\n \t\tstruct net_device *br_dev = netdev_master_upper_dev_get(dev);\n-\t\tconst struct net_device_ops *ops = br_dev->netdev_ops;\n+\t\tconst struct net_device_ops *ops;\n+\n+\t\tif (!br_dev)\n+\t\t\tbr_dev = dev;\n+\n+\t\tops = br_dev->netdev_ops;\n \n \t\tif (ops->ndo_fdb_del)\n \t\t\terr = ops->ndo_fdb_del(ndm, tb, dev, addr, vid);\n@@ -3332,6 +3341,8 @@ static int rtnl_fdb_dump(struct sk_buff *skb, struct netlink_callback *cb)\n \t\t\tif (!br_idx) { /* user did not specify a specific bridge */\n \t\t\t\tif (dev->priv_flags & IFF_BRIDGE_PORT) {\n \t\t\t\t\tbr_dev = netdev_master_upper_dev_get(dev);\n+\t\t\t\t\tif (!br_dev)\n+\t\t\t\t\t\tbr_dev = dev;\n \t\t\t\t\tcops = br_dev->netdev_ops;\n \t\t\t\t}\n \t\t\t} else {\n@@ -3410,6 +3421,9 @@ int ndo_dflt_bridge_getlink(struct sk_buff *skb, u32 pid, u32 seq,\n \tstruct net_device *br_dev = netdev_master_upper_dev_get(dev);\n \tint err = 0;\n \n+\tif (!br_dev)\n+\t\tbr_dev = dev;\n+\n \tnlh = nlmsg_put(skb, pid, seq, RTM_NEWLINK, sizeof(*ifm), nlflags);\n \tif (nlh == NULL)\n \t\treturn -EMSGSIZE;\n@@ -3647,6 +3661,8 @@ static int rtnl_bridge_setlink(struct sk_buff *skb, struct nlmsghdr *nlh,\n \n \tif (!flags || (flags & BRIDGE_FLAGS_MASTER)) {\n \t\tstruct net_device *br_dev = netdev_master_upper_dev_get(dev);\n+\t\tif (!br_dev)\n+\t\t\tbr_dev = dev;\n \n \t\tif (!br_dev || !br_dev->netdev_ops->ndo_bridge_setlink) {\n \t\t\terr = -EOPNOTSUPP;\n@@ -3723,6 +3739,9 @@ static int rtnl_bridge_dellink(struct sk_buff *skb, struct nlmsghdr *nlh,\n \tif (!flags || (flags & BRIDGE_FLAGS_MASTER)) {\n \t\tstruct net_device *br_dev = netdev_master_upper_dev_get(dev);\n \n+\t\tif (!br_dev)\n+\t\t\tbr_dev = dev;\n+\n \t\tif (!br_dev || !br_dev->netdev_ops->ndo_bridge_dellink) {\n \t\t\terr = -EOPNOTSUPP;\n \t\t\tgoto out;\n","prefixes":["RFC","WIP","1/5"]}