Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 904658 - net-misc/netifrc-0.7.4 calls _netns in iproute2.sh, which it can't find
Summary: net-misc/netifrc-0.7.4 calls _netns in iproute2.sh, which it can't find
Status: RESOLVED INVALID
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal critical
Assignee: netifrc Team
URL: https://forums.gentoo.org/viewtopic-t...
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-04-19 11:58 UTC by N. Andrew Walsh
Modified: 2023-04-19 21:14 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description N. Andrew Walsh 2023-04-19 11:58:02 UTC
multiple lines in /lib/netifrc/net/iproute2.sh invokes '_netns', which is a command it apparently can't find. Starting, for example, /net/init.d/net.eth0 subsequently fails, along with any other network service.

Downgrading to netifrc-0.7.3 resolves the issue. 

Reproducible: Always

Steps to Reproduce:
1. update netifrc
2. /etc/init.d/net.eth start
3. failure with "_netns: no such file or directory" errors
Comment 1 kfm 2023-04-19 16:38:25 UTC
(In reply to N. Andrew Walsh from comment #0)
> multiple lines in /lib/netifrc/net/iproute2.sh invokes '_netns', which is a
> command it apparently can't find. Starting, for example,
> /net/init.d/net.eth0 subsequently fails, along with any other network
> service.

Thank you for reporting. I will investigate this shortly. In the meantime, and for completeness, could you also attach your /etc/conf.d/net file (or, at least, something that is representative of it) and detail which net.* links are enabled in your default runlevel?
Comment 2 N. Andrew Walsh 2023-04-19 17:03:02 UTC
/etc/conf.d/net does not have anything in it except the line:

dns_domain_lo="{domain}"

(where {domain} is a dummy domain).

Only /etc/init.d/net.eth0 and /etc/init.d/net.lo are enabled in the default runlevel. 

Cheers,

A
Comment 3 kfm 2023-04-19 17:35:54 UTC
I cannot reproduce this. The definition of the _netns function is in "netifrc/sh/functions.sh" which is sourced almost immediately after /etc/init.d/net.lo begins execution. Ostensibly, there should be no circumstance under which _netns cannot be resolved as a function name. Further, "no such file or directory" is not a typical diagnostic message for sh(1) implementations to print in the case that a simple command name cannot be resolved, be it a function or otherwise.

As such, I'll be needing some more information. In your case, is /bin/sh presently a symlink to /bin/bash? If it is, we may exploit its capability to provide rich tracing information. Here is one method of doing so.

Insert the following lines into the /etc/init.d/net.lo script, beginning from line #2. Line #1 must remain intact as it is the "shebang" and needs to be parsed by the kernel.

   PS4='+$BASH_SOURCE:$LINENO: '
   exec 2>>/var/tmp/net-runscript.log
   printf '%s\n' "$(date -Is) $0: $*" >&2
   set -x

Having done so, you will find that your net.eth0 now prints a (rather noisy) trace to STDERR. You may redirect STDERR using shell redirection. For example, assuming that starting is sufficient to induce the error, you could run:

   rc-service net.eth0 start 2>>"$HOME"/net-runscript.log

Please then attach the resulting log file to this bug.
Comment 4 kfm 2023-04-19 17:37:00 UTC
Rather:

   PS4='+$BASH_SOURCE:$LINENO: '
   printf '%s\n' "$(date -Is) $0: $*" >&2
   set -x

The inclusion of the "exec" command in the prior comment was unintentional.
Comment 5 Robin Johnson archtester Gentoo Infrastructure gentoo-dev Security 2023-04-19 17:41:30 UTC
As the reporter likely doesn't want to keep losing networking while debugging this, in addition to what Kerin has said, I'd add:

make a net.dummy1 symlink to net.lo, and start that (don't call it dummy0 for now).

For conf.d/net

pick ONE of these lines, depending on your testcases:
config_dummy1="10.1.1.1/32"
config_dummy1="null"


I also can't reproduce this right now.
Comment 6 N. Andrew Walsh 2023-04-19 19:16:48 UTC
OK, I'll see about producing some more useful output to help debug. A couple things while we wait: 

I was wrong about the exact wording of the error, which was:

"/lib/netifrc/net/iproute2.sh: line 74: _netns: command not found"

Second, when I go searching through /lib/netifrc/sh/functions.sh, I do not find "netns" in it. Nor do I find it in /lib/gentoo/functions.sh, which is invoked at the top of that file. Is there somewhere else it should be?

/bin/sh does symlink to /bin/bash. 

The first lines of /etc/init.d/net.lo are as follows:

--------------------------------------
#!/sbin/openrc-run
# shellcheck shell=sh disable=SC1008
# Copyright (c) 2007-2009 Roy Marples <roy@marples.name>
# Copyright (c) 2010-2016 Gentoo Foundation
# Released under the 2-clause BSD license.

SHDIR="/lib/netifrc/sh"
MODULESDIR="/lib/netifrc/net"
_config_vars="config metric routes"

[ -z "${IN_BACKGROUND}" ] && IN_BACKGROUND="NO"
-------------[etc]----------------

I do not usually start net.eth0 with rc-service when I'm stopping/starting it explicitly, but with the command `/etc/init.d/net.eth0 start`. Does that differ somehow from using rc-service?

Thanks for the help,

A
Comment 7 Robin Johnson archtester Gentoo Infrastructure gentoo-dev Security 2023-04-19 19:40:08 UTC
(In reply to N. Andrew Walsh from comment #6)
> OK, I'll see about producing some more useful output to help debug. A couple
> things while we wait: 
> 
> I was wrong about the exact wording of the error, which was:
> 
> "/lib/netifrc/net/iproute2.sh: line 74: _netns: command not found"
> 
> Second, when I go searching through /lib/netifrc/sh/functions.sh, I do not
> find "netns" in it. Nor do I find it in /lib/gentoo/functions.sh, which is
> invoked at the top of that file. Is there somewhere else it should be?

That sounds like your /lib/netifrc/sh/functions.sh did not update correctly.

$ sha1sum /lib/netifrc/sh/functions.sh 
60497713916ff7b77a491007366220b81b60ac83  /lib/netifrc/sh/functions.sh

$ grep _netns /lib/netifrc/sh/functions.sh 
_netns()

That file hasn't changed since 2021, commit 
7ff5d213660e5df80aba8782e5cfe4373416ed86.

_netns was during 2020, in commit 1e807ce5e4dacf3fd491844588192f8ebb74f3a2.
Comment 8 kfm 2023-04-19 20:06:55 UTC
(In reply to N. Andrew Walsh from comment #6)

> I do not usually start net.eth0 with rc-service when I'm stopping/starting
> it explicitly, but with the command `/etc/init.d/net.eth0 start`. Does that
> differ somehow from using rc-service?

Not meaningfully but I don't think it matters now, in view of the intervening comments.
Comment 9 N. Andrew Walsh 2023-04-19 20:51:33 UTC
grep did not return any result for "_netns" on /lib/netifrc/sh/functions.sh, and the checksum is completely different. So I remerged netifrc-0.7.4, and now the hash is correct, and grep finds it, but running `/etc/init.d/net.eth0 stop start` returns the same "command not found" error. 

But it's safe to say that this is something wrong with the config on my end, which means it's not a bug and should be taken up on the forum.

Sorry for wasting your time :(
Comment 10 kfm 2023-04-19 21:14:06 UTC
I'm all but certain that your instance of /etc/init.d/net.eth0 isn't a symlink to net.lo, as it should be.