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_CONDUIT
] = { .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_CONDUIT
]) {
24 u32 ifindex
= nla_get_u32(data
[IFLA_DSA_CONDUIT
]);
25 struct net_device
*conduit
;
27 conduit
= __dev_get_by_index(dev_net(dev
), ifindex
);
31 err
= dsa_user_change_conduit(dev
, conduit
, extack
);
39 static size_t dsa_get_size(const struct net_device
*dev
)
41 return nla_total_size(sizeof(u32
)) + /* IFLA_DSA_CONDUIT */
45 static int dsa_fill_info(struct sk_buff
*skb
, const struct net_device
*dev
)
47 struct net_device
*conduit
= dsa_user_to_conduit(dev
);
49 if (nla_put_u32(skb
, IFLA_DSA_CONDUIT
, conduit
->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
,