1. 17 Sep, 2018 1 commit
  2. 24 Jul, 2018 2 commits
    • Thomas Haller's avatar
      core: give better error reason why device is incompatible with profile · 33a88ca5
      Thomas Haller authored
      Note the special error codes  NM_UTILS_ERROR_CONNECTION_AVAILABLE_*.
      This will be used to determine, whether the profile is fundamentally
      incompatible with the device, or whether just some other properties
      mismatch. That information will be importand during a plain `nmcli
      connection up`, where NetworkManager searches all devices for a device
      to activate. If no device is found (and multiple errors happened),
      we want to show the error that is most likely relevant for the user.
      
      Also note, how NMDevice's check_connection_compatible() uses the new
      class field "device_class->connection_type_check_compatible" to simplify
      checks for compatible profiles.
      
      The error reason is still unused.
      33a88ca5
    • Thomas Haller's avatar
      wwan/trivial: rename NMModemClass.check_connection_compatible() to use unique name · 39f47e2f
      Thomas Haller authored
      We also have NMDeviceClass.check_connection_compatible(). It is preferable
      to use unique names, especially for the virtual function table. A reasonable
      thing to do is grep for the function name to find all places that implement
      this function. But if different classes use the same name, grep just
      turns up annoying false positives.
      39f47e2f
  3. 11 Jul, 2018 1 commit
    • Thomas Haller's avatar
      all: don't use gchar/gshort/gint/glong but C types · e1c7a2b5
      Thomas Haller authored
      We commonly don't use the glib typedefs for char/short/int/long,
      but their C types directly.
      
          $ git grep '\<g\(char\|short\|int\|long\|float\|double\)\>' | wc -l
          587
          $ git grep '\<\(char\|short\|int\|long\|float\|double\)\>' | wc -l
          21114
      
      One could argue that using the glib typedefs is preferable in
      public API (of our glib based libnm library) or where it clearly
      is related to glib, like during
      
        g_object_set (obj, PROPERTY, (gint) value, NULL);
      
      However, that argument does not seem strong, because in practice we don't
      follow that argument today, and seldomly use the glib typedefs.
      Also, the style guide for this would be hard to formalize, because
      "using them where clearly related to a glib" is a very loose suggestion.
      
      Also note that glib typedefs will always just be typedefs of the
      underlying C types. There is no danger of glib changing the meaning
      of these typedefs (because that would be a major API break of glib).
      
      A simple style guide is instead: don't use these typedefs.
      
      No manual actions, I only ran the bash script:
      
        FILES=($(git ls-files '*.[hc]'))
        sed -i \
            -e 's/\<g\(char\|short\|int\|long\|float\|double\)\>\( [^ ]\)/\1\2/g' \
            -e 's/\<g\(char\|short\|int\|long\|float\|double\)\>  /\1   /g' \
            -e 's/\<g\(char\|short\|int\|long\|float\|double\)\>/\1/g' \
            "${FILES[@]}"
      e1c7a2b5
  4. 10 May, 2018 1 commit
    • Lubomir Rintel's avatar
      all: use the elvis operator wherever possible · e69d3869
      Lubomir Rintel authored
      Coccinelle:
      
        @@
        expression a, b;
        @@
        -a ? a : b
        +a ?: b
      
      Applied with:
      
        spatch --sp-file ternary.cocci --in-place --smpl-spacing --dir .
      
      With some manual adjustments on spots that Cocci didn't catch for
      reasons unknown.
      
      Thanks to the marvelous effort of the GNU compiler developer we can now
      spare a couple of bits that could be used for more important things,
      like this commit message. Standards commitees yet have to catch up.
      e69d3869
  5. 30 Apr, 2018 1 commit
  6. 20 Mar, 2018 1 commit
    • Thomas Haller's avatar
      core: avoid clone of all-connections list for nm_utils_complete_generic() · e17cd1d7
      Thomas Haller authored
      NMSettings exposes a cached list of all connection. We don't need
      to clone it. Note that this is not save against concurrent modification,
      meaning, add/remove of connections in NMSettings will invalidate the
      list.
      
      However, it wasn't save against that previously either, because
      altough we cloned the container (GSList), we didn't take an additional
      reference to the elements.
      
      This is purely a performance optimization, we don't need to clone the
      list. Also, since the original list is of type "NMConnection *const*",
      use that type insistently, instead of dependent API requiring GSList.
      
      IMO, GSList is anyway not a very nice API for many use cases because
      it requires an additional slice allocation for each element. It's
      slower, and often less convenient to use.
      e17cd1d7
  7. 19 Mar, 2018 1 commit
  8. 21 Feb, 2018 3 commits
  9. 21 Dec, 2017 3 commits
  10. 30 Oct, 2017 1 commit
    • Thomas Haller's avatar
      all: avoid coverity warnings about "Wrong Check of Return Value" · 4a8a5495
      Thomas Haller authored
      30. NetworkManager-1.9.2/src/settings/plugins/keyfile/nms-keyfile-writer.c:218:
      check_return: Calling "g_mkdir_with_parents" without checking return
      value (as is done elsewhere 4 out of 5
       times).
      
      25. NetworkManager-1.9.2/src/platform/nm-linux-platform.c:3969:
      check_return: Calling "_nl_send_nlmsg" without checking return value (as
      is done elsewhere 4 out of 5 times).
      
      34. NetworkManager-1.9.2/src/nm-core-utils.c:2843:
      negative_returns: "fd2" is passed to a parameter that cannot be negative.
      
      26. NetworkManager-1.9.2/src/devices/wwan/nm-modem-broadband.c:897:
      check_return: Calling "nm_utils_parse_inaddr_bin" without checking
      return value (as is done elsewhere 4 out of 5 times).
      
      3. NetworkManager-1.9.2/src/devices/bluetooth/nm-bluez5-manager.c:386:
      check_return: Calling "g_variant_lookup" without checking return value
      (as is done elsewhere 79 out of 83 times).
      
      16. NetworkManager-1.9.2/libnm-util/nm-setting.c:405:
      check_return: Calling "nm_g_object_set_property" without checking return
      value (as is done elsewhere 4 out of 5 times).
      4a8a5495
  11. 10 Oct, 2017 1 commit
    • Thomas Haller's avatar
      core: rework tracking of gateway/default-route in ip-config · 5c299454
      Thomas Haller authored
      Instead of having 3 properties @gateway, @never_default and @has_gateway
      on NMIP4Config/NMIP6Config that determine the default-route, track the
      default-route as a regular route.
      
      The gateway setting is the configuration knob for the default-route.
      Since an NMIP4Config/NMIP6Config instance only has one gateway property,
      it cannot track more then one default-routes (see related bug rh#1445417).
      Especially with policy routing, it might be interesting to configure a
      default-route in multiple tables.
      
      Also, later it might be interesting to allow adding default-routes as
      regular static routes in a connection, so that the user can configure additional
      route parameters for the default-route or add default-routes in multiple tables.
      
      With this patch, default-routes now have a rt_source property according to their
      origin.
      
      Also, the previous commits of this branch broke handling of the
      default-route :) . That should be working now again.
      5c299454
  12. 06 Oct, 2017 2 commits
  13. 05 Jul, 2017 1 commit
    • Thomas Haller's avatar
      core: pass NMDedupMultiIndex instance to NMIP4Config and other · 89385bd9
      Thomas Haller authored
      NMIP4Config, NMIP6Config, and NMPlatform shall share one
      NMDedupMultiIndex instance.
      
      For that, pass an NMDedupMultiIndex instance to NMPlatform and NMNetns.
      NMNetns than passes it on to NMDevice, NMDhcpClient, NMIP4Config and NMIP6Config.
      So currently NMNetns is the access point to the shared NMDedupMultiIndex
      instance, and it gets it from it's NMPlatform instance.
      
      The NMDedupMultiIndex instance is really a singleton, we don't want
      multiple instances of it. However, for testing, instead of adding a
      singleton instance, pass the instance explicitly around.
      89385bd9
  14. 24 Mar, 2017 2 commits
  15. 23 Feb, 2017 1 commit
  16. 22 Feb, 2017 1 commit
    • Thomas Haller's avatar
      device: rename device-state-reason argument to out_failure_reason · 437c12fc
      Thomas Haller authored
      This argument is only relevant when the NMActStageReturn argument
      indicates NM_ACT_STAGE_RETURN_FAILURE. In all other cases it is ignored.
      
      Rename the argument to make the meaning clearer. The argument is passed
      through several layers of code, it isn't obvious that this argument only
      matters for the failure case. Also, the distinct name makes it easier
      to distinguish from other uses of the "reason" name.
      
      While at it, do some drive-by cleanup:
      
        - use g_return_*() instead of g_assert() to have a more graceful
          assertion.
        - functions like dhcp4_start() don't need to return a failure reason.
          Most callers don't care, and the caller who does can determine the
          proper reason.
        - allow omitting the out-argument via NM_SET_OUT().
      437c12fc
  17. 06 Feb, 2017 1 commit
  18. 21 Nov, 2016 1 commit
    • Thomas Haller's avatar
      build: don't add subdirectories to include search path but require qualified include · 44ecb415
      Thomas Haller authored
      Keep the include paths clean and separate. We use directories to group source
      files together. That makes sense (I guess), but then we should use this
      grouping also when including files. Thus require to #include files with their
      path relative to "src/".
      
      Also, we build various artifacts from the "src/" tree. Instead of having
      individual CFLAGS for each artifact in Makefile.am, the CFLAGS should be
      unified. Previously, the CFLAGS for each artifact differ and are inconsistent
      in which paths they add to the search path. Fix the inconsistency by just
      don't add the paths at all.
      44ecb415
  19. 18 Nov, 2016 1 commit
  20. 04 Oct, 2016 1 commit
    • Thomas Haller's avatar
      core: refactor private data in "src" · 4d37f7a1
      Thomas Haller authored
      - use _NM_GET_PRIVATE() and _NM_GET_PRIVATE_PTR() everywhere.
      
      - reorder statements, to have GObject related functions (init, dispose,
        constructed) at the bottom of each file and in a consistent order w.r.t.
        each other.
      
      - unify whitespaces in signal and properties declarations.
      
      - use NM_GOBJECT_PROPERTIES_DEFINE() and _notify()
      
      - drop unused signal slots in class structures
      
      - drop unused header files for device factories
      4d37f7a1
  21. 02 Sep, 2016 1 commit
  22. 10 Jul, 2016 1 commit
  23. 28 Jun, 2016 1 commit
  24. 16 May, 2016 1 commit
    • Thomas Haller's avatar
      wwan: fix crash during nm_modem_deactivate()/disconnect_context_complete() · 57a2aba0
      Thomas Haller authored
          (gdb) bt
          #0  0x00007ffff4d9e075 in g_type_check_instance_is_fundamentally_a (type_instance=type_instance@entry=0x-1, fundamental_type=fundamental_type@entry=80) at gtype.c:4030
          #1  0x00007ffff4d7e447 in g_object_unref (_object=0xffffffffffffffff) at gobject.c:3076
          #2  0x00007fffe89cdfa8 in disconnect_context_complete (ctx=ctx@entry=0x555555b4c680) at nm-modem-broadband.c:1062
          #3  0x00007fffe89cf6e5 in disconnect (modem=<optimized out>, warn=0, cancellable=0x0, callback=0x0, user_data=0x0) at nm-modem-broadband.c:1126
          #4  0x00007fffe89d24cd in nm_modem_deactivate (self=0x555555aba1b0 [NMModemBroadband], device=device@entry=0x555555ab8c20 [NMDeviceModem]) at nm-modem.c:1164
          #5  0x00007fffdbd73022 in deactivate (device=0x555555ab8c20 [NMDeviceModem]) at nm-device-modem.c:455
          #6  0x00005555555e087b in nm_device_cleanup (self=self@entry=0x555555ab8c20 [NMDeviceModem], reason=reason@entry=NM_DEVICE_STATE_REASON_NOW_MANAGED, cleanup_type=cleanup_type@entry=CLEANUP_TYPE_DECONFIGURE)
              at devices/nm-device.c:10392
          #7  0x00005555555e0ffd in _set_state_full (self=self@entry=0x555555ab8c20 [NMDeviceModem], state=state@entry=NM_DEVICE_STATE_UNAVAILABLE, reason=reason@entry=NM_DEVICE_STATE_REASON_NOW_MANAGED, quitting=quitting@entry=0) at devices/nm-device.c:10804
          #8  0x00005555555e1a16 in nm_device_state_changed (self=self@entry=0x555555ab8c20 [NMDeviceModem], state=state@entry=NM_DEVICE_STATE_UNAVAILABLE, reason=reason@entry=NM_DEVICE_STATE_REASON_NOW_MANAGED)
              at devices/nm-device.c:11029
      
      Fixes: 21b50c59
      57a2aba0
  25. 12 May, 2016 3 commits
  26. 10 May, 2016 3 commits
    • Thomas Haller's avatar
      wwan: return from send_pin_ready() when operation cancelled and fix leak · 37827fca
      Thomas Haller authored
      We call the asynchrnous function mm_sim_send_pin() without taking a
      reference on @self. During send_pin_ready() we must first check whether
      the request was cancelled because self might be a dangling pointer at
      this point.
      
      Also, avoid leaking @Error if the ctx is no longer valid.
      
      Fixes: aa0b3796
      37827fca
    • Lubomir Rintel's avatar
      modem: clear the connection context on device disconnection · 702b74c9
      Lubomir Rintel authored
      If the device is disconnected, we should also disconnect the modem; and
      while we disconnect the device we should clean the connection context.
      Otherwise the modem will surprise us by emitting PREPARED signal when
      the device is no longer PREPARED:
      
        NetworkManager[28469]: <info>  [1462383185.8714] (ttyACM1): modem state changed, 'disconnecting' --> 'registered' (reason: user-requested)
        NetworkManager[28469]: <info>  [1462383185.8715] (ttyACM1): modem state changed, 'registered' --> 'connecting' (reason: user-requested)
        NetworkManager[28469]: <info>  [1462383185.8716] device (ttyACM1): state change: deactivating -> disconnected (reason 'connection-removed') [110 30 38]
        NetworkManager[28469]: <info>  [1462383185.8759] (ttyACM1): modem state changed, 'connecting' --> 'disconnecting' (reason: user-requested)
        NetworkManager[28469]: <warn>  [1462383185.8937] (ttyACM1): failed to connect modem: Dial operation has been cancelled
      
        (NetworkManager:28469): NetworkManager-wwan-CRITICAL **: modem_prepare_result: assertion 'state == NM_DEVICE_STATE_PREPARE' failed
      
        Program received signal SIGTRAP, Trace/breakpoint trap.
        g_logv (log_domain=0x7fffea31bc47 "NetworkManager-wwan", log_level=G_LOG_LEVEL_CRITICAL, format=<optimized out>, args=args@entry=0x7fffffffcfc0) at gmessages.c:1086
        1086              g_private_set (&g_log_depth, GUINT_TO_POINTER (depth));
        (gdb) bt
        #0  0x00007ffff4ebe643 in g_logv (log_domain=0x7fffea31bc47 "NetworkManager-wwan", log_level=G_LOG_LEVEL_CRITICAL, format=<optimized out>, args=args@entry=0x7fffffffcfc0) at gmessages.c:1086
        #1  0x00007ffff4ebe7bf in g_log (log_domain=<optimized out>, log_level=<optimized out>, format=<optimized out>) at gmessages.c:1119
        Python Exception <type 'exceptions.RuntimeError'> Cannot locate object file for block.:
        #2  0x00007ffff2ce6dac in ffi_call_unix64#3  0x00007ffff2ce66d5 in ffi_call (cif=cif@entry=0x7fffffffd300, fn=<optimized out>, rvalue=0x7fffffffd230, avalue=avalue@entry=0x7fffffffd1d0) at ../src/x86/ffi64.c:522
        #4  0x00007ffff51b55a5 in g_cclosure_marshal_generic_va (closure=0x555555b30cb0, return_value=0x0, instance=0x555555a8d360, args_list=<optimized out>, marshal_data=0x0, n_params=2, param_types=0x555555c2bb60) at gclosure.c:1600
        #5  0x00007ffff51b4b37 in _g_closure_invoke_va (closure=closure@entry=0x555555b30cb0, return_value=return_value@entry=0x0, instance=instance@entry=0x555555a8d360, args=args@entry=0x7fffffffd5b8, n_params=2, param_types=0x555555c2bb60) at gclosure.c:864
        #6  0x00007ffff51ce117 in g_signal_emit_valist (instance=instance@entry=0x555555a8d360, signal_id=signal_id@entry=168, detail=detail@entry=0, var_args=var_args@entry=0x7fffffffd5b8) at gsignal.c:3292
        #7  0x00007ffff51cf2e8 in g_signal_emit_by_name (instance=instance@entry=0x555555a8d360, detailed_signal=detailed_signal@entry=0x7fffea074cdd "prepare-result") at gsignal.c:3479
        #8  0x00007fffea011fd3 in connect_context_step (self=self@entry=0x555555a8d360 [NMModemBroadband]) at nm-modem-broadband.c:529
        #9  0x00007fffea01264d in connect_ready (simple_iface=<optimized out>, res=<optimized out>, self=0x555555a8d360 [NMModemBroadband]) at nm-modem-broadband.c:378
        #10 0x00007ffff546a297 in g_simple_async_result_complete (simple=0x7fffe00104e0 [GSimpleAsyncResult]) at gsimpleasyncresult.c:801
        #11 0x00007fffe9d82fec in connect_context_complete_and_free (ctx=ctx@entry=0x555555c52f60) at mm-modem-simple.c:93
        #12 0x00007fffe9d83155 in simple_connect_ready (self=0x7fffdc00b9f0 [MMModemSimple], res=0x7fffdc004410, ctx=0x555555c52f60) at mm-modem-simple.c:159
        #13 0x00007ffff547af93 in g_task_return_now (task=0x7fffdc004410 [GTask]) at gtask.c:1106
        #14 0x00007ffff547b62e in g_task_return (task=0x7fffdc004410 [GTask], type=<optimized out>) at gtask.c:1164
        #15 0x00007ffff54d4239 in reply_cb (connection=<optimized out>, res=<optimized out>, user_data=0x7fffdc004410) at gdbusproxy.c:2570
        #16 0x00007ffff547af93 in g_task_return_now (task=0x7fffdc004340 [GTask]) at gtask.c:1106
        #17 0x00007ffff547b62e in g_task_return (task=0x7fffdc004340 [GTask], type=<optimized out>) at gtask.c:1164
        #18 0x00007ffff54c8c9f in g_dbus_connection_call_done (source=<optimized out>, result=0x555555a60920, user_data=0x7fffdc004340) at gdbusconnection.c:5702
        #19 0x00007ffff547af93 in g_task_return_now (task=0x555555a60920 [GTask]) at gtask.c:1106
        #20 0x00007ffff547afc9 in complete_in_idle_cb (task=0x555555a60920) at gtask.c:1120
        #21 0x00007ffff4eb7d7a in g_main_context_dispatch (context=0x555555a4a000) at gmain.c:3152
        #22 0x00007ffff4eb7d7a in g_main_context_dispatch (context=context@entry=0x555555a4a000) at gmain.c:3767
        #23 0x00007ffff4eb80b8 in g_main_context_iterate (context=0x555555a4a000, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>) at gmain.c:3838
        #24 0x00007ffff4eb838a in g_main_loop_run (loop=0x555555a48780) at gmain.c:4032
        #25 0x00005555555aebf2 in main (argc=1, argv=0x7fffffffdc48) at main.c:477
        (gdb)
      702b74c9
    • Lubomir Rintel's avatar
      modem-broadband: ignore late callbacks · aa0b3796
      Lubomir Rintel authored
      If libmm invokes callbacks after the connect context has been disposed
      we should just ignore them. Fixes crash on dereferencing already freed
      connect context (due to explicit disconnection while the modem is
      connecting):
      
        NetworkManager[29074]: <info>  [1462383917.8718] (ttyACM1): modem state changed, 'disconnecting' --> 'registered' (reason: user-requested)
        NetworkManager[29074]: <info>  [1462383917.8719] (ttyACM1): modem state changed, 'registered' --> 'connecting' (reason: user-requested)
        NetworkManager[29074]: <info>  [1462383917.8720] device (ttyACM1): state change: deactivating -> disconnected (reason 'connection-removed') [110 30 38]
        NetworkManager[29074]: <info>  [1462383917.8758] (ttyACM1): modem state changed, 'connecting' --> 'disconnecting' (reason: user-requested)
        NetworkManager[29074]: <warn>  [1462383917.8909] (ttyACM1): failed to connect modem: Dial operation has been cancelled
      
        (NetworkManager:29074): NetworkManager-wwan-CRITICAL **: modem_prepare_result: assertion 'state == NM_DEVICE_STATE_PREPARE' failed
        NetworkManager[29074]: <info>  [1462383917.8912] (ttyACM1): modem state changed, 'disconnecting' --> 'registered' (reason: user-requested)
        NetworkManager[29074]: <info>  [1462383917.8913] (ttyACM1): modem state changed, 'registered' --> 'connecting' (reason: user-requested)
        NetworkManager[29074]: <info>  [1462383917.9693] (ttyACM1): modem state changed, 'connecting' --> 'registered' (reason: user-requested)
      
        Program received signal SIGSEGV, Segmentation fault.
        connect_ready (simple_iface=<optimized out>, res=0x7fffe0009200, self=0x555555a8d670 [NMModemBroadband]) at nm-modem-broadband.c:329
        329                     if (!ctx->first_error) {
        (gdb) bt
        #0  0x00007fffea01272a in connect_ready (simple_iface=<optimized out>, res=0x7fffe0009200, self=0x555555a8d670 [NMModemBroadband]) at nm-modem-broadband.c:329
        #1  0x00007ffff546a297 in g_simple_async_result_complete (simple=0x7fffe0009200 [GSimpleAsyncResult]) at gsimpleasyncresult.c:801
        #2  0x00007fffe9d82fec in connect_context_complete_and_free (ctx=ctx@entry=0x7fffdc00c550) at mm-modem-simple.c:93
        #3  0x00007fffe9d83155 in simple_connect_ready (self=0x7fffdc00c960 [MMModemSimple], res=0x555555a7c2b0, ctx=0x7fffdc00c550) at mm-modem-simple.c:159
        #4  0x00007ffff547af93 in g_task_return_now (task=0x555555a7c2b0 [GTask]) at gtask.c:1106
        #5  0x00007ffff547b62e in g_task_return (task=0x555555a7c2b0 [GTask], type=<optimized out>) at gtask.c:1164
        #6  0x00007ffff54d4239 in reply_cb (connection=<optimized out>, res=<optimized out>, user_data=0x555555a7c2b0) at gdbusproxy.c:2570
        #7  0x00007ffff547af93 in g_task_return_now (task=0x7fffdc004470 [GTask]) at gtask.c:1106
        #8  0x00007ffff547b62e in g_task_return (task=0x7fffdc004470 [GTask], type=<optimized out>) at gtask.c:1164
        #9  0x00007ffff54c8c9f in g_dbus_connection_call_done (source=<optimized out>, result=0x7fffe00036f0, user_data=0x7fffdc004470) at gdbusconnection.c:5702
        #10 0x00007ffff547af93 in g_task_return_now (task=0x7fffe00036f0 [GTask]) at gtask.c:1106
        #11 0x00007ffff547afc9 in complete_in_idle_cb (task=0x7fffe00036f0) at gtask.c:1120
        #12 0x00007ffff4eb7d7a in g_main_context_dispatch (context=0x555555a4a000) at gmain.c:3152
        #13 0x00007ffff4eb7d7a in g_main_context_dispatch (context=context@entry=0x555555a4a000) at gmain.c:3767
        #14 0x00007ffff4eb80b8 in g_main_context_iterate (context=0x555555a4a000, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>) at gmain.c:3838
        #15 0x00007ffff4eb838a in g_main_loop_run (loop=0x555555a48780) at gmain.c:4032
        #16 0x00005555555aebf2 in main (argc=1, argv=0x7fffffffdc78) at main.c:477
        (gdb)
      aa0b3796
  27. 28 Apr, 2016 2 commits
  28. 11 Apr, 2016 1 commit