Skip to content

Commit 9651009

Browse files
idoschdavem330
authored andcommitted
drop_monitor: Add extack support
Add various extack messages to make drop_monitor more user friendly. Signed-off-by: Ido Schimmel <idosch@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent ff3818c commit 9651009

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

net/core/drop_monitor.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ static void trace_napi_poll_hit(void *ignore, struct napi_struct *napi,
241241
rcu_read_unlock();
242242
}
243243

244-
static int set_all_monitor_traces(int state)
244+
static int set_all_monitor_traces(int state, struct netlink_ext_ack *extack)
245245
{
246246
int rc = 0;
247247
struct dm_hw_stat_delta *new_stat = NULL;
@@ -250,13 +250,15 @@ static int set_all_monitor_traces(int state)
250250
mutex_lock(&net_dm_mutex);
251251

252252
if (state == trace_state) {
253+
NL_SET_ERR_MSG_MOD(extack, "Trace state already set to requested state");
253254
rc = -EAGAIN;
254255
goto out_unlock;
255256
}
256257

257258
switch (state) {
258259
case TRACE_ON:
259260
if (!try_module_get(THIS_MODULE)) {
261+
NL_SET_ERR_MSG_MOD(extack, "Failed to take reference on module");
260262
rc = -ENODEV;
261263
break;
262264
}
@@ -303,6 +305,8 @@ static int set_all_monitor_traces(int state)
303305
static int net_dm_cmd_config(struct sk_buff *skb,
304306
struct genl_info *info)
305307
{
308+
NL_SET_ERR_MSG_MOD(info->extack, "Command not supported");
309+
306310
return -EOPNOTSUPP;
307311
}
308312

@@ -311,9 +315,9 @@ static int net_dm_cmd_trace(struct sk_buff *skb,
311315
{
312316
switch (info->genlhdr->cmd) {
313317
case NET_DM_CMD_START:
314-
return set_all_monitor_traces(TRACE_ON);
318+
return set_all_monitor_traces(TRACE_ON, info->extack);
315319
case NET_DM_CMD_STOP:
316-
return set_all_monitor_traces(TRACE_OFF);
320+
return set_all_monitor_traces(TRACE_OFF, info->extack);
317321
}
318322

319323
return -EOPNOTSUPP;

0 commit comments

Comments
 (0)