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
16 config_get mtu "$config" mtu
18 # make sure there is a gateway and a target
20 echo "Missing target in route section $config"
23 [ -n "$gateway" ] || {
24 config_get gateway "$interface" gateway
27 # handle "0.0.0.0" as "no gateway given" to allow
28 # defining gateway-less routes while still keeping
29 # the possibility to have static routes with a
30 # proper gateway on interfaces with dynamic ips
31 [ "$gateway" = "0.0.0.0" ] && gateway=""
33 dest="${netmask:+-net "$target" netmask "$netmask"}"
34 dest="${dest:--host "$target"}"
36 /sbin/route add $dest ${gateway:+gw "$gateway"} \
37 ${dev:+dev "$dev"} ${metric:+ metric "$metric"} \
44 # is this route intended for the
45 # $INTERFACE of this hotplug event
46 config_get interface "$config" interface
47 [ "$interface" != "$INTERFACE" ] && return 0
49 # get the real interface name from network config
50 config_get dev "$interface" ifname
52 config_get target "$config" target
53 config_get gateway "$config" gateway
54 config_get metric "$config" metric
55 config_get mtu "$config" mtu
57 # make sure there is a gateway and a target
59 echo "Missing target in route section $config"
62 [ -n "$gateway" ] || {
63 config_get gateway "$interface" gateway
66 /sbin/route -A inet6 add $target ${gateway:+gw "$gateway"} \
67 ${dev:+dev "$dev"} ${metric:+ metric "$metric"} \
71 # Skip fake devices (e.g. relayd)
72 grep -qs "^ *$DEVICE:" /proc/net/dev || exit 0
80 config_set "$INTERFACE" aliases ""
81 config_set "$INTERFACE" alias_count 0
82 config_foreach setup_interface_alias alias "$INTERFACE" "$DEVICE"
84 # Save alias references in state vars
86 config_get aliases "$INTERFACE" aliases
87 [ -z "$aliases" ] || uci_set_state network "$INTERFACE" aliases "$aliases"
89 # Make ip6addr of parent iface the main address again
91 config_get ip6addr "$INTERFACE" ip6addr
92 [ -z "$ip6addr" ] || {
93 ifconfig "$DEVICE" del "$ip6addr"
94 ifconfig "$DEVICE" add "$ip6addr"
98 local proto accept_ra send_rs
100 config_get proto "$INTERFACE" proto
101 if [ "$proto" = dhcp ]; then
109 config_get_bool accept_ra "$INTERFACE" accept_ra $accept_ra
110 [ $accept_ra -eq 0 ] || {
111 logger -t ifup "Allowing Router Advertisements on $INTERFACE ($DEVICE)"
114 do_sysctl "net.ipv6.conf.$DEVICE.accept_ra" $accept_ra
116 config_get_bool send_rs "$INTERFACE" send_rs $send_rs
117 [ $send_rs -eq 0 ] || {
118 logger -t ifup "Enabling Router Solicitations on $INTERFACE ($DEVICE)"
121 do_sysctl "net.ipv6.conf.$DEVICE.forwarding" $send_rs
125 config_foreach "add_route" route
126 config_foreach "add_route6" route6
129 # Bring down named aliases
130 local device=$(uci_get_state network "$INTERFACE" device)
132 for ifn in $(ifconfig | sed -ne "s/^\(\($DEVICE${device:+\|$device}\|br-$INTERFACE\):[^[:space:]]\+\).*/\1/p"); do