aboutsummaryrefslogtreecommitdiff
path: root/init.d
diff options
context:
space:
mode:
authorAlexander Zubkov <green@qrator.net>2024-05-10 23:38:02 +0200
committerPatrick McLean <chutzpah@gentoo.org>2024-05-23 09:12:29 -0700
commit7c6a8de0c521ea474bccb0dbda4338ff293cdfc6 (patch)
treeb1a9adfc8a8edc896dc4b37f8112f17a2a15b27c /init.d
parentmk/os.mk: don't use OS env var for overriding (diff)
downloadnetifrc-7c6a8de0c521ea474bccb0dbda4338ff293cdfc6.tar.gz
netifrc-7c6a8de0c521ea474bccb0dbda4338ff293cdfc6.tar.bz2
netifrc-7c6a8de0c521ea474bccb0dbda4338ff293cdfc6.zip
Allow setting blackhole-like routes
There were several problems preventing usage of routes of types blackhole, prohibit, throw, unreachable in IFACE_routes variables: - Those route types do not allow to use dev in the route definition, but it was added unconditionally - As there is no dev, such routes are not flushed automatically by dev, they need to be remembered and deleted while stopping the interface - Route type must go before the prefix in the command, but first parameters have special meaning Signed-off-by: Alexander Zubkov <green@qrator.net> Closes: https://bugs.gentoo.org/637394 Closes: https://github.com/gentoo/netifrc/pull/53 X-Gentoo-Bug: 637394 X-Gentoo-Bug-URL: https://bugs.gentoo.org/637394 Signed-off-by: Patrick McLean <chutzpah@gentoo.org>
Diffstat (limited to 'init.d')
-rw-r--r--init.d/net.lo.in13
1 files changed, 10 insertions, 3 deletions
diff --git a/init.d/net.lo.in b/init.d/net.lo.in
index afba99f..dbacaa2 100644
--- a/init.d/net.lo.in
+++ b/init.d/net.lo.in
@@ -780,9 +780,11 @@ ${routes}"
fi
fi
+ service_set_value "nodev_routes" ""
+
local OIFS="${IFS}" SIFS="${IFS-y}"
local IFS="$__IFS"
- local fam
+ local cmd_head fam
for cmd in ${routes}; do
unset IFS
if ${first}; then
@@ -795,8 +797,13 @@ ${routes}"
-4" "*) fam="-4"; cmd=${cmd#-4 };;
esac
+ cmd_head=
+ case ${cmd%% *} in
+ blackhole|prohibit|throw|unreachable) cmd_head="${cmd_head} ${cmd%% *}"; cmd=${cmd#* };;
+ esac
+
eindent
- ebegin ${cmd}
+ ebegin ${cmd_head} ${cmd}
# Work out if we're a host or a net if not told
case ${cmd} in
-net\ *|-host\ *);;
@@ -808,7 +815,7 @@ ${routes}"
*:*/*) cmd="-net ${cmd}";;
*) cmd="-host ${cmd}";;
esac
- _add_route ${fam} ${cmd}
+ _add_route ${fam} ${cmd_head} ${cmd}
eend $?
eoutdent
done