4 # is this route intended for the
5 # $INTERFACE of this hotplug event
6 config_get interface "$config" interface
7 [ "$interface" != "$INTERFACE" ] && return 0
9 # get the real interface name from network config
10 config_get dev "$interface" ifname
12 config_get target "$config" target
13 config_get netmask "$config" netmask
14 config_get gateway "$config" gateway
15 config_get metric "$config" metric
17 # make sure there is a gateway and a target
19 echo "Missing target in route section $config"
22 [ -n "$gateway" ] || {
23 config_get gateway "$interface" gateway
26 # handle "0.0.0.0" as "no gateway given" to allow
27 # defining gateway-less routes while still keeping
28 # the possibility to have static routes with a
29 # proper gateway on interfaces with dynamic ips
30 [ "$gateway" = "0.0.0.0" ] && gateway=""
32 dest="${netmask:+-net "$target" netmask "$netmask"}"
33 dest="${dest:--host "$target"}"
35 /sbin/route add $dest ${gateway:+gw "$gateway"} \
36 ${dev:+dev "$dev"} ${metric:+ metric "$metric"}
42 # is this route intended for the
43 # $INTERFACE of this hotplug event
44 config_get interface "$config" interface
45 [ "$interface" != "$INTERFACE" ] && return 0
47 # get the real interface name from network config
48 config_get dev "$interface" ifname
50 config_get target "$config" target
51 config_get gateway "$config" gateway
52 config_get metric "$config" metric
54 # make sure there is a gateway and a target
56 echo "Missing target in route section $config"
59 [ -n "$gateway" ] || {
60 config_get gateway "$interface" gateway
63 /sbin/route -A inet6 add $target ${gateway:+gw "$gateway"} \
64 ${dev:+dev "$dev"} ${metric:+ metric "$metric"}
71 config_foreach "add_route" route
72 config_foreach "add_route6" route6