Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

genetlink: pass extended ACK report down

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>

authored by

Johannes Berg and committed by
David S. Miller
7ab606d1 2d4bc933

+16 -2
+12
include/net/genetlink.h
··· 84 84 * @attrs: netlink attributes 85 85 * @_net: network namespace 86 86 * @user_ptr: user pointers 87 + * @extack: extended ACK report struct 87 88 */ 88 89 struct genl_info { 89 90 u32 snd_seq; ··· 95 94 struct nlattr ** attrs; 96 95 possible_net_t _net; 97 96 void * user_ptr[2]; 97 + struct netlink_ext_ack *extack; 98 98 }; 99 99 100 100 static inline struct net *genl_info_net(struct genl_info *info) ··· 106 104 static inline void genl_info_net_set(struct genl_info *info, struct net *net) 107 105 { 108 106 write_pnet(&info->_net, net); 107 + } 108 + 109 + #define GENL_SET_ERR_MSG(info, msg) NL_SET_ERR_MSG((info)->extack, msg) 110 + 111 + static inline int genl_err_attr(struct genl_info *info, int err, 112 + struct nlattr *attr) 113 + { 114 + info->extack->bad_attr = attr; 115 + 116 + return err; 109 117 } 110 118 111 119 /**
+4 -2
net/netlink/genetlink.c
··· 497 497 498 498 static int genl_family_rcv_msg(const struct genl_family *family, 499 499 struct sk_buff *skb, 500 - struct nlmsghdr *nlh) 500 + struct nlmsghdr *nlh, 501 + struct netlink_ext_ack *extack) 501 502 { 502 503 const struct genl_ops *ops; 503 504 struct net *net = sock_net(skb->sk); ··· 585 584 info.genlhdr = nlmsg_data(nlh); 586 585 info.userhdr = nlmsg_data(nlh) + GENL_HDRLEN; 587 586 info.attrs = attrbuf; 587 + info.extack = extack; 588 588 genl_info_net_set(&info, net); 589 589 memset(&info.user_ptr, 0, sizeof(info.user_ptr)); 590 590 ··· 620 618 if (!family->parallel_ops) 621 619 genl_lock(); 622 620 623 - err = genl_family_rcv_msg(family, skb, nlh); 621 + err = genl_family_rcv_msg(family, skb, nlh, extack); 624 622 625 623 if (!family->parallel_ops) 626 624 genl_unlock();