@@ -490,6 +490,13 @@ def setup_tunnel_routes(r1con, r2con, tun_ipv6, network3):
490
490
return r1ipnh , r1ip6nh , r2ipnh , r2ip6nh
491
491
492
492
493
+ def esp_args_filter_dir (direction , esp_args ):
494
+ """Filter out esp args inappropriate for the direction."""
495
+ if direction != "in" :
496
+ esp_args = re .sub (r"replay-window \d+" , "" , esp_args )
497
+ return esp_args
498
+
499
+
493
500
def esp_flags_filter_dir (direction , esp_flags ):
494
501
"""Filter out esp flags inappropriate for the direction."""
495
502
if direction == "in" :
@@ -523,6 +530,7 @@ async def setup_policy_tun(
523
530
trex = False ,
524
531
r1only = False ,
525
532
ipsec_intf = "eth2" ,
533
+ esp_args = "" ,
526
534
esp_flags = "" ,
527
535
iptfs_opts = "" ,
528
536
ipv4 = True ,
@@ -594,25 +602,25 @@ async def setup_policy_tun(
594
602
#
595
603
direction = "out" if r == r1 else "in"
596
604
eflags = esp_flags_filter_dir (direction , esp_flags )
597
- esp_args = "replay-window 128" if direction == "in" else ""
605
+ eargs = esp_args_filter_dir ( direction , esp_args )
598
606
repl .cmd_raises (
599
607
(
600
608
f"ip xfrm state add src { r1ip } dst { r2ip } proto esp "
601
609
f"spi { spi_1to2 } mode { mode } { sa_auth } { sa_enc } "
602
- f"{ esp_args } { eflags } reqid { reqid_1to2 } dir { direction } "
610
+ f"{ eargs } { eflags } reqid { reqid_1to2 } dir { direction } "
603
611
# f"reqid {reqid_1to2} "
604
612
)
605
613
+ iptfs_opts_filter_dir (direction , iptfs_opts )
606
614
)
607
615
608
616
direction = "in" if r == r1 else "out"
609
617
eflags = esp_flags_filter_dir (direction , esp_flags )
610
- esp_args = "replay-window 128" if direction == "in" else ""
618
+ eargs = esp_args_filter_dir ( direction , esp_args )
611
619
repl .cmd_raises (
612
620
(
613
621
f"ip xfrm state add src { r2ip } dst { r1ip } proto esp "
614
622
f"spi { spi_2to1 } mode { mode } { sa_auth } { sa_enc } "
615
- f"{ esp_args } { eflags } reqid { reqid_2to1 } dir { direction } "
623
+ f"{ eargs } { eflags } reqid { reqid_2to1 } dir { direction } "
616
624
# f"reqid {reqid_2to1} "
617
625
)
618
626
+ iptfs_opts_filter_dir (direction , iptfs_opts )
@@ -757,6 +765,7 @@ async def setup_routed_tun(
757
765
r1only = False ,
758
766
ipsec_intf = "eth2" ,
759
767
iptfs_opts = "" ,
768
+ esp_args = "" ,
760
769
esp_flags = "" ,
761
770
ipv4 = True ,
762
771
ipv6 = False ,
@@ -835,23 +844,23 @@ async def setup_routed_tun(
835
844
836
845
direction = "out" if r == r1 else "in"
837
846
eflags = esp_flags_filter_dir (direction , esp_flags )
838
- esp_args = "replay-window 128" if direction == "in" else ""
847
+ eargs = esp_args_filter_dir ( direction , esp_args )
839
848
repl .cmd_raises (
840
849
(
841
850
f"ip xfrm state add src { r1ip } dst { r2ip } proto esp "
842
851
f"spi { spi_1to2 } mode { mode } { sa_auth } { sa_enc } "
843
- f"{ esp_args } { eflags } if_id 55 reqid { reqid_1to2 } dir { direction } "
852
+ f"{ eargs } { eflags } if_id 55 reqid { reqid_1to2 } dir { direction } "
844
853
)
845
854
+ iptfs_opts_filter_dir (direction , iptfs_opts )
846
855
)
847
856
direction = "in" if r == r1 else "out"
848
857
eflags = esp_flags_filter_dir (direction , esp_flags )
849
- esp_args = "replay-window 128" if direction == "in" else ""
858
+ eargs = esp_args_filter_dir ( direction , esp_args )
850
859
repl .cmd_raises (
851
860
(
852
861
f"ip xfrm state add src { r2ip } dst { r1ip } proto esp "
853
862
f"spi { spi_2to1 } mode { mode } { sa_auth } { sa_enc } "
854
- f"{ esp_args } { eflags } if_id 55 reqid { reqid_2to1 } dir { direction } "
863
+ f"{ eargs } { eflags } if_id 55 reqid { reqid_2to1 } dir { direction } "
855
864
)
856
865
+ iptfs_opts_filter_dir (direction , iptfs_opts )
857
866
)
0 commit comments