History

Merge tag 'nf-26-06-23' of git://git.kernel.org/pub/scm/linux/kernel/git/netfilter/nf

Pablo Neira Ayuso says: ==================== Netfilter fixes for net The following patchset contains Netfilter fixes for net: 1) Add a workaround to avoid a possible crash if nf_nat and nft_chain_nat are compiled built-in and nf_nat fails to register, allowing nft_chain_nat to access the incorrect pernetns area. This is crash specific of all built-in compilation. From Matias Krause. 2) Revisit conncount GC optimization for confirmed conntracks, skip GC round if IPS_ASSURED is set on. This is addressing an issue for corner case use case scenario involving locally generated traffic. No crash, just a functionality fix. From Fernando F. Mancera. 3) Validate iph->ihl in flowtable IPIP tunnel support, from Lorenzo Bianconi. This a sanity check to bounces back malformed IPIP packets to classic forwarding path. 4) Kdoc fixes for x_tables.h, from Randy Dunlap. 5) Use info->options so nft_synproxy_tcp_options() stays on the same local snapshot, otherwise eval path can observe inconsistent mix of mss and timestamps. From Runyu Xiao. 6) Add conntrack_sctp_collision.sh to cover for SCTP INIT collisions. From Yi Chen. 7) Do not allow NFPROTO_UNSPEC targets if family is NFPROTO_BRIDGE in nft_compat. This allows to use non-sense targets such as xt_nat leading to crash. From Florian Westphal. 8) Add a selftest queueing from bridge family. From Florian Westphal. 9) Do not allow to reset a conntrack helper via ctnetlink. This feature antedates the creation of the conntrack-tools, and it is not used I don't have a usecase for it, I prefer to remove than fixing it. 10) Add deprecation warning for IPv4 only conntrack helpers for PPTP and IRC. From Florian Westphal. 11) Store the master tuple in the expectation object and use it, otherwise SLAB_TYPESAFE_RCU rules allow to display incorrect master tuple information through ctnetlink. 12) Run expectation eviction when inserting an expectation with no helper, this is a fix for the nft_ct custom expectation support. 13) Fix nft_ct custom expectation timeouts, userspace provides a timeout in milliseconds but kernel assumes this comes in seconds. From Florian Westphal. 14) Cap maximum number of expectations per class to 255 expectations per master conntrack at helper registration. This is a fix to restrict the maximum number of expectations per master conntrack which can be a issue for the new lazy GC expectation approach. * tag 'nf-26-06-23' of git://git.kernel.org/pub/scm/linux/kernel/git/netfilter/nf: netfilter: nf_conntrack_helper: cap maximum number of expectation at helper registration netfilter: nft_ct: expectation timeouts are passed in milliseconds netfilter: nf_conntrack_expect: run expectation eviction with no helper netfilter: nf_conntrack_expect: store master_tuple in expectation netfilter: conntrack: add deprecation warnings for irc and pptp trackers netfilter: ctnetlink: do not allow to reset helper on existing conntrack selftests: nft_queue.sh: add a bridge queue test netfilter: nft_compat: ebtables emulation must reject non-bridge targets selftests: netfilter: conntrack_sctp_collision.sh: Introduce SCTP INIT collision test netfilter: nft_synproxy: stop bypassing the priv->info snapshot netfilter: x_tables.h: fix all kernel-doc warnings netfilter: flowtable: Validate iph->ihl in nf_flow_ip4_tunnel_proto() netfilter: nf_conncount: prevent connlimit drops for early confirmed ct netfilter: nf_nat: avoid invalid nat_net pointer use on failed nf_nat_init() ====================

Jakub Kicinski committed 4 months ago

Commit 02f144f2 parents 620839b 397c83018 files · +246 −86Browse files

Unified · Split

18 files
  1. include/linux/netfilter/x_tables.h +21 −8
  2. include/net/netfilter/nf_conntrack_expect.h +1 −0
  3. include/net/netfilter/nf_conntrack_helper.h +4 −0
  4. net/netfilter/Kconfig +6 −5
  5. net/netfilter/nf_conncount.c +5 −6
  6. net/netfilter/nf_conntrack_broadcast.c +1 −0
  7. net/netfilter/nf_conntrack_expect.c +10 −2
  8. net/netfilter/nf_conntrack_helper.c +7 −2
  9. net/netfilter/nf_conntrack_irc.c +2 −0
  10. net/netfilter/nf_conntrack_netlink.c +4 −19
  11. net/netfilter/nf_conntrack_pptp.c +2 −0
  12. net/netfilter/nf_flow_table_ip.c +5 −3
  13. net/netfilter/nf_nat_core.c +10 −0
  14. net/netfilter/nft_compat.c +21 −3
  15. net/netfilter/nft_ct.c +18 −3
  16. net/netfilter/nft_synproxy.c +4 −5
  17. tools/testing/selftests/net/netfilter/conntrack_sctp_collision.sh +67 −22
  18. tools/testing/selftests/net/netfilter/nft_queue.sh +58 −8
include/linux/netfilter/x_tables.h+21−8
@@ -18,7 +18,7 @@ · 17 unmodified lines
18 * @match: the match extension18 * @match: the match extension
19 * @target: the target extension19 * @target: the target extension
20 * @matchinfo: per-match data20 * @matchinfo: per-match data
21 * @targetinfo: per-target data21 * @targinfo: per-target data
22 * @state: pointer to hook state this packet came from22 * @state: pointer to hook state this packet came from
23 * @fragoff: packet is a fragment, this is the data offset23 * @fragoff: packet is a fragment, this is the data offset
24 * @thoff: position of transport header relative to skb->data24 * @thoff: position of transport header relative to skb->data
@@ -77,7 +77,9 @@ static inline u_int8_t xt_family(const struct xt_action_param *par) · 52 unmodified lines
77 * @match: struct xt_match through which this function was invoked77 * @match: struct xt_match through which this function was invoked
78 * @matchinfo: per-match data78 * @matchinfo: per-match data
79 * @hook_mask: via which hooks the new rule is reachable79 * @hook_mask: via which hooks the new rule is reachable
80 * Other fields as above.80 * @family: actual NFPROTO_* through which the function is invoked
81 * (helpful when match->family == NFPROTO_UNSPEC)
82 * @nft_compat: running from the nft compat layer if true
81 */83 */
82struct xt_mtchk_param {84struct xt_mtchk_param {
83 struct net *net;85 struct net *net;
@@ -91,8 +93,13 @@ struct xt_mtchk_param { · 7 unmodified lines
91};93};
92 94
93/**95/**
94 * struct xt_mdtor_param - match destructor parameters96 * struct xt_mtdtor_param - match destructor parameters
95 * Fields as above.97 *
98 * @net: network namespace through which the check was invoked
99 * @match: struct xt_match through which this function was invoked
100 * @matchinfo: per-match data
101 * @family: actual NFPROTO_* through which the function is invoked
102 * (helpful when match->family == NFPROTO_UNSPEC)
96 */103 */
97struct xt_mtdtor_param {104struct xt_mtdtor_param {
98 struct net *net;105 struct net *net;
@@ -105,10 +112,16 @@ struct xt_mtdtor_param { · 6 unmodified lines
105 * struct xt_tgchk_param - parameters for target extensions'112 * struct xt_tgchk_param - parameters for target extensions'
106 * checkentry functions113 * checkentry functions
107 *114 *
115 * @net: network namespace through which the check was invoked
116 * @table: table the rule is tried to be inserted into
108 * @entryinfo: the family-specific rule data117 * @entryinfo: the family-specific rule data
109 * (struct ipt_entry, ip6t_entry, arpt_entry, ebt_entry)118 * (struct ipt_entry, ip6t_entry, arpt_entry, ebt_entry)
110 *119 * @target: the target extension
111 * Other fields see above.120 * @targinfo: per-target data
121 * @hook_mask: via which hooks the new rule is reachable
122 * @family: actual NFPROTO_* through which the function is invoked
123 * (helpful when match->family == NFPROTO_UNSPEC)
124 * @nft_compat: running from the nft compat layer if true
112 */125 */
113struct xt_tgchk_param {126struct xt_tgchk_param {
114 struct net *net;127 struct net *net;
@@ -336,9 +349,9 @@ struct xt_table_info *xt_alloc_table_info(unsigned int size); · 221 unmodified lines
336void xt_free_table_info(struct xt_table_info *info);349void xt_free_table_info(struct xt_table_info *info);
337 350
338/**351/**
339 * xt_recseq - recursive seqcount for netfilter use352 * var xt_recseq - recursive seqcount for netfilter use
340 *353 *
341 * Packet processing changes the seqcount only if no recursion happened354 * Packet processing changes the seqcount only if no recursion happened.
342 * get_counters() can use read_seqcount_begin()/read_seqcount_retry(),355 * get_counters() can use read_seqcount_begin()/read_seqcount_retry(),
343 * because we use the normal seqcount convention :356 * because we use the normal seqcount convention :
344 * Low order bit set to 1 if a writer is active.357 * Low order bit set to 1 if a writer is active.
include/net/netfilter/nf_conntrack_expect.h+1−0
@@ -26,6 +26,7 @@ struct nf_conntrack_expect { · 25 unmodified lines
26 possible_net_t net;26 possible_net_t net;
27 27
28 /* We expect this tuple, with the following mask */28 /* We expect this tuple, with the following mask */
29 struct nf_conntrack_tuple master_tuple;
29 struct nf_conntrack_tuple tuple;30 struct nf_conntrack_tuple tuple;
30 struct nf_conntrack_tuple_mask mask;31 struct nf_conntrack_tuple_mask mask;
31 32
include/net/netfilter/nf_conntrack_helper.h+4−0
@@ -114,6 +114,10 @@ int nf_conntrack_helpers_register(struct nf_conntrack_helper *, unsigned int, · 113 unmodified lines
114void nf_conntrack_helpers_unregister(struct nf_conntrack_helper **,114void nf_conntrack_helpers_unregister(struct nf_conntrack_helper **,
115 unsigned int);115 unsigned int);
116 116
117#define nf_conntrack_helper_deprecated(name) \
118 pr_warn("The %s conntrack helper is scheduled for removal.\n" \
119 "Please contact the netfilter-devel mailing list if you still need this.\n", name)
120
117struct nf_conn_help *nf_ct_helper_ext_add(struct nf_conn *ct, gfp_t gfp);121struct nf_conn_help *nf_ct_helper_ext_add(struct nf_conn *ct, gfp_t gfp);
118 122
119int __nf_ct_try_assign_helper(struct nf_conn *ct, struct nf_conn *tmpl,123int __nf_ct_try_assign_helper(struct nf_conn *ct, struct nf_conn *tmpl,
net/netfilter/Kconfig+6−5
@@ -256,8 +256,7 @@ config NF_CONNTRACK_H323 · 255 unmodified lines
256 To compile it as a module, choose M here. If unsure, say N.256 To compile it as a module, choose M here. If unsure, say N.
257 257
258config NF_CONNTRACK_IRC258config NF_CONNTRACK_IRC
259 tristate "IRC protocol support"259 tristate "IRC DCC protocol support (obsolete)"
260 default m if NETFILTER_ADVANCED=n
261 help260 help
262 There is a commonly-used extension to IRC called261 There is a commonly-used extension to IRC called
263 Direct Client-to-Client Protocol (DCC). This enables users to send262 Direct Client-to-Client Protocol (DCC). This enables users to send
@@ -267,6 +266,8 @@ config NF_CONNTRACK_IRC · 3 unmodified lines
267 using NAT, this extension will enable you to send files and initiate266 using NAT, this extension will enable you to send files and initiate
268 chats. Note that you do NOT need this extension to get files or267 chats. Note that you do NOT need this extension to get files or
269 have others initiate chats, or everything else in IRC.268 have others initiate chats, or everything else in IRC.
269 DCC tracking behind NAT requires plaintext (unencrypted) IRC, so
270 this helper is of limited use these days.
270 271
271 To compile it as a module, choose M here. If unsure, say N.272 To compile it as a module, choose M here. If unsure, say N.
272 273
@@ -308,17 +309,17 @@ config NF_CONNTRACK_SNMP · 35 unmodified lines
308 To compile it as a module, choose M here. If unsure, say N.309 To compile it as a module, choose M here. If unsure, say N.
309 310
310config NF_CONNTRACK_PPTP311config NF_CONNTRACK_PPTP
311 tristate "PPtP protocol support"312 tristate "PPtP protocol support (deprecated)"
312 depends on NETFILTER_ADVANCED313 depends on NETFILTER_ADVANCED
313 select NF_CT_PROTO_GRE314 select NF_CT_PROTO_GRE
314 help315 help
315 This module adds support for PPTP (Point to Point Tunnelling316 This module adds support for PPTP (Point to Point Tunnelling
316 Protocol, RFC2637) connection tracking and NAT.317 Protocol, RFC2637) connection tracking and NAT.
317 318
318 If you are running PPTP sessions over a stateful firewall or NAT319 If you are still running PPTP sessions over a stateful firewall or NAT
319 box, you may want to enable this feature.320 box, you may want to enable this feature.
320 321
321 Please note that not all PPTP modes of operation are supported yet.322 Please note that not all PPTP modes of operation are supported.
322 Specifically these limitations exist:323 Specifically these limitations exist:
323 - Blindly assumes that control connections are always established324 - Blindly assumes that control connections are always established
324 in PNS->PAC direction. This is a violation of RFC2637.325 in PNS->PAC direction. This is a violation of RFC2637.
net/netfilter/nf_conncount.c+5−6
@@ -183,17 +183,16 @@ static int __nf_conncount_add(struct net *net, · 182 unmodified lines
183 return -ENOENT;183 return -ENOENT;
184 184
185 if (ct && nf_ct_is_confirmed(ct)) {185 if (ct && nf_ct_is_confirmed(ct)) {
186 /* local connections are confirmed in postrouting so confirmation186 /* Connection is confirmed but might still be in the setup phase.
187 * might have happened before hitting connlimit187 * Only skip the tracking if it is fully assured. This guarantees
188 * that setup packets or retransmissions are properly counted and
189 * deduplicated.
188 */190 */
189 if (skb->skb_iif != LOOPBACK_IFINDEX) {191 if (test_bit(IPS_ASSURED_BIT, &ct->status)) {
190 err = -EEXIST;192 err = -EEXIST;
191 goto out_put;193 goto out_put;
192 }194 }
193 195
194 /* this is likely a local connection, skip optimization to avoid
195 * adding duplicates from a 'packet train'
196 */
197 goto check_connections;196 goto check_connections;
198 }197 }
199 198
net/netfilter/nf_conntrack_broadcast.c+1−0
@@ -62,6 +62,7 @@ int nf_conntrack_broadcast_help(struct sk_buff *skb, · 61 unmodified lines
62 if (exp == NULL)62 if (exp == NULL)
63 goto out;63 goto out;
64 64
65 exp->master_tuple = ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple;
65 exp->tuple = ct->tuplehash[IP_CT_DIR_REPLY].tuple;66 exp->tuple = ct->tuplehash[IP_CT_DIR_REPLY].tuple;
66 67
67 helper = rcu_dereference(help->helper);68 helper = rcu_dereference(help->helper);
net/netfilter/nf_conntrack_expect.c+10−2
@@ -355,6 +355,8 @@ void nf_ct_expect_init(struct nf_conntrack_expect *exp, unsigned int class, · 354 unmodified lines
355 exp->tuple.src.l3num = family;355 exp->tuple.src.l3num = family;
356 exp->tuple.dst.protonum = proto;356 exp->tuple.dst.protonum = proto;
357 357
358 exp->master_tuple = ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple;
359
358 if (saddr) {360 if (saddr) {
359 memcpy(&exp->tuple.src.u3, saddr, len);361 memcpy(&exp->tuple.src.u3, saddr, len);
360 if (sizeof(exp->tuple.src.u3) > len)362 if (sizeof(exp->tuple.src.u3) > len)
@@ -494,9 +496,15 @@ static inline int __nf_ct_expect_check(struct nf_conntrack_expect *expect, · 133 unmodified lines
494 lockdep_is_held(&nf_conntrack_expect_lock));496 lockdep_is_held(&nf_conntrack_expect_lock));
495 if (helper) {497 if (helper) {
496 p = &helper->expect_policy[expect->class];498 p = &helper->expect_policy[expect->class];
497 if (p->max_expected &&499 if (master_help->expecting[expect->class] >= p->max_expected)
498 master_help->expecting[expect->class] >= p->max_expected)
499 evict_oldest_expect(master_help, expect, p);500 evict_oldest_expect(master_help, expect, p);
501 } else {
502 const struct nf_conntrack_expect_policy default_exp_policy = {
503 .max_expected = NF_CT_EXPECT_MAX_CNT,
504 };
505
506 if (master_help->expecting[expect->class] >= default_exp_policy.max_expected)
507 evict_oldest_expect(master_help, expect, &default_exp_policy);
500 }508 }
501 509
502 cnet = nf_ct_pernet(net);510 cnet = nf_ct_pernet(net);
net/netfilter/nf_conntrack_helper.c+7−2
@@ -374,8 +374,13 @@ int __nf_conntrack_helper_register(struct nf_conntrack_helper *me) · 373 unmodified lines
374 if (!nf_ct_helper_hash)374 if (!nf_ct_helper_hash)
375 return -ENOENT;375 return -ENOENT;
376 376
377 if (me->expect_policy->max_expected > NF_CT_EXPECT_MAX_CNT)377 for (i = 0; i <= me->expect_class_max; i++) {
378 return -EINVAL;378 if (!me->expect_policy[i].max_expected)
379 me->expect_policy[i].max_expected = NF_CT_EXPECT_MAX_CNT;
380
381 if (me->expect_policy[i].max_expected > NF_CT_EXPECT_MAX_CNT)
382 return -EINVAL;
383 }
379 384
380 mutex_lock(&nf_ct_helper_mutex);385 mutex_lock(&nf_ct_helper_mutex);
381 for (i = 0; i < nf_ct_helper_hsize; i++) {386 for (i = 0; i < nf_ct_helper_hsize; i++) {
net/netfilter/nf_conntrack_irc.c+2−0
@@ -262,6 +262,8 @@ static int __init nf_conntrack_irc_init(void) · 261 unmodified lines
262{262{
263 int i, ret;263 int i, ret;
264 264
265 nf_conntrack_helper_deprecated(HELPER_NAME);
266
265 if (max_dcc_channels < 1) {267 if (max_dcc_channels < 1) {
266 pr_err("max_dcc_channels must not be zero\n");268 pr_err("max_dcc_channels must not be zero\n");
267 return -EINVAL;269 return -EINVAL;
net/netfilter/nf_conntrack_netlink.c+4−19
@@ -1953,19 +1953,6 @@ static int ctnetlink_change_helper(struct nf_conn *ct, · 1952 unmodified lines
1953 return err;1953 return err;
1954 }1954 }
1955 1955
1956 if (!strcmp(helpname, "") && help) {
1957 helper = rcu_dereference(help->helper);
1958 if (helper) {
1959 /* we had a helper before ... */
1960 nf_ct_remove_expectations(ct);
1961 RCU_INIT_POINTER(help->helper, NULL);
1962 if (refcount_dec_and_test(&helper->ct_refcnt))
1963 kfree_rcu(helper, rcu);
1964 }
1965 rcu_read_unlock();
1966 return 0;
1967 }
1968
1969 helper = __nf_conntrack_helper_find(helpname, nf_ct_l3num(ct),1956 helper = __nf_conntrack_helper_find(helpname, nf_ct_l3num(ct),
1970 nf_ct_protonum(ct));1957 nf_ct_protonum(ct));
1971 if (helper == NULL) {1958 if (helper == NULL) {
@@ -3015,7 +3002,6 @@ ctnetlink_exp_dump_expect(struct sk_buff *skb, · 1043 unmodified lines
3015 const struct nf_conntrack_expect *exp)3002 const struct nf_conntrack_expect *exp)
3016{3003{
3017 __s32 timeout = (__s32)(READ_ONCE(exp->timeout) - nfct_time_stamp) / HZ;3004 __s32 timeout = (__s32)(READ_ONCE(exp->timeout) - nfct_time_stamp) / HZ;
3018 struct nf_conn *master = exp->master;
3019 struct nf_conntrack_helper *helper;3005 struct nf_conntrack_helper *helper;
3020#if IS_ENABLED(CONFIG_NF_NAT)3006#if IS_ENABLED(CONFIG_NF_NAT)
3021 struct nlattr *nest_parms;3007 struct nlattr *nest_parms;
@@ -3030,9 +3016,7 @@ ctnetlink_exp_dump_expect(struct sk_buff *skb, · 8 unmodified lines
3030 goto nla_put_failure;3016 goto nla_put_failure;
3031 if (ctnetlink_exp_dump_mask(skb, &exp->tuple, &exp->mask) < 0)3017 if (ctnetlink_exp_dump_mask(skb, &exp->tuple, &exp->mask) < 0)
3032 goto nla_put_failure;3018 goto nla_put_failure;
3033 if (ctnetlink_exp_dump_tuple(skb,3019 if (ctnetlink_exp_dump_tuple(skb, &exp->master_tuple, CTA_EXPECT_MASTER) < 0)
3034 &master->tuplehash[IP_CT_DIR_ORIGINAL].tuple,
3035 CTA_EXPECT_MASTER) < 0)
3036 goto nla_put_failure;3020 goto nla_put_failure;
3037 3021
3038#if IS_ENABLED(CONFIG_NF_NAT)3022#if IS_ENABLED(CONFIG_NF_NAT)
@@ -3045,9 +3029,9 @@ ctnetlink_exp_dump_expect(struct sk_buff *skb, · 6 unmodified lines
3045 if (nla_put_be32(skb, CTA_EXPECT_NAT_DIR, htonl(exp->dir)))3029 if (nla_put_be32(skb, CTA_EXPECT_NAT_DIR, htonl(exp->dir)))
3046 goto nla_put_failure;3030 goto nla_put_failure;
3047 3031
3048 nat_tuple.src.l3num = nf_ct_l3num(master);3032 nat_tuple.src.l3num = exp->master_tuple.src.l3num;
3049 nat_tuple.src.u3 = exp->saved_addr;3033 nat_tuple.src.u3 = exp->saved_addr;
3050 nat_tuple.dst.protonum = nf_ct_protonum(master);3034 nat_tuple.dst.protonum = exp->master_tuple.dst.protonum;
3051 nat_tuple.src.u = exp->saved_proto;3035 nat_tuple.src.u = exp->saved_proto;
3052 3036
3053 if (ctnetlink_exp_dump_tuple(skb, &nat_tuple,3037 if (ctnetlink_exp_dump_tuple(skb, &nat_tuple,
@@ -3589,6 +3573,7 @@ ctnetlink_alloc_expect(const struct nlattr * const cda[], struct nf_conn *ct, · 535 unmodified lines
3589#endif3573#endif
3590 rcu_assign_pointer(exp->helper, helper);3574 rcu_assign_pointer(exp->helper, helper);
3591 rcu_assign_pointer(exp->assign_helper, assign_helper);3575 rcu_assign_pointer(exp->assign_helper, assign_helper);
3576 exp->master_tuple = ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple;
3592 exp->tuple = *tuple;3577 exp->tuple = *tuple;
3593 exp->mask.src.u3 = mask->src.u3;3578 exp->mask.src.u3 = mask->src.u3;
3594 exp->mask.src.u.all = mask->src.u.all;3579 exp->mask.src.u.all = mask->src.u.all;
net/netfilter/nf_conntrack_pptp.c+2−0
@@ -545,6 +545,8 @@ static int __init nf_conntrack_pptp_init(void) · 544 unmodified lines
545 545
546 pptp.destroy = gre_pptp_destroy_siblings;546 pptp.destroy = gre_pptp_destroy_siblings;
547 547
548 nf_conntrack_helper_deprecated(pptp.name);
549
548 return nf_conntrack_helper_register(&pptp, &pptp_ptr);550 return nf_conntrack_helper_register(&pptp, &pptp_ptr);
549}551}
550 552
net/netfilter/nf_flow_table_ip.c+5−3
@@ -326,8 +326,10 @@ static bool nf_flow_ip4_tunnel_proto(struct nf_flowtable_ctx *ctx, · 325 unmodified lines
326 return false;326 return false;
327 327
328 iph = (struct iphdr *)(skb_network_header(skb) + ctx->offset);328 iph = (struct iphdr *)(skb_network_header(skb) + ctx->offset);
329 size = iph->ihl << 2;329 if (iph->ihl < 5)
330 return false;
330 331
332 size = iph->ihl << 2;
331 if (ip_is_fragment(iph) || unlikely(ip_has_options(size)))333 if (ip_is_fragment(iph) || unlikely(ip_has_options(size)))
332 return false;334 return false;
333 335
@@ -335,9 +337,9 @@ static bool nf_flow_ip4_tunnel_proto(struct nf_flowtable_ctx *ctx, · 1 unmodified line
335 return false;337 return false;
336 338
337 if (iph->protocol == IPPROTO_IPIP) {339 if (iph->protocol == IPPROTO_IPIP) {
338 ctx->tun.proto = IPPROTO_IPIP;340 ctx->tun.proto = iph->protocol;
339 ctx->tun.hdr_size = size;341 ctx->tun.hdr_size = size;
340 ctx->offset += size;342 ctx->offset += ctx->tun.hdr_size;
341 }343 }
342 344
343 return true;345 return true;
net/netfilter/nf_nat_core.c+10−0
@@ -1181,6 +1181,16 @@ int nf_nat_register_fn(struct net *net, u8 pf, const struct nf_hook_ops *ops, · 1180 unmodified lines
1181 struct nf_hook_ops *nat_ops;1181 struct nf_hook_ops *nat_ops;
1182 int i, ret;1182 int i, ret;
1183 1183
1184#ifndef MODULE
1185 /* If nf_nat_core is built-in and nf_nat_init() fails, dependent
1186 * modules like nft_chain_nat.ko may still call this function.
1187 * However, nat_net would be invalid, likely pointing to some other
1188 * per-net structure.
1189 */
1190 if (WARN_ON_ONCE(!nf_nat_hook))
1191 return -EOPNOTSUPP;
1192#endif
1193
1184 if (WARN_ON_ONCE(pf >= ARRAY_SIZE(nat_net->nat_proto_net)))1194 if (WARN_ON_ONCE(pf >= ARRAY_SIZE(nat_net->nat_proto_net)))
1185 return -EINVAL;1195 return -EINVAL;
1186 1196
net/netfilter/nft_compat.c+21−3
@@ -397,6 +397,22 @@ static int nft_target_validate(const struct nft_ctx *ctx, · 396 unmodified lines
397 return 0;397 return 0;
398}398}
399 399
400static int nft_target_bridge_validate(const struct nft_ctx *ctx,
401 const struct nft_expr *expr)
402{
403 struct xt_target *target = expr->ops->data;
404
405 /* Do not allow UNSPEC to stand-in for NFPROTO_BRIDGE
406 * targets: they are incompatible. ebtables targets return
407 * EBT_ACCEPT, DROP and so on which are not compatible with
408 * NF_ACCEPT, NF_DROP and so on.
409 */
410 if (target->family != NFPROTO_BRIDGE)
411 return -ENOENT;
412
413 return nft_target_validate(ctx, expr);
414}
415
400static void __nft_match_eval(const struct nft_expr *expr,416static void __nft_match_eval(const struct nft_expr *expr,
401 struct nft_regs *regs,417 struct nft_regs *regs,
402 const struct nft_pktinfo *pkt,418 const struct nft_pktinfo *pkt,
@@ -932,13 +948,15 @@ nft_target_select_ops(const struct nft_ctx *ctx, · 529 unmodified lines
932 ops->init = nft_target_init;948 ops->init = nft_target_init;
933 ops->destroy = nft_target_destroy;949 ops->destroy = nft_target_destroy;
934 ops->dump = nft_target_dump;950 ops->dump = nft_target_dump;
935 ops->validate = nft_target_validate;
936 ops->data = target;951 ops->data = target;
937 952
938 if (family == NFPROTO_BRIDGE)953 if (family == NFPROTO_BRIDGE) {
939 ops->eval = nft_target_eval_bridge;954 ops->eval = nft_target_eval_bridge;
940 else955 ops->validate = nft_target_bridge_validate;
956 } else {
941 ops->eval = nft_target_eval_xt;957 ops->eval = nft_target_eval_xt;
958 ops->validate = nft_target_validate;
959 }
942 960
943 return ops;961 return ops;
944err:962err:
net/netfilter/nft_ct.c+18−3
@@ -1215,11 +1215,23 @@ struct nft_ct_expect_obj { · 1214 unmodified lines
1215 u32 timeout;1215 u32 timeout;
1216};1216};
1217 1217
1218static int nft_ct_expect_timeout_get(const struct nlattr *attr, u32 *val)
1219{
1220 unsigned long jiffies_val = msecs_to_jiffies(nla_get_u32(attr));
1221
1222 if (jiffies_val > UINT_MAX)
1223 return -ERANGE;
1224
1225 *val = jiffies_val;
1226 return 0;
1227}
1228
1218static int nft_ct_expect_obj_init(const struct nft_ctx *ctx,1229static int nft_ct_expect_obj_init(const struct nft_ctx *ctx,
1219 const struct nlattr * const tb[],1230 const struct nlattr * const tb[],
1220 struct nft_object *obj)1231 struct nft_object *obj)
1221{1232{
1222 struct nft_ct_expect_obj *priv = nft_obj_data(obj);1233 struct nft_ct_expect_obj *priv = nft_obj_data(obj);
1234 int err;
1223 1235
1224 if (!tb[NFTA_CT_EXPECT_L4PROTO] ||1236 if (!tb[NFTA_CT_EXPECT_L4PROTO] ||
1225 !tb[NFTA_CT_EXPECT_DPORT] ||1237 !tb[NFTA_CT_EXPECT_DPORT] ||
@@ -1254,8 +1266,11 @@ static int nft_ct_expect_obj_init(const struct nft_ctx *ctx, · 28 unmodified lines
1254 return -EOPNOTSUPP;1266 return -EOPNOTSUPP;
1255 }1267 }
1256 1268
1269 err = nft_ct_expect_timeout_get(tb[NFTA_CT_EXPECT_TIMEOUT], &priv->timeout);
1270 if (err)
1271 return err;
1272
1257 priv->dport = nla_get_be16(tb[NFTA_CT_EXPECT_DPORT]);1273 priv->dport = nla_get_be16(tb[NFTA_CT_EXPECT_DPORT]);
1258 priv->timeout = nla_get_u32(tb[NFTA_CT_EXPECT_TIMEOUT]);
1259 priv->size = nla_get_u8(tb[NFTA_CT_EXPECT_SIZE]);1274 priv->size = nla_get_u8(tb[NFTA_CT_EXPECT_SIZE]);
1260 1275
1261 return nf_ct_netns_get(ctx->net, ctx->family);1276 return nf_ct_netns_get(ctx->net, ctx->family);
@@ -1275,7 +1290,7 @@ static int nft_ct_expect_obj_dump(struct sk_buff *skb, · 13 unmodified lines
1275 if (nla_put_be16(skb, NFTA_CT_EXPECT_L3PROTO, htons(priv->l3num)) ||1290 if (nla_put_be16(skb, NFTA_CT_EXPECT_L3PROTO, htons(priv->l3num)) ||
1276 nla_put_u8(skb, NFTA_CT_EXPECT_L4PROTO, priv->l4proto) ||1291 nla_put_u8(skb, NFTA_CT_EXPECT_L4PROTO, priv->l4proto) ||
1277 nla_put_be16(skb, NFTA_CT_EXPECT_DPORT, priv->dport) ||1292 nla_put_be16(skb, NFTA_CT_EXPECT_DPORT, priv->dport) ||
1278 nla_put_u32(skb, NFTA_CT_EXPECT_TIMEOUT, priv->timeout) ||1293 nla_put_u32(skb, NFTA_CT_EXPECT_TIMEOUT, jiffies_to_msecs(priv->timeout)) ||
1279 nla_put_u8(skb, NFTA_CT_EXPECT_SIZE, priv->size))1294 nla_put_u8(skb, NFTA_CT_EXPECT_SIZE, priv->size))
1280 return -1;1295 return -1;
1281 1296
@@ -1325,7 +1340,7 @@ static void nft_ct_expect_obj_eval(struct nft_object *obj, · 43 unmodified lines
1325 &ct->tuplehash[!dir].tuple.src.u3,1340 &ct->tuplehash[!dir].tuple.src.u3,
1326 &ct->tuplehash[!dir].tuple.dst.u3,1341 &ct->tuplehash[!dir].tuple.dst.u3,
1327 priv->l4proto, NULL, &priv->dport);1342 priv->l4proto, NULL, &priv->dport);
1328 exp->timeout += priv->timeout * HZ;1343 exp->timeout += priv->timeout;
1329 1344
1330 if (nf_ct_expect_related(exp, 0) != 0)1345 if (nf_ct_expect_related(exp, 0) != 0)
1331 regs->verdict.code = NF_DROP;1346 regs->verdict.code = NF_DROP;
net/netfilter/nft_synproxy.c+4−5
@@ -24,14 +24,13 @@ static const struct nla_policy nft_synproxy_policy[NFTA_SYNPROXY_MAX + 1] = { · 23 unmodified lines
24static void nft_synproxy_tcp_options(struct synproxy_options *opts,24static void nft_synproxy_tcp_options(struct synproxy_options *opts,
25 const struct tcphdr *tcp,25 const struct tcphdr *tcp,
26 struct synproxy_net *snet,26 struct synproxy_net *snet,
27 struct nf_synproxy_info *info,27 struct nf_synproxy_info *info)
28 const struct nft_synproxy *priv)
29{28{
30 this_cpu_inc(snet->stats->syn_received);29 this_cpu_inc(snet->stats->syn_received);
31 if (tcp->ece && tcp->cwr)30 if (tcp->ece && tcp->cwr)
32 opts->options |= NF_SYNPROXY_OPT_ECN;31 opts->options |= NF_SYNPROXY_OPT_ECN;
33 32
34 opts->options &= priv->info.options;33 opts->options &= info->options;
35 opts->mss_encode = opts->mss_option;34 opts->mss_encode = opts->mss_option;
36 opts->mss_option = info->mss;35 opts->mss_option = info->mss;
37 if (opts->options & NF_SYNPROXY_OPT_TIMESTAMP)36 if (opts->options & NF_SYNPROXY_OPT_TIMESTAMP)
@@ -56,7 +55,7 @@ static void nft_synproxy_eval_v4(const struct nft_synproxy *priv, · 18 unmodified lines
56 55
57 if (tcp->syn) {56 if (tcp->syn) {
58 /* Initial SYN from client */57 /* Initial SYN from client */
59 nft_synproxy_tcp_options(opts, tcp, snet, &info, priv);58 nft_synproxy_tcp_options(opts, tcp, snet, &info);
60 synproxy_send_client_synack(net, skb, tcp, opts);59 synproxy_send_client_synack(net, skb, tcp, opts);
61 consume_skb(skb);60 consume_skb(skb);
62 regs->verdict.code = NF_STOLEN;61 regs->verdict.code = NF_STOLEN;
@@ -87,7 +86,7 @@ static void nft_synproxy_eval_v6(const struct nft_synproxy *priv, · 24 unmodified lines
87 86
88 if (tcp->syn) {87 if (tcp->syn) {
89 /* Initial SYN from client */88 /* Initial SYN from client */
90 nft_synproxy_tcp_options(opts, tcp, snet, &info, priv);89 nft_synproxy_tcp_options(opts, tcp, snet, &info);
91 synproxy_send_client_synack_ipv6(net, skb, tcp, opts);90 synproxy_send_client_synack_ipv6(net, skb, tcp, opts);
92 consume_skb(skb);91 consume_skb(skb);
93 regs->verdict.code = NF_STOLEN;92 regs->verdict.code = NF_STOLEN;
tools/testing/selftests/net/netfilter/conntrack_sctp_collision.sh+67−22
@@ -2,18 +2,32 @@ · 1 unmodified line
2# SPDX-License-Identifier: GPL-2.02# SPDX-License-Identifier: GPL-2.0
3#3#
4# Testing For SCTP COLLISION SCENARIO as Below:4# Testing For SCTP COLLISION SCENARIO as Below:
5#5# 1. Stale INIT_ACK capture:
6# 14:35:47.655279 IP CLIENT_IP.PORT > SERVER_IP.PORT: sctp (1) [INIT] [init tag: 2017837359]6# 14:35:47.655279 IP CLIENT_IP.PORT > SERVER_IP.PORT: sctp (1) [INIT] [init tag: 2017837359]
7# 14:35:48.353250 IP SERVER_IP.PORT > CLIENT_IP.PORT: sctp (1) [INIT] [init tag: 1187206187]7# 14:35:48.353250 IP SERVER_IP.PORT > CLIENT_IP.PORT: sctp (1) [INIT] [init tag: 1187206187]
8# 14:35:48.353275 IP CLIENT_IP.PORT > SERVER_IP.PORT: sctp (1) [INIT ACK] [init tag: 2017837359]8# 14:35:48.353275 IP CLIENT_IP.PORT > SERVER_IP.PORT: sctp (1) [INIT ACK] [init tag: 2017837359]
9# 14:35:48.353283 IP SERVER_IP.PORT > CLIENT_IP.PORT: sctp (1) [COOKIE ECHO]9# 14:35:48.353283 IP SERVER_IP.PORT > CLIENT_IP.PORT: sctp (1) [COOKIE ECHO]
10# 14:35:48.353977 IP CLIENT_IP.PORT > SERVER_IP.PORT: sctp (1) [COOKIE ACK]10# 14:35:48.353977 IP CLIENT_IP.PORT > SERVER_IP.PORT: sctp (1) [COOKIE ACK]
11# 14:35:48.855335 IP SERVER_IP.PORT > CLIENT_IP.PORT: sctp (1) [INIT ACK] [init tag: 164579970]11# 14:35:48.855335 IP SERVER_IP.PORT > CLIENT_IP.PORT: sctp (1) [INIT ACK] [init tag: 164579970]
12# (Delayed)
13#
14# 2. Stale INIT capture:
15# 14:35:48.353250 IP SERVER_IP.PORT > CLIENT_IP.PORT: sctp (1) [INIT] [init tag: 1187206187]
16# 14:35:48.353275 IP CLIENT_IP.PORT > SERVER_IP.PORT: sctp (1) [INIT ACK] [init tag: 2017837359]
17# 14:35:48.353283 IP SERVER_IP.PORT > CLIENT_IP.PORT: sctp (1) [COOKIE ECHO]
18# 14:35:48.353977 IP CLIENT_IP.PORT > SERVER_IP.PORT: sctp (1) [COOKIE ACK]
19# 14:35:47.655279 IP CLIENT_IP.PORT > SERVER_IP.PORT: sctp (1) [INIT] [init tag: 2017837359]
20# (Delayed)
21# 14:35:48.855335 IP SERVER_IP.PORT > CLIENT_IP.PORT: sctp (1) [INIT ACK] [init tag: 164579970]
12#22#
13# TOPO: SERVER_NS (link0)<--->(link1) ROUTER_NS (link2)<--->(link3) CLIENT_NS23# TOPO: SERVER_NS (link0)<--->(link1) ROUTER_NS (link2)<--->(link3) CLIENT_NS
14 24
15source lib.sh25source lib.sh
16 26
27checktool "nft --version" "run test without nft"
28checktool "tc -h" "run test without tc"
29checktool "modprobe -q sctp" "load sctp module"
30
17CLIENT_IP="198.51.200.1"31CLIENT_IP="198.51.200.1"
18CLIENT_PORT=123432CLIENT_PORT=1234
19 33
@@ -24,7 +38,8 @@ CLIENT_GW="198.51.200.2" · 4 unmodified lines
24SERVER_GW="198.51.100.2"38SERVER_GW="198.51.100.2"
25 39
26# setup the topo40# setup the topo
27setup() {41topo_setup() {
42 # setup_ns cleans up existing net namespaces first.
28 setup_ns CLIENT_NS SERVER_NS ROUTER_NS43 setup_ns CLIENT_NS SERVER_NS ROUTER_NS
29 ip -n "$SERVER_NS" link add link0 type veth peer name link1 netns "$ROUTER_NS"44 ip -n "$SERVER_NS" link add link0 type veth peer name link1 netns "$ROUTER_NS"
30 ip -n "$CLIENT_NS" link add link3 type veth peer name link2 netns "$ROUTER_NS"45 ip -n "$CLIENT_NS" link add link3 type veth peer name link2 netns "$ROUTER_NS"
@@ -38,35 +53,53 @@ setup() { · 7 unmodified lines
38 ip -n "$ROUTER_NS" addr add $SERVER_GW/24 dev link153 ip -n "$ROUTER_NS" addr add $SERVER_GW/24 dev link1
39 ip -n "$ROUTER_NS" addr add $CLIENT_GW/24 dev link254 ip -n "$ROUTER_NS" addr add $CLIENT_GW/24 dev link2
40 ip net exec "$ROUTER_NS" sysctl -wq net.ipv4.ip_forward=155 ip net exec "$ROUTER_NS" sysctl -wq net.ipv4.ip_forward=1
56 sysctl -wq net.netfilter.nf_log_all_netns=1
41 57
42 ip -n "$CLIENT_NS" link set link3 up58 ip -n "$CLIENT_NS" link set link3 up
43 ip -n "$CLIENT_NS" addr add $CLIENT_IP/24 dev link359 ip -n "$CLIENT_NS" addr add $CLIENT_IP/24 dev link3
44 ip -n "$CLIENT_NS" route add $SERVER_IP dev link3 via $CLIENT_GW60 ip -n "$CLIENT_NS" route add $SERVER_IP dev link3 via $CLIENT_GW
61}
62
63conf_delay()
64{
65 # simulate the delay on OVS upcall by setting up a delay for INIT_ACK/INIT with
66 local ns=$1
67 local link=$2
68 local chunk_type=$3
45 69
46 # simulate the delay on OVS upcall by setting up a delay for INIT_ACK with70 # use a smaller number for assoc's max_retrans to reproduce the issue
47 # tc on $SERVER_NS side71 ip net exec "$CLIENT_NS" sysctl -wq net.sctp.association_max_retrans=3
48 tc -n "$SERVER_NS" qdisc add dev link0 root handle 1: htb r2q 6472
49 tc -n "$SERVER_NS" class add dev link0 parent 1: classid 1:1 htb rate 100mbit73 tc -n "$ns" qdisc add dev "$link" root handle 1: htb r2q 64
50 tc -n "$SERVER_NS" filter add dev link0 parent 1: protocol ip u32 match ip protocol 132 \74 tc -n "$ns" class add dev "$link" parent 1: classid 1:1 htb rate 100mbit
51 0xff match u8 2 0xff at 32 flowid 1:175 tc -n "$ns" filter add dev "$link" parent 1: protocol ip \
52 if ! tc -n "$SERVER_NS" qdisc add dev link0 parent 1:1 handle 10: netem delay 1200ms; then76 u32 match ip protocol 132 0xff match u8 "$chunk_type" 0xff at 32 flowid 1:1
77 if ! tc -n "$ns" qdisc add dev "$link" parent 1:1 handle 10: netem delay 1200ms; then
53 echo "SKIP: Cannot add netem qdisc"78 echo "SKIP: Cannot add netem qdisc"
54 exit $ksft_skip79 return $ksft_skip
55 fi80 fi
56 81
57 # simulate the ctstate check on OVS nf_conntrack82 # simulate the ctstate check on OVS nf_conntrack
58 ip net exec "$ROUTER_NS" iptables -A FORWARD -m state --state INVALID,UNTRACKED -j DROP83 ip net exec "$ROUTER_NS" nft -f - <<-EOF
59 ip net exec "$ROUTER_NS" iptables -A INPUT -p sctp -j DROP84 table ip t {
60 85 chain forward {
61 # use a smaller number for assoc's max_retrans to reproduce the issue86 type filter hook forward priority filter; policy accept;
62 modprobe -q sctp87 meta l4proto icmp counter accept
63 ip net exec "$CLIENT_NS" sysctl -wq net.sctp.association_max_retrans=388 ct state new counter accept
89 ct state established,related counter accept
90 ct state invalid log flags all counter drop comment \
91 "Expect to drop stale INIT/INIT_ACK chunks"
92 counter
93 }
94 }
95 EOF
96 return 0
64}97}
65 98
66cleanup() {99cleanup() {
67 ip net exec "$CLIENT_NS" pkill sctp_collision >/dev/null 2>&1100 # cleanup_all_ns terminates running processes in the namespaces.
68 ip net exec "$SERVER_NS" pkill sctp_collision >/dev/null 2>&1
69 cleanup_all_ns101 cleanup_all_ns
102 sysctl -wq net.netfilter.nf_log_all_netns=0
70}103}
71 104
72do_test() {105do_test() {
@@ -81,7 +114,19 @@ do_test() { · 8 unmodified lines
81 114
82# run the test case115# run the test case
83trap cleanup EXIT116trap cleanup EXIT
84setup && \117
85echo "Test for SCTP Collision in nf_conntrack:" && \118echo "Test for SCTP INIT_ACK Collision in nf_conntrack:"
86do_test && echo "PASS!"119topo_setup || exit $?
87exit $?120conf_delay $SERVER_NS link0 2 || exit $?
121
122if ! do_test; then
123 exit $ksft_fail
124fi
125
126echo "Test for SCTP INIT Collision in nf_conntrack:"
127topo_setup || exit $?
128conf_delay $CLIENT_NS link3 1 || exit $?
129
130if ! do_test; then
131 exit $ksft_fail
132fi
tools/testing/selftests/net/netfilter/nft_queue.sh+58−8
@@ -85,11 +85,12 @@ ip -net "$ns3" route add default via 10.0.3.1 · 84 unmodified lines
85ip -net "$ns3" route add default via dead:3::185ip -net "$ns3" route add default via dead:3::1
86 86
87load_ruleset() {87load_ruleset() {
88 local name=$188 local family=$1
89 local prio=$289 local name=$2
90 local prio=$3
90 91
91ip netns exec "$nsrouter" nft -f /dev/stdin <<EOF92ip netns exec "$nsrouter" nft -f /dev/stdin <<EOF
92table inet $name {93table $family $name {
93 chain nfq {94 chain nfq {
94 ip protocol icmp queue bypass95 ip protocol icmp queue bypass
95 icmpv6 type { "echo-request", "echo-reply" } queue num 1 bypass96 icmpv6 type { "echo-request", "echo-reply" } queue num 1 bypass
@@ -228,6 +229,7 @@ nf_queue_wait() · 132 unmodified lines
228test_queue()229test_queue()
229{230{
230 local expected="$1"231 local expected="$1"
232 local family="$2"
231 local last=""233 local last=""
232 234
233 # spawn nf_queue listeners235 # spawn nf_queue listeners
@@ -255,11 +257,13 @@ test_queue() · 21 unmodified lines
255 if [ x"$last" != x"$expected packets total" ]; then257 if [ x"$last" != x"$expected packets total" ]; then
256 echo "FAIL: Expected $expected packets total, but got $last" 1>&2258 echo "FAIL: Expected $expected packets total, but got $last" 1>&2
257 ip netns exec "$nsrouter" nft list ruleset259 ip netns exec "$nsrouter" nft list ruleset
260 echo -n "$TMPFILE0: ";cat "$TMPFILE0"
261 echo -n "$TMPFILE1: ";cat "$TMPFILE1"
258 exit 1262 exit 1
259 fi263 fi
260 done264 done
261 265
262 echo "PASS: Expected and received $last"266 echo "PASS: Expected and received $last ($family)"
263}267}
264 268
265listener_ready()269listener_ready()
@@ -400,6 +404,8 @@ EOF · 134 unmodified lines
400 404
401 kill "$nfqpid"405 kill "$nfqpid"
402 echo "PASS: icmp+nfqueue via vrf"406 echo "PASS: icmp+nfqueue via vrf"
407 ip -net "$ns1" link del tvrf
408 ip netns exec "$ns1" nft flush ruleset
403}409}
404 410
405sctp_listener_ready()411sctp_listener_ready()
@@ -814,12 +820,53 @@ EOF · 408 unmodified lines
814 check_tainted "queue program exiting while packets queued"820 check_tainted "queue program exiting while packets queued"
815}821}
816 822
823test_queue_bridge()
824{
825 ip -net "$nsrouter" addr flush dev veth0
826 ip -net "$nsrouter" addr flush dev veth1
827
828 ip -net "$nsrouter" link add br0 type bridge
829 ip -net "$nsrouter" link set veth0 master br0
830 ip -net "$nsrouter" link set veth1 master br0
831
832 ip -net "$nsrouter" link set br0 up
833
834 ip -net "$nsrouter" addr add 10.0.2.1/16 dev br0
835 ip -net "$nsrouter" addr add dead:2::1/64 dev br0 nodad
836
837 ip -net "$ns1" addr flush dev eth0
838 ip -net "$ns2" addr flush dev eth0
839
840 ip -net "$ns1" addr add 10.0.1.1/16 dev eth0
841 ip -net "$ns1" addr add dead:2::2/64 dev eth0 nodad
842
843 ip -net "$ns2" addr add 10.0.2.99/16 dev eth0
844 ip -net "$ns2" addr add dead:2::99/64 dev eth0 nodad
845
846 ip netns exec "$nsrouter" nft flush ruleset
847
848 ip netns exec "$nsrouter" sysctl net.ipv6.conf.all.forwarding=0 > /dev/null
849 ip netns exec "$nsrouter" sysctl net.ipv4.conf.veth0.forwarding=0 > /dev/null
850 ip netns exec "$nsrouter" sysctl net.ipv4.conf.veth1.forwarding=0 > /dev/null
851
852 if ! test_ping;then
853 echo "FAIL: netns bridge connectivity" 1>&2
854 exit $ret
855 fi
856
857 load_ruleset "bridge" "filter" 10
858 test_queue 10 "bridge"
859
860 load_ruleset "bridge" "filter2" 20
861 test_queue 20 "bridge"
862}
863
817ip netns exec "$nsrouter" sysctl net.ipv6.conf.all.forwarding=1 > /dev/null864ip netns exec "$nsrouter" sysctl net.ipv6.conf.all.forwarding=1 > /dev/null
818ip netns exec "$nsrouter" sysctl net.ipv4.conf.veth0.forwarding=1 > /dev/null865ip netns exec "$nsrouter" sysctl net.ipv4.conf.veth0.forwarding=1 > /dev/null
819ip netns exec "$nsrouter" sysctl net.ipv4.conf.veth1.forwarding=1 > /dev/null866ip netns exec "$nsrouter" sysctl net.ipv4.conf.veth1.forwarding=1 > /dev/null
820ip netns exec "$nsrouter" sysctl net.ipv4.conf.veth2.forwarding=1 > /dev/null867ip netns exec "$nsrouter" sysctl net.ipv4.conf.veth2.forwarding=1 > /dev/null
821 868
822load_ruleset "filter" 0869load_ruleset "inet" "filter" 0
823 870
824if test_ping; then871if test_ping; then
825 # queue bypass works (rules were skipped, no listener)872 # queue bypass works (rules were skipped, no listener)
@@ -842,11 +889,11 @@ load_counter_ruleset 10 · 16 unmodified lines
842# 1x icmp prerouting,forward,postrouting -> 3 queue events (6 incl. reply).889# 1x icmp prerouting,forward,postrouting -> 3 queue events (6 incl. reply).
843# 1x icmp prerouting,input,output postrouting -> 4 queue events incl. reply.890# 1x icmp prerouting,input,output postrouting -> 4 queue events incl. reply.
844# so we expect that userspace program receives 10 packets.891# so we expect that userspace program receives 10 packets.
845test_queue 10892test_queue 10 "inet"
846 893
847# same. We queue to a second program as well.894# same. We queue to a second program as well.
848load_ruleset "filter2" 20895load_ruleset "inet" "filter2" 20
849test_queue 20896test_queue 20 "inet"
850ip netns exec "$ns1" nft flush ruleset897ip netns exec "$ns1" nft flush ruleset
851 898
852test_tcp_forward899test_tcp_forward
@@ -863,4 +910,7 @@ test_queue_stress · 10 unmodified lines
863test_icmp_vrf910test_icmp_vrf
864test_queue_removal911test_queue_removal
865 912
913# turns router into a bridge
914test_queue_bridge
915
866exit $ret916exit $ret