@@ -156,6 +156,8 @@ def get_config(config=None):
156
156
_ , vti = get_interface_dict (conf , ['interfaces' , 'vti' ], vti_interface )
157
157
ipsec ['vti_interface_dicts' ][vti_interface ] = vti
158
158
159
+ ipsec ['vpp_ipsec_exists' ] = conf .exists (['vpp' , 'settings' , 'ipsec' ])
160
+
159
161
return ipsec
160
162
161
163
def get_dhcp_address (iface ):
@@ -484,6 +486,17 @@ def verify(ipsec):
484
486
else :
485
487
raise ConfigError (f"Missing ike-group on site-to-site peer { peer } " )
486
488
489
+ # verify encryption algorithm compatibility for IKE with VPP
490
+ if ipsec ['vpp_ipsec_exists' ]:
491
+ ike_group = ipsec ['ike_group' ][peer_conf ['ike_group' ]]
492
+ for proposal , proposal_config in ike_group .get ('proposal' , {}).items ():
493
+ algs = ['gmac' , 'serpent' , 'twofish' ]
494
+ if any (alg in proposal_config ['encryption' ] for alg in algs ):
495
+ raise ConfigError (
496
+ f'Encryption algorithm { proposal_config ["encryption" ]} cannot be used '
497
+ f'for IKE proposal { proposal } for site-to-site peer { peer } with VPP'
498
+ )
499
+
487
500
if 'authentication' not in peer_conf or 'mode' not in peer_conf ['authentication' ]:
488
501
raise ConfigError (f"Missing authentication on site-to-site peer { peer } " )
489
502
@@ -562,7 +575,7 @@ def verify(ipsec):
562
575
563
576
esp_group_name = tunnel_conf ['esp_group' ] if 'esp_group' in tunnel_conf else peer_conf ['default_esp_group' ]
564
577
565
- if esp_group_name not in ipsec [ 'esp_group' ] :
578
+ if esp_group_name not in ipsec . get ( 'esp_group' ) :
566
579
raise ConfigError (f"Invalid esp-group on tunnel { tunnel } for site-to-site peer { peer } " )
567
580
568
581
esp_group = ipsec ['esp_group' ][esp_group_name ]
@@ -574,6 +587,18 @@ def verify(ipsec):
574
587
if ('local' in tunnel_conf and 'prefix' in tunnel_conf ['local' ]) or ('remote' in tunnel_conf and 'prefix' in tunnel_conf ['remote' ]):
575
588
raise ConfigError (f"Local/remote prefix cannot be used with ESP transport mode on tunnel { tunnel } for site-to-site peer { peer } " )
576
589
590
+ # verify ESP encryption algorithm compatibility with VPP
591
+ # because Marvel plugin for VPP doesn't support all algorithms that Strongswan does
592
+ if ipsec ['vpp_ipsec_exists' ]:
593
+ for proposal , proposal_config in esp_group .get ('proposal' , {}).items ():
594
+ algs = ['aes128' , 'aes192' , 'aes256' , 'aes128gcm128' , 'aes192gcm128' , 'aes256gcm128' ]
595
+ if proposal_config ['encryption' ] not in algs :
596
+ raise ConfigError (
597
+ f'Encryption algorithm { proposal_config ["encryption" ]} cannot be used '
598
+ f'for ESP proposal { proposal } on tunnel { tunnel } for site-to-site peer { peer } with VPP'
599
+ )
600
+
601
+
577
602
def cleanup_pki_files ():
578
603
for path in [CERT_PATH , CA_PATH , CRL_PATH , KEY_PATH , PUBKEY_PATH ]:
579
604
if not os .path .exists (path ):
0 commit comments