Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Net::Ping broken on Solaris?

by bronto (Priest)
on Sep 11, 2006 at 10:22 UTC ( #572325=perlquestion: print w/ replies, xml ) Need Help??
bronto has asked for the wisdom of the Perl Monks concerning the following question:

Dearest Monks

A colleague of mine has a test script that he uses to send ICMP ping packets for monitorning purposes. The script can be shortened to a one-liner like the following:

perl -MNet::Ping -MTime::HiRes -le ' my $p=Net::Ping->new("icmp",3,3,"bge0") ; $p->hires() ; @r=$p->ping("10.39.15.20"); print "[$r[0]] [$r[1]]"'

Now, everything works on a couple of different Linux distributions, but on Solaris it dies with an error:

error binding to device bge0 Option not supported by protocol at -e line 1

Needless to say, everything works fine if he doesn't specify the network interface. The problem is that he needs to, since he needs to test connectivity from both. I took a look at Net::Ping's code and the problem happens with a setsockopt call, but it seems so weird that no one noticed before...

Is anybody out there aware of a Solaris-specific bug of the module? I tried an handful of searches here and there (google, rt.cpan.org, perlmonks...) but none gave relevant results.

Thanks in advance

Ciao!
--bronto


In theory, there is no difference between theory and practice. In practice, there is.

Comment on Net::Ping broken on Solaris?
Select or Download Code
Re: Net::Ping broken on Solaris?
by prodevel (Scribe) on Sep 11, 2006 at 11:31 UTC
    When I first got to Solaris from HP I missed my old flags...

    Just a stab, but I suspect the '-e' flag is the culprit, although I could be off at this hour.

    http://docs.sun.com/app/docs/doc/802-1930-1M/6i5u98e73?a=view

      That one-liner is a... condensation of mine of a full-fledged script, that doesn't work either. So -e isn't the culprit, definitely.

      Thanks anyway for trying to help

      Ciao!
      --bronto


      In theory, there is no difference between theory and practice. In practice, there is.
        I've got some boxes. What version, patch-level, hardware, etc.?

        I feel like helping in my own sloth-type way if you don't mind.

        Ask the sysadmins? Maybe someone got 'slick' and replaced ping or some other bin/lib w/their own (devious) routines. I doubt it but it happened to me once or twice in a sub-par shop.

Re: Net::Ping broken on Solaris?
by shmem (Canon) on Sep 11, 2006 at 13:18 UTC

    Indeed, Net::Ping hardware binding seems to work on linux only; the setsockopt call uses SO_BINDTODEVICE which constant isn't defined on solaris. The subroutine that provides the constant is

    # h2ph "asm/socket.h" # require "asm/socket.ph"; sub SO_BINDTODEVICE {25;}

    Hmm... asm/socket.h ? This file doesn't exist on solaris (nor *BSD).

    But in Net::Ping there's $p->bind($local_addr) - maybe that suffices to select the interface.

    --shmem

    _($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                                  /\_¯/(q    /
    ----------------------------  \__(m.====·.(_("always off the crowd"))."·
    ");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}

      Thanks shmem. Unfortunately, my colleague can bind any address he wants, even weird or non-existent ones, and the module flawlessly fails to notice. It still uses the... er, default interface.

      Any clues? Should I go and try to patch the module myself?

      Ciao!
      --bronto


      In theory, there is no difference between theory and practice. In practice, there is.

        No further clue atm; and - if it's broken, u-fix-it :-)

        But it might be the case that binding a socket to an interface just isn't possible on Solaris.

        Why is interface binding necessary?

        --shmem

        _($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                                      /\_¯/(q    /
        ----------------------------  \__(m.====·.(_("always off the crowd"))."·
        ");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
Re: Net::Ping broken on Solaris?
by Steve_p (Priest) on Aug 06, 2007 at 14:05 UTC

    Hmmm...no ticket has been opened on this issue. I guess I'll do it. You may monitor CPAN RT#28686 for progress.


    Steve_p

    Test your modules with bleadperl!

      rsync -avz rsync://public.activestate.com/perl-current/ .
      ./Configure -des -Dusedevel -Dprefix=/path/to/test/perl
      make test
      make install
    

    Now, please test you modules! If you have test failures that don't happen with Perl 5.8.8, send a simplified test case to

    perlbug at perl.org

      It looks like device binding is only available on Linux. The documentation for Net::Ping has been updated as such and should be in the next release of Net::Ping and Perl.


      Steve_p

      Test your modules with bleadperl!

        rsync -avz rsync://public.activestate.com/perl-current/ .
        ./Configure -des -Dusedevel -Dprefix=/path/to/test/perl
        make test
        make install
      

      Now, please test you modules! If you have test failures that don't happen with Perl 5.8.8, send a simplified test case to

      perlbug at perl.org

        I almost completely forgot about the problem and, after a year, I couldn't imagine anyone noticing it anymore! Thanks for digging down in it, Steve_p!

        Ciao!
        --bronto


        In theory, there is no difference between theory and practice. In practice, there is.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://572325]
Approved by robartes
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (11)
As of 2014-10-23 06:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (124 votes), past polls