You are not logged in.

#1 2012-10-29 07:41:05

igvk
Member
Registered: 2012-10-29
Posts: 8

Systemd and Netcfg

I am using Arch linux with systemd.
All packages are recent.

And I encountered the following behavour when configuring network:
netcfg.service starts before network interfaces appear in the system (modules are not yet loaded), so I get the following error in syslog:
netcfg-daemon[463]: :: mgmt up Interface eth0 does not exist
netcfg-daemon[463]: [fail]

So I added the following line to "Unit" to /etc/systemd/system/multi-user.target.wants/netcfg.service:
[Unit]
After=sys-class-net-eth0.device

But it didn't help - the netcfg-daemon still starts before the symlink /sys/calss/net/eth0 appears.

Please advise - what can be done to fix the problem with network configuration?

Offline

#2 2012-10-29 08:06:18

Perfect Gentleman
Member
Registered: 2012-10-25
Posts: 222

Re: Systemd and Netcfg

systemctl enable net-auto-wired.service ?

Last edited by Perfect Gentleman (2012-10-29 08:07:03)

Offline

#3 2012-10-29 08:10:11

skunktrader
Member
From: Brisbane, Australia
Registered: 2010-02-14
Posts: 1,538

Re: Systemd and Netcfg

Its a bug and is currently being looked at https://mailman.archlinux.org/pipermail … 03331.html

Offline

#4 2012-10-29 08:38:53

igvk
Member
Registered: 2012-10-29
Posts: 8

Re: Systemd and Netcfg

No, they were not present.
I enabled net-auto-wired.service and the eth0 interface configured correctly.
Although the question remains - can't I use only netcfg.service for network configuration?

Last edited by igvk (2012-10-29 08:53:56)

Offline

#5 2012-10-29 08:47:17

igvk
Member
Registered: 2012-10-29
Posts: 8

Re: Systemd and Netcfg

O.K. It's a bug.
So - I need to enable net-auto-wired.service and disable netcfg.service, right?
Is this the correct way to configure network?

Offline

#6 2012-10-29 08:51:28

Perfect Gentleman
Member
Registered: 2012-10-25
Posts: 222

Re: Systemd and Netcfg

intall ifplugd, and enable net-auto-wired.service and disable netcfg.service. i think net would be work

Offline

#7 2012-10-29 08:55:22

igvk
Member
Registered: 2012-10-29
Posts: 8

Re: Systemd and Netcfg

The problem with net-auto-wired is that it configures only interface eth0 (defined by WIRED_INTERFACE in /etc/conf.d/netcfg).
What about all the other interfaces (defined by NETWORKS)?

Offline

#8 2012-10-29 08:58:15

Perfect Gentleman
Member
Registered: 2012-10-25
Posts: 222

Re: Systemd and Netcfg

when i used netcfg with wlan. i configured file in /etc/network.d/, the enabled net-auto-wireless.service, and not enabled netcfg.service. really i don't know whether it was enabled or not.

Offline

#9 2012-10-29 09:57:19

skunktrader
Member
From: Brisbane, Australia
Registered: 2010-02-14
Posts: 1,538

Re: Systemd and Netcfg

As a temporary workaround, try

sudo systemctl restart netcfg

Offline

#10 2012-10-29 09:57:50

igvk
Member
Registered: 2012-10-29
Posts: 8

Re: Systemd and Netcfg

Does anyone have a stable working solution for confiuring multiple interfaces via systemd on startup?

Offline

#11 2012-10-29 10:02:22

brain0
Developer
From: Aachen - Germany
Registered: 2005-01-03
Posts: 1,382

Re: Systemd and Netcfg

skunktrader wrote:

Its a bug and is currently being looked at https://mailman.archlinux.org/pipermail … 03331.html

Rather look at this patch series: https://mailman.archlinux.org/pipermail … 03350.html. This is far from finished: There's conflict handling remaining, and the netcfg, wifi-menu and netcfg-menu commands should forward everything to systemd instead of starting the profiles inside the current session.

Offline

#12 2012-10-29 10:06:32

skanky
Member
From: WAIS
Registered: 2009-10-23
Posts: 1,847

Re: Systemd and Netcfg

igvk wrote:

Does anyone have a stable working solution for confiuring multiple interfaces via systemd on startup?

I have both wired and wireless running no problem.
I've enabled both net-auto-wired and net-auto-wireless in systemd.

I have ifplugd installed and wireless starts and stops as I plug/unplug my laptop from the docking station (or at least last time I tried).

I also am able to have both up and running at the same time, though they run separately and unfortunately the upload and doownload are the wrong way round, one day I may try and set up bonding again (though that's a different issue).


"...one cannot be angry when one looks at a penguin."  - John Ruskin
"Life in general is a bit shit, and so too is the internet. And that's all there is." - scepticisle

Offline

#13 2012-10-29 10:33:02

igvk
Member
Registered: 2012-10-29
Posts: 8

Re: Systemd and Netcfg

I am looking forward to integration of the patches into archlinux.

And - several eth (eth1, eth2, eth3, etc.) interfaces won't come up when using net-auto-wired - only eth0.

Last edited by igvk (2012-10-29 10:33:19)

Offline

#14 2012-10-29 11:05:09

skanky
Member
From: WAIS
Registered: 2009-10-23
Posts: 1,847

Re: Systemd and Netcfg

igvk wrote:

I am looking forward to integration of the patches into archlinux.

And - several eth (eth1, eth2, eth3, etc.) interfaces won't come up when using net-auto-wired - only eth0.

Sorry, didn't realise you were talking about multiple eth interfaces, thought you were talking about eth & wlan. I guess my post is irrelevant.


"...one cannot be angry when one looks at a penguin."  - John Ruskin
"Life in general is a bit shit, and so too is the internet. And that's all there is." - scepticisle

Offline

#15 2012-10-29 12:51:20

brain0
Developer
From: Aachen - Germany
Registered: 2005-01-03
Posts: 1,382

Re: Systemd and Netcfg

igvk wrote:

I am looking forward to integration of the patches into archlinux.

You could get the patches from my github and build a netcfg package with them: https://github.com/brain0/netcfg/commits/working. Everything should be fine as long as you configure auto-started profiles in /etc/conf.d/netcfg and only manually start and stop profiles using

systemctl netcfg-profile-NAME.service

instead of the native netcfg command. If you change a profile, run

systemctl --system daemon-reload

before trying to start a profile.

Offline

#16 2012-10-30 02:39:25

SamSpade
Member
Registered: 2012-10-29
Posts: 9

Re: Systemd and Netcfg

Another suggestion is to put a timeout in netcfg when it's checking the existence of the interface (ex. 'eth0'). Netcfg already does that while waiting for the LINK UP and CARRIER flags right after doing a 'ip link set dev "$INTERFACE" up'.

In the /usr/lib/network/connections/ethernet script of netcfg, it assumes $INTERFACE (ex. 'eth0') is already existing, or else it will fail.  I commented the code below #### where the updated code should be placed. There's an example timeout_wait() near the bottom when it waits for 5 secs for the CARRIER signal.

/usr/lib/network/connections/ethernet (part of netcfg).
----------------------------------------------------------
.
ethernet_up() {
    load_profile "$1"
    SYSCTL_INTERFACE="${INTERFACE/.//}"

    #### As implemented now is_interface() exits on error when /sys/class/net/$INTERFACE doesn't exist yet.
    #### Insert a timeout_wait here (30 sec max?) so netcfg can wait for /sys/class/net/eth0 to show up before failing:
    if ! is_interface "$INTERFACE"; then
        report_iproute "Interface $INTERFACE does not exist"
    fi

    # Disable IPv6 before bringing the interface up to prevent SLAAC
    if [[ "$IP6" == "no" ]]; then
        sysctl -q -w "net.ipv6.conf.$SYSCTL_INTERFACE.disable_ipv6=1"
    fi

    report_debug ethernet_up bring_interface up "$INTERFACE"
    bring_interface up "$INTERFACE"

    if ! checkyesno "${SKIPNOCARRIER:-no}"; then
        # Some cards are plain slow to come up. Don't fail immediately.
        if ! timeout_wait "${CARRIER_TIMEOUT:-5}" '(( $(< "/sys/class/net/$INTERFACE/carrier") ))'; then
            report_iproute "No connection"
        fi
    fi
.

The is_interface() funtions is in /usr/lib/network/network (also part of netcfg).

/usr/lib/network/network (part of netcfg).
----------------------------------------------------------
is_interface() {
    local INTERFACE="$1"
    if [[ ! -e "/sys/class/net/$INTERFACE" ]]; then
        if ! echo "$INTERFACE" | grep -F -q ":"; then
            return 1
        fi
    fi
    return 0
}

The timeout_wait() function is in /usr/lib/network/globals (also part of netcfg).

/usr/lib/network/globals (part of netcfg).
----------------------------------------------------------
## Waits until a statement succeeds or a timeout occurs
# $1: timeout in seconds
# $2...: condition command
function timeout_wait() {
    local timeout="$1"
    (( timeout *= 10 ))
    shift
    while ! eval "$*"; do
        (( timeout-- > 0 )) || return 1
        sleep 0.1
    done
    return 0
}

This would be a viable solution until the systemd device dependencies are worked out. I'm not a confident bash coder so I leave others to work this out. Probably takes 2 min for the experienced ones.

Offline

#17 2012-10-30 08:32:39

SamSpade
Member
Registered: 2012-10-29
Posts: 9

Re: Systemd and Netcfg

Ok, finally figured out what the patch was for. Got the service file to work. Netcfg now loads only after eth0 is available:

/etc/systemd/system/netcfg.service
----------------------------------------------------
[Unit]
Description=Netcfg multi-profile daemon
Before=network.target
Wants=network.target
BindsTo=sys-subsystem-net-devices-eth0.device
After=sys-subsystem-net-devices-eth0.device
.
.

I now realize why brain0 is reconsidering Netcfg. The way the profiles are stuctured isn't friendly to systemd unit files without using a separate service file generator (netcfg-generator). For computers with just a static interface (eth0), it's not a problem though.

Thanks for the patch brain0.

Offline

#18 2012-10-30 11:12:44

igvk
Member
Registered: 2012-10-29
Posts: 8

Re: Systemd and Netcfg

SamSpade wrote:

Ok, finally figured out what the patch was for. Got the service file to work. Netcfg now loads only after eth0 is available:

/etc/systemd/system/netcfg.service
----------------------------------------------------
[Unit]
Description=Netcfg multi-profile daemon
Before=network.target
Wants=network.target
BindsTo=sys-subsystem-net-devices-eth0.device
After=sys-subsystem-net-devices-eth0.device
.
.

The part:
After=sys-subsystem-net-devices-eth0.device
doesn't work for me - netcfg starts before the interfaces are available.

Offline

#19 2012-10-30 11:23:22

SamSpade
Member
Registered: 2012-10-29
Posts: 9

Re: Systemd and Netcfg

igvk wrote:

The part:
After=sys-subsystem-net-devices-eth0.device
doesn't work for me - netcfg starts before the interfaces are available.

The BindsTo= is needed too, or else it won't work.

Also make sure that the new service file is under /etc/systemd/system/, NOT /etc/systemd/system/multi-user.target.wants/.  I made the same mistake before of changing the symlinks into actual files under ../multi-user.target.wants/. I was wondering why the behavior didn't change no matter what I did to the file.

The files under ../multi-user.target.wants/ need to remain as symlinks. Then run systemctl reenable netcfg, systemd will change the netcfg symlink under multi-user.target.wants/ to point to the new /etc/systemd/system/netcfg.service.

Check out https://wiki.archlinux.org/index.php/Sy … unit_files.

Offline

#20 2012-10-30 12:33:31

igvk
Member
Registered: 2012-10-29
Posts: 8

Re: Systemd and Netcfg

SamSpade wrote:

Also make sure that the new service file is under /etc/systemd/system/, NOT /etc/systemd/system/multi-user.target.wants/.  I made the same mistake before of changing the symlinks into actual files under ../multi-user.target.wants/. I was wondering why the behavior didn't change no matter what I did to the file.

The files under ../multi-user.target.wants/ need to remain as symlinks. Then run systemctl reenable netcfg, systemd will change the netcfg symlink under multi-user.target.wants/ to point to the new /etc/systemd/system/netcfg.service.

Check out https://wiki.archlinux.org/index.php/Sy … unit_files.

Thank you very much!
This is what helped after all. I made the same mistake of not placing the file into /etc/systemd/system.

Offline

#21 2012-11-28 14:28:54

Czarcasmo
Member
From: Colorado Springs, Colorado
Registered: 2011-04-20
Posts: 82

Re: Systemd and Netcfg

May tag on a question that was briefly touched on earlier in this thread? If I have net-auto-wired and net-auto-wireless enabled, do I need to disable the netcfg service or is it required for the first two to operate properly? When I check netcfg status it showed that failed, but my wireless connects automatically, so reading this thread makes me wonder if I need to change a couple things.

Thanks!
Czar.


Laptop: Lenovo X1 Carbon, Core i7 2.0Ghz, 8GB RAM, Gnome 3.16

Offline

#22 2012-11-29 01:44:22

ngoonee
Forum Fellow
From: Between Thailand and Singapore
Registered: 2009-03-17
Posts: 7,354

Re: Systemd and Netcfg

The description says "Netcfg multi-profile daemon". It's not needed by either net-auto-wired or net-auto-wireless, serves a different purpose entirely.


Allan-Volunteer on the (topic being discussed) mailn lists. You never get the people who matters attention on the forums.
jasonwryan-Installing Arch is a measure of your literacy. Maintaining Arch is a measure of your diligence. Contributing to Arch is a measure of your competence.
Griemak-Bleeding edge, not bleeding flat. Edge denotes falls will occur from time to time. Bring your own parachute.

Offline

#23 2012-11-29 21:43:31

Czarcasmo
Member
From: Colorado Springs, Colorado
Registered: 2011-04-20
Posts: 82

Re: Systemd and Netcfg

Thanks, ngoonee. I...probably should've checked the description first.

Cheers,
Czar.


Laptop: Lenovo X1 Carbon, Core i7 2.0Ghz, 8GB RAM, Gnome 3.16

Offline

#24 2012-11-30 00:24:26

ngoonee
Forum Fellow
From: Between Thailand and Singapore
Registered: 2009-03-17
Posts: 7,354

Re: Systemd and Netcfg

Yeah well, we do miss things once in a while. Please mark [solved] smile


Allan-Volunteer on the (topic being discussed) mailn lists. You never get the people who matters attention on the forums.
jasonwryan-Installing Arch is a measure of your literacy. Maintaining Arch is a measure of your diligence. Contributing to Arch is a measure of your competence.
Griemak-Bleeding edge, not bleeding flat. Edge denotes falls will occur from time to time. Bring your own parachute.

Offline

#25 2012-11-30 19:33:32

Czarcasmo
Member
From: Colorado Springs, Colorado
Registered: 2011-04-20
Posts: 82

Re: Systemd and Netcfg

I would if I could, igvk is the owner of this thread.


Laptop: Lenovo X1 Carbon, Core i7 2.0Ghz, 8GB RAM, Gnome 3.16

Offline

Board footer

Powered by FluxBB