Skip to content

Commit 3bad540

Browse files
jpirkodavem330
authored andcommitted
bonding: convert netlink to use slave data info api
Signed-off-by: Jiri Pirko <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent ba7d49b commit 3bad540

File tree

4 files changed

+19
-55
lines changed

4 files changed

+19
-55
lines changed

drivers/net/bonding/bond_main.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3824,7 +3824,6 @@ static const struct net_device_ops bond_netdev_ops = {
38243824
#endif
38253825
.ndo_add_slave = bond_enslave,
38263826
.ndo_del_slave = bond_release,
3827-
.ndo_get_slave = bond_get_slave,
38283827
.ndo_fix_features = bond_fix_features,
38293828
};
38303829

drivers/net/bonding/bond_netlink.c

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,23 @@
2121
#include <net/rtnetlink.h>
2222
#include "bonding.h"
2323

24-
int bond_get_slave(struct net_device *slave_dev, struct sk_buff *skb)
24+
static size_t bond_get_slave_size(const struct net_device *bond_dev,
25+
const struct net_device *slave_dev)
26+
{
27+
return nla_total_size(sizeof(u8)) + /* IFLA_BOND_SLAVE_STATE */
28+
nla_total_size(sizeof(u8)) + /* IFLA_BOND_SLAVE_MII_STATUS */
29+
nla_total_size(sizeof(u32)) + /* IFLA_BOND_SLAVE_LINK_FAILURE_COUNT */
30+
nla_total_size(MAX_ADDR_LEN) + /* IFLA_BOND_SLAVE_PERM_HWADDR */
31+
nla_total_size(sizeof(u16)) + /* IFLA_BOND_SLAVE_QUEUE_ID */
32+
nla_total_size(sizeof(u16)) + /* IFLA_BOND_SLAVE_AD_AGGREGATOR_ID */
33+
0;
34+
}
35+
36+
static int bond_fill_slave_info(struct sk_buff *skb,
37+
const struct net_device *bond_dev,
38+
const struct net_device *slave_dev)
2539
{
2640
struct slave *slave = bond_slave_get_rtnl(slave_dev);
27-
const struct aggregator *agg;
2841

2942
if (nla_put_u8(skb, IFLA_BOND_SLAVE_STATE, bond_slave_state(slave)))
3043
goto nla_put_failure;
@@ -44,6 +57,8 @@ int bond_get_slave(struct net_device *slave_dev, struct sk_buff *skb)
4457
goto nla_put_failure;
4558

4659
if (slave->bond->params.mode == BOND_MODE_8023AD) {
60+
const struct aggregator *agg;
61+
4762
agg = SLAVE_AD_INFO(slave).port.aggregator;
4863
if (agg)
4964
if (nla_put_u16(skb, IFLA_BOND_SLAVE_AD_AGGREGATOR_ID,
@@ -541,6 +556,8 @@ struct rtnl_link_ops bond_link_ops __read_mostly = {
541556
.get_num_tx_queues = bond_get_num_tx_queues,
542557
.get_num_rx_queues = bond_get_num_tx_queues, /* Use the same number
543558
as for TX queues */
559+
.get_slave_size = bond_get_slave_size,
560+
.fill_slave_info = bond_fill_slave_info,
544561
};
545562

546563
int __init bond_netlink_init(void)

drivers/net/bonding/bonding.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,6 @@ int bond_sysfs_slave_add(struct slave *slave);
436436
void bond_sysfs_slave_del(struct slave *slave);
437437
int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev);
438438
int bond_release(struct net_device *bond_dev, struct net_device *slave_dev);
439-
int bond_get_slave(struct net_device *slave_dev, struct sk_buff *skb);
440439
int bond_xmit_hash(struct bonding *bond, struct sk_buff *skb, int count);
441440
int bond_parse_parm(const char *mode_arg, const struct bond_parm_tbl *tbl);
442441
int bond_parm_tbl_lookup(int mode, const struct bond_parm_tbl *tbl);

net/core/rtnetlink.c

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -800,28 +800,6 @@ static size_t rtnl_port_size(const struct net_device *dev)
800800
return port_self_size;
801801
}
802802

803-
static size_t rtnl_bond_slave_size(const struct net_device *dev)
804-
{
805-
struct net_device *bond;
806-
size_t slave_size =
807-
nla_total_size(sizeof(struct nlattr)) + /* IFLA_BOND_SLAVE */
808-
nla_total_size(1) + /* IFLA_BOND_SLAVE_STATE */
809-
nla_total_size(1) + /* IFLA_BOND_SLAVE_MII_STATUS */
810-
nla_total_size(4) + /* IFLA_BOND_SLAVE_LINK_FAILURE_COUNT */
811-
nla_total_size(MAX_ADDR_LEN) + /* IFLA_BOND_SLAVE_PERM_HWADDR */
812-
nla_total_size(2) + /* IFLA_BOND_SLAVE_QUEUE_ID */
813-
nla_total_size(2) + /* IFLA_BOND_SLAVE_AD_AGGREGATOR_ID */
814-
0;
815-
816-
if (netif_is_bond_slave((struct net_device *)dev)) {
817-
bond = netdev_master_upper_dev_get((struct net_device *)dev);
818-
if (bond && bond->netdev_ops->ndo_get_slave)
819-
return slave_size;
820-
}
821-
822-
return 0;
823-
}
824-
825803
static noinline size_t if_nlmsg_size(const struct net_device *dev,
826804
u32 ext_filter_mask)
827805
{
@@ -851,7 +829,6 @@ static noinline size_t if_nlmsg_size(const struct net_device *dev,
851829
+ rtnl_port_size(dev) /* IFLA_VF_PORTS + IFLA_PORT_SELF */
852830
+ rtnl_link_get_size(dev) /* IFLA_LINKINFO */
853831
+ rtnl_link_get_af_size(dev) /* IFLA_AF_SPEC */
854-
+ rtnl_bond_slave_size(dev) /* IFLA_SLAVE */
855832
+ nla_total_size(MAX_PHYS_PORT_ID_LEN); /* IFLA_PHYS_PORT_ID */
856833
}
857834

@@ -949,34 +926,6 @@ static int rtnl_phys_port_id_fill(struct sk_buff *skb, struct net_device *dev)
949926
return 0;
950927
}
951928

952-
static size_t rtnl_bond_slave_fill(struct sk_buff *skb, struct net_device *dev)
953-
{
954-
struct net_device *bond;
955-
struct nlattr *nest;
956-
int err;
957-
958-
if (!netif_is_bond_slave(dev))
959-
return 0;
960-
961-
bond = netdev_master_upper_dev_get(dev);
962-
if (!bond || !bond->netdev_ops->ndo_get_slave)
963-
return 0;
964-
965-
nest = nla_nest_start(skb, IFLA_BOND_SLAVE);
966-
if (!nest)
967-
return -EMSGSIZE;
968-
969-
err = bond->netdev_ops->ndo_get_slave(dev, skb);
970-
if (err) {
971-
nla_nest_cancel(skb, nest);
972-
return (err == -EMSGSIZE) ? err : 0;
973-
}
974-
975-
nla_nest_end(skb, nest);
976-
977-
return 0;
978-
}
979-
980929
static int rtnl_fill_ifinfo(struct sk_buff *skb, struct net_device *dev,
981930
int type, u32 pid, u32 seq, u32 change,
982931
unsigned int flags, u32 ext_filter_mask)

0 commit comments

Comments
 (0)