aboutsummaryrefslogtreecommitdiffstats
path: root/net/netlink/af_netlink.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/netlink/af_netlink.c')
-rw-r--r--net/netlink/af_netlink.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index 94c11cf0459d..b93148e8e9fb 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -2266,16 +2266,17 @@ int __netlink_dump_start(struct sock *ssk, struct sk_buff *skb,
2266 cb->min_dump_alloc = control->min_dump_alloc; 2266 cb->min_dump_alloc = control->min_dump_alloc;
2267 cb->skb = skb; 2267 cb->skb = skb;
2268 2268
2269 if (cb->start) {
2270 ret = cb->start(cb);
2271 if (ret)
2272 goto error_unlock;
2273 }
2274
2269 nlk->cb_running = true; 2275 nlk->cb_running = true;
2270 2276
2271 mutex_unlock(nlk->cb_mutex); 2277 mutex_unlock(nlk->cb_mutex);
2272 2278
2273 ret = 0; 2279 ret = netlink_dump(sk);
2274 if (cb->start)
2275 ret = cb->start(cb);
2276
2277 if (!ret)
2278 ret = netlink_dump(sk);
2279 2280
2280 sock_put(sk); 2281 sock_put(sk);
2281 2282
@@ -2306,6 +2307,7 @@ void netlink_ack(struct sk_buff *in_skb, struct nlmsghdr *nlh, int err,
2306 size_t tlvlen = 0; 2307 size_t tlvlen = 0;
2307 struct netlink_sock *nlk = nlk_sk(NETLINK_CB(in_skb).sk); 2308 struct netlink_sock *nlk = nlk_sk(NETLINK_CB(in_skb).sk);
2308 unsigned int flags = 0; 2309 unsigned int flags = 0;
2310 bool nlk_has_extack = nlk->flags & NETLINK_F_EXT_ACK;
2309 2311
2310 /* Error messages get the original request appened, unless the user 2312 /* Error messages get the original request appened, unless the user
2311 * requests to cap the error message, and get extra error data if 2313 * requests to cap the error message, and get extra error data if
@@ -2316,7 +2318,7 @@ void netlink_ack(struct sk_buff *in_skb, struct nlmsghdr *nlh, int err,
2316 payload += nlmsg_len(nlh); 2318 payload += nlmsg_len(nlh);
2317 else 2319 else
2318 flags |= NLM_F_CAPPED; 2320 flags |= NLM_F_CAPPED;
2319 if (nlk->flags & NETLINK_F_EXT_ACK && extack) { 2321 if (nlk_has_extack && extack) {
2320 if (extack->_msg) 2322 if (extack->_msg)
2321 tlvlen += nla_total_size(strlen(extack->_msg) + 1); 2323 tlvlen += nla_total_size(strlen(extack->_msg) + 1);
2322 if (extack->bad_attr) 2324 if (extack->bad_attr)
@@ -2325,8 +2327,7 @@ void netlink_ack(struct sk_buff *in_skb, struct nlmsghdr *nlh, int err,
2325 } else { 2327 } else {
2326 flags |= NLM_F_CAPPED; 2328 flags |= NLM_F_CAPPED;
2327 2329
2328 if (nlk->flags & NETLINK_F_EXT_ACK && 2330 if (nlk_has_extack && extack && extack->cookie_len)
2329 extack && extack->cookie_len)
2330 tlvlen += nla_total_size(extack->cookie_len); 2331 tlvlen += nla_total_size(extack->cookie_len);
2331 } 2332 }
2332 2333
@@ -2354,7 +2355,7 @@ void netlink_ack(struct sk_buff *in_skb, struct nlmsghdr *nlh, int err,
2354 errmsg->error = err; 2355 errmsg->error = err;
2355 memcpy(&errmsg->msg, nlh, payload > sizeof(*errmsg) ? nlh->nlmsg_len : sizeof(*nlh)); 2356 memcpy(&errmsg->msg, nlh, payload > sizeof(*errmsg) ? nlh->nlmsg_len : sizeof(*nlh));
2356 2357
2357 if (nlk->flags & NETLINK_F_EXT_ACK && extack) { 2358 if (nlk_has_extack && extack) {
2358 if (err) { 2359 if (err) {
2359 if (extack->_msg) 2360 if (extack->_msg)
2360 WARN_ON(nla_put_string(skb, NLMSGERR_ATTR_MSG, 2361 WARN_ON(nla_put_string(skb, NLMSGERR_ATTR_MSG,