summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRenato Botelho <renato@netgate.com>2016-01-11 15:53:10 -0200
committerRenato Botelho <renato@netgate.com>2016-01-11 18:20:22 -0200
commit12ca72bae9edf94bb9fef8466fa01c4354444123 (patch)
treec9c645758ca2189361fd23db64dc9db7e34e7217 /src
parent64fa3cf79b99fb6f3cd845f4699b82ac8fe9ac6a (diff)
downloadpfsense-12ca72bae9edf94bb9fef8466fa01c4354444123.zip
pfsense-12ca72bae9edf94bb9fef8466fa01c4354444123.tar.gz
Rework a bit interface_mtu_wanted_for_pppoe(), no functional changes
Diffstat (limited to 'src')
-rw-r--r--src/etc/inc/interfaces.inc64
1 files changed, 36 insertions, 28 deletions
diff --git a/src/etc/inc/interfaces.inc b/src/etc/inc/interfaces.inc
index 49fd2ca..2e1fce5 100644
--- a/src/etc/inc/interfaces.inc
+++ b/src/etc/inc/interfaces.inc
@@ -3089,37 +3089,45 @@ function interface_mtu_wanted_for_pppoe($realif) {
$mtu = 0;
- if (is_array($config['ppps']) && is_array($config['ppps']['ppp'])) {
- foreach ($config['ppps']['ppp'] as $ppp) {
- if ($ppp['type'] == "pppoe") {
- $ports = explode(',',$ppp['ports']);
- $mtu_wanted = 1500;
- foreach ($ports as $pid => $port) {
- if (get_real_interface($port) == $realif) {
- // use the MTU configured on the interface ...
- if (is_array($config['interfaces'])) {
- foreach ($config['interfaces'] as $interface) {
- if ($interface['if'] != $ppp['if']) {
- continue;
- }
- if (!empty($interface['mtu'])) {
- $mtu_wanted = intval($interface['mtu']) + 8;
- }
- }
- }
- // ... unless there is an MTU configured on the port in question
- if (!empty($ppp['mtu'])) {
- $mtus = explode(',',$ppp['mtu']);
- if (!empty($mtus[$pid])) {
- $mtu_wanted = intval($mtus[$pid]) + 8;
- }
- }
- if ($mtu_wanted > $mtu) {
- $mtu = $mtu_wanted;
- }
+ if (!is_array($config['ppps']) || !is_array($config['ppps']['ppp'])) {
+ return $mtu;
+ }
+
+ foreach ($config['ppps']['ppp'] as $ppp) {
+ if ($ppp['type'] != "pppoe") {
+ continue;
+ }
+
+ $ports = explode(',',$ppp['ports']);
+ $mtu_wanted = 1500;
+ foreach ($ports as $pid => $port) {
+ if (get_real_interface($port) != $realif) {
+ continue;
+ }
+
+ if (!empty($ppp['mtu'])) {
+ $mtus = explode(',',$ppp['mtu']);
+ } else {
+ $mtus == array();
+ }
+ // there is an MTU configured on the port in question
+ if (!empty($mtus[$pid])) {
+ $mtu_wanted = intval($mtus[$pid]) + 8;
+ // or use the MTU configured on the interface ...
+ } elseif (is_array($config['interfaces'])) {
+ foreach ($config['interfaces'] as $interface) {
+ if ($interface['if'] == $ppp['if'] &&
+ !empty($interface['mtu'])) {
+ $mtu_wanted = intval($interface['mtu']) + 8;
+ break;
}
}
}
+ unset($mtus);
+
+ if ($mtu_wanted > $mtu) {
+ $mtu = $mtu_wanted;
+ }
}
}
OpenPOWER on IntegriCloud