LVS
lvs-users
Google
 
Web LinuxVirtualServer.org

Re: how to tell if certain code is in kernel

To: Joseph Mack <mack.joseph@xxxxxxx>
Subject: Re: how to tell if certain code is in kernel
Cc: lvs-users@xxxxxxxxxxxxxxxxxxxxxx
From: Roberto Nibali <ratz@xxxxxx>
Date: Mon, 24 Sep 2001 20:39:14 +0200
Good evening,

> I remember why I wanted to check before running these commands. The
> command is
> 
> ip link add dev $DEVICE

I reckon it'll be `ip link set dev $DEVICE`.
 
> Where $DEVICE was parsed elsewhere in the code and possibly on another 
> machine.

???
 
> In that case all I can say is
> 
> "Sorry mate, couldn't put IP=x.x.x.x onto dev $DEVICE"

This is different from setting up a device. ip link set is used to
set up a device, look at it as ifconfig hme0 plumb under SunOS. With
ip addr add you assign an IP to a link (aka device).
 
> I have no idea whether device is eth0, tun0, hme0 at that stage. I'd have
> to give error message appropriate for all devices.

What's wrong with:

function check_and_insert_dev(){
   local retval=0
   local device=$1
   if [ "x${device//tun/}" != "x${device}" ]; then 
      printf "%s" "Loading ipip for device [$device] ... "
      modprobe ipip 2>/dev/null 1>&2 &&\
           { printf "%s\n" "done"; } ||\
           { printf "%s\n" "failed"; retval=1; }
   fi
   return $retval
}

check_and_insert_dev $DEVICE
if [ $? -ne 0 ]; then
   # Do whatever you want to do
   exit 1
fi

zar:~ # function check_and_insert_dev(){
>    local retval=0
>    local device=$1
>    if [ "x${device//tun/}" != "x${device}" ]; then 
>       printf "%s" "Loading ipip for device [$device] ... "
>       modprobe ipip 2>/dev/null 1>&2 &&\
>            { printf "%s\n" "done"; } ||\
>            { printf "%s\n" "failed"; retval=1; }
>    fi
>    return $retval
> }
zar:~ # check_and_insert_dev eth0
zar:~ # echo $?
0
zar:~ # check_and_insert_dev tun123
Loading ipip for device [tun123] ... failed
zar:~ # echo $?
1
zar:~ # 

> I could still do my tests ahead (like when I find a tunl device in the conf 
> file).

My method is fast enough, so no need to grep for it ;)

Cheers,
Roberto Nibali, ratz

-- 
echo '[q]sa[ln0=aln256%Pln256/snlbx]sb3135071790101768542287578439snlbxq' | dc


<Prev in Thread] Current Thread [Next in Thread>