Don't give up as soon as a network configuration command fails. That
tends to leave the device's routing in a hopelessly broken state.
Instead, catch errors, report them via the server, and issue a slightly
different notification on completion.
may be IPv4 or IPv6 addresses. If the interface has only an IPv4
address then IPv6 routes will be ignored, and
.IR "vice versa" .
may be IPv4 or IPv6 addresses. If the interface has only an IPv4
address then IPv6 routes will be ignored, and
.IR "vice versa" .
+.RS
+.PP
+If any configuration commands fail, a warning
+.IP
+.B USER tripe-ifup command-failed
+.BI rc= rc
+.I command
+.PP
+is issued.
+.RE
.hP 4.
Configure the interface MTU and bring it up. The
interface MTU is configured based on the path MTU to the peer's external
.hP 4.
Configure the interface MTU and bring it up. The
interface MTU is configured based on the path MTU to the peer's external
.IP
.B USER tripe-ifup configured
.I peer
.IP
.B USER tripe-ifup configured
.I peer
+is issued: the
+.B failed
+token is included if any of the configuration commands failed.
.RE
.
.\"--------------------------------------------------------------------------
.RE
.
.\"--------------------------------------------------------------------------
## Determine whether we have IPv6 support.
if [ -d /proc/sys/net/ipv6 ]; then have6=t; else have6=nil; fi
## Determine whether we have IPv6 support.
if [ -d /proc/sys/net/ipv6 ]; then have6=t; else have6=nil; fi
+###--------------------------------------------------------------------------
+### Error handling.
+
+win=t
+try () {
+ if "$@"; then :; else
+ rc=$?
+ tripectl warn tripe-ifup command-failed rc=$rc "$*"
+ win=nil
+ fi
+}
+
###--------------------------------------------------------------------------
### Collect arguments.
###--------------------------------------------------------------------------
### Collect arguments.
case "${P_IFNAME+set}" in
set)
case "${P_IFNAME+set}" in
set)
- ip link set "$ifname" name "$P_IFNAME"
+ try ip link set "$ifname" name "$P_IFNAME"
ifname=$P_IFNAME
$tripectl setifname "$peer" "$ifname"
;;
ifname=$P_IFNAME
$tripectl setifname "$peer" "$ifname"
;;
set -- $l4addr
case $#,${r4addr+set} in
[1-9]*,set)
set -- $l4addr
case $#,${r4addr+set} in
[1-9]*,set)
- ip addr add "$1" peer "$r4addr" dev "$ifname"
+ try ip addr add "$1" peer "$r4addr" dev "$ifname"
haveaddr4=t
shift
;;
esac
for a in "$@"; do
haveaddr4=t
shift
;;
esac
for a in "$@"; do
- ip addr add "$a" dev "$ifname"
+ try ip addr add "$a" dev "$ifname"
case $have6,$# in
t,[1-9]*)
for a in "$@"; do
case $have6,$# in
t,[1-9]*)
for a in "$@"; do
- ip addr add "$a" dev "$ifname"
+ try ip addr add "$a" dev "$ifname"
haveaddr6=t
done
case ${r6addr+set} in
haveaddr6=t
done
case ${r6addr+set} in
- set) ip route add $r6addr proto static dev "$ifname" ;;
+ set) try ip route add $r6addr proto static dev "$ifname" ;;
mtu=$(expr "$pathmtu" - 29 - $A_BULK_OVERHEAD)
;;
esac
mtu=$(expr "$pathmtu" - 29 - $A_BULK_OVERHEAD)
;;
esac
- ip link set dev "$ifname" up mtu "$mtu"
+ try ip link set dev "$ifname" up mtu "$mtu"
case $haveaddr4,$# in
t,[1-9]*)
for p in "$@"; do
case $haveaddr4,$# in
t,[1-9]*)
for p in "$@"; do
- ip route add $p proto static via "$r4addr"
+ try ip route add $p proto static via "$r4addr"
case $haveaddr6,$# in
t,[1-9]*)
for p in "$@"; do
case $haveaddr6,$# in
t,[1-9]*)
for p in "$@"; do
- ip route add $p proto static via "${r6addr%/*}"
+ try ip route add $p proto static via "${r6addr%/*}"
###--------------------------------------------------------------------------
### Issue a notification that we've won.
###--------------------------------------------------------------------------
### Issue a notification that we've won.
-$tripectl notify tripe-ifup configured "$peer"
+case $win in
+ t) $tripectl notify tripe-ifup configured "$peer" ;;
+ nil) $tripectl notify tripe-ifup configured "$peer" failed ;;
+esac
###----- That's all, folks --------------------------------------------------
###----- That's all, folks --------------------------------------------------