interfaces: add ifctl -r and -p for router and prefix files

We add this here to ensure consistency between the functionalities
of these interface helper files.  Not all instances have been
converted, but they can be as time permits.  Tested on IPv6.

While here settle on "prefix" for pdinfo as a thing since we
renamed it already anyway.
This commit is contained in:
Franco Fichtner 2022-03-11 15:16:49 +01:00
parent 2d040c8968
commit c39ef68e58
4 changed files with 19 additions and 19 deletions

View File

@ -958,7 +958,7 @@ function interface_bring_down($interface = "wan", $ifacecfg = false)
/* clear stale state files associated with this interface */
@unlink("/tmp/{$realifv6}_nameserverv6");
@unlink("/tmp/{$realifv6}_pdinfov6");
@unlink("/tmp/{$realifv6}_prefixv6");
@unlink("/tmp/{$realifv6}_routerv6");
@unlink("/tmp/{$realifv6}_searchdomainv6");
@unlink("/tmp/{$realif}_nameserver");
@ -2771,25 +2771,20 @@ fi
case \$REASON in
REQUEST)
/usr/bin/logger -t dhcp6c "dhcp6c \$REASON on {$wanif} - running newipv6"
if [ -n "\${PDINFO}" ]; then
echo \${PDINFO} > /tmp/{$wanif}_pdinfov6
else
rm -f /tmp/{$wanif}_pdinfov6
fi
ARGS="-i ${wanif} -6nd"
for NAMESERVER in \${new_domain_name_servers}; do
ARGS="\${ARGS} -a \${NAMESERVER}"
done
/usr/local/sbin/ifctl \${ARGS}
ARGS="-i ${wanif} -6sd \${new_domain_name:+"-a \${new_domain_name}"}"
/usr/local/sbin/ifctl \${ARGS}
/usr/local/sbin/ifctl -i ${wanif} -6sd \${new_domain_name:+"-a \${new_domain_name}"}
/usr/local/sbin/ifctl -i ${wanif} -6pd \${PDINFO:+"-a \${PDINFO}"}
/usr/local/sbin/configctl -d interface newipv6 {$wanif}
;;
EXIT|RELEASE)
/usr/bin/logger -t dhcp6c "dhcp6c \$REASON on {$wanif} - running newipv6"
/usr/local/sbin/ifctl -i ${wanif} -6nd
/usr/local/sbin/ifctl -i ${wanif} -6sd
rm -f /tmp/{$wanif}_pdinfov6
/usr/local/sbin/ifctl -i ${wanif} -6pd
/usr/local/sbin/configctl -d interface newipv6 {$wanif}
;;
*)
@ -2844,9 +2839,9 @@ if [ -z "\${1}" ]; then
exit 0
fi
if [ -n "\${2}" ]; then
echo \${2} > /tmp/\${1}_routerv6
echo \${2} > /tmp/\${1}_defaultgwv6
fi
/usr/local/sbin/ifctl -i \${1} -6rd \${2:+"-a \${2}"}
if [ -f /var/run/dhcp6c.pid ]; then
if ! /bin/pkill -0 -F /var/run/dhcp6c.pid; then
rm -f /var/run/dhcp6c.pid
@ -3919,9 +3914,9 @@ function get_interfaces_info($include_unlinked = false)
}
/* XXX there are more magic files */
$aux = @file_get_contents("/tmp/{$ifinfo['ifv6']}_pdinfov6");
$aux = @file_get_contents("/tmp/{$ifinfo['ifv6']}_prefixv6");
if (!empty($aux)) {
$ifinfo['pdinfo'] = $aux;
$ifinfo['prefixv6'] = $aux;
}
$ifinfotmp = $all_intf_stats[$ifinfo['if']];

View File

@ -219,12 +219,9 @@ add_new_resolv_conf() {
for nameserver in ${new_domain_name_servers}; do
ARGS="${ARGS} -a ${nameserver}"
done
/usr/local/sbin/ifctl ${ARGS}
ARGS="-i ${interface} -4sd ${new_domain_name:+"-a ${new_domain_name}"}"
/usr/local/sbin/ifctl ${ARGS}
/usr/local/sbin/ifctl -i ${interface} -4sd ${new_domain_name:+"-a ${new_domain_name}"}
return 0
}

View File

@ -48,7 +48,7 @@ IF=
# default to IPv4 with nameserver mode
set -- -4 -n ${@}
while getopts 46a:di:ns OPT; do
while getopts 46a:di:nprs OPT; do
case ${OPT} in
4)
AF=inet
@ -71,6 +71,14 @@ while getopts 46a:di:ns OPT; do
DO_MODE="-n"
MD="nameserver"
;;
p)
DO_MODE="-p"
MD="prefix"
;;
r)
DO_MODE="-r"
MD="router"
;;
s)
DO_MODE="-s"
MD="searchdomain"

View File

@ -296,10 +296,10 @@ include("head.inc");
</td>
</tr>
<?php endif ?>
<?php if (array_key_exists('pdinfo', $ifinfo)): ?>
<?php if (array_key_exists('prefixv6', $ifinfo)): ?>
<tr>
<td><?= gettext('IPv6 delegated prefix') ?></td>
<td><?= $ifinfo['pdinfo'] ?></td>
<td><?= $ifinfo['prefixv6'] ?></td>
</tr>
<?php endif ?>
<?php if (!empty($ifinfo['gatewayv6'])): ?>