mirror of
https://gitlab.com/shorewall/code.git
synced 2025-01-09 15:18:12 +01:00
Add 'wait' interface option
Signed-off-by: Tom Eastep <teastep@shorewall.net>
This commit is contained in:
parent
16e451a7d8
commit
88188202cc
@ -181,9 +181,9 @@ use constant { SIMPLE_IF_OPTION => 1,
|
|||||||
|
|
||||||
our %validinterfaceoptions;
|
our %validinterfaceoptions;
|
||||||
|
|
||||||
our %defaultinterfaceoptions = ( routefilter => 1 );
|
our %defaultinterfaceoptions = ( routefilter => 1 , wait => 60 );
|
||||||
|
|
||||||
our %maxoptionvalue = ( routefilter => 2, mss => 100000 );
|
our %maxoptionvalue = ( routefilter => 2, mss => 100000 , wait => 120 );
|
||||||
|
|
||||||
our %validhostoptions;
|
our %validhostoptions;
|
||||||
|
|
||||||
@ -233,6 +233,7 @@ sub initialize( $ ) {
|
|||||||
upnpclient => SIMPLE_IF_OPTION,
|
upnpclient => SIMPLE_IF_OPTION,
|
||||||
mss => NUMERIC_IF_OPTION,
|
mss => NUMERIC_IF_OPTION,
|
||||||
physical => STRING_IF_OPTION + IF_OPTION_HOST,
|
physical => STRING_IF_OPTION + IF_OPTION_HOST,
|
||||||
|
wait => NUMERIC_IF_OPTION,
|
||||||
);
|
);
|
||||||
%validhostoptions = (
|
%validhostoptions = (
|
||||||
blacklist => 1,
|
blacklist => 1,
|
||||||
@ -260,6 +261,7 @@ sub initialize( $ ) {
|
|||||||
mss => NUMERIC_IF_OPTION,
|
mss => NUMERIC_IF_OPTION,
|
||||||
forward => BINARY_IF_OPTION,
|
forward => BINARY_IF_OPTION,
|
||||||
physical => STRING_IF_OPTION + IF_OPTION_HOST,
|
physical => STRING_IF_OPTION + IF_OPTION_HOST,
|
||||||
|
wait => NUMERIC_IF_OPTION,
|
||||||
);
|
);
|
||||||
%validhostoptions = (
|
%validhostoptions = (
|
||||||
blacklist => 1,
|
blacklist => 1,
|
||||||
@ -1175,11 +1177,38 @@ sub set_interface_option( $$$ ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
# Verify that all required interfaces are available
|
# Verify that all required interfaces are available after waiting for any that specify the 'wait' option.
|
||||||
#
|
#
|
||||||
sub verify_required_interfaces() {
|
sub verify_required_interfaces() {
|
||||||
|
|
||||||
my $interfaces = find_interfaces_by_option 'required';
|
my $returnvalue = 0;
|
||||||
|
|
||||||
|
my $interfaces = find_interfaces_by_option 'wait';
|
||||||
|
|
||||||
|
if ( @$interfaces ) {
|
||||||
|
for my $interface (@$interfaces ) {
|
||||||
|
my $wait = $interfaces{$interface}{options}{wait};
|
||||||
|
|
||||||
|
if ( $wait ) {
|
||||||
|
my $physical = get_physical $interface;
|
||||||
|
|
||||||
|
emit qq(if ! interface_is_usable $physical; then);
|
||||||
|
emit q( local waittime);
|
||||||
|
emit qq( waittime=$wait);
|
||||||
|
emit '';
|
||||||
|
emit q( while [ $waittime -gt 0 ]; do);
|
||||||
|
emit qq( interface_is_usable $physical && break);
|
||||||
|
emit q( sleep 1);
|
||||||
|
emit ' $waittime=$(($waittime - 1))';
|
||||||
|
emit q( done);
|
||||||
|
emit qq(fi\n);
|
||||||
|
|
||||||
|
$returnvalue = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$interfaces = find_interfaces_by_option 'required';
|
||||||
|
|
||||||
if ( @$interfaces ) {
|
if ( @$interfaces ) {
|
||||||
for my $interface (@$interfaces ) {
|
for my $interface (@$interfaces ) {
|
||||||
@ -1190,8 +1219,10 @@ sub verify_required_interfaces() {
|
|||||||
emit qq(fi\n);
|
emit qq(fi\n);
|
||||||
}
|
}
|
||||||
|
|
||||||
1;
|
$returnvalue = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$returnvalue;
|
||||||
}
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@ -114,6 +114,8 @@ loc eth2 -</programlisting>
|
|||||||
<member>sourceroute</member>
|
<member>sourceroute</member>
|
||||||
|
|
||||||
<member>upnp</member>
|
<member>upnp</member>
|
||||||
|
|
||||||
|
<member>wait</member>
|
||||||
</simplelist>
|
</simplelist>
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
@ -598,6 +600,17 @@ loc eth2 -</programlisting>
|
|||||||
this option at your own risk.</para>
|
this option at your own risk.</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term><emphasis
|
||||||
|
role="bold">wait</emphasis>=<emphasis>seconds</emphasis></term>
|
||||||
|
|
||||||
|
<listitem>
|
||||||
|
<para>Added in Shorewall 4.4.10. Causes the generated script
|
||||||
|
to wait up to <emphasis>seconds</emphasis> seconds before
|
||||||
|
applying the required or optional options.</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
</variablelist>
|
</variablelist>
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
@ -293,6 +293,17 @@ loc eth2 -</programlisting>
|
|||||||
value is given.</para>
|
value is given.</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term><emphasis
|
||||||
|
role="bold">wait</emphasis>=<emphasis>seconds</emphasis></term>
|
||||||
|
|
||||||
|
<listitem>
|
||||||
|
<para>Added in Shorewall 4.4.10. Causes the generated script
|
||||||
|
to wait up to <emphasis>seconds</emphasis> seconds before
|
||||||
|
applying the required or optional options.</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
</variablelist>
|
</variablelist>
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
Loading…
Reference in New Issue
Block a user