Commit Graph

22651 Commits

Author SHA1 Message Date
Thomas Haller
cb5a81399a cli: don't interpret value as index too early for nmc_setting_remove_property_option()
Not all implementations support having the value being an index.
For example, the implementations that are done via DEFINE_REMOVER_OPTION() macro.

The meaning of the "value" string must not be determined by
nmc_setting_remove_property_option(). It's up to the implementation
to decide whether to allow an index and how to interpret it.
2019-03-25 09:12:32 +01:00
Thomas Haller
d3cfe20598 cli: support removing multiple vlan ingress/egress priority mappings
$ nmcli connection add type vlan autoconnect no con-name v dev vlan.1 id 1
    $ nmcli connection modify v +vlan.ingress-priority-map 1:2,2:3
    $ nmcli connection modify v +vlan.ingress-priority-map 2:3,4:5
    $ nmcli connection modify v -vlan.ingress-priority-map 1:2,4:5
    Warning: only one mapping at a time is supported; taking the first one (1:2)
2019-03-25 09:12:32 +01:00
Thomas Haller
626aed64e7 cli: don't fail removing non-existing option (pt6)
Part 6, which addresses the issue for VLAN priority maps.
2019-03-25 09:12:32 +01:00
Thomas Haller
eff01cd256 cli: don't fail removing non-existing option (pt5)
Part 5, which addresses the issue for DEFINE_REMOVER_OPTION(),
which are simple properties.
2019-03-25 09:12:32 +01:00
Thomas Haller
6baaa20763 cli: don't fail removing non-existing option (pt4)
Part 4, which addresses the issue for properties that have
complex values.
2019-03-25 09:12:32 +01:00
Thomas Haller
936912cad0 cli: don't fail removing non-existing option (pt3)
Part 3, which addresses the issue for properties that have
a simple validation function.
2019-03-25 09:12:32 +01:00
Thomas Haller
83fb6bcb42 cli: don't fail removing non-existing option (pt2)
Part 2, which addresses the issue for properties with a static
list of valid values.
2019-03-25 09:12:32 +01:00
Thomas Haller
0055d8ed58 cli: don't fail removing non-existing option (pt1)
Part 1, which addresses the issue for simple properties that have
a plain remove-by-value function.

Rationale:

Removing a value/index that does not exist should not be a failure.

Woule you like:

    $ nmcli connection modify "$PROFILE" autoconnect no
    $ nmcli connection modify "$PROFILE" autoconnect no
    Error: autoconnect is already disabled

So, why would it be a good idea to fail during

    $ nmcli connection modify "$PROFILE" -vpn.data ca
    $ nmcli connection modify "$PROFILE" -vpn.data ca
    Error: failed to remove a value from vpn.data: invalid option 'ca'.

Generally, it should not be an error to remove an option, as long
as the option itself is valid. For example,

    $ nmcli connection modify "$PROFILE" -vlan.ingress-priority-map bogus

should fail, but

    $ nmcli connection modify "$PROFILE" -vlan.ingress-priority-map 1:5

should succeed even if there was nothing to remove.
2019-03-25 09:12:32 +01:00
Thomas Haller
d178c25728 libnm,cli: move cleanup macros to "shared/nm-libnm-core-utils.h" 2019-03-25 09:12:32 +01:00
Thomas Haller
25ef45ff3d libnm/cli: support deleting VLAN egress/ingress priority map by "from"
The "from" part is like a key for the egress/ingress priority map.

Extend nm_setting_vlan_remove_priority_str_by_value() to accept only the
"from" part when finding and deleting value. This allows for:

    $ nmcli connection modify "$PROFILE" -vlan.ingress-priority-map '4:'
    $ nmcli connection modify "$PROFILE" -vlan.ingress-priority-map '4:*'

to fuzzy match the value to remove.
2019-03-25 09:12:32 +01:00
Thomas Haller
bb4e5a7a62 cli: don't treat empty string as valid number in nmc_string_to_uint_base()
How hard can it be to use strtol()? Apparently very. You need to check
errno, the endpointer, and also not pass in an empty string.

Previously, nmc_string_to_uint_base() would silently accept "" as valid
number. That's a bug.

Btw, let's not use strtol() (or nmc_string_to_uint*()). We have
_nm_utils_ascii_str_to_int64(), which gets all of this right.
2019-03-25 09:12:32 +01:00
Thomas Haller
b56e430da9 cli: reuse nm_utils_vlan_priority_map_parse_str() in _parse_vlan_priority_maps() 2019-03-25 09:12:32 +01:00
Thomas Haller
5079cd9942 libnm: move parsing VLAN priority mapping to "shared/nm-libnm-core-utils.h"
The same code is used by nmcli. Obviously, clients also need to
parse string representations.

That begs the question whether this should be public API of libnm.
Maybe, but don't decide that now, just reuse the code internally via
"shared/nm-libnm-core-utils.h".
2019-03-25 09:12:32 +01:00
Thomas Haller
d0f1e68b3e shared: add "shared/nm-libnm-core-utils.h" utils
We have code in "shared/nm-utils" which are general purpose
helpers, independent of "libnm", "libnm-core", "clients" and "src".

We have shared code like "shared/nm-ethtool-utils.h" and
"shared/nm-meta-setting.h", which is statically linked, shared
code that contains libnm related helpers. But these helpers already
have a specific use (e.g. they are related to ethtool or NMSetting
metadata).

Add a general purpose helper that:

 - depends (and extends) libnm-core

 - contains unrelated helpers

 - can be shared (meaning it will be statically linked).

 - this code can be used by any library user of "libnm.so"
   (nmcli, nm-applet) and by "libnm-core" itself. Thus, "src/"
   and "libnm/" may also use this code indirectly, via "libnm-core/".
2019-03-25 09:12:32 +01:00
Thomas Haller
aaaccfd264 libnm: refactor parsing of NMVlanQosMapping and support wildcard for "to"
- avoid the memory allocations by not using g_strsplit().

- add a helper function priority_map_parse_str(). This will
  be used later, to avoid allocating a NMVlanQosMapping
  result, when we don't need it on the heap.

- for the priority mappings, the "from" part is the key and must
  be unique. As such, it would make sense to say

    $ nmcli connection modify "$PROFILE" -vlan.ingress-priority-map '1:*'

  or

    $ nmcli connection modify "$PROFILE" -vlan.ingress-priority-map '1:'

  to delete any mapping for that priority, regardless of the "to" part.
  Add an option to leave the "to" part unspecified. This will be used
  later.
2019-03-25 09:12:32 +01:00
Thomas Haller
395738900f libnm: don't use strlen() for checking for non-empty string
It's well understood that these are NUL terminated strings.
We don't need strlen() to check that the strings aren't
empty.
2019-03-25 09:12:32 +01:00
Thomas Haller
731d251cc0 shared: don't implement nm_utils_parse_inaddr() based on nm_utils_parse_inaddr_bin()
nm_utils_parse_inaddr() is trivial enough to reimplement it, instead of calling
nm_utils_parse_inaddr_bin(). Calling nm_utils_parse_inaddr_bin() involves several
things that don't matter for nm_utils_parse_inaddr() -- like assigning
out_addr_family or returning the binary address.
2019-03-25 09:12:32 +01:00
Thomas Haller
e187bd08fe cli: fix leaking error variables setting vfs, qdiscs and tfilters 2019-03-25 09:12:32 +01:00
Thomas Haller
4e7eadd6d3 cli: fix appending team link-watchers
The set_fcn() function is supposed to only append. For the set-all
mode, the caller ensures to clear the array first.
2019-03-25 09:12:32 +01:00
Thomas Haller
c7864fc1b2 libnm/team: merge branch 'th/libnm-team-fixes'
https://github.com/NetworkManager/NetworkManager/pull/318
2019-03-25 08:09:29 +01:00
Thomas Haller
2a93ce9122 libnm/team: preserve unset priv->runner_tx_hash in _align_team_properties()
There is a difference between an unset JSON array element and an empty
one. Don't loose that information.
2019-03-24 09:21:14 +01:00
Thomas Haller
5478853a0b libnm/team: check for changes to team:runner-tx-hash in _align_team_properties()
We will need to emit property changed signals. For that we need to know
whether the property changes. Compare it.
2019-03-24 09:21:14 +01:00
Thomas Haller
9d2a15514a libnm/team: add function to compare list of link-watchers 2019-03-24 09:21:14 +01:00
Thomas Haller
265864952d libnm/team: simplify handling in _nm_utils_team_config_set()
- use nm_auto_decref_json for "json_value" to indicate ownership
  transfer.
- don't reuse variable json_element and json_link to construct
  watchers list. It's confusing. In general, use different variables
  for different purposes.
2019-03-24 09:21:14 +01:00
Thomas Haller
0cff18e055 libnm/team: indicate whether there were changes in _nm_utils_team_config_set() 2019-03-24 09:21:13 +01:00
Thomas Haller
f84323bf47 libnm/team: return early from _nm_utils_team_config_set() 2019-03-24 09:21:13 +01:00
Thomas Haller
00b0dfb5df libnm/team: avoid assertions parsing JSON of invalid type
_nm_utils_team_config_get() determines the type based on the JSON content.
Hence, the caller must validate that the returned GValue is of the expected
type, or it will trigger an assertion/crash.
2019-03-24 09:21:13 +01:00
Thomas Haller
3b69816ed6 libnm/team: fix memleaks in getting json values
Use nm_auto*, it's almost always harder to get wrong, because
ownership (and lifetime management of a variable, and what it points
to) is more clearly expressed.
2019-03-24 09:21:13 +01:00
Thomas Haller
1283d9d321 libnm/team: minor coding style cleanup 2019-03-24 09:21:13 +01:00
Thomas Haller
047adae242 libnm/team: fix crash with nm_setting_team_remove_runner_tx_hash_by_value() having no runner_tx_hash array 2019-03-24 09:21:13 +01:00
Thomas Haller
acf1cf61cf shared: add _nm_utils_strv_cmp_n() and _nm_utils_strv_equal() 2019-03-24 09:21:13 +01:00
Thomas Haller
0528c1e978 shared/tests: add parentheses around arguments of NMTST_SWAP() macro 2019-03-24 09:21:13 +01:00
Thomas Haller
19bd698357 Revert "ovs-port: dissociate the link from the interface device on delete"
Revert this patch for now. It causes a crash and breaks CI tests.

This reverts commit ee39f3ab79.
2019-03-24 09:19:25 +01:00
Lubomir Rintel
ee39f3ab79 ovs-port: dissociate the link from the interface device on delete
Open vSwitch is the special kid on the block -- it likes to be in charge of
the link lifetime and so we shouldn't be. This means that we shouldn't be
attempting to remove the link: we'd just (gracefully) fail anyways.

More importantly, this also means that we shouldn't care if we see the link
go away. We may already be activating another connection and shouldn't alter
the device state when OpenVSwitch decides to drop the old link.

https://bugzilla.redhat.com/show_bug.cgi?id=1543557
https://github.com/NetworkManager/NetworkManager/pull/315
2019-03-22 20:11:26 +01:00
Francesco Giudici
89713ebfdf merge: branch 'fg/checkpoint-devices-rh1578335-pt1'
https://bugzilla.redhat.com/show_bug.cgi?id=1578335

https://github.com/NetworkManager/NetworkManager/pull/316
2019-03-22 16:28:23 +01:00
Francesco Giudici
d74e09a778 nm-checkpoint: save device ifname and track if it is software
This will be soon useful as we are going to drop the reference to the
Device objs: so, when a checkpoint is created and a device disappear
(hw removed or sw device deleted) we will be able to correctly perform
the rollback.
2019-03-22 16:14:12 +01:00
Francesco Giudici
b159a0da82 nm-checkpoint: skip unmanage state check on unrealized devices
The "activate" label is used only for unrealized software devices that
should be recreated. Move the label to skip useless checks.
2019-03-22 16:14:12 +01:00
Francesco Giudici
6621820a70 nm-checkpoint: emit signal on the Devices property when required
that is: when a Device gets unexported from DBus. In this way we will
allow "Devices" property to be rechecked on get() returning an
up-to-date "Devices" property value.
2019-03-22 16:14:12 +01:00
Francesco Giudici
83ee0bbd6d dbus-utils: don't return paths if they are in the process of being unexported 2019-03-22 16:14:12 +01:00
Francesco Giudici
f15e634236 nm-checkpoint: remove duplicate comment
Fixes: 5fb65b7f96 ('checkpoint: let each checkpoint schedule its own timeout')
2019-03-22 16:14:12 +01:00
Francesco Giudici
90c614a91e trivial: fix grouping of empty GClosure arg in g_signal_new() 2019-03-22 16:14:12 +01:00
Thomas Haller
72bdeebd73 platform/tests: workaround test failure for routing rules with older kernels
# NetworkManager-MESSAGE: <warn>  [1553100541.6609] platform-linux: do-add-rule: failure 17 (File exists)
  >>> failing... errno=-17, rule=[routing-rule,0xe9c540,1,+alive,+visible; [6] 4294967295: from all suppress_prefixlen 3 none goto-target 2955537847]
  0:      from all to 73.165.79.8/2 iif nm-test-device 178
  0:      from all 109
  0:      from all tos 0x13 lookup 10004 suppress_prefixlength 0 none
  0:      from all none
  4294967295:     not from all none

  test:ERROR:../src/platform/tests/test-route.c:1607:test_rule: assertion failed (r == 0): (-17 == 0)

Possibly fixed by https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=7c8f4e6dc30996bff806285730a0bb4e714d3d52
2019-03-20 21:27:08 +01:00
Thomas Haller
d3c60326eb platform/tests: skip rule tests if not all features could be tested 2019-03-20 21:26:50 +01:00
Thomas Haller
6ed4c6a815 platform/tests: print more information when routing rule test is about to fail 2019-03-20 21:15:02 +01:00
Lubomir Rintel
cfcd746260 settings: remove README
It is out of date and doesn't seem to serve any real purpose.
2019-03-20 08:53:10 +01:00
Lubomir Rintel
0750ff1f81 contrib/rpm: drop --with-libnm-glib from build_clean
It does nothing now.
2019-03-20 08:47:51 +01:00
Lubomir Rintel
1de8383ad9 all: goodbye libnm-glib
This removes libnm-glib, libnm-glib-vpn, and libnm-util for good.
The it has been replaced with libnm since NetworkManager 1.0, disabled
by default since 1.12 and no up-to-date distributions ship it for years
now.

Removing the libraries allows us to:

* Remove the horrible hacks that were in place to deal with accidental use
  of both the new and old library in a single process.
* Relief the translators of maintenance burden of similar yet different
  strings.
* Get rid of known bad code without chances of ever getting fixed
  (libnm-glib/nm-object.c and libnm-glib/nm-object-cache.c)
* Generally lower the footprint of the releases and our workspace

If there are some really really legacy users; they can just build
libnm-glib and friends from the NetworkManager-1.16 distribution. The
D-Bus API is stable and old libnm-glib will keep working forever.

https://github.com/NetworkManager/NetworkManager/pull/308
2019-03-19 17:15:15 +01:00
Lubomir Rintel
32e0bf1421 Revert "wwan/device-modem: don't enter available state until registered"
This is wrong -- we may want to start activating before device is
registered if it the SIM needs unlocking with a PIN code that's included
in the connection.

This reverts commit 2e8f43e379.
2019-03-18 17:33:41 +01:00
Thomas Haller
d66a1ace23 contrib/checkpatch: avoid command injection in checkpatch.pl script
The capture variables, $1, etc, are not valid unless the match
succeeded, and they're not cleared, either.

    $ git checkout -B C origin/master && \
        echo XXXXX > f.txt && \
        git add f.txt && \
        git commit -m 'this commit does something()'
    Branch 'C' set up to track remote branch 'master' from 'origin'.
    Reset branch 'C'
    Your branch is up to date with 'origin/master'.
    sh: -c: line 0: syntax error near unexpected token `('
    sh: -c: line 0: `git log --abbrev=12 --pretty=format:"%h ('%s')" -1 does something() 2>/dev/null'

    >>> VALIDATE "a169a98e14 this commit does something()"
    (commit message):4: Commit 'does something()' does not seem to exist:
    > Subject: [PATCH] this commit does something()

    (commit message):4: Refer to the commit id properly: :
    > Subject: [PATCH] this commit does something()

    The patch does not validate.
2019-03-18 11:57:04 +01:00
Thomas Haller
e491b46800 release: bump version to 1.17.1-dev after 1.16.0 release
After 1.16.0 is released, merge it back into master so that
1.16.0 is part of the history of master. That means,
  $ git log --first-parent master
will also traverse 1.16.0 and 1.16-rc*.

Also bump the micro version to 1.17.1-dev to indicate that this is
after 1.16.0 is out.
2019-03-15 16:23:02 +01:00