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
951a4ceb
Commit
951a4ceb
authored
Jun 18, 2016
by
Franco Fichtner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
interfaces: call stack on get_carp_interface_status() is also tricky
parent
382a3d3b
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
22 deletions
+23
-22
interfaces.inc
src/etc/inc/interfaces.inc
+23
-0
pfsense-utils.inc
src/etc/inc/pfsense-utils.inc
+0
-22
No files found.
src/etc/inc/interfaces.inc
View file @
951a4ceb
...
...
@@ -5397,3 +5397,26 @@ function is_ipaddr_configured($ipaddr, $ignore_if = "", $check_localip = false,
return false;
}
/*
* get_carp_interface_status(
$carpinterface
): returns the status of a carp ip
*/
function get_carp_interface_status(
$carpinterface
)
{
$carp_query
= '';
/* XXX: Need to fidn a better way for this! */
list (
$interface
,
$vhid
) = explode("
_vip
",
$carpinterface
);
$interface
= get_real_interface(
$interface
);
exec("
/
sbin
/
ifconfig
$interface
|
/
usr
/
bin
/
grep
-
v
grep
|
/
usr
/
bin
/
grep
carp
:
|
/
usr
/
bin
/
grep
'vhid {$vhid}'
",
$carp_query
);
foreach(
$carp_query
as
$int
) {
if (stristr(
$int
, "
MASTER
")) {
return gettext("
MASTER
");
} elseif (stristr(
$int
, "
BACKUP
")) {
return gettext("
BACKUP
");
} elseif(stristr(
$int
, "
INIT
")) {
return gettext("
INIT
");
}
}
return;
}
src/etc/inc/pfsense-utils.inc
View file @
951a4ceb
...
...
@@ -51,28 +51,6 @@ function is_private_ip($iptocheck)
return
$isprivate
;
}
/*
* get_carp_interface_status($carpinterface): returns the status of a carp ip
*/
function
get_carp_interface_status
(
$carpinterface
)
{
$carp_query
=
""
;
/* XXX: Need to fidn a better way for this! */
list
(
$interface
,
$vhid
)
=
explode
(
"_vip"
,
$carpinterface
);
$interface
=
get_real_interface
(
$interface
);
exec
(
"/sbin/ifconfig
$interface
| /usr/bin/grep -v grep | /usr/bin/grep carp: | /usr/bin/grep 'vhid
{
$vhid
}
'"
,
$carp_query
);
foreach
(
$carp_query
as
$int
)
{
if
(
stristr
(
$int
,
"MASTER"
))
{
return
gettext
(
"MASTER"
);
}
elseif
(
stristr
(
$int
,
"BACKUP"
))
{
return
gettext
(
"BACKUP"
);
}
elseif
(
stristr
(
$int
,
"INIT"
))
{
return
gettext
(
"INIT"
);
}
}
return
;
}
/*
* restore_config_section($section_name, new_contents): restore a configuration section,
* and write the configuration out
...
...
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