Subroutine SNMP_Session::pack_sockaddr_in6 redefined on Centos 6.3 with mrtg

Here is a quick fix-patch for the following warning:

Subroutine SNMP_Session::pack_sockaddr_in6 redefined at /usr/share/perl5/Exporter.pm line 67.
 at /usr/bin/../lib64/mrtg2/SNMP_Session.pm line 149.
Subroutine SNMP_Session::unpack_sockaddr_in6 redefined at /usr/share/perl5/Exporter.pm line 67.
 at /usr/bin/../lib64/mrtg2/SNMP_Session.pm line 149.
Subroutine SNMP_Session::sockaddr_in6 redefined at /usr/share/perl5/Exporter.pm line 67.
 at /usr/bin/../lib64/mrtg2/SNMP_Session.pm line 149.
Subroutine SNMPv1_Session::pack_sockaddr_in6 redefined at /usr/share/perl5/Exporter.pm line 67.
 at /usr/bin/../lib64/mrtg2/SNMP_Session.pm line 604.
Subroutine SNMPv1_Session::unpack_sockaddr_in6 redefined at /usr/share/perl5/Exporter.pm line 67.
 at /usr/bin/../lib64/mrtg2/SNMP_Session.pm line 604.
Subroutine SNMPv1_Session::sockaddr_in6 redefined at /usr/share/perl5/Exporter.pm line 67.
 at /usr/bin/../lib64/mrtg2/SNMP_Session.pm line 604.
Subroutine main::pack_sockaddr_in6 redefined at /usr/share/perl5/Exporter.pm line 67.
 at /usr/bin/mrtg line 101.
Subroutine main::unpack_sockaddr_in6 redefined at /usr/share/perl5/Exporter.pm line 67.
 at /usr/bin/mrtg line 101.
Subroutine main::sockaddr_in6 redefined at /usr/share/perl5/Exporter.pm line 67.
 at /usr/bin/mrtg line 101.

You need to edit 2 files in order to stop getting the above warnings.

Open /usr/bin/mrtg (rows 98-105) and replace:

BEGIN {
    if (eval {local $SIG{__DIE__};require Socket6;})  {
        import Socket;
        import Socket6;
    }
}

with

BEGIN {
    if (eval {local $SIG{__DIE__};require Socket6;})  {
        import Socket;
        Socket6->import(qw(inet_pton getaddrinfo));
    }
}

Also open usr/lib64/mrtg2/SNMP_Session.pm and and replace:

if (eval {local $SIG{__DIE__};require Socket6;} &&
      eval {local $SIG{__DIE__};require IO::Socket::INET6; IO::Socket::INET6->VERSION("1.26");}) {
      import Socket6;
      $ipv6_addr_len = length(pack_sockaddr_in6(161, inet_pton(AF_INET6(), "::1")));
      $SNMP_Session::ipv6available = 1;
}

with

if (eval {local $SIG{__DIE__};require Socket6;} &&
      eval {local $SIG{__DIE__};require IO::Socket::INET6; IO::Socket::INET6->VERSION("1.26");}) {
      Socket6->import(qw(inet_pton getaddrinfo));
      $ipv6_addr_len = length(pack_sockaddr_in6(161, inet_pton(AF_INET6(), "::1")));
      $SNMP_Session::ipv6available = 1;
}

and rows 602-607

BEGIN {
    if($SNMP_Session::ipv6available) {
        import IO::Socket::INET6;
        import Socket6;
     }
}

with

BEGIN {
    if($SNMP_Session::ipv6available) {
        import IO::Socket::INET6;
        Socket6->import(qw(inet_pton getaddrinfo));
    }
}

After these steps you will stop getting those irritating warnings.

Scroll to top