Changeset 194 for trunk/klask


Ignore:
Timestamp:
Jan 4, 2017, 9:34:36 PM (7 years ago)
Author:
g7moreau
Message:
  • Use 'ip neigh show' to replace old 'arp -a'. Less command, les dns resolution. Faster code...
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/klask

    r190 r194  
    258258      }
    259259
    260    # resultat de la commande arp
    261    # tech7meylan.hmg.inpg.fr (194.254.66.240) at 00:14:22:45:28:A9 [ether] on eth0
    262    # sw2-batF0-legi.hmg.priv (192.168.22.112) at 00:30:c1:76:9c:01 [ether] on eth0.37
    263    my $cmd_arp  = shell_command "arp -a $param_ip_or_host -i $ret{interface}";
    264    if ( $cmd_arp =~ m{ (\S*) \s \( ( $RE_IPv4_ADDRESS ) \) \s at \s ( $RE_MAC_ADDRESS ) }xms ) {
    265       ( $ret{hostname_fq}, $ret{ipv4_address}, $ret{mac_address} )  = ($1, $2, $3);
     260   # ARP result
     261   #
     262   # LANG=C arp -a 194.254.66.62 -i eth331
     263   # gw66-62.legi.grenoble-inp.fr (194.254.66.62) at 00:08:7c:bb:0f:c0 [ether] on eth331
     264   #
     265   # LANG=C ip neigh show to 194.254.66.62 dev eth331
     266   # 194.254.66.62 lladdr 00:08:7c:bb:0f:c0 REACHABLE
     267#   my $cmd_arp  = shell_command "arp -a $param_ip_or_host -i $ret{interface}";
     268#   if ( $cmd_arp =~ m{ (\S*) \s \( ( $RE_IPv4_ADDRESS ) \) \s at \s ( $RE_MAC_ADDRESS ) }xms ) {
     269#      ( $ret{hostname_fq}, $ret{ipv4_address}, $ret{mac_address} )  = ($1, $2, $3);
     270#      }
     271   if ($ret{mac_address} eq 'unknow') {
     272      # Another chance to have mac_address
     273      my $cmd_arp  = shell_command "ip neigh show to $ret{ipv4_address} dev $ret{interface}";
     274      if ( $cmd_arp =~ m{ ^$RE_IPv4_ADDRESS \s lladdr \s ( $RE_MAC_ADDRESS ) \s }xms ) {
     275         $ret{mac_address} = $1;
     276         }
    266277      }
    267278
Note: See TracChangeset for help on using the changeset viewer.