hc
2024-01-03 2f7c68cb55ecb7331f2381deb497c27155f32faf
kernel/net/netfilter/nf_conntrack_netlink.c
....@@ -317,11 +317,12 @@
317317 }
318318
319319 #ifdef CONFIG_NF_CONNTRACK_MARK
320
-static int ctnetlink_dump_mark(struct sk_buff *skb, const struct nf_conn *ct)
320
+static int ctnetlink_dump_mark(struct sk_buff *skb, const struct nf_conn *ct,
321
+ bool dump)
321322 {
322323 u32 mark = READ_ONCE(ct->mark);
323324
324
- if (!mark)
325
+ if (!mark && !dump)
325326 return 0;
326327
327328 if (nla_put_be32(skb, CTA_MARK, htonl(mark)))
....@@ -332,7 +333,7 @@
332333 return -1;
333334 }
334335 #else
335
-#define ctnetlink_dump_mark(a, b) (0)
336
+#define ctnetlink_dump_mark(a, b, c) (0)
336337 #endif
337338
338339 #ifdef CONFIG_NF_CONNTRACK_SECMARK
....@@ -537,7 +538,7 @@
537538 static int ctnetlink_dump_info(struct sk_buff *skb, struct nf_conn *ct)
538539 {
539540 if (ctnetlink_dump_status(skb, ct) < 0 ||
540
- ctnetlink_dump_mark(skb, ct) < 0 ||
541
+ ctnetlink_dump_mark(skb, ct, true) < 0 ||
541542 ctnetlink_dump_secctx(skb, ct) < 0 ||
542543 ctnetlink_dump_id(skb, ct) < 0 ||
543544 ctnetlink_dump_use(skb, ct) < 0 ||
....@@ -816,8 +817,7 @@
816817 }
817818
818819 #ifdef CONFIG_NF_CONNTRACK_MARK
819
- if (events & (1 << IPCT_MARK) &&
820
- ctnetlink_dump_mark(skb, ct) < 0)
820
+ if (ctnetlink_dump_mark(skb, ct, events & (1 << IPCT_MARK)))
821821 goto nla_put_failure;
822822 #endif
823823 nlmsg_end(skb, nlh);
....@@ -1493,9 +1493,6 @@
14931493
14941494 static int ctnetlink_flush_iterate(struct nf_conn *ct, void *data)
14951495 {
1496
- if (test_bit(IPS_OFFLOAD_BIT, &ct->status))
1497
- return 0;
1498
-
14991496 return ctnetlink_filter_match(ct, data);
15001497 }
15011498
....@@ -1560,11 +1557,6 @@
15601557 return -ENOENT;
15611558
15621559 ct = nf_ct_tuplehash_to_ctrack(h);
1563
-
1564
- if (test_bit(IPS_OFFLOAD_BIT, &ct->status)) {
1565
- nf_ct_put(ct);
1566
- return -EBUSY;
1567
- }
15681560
15691561 if (cda[CTA_ID]) {
15701562 __be32 id = nla_get_be32(cda[CTA_ID]);
....@@ -2359,12 +2351,15 @@
23592351
23602352 err = nf_conntrack_hash_check_insert(ct);
23612353 if (err < 0)
2362
- goto err2;
2354
+ goto err3;
23632355
23642356 rcu_read_unlock();
23652357
23662358 return ct;
23672359
2360
+err3:
2361
+ if (ct->master)
2362
+ nf_ct_put(ct->master);
23682363 err2:
23692364 rcu_read_unlock();
23702365 err1:
....@@ -2731,7 +2726,7 @@
27312726 goto nla_put_failure;
27322727
27332728 #ifdef CONFIG_NF_CONNTRACK_MARK
2734
- if (ctnetlink_dump_mark(skb, ct) < 0)
2729
+ if (ctnetlink_dump_mark(skb, ct, true) < 0)
27352730 goto nla_put_failure;
27362731 #endif
27372732 if (ctnetlink_dump_labels(skb, ct) < 0)
....@@ -2973,7 +2968,9 @@
29732968 return -1;
29742969 }
29752970
2971
+#if IS_ENABLED(CONFIG_NF_NAT)
29762972 static const union nf_inet_addr any_addr;
2973
+#endif
29772974
29782975 static __be32 nf_expect_get_id(const struct nf_conntrack_expect *exp)
29792976 {
....@@ -3463,10 +3460,12 @@
34633460 return 0;
34643461 }
34653462
3463
+#if IS_ENABLED(CONFIG_NF_NAT)
34663464 static const struct nla_policy exp_nat_nla_policy[CTA_EXPECT_NAT_MAX+1] = {
34673465 [CTA_EXPECT_NAT_DIR] = { .type = NLA_U32 },
34683466 [CTA_EXPECT_NAT_TUPLE] = { .type = NLA_NESTED },
34693467 };
3468
+#endif
34703469
34713470 static int
34723471 ctnetlink_parse_expect_nat(const struct nlattr *attr,