mirror of
https://gitlab.com/shorewall/code.git
synced 2025-06-20 09:47:51 +02: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;
|
emit( join( '_', 'SW', uc chain_base( get_physical( $_ ) ) , 'IS_USABLE=' ) ) for @$interfaces;
|
||||||
|
|
||||||
if ( $wildcards ) {
|
if ( $wildcards ) {
|
||||||
|
#
|
||||||
|
# We must consider all interfaces with an address in $family -- generate a list of such addresses.
|
||||||
|
#
|
||||||
emit( '',
|
emit( '',
|
||||||
'interfaces=$($IP -' . $family . ' addr list | egrep \'^[[:digit:]]+\' | while read number interface rest; do echo ${interface%:}; done)',
|
'for interface in $(find_all_interfaces1); do',
|
||||||
'',
|
|
||||||
'for interface in $interfaces; do'
|
|
||||||
);
|
);
|
||||||
|
|
||||||
push_indent;
|
push_indent;
|
||||||
|
emit ( 'case "$interface" in' );
|
||||||
emit ( 'case "$interface" in'
|
|
||||||
);
|
|
||||||
|
|
||||||
push_indent;
|
push_indent;
|
||||||
} else {
|
} else {
|
||||||
emit '';
|
emit '';
|
||||||
@ -881,9 +879,7 @@ sub handle_optional_interfaces( $ ) {
|
|||||||
my $base = uc chain_base( $physical );
|
my $base = uc chain_base( $physical );
|
||||||
my $providerref = $providers{$provider};
|
my $providerref = $providers{$provider};
|
||||||
|
|
||||||
emit( "$physical)" ) if $wildcards;
|
emit( "$physical)" ), push_indent if $wildcards;
|
||||||
|
|
||||||
push_indent;
|
|
||||||
|
|
||||||
if ( $providerref->{gatewaycase} eq 'detect' ) {
|
if ( $providerref->{gatewaycase} eq 'detect' ) {
|
||||||
emit qq(if interface_is_usable $physical && [ -n "$providerref->{gateway}" ]; then);
|
emit qq(if interface_is_usable $physical && [ -n "$providerref->{gateway}" ]; then);
|
||||||
@ -909,7 +905,6 @@ sub handle_optional_interfaces( $ ) {
|
|||||||
emit( "$case)" );
|
emit( "$case)" );
|
||||||
push_indent;
|
push_indent;
|
||||||
|
|
||||||
|
|
||||||
if ( $wild ) {
|
if ( $wild ) {
|
||||||
emit( qq(if [ -z "\$SW_${base}_IS_USABLE" ]; then) );
|
emit( qq(if [ -z "\$SW_${base}_IS_USABLE" ]; then) );
|
||||||
push_indent;
|
push_indent;
|
||||||
@ -922,7 +917,6 @@ sub handle_optional_interfaces( $ ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
emit ( ' HAVE_INTERFACE=Yes' ) if $require;
|
emit ( ' HAVE_INTERFACE=Yes' ) if $require;
|
||||||
|
|
||||||
emit ( " SW_${base}_IS_USABLE=Yes" ,
|
emit ( " SW_${base}_IS_USABLE=Yes" ,
|
||||||
'fi' );
|
'fi' );
|
||||||
|
|
||||||
@ -934,6 +928,10 @@ sub handle_optional_interfaces( $ ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ( $wildcards ) {
|
if ( $wildcards ) {
|
||||||
|
emit( '*)' ,
|
||||||
|
' ;;'
|
||||||
|
);
|
||||||
|
pop_indent;
|
||||||
emit( 'esac' );
|
emit( 'esac' );
|
||||||
pop_indent;
|
pop_indent;
|
||||||
emit('done' );
|
emit('done' );
|
||||||
|
@ -1429,16 +1429,16 @@ sub verify_required_interfaces( $ ) {
|
|||||||
|
|
||||||
$physical =~ s/\+$/*/;
|
$physical =~ s/\+$/*/;
|
||||||
|
|
||||||
emit( "${base}_IS_UP=\n",
|
emit( "SW_${base}_IS_UP=\n",
|
||||||
'for interface in $(find_all_interfaces); do',
|
'for interface in $(find_all_interfaces); do',
|
||||||
' case $interface in',
|
' case $interface in',
|
||||||
" $physical)",
|
" $physical)",
|
||||||
" interface_is_usable \$interface && ${base}_IS_UP=Yes && break",
|
" interface_is_usable \$interface && SW_${base}_IS_UP=Yes && break",
|
||||||
' ;;',
|
' ;;',
|
||||||
' esac',
|
' esac',
|
||||||
'done',
|
'done',
|
||||||
'',
|
'',
|
||||||
"if [ -z \"\$${base}_IS_UP\" ]; then",
|
"if [ -z \"\$SW_${base}_IS_UP\" ]; then",
|
||||||
" startup_error \"None of the required interfaces $physical are available\"",
|
" startup_error \"None of the required interfaces $physical are available\"",
|
||||||
"fi\n"
|
"fi\n"
|
||||||
);
|
);
|
||||||
|
@ -124,7 +124,14 @@ deleteallchains() {
|
|||||||
# Generate a list of all network interfaces on the system
|
# Generate a list of all network interfaces on the system
|
||||||
#
|
#
|
||||||
find_all_interfaces() {
|
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
|
# Generate a list of all network interfaces on the system
|
||||||
#
|
#
|
||||||
find_all_interfaces() {
|
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…
x
Reference in New Issue
Block a user