1 // SPDX-License-Identifier: GPL-2.0
4 #include <linux/netdevice.h>
5 #include <net/rtnetlink.h>
10 static const struct nla_policy dsa_policy[IFLA_DSA_MAX + 1] = {
11 [IFLA_DSA_MASTER] = { .type = NLA_U32 },
14 static int dsa_changelink(struct net_device *dev, struct nlattr *tb[],
15 struct nlattr *data[],
16 struct netlink_ext_ack *extack)
23 if (data[IFLA_DSA_MASTER]) {
24 u32 ifindex = nla_get_u32(data[IFLA_DSA_MASTER]);
25 struct net_device *master;
27 master = __dev_get_by_index(dev_net(dev), ifindex);
31 err = dsa_slave_change_master(dev, master, extack);
39 static size_t dsa_get_size(const struct net_device *dev)
41 return nla_total_size(sizeof(u32)) + /* IFLA_DSA_MASTER */
45 static int dsa_fill_info(struct sk_buff *skb, const struct net_device *dev)
47 struct net_device *master = dsa_slave_to_master(dev);
49 if (nla_put_u32(skb, IFLA_DSA_MASTER, master->ifindex))
55 struct rtnl_link_ops dsa_link_ops __read_mostly = {
57 .priv_size = sizeof(struct dsa_port),
58 .maxtype = IFLA_DSA_MAX,
60 .changelink = dsa_changelink,
61 .get_size = dsa_get_size,
62 .fill_info = dsa_fill_info,