Re: [systemd-devel] Handling on network-connections and networkmanager

2017-06-19 Thread Dan Williams
On Sun, 2017-06-18 at 01:47 +0200, Jakob Schürz wrote:
> Hi there!
> 
> I didn't found anything about the following problem:
> There is network.target and network-online.target. In combination
> with
> NetworkManager network-online.target get started, when
> NetworkManager-wait-online.service exits successfull.
> 
> This is all ok, if i have a computer with permanent LAN/WLAN-
> connection.
> But it doesn't fit the needs for laptops moved in different networks.
> 
> I need NetworkManager, because i use LAN, WLAN, Modem-Connections as
> well as USB-Thetering. So a setup with networkd is not the best way
> in
> my case.
> 
> I have some ftp-mountpoints, which i have configured with automount
> and
> auto-unmounting after idle-time.
> When the automount is activated on boot, a simple ls on this
> mountpoint
> can block the whole system, when there is no network. So i bound the
> automount-unit to network-online.target with
> "BindsTo=network-online.target". This works fine. ls gives me an
> empty
> directory, when no network-connection is active, and gives me back
> the
> content of the mounted dir, when the network-connection is active.
> 
> BUT
> 
> When i stop the network-connection from the gnome-nm-applet, or when
> i'm
> sitting in a train and there is no network-connection possible (in
> case
> of a tunnel), the automount-unit should be stopped. But in normal
> configuration this never will happen.

NetworkManager has a "pre-down" capability via dispatcher scripts (see
man NetworkManager) that calls out to scripts in
/etc/NetworkManager/dispatcher.d when a network connection is
disconnected explicitly by the user.  You could use this to unmount
cleanly when using NM.  NM will block the actual network disconnection
until your script completes (subject to reasonable times of course).

Obviously, if the network connection drops unexpectedly this is not
possible, and the connection is already gone when your script runs.  So
the best possible way to solve all this is to ensure that your
filesystem driver can handle unexpected network dropouts cleanly.

Dan

> Do you have any suggestions, how to solve this problem?
> 
> I tried a solution:
> 
> i created a simple script, which checks the connection every minute.
> Is
> there a connection, and is this connection working (realized with a
> ping
> to a server in the internet), then network-online.target gets
> (re)started.
> If there is no connection, or the connection is not working (think
> about
> WLAN in a train in a tunnel, WLAN is working, but no connection to
> the
> internet is possible), network-online.target gets stopped.
> 
> Also a simple script in NetworkManager/dispatcher.d/, wich starts
> network-online.target, when a connection changes its state zu up, and
> stop this target, when a connection changes to down.
> 
> All services, which should stop on closing the network-connection
> have
> the dependency BindsTo=network-online.target
> 
> But i'm not sure, if this is a good solution to change the behaviour
> of
> network-online.target. Should i create a own target? Or is there
> another, better solution?
> 
> greets
> 
> jakob
> 
> ___
> systemd-devel mailing list
> systemd-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/systemd-devel
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Handling on network-connections and networkmanager

2017-06-17 Thread Andrei Borzenkov
18.06.2017 02:47, Jakob Schürz пишет:
...
> 
> i created a simple script, which checks the connection every minute. Is
> there a connection, and is this connection working (realized with a ping
> to a server in the internet), then network-online.target gets (re)started.
> If there is no connection, or the connection is not working (think about
> WLAN in a train in a tunnel, WLAN is working, but no connection to the
> internet is possible), network-online.target gets stopped.
> 
> Also a simple script in NetworkManager/dispatcher.d/, wich starts
> network-online.target, when a connection changes its state zu up, and
> stop this target, when a connection changes to down.
> 
> All services, which should stop on closing the network-connection have
> the dependency BindsTo=network-online.target
> 
> But i'm not sure, if this is a good solution to change the behaviour of
> network-online.target. Should i create a own target? Or is there
> another, better solution?
> 


systemd is not designed to track network state, nor is
network-online.target meaningful outside of initial boot transaction. So
yes, it would be more clean to use custom target to avoid confusion.
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] Handling on network-connections and networkmanager

2017-06-17 Thread Jakob Schürz
Hi there!

I didn't found anything about the following problem:
There is network.target and network-online.target. In combination with
NetworkManager network-online.target get started, when
NetworkManager-wait-online.service exits successfull.

This is all ok, if i have a computer with permanent LAN/WLAN-connection.
But it doesn't fit the needs for laptops moved in different networks.

I need NetworkManager, because i use LAN, WLAN, Modem-Connections as
well as USB-Thetering. So a setup with networkd is not the best way in
my case.

I have some ftp-mountpoints, which i have configured with automount and
auto-unmounting after idle-time.
When the automount is activated on boot, a simple ls on this mountpoint
can block the whole system, when there is no network. So i bound the
automount-unit to network-online.target with
"BindsTo=network-online.target". This works fine. ls gives me an empty
directory, when no network-connection is active, and gives me back the
content of the mounted dir, when the network-connection is active.

BUT

When i stop the network-connection from the gnome-nm-applet, or when i'm
sitting in a train and there is no network-connection possible (in case
of a tunnel), the automount-unit should be stopped. But in normal
configuration this never will happen.

Do you have any suggestions, how to solve this problem?

I tried a solution:

i created a simple script, which checks the connection every minute. Is
there a connection, and is this connection working (realized with a ping
to a server in the internet), then network-online.target gets (re)started.
If there is no connection, or the connection is not working (think about
WLAN in a train in a tunnel, WLAN is working, but no connection to the
internet is possible), network-online.target gets stopped.

Also a simple script in NetworkManager/dispatcher.d/, wich starts
network-online.target, when a connection changes its state zu up, and
stop this target, when a connection changes to down.

All services, which should stop on closing the network-connection have
the dependency BindsTo=network-online.target

But i'm not sure, if this is a good solution to change the behaviour of
network-online.target. Should i create a own target? Or is there
another, better solution?

greets

jakob

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel