genetlink: pass extended ACK report down
authorJohannes Berg <johannes.berg@intel.com>
Wed, 12 Apr 2017 12:34:05 +0000 (14:34 +0200)
committerDavid S. Miller <davem@davemloft.net>
Thu, 13 Apr 2017 17:58:21 +0000 (13:58 -0400)
Pass the extended ACK reporting struct down from generic netlink to
the families, using the existing struct genl_info for simplicity.

Also add support to set the extended ACK information from generic
netlink users.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Reviewed-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/genetlink.h
net/netlink/genetlink.c

index a34275be360001e89740fe4325a53905683e9778..f18db6570f52f4771164de6564788d856f169842 100644 (file)
@@ -84,6 +84,7 @@ struct nlattr **genl_family_attrbuf(const struct genl_family *family);
  * @attrs: netlink attributes
  * @_net: network namespace
  * @user_ptr: user pointers
+ * @extack: extended ACK report struct
  */
 struct genl_info {
        u32                     snd_seq;
@@ -94,6 +95,7 @@ struct genl_info {
        struct nlattr **        attrs;
        possible_net_t          _net;
        void *                  user_ptr[2];
+       struct netlink_ext_ack *extack;
 };
 
 static inline struct net *genl_info_net(struct genl_info *info)
@@ -106,6 +108,16 @@ static inline void genl_info_net_set(struct genl_info *info, struct net *net)
        write_pnet(&info->_net, net);
 }
 
+#define GENL_SET_ERR_MSG(info, msg) NL_SET_ERR_MSG((info)->extack, msg)
+
+static inline int genl_err_attr(struct genl_info *info, int err,
+                               struct nlattr *attr)
+{
+       info->extack->bad_attr = attr;
+
+       return err;
+}
+
 /**
  * struct genl_ops - generic netlink operations
  * @cmd: command identifier
index 57b2e3648bc02b6c39b2e56705c52d6c96885ee2..4b598a5999a214200242863105139e2df2b67d86 100644 (file)
@@ -497,7 +497,8 @@ static int genl_lock_done(struct netlink_callback *cb)
 
 static int genl_family_rcv_msg(const struct genl_family *family,
                               struct sk_buff *skb,
-                              struct nlmsghdr *nlh)
+                              struct nlmsghdr *nlh,
+                              struct netlink_ext_ack *extack)
 {
        const struct genl_ops *ops;
        struct net *net = sock_net(skb->sk);
@@ -584,6 +585,7 @@ static int genl_family_rcv_msg(const struct genl_family *family,
        info.genlhdr = nlmsg_data(nlh);
        info.userhdr = nlmsg_data(nlh) + GENL_HDRLEN;
        info.attrs = attrbuf;
+       info.extack = extack;
        genl_info_net_set(&info, net);
        memset(&info.user_ptr, 0, sizeof(info.user_ptr));
 
@@ -618,7 +620,7 @@ static int genl_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh,
        if (!family->parallel_ops)
                genl_lock();
 
-       err = genl_family_rcv_msg(family, skb, nlh);
+       err = genl_family_rcv_msg(family, skb, nlh, extack);
 
        if (!family->parallel_ops)
                genl_unlock();