Skip to content

Commit

Permalink
net: tipc: have genetlink code to parse the attrs during dumpit
Browse files Browse the repository at this point in the history
Benefit from the fact that the generic netlink code can parse the attrs
for dumpit op and avoid need to parse it in the op callback.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Jiri Pirko authored and David S. Miller committed Oct 6, 2019
1 parent 4495af3 commit 057af70
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 18 deletions.
9 changes: 6 additions & 3 deletions net/tipc/netlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,8 @@ static const struct genl_ops tipc_genl_v2_ops[] = {
},
{
.cmd = TIPC_NL_PUBL_GET,
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
.validate = GENL_DONT_VALIDATE_STRICT |
GENL_DONT_VALIDATE_DUMP_STRICT,
.dumpit = tipc_nl_publ_dump,
},
{
Expand Down Expand Up @@ -239,7 +240,8 @@ static const struct genl_ops tipc_genl_v2_ops[] = {
},
{
.cmd = TIPC_NL_MON_PEER_GET,
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
.validate = GENL_DONT_VALIDATE_STRICT |
GENL_DONT_VALIDATE_DUMP_STRICT,
.dumpit = tipc_nl_node_dump_monitor_peer,
},
{
Expand All @@ -250,7 +252,8 @@ static const struct genl_ops tipc_genl_v2_ops[] = {
#ifdef CONFIG_TIPC_MEDIA_UDP
{
.cmd = TIPC_NL_UDP_GET_REMOTEIP,
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
.validate = GENL_DONT_VALIDATE_STRICT |
GENL_DONT_VALIDATE_DUMP_STRICT,
.dumpit = tipc_udp_nl_dump_remoteip,
},
#endif
Expand Down
6 changes: 1 addition & 5 deletions net/tipc/node.c
Original file line number Diff line number Diff line change
Expand Up @@ -2484,13 +2484,9 @@ int tipc_nl_node_dump_monitor_peer(struct sk_buff *skb,
int err;

if (!prev_node) {
struct nlattr **attrs;
struct nlattr **attrs = genl_dumpit_info(cb)->attrs;
struct nlattr *mon[TIPC_NLA_MON_MAX + 1];

err = tipc_nlmsg_parse(cb->nlh, &attrs);
if (err)
return err;

if (!attrs[TIPC_NLA_MON])
return -EINVAL;

Expand Down
6 changes: 1 addition & 5 deletions net/tipc/socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -3588,13 +3588,9 @@ int tipc_nl_publ_dump(struct sk_buff *skb, struct netlink_callback *cb)
struct tipc_sock *tsk;

if (!tsk_portid) {
struct nlattr **attrs;
struct nlattr **attrs = genl_dumpit_info(cb)->attrs;
struct nlattr *sock[TIPC_NLA_SOCK_MAX + 1];

err = tipc_nlmsg_parse(cb->nlh, &attrs);
if (err)
return err;

if (!attrs[TIPC_NLA_SOCK])
return -EINVAL;

Expand Down
6 changes: 1 addition & 5 deletions net/tipc/udp_media.c
Original file line number Diff line number Diff line change
Expand Up @@ -448,15 +448,11 @@ int tipc_udp_nl_dump_remoteip(struct sk_buff *skb, struct netlink_callback *cb)
int i;

if (!bid && !skip_cnt) {
struct nlattr **attrs = genl_dumpit_info(cb)->attrs;
struct net *net = sock_net(skb->sk);
struct nlattr *battrs[TIPC_NLA_BEARER_MAX + 1];
struct nlattr **attrs;
char *bname;

err = tipc_nlmsg_parse(cb->nlh, &attrs);
if (err)
return err;

if (!attrs[TIPC_NLA_BEARER])
return -EINVAL;

Expand Down

0 comments on commit 057af70

Please sign in to comment.