Commit 898e5061 authored by Jiri Pirko's avatar Jiri Pirko Committed by David S. Miller

rtnetlink: remove usage of dev->master

Signed-off-by: default avatarJiri Pirko <jiri@resnulli.us>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 126d6c23
...@@ -880,6 +880,7 @@ static int rtnl_fill_ifinfo(struct sk_buff *skb, struct net_device *dev, ...@@ -880,6 +880,7 @@ static int rtnl_fill_ifinfo(struct sk_buff *skb, struct net_device *dev,
const struct rtnl_link_stats64 *stats; const struct rtnl_link_stats64 *stats;
struct nlattr *attr, *af_spec; struct nlattr *attr, *af_spec;
struct rtnl_af_ops *af_ops; struct rtnl_af_ops *af_ops;
struct net_device *upper_dev = netdev_master_upper_dev_get(dev);
ASSERT_RTNL(); ASSERT_RTNL();
nlh = nlmsg_put(skb, pid, seq, type, sizeof(*ifm), flags); nlh = nlmsg_put(skb, pid, seq, type, sizeof(*ifm), flags);
...@@ -908,8 +909,8 @@ static int rtnl_fill_ifinfo(struct sk_buff *skb, struct net_device *dev, ...@@ -908,8 +909,8 @@ static int rtnl_fill_ifinfo(struct sk_buff *skb, struct net_device *dev,
#endif #endif
(dev->ifindex != dev->iflink && (dev->ifindex != dev->iflink &&
nla_put_u32(skb, IFLA_LINK, dev->iflink)) || nla_put_u32(skb, IFLA_LINK, dev->iflink)) ||
(dev->master && (upper_dev &&
nla_put_u32(skb, IFLA_MASTER, dev->master->ifindex)) || nla_put_u32(skb, IFLA_MASTER, upper_dev->ifindex)) ||
nla_put_u8(skb, IFLA_CARRIER, netif_carrier_ok(dev)) || nla_put_u8(skb, IFLA_CARRIER, netif_carrier_ok(dev)) ||
(dev->qdisc && (dev->qdisc &&
nla_put_string(skb, IFLA_QDISC, dev->qdisc->ops->id)) || nla_put_string(skb, IFLA_QDISC, dev->qdisc->ops->id)) ||
...@@ -1273,16 +1274,16 @@ static int do_setvfinfo(struct net_device *dev, struct nlattr *attr) ...@@ -1273,16 +1274,16 @@ static int do_setvfinfo(struct net_device *dev, struct nlattr *attr)
static int do_set_master(struct net_device *dev, int ifindex) static int do_set_master(struct net_device *dev, int ifindex)
{ {
struct net_device *master_dev; struct net_device *upper_dev = netdev_master_upper_dev_get(dev);
const struct net_device_ops *ops; const struct net_device_ops *ops;
int err; int err;
if (dev->master) { if (upper_dev) {
if (dev->master->ifindex == ifindex) if (upper_dev->ifindex == ifindex)
return 0; return 0;
ops = dev->master->netdev_ops; ops = upper_dev->netdev_ops;
if (ops->ndo_del_slave) { if (ops->ndo_del_slave) {
err = ops->ndo_del_slave(dev->master, dev); err = ops->ndo_del_slave(upper_dev, dev);
if (err) if (err)
return err; return err;
} else { } else {
...@@ -1291,12 +1292,12 @@ static int do_set_master(struct net_device *dev, int ifindex) ...@@ -1291,12 +1292,12 @@ static int do_set_master(struct net_device *dev, int ifindex)
} }
if (ifindex) { if (ifindex) {
master_dev = __dev_get_by_index(dev_net(dev), ifindex); upper_dev = __dev_get_by_index(dev_net(dev), ifindex);
if (!master_dev) if (!upper_dev)
return -EINVAL; return -EINVAL;
ops = master_dev->netdev_ops; ops = upper_dev->netdev_ops;
if (ops->ndo_add_slave) { if (ops->ndo_add_slave) {
err = ops->ndo_add_slave(master_dev, dev); err = ops->ndo_add_slave(upper_dev, dev);
if (err) if (err)
return err; return err;
} else { } else {
...@@ -2048,7 +2049,6 @@ static void rtnl_fdb_notify(struct net_device *dev, u8 *addr, int type) ...@@ -2048,7 +2049,6 @@ static void rtnl_fdb_notify(struct net_device *dev, u8 *addr, int type)
static int rtnl_fdb_add(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg) static int rtnl_fdb_add(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
{ {
struct net *net = sock_net(skb->sk); struct net *net = sock_net(skb->sk);
struct net_device *master = NULL;
struct ndmsg *ndm; struct ndmsg *ndm;
struct nlattr *tb[NDA_MAX+1]; struct nlattr *tb[NDA_MAX+1];
struct net_device *dev; struct net_device *dev;
...@@ -2090,10 +2090,10 @@ static int rtnl_fdb_add(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg) ...@@ -2090,10 +2090,10 @@ static int rtnl_fdb_add(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
/* Support fdb on master device the net/bridge default case */ /* Support fdb on master device the net/bridge default case */
if ((!ndm->ndm_flags || ndm->ndm_flags & NTF_MASTER) && if ((!ndm->ndm_flags || ndm->ndm_flags & NTF_MASTER) &&
(dev->priv_flags & IFF_BRIDGE_PORT)) { (dev->priv_flags & IFF_BRIDGE_PORT)) {
master = dev->master; struct net_device *br_dev = netdev_master_upper_dev_get(dev);
err = master->netdev_ops->ndo_fdb_add(ndm, tb, const struct net_device_ops *ops = br_dev->netdev_ops;
dev, addr,
nlh->nlmsg_flags); err = ops->ndo_fdb_add(ndm, tb, dev, addr, nlh->nlmsg_flags);
if (err) if (err)
goto out; goto out;
else else
...@@ -2154,10 +2154,11 @@ static int rtnl_fdb_del(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg) ...@@ -2154,10 +2154,11 @@ static int rtnl_fdb_del(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
/* Support fdb on master device the net/bridge default case */ /* Support fdb on master device the net/bridge default case */
if ((!ndm->ndm_flags || ndm->ndm_flags & NTF_MASTER) && if ((!ndm->ndm_flags || ndm->ndm_flags & NTF_MASTER) &&
(dev->priv_flags & IFF_BRIDGE_PORT)) { (dev->priv_flags & IFF_BRIDGE_PORT)) {
struct net_device *master = dev->master; struct net_device *br_dev = netdev_master_upper_dev_get(dev);
const struct net_device_ops *ops = br_dev->netdev_ops;
if (master->netdev_ops->ndo_fdb_del) if (ops->ndo_fdb_del)
err = master->netdev_ops->ndo_fdb_del(ndm, dev, addr); err = ops->ndo_fdb_del(ndm, dev, addr);
if (err) if (err)
goto out; goto out;
...@@ -2241,9 +2242,11 @@ static int rtnl_fdb_dump(struct sk_buff *skb, struct netlink_callback *cb) ...@@ -2241,9 +2242,11 @@ static int rtnl_fdb_dump(struct sk_buff *skb, struct netlink_callback *cb)
rcu_read_lock(); rcu_read_lock();
for_each_netdev_rcu(net, dev) { for_each_netdev_rcu(net, dev) {
if (dev->priv_flags & IFF_BRIDGE_PORT) { if (dev->priv_flags & IFF_BRIDGE_PORT) {
struct net_device *master = dev->master; struct net_device *br_dev;
const struct net_device_ops *ops = master->netdev_ops; const struct net_device_ops *ops;
br_dev = netdev_master_upper_dev_get(dev);
ops = br_dev->netdev_ops;
if (ops->ndo_fdb_dump) if (ops->ndo_fdb_dump)
idx = ops->ndo_fdb_dump(skb, cb, dev, idx); idx = ops->ndo_fdb_dump(skb, cb, dev, idx);
} }
...@@ -2264,6 +2267,7 @@ int ndo_dflt_bridge_getlink(struct sk_buff *skb, u32 pid, u32 seq, ...@@ -2264,6 +2267,7 @@ int ndo_dflt_bridge_getlink(struct sk_buff *skb, u32 pid, u32 seq,
struct ifinfomsg *ifm; struct ifinfomsg *ifm;
struct nlattr *br_afspec; struct nlattr *br_afspec;
u8 operstate = netif_running(dev) ? dev->operstate : IF_OPER_DOWN; u8 operstate = netif_running(dev) ? dev->operstate : IF_OPER_DOWN;
struct net_device *br_dev = netdev_master_upper_dev_get(dev);
nlh = nlmsg_put(skb, pid, seq, RTM_NEWLINK, sizeof(*ifm), NLM_F_MULTI); nlh = nlmsg_put(skb, pid, seq, RTM_NEWLINK, sizeof(*ifm), NLM_F_MULTI);
if (nlh == NULL) if (nlh == NULL)
...@@ -2281,8 +2285,8 @@ int ndo_dflt_bridge_getlink(struct sk_buff *skb, u32 pid, u32 seq, ...@@ -2281,8 +2285,8 @@ int ndo_dflt_bridge_getlink(struct sk_buff *skb, u32 pid, u32 seq,
if (nla_put_string(skb, IFLA_IFNAME, dev->name) || if (nla_put_string(skb, IFLA_IFNAME, dev->name) ||
nla_put_u32(skb, IFLA_MTU, dev->mtu) || nla_put_u32(skb, IFLA_MTU, dev->mtu) ||
nla_put_u8(skb, IFLA_OPERSTATE, operstate) || nla_put_u8(skb, IFLA_OPERSTATE, operstate) ||
(dev->master && (br_dev &&
nla_put_u32(skb, IFLA_MASTER, dev->master->ifindex)) || nla_put_u32(skb, IFLA_MASTER, br_dev->ifindex)) ||
(dev->addr_len && (dev->addr_len &&
nla_put(skb, IFLA_ADDRESS, dev->addr_len, dev->dev_addr)) || nla_put(skb, IFLA_ADDRESS, dev->addr_len, dev->dev_addr)) ||
(dev->ifindex != dev->iflink && (dev->ifindex != dev->iflink &&
...@@ -2318,11 +2322,11 @@ static int rtnl_bridge_getlink(struct sk_buff *skb, struct netlink_callback *cb) ...@@ -2318,11 +2322,11 @@ static int rtnl_bridge_getlink(struct sk_buff *skb, struct netlink_callback *cb)
rcu_read_lock(); rcu_read_lock();
for_each_netdev_rcu(net, dev) { for_each_netdev_rcu(net, dev) {
const struct net_device_ops *ops = dev->netdev_ops; const struct net_device_ops *ops = dev->netdev_ops;
struct net_device *master = dev->master; struct net_device *br_dev = netdev_master_upper_dev_get(dev);
if (master && master->netdev_ops->ndo_bridge_getlink) { if (br_dev && br_dev->netdev_ops->ndo_bridge_getlink) {
if (idx >= cb->args[0] && if (idx >= cb->args[0] &&
master->netdev_ops->ndo_bridge_getlink( br_dev->netdev_ops->ndo_bridge_getlink(
skb, portid, seq, dev) < 0) skb, portid, seq, dev) < 0)
break; break;
idx++; idx++;
...@@ -2359,7 +2363,7 @@ static inline size_t bridge_nlmsg_size(void) ...@@ -2359,7 +2363,7 @@ static inline size_t bridge_nlmsg_size(void)
static int rtnl_bridge_notify(struct net_device *dev, u16 flags) static int rtnl_bridge_notify(struct net_device *dev, u16 flags)
{ {
struct net *net = dev_net(dev); struct net *net = dev_net(dev);
struct net_device *master = dev->master; struct net_device *br_dev = netdev_master_upper_dev_get(dev);
struct sk_buff *skb; struct sk_buff *skb;
int err = -EOPNOTSUPP; int err = -EOPNOTSUPP;
...@@ -2370,8 +2374,8 @@ static int rtnl_bridge_notify(struct net_device *dev, u16 flags) ...@@ -2370,8 +2374,8 @@ static int rtnl_bridge_notify(struct net_device *dev, u16 flags)
} }
if ((!flags || (flags & BRIDGE_FLAGS_MASTER)) && if ((!flags || (flags & BRIDGE_FLAGS_MASTER)) &&
master && master->netdev_ops->ndo_bridge_getlink) { br_dev && br_dev->netdev_ops->ndo_bridge_getlink) {
err = master->netdev_ops->ndo_bridge_getlink(skb, 0, 0, dev); err = br_dev->netdev_ops->ndo_bridge_getlink(skb, 0, 0, dev);
if (err < 0) if (err < 0)
goto errout; goto errout;
} }
...@@ -2430,13 +2434,14 @@ static int rtnl_bridge_setlink(struct sk_buff *skb, struct nlmsghdr *nlh, ...@@ -2430,13 +2434,14 @@ static int rtnl_bridge_setlink(struct sk_buff *skb, struct nlmsghdr *nlh,
oflags = flags; oflags = flags;
if (!flags || (flags & BRIDGE_FLAGS_MASTER)) { if (!flags || (flags & BRIDGE_FLAGS_MASTER)) {
if (!dev->master || struct net_device *br_dev = netdev_master_upper_dev_get(dev);
!dev->master->netdev_ops->ndo_bridge_setlink) {
if (!br_dev || !br_dev->netdev_ops->ndo_bridge_setlink) {
err = -EOPNOTSUPP; err = -EOPNOTSUPP;
goto out; goto out;
} }
err = dev->master->netdev_ops->ndo_bridge_setlink(dev, nlh); err = br_dev->netdev_ops->ndo_bridge_setlink(dev, nlh);
if (err) if (err)
goto out; goto out;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment