Skip to content

Commit 647c75a

Browse files
Leon Romanovskyrleon
Leon Romanovsky
authored andcommitted
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 <[email protected]> Reviewed-by: Steve Wise <[email protected]>
1 parent c729943 commit 647c75a

File tree

5 files changed

+25
-31
lines changed

5 files changed

+25
-31
lines changed

drivers/infiniband/core/addr.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,9 @@ static void ib_nl_process_good_ip_rsep(const struct nlmsghdr *nlh)
129129
}
130130

131131
int ib_nl_handle_ip_res_resp(struct sk_buff *skb,
132-
struct netlink_callback *cb)
132+
struct nlmsghdr *nlh,
133+
struct netlink_ext_ack *extack)
133134
{
134-
const struct nlmsghdr *nlh = (struct nlmsghdr *)cb->nlh;
135-
136135
if ((nlh->nlmsg_flags & NLM_F_REQUEST) ||
137136
!(NETLINK_CB(skb).sk))
138137
return -EPERM;

drivers/infiniband/core/core_priv.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,11 +198,14 @@ void rdma_nl_exit(void);
198198
int ibnl_chk_listeners(unsigned int group);
199199

200200
int ib_nl_handle_resolve_resp(struct sk_buff *skb,
201-
struct netlink_callback *cb);
201+
struct nlmsghdr *nlh,
202+
struct netlink_ext_ack *extack);
202203
int ib_nl_handle_set_timeout(struct sk_buff *skb,
203-
struct netlink_callback *cb);
204+
struct nlmsghdr *nlh,
205+
struct netlink_ext_ack *extack);
204206
int ib_nl_handle_ip_res_resp(struct sk_buff *skb,
205-
struct netlink_callback *cb);
207+
struct nlmsghdr *nlh,
208+
struct netlink_ext_ack *extack);
206209

207210
int ib_get_cached_subnet_prefix(struct ib_device *device,
208211
u8 port_num,

drivers/infiniband/core/device.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1148,15 +1148,15 @@ EXPORT_SYMBOL(ib_get_net_dev_by_params);
11481148

11491149
static const struct rdma_nl_cbs ibnl_ls_cb_table[] = {
11501150
[RDMA_NL_LS_OP_RESOLVE] = {
1151-
.dump = ib_nl_handle_resolve_resp,
1151+
.doit = ib_nl_handle_resolve_resp,
11521152
.flags = RDMA_NL_ADMIN_PERM,
11531153
},
11541154
[RDMA_NL_LS_OP_SET_TIMEOUT] = {
1155-
.dump = ib_nl_handle_set_timeout,
1155+
.doit = ib_nl_handle_set_timeout,
11561156
.flags = RDMA_NL_ADMIN_PERM,
11571157
},
11581158
[RDMA_NL_LS_OP_IP_RESOLVE] = {
1159-
.dump = ib_nl_handle_ip_res_resp,
1159+
.doit = ib_nl_handle_ip_res_resp,
11601160
.flags = RDMA_NL_ADMIN_PERM,
11611161
},
11621162
};

drivers/infiniband/core/netlink.c

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -153,38 +153,30 @@ static int rdma_nl_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh,
153153
int type = nlh->nlmsg_type;
154154
unsigned int index = RDMA_NL_GET_CLIENT(type);
155155
unsigned int op = RDMA_NL_GET_OP(type);
156-
struct netlink_callback cb = {};
157-
struct netlink_dump_control c = {};
158156
const struct rdma_nl_cbs *cb_table;
159-
int ret;
160157

161158
if (!is_nl_valid(index, op))
162159
return -EINVAL;
163160

164-
cb_table = rdma_nl_types[type].cb_table;
161+
cb_table = rdma_nl_types[index].cb_table;
165162

166163
if ((cb_table[op].flags & RDMA_NL_ADMIN_PERM) &&
167164
!netlink_capable(skb, CAP_NET_ADMIN))
168165
return -EPERM;
169166

170-
/*
171-
* For response or local service set_timeout request,
172-
* there is no need to use netlink_dump_start.
173-
*/
174-
if (!(nlh->nlmsg_flags & NLM_F_REQUEST) ||
175-
(index == RDMA_NL_LS && op == RDMA_NL_LS_OP_SET_TIMEOUT)) {
176-
cb.skb = skb;
177-
cb.nlh = nlh;
178-
cb.dump = cb_table[op].dump;
179-
return cb.dump(skb, &cb);
180-
} else {
181-
c.dump = cb_table[op].dump;
167+
/* FIXME: Convert IWCM to properly handle doit callbacks */
168+
if ((nlh->nlmsg_flags & NLM_F_DUMP) || index == RDMA_NL_RDMA_CM ||
169+
index == RDMA_NL_IWCM) {
170+
struct netlink_dump_control c = {
171+
.dump = cb_table[op].dump,
172+
};
182173
return netlink_dump_start(nls, skb, nlh, &c);
183174
}
175+
184176
if (cb_table[op].doit)
185-
ret = cb_table[op].doit(skb, nlh, extack);
186-
return ret;
177+
return cb_table[op].doit(skb, nlh, extack);
187178

179+
return 0;
188180
}
189181

190182
/*

drivers/infiniband/core/sa_query.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1021,9 +1021,9 @@ static void ib_nl_request_timeout(struct work_struct *work)
10211021
}
10221022

10231023
int ib_nl_handle_set_timeout(struct sk_buff *skb,
1024-
struct netlink_callback *cb)
1024+
struct nlmsghdr *nlh,
1025+
struct netlink_ext_ack *extack)
10251026
{
1026-
const struct nlmsghdr *nlh = (struct nlmsghdr *)cb->nlh;
10271027
int timeout, delta, abs_delta;
10281028
const struct nlattr *attr;
10291029
unsigned long flags;
@@ -1097,9 +1097,9 @@ static inline int ib_nl_is_good_resolve_resp(const struct nlmsghdr *nlh)
10971097
}
10981098

10991099
int ib_nl_handle_resolve_resp(struct sk_buff *skb,
1100-
struct netlink_callback *cb)
1100+
struct nlmsghdr *nlh,
1101+
struct netlink_ext_ack *extack)
11011102
{
1102-
const struct nlmsghdr *nlh = (struct nlmsghdr *)cb->nlh;
11031103
unsigned long flags;
11041104
struct ib_sa_query *query;
11051105
struct ib_mad_send_buf *send_buf;

0 commit comments

Comments
 (0)