From 9a01f6851533c808ff0665a3749a20f710a3ee57 Mon Sep 17 00:00:00 2001 From: "Robin H. Johnson" Date: Mon, 26 Dec 2011 16:27:38 -0800 Subject: net: Add up_before_preup variable for CAN devices Historically, we have tried to up interfaces before running preup, so that the kernel setups up the device and makes things like ethtool work (some hardware cannot be correct probed until then). However this ends up breaking other hardware, so a variable has been introduced to allow the up prior to preup to be disabled: up_before_preup_IFVAR=no X-Gentoo-Bug: 389475 X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=389475 Signed-off-by: Robin H. Johnson --- doc/net.example.Linux.in | 10 ++++++++++ init.d/net.lo.in | 6 ++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/doc/net.example.Linux.in b/doc/net.example.Linux.in index 0ee83a6e..d48983ee 100644 --- a/doc/net.example.Linux.in +++ b/doc/net.example.Linux.in @@ -1102,6 +1102,16 @@ # # ${IFACE} is set to the interface being brought up/down # ${IFVAR} is ${IFACE} converted to variable name bash allows +# +# For historical & compatbility reasons, preup is actually normally called in +# the follow sequence: up ; preup ; up +# In that case, the first up causes the kernel to initialize the device, so +# that it is available for use in the preup function. However, for some other +# hardware, eg CAN devices, some configuration is needed before trying to up +# the interface will actually work. For such harware, there are the +# 'up_before_preup' variables, that skips the first up call. +#up_before_preup_IFVAR=no +#up_before_preup=no #preup() { # # Test for link on the interface prior to bringing it up. This diff --git a/init.d/net.lo.in b/init.d/net.lo.in index ae07b52f..02d11a82 100644 --- a/init.d/net.lo.in +++ b/init.d/net.lo.in @@ -488,7 +488,9 @@ start() { local IFACE=${RC_SVCNAME#*.} oneworked=false fallback=false module= local IFVAR=$(shell_var "${IFACE}") cmd= our_metric= - local metric=0 + local metric=0 _up_before_preup + eval _up_before_preup="\$up_before_preup_${IFVAR}" + [ -z "${_up_before_preup}" ] && _up_before_preup=$up_before_preup einfo "Bringing up interface ${IFACE}" eindent @@ -502,7 +504,7 @@ start() # available in preup and afterwards incase the user inadvertently # brings it down if [ "$(command -v preup)" = "preup" ]; then - _up 2>/dev/null + [ "${_up_before_preup}" = "no" ] || _up 2>/dev/null ebegin "Running preup" eindent preup || return 1 -- cgit v1.2.3