Menu

#4020 xcatd Install Monitor bug - gethostbyaddr

2.8.4
pending
xcatd (11)
general
5
2014-03-31
2014-03-14
Jason
No

I've discovered a bug in the Install Monitor process which causes extra iterations of the call to getNodeDomains.
The issue is that gethostbyaddr returns an array containing ($name,$aliases,$addrtype,$length,@addrs) which all get put into the @clients array.

This is what ends up in the @clients array:
$VAR1 =
'c101n69.xyz.com',
'',
2,
4,
'¬e'
;

Only the 1st array element from gethostbyaddr should be added to the @clients array.
And actually, for this call, there will only ever be 1 client in the array since this chunk of code is ran on a per connection basis.

An quick fix would be:
@clients = gethostbyaddr($conn->peeraddr,AF_INET6);
@clients = ( $clients[0] );

Attached is the TRACE output of a node connecting with updateflag.awk $SERVICENODE 3002 "installstatus booted"

Here is the chunk of code from xcatd (with TRACE_LINE comments):

:::perl
#  until ($quit) {
#    $SIG{ALRM} = sub { xCAT::MsgUtils->message("S","XCATTIMEOUT"); die; };
#    my $conn;
#    next unless $conn = $socket->accept;
### TRACE_LINE print "Install Montior: Got a connection!\n";
### TRACE_LINE print Dumper(\$conn);
#my @clients;
#if ($inet6support) {
#    @clients = gethostbyaddr($conn->peeraddr,AF_INET6);
#    unless (@clients) { @clients =  gethostbyaddr($conn->peeraddr,AF_INET); }
#} else {
### TRACE_LINE print "PeerAddr: ",$conn->peeraddr,AF_INET,"\n";
### TRACE_LINE print "Getting \@clients\n";
#    ## TRACE_LINE print Dumper(\@clients);
#    @clients = gethostbyaddr($conn->peeraddr,AF_INET);    
### TRACE_LINE print "Done geting \@clients : \n";
### TRACE_LINE print Dumper(\@clients);
#}
#
#        my $validclient=0;
#        my $node;
#        my $domain;
#
#        ## TRACE_LINE print "Calling xCAT::NetworkUtils->getNodeDomains..\n";
#        my $nd = xCAT::NetworkUtils->getNodeDomains(\@clients);
#        ## TRACE_LINE print "Returned from  xCAT::NetworkUtils->getNodeDomains..\n";
#        my %nodedomains = %{$nd};
#        foreach my $client (@clients) {
#                ## TRACE_LINE print "Forloop client=$client\n";
#                $domain = $nodedomains{$client};
#                $client =~ s/\..*//;
#                if ($domain) {
#                        $client =~ s/\.$domain//;
#                } else {
#                        $client =~ s/\..*//;
#                }
#               #ensure this is coming from a node IP at least
#                ($node) = noderange($client);
#                if ($node) {  #Means the source isn't valid
#                        $validclient=1;
#                        last;
#                }
#        }

It may also be a good idea to verify this bug doesn't exists in any other functions calling gethostbyaddr
For small xcat deployments, this bug has very little impact, but with larger deployments the extra overhead can add up quickly when site.nodestatus=1 and a large number of nodes are booted at once.

1 Attachments

Discussion

  • Lissa Valletta

    Lissa Valletta - 2014-03-14

    What level of xCAT are your running?

     
    • Jason

      Jason - 2014-03-14

      This is on xCat 2.8.3

       
  • Lissa Valletta

    Lissa Valletta - 2014-03-14
    • labels: --> xcatd
    • assigned_to: Jarrod Johnson
    • Milestones: 2.9 --> 2.8.4
     
  • Lissa Valletta

    Lissa Valletta - 2014-03-24

    Linda could you look into this

     
  • Lissa Valletta

    Lissa Valletta - 2014-03-24
    • assigned_to: Jarrod Johnson --> Linda Mellor
     
  • Anonymous

    Anonymous - 2014-03-25
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -22,6 +22,7 @@
    
    
     Here is the chunk of code from xcatd (with TRACE_LINE comments):
    +~~~~
     :::perl
     #  until ($quit) {
     #    $SIG{ALRM} = sub { xCAT::MsgUtils->message("S","XCATTIMEOUT"); die; };
    @@ -66,7 +67,7 @@
     #                        last;
     #                }
     #        }
    -
    +~~~~
    
     It may also be a good idea to verify this bug doesn't exists in any other functions calling gethostbyaddr 
     For small xcat deployments, this bug has very little impact, but with larger deployments the extra overhead can add up quickly when  site.nodestatus=1 and a large number of nodes are booted at once.
    
     
  • Anonymous

    Anonymous - 2014-03-31

    I've taken a closer look at this code. My guess is that the @clients array was originally implemented to also handle aliases, but even that is not coded correctly if there is more than one alias defined for the node. I will fix this.

    Also, I did grep the rest of xCAT for uses of gethostbyaddr, and this is the only place that an array is used to capture the results.

     
  • Anonymous

    Anonymous - 2014-03-31
    • status: open --> accepted
     
  • Anonymous

    Anonymous - 2014-03-31
    • status: accepted --> pending
     
  • Anonymous

    Anonymous - 2014-03-31

    Fix checked in.

    xCAT 2.8.4 a3b09614f651e71dbcf03bb26635d1ae415151b2
    xCAT 2.9 (master) a698e1757d6f77eb8df224ac3f780f6df42342a9

     
MongoDB Logo MongoDB