On 9/15/2020 12:33 AM, Jakub Kicinski wrote:
External email: Use caution opening links or attachments


On Mon, 14 Sep 2020 09:07:48 +0300 Moshe Shemesh wrote:
@@ -3011,12 +3060,41 @@ static int devlink_nl_cmd_reload(struct sk_buff *skb, 
struct genl_info *info)
                       return PTR_ERR(dest_net);
       }

-     err = devlink_reload(devlink, dest_net, info->extack);
+     if (info->attrs[DEVLINK_ATTR_RELOAD_ACTION])
+             action = nla_get_u8(info->attrs[DEVLINK_ATTR_RELOAD_ACTION]);
+     else
+             action = DEVLINK_RELOAD_ACTION_DRIVER_REINIT;
+
+     if (action == DEVLINK_RELOAD_ACTION_UNSPEC || action > 
DEVLINK_RELOAD_ACTION_MAX) {
+             NL_SET_ERR_MSG_MOD(info->extack, "Invalid reload action");
+             return -EINVAL;
+     } else if (!devlink_reload_action_is_supported(devlink, action)) {
+             NL_SET_ERR_MSG_MOD(info->extack, "Requested reload action is not 
supported");
+             return -EOPNOTSUPP;
+     }
+
+     err = devlink_reload(devlink, dest_net, action, info->extack, 
&actions_performed);

       if (dest_net)
               put_net(dest_net);

-     return err;
+     if (err)
+             return err;
+
+     WARN_ON(!actions_performed);
+     msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
+     if (!msg)
+             return -ENOMEM;
+
+     err = devlink_nl_reload_actions_performed_fill(msg, devlink, 
actions_performed,
+                                                    DEVLINK_CMD_RELOAD, 
info->snd_portid,
+                                                    info->snd_seq, 0);
+     if (err) {
+             nlmsg_free(msg);
+             return err;
+     }
+
+     return genlmsg_reply(msg, info);
I think generating the reply may break existing users. Only generate
the reply if request contained DEVLINK_ATTR_RELOAD_ACTION (or any other
new attribute which existing users can't pass).


OK, I can do that. But I update stats and generate devlink notification anyway, that should fine, right ?

Reply via email to