Skip to content

Commit

Permalink
findif.sh: dont use table parameter as it returns no netmask (tested …
Browse files Browse the repository at this point in the history
…with main/local/custom tables)
  • Loading branch information
oalbrigt committed Oct 5, 2023
1 parent c33c416 commit cf2fd2a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 16 deletions.
12 changes: 0 additions & 12 deletions heartbeat/IPaddr2
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ OCF_RESKEY_ip_default=""
OCF_RESKEY_cidr_netmask_default=""
OCF_RESKEY_broadcast_default=""
OCF_RESKEY_iflabel_default=""
OCF_RESKEY_table_default=""
OCF_RESKEY_cidr_netmask_default=""
OCF_RESKEY_lvs_support_default=false
OCF_RESKEY_lvs_ipv6_addrlabel_default=false
Expand All @@ -98,7 +97,6 @@ OCF_RESKEY_network_namespace_default=""
: ${OCF_RESKEY_cidr_netmask=${OCF_RESKEY_cidr_netmask_default}}
: ${OCF_RESKEY_broadcast=${OCF_RESKEY_broadcast_default}}
: ${OCF_RESKEY_iflabel=${OCF_RESKEY_iflabel_default}}
: ${OCF_RESKEY_table=${OCF_RESKEY_table_default}}
: ${OCF_RESKEY_lvs_support=${OCF_RESKEY_lvs_support_default}}
: ${OCF_RESKEY_lvs_ipv6_addrlabel=${OCF_RESKEY_lvs_ipv6_addrlabel_default}}
: ${OCF_RESKEY_lvs_ipv6_addrlabel_value=${OCF_RESKEY_lvs_ipv6_addrlabel_value_default}}
Expand Down Expand Up @@ -241,16 +239,6 @@ If a label is specified in nic name, this parameter has no effect.
<content type="string" default="${OCF_RESKEY_iflabel_default}"/>
</parameter>
<parameter name="table">
<longdesc lang="en">
Table to use to lookup which interface to use for the IP.
This can be used for policy based routing. See man ip-rule(8).
</longdesc>
<shortdesc lang="en">Table</shortdesc>
<content type="string" default="${OCF_RESKEY_table_default}" />
</parameter>
<parameter name="lvs_support">
<longdesc lang="en">
Enable support for LVS Direct Routing configurations. In case a IP
Expand Down
8 changes: 4 additions & 4 deletions heartbeat/findif.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ prefixcheck() {
getnetworkinfo()
{
local line netinfo
ip -o -f inet route list match $OCF_RESKEY_ip table "${OCF_RESKEY_table:=main}" scope host | (while read line;
ip -o -f inet route list match $OCF_RESKEY_ip scope host | (while read line;
do
netinfo=`echo $line | awk '{print $2}'`
case $netinfo in
Expand Down Expand Up @@ -210,14 +210,14 @@ findif()
fi
findif_check_params $family || return $?

if [ -n "$netmask" ] ; then
if [ -n "$netmask" ]; then
match=$match/$netmask
fi
if [ -n "$nic" ] ; then
# NIC supports more than two.
set -- $(ip -o -f $family route list match $match $scope table "${OCF_RESKEY_table:=main}" | grep "dev $nic " | awk 'BEGIN{best=0} /\// { mask=$1; sub(".*/", "", mask); if( int(mask)>=best ) { best=int(mask); best_ln=$0; } } END{print best_ln}')
set -- $(ip -o -f $family route list match $match $scope | grep "dev $nic " | awk 'BEGIN{best=0} /\// { mask=$1; sub(".*/", "", mask); if( int(mask)>=best ) { best=int(mask); best_ln=$0; } } END{print best_ln}')
else
set -- $(ip -o -f $family route list match $match $scope table "${OCF_RESKEY_table:=main}" | awk 'BEGIN{best=0} /\// { mask=$1; sub(".*/", "", mask); if( int(mask)>=best ) { best=int(mask); best_ln=$0; } } END{print best_ln}')
set -- $(ip -o -f $family route list match $match $scope | awk 'BEGIN{best=0} /\// { mask=$1; sub(".*/", "", mask); if( int(mask)>=best ) { best=int(mask); best_ln=$0; } } END{print best_ln}')
fi
if [ $# = 0 ] ; then
case $OCF_RESKEY_ip in
Expand Down

0 comments on commit cf2fd2a

Please sign in to comment.