mirror of
https://gitlab.com/shorewall/code.git
synced 2025-02-13 16:30:32 +01:00
Use a function to generate the list of interfaces with an L3 address
This commit is contained in:
parent
57c54af6ed
commit
c18d206726
@ -859,17 +859,15 @@ sub handle_optional_interfaces( $ ) {
|
||||
emit( join( '_', 'SW', uc chain_base( get_physical( $_ ) ) , 'IS_USABLE=' ) ) for @$interfaces;
|
||||
|
||||
if ( $wildcards ) {
|
||||
#
|
||||
# We must consider all interfaces with an address in $family -- generate a list of such addresses.
|
||||
#
|
||||
emit( '',
|
||||
'interfaces=$($IP -' . $family . ' addr list | egrep \'^[[:digit:]]+\' | while read number interface rest; do echo ${interface%:}; done)',
|
||||
'',
|
||||
'for interface in $interfaces; do'
|
||||
'for interface in $(find_all_interfaces1); do',
|
||||
);
|
||||
|
||||
push_indent;
|
||||
|
||||
emit ( 'case "$interface" in'
|
||||
);
|
||||
|
||||
emit ( 'case "$interface" in' );
|
||||
push_indent;
|
||||
} else {
|
||||
emit '';
|
||||
@ -881,9 +879,7 @@ sub handle_optional_interfaces( $ ) {
|
||||
my $base = uc chain_base( $physical );
|
||||
my $providerref = $providers{$provider};
|
||||
|
||||
emit( "$physical)" ) if $wildcards;
|
||||
|
||||
push_indent;
|
||||
emit( "$physical)" ), push_indent if $wildcards;
|
||||
|
||||
if ( $providerref->{gatewaycase} eq 'detect' ) {
|
||||
emit qq(if interface_is_usable $physical && [ -n "$providerref->{gateway}" ]; then);
|
||||
@ -909,7 +905,6 @@ sub handle_optional_interfaces( $ ) {
|
||||
emit( "$case)" );
|
||||
push_indent;
|
||||
|
||||
|
||||
if ( $wild ) {
|
||||
emit( qq(if [ -z "\$SW_${base}_IS_USABLE" ]; then) );
|
||||
push_indent;
|
||||
@ -922,7 +917,6 @@ sub handle_optional_interfaces( $ ) {
|
||||
}
|
||||
|
||||
emit ( ' HAVE_INTERFACE=Yes' ) if $require;
|
||||
|
||||
emit ( " SW_${base}_IS_USABLE=Yes" ,
|
||||
'fi' );
|
||||
|
||||
@ -934,6 +928,10 @@ sub handle_optional_interfaces( $ ) {
|
||||
}
|
||||
|
||||
if ( $wildcards ) {
|
||||
emit( '*)' ,
|
||||
' ;;'
|
||||
);
|
||||
pop_indent;
|
||||
emit( 'esac' );
|
||||
pop_indent;
|
||||
emit('done' );
|
||||
|
@ -1429,16 +1429,16 @@ sub verify_required_interfaces( $ ) {
|
||||
|
||||
$physical =~ s/\+$/*/;
|
||||
|
||||
emit( "${base}_IS_UP=\n",
|
||||
emit( "SW_${base}_IS_UP=\n",
|
||||
'for interface in $(find_all_interfaces); do',
|
||||
' case $interface in',
|
||||
" $physical)",
|
||||
" interface_is_usable \$interface && ${base}_IS_UP=Yes && break",
|
||||
" interface_is_usable \$interface && SW_${base}_IS_UP=Yes && break",
|
||||
' ;;',
|
||||
' esac',
|
||||
'done',
|
||||
'',
|
||||
"if [ -z \"\$${base}_IS_UP\" ]; then",
|
||||
"if [ -z \"\$SW_${base}_IS_UP\" ]; then",
|
||||
" startup_error \"None of the required interfaces $physical are available\"",
|
||||
"fi\n"
|
||||
);
|
||||
|
@ -124,7 +124,14 @@ deleteallchains() {
|
||||
# Generate a list of all network interfaces on the system
|
||||
#
|
||||
find_all_interfaces() {
|
||||
${IP:-ip} link list | egrep '^[[:digit:]]+:' | cut -d ' ' -f2 | sed 's/:$//'
|
||||
${IP:-ip} link list | egrep '^[[:digit:]]+:' | cut -d ' ' -f2 | sed -r 's/(@.*)?:$//'
|
||||
}
|
||||
|
||||
#
|
||||
# Generate a list of all network interfaces on the system that have an ipv4 address
|
||||
#
|
||||
find_all_interfaces1() {
|
||||
${IP:-ip} -4 addr list | egrep '^[[:digit:]]+:' | cut -d ' ' -f2 | sed -r 's/(@.*)?:$//'
|
||||
}
|
||||
|
||||
#
|
||||
|
@ -116,7 +116,14 @@ deleteallchains() {
|
||||
# Generate a list of all network interfaces on the system
|
||||
#
|
||||
find_all_interfaces() {
|
||||
${IP:-ip} link list | egrep '^[[:digit:]]+:' | cut -d ' ' -f2 | sed 's/:$//'
|
||||
${IP:-ip} link list | egrep '^[[:digit:]]+:' | cut -d ' ' -f2 | sed -r 's/(@.*)?:$//'
|
||||
}
|
||||
|
||||
#
|
||||
# Generate a list of all network interfaces on the system that have an ipv6 address
|
||||
#
|
||||
find_all_interfaces1() {
|
||||
${IP:-ip} -6 addr list | egrep '^[[:digit:]]+:' | cut -d ' ' -f2 | sed -r 's/(@.*)?:$//'
|
||||
}
|
||||
|
||||
#
|
||||
|
Loading…
Reference in New Issue
Block a user