Skip to content

Commit 7ab606d

Browse files
jmberg-inteldavem330
authored andcommitted
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 <[email protected]> Reviewed-by: Jiri Pirko <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 2d4bc93 commit 7ab606d

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

include/net/genetlink.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ struct nlattr **genl_family_attrbuf(const struct genl_family *family);
8484
* @attrs: netlink attributes
8585
* @_net: network namespace
8686
* @user_ptr: user pointers
87+
* @extack: extended ACK report struct
8788
*/
8889
struct genl_info {
8990
u32 snd_seq;
@@ -94,6 +95,7 @@ struct genl_info {
9495
struct nlattr ** attrs;
9596
possible_net_t _net;
9697
void * user_ptr[2];
98+
struct netlink_ext_ack *extack;
9799
};
98100

99101
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)
106108
write_pnet(&info->_net, net);
107109
}
108110

111+
#define GENL_SET_ERR_MSG(info, msg) NL_SET_ERR_MSG((info)->extack, msg)
112+
113+
static inline int genl_err_attr(struct genl_info *info, int err,
114+
struct nlattr *attr)
115+
{
116+
info->extack->bad_attr = attr;
117+
118+
return err;
119+
}
120+
109121
/**
110122
* struct genl_ops - generic netlink operations
111123
* @cmd: command identifier

net/netlink/genetlink.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,8 @@ static int genl_lock_done(struct netlink_callback *cb)
497497

498498
static int genl_family_rcv_msg(const struct genl_family *family,
499499
struct sk_buff *skb,
500-
struct nlmsghdr *nlh)
500+
struct nlmsghdr *nlh,
501+
struct netlink_ext_ack *extack)
501502
{
502503
const struct genl_ops *ops;
503504
struct net *net = sock_net(skb->sk);
@@ -584,6 +585,7 @@ static int genl_family_rcv_msg(const struct genl_family *family,
584585
info.genlhdr = nlmsg_data(nlh);
585586
info.userhdr = nlmsg_data(nlh) + GENL_HDRLEN;
586587
info.attrs = attrbuf;
588+
info.extack = extack;
587589
genl_info_net_set(&info, net);
588590
memset(&info.user_ptr, 0, sizeof(info.user_ptr));
589591

@@ -618,7 +620,7 @@ static int genl_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh,
618620
if (!family->parallel_ops)
619621
genl_lock();
620622

621-
err = genl_family_rcv_msg(family, skb, nlh);
623+
err = genl_family_rcv_msg(family, skb, nlh, extack);
622624

623625
if (!family->parallel_ops)
624626
genl_unlock();

0 commit comments

Comments
 (0)