fi
mwan3_set_policies_iptables
mwan3_set_user_rules
- mwan3_flush_conntrack $INTERFACE $DEVICE "ifup"
;;
ifdown)
mwan3_set_iface_hotplug_state $INTERFACE "offline"
mwan3_track_signal $INTERFACE $DEVICE
mwan3_set_policies_iptables
mwan3_set_user_rules
- mwan3_flush_conntrack $INTERFACE $DEVICE "ifdown"
;;
esac
mwan3_flush_conntrack()
{
- local flush_conntrack
+ local interface="$1"
+ local action="$2"
- config_get flush_conntrack $1 flush_conntrack never
+ handle_flush() {
+ local flush_conntrack="$1"
+ local action="$2"
+
+ if [ "$action" = "$flush_conntrack" ]; then
+ echo f > ${CONNTRACK_FILE}
+ $LOG info "Connection tracking flushed for interface '$interface' on action '$action'"
+ fi
+ }
if [ -e "$CONNTRACK_FILE" ]; then
- case $flush_conntrack in
- ifup)
- [ "$3" = "ifup" ] && {
- echo f > ${CONNTRACK_FILE}
- $LOG info "connection tracking flushed on interface $1 ($2) $3"
- }
- ;;
- ifdown)
- [ "$3" = "ifdown" ] && {
- echo f > ${CONNTRACK_FILE}
- $LOG info "connection tracking flushed on interface $1 ($2) $3"
- }
- ;;
- always)
- echo f > ${CONNTRACK_FILE}
- $LOG info "connection tracking flushed on interface $1 ($2) $3"
- ;;
- never)
- $LOG info "connection tracking not flushed on interface $1 ($2) $3"
- ;;
- esac
- else
- $LOG warning "connection tracking not enabled"
+ config_list_foreach "$interface" flush_conntrack handle_flush "$action"
fi
}