Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
OpnSense
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kulya
OpnSense
Commits
57526fb8
Commit
57526fb8
authored
Jul 24, 2015
by
Ad Schellevis
Committed by
Franco Fichtner
Jul 24, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(legacy) ipsec configuration issue when using carp ip (
https://github.com/opnsense/core/issues/267
)
parent
44c72304
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
26 deletions
+33
-26
ipsec.inc
src/etc/inc/ipsec.inc
+17
-14
vpn.inc
src/etc/inc/vpn.inc
+16
-12
No files found.
src/etc/inc/ipsec.inc
View file @
57526fb8
...
@@ -95,28 +95,31 @@ $p2_pfskeygroups = array(
...
@@ -95,28 +95,31 @@ $p2_pfskeygroups = array(
* Return phase1 local address
* Return phase1 local address
*/
*/
function
ipsec_get_phase1_src
(
&
$ph1ent
)
{
function
ipsec_get_phase1_src
(
&
$ph1ent
)
{
if
(
!
empty
(
$ph1ent
[
'interface'
]))
{
if
(
$ph1ent
[
'interface'
])
{
if
(
!
is_ipaddr
(
$ph1ent
[
'interface'
]))
{
if
(
!
is_ipaddr
(
$ph1ent
[
'interface'
]))
{
if
(
$ph1ent
[
'protocol'
]
==
"inet6"
)
{
if
(
strpos
(
$ph1ent
[
'interface'
],
'_vip'
)
!==
false
)
{
$if
=
get_failover_interface
(
$ph1ent
[
'interface'
],
"inet6"
);
// if this is a vip, set the interface to $ph1ent['interface']
$i
nterfaceip
=
get_interface_ipv6
(
$if
)
;
$i
f
=
$ph1ent
[
'interface'
]
;
}
else
{
}
else
{
$if
=
get_failover_interface
(
$ph1ent
[
'interface'
]);
// not a vip, check failover interface
$interfaceip
=
get_interface_ip
(
$if
);
if
(
$ph1ent
[
'protocol'
]
==
"inet6"
)
{
$if
=
get_failover_interface
(
$ph1ent
[
'interface'
],
"inet6"
);
}
else
{
$if
=
get_failover_interface
(
$ph1ent
[
'interface'
]);
}
}
}
}
else
{
}
else
{
$interfaceip
=
$ph1ent
[
'interface'
];
// interface is an ip address, return
return
$ph1ent
[
'interface'
];
}
}
}
else
{
}
else
{
$if
=
"wan"
;
$if
=
"wan"
;
if
(
$ph1ent
[
'protocol'
]
==
"inet6"
)
$interfaceip
=
get_interface_ipv6
(
$if
);
else
$interfaceip
=
get_interface_ip
(
$if
);
}
}
if
(
$ph1ent
[
'protocol'
]
==
"inet6"
)
{
return
$interfaceip
;
return
get_interface_ipv6
(
$if
);
}
else
{
return
get_interface_ip
(
$if
);
}
}
}
/*
/*
...
...
src/etc/inc/vpn.inc
View file @
57526fb8
...
@@ -40,7 +40,7 @@ function vpn_ipsec_configure_loglevels($forconfig = false)
...
@@ -40,7 +40,7 @@ function vpn_ipsec_configure_loglevels($forconfig = false)
foreach
(
$ipsec_loglevels
as
$lkey
=>
$ldescr
)
{
foreach
(
$ipsec_loglevels
as
$lkey
=>
$ldescr
)
{
if
(
!
isset
(
$config
[
'ipsec'
][
"ipsec_
{
$lkey
}
"
])
&&
!
$forconfig
)
if
(
!
isset
(
$config
[
'ipsec'
][
"ipsec_
{
$lkey
}
"
])
&&
!
$forconfig
)
mwexec
(
"/usr/local/sbin/ipsec stroke loglevel
{
$lkey
}
-- -1"
,
false
);
mwexec
(
"/usr/local/sbin/ipsec stroke loglevel
{
$lkey
}
-- -1"
,
false
);
else
if
(
is_numeric
(
$config
[
'ipsec'
][
"ipsec_
{
$lkey
}
"
])
&&
else
if
(
is
set
(
$config
[
'ipsec'
][
"ipsec_
{
$lkey
}
"
])
&&
is
_numeric
(
$config
[
'ipsec'
][
"ipsec_
{
$lkey
}
"
])
&&
intval
(
$config
[
'ipsec'
][
"ipsec_
{
$lkey
}
"
])
>=
1
&&
intval
(
$config
[
'ipsec'
][
"ipsec_
{
$lkey
}
"
])
<=
5
)
intval
(
$config
[
'ipsec'
][
"ipsec_
{
$lkey
}
"
])
>=
1
&&
intval
(
$config
[
'ipsec'
][
"ipsec_
{
$lkey
}
"
])
<=
5
)
$forconfig
?
$cfgtext
[]
=
"${lkey} "
.
(
intval
(
$config
[
'ipsec'
][
"ipsec_
{
$lkey
}
"
])
-
1
)
:
$forconfig
?
$cfgtext
[]
=
"${lkey} "
.
(
intval
(
$config
[
'ipsec'
][
"ipsec_
{
$lkey
}
"
])
-
1
)
:
mwexec
(
"/usr/local/sbin/ipsec stroke loglevel
{
$lkey
}
"
.
(
intval
(
$config
[
'ipsec'
][
"ipsec_
{
$lkey
}
"
])
-
1
)
,
false
);
mwexec
(
"/usr/local/sbin/ipsec stroke loglevel
{
$lkey
}
"
.
(
intval
(
$config
[
'ipsec'
][
"ipsec_
{
$lkey
}
"
])
-
1
)
,
false
);
...
@@ -146,7 +146,6 @@ function vpn_ipsec_configure($ipchg = false)
...
@@ -146,7 +146,6 @@ function vpn_ipsec_configure($ipchg = false)
$ipmap
=
array
();
$ipmap
=
array
();
$rgmap
=
array
();
$rgmap
=
array
();
$filterdns_list
=
array
();
$filterdns_list
=
array
();
$listeniflist
=
array
();
unset
(
$iflist
);
unset
(
$iflist
);
if
(
is_array
(
$a_phase1
)
&&
count
(
$a_phase1
))
{
if
(
is_array
(
$a_phase1
)
&&
count
(
$a_phase1
))
{
...
@@ -157,7 +156,6 @@ function vpn_ipsec_configure($ipchg = false)
...
@@ -157,7 +156,6 @@ function vpn_ipsec_configure($ipchg = false)
continue
;
continue
;
$ikeid
=
$ph1ent
[
'ikeid'
];
$ikeid
=
$ph1ent
[
'ikeid'
];
$listeniflist
=
get_real_interface
(
$a_phase1
[
'interface'
]);
$ep
=
ipsec_get_phase1_src
(
$ph1ent
);
$ep
=
ipsec_get_phase1_src
(
$ph1ent
);
if
(
!
is_ipaddr
(
$ep
))
if
(
!
is_ipaddr
(
$ep
))
...
@@ -392,7 +390,7 @@ EOD;
...
@@ -392,7 +390,7 @@ EOD;
unset
(
$strongswan
);
unset
(
$strongswan
);
/* generate CA certificates files */
/* generate CA certificates files */
if
(
is
_array
(
$config
[
'ca'
])
&&
coun
t
(
$config
[
'ca'
]))
{
if
(
is
se
t
(
$config
[
'ca'
]))
{
foreach
(
$config
[
'ca'
]
as
$ca
)
{
foreach
(
$config
[
'ca'
]
as
$ca
)
{
if
(
!
isset
(
$ca
[
'crt'
]))
{
if
(
!
isset
(
$ca
[
'crt'
]))
{
log_error
(
sprintf
(
gettext
(
"Error: Invalid certificate info for %s"
),
$ca
[
'descr'
]));
log_error
(
sprintf
(
gettext
(
"Error: Invalid certificate info for %s"
),
$ca
[
'descr'
]));
...
@@ -477,7 +475,7 @@ EOD;
...
@@ -477,7 +475,7 @@ EOD;
}
}
/* add PSKs for mobile clients */
/* add PSKs for mobile clients */
if
(
is
_array
(
$ipseccfg
[
'mobilekey'
]))
{
if
(
is
set
(
$ipseccfg
[
'mobilekey'
]))
{
foreach
(
$ipseccfg
[
'mobilekey'
]
as
$key
)
{
foreach
(
$ipseccfg
[
'mobilekey'
]
as
$key
)
{
if
(
$key
[
'ident'
]
==
"allusers"
)
if
(
$key
[
'ident'
]
==
"allusers"
)
$key
[
'ident'
]
=
''
;
$key
[
'ident'
]
=
''
;
...
@@ -535,14 +533,15 @@ EOD;
...
@@ -535,14 +533,15 @@ EOD;
if
(
!
isset
(
$ph1ent
[
'mobile'
]))
if
(
!
isset
(
$ph1ent
[
'mobile'
]))
$peerid_spec
=
$peerid_data
;
$peerid_spec
=
$peerid_data
;
if
(
is_array
(
$ph1ent
[
'encryption-algorithm'
])
&&
!
empty
(
$ph1ent
[
'encryption-algorithm'
][
'name'
])
&&
!
empty
(
$ph1ent
[
'hash-algorithm'
]))
{
if
(
!
empty
(
$ph1ent
[
'encryption-algorithm'
][
'name'
])
&&
!
empty
(
$ph1ent
[
'hash-algorithm'
]))
{
$ealgosp1
=
''
;
$ealgosp1
=
''
;
$ealg_id
=
$ph1ent
[
'encryption-algorithm'
][
'name'
];
$ealg_id
=
$ph1ent
[
'encryption-algorithm'
][
'name'
];
$ealg_kl
=
$ph1ent
[
'encryption-algorithm'
][
'keylen'
];
if
(
isset
(
$ph1ent
[
'encryption-algorithm'
][
'keylen'
])){
if
(
$ealg_kl
)
$ealgosp1
=
"ike =
{
$ealg_id
}{
$ph1ent
[
'encryption-algorithm'
][
'keylen'
]
}
-
{
$ph1ent
[
'hash-algorithm'
]
}
"
;
$ealgosp1
=
"ike =
{
$ealg_id
}{
$ealg_kl
}
-
{
$ph1ent
[
'hash-algorithm'
]
}
"
;
}
else
{
else
$ealgosp1
=
"ike =
{
$ealg_id
}
-
{
$ph1ent
[
'hash-algorithm'
]
}
"
;
$ealgosp1
=
"ike =
{
$ealg_id
}
-
{
$ph1ent
[
'hash-algorithm'
]
}
"
;
}
$modp
=
vpn_ipsec_convert_to_modp
(
$ph1ent
[
'dhgroup'
]);
$modp
=
vpn_ipsec_convert_to_modp
(
$ph1ent
[
'dhgroup'
]);
if
(
!
empty
(
$modp
))
if
(
!
empty
(
$modp
))
...
@@ -691,7 +690,12 @@ EOD;
...
@@ -691,7 +690,12 @@ EOD;
if
(
is_array
(
$ph2ent
[
'encryption-algorithm-option'
]))
{
if
(
is_array
(
$ph2ent
[
'encryption-algorithm-option'
]))
{
foreach
(
$ph2ent
[
'encryption-algorithm-option'
]
as
$ealg
)
{
foreach
(
$ph2ent
[
'encryption-algorithm-option'
]
as
$ealg
)
{
$ealg_id
=
$ealg
[
'name'
];
$ealg_id
=
$ealg
[
'name'
];
$ealg_kl
=
$ealg
[
'keylen'
];
if
(
isset
(
$ealg
[
'keylen'
]))
{
$ealg_kl
=
$ealg
[
'keylen'
];
}
else
{
$ealg_kl
=
null
;
}
if
(
!
empty
(
$ealg_kl
)
&&
$ealg_kl
==
"auto"
)
{
if
(
!
empty
(
$ealg_kl
)
&&
$ealg_kl
==
"auto"
)
{
if
(
empty
(
$p2_ealgos
)
||
!
is_array
(
$p2_ealgos
))
if
(
empty
(
$p2_ealgos
)
||
!
is_array
(
$p2_ealgos
))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment