Commit Graph

22710 Commits

Author SHA1 Message Date
Thomas Haller
5b51a1a9f7 libnm/lldp: cleanup asserting for valid NMLldpNeighbor agument
At a few places we checked whether neighbor->attrs was non-NULL.
That is not necessary, unless we'd like to catch some dangling/invalid
pointers. The attrs hash is always set otherwise.

Instead of just dropping the check, add a NM_IS_LLDP_NEIGHBOR() macro
(inline function).
2019-03-27 10:47:24 +01:00
Thomas Haller
95aa7ac91e core/lldp: avoid default switch case in lldp_neighbor_to_variant()
Explicitly check for LLDP_ATTR_TYPE_NONE. That's the only one we expect,
and the compiler can warn about missing switch cases for enums.
2019-03-27 10:47:24 +01:00
Thomas Haller
1c7cbda67a core/lldp: fix checking for NM_MORE_ASSERTS
It's called NM_MORE_ASSERTS not WITH_MORE_ASSERTS.

Also, NM_MORE_ASSERTS is always enabled. It's wrong to check whether it
is defined.

Fixes: e1e428b21e
2019-03-27 10:47:24 +01:00
Thomas Haller
8db0319198 libnm/lldp: fix leak and bug in nm_lldp_neighbor_dup()
For one, just reassigning copy->attrs leaks the previous
hash table. Fix that.

Also, NMLldpNeighbor instances are not immutable. I think that
is an uglyness, and it would be preferable that they can be sealed.
A sealed object could safely share/ref the internal hash-table. However,
as it is, we cannot just have two NMLldpNeighbor instances share the
same hash-table. Do a full copy.
2019-03-27 10:47:24 +01:00
Beniamino Galvani
8200078ec5 lldp: support IEEE 802.3 TLVs
Add support for IEEE 802.3 organizationally specific TLVs:

 - MAC/PHY configuration/status (IEEE 802.1AB-2009 clause F.2)
 - power via medium dependent interface (clause F.3)
 - maximum frame size (clause F.4)
2019-03-27 10:47:24 +01:00
Beniamino Galvani
452851cc35 lldp: support multiple PPVIDs
As done for VLANs, add a new 'ppvids' attribute that reports all 'port
and protocol VLAN ID' TLVs for the neighbor.
2019-03-27 10:47:24 +01:00
Beniamino Galvani
c4be4ea298 lldp: support multiple vlans
Previously we exported the contents of VLAN Name TLV in the 'vid'
(uint32) and 'vlan-name' (string) attributes. This is not entirely
correct as the TLV can appear multiple times.

We need a way to export all the VLAN IDs and names for the
neighbor. Add a new 'vlans' attribute which obsoletes the other two
and is an array of dictionaries, where each dictionary contains the
'vid' and 'name' keys.
2019-03-27 10:47:24 +01:00
Beniamino Galvani
6c52d946fc lldp: add support for management address TLV
Support the management address TLV (IEEE 802.1AB-2009 clause
8.5.9). The TLV can appear multiple times and so it is exported on
D-Bus as an array of dictionaries.
2019-03-27 10:47:24 +01:00
Beniamino Galvani
937796f6ea libnm: add nm_lldp_neighbor_get_attr_value()
The function provides access to the GVariant representing a LLDP
attribute.
2019-03-27 10:17:39 +01:00
Beniamino Galvani
8cdc011cd1 libnm: make attribute name const in LLDP API functions
Add the const qualifier to the attribute name in LLDP API functions so
that const strings and string literals are accepted. This change is
backwards compatible for existing users of the API.
2019-03-27 10:17:39 +01:00
Beniamino Galvani
15798df882 lldp: rename enum value 2019-03-27 10:17:39 +01:00
Beniamino Galvani
b1d5f11b3d cli: add lldp output tests
Check the result of 'nmcli device lldp' command.
2019-03-27 10:17:39 +01:00
Beniamino Galvani
a66ab735b6 lldp: drop _access* macros
Use unaligned access functions instead where needed.
2019-03-27 10:16:39 +01:00
Beniamino Galvani
579373a5df dns: fix memory leak of error
The error was leaked when cancelled.

Fixes: 818023c257 ('dns/resolved: add systemd-resolved backend')
2019-03-26 17:37:54 +01:00
Beniamino Galvani
fc4aedc6f3 merge: branch 'bg/bridge-vlan-filtering'
https://github.com/NetworkManager/NetworkManager/pull/322
https://bugzilla.redhat.com/show_bug.cgi?id=1652910
2019-03-26 17:32:03 +01:00
Beniamino Galvani
494f78440c device: support bridge vlans 2019-03-26 17:26:31 +01:00
Beniamino Galvani
fafde171ea platform: add support for bridge vlans 2019-03-26 17:19:39 +01:00
Beniamino Galvani
be2fbd0c69 platform: add @family argument to new-link function
This will be used to create bridge vlans, which require an AF_BRIDGE
message family.
2019-03-26 17:19:39 +01:00
Beniamino Galvani
4848ad7c77 nmcli: add bridge vlans support 2019-03-26 17:19:39 +01:00
Beniamino Galvani
56d193e686 ifcfg-rh: add bridge vlans support 2019-03-26 17:19:39 +01:00
Beniamino Galvani
c66d17d4fc keyfile: support bridge vlans 2019-03-26 17:19:39 +01:00
Beniamino Galvani
cf71860183 libnm-core: add bridge vlan conversion utils 2019-03-26 17:18:29 +01:00
Beniamino Galvani
a680bedf94 libnm-core: add vlans property to bridge setting 2019-03-26 17:18:29 +01:00
Beniamino Galvani
1e5b0788bc libnm-core: add vlans property to bridge-port setting 2019-03-26 17:18:29 +01:00
Beniamino Galvani
96fab7b462 all: add vlan-filtering and vlan-default-pvid bridge properties 2019-03-26 17:18:29 +01:00
Beniamino Galvani
6f8beac4cf keyfile: fix memory leaks
The GPtrArray was leaked when the group did not have keys.
2019-03-26 17:18:29 +01:00
Beniamino Galvani
2691fd279d libnm-core: fix typos in API documentation 2019-03-26 17:18:29 +01:00
Beniamino Galvani
d9143d851d libnm-core: add missing notify in sriov setting 2019-03-26 17:18:29 +01:00
Lubomir Rintel
8f2a8a52f0 device: fix the slave state change reason on master connection removal
If we surprise-remove the master, slaves would immediately attempt to bring
things up by autoconnecting. Not cool. Policy, however, blocks
autoconnect if the slaves disconnect due to "dependency-failed", and it
indeed seems to be an appropriate reason here:

  $ nmcli c add type bridge
  $ nmcli c add type dummy ifname dummy0 master bridge autoconnect yes
  $ nmcli c del bridge
  $

Before:

  (nm-bridge): state change: ip-config -> deactivating (reason 'connection-removed')
  (nm-bridge): state change: deactivating -> disconnected (reason 'connection-removed')
  (nm-bridge): detached bridge port dummy0
  (dummy0): state change: activated -> disconnected (reason 'connection-removed')
  (nm-bridge): state change: disconnected -> unmanaged (reason 'user-requested')
  (dummy0): state change: disconnected -> unmanaged (reason 'user-requested')
  policy: auto-activating connection 'bridge-slave-dummy0'

After:

  (nm-bridge): state change: ip-config -> deactivating (reason 'connection-removed')
  (nm-bridge): state change: deactivating -> disconnected (reason 'connection-removed')
  (nm-bridge): detached bridge port dummy0
  (dummy0): state change: activated -> deactivating (reason 'dependency-failed')
  (nm-bridge): state change: disconnected -> unmanaged (reason 'user-requested')
  (dummy0): state change: deactivating -> disconnected (reason 'dependency-failed')
  (dummy0): state change: disconnected -> unmanaged (reason 'user-requested')

https://github.com/NetworkManager/NetworkManager/pull/319
2019-03-26 15:03:15 +01:00
Thomas Haller
f224d6a853 nmcli: merge branch 'th/nmcli-list-options'
https://github.com/NetworkManager/NetworkManager/pull/317
2019-03-25 10:15:08 +01:00
Thomas Haller
8b0461380f cli/trivial: add comment about partially modifying settings when failing set_fcn() 2019-03-25 09:12:33 +01:00
Thomas Haller
7dcf368cf0 cli: freeze/thaw property changed signals in nmc_setting_set_property()
Setting one property might affect multiple properties.
For example, setting a team property might also emit property changed
signal for "team.config".

Or, one property might be modified multiple times. For example list
properties may first clear the property, then append multiple elements.
Or a list property might remove multiple elements.

Combine these signals via g_object_freeze_notify() and
g_object_thaw_notify().
2019-03-25 09:12:33 +01:00
Thomas Haller
d3343b241f cli/trivial: add FIXME comment about how wrong editor_init_existing_connection() is 2019-03-25 09:12:33 +01:00
Thomas Haller
3a77201361 cli: workaround libnm issue for setting team.runner-tx-hash
This workaround was dropped when refactoring the property handling.
Restore the workaround (at least) until libnm is fixed.
2019-03-25 09:12:33 +01:00
Thomas Haller
a1c7b04664 nmcli: add clear_all_fcn() hook for mutllist property types 2019-03-25 09:12:33 +01:00
Thomas Haller
3a8fe7ad45 cli: consistently validate multilist options for add and remove
There is no reason to validate only in certain cases. Either we
validate, or we don't (always the same).

This is a change in behavior, but the cases should be sensible.
2019-03-25 09:12:33 +01:00
Thomas Haller
96c4f51208 cli: distinguish between resetting GObject property to default and NULL
Most GObject properties default to FALSE/NULL/0. In that case, there
is no difference between setting the default or clearing the value.

During

     if (_SET_FCN_DO_RESET_DEFAULT (property_info, modifier, value))
         return _gobject_property_reset_default (setting, property_info->property_name);

it is correct to reset the default.

However for list-typed properties, we want to clear the list. So,
it should be

     if (_SET_FCN_DO_SET_ALL (modifier, value))
         _gobject_property_reset (setting, property_info->property_name, FALSE);
2019-03-25 09:12:33 +01:00
Thomas Haller
166e04799d cli: accept ',' as delimiter for match.interface-names
"match.interface-names" is the only property that uses VALUE_STRSPLIT_MODE_MULTILIST_WITH_ESCAPE.

    $ nmcli connection modify "$PROFILE" match.interface-name ' 5, \,\  4\,  '

results in

    [match]
    interface-name=5;, ;4,;

and

    $ echo ">$(nmcli -g match.interface-name -escape=no connection show "$PROFILE")<"
    >5 \,\  4\,<

Yes, plain --get leads to a wrong double-escaping:

    $ echo ">$(nmcli -g match.interface-name connection show "$PROFILE")<"
    >5 \\,\\  4\\,<
2019-03-25 09:12:33 +01:00
Thomas Haller
65c8c19fa7 cli: don't support removing sriov vfs by index
The VFs already can be parsed as plain number (to indicate the
ifindex). We should not also support accepting the plain number
as index to be removed.

Fixes: a2f12994b7 ('cli: add support for configuring SR-IOV')
2019-03-25 09:12:33 +01:00
Thomas Haller
da5895951a shared: add _nm_utils_escape_plain() API 2019-03-25 09:12:33 +01:00
Thomas Haller
e26e0fdffd all: consider all ASCII spaces for _nm_utils_escape_spaces() and unescape 2019-03-25 09:12:33 +01:00
Thomas Haller
5b8305c27c shared: add NM_ASCII_SPACES macro 2019-03-25 09:12:33 +01:00
Thomas Haller
70bad5c74d cli: support list of indexes for removing objlist property
$ nmcli connection modify "$PROFILE" -ipv4.addresses 1,3

Already before, nmcli would support removing items by index. But only
one number was supported.

- indexes are zero based (as before).

- duplicate indexes or indexes out of bounds are silently ignored.

Maybe certain properties should not support removal by index.
2019-03-25 09:12:33 +01:00
Thomas Haller
28f0153350 cli: cleanup parsing of VLAN ingress/egress priority map
Use new ValueStrsplitMode "VALUE_STRSPLIT_MODE_STRIPPED".

Note that this is not exactly what we did before. For example, empty
tokens are now silently removed.

Also, we accept now whitespace as separators.
2019-03-25 09:12:33 +01:00
Thomas Haller
c0d83ef522 cli: refactor splitting the string when parsing the property values
Have one function that gets all the nonesense right. "nonesense", because
we have inconsistent behaviors, and the function is supposed to help with
that.
2019-03-25 09:12:33 +01:00
Thomas Haller
e2c95014c2 cli: merge remove-by-value and add functions of objlist property types 2019-03-25 09:12:33 +01:00
Thomas Haller
18fac0407e cli: merge set_fcn() and remove_fcn()
set_fcn() and remove_fcn() are strongly related. They should accept
arguments in the same format, hence the parsing of the arguments should
be done at one place.

In fact, previously the parsing was separate, leading to ugly
inconsistencies:

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

or

  $ nmcli connection modify "$PROFILE" +ipv4.addresses 192.168.1.5/24,192.168.2.5/24
  $ nmcli connection modify "$PROFILE" -ipv4.addresses 192.168.1.5/24,192.168.2.5/24
  Error: failed to remove a value from ipv4.addresses: invalid prefix '24,192.168.2.5/24'; <1-32> allowed.

Let set_fcn() handle set-default, set-all, add, and subtract.
2019-03-25 09:12:33 +01:00
Thomas Haller
eb0cfefe52 cli: allow resetting all values via set_fcn() property handler
Previously, set_fcn() could only append values. Now, pass on the modifier
so that it may append, set all, or reset the default.

These operations are strongly related and should be handled by the same
set_fcn() function.
2019-03-25 09:12:33 +01:00
Thomas Haller
22382c4e82 cli: implement remove-fcn for objlist types 2019-03-25 09:12:33 +01:00
Thomas Haller
923a79554c cli: implement add-fcn for objlist types 2019-03-25 09:12:33 +01:00