Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wi-Fi fails to work when connman is enabled with networking.connman.enable = true. #23196

Closed
nihilx7e3 opened this issue Feb 26, 2017 · 21 comments
Labels
0.kind: bug Something is broken 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 9.needs: port to stable A PR needs a backport to the stable release.

Comments

@nihilx7e3
Copy link

Issue description

When connman is enabled with networking.connman.enable = true, connman fails to see Wi-Fi. It will not be listed in technologies & when running enable wifi in connmanctl you will get the cryptic & confusing error Error wifi: Method "SetProperty" with signature "sv" on interface "net.connman.Technology" doesn't exist

Oddly enough, connman works fine when networking.connman.enable = false & networking.wireless.enable = true (specifically, when wpa_supplicant is running, which of course also requires a valid wpa_supplicant.conf otherwise it'll fail.) & connmand is manually run as root.

Steps to reproduce

1.Put networking.connman.enable = true in configuration.nix.
2. Run nixos-rebuild switch --upgrade

Technical details

  • System: 17.03pre101839.53a2baa (Gorilla)
  • Nix version: nix-env (Nix) 1.11.6
  • Nixpkgs version: 17.03pre101839.53a2baa
@fpletz fpletz added this to the 17.03 milestone Feb 26, 2017
@fpletz fpletz added the 0.kind: bug Something is broken label Feb 26, 2017
@domenkozar
Copy link
Member

cc @matejc

@fpletz fpletz modified the milestones: 17.09, 17.03 Jul 25, 2017
@lukateras
Copy link
Member

@lukateras lukateras self-assigned this Dec 21, 2017
@lukateras lukateras removed this from the 17.09 milestone Dec 21, 2017
@lukateras lukateras added the 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS label Dec 21, 2017
@stefano-m
Copy link
Contributor

FTR I have applied a similar workaround to @yegortimoshenko in my configuration.nix

  networking.wireless = {
    enable = true; # Actually automatically enabled by connman.
    networks = {
      # Fake ssid so NixOS creates wpa_supplicant.conf
      # otherwise the service fails and WiFi is not available.
      # https://github.com/NixOS/nixpkgs/issues/23196
      S4AKR00UNUN21W1NV2Y5MDDW8 = {};
    };
  };

I think that it would be possible to fix this if the connman configuration did something similar when it's being instantiated:

  1. check wireless.networks
  2. if empty, add an entry that is a random string (to reduce the chance of collisions)

If people are interested, I'd be willing to submit a PR (with some guidance from maintainers/developers).

BTW, this happens in:

  • system: "x86_64-linux"
  • host os: Linux 4.14.43, NixOS, 18.03.132507.5f2da7f837e (Impala)
  • multi-user?: yes
  • sandbox: no
  • version: nix-env (Nix) 2.0.2
  • channels(root): "nixos-18.03.132507.5f2da7f837e"
  • channels(user): "nixpkgs-18.03.132448.33682d9af4c"
  • nixpkgs: /nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs

Thanks!

@doronbehar
Copy link
Contributor

So isn't it a duplicate of #56125 ?

@lukateras lukateras removed their assignment Dec 16, 2019
@doronbehar
Copy link
Contributor

This workaround is no longer needed.

@stefano-m
Copy link
Contributor

stefano-m commented Jul 25, 2020

@doronbehar unfortunately I can still reproduce the issue with a fresh NixOS 20.03.2651.0a40a3999eb.

Would it be possible to reopen this issue please? I don't want to create duplicates.

Thanks.

@doronbehar
Copy link
Contributor

@stefano-m many things have changed since your last comment - e.g the names of the options. I think it'd be better to open a new issue with better info of the NixOS version you use (I can confirm I don't experience this issue anymore on unstable) and ccing the module's maintainer.

@stefano-m
Copy link
Contributor

#56125 fixes the issue with iwd but the problem is still present with wpa_supplicant.

I can open a new GitHub issue allright, but the problem on the latest stable 20.03 (fresh installation) is the same as described here with the same workaround #23196 (comment)).

If the problem has been fixed in unstable, unfortunately it does not make the situation any better for users that are on the stable channel.

Also, AFAIU this does not even seem to be fixed in unstable, because networking.wireless.enable with no networks configured still relies on a /etc/wpa_supplicant.conf file

configFile = if cfg.networks != {} || cfg.extraConfig != "" || cfg.userControlled.enable then pkgs.writeText "wpa_supplicant.conf" ''

'' else "/etc/wpa_supplicant.conf";

that may or may not exist. In the case of connman, that file does not exist, which causes the wpa supplicant service to fail which causes connman to be unable to use wifi.

@jraygauthier
Copy link
Member

jraygauthier commented Sep 9, 2020

Alternative workaround (which is also nice for plain wpa supplicant use so that wpa_gui can be used by users in the network group):

{
  users.groups = {
    "network" = {};
  };

  systemd.services.wpa_supplicant_initial_cfg = {
      description = "WPA Supplicant Initial Configuration";

      before = [ "network.target" "wpa_supplicant.service" ];
      wants = [ "network.target" ];
      wantedBy = [ "multi-user.target" "wpa_supplicant.service" ];

      path = [];

      script = ''
        if ! test -e "/etc/wpa_supplicant.conf"; then
          printf "ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=network\nupdate_config=1\n" > /etc/wpa_supplicant.conf
        fi
        chmod 600 /etc/wpa_supplicant.conf
      '';

      serviceConfig = {
        Type = "oneshot";
        RemainAfterExit = true;
      };
  };

  networking = {
    wireless.enable = true;
    connman.enable = true;
  };
}

@doronbehar
Copy link
Contributor

If the problem has been fixed in unstable, unfortunately it does not make the situation any better for users that are on the stable channel.

I agree 😬 though we are near yet a 20.09 release and I sure hope whatever commit that fixed it on unstable will reach 20.09. I'll reopen as it seems others are still facing this issue on 20.03. If anyone is capable of verifying that the issue persists on 20.03 or 20.09, it'll help.

@doronbehar doronbehar reopened this Sep 9, 2020
@doronbehar doronbehar added the 9.needs: port to stable A PR needs a backport to the stable release. label Sep 9, 2020
@stefano-m
Copy link
Contributor

Well, I'm happy that this has been reopened although, looking at the code on master, I have the feeling that this is not yet solved.

The problem is that connman sets networking.wifi.enable to true but it does not set a default configuration for wpa_supplicant causing the wpa_supplicant service to fail.

I wish I had more time to look into it since it's been bothering me for a while. I hope that eventually I'll be able to post a PR.

Thanks for keeping this issue open.

@knuton
Copy link
Contributor

knuton commented Dec 14, 2020

Is it possible that this is related to #101963?

Applying @rnhmjoj's fix (#104722) I observe reliable availability of wifi in NixOS 20.09 (including on first boot), even when removing the dummy network workaround.

@stale
Copy link

stale bot commented Jun 16, 2021

I marked this as stale due to inactivity. → More info

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jun 16, 2021
@doronbehar
Copy link
Contributor

I close this considering @knuton's report that this is not an issue on stable and unstable anymore.

@stefano-m
Copy link
Contributor

Interesting... I have recently moved to NixOS 21.05 and the issue was still present for me. I don't mind that this issue has been closed. If I ever get to it I might investigate further and possibly submit a patch.

In the meantime I changed my workaround slightly:

  environment.etc."wpa_supplicant.conf".text = lib.mkIf
    config.services.connman.enable
    ''
      # Dummy config file. Connman uses wpa_supplicant directly.
    '';

The only annoying thing is that with 21.05 I get a warning whenever I rebuild because "wpa_supplicant" has not interfaces:

trace: warning: No network interfaces for wpa_supplicant have been configured: the service
may randomly fail to start at boot. You should specify at least one using the option
networking.wireless.interfaces.

I guess this can be avoided by conditionally disabling the warning is services.connman.enable is true.

@rnhmjoj
Copy link
Contributor

rnhmjoj commented Jun 19, 2021

@stefano-m I must be missing something: why are you enabling networking.wireless when using services.connman? You say connman starts wpa_supplicant manually, so you should configure the its daemon using networking.wireless.

@stefano-m
Copy link
Contributor

Not sure I follow...

IIRC services.connman.enable = true also enables networking.wireless

enable = mkIf (!enableIwd) true;

and I guess that then the warning follows.

Connman configures wpa_supplicant on its own, I don't need to do anything directly.

@rnhmjoj
Copy link
Contributor

rnhmjoj commented Jun 19, 2021

Ah, I missed that line, thanks. So, connman starts the daemon and writes to /etc/wpa_supplicant.conf at runtime?

@stefano-m
Copy link
Contributor

AFAIU no, it does not, it just sets networking.wireless to true (and disables NetworkManager).

I guess that ideally, it should create a dummy /etc/wpa_supplicant.conf if none exists, and at the same time networking.wireless should disable the warning if connman is enabled.

@knuton
Copy link
Contributor

knuton commented Jun 19, 2021

I close this considering @knuton's report that this is not an issue on stable and unstable anymore.

My report above was about a version of nixpkgs with #104722 applied, however this patch has been reverted in upstream nixpkgs and no longer is present in 21.05 (see also #107341 (comment)).

So I can't say how this behaves in current NixOS, sorry. :-)

@doronbehar doronbehar reopened this Jun 20, 2021
rnhmjoj added a commit to rnhmjoj/nixpkgs that referenced this issue Aug 11, 2021
I may have finally found a clean solution to the issues[1][2][3] with
the automatic discovery of wireless network interfaces.

[1]: NixOS#101963
[2]: NixOS#23196
[3]: NixOS#125917 (comment)

Currently the start script fails right away if no interface is available
by the time it's running, possibly leaving the system without network.
This happens when running a little early in the boot. A solution is to
instead wait for at least one interface to appear before scanning the
/sys/class/net/ directory. This is done here by listening for the right
udev events (from the net/wlan subsystem) using the `udevadm monitor`
command and grep to match its output.

This methods guarantees the availability of at least one interface to
wpa_supplicant, but won't add additional interfaces once it has started.
However, if the current interface is lost, say unplugged, the service is
automatically stopped and will be restarted as soon as a one (not
necessarily the same) is detected. It would be possible make this fully
dynamic by running another service that continously listen for udev
events and manages the main wpa_supplicant daemon, but this is probably
overkill.

I tested the following cases:

  - one interface, starting at boot, w/o predictable naming scheme
  - two interfaces, starting at boot (intel wireless and a usb adapter),
    w/o predictable naming scheme
  - one interface after the system booted, w/o predictable naming scheme
  - two interfaces after the system booted, w/o predictable naming scheme
  - unplugging and plugging back the current interface
@rnhmjoj
Copy link
Contributor

rnhmjoj commented Aug 16, 2021

This should be finally fixed with #127595 (now in nixos-unstable).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: bug Something is broken 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 9.needs: port to stable A PR needs a backport to the stable release.
Projects
None yet
Development

No branches or pull requests

9 participants