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
b4329c84
Commit
b4329c84
authored
May 09, 2016
by
Franco Fichtner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
system: generate far routes for default gateways, fix style
parent
b3d14817
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
14 deletions
+24
-14
system.inc
src/etc/inc/system.inc
+24
-14
No files found.
src/etc/inc/system.inc
View file @
b4329c84
...
@@ -517,6 +517,8 @@ function system_routing_configure($interface = '')
...
@@ -517,6 +517,8 @@ function system_routing_configure($interface = '')
$gatewayipv6
=
""
;
$gatewayipv6
=
""
;
$interfacegwv6
=
""
;
$interfacegwv6
=
""
;
$foundgwv6
=
false
;
$foundgwv6
=
false
;
$fargw
=
false
;
/* tack on all the hard defined gateways as well */
/* tack on all the hard defined gateways as well */
if
(
isset
(
$config
[
'gateways'
][
'gateway_item'
]))
{
if
(
isset
(
$config
[
'gateways'
][
'gateway_item'
]))
{
array_map
(
'unlink'
,
glob
(
'/tmp/*_defaultgw{,v6}'
,
GLOB_BRACE
));
array_map
(
'unlink'
,
glob
(
'/tmp/*_defaultgw{,v6}'
,
GLOB_BRACE
));
...
@@ -529,6 +531,7 @@ function system_routing_configure($interface = '')
...
@@ -529,6 +531,7 @@ function system_routing_configure($interface = '')
if
(
$gateway
[
'gateway'
]
==
"dynamic"
)
{
if
(
$gateway
[
'gateway'
]
==
"dynamic"
)
{
$gateway
[
'gateway'
]
=
get_interface_gateway
(
$gateway
[
'interface'
]);
$gateway
[
'gateway'
]
=
get_interface_gateway
(
$gateway
[
'interface'
]);
}
}
$fargw
=
isset
(
$gateway
[
'fargw'
]);
$gatewayip
=
$gateway
[
'gateway'
];
$gatewayip
=
$gateway
[
'gateway'
];
$interfacegw
=
$gateway
[
'interface'
];
$interfacegw
=
$gateway
[
'interface'
];
if
(
!
empty
(
$gateway
[
'interface'
]))
{
if
(
!
empty
(
$gateway
[
'interface'
]))
{
...
@@ -542,6 +545,7 @@ function system_routing_configure($interface = '')
...
@@ -542,6 +545,7 @@ function system_routing_configure($interface = '')
if
(
$gateway
[
'gateway'
]
==
"dynamic"
)
{
if
(
$gateway
[
'gateway'
]
==
"dynamic"
)
{
$gateway
[
'gateway'
]
=
get_interface_gateway_v6
(
$gateway
[
'interface'
]);
$gateway
[
'gateway'
]
=
get_interface_gateway_v6
(
$gateway
[
'interface'
]);
}
}
$fargw
=
isset
(
$gateway
[
'fargw'
]);
$gatewayipv6
=
$gateway
[
'gateway'
];
$gatewayipv6
=
$gateway
[
'gateway'
];
$interfacegwv6
=
$gateway
[
'interface'
];
$interfacegwv6
=
$gateway
[
'interface'
];
if
(
!
empty
(
$gateway
[
'interface'
]))
{
if
(
!
empty
(
$gateway
[
'interface'
]))
{
...
@@ -574,22 +578,28 @@ function system_routing_configure($interface = '')
...
@@ -574,22 +578,28 @@ function system_routing_configure($interface = '')
if
(
!
empty
(
$interface
)
&&
$interface
!=
$interfacegw
)
if
(
!
empty
(
$interface
)
&&
$interface
!=
$interfacegw
)
;
;
elseif
(
is_ipaddrv4
(
$gatewayip
))
{
elseif
(
is_ipaddrv4
(
$gatewayip
))
{
log_error
(
"ROUTING: remove current default route to
$gatewayip
"
);
log_error
(
"ROUTING: setting IPv4 default route to
{
$gatewayip
}
"
);
mwexec
(
"/sbin/route delete default"
);
mwexecf
(
'/sbin/route delete -inet %s'
,
'default'
);
log_error
(
"ROUTING: setting default route to
$gatewayip
"
);
if
(
$fargw
)
{
mwexec
(
"/sbin/route add -inet default "
.
escapeshellarg
(
$gatewayip
));
mwexecf
(
'/sbin/route delete -inet %s -interface %s'
,
array
(
$gatewayip
,
$interfacegw
));
mwexecf
(
'/sbin/route add -inet %s -interface %s'
,
array
(
$gatewayip
,
$interfacegw
));
}
mwexecf
(
'/sbin/route add -inet %s %s'
,
array
(
'default'
,
$gatewayip
));
}
}
if
(
!
empty
(
$interface
)
&&
$interface
!=
$interfacegwv6
)
if
(
!
empty
(
$interface
)
&&
$interface
!=
$interfacegwv6
)
;
;
elseif
(
is_ipaddrv6
(
$gatewayipv6
))
{
elseif
(
is_ipaddrv6
(
$gatewayipv6
))
{
$ifscope
=
""
;
if
(
is_linklocal
(
$gatewayipv6
))
{
if
(
is_linklocal
(
$gatewayipv6
))
{
$ifscope
=
"%
{
$defaultifv6
}
"
;
$gatewayipv6
.=
"%
{
$defaultifv6
}
"
;
}
log_error
(
"ROUTING: setting IPv6 default route to
{
$gatewayipv6
}
"
);
mwexecf
(
'/sbin/route delete -inet6 %s %s'
,
array
(
'default'
,
$gatewayipv6
));
if
(
$fargw
)
{
mwexecf
(
'/sbin/route delete -inet6 %s -interface %s'
,
array
(
$gatewayipv6
,
$interfacegwv6
));
mwexecf
(
'/sbin/route add -inet6 %s -interface %s'
,
array
(
$gatewayipv6
,
$interfacegwv6
));
}
}
log_error
(
"ROUTING: setting IPv6 default route to
{
$gatewayipv6
}{
$ifscope
}
"
);
mwexecf
(
'/sbin/route add -inet6 %s %s'
,
array
(
'default'
,
$gatewayipv6
));
mwexec
(
"/sbin/route delete -inet6 default "
.
escapeshellarg
(
"
{
$gatewayipv6
}{
$ifscope
}
"
));
mwexec
(
"/sbin/route add -inet6 default "
.
escapeshellarg
(
"
{
$gatewayipv6
}{
$ifscope
}
"
));
}
}
system_staticroutes_configure
(
$interface
,
false
);
system_staticroutes_configure
(
$interface
,
false
);
...
@@ -716,15 +726,15 @@ function system_staticroutes_configure($interface = '', $update_dns = false)
...
@@ -716,15 +726,15 @@ function system_staticroutes_configure($interface = '', $update_dns = false)
$ip
.=
"/128"
;
$ip
.=
"/128"
;
}
}
$inet
=
(
is_subnetv6
(
$ip
)
?
"-inet6"
:
"-inet"
);
$inet
=
(
is_subnetv6
(
$ip
)
?
"-inet6"
:
"-inet"
);
$iface
=
$needs_iface
?
' -iface '
.
escapeshellarg
(
$interfacegw
)
.
' '
:
''
;
$iface
=
$needs_iface
?
' -i
nter
face '
.
escapeshellarg
(
$interfacegw
)
.
' '
:
''
;
$cmd
=
"
{
$inet
}
{
$blackhole
}
"
.
escapeshellarg
(
$ip
)
.
" "
;
$cmd
=
"
{
$inet
}
{
$blackhole
}
"
.
escapeshellarg
(
$ip
)
.
" "
;
if
(
is_subnet
(
$ip
))
{
if
(
is_subnet
(
$ip
))
{
if
(
is_ipaddr
(
$gatewayip
))
{
if
(
is_ipaddr
(
$gatewayip
))
{
mwexec
(
"/sbin/route delete"
.
$cmd
.
$iface
.
escapeshellarg
(
$gatewayip
)
);
mwexec
(
"/sbin/route delete"
.
$cmd
.
escapeshellarg
(
$gatewayip
)
.
$iface
);
mwexec
(
"/sbin/route add"
.
$cmd
.
$iface
.
escapeshellarg
(
$gatewayip
)
);
mwexec
(
"/sbin/route add"
.
$cmd
.
escapeshellarg
(
$gatewayip
)
.
$iface
);
}
elseif
(
!
empty
(
$interfacegw
))
{
}
elseif
(
!
empty
(
$interfacegw
))
{
mwexec
(
"/sbin/route delete"
.
$cmd
.
"-iface "
.
escapeshellarg
(
$interfacegw
));
mwexec
(
"/sbin/route delete"
.
$cmd
.
"-i
nter
face "
.
escapeshellarg
(
$interfacegw
));
mwexec
(
"/sbin/route add"
.
$cmd
.
"-iface "
.
escapeshellarg
(
$interfacegw
));
mwexec
(
"/sbin/route add"
.
$cmd
.
"-i
nter
face "
.
escapeshellarg
(
$interfacegw
));
}
}
}
}
}
}
...
...
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