RDMA/netlink: Convert LS to doit callback
RDMA_NL_LS protocol is actually does not dump anything, but sets data and it should be handled by doit callback. This patch actually converts RDMA_NL_LS to doit callback, while preserving IWCM and RDMA_CM flows through netlink_dump_start(). Signed-off-by: Leon Romanovsky <leonro@mellanox.com> Reviewed-by: Steve Wise <swise@opengridcomputing.com>
This commit is contained in:
parent
c729943a77
commit
647c75ac59
@ -129,10 +129,9 @@ static void ib_nl_process_good_ip_rsep(const struct nlmsghdr *nlh)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int ib_nl_handle_ip_res_resp(struct sk_buff *skb,
|
int ib_nl_handle_ip_res_resp(struct sk_buff *skb,
|
||||||
struct netlink_callback *cb)
|
struct nlmsghdr *nlh,
|
||||||
|
struct netlink_ext_ack *extack)
|
||||||
{
|
{
|
||||||
const struct nlmsghdr *nlh = (struct nlmsghdr *)cb->nlh;
|
|
||||||
|
|
||||||
if ((nlh->nlmsg_flags & NLM_F_REQUEST) ||
|
if ((nlh->nlmsg_flags & NLM_F_REQUEST) ||
|
||||||
!(NETLINK_CB(skb).sk))
|
!(NETLINK_CB(skb).sk))
|
||||||
return -EPERM;
|
return -EPERM;
|
||||||
|
@ -198,11 +198,14 @@ void rdma_nl_exit(void);
|
|||||||
int ibnl_chk_listeners(unsigned int group);
|
int ibnl_chk_listeners(unsigned int group);
|
||||||
|
|
||||||
int ib_nl_handle_resolve_resp(struct sk_buff *skb,
|
int ib_nl_handle_resolve_resp(struct sk_buff *skb,
|
||||||
struct netlink_callback *cb);
|
struct nlmsghdr *nlh,
|
||||||
|
struct netlink_ext_ack *extack);
|
||||||
int ib_nl_handle_set_timeout(struct sk_buff *skb,
|
int ib_nl_handle_set_timeout(struct sk_buff *skb,
|
||||||
struct netlink_callback *cb);
|
struct nlmsghdr *nlh,
|
||||||
|
struct netlink_ext_ack *extack);
|
||||||
int ib_nl_handle_ip_res_resp(struct sk_buff *skb,
|
int ib_nl_handle_ip_res_resp(struct sk_buff *skb,
|
||||||
struct netlink_callback *cb);
|
struct nlmsghdr *nlh,
|
||||||
|
struct netlink_ext_ack *extack);
|
||||||
|
|
||||||
int ib_get_cached_subnet_prefix(struct ib_device *device,
|
int ib_get_cached_subnet_prefix(struct ib_device *device,
|
||||||
u8 port_num,
|
u8 port_num,
|
||||||
|
@ -1148,15 +1148,15 @@ EXPORT_SYMBOL(ib_get_net_dev_by_params);
|
|||||||
|
|
||||||
static const struct rdma_nl_cbs ibnl_ls_cb_table[] = {
|
static const struct rdma_nl_cbs ibnl_ls_cb_table[] = {
|
||||||
[RDMA_NL_LS_OP_RESOLVE] = {
|
[RDMA_NL_LS_OP_RESOLVE] = {
|
||||||
.dump = ib_nl_handle_resolve_resp,
|
.doit = ib_nl_handle_resolve_resp,
|
||||||
.flags = RDMA_NL_ADMIN_PERM,
|
.flags = RDMA_NL_ADMIN_PERM,
|
||||||
},
|
},
|
||||||
[RDMA_NL_LS_OP_SET_TIMEOUT] = {
|
[RDMA_NL_LS_OP_SET_TIMEOUT] = {
|
||||||
.dump = ib_nl_handle_set_timeout,
|
.doit = ib_nl_handle_set_timeout,
|
||||||
.flags = RDMA_NL_ADMIN_PERM,
|
.flags = RDMA_NL_ADMIN_PERM,
|
||||||
},
|
},
|
||||||
[RDMA_NL_LS_OP_IP_RESOLVE] = {
|
[RDMA_NL_LS_OP_IP_RESOLVE] = {
|
||||||
.dump = ib_nl_handle_ip_res_resp,
|
.doit = ib_nl_handle_ip_res_resp,
|
||||||
.flags = RDMA_NL_ADMIN_PERM,
|
.flags = RDMA_NL_ADMIN_PERM,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -153,38 +153,30 @@ static int rdma_nl_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh,
|
|||||||
int type = nlh->nlmsg_type;
|
int type = nlh->nlmsg_type;
|
||||||
unsigned int index = RDMA_NL_GET_CLIENT(type);
|
unsigned int index = RDMA_NL_GET_CLIENT(type);
|
||||||
unsigned int op = RDMA_NL_GET_OP(type);
|
unsigned int op = RDMA_NL_GET_OP(type);
|
||||||
struct netlink_callback cb = {};
|
|
||||||
struct netlink_dump_control c = {};
|
|
||||||
const struct rdma_nl_cbs *cb_table;
|
const struct rdma_nl_cbs *cb_table;
|
||||||
int ret;
|
|
||||||
|
|
||||||
if (!is_nl_valid(index, op))
|
if (!is_nl_valid(index, op))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
cb_table = rdma_nl_types[type].cb_table;
|
cb_table = rdma_nl_types[index].cb_table;
|
||||||
|
|
||||||
if ((cb_table[op].flags & RDMA_NL_ADMIN_PERM) &&
|
if ((cb_table[op].flags & RDMA_NL_ADMIN_PERM) &&
|
||||||
!netlink_capable(skb, CAP_NET_ADMIN))
|
!netlink_capable(skb, CAP_NET_ADMIN))
|
||||||
return -EPERM;
|
return -EPERM;
|
||||||
|
|
||||||
/*
|
/* FIXME: Convert IWCM to properly handle doit callbacks */
|
||||||
* For response or local service set_timeout request,
|
if ((nlh->nlmsg_flags & NLM_F_DUMP) || index == RDMA_NL_RDMA_CM ||
|
||||||
* there is no need to use netlink_dump_start.
|
index == RDMA_NL_IWCM) {
|
||||||
*/
|
struct netlink_dump_control c = {
|
||||||
if (!(nlh->nlmsg_flags & NLM_F_REQUEST) ||
|
.dump = cb_table[op].dump,
|
||||||
(index == RDMA_NL_LS && op == RDMA_NL_LS_OP_SET_TIMEOUT)) {
|
};
|
||||||
cb.skb = skb;
|
|
||||||
cb.nlh = nlh;
|
|
||||||
cb.dump = cb_table[op].dump;
|
|
||||||
return cb.dump(skb, &cb);
|
|
||||||
} else {
|
|
||||||
c.dump = cb_table[op].dump;
|
|
||||||
return netlink_dump_start(nls, skb, nlh, &c);
|
return netlink_dump_start(nls, skb, nlh, &c);
|
||||||
}
|
}
|
||||||
if (cb_table[op].doit)
|
|
||||||
ret = cb_table[op].doit(skb, nlh, extack);
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
|
if (cb_table[op].doit)
|
||||||
|
return cb_table[op].doit(skb, nlh, extack);
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1021,9 +1021,9 @@ static void ib_nl_request_timeout(struct work_struct *work)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int ib_nl_handle_set_timeout(struct sk_buff *skb,
|
int ib_nl_handle_set_timeout(struct sk_buff *skb,
|
||||||
struct netlink_callback *cb)
|
struct nlmsghdr *nlh,
|
||||||
|
struct netlink_ext_ack *extack)
|
||||||
{
|
{
|
||||||
const struct nlmsghdr *nlh = (struct nlmsghdr *)cb->nlh;
|
|
||||||
int timeout, delta, abs_delta;
|
int timeout, delta, abs_delta;
|
||||||
const struct nlattr *attr;
|
const struct nlattr *attr;
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
@ -1097,9 +1097,9 @@ static inline int ib_nl_is_good_resolve_resp(const struct nlmsghdr *nlh)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int ib_nl_handle_resolve_resp(struct sk_buff *skb,
|
int ib_nl_handle_resolve_resp(struct sk_buff *skb,
|
||||||
struct netlink_callback *cb)
|
struct nlmsghdr *nlh,
|
||||||
|
struct netlink_ext_ack *extack)
|
||||||
{
|
{
|
||||||
const struct nlmsghdr *nlh = (struct nlmsghdr *)cb->nlh;
|
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
struct ib_sa_query *query;
|
struct ib_sa_query *query;
|
||||||
struct ib_mad_send_buf *send_buf;
|
struct ib_mad_send_buf *send_buf;
|
||||||
|
Loading…
Reference in New Issue
Block a user