# [Resolved] baselayout 2 postdown function problem

## RioFL

i tried to search but the stupid search system chops words out and does what it wants not what i want... anyway

i converted a system to baselayout 2 and openrc and now although things 'work' when i stop a network interface i get an error from the postdown function which was taken directly from the openrc sample.

```
 * Bringing down interface eth1

 *   Running postdown .../etc/init.d/../conf.d//net: line 49: interface_exists: command not found
```

i will list the entire contents of my net file

```

cat /etc/conf.d/net

modules="iproute2"

modules="!arping"

config_eth0="192.168.1.77 netmask 255.255.255.0 broadcast 192.168.1.255"

routes_eth0="192.168.1.0/24 src 192.168.1.77 table 192net"

routes_eth0="default via 192.168.1.1 table 192net"

routes_eth0="default via 192.168.1.1"

rules_eth0="from 192.168.1.0/24 table 192net"

config_eth1="172.30.0.50 netmask 255.255.255.0 broadcast 172.30.0.255"

routes_eth1="172.30.0.0/24 src 172.30.0.50 table pvtnet"

routes_eth1="default via 172.30.0.1 table pvtnet"

rules_eth1="from 172.30.0.0/24 table pvtnet"

postup() {

       local x="rules_${IFVAR}[@]"

       local -a rules=( "${!x}" )

       if [[ -n ${rules} ]] ; then

               einfo "Adding IP policy routing rules"

               eindent

               # Ensure that the kernel supports policy routing

               if ! ip rule list | grep -q "^" ; then

                       eerror "You need to enable IP Policy Routing (CONFIG_IP_MULTIPLE_TABLES)"

                       eerror "in your kernel to use ip rules"

               else

                       for x in "${rules[@]}" ; do

                               ebegin "${x}"

                               ip rule add ${x} dev "${IFACE}"

                               eend $?

                       done

               fi

               eoutdent

               # Flush the cache

               ip route flush cache dev "${IFACE}"

       fi

}

postdown() {

#       Automatically erase any ip rules created in the example postup above

       if interface_exists "${IFACE}"; then

               # Remove any rules for this interface

               local rule

               ip rule list | grep " iif ${IFACE}[ ]*" | {

                       while read rule; do

                               rule="${rule#*:}"

                               ip rule del ${rule}

                       done

               }

               # Flush the route cache

               ip route flush cache dev "${IFACE}"

       fi

       # Return 0 always

       return 0

}

```

line 49 is   

```
if interface_exists "${IFACE}" ; then
```

any ideas here? 

i am far from a 'script kiddie' and generally use things from samples for this..  before i changed to openrc it worked just fine under baselayout1Last edited by RioFL on Sat Nov 08, 2008 9:36 am; edited 2 times in total

----------

## f4u5t

 *RioFL wrote:*   

> i tried to search but the stupid search system chops words out and does what it wants not what i want... anyway
> 
> i converted a system to baselayout 2 and openrc and now although things 'work' when i stop a network interface i get an error from the postdown function which was taken directly from the openrc sample.
> 
> any ideas here? 
> ...

 

The net.example file is wrong.   :Sad:   It is basically a copy of baselayout1's net.example. Openrc has a different feature set. That set does not include "interface_exists".

For your specific problem you could simply remove the "if interface_exists "${IFACE}"; then" and the corresponding "fi". If that doesn't work for you have a look at /lib/rc/net/*. In there you will find definitions for _exists in ifconfig.sh and iproute2.sh that are equivalent to baselayout1's interlace_exists:

```

_exists()

{

        grep -Eq "^[[:space:]]*${IFACE}:" /proc/net/dev

}

```

You have three options: (1) use _exists (if available), (2) simply replace "interface_exists" in your postdown with the body of that function, or (3) ask the OpenRC developer to add an interface_exists function.

The most stable would be (3). Option (2) relies on the stability of the /proc/net/dev interface. Option (1) would be a bad way to go because the fact that the function starts with _ indicates it is for internal use only.

----------

## RioFL

 *f4u5t wrote:*   

>  *RioFL wrote:*   i tried to search but the stupid search system chops words out and does what it wants not what i want... anyway
> 
> i converted a system to baselayout 2 and openrc and now although things 'work' when i stop a network interface i get an error from the postdown function which was taken directly from the openrc sample.
> 
> any ideas here? 
> ...

 

thanks! i think i will opt for (3). since it appears to work ok and does shut the interface down but just complains, it isn't an earthshaking problem that I cannot wait for the dev to come up with a fix. it may not clear the rules properly but i don't expect to be shutting this down very much anyway. once they identify the problem then i can install the fix and just wait for the next reboot which may be 6 months

----------

## RioFL

I tried commenting the line out and its corresponding fi and the problem went away so yes you are correct. I will report this to the developer and see if he has or will come up with a solution.

thank you.

----------

## RioFL

 *RioFL wrote:*   

>  *f4u5t wrote:*    *RioFL wrote:*   i tried to search but the stupid search system chops words out and does what it wants not what i want... anyway
> 
> i converted a system to baselayout 2 and openrc and now although things 'work' when i stop a network interface i get an error from the postdown function which was taken directly from the openrc sample.
> 
> any ideas here? 
> ...

 

Just heard back from the developer. I am quoting his entire msg. He says to use _exists

 *Quote:*   

>     *   status  changed from new to closed
> 
>     * resolution set to wontfix
> 
> You should change
> ...

 

I did this and it works perfectly.

----------

