Commit Graph

18456 Commits

Author SHA1 Message Date
Thomas Haller
39d30a170d man: fix docu of AUTOCONNECT_SLAVES variable in nm-settings-ifcfg-rh
Fixes: 6caafab258

https://bugzilla.redhat.com/show_bug.cgi?id=1492912
2017-09-19 08:35:16 +02:00
Thomas Haller
63104b7213 ifcfg-rh: merge branch 'th/ifcfg-route-parse'
https://github.com/NetworkManager/NetworkManager/pull/28
2017-09-18 20:15:07 +02:00
Thomas Haller
6d675a943b ifcfg-rh: refactor parsing of route options to be strict
The previous parsing was done using regex. One could implement a
complex regex to parse the setting. However, as it was implemented,
the regex would just pick out parts of the line that it expects,
and ignore unknown parts.

Let's be strict about what we parse. The only strong requirement
is that NM can parse everything that was written by NM itself.
Eventually, we could extend the parser to accept everything that
initscripts accept.

Initscripts split the line at $IFS and do filename globbing on the
arguments. That is ugly, because globbing is of coures wrong (we don't
do that). But also, the splitting at $IFS cannot be escaped, hence for
initscripts it is impossible to use '<space><tab><newline>'. We do that
too, as it makes it easy to parse. Later we may want to extend this to
allow a form of escaping/quoting.

Yes, we may now ignore routes that are not defined as we expect them.
2017-09-18 20:14:09 +02:00
Thomas Haller
62f2c4cf20 ifcfg-rh: write lock route attribute with zero value
Only specifying "lock" without a corresponding attribute shall have
the meaning of "$NAME lock 0".
2017-09-18 20:14:09 +02:00
Thomas Haller
e54fad0886 ifcfg-rh: refactor code to avoid unnecessary copies
svGetValueStr() is preferred over svGetValueStr_cp() because it may safe
an additional string copy (if the value needs no unescaping/unquoting).

Also, use nm_utils_strsplit_set() because it saves to copy each word.

There are some changes here. For example, read_8021x_list_value()
previously would not strip empty words. When switching from
g_strsplit_set() to nm_utils_strsplit_set(), empty words are implicitly
skipped.
2017-09-18 20:14:09 +02:00
Thomas Haller
b1029c6198 ifcfg-rh/trivial: rename function that are only for testing
We have similar functions, like _nmtst_ip4_config_del_route(). Rename testing
functions to have "_nmtst_" prefix for consistency.
2017-09-18 20:14:09 +02:00
Thomas Haller
daa4604c12 shared: add nm_utils_strsplit_set() helper
A replacement for g_strsplit_set(). While g_strsplit_set()
does (n+1) malloc and n slice allocations, this needs
roughtly (O(log(n))) mallocs.

Another difference from g_strsplit_set() is that this function
treats multiple delimiters as one (and thus never returns empty
words). While I can see that sometimes you may want to keep empty
words (like parsing a CSV file and preserve empty cells), we usually
use this function for splitting user input. In such case, we want
to treat multiple delimiters as one.
2017-09-18 20:14:09 +02:00
Thomas Haller
f6a727685e shared: add nm_utils_parse_inaddr_prefix_bin() helper 2017-09-18 20:14:09 +02:00
Thomas Haller
dd0617547d shared: add NMIPAddr struct 2017-09-18 20:14:09 +02:00
Thomas Haller
569b443233 shared: add nm-glib.h compat implementation for g_variant_new_printf() 2017-09-18 20:14:09 +02:00
Beniamino Galvani
3be7910520 bluetooth: drop unused function declaration 2017-09-18 18:56:50 +02:00
Beniamino Galvani
87e17d96df bluetooth: generate connections only for paired devices
It makes little sense to have a connection while the device is not
paired.

https://bugzilla.gnome.org/show_bug.cgi?id=787440
2017-09-18 18:50:08 +02:00
Francesco Giudici
dcaed616f7 dhcp: merge branch 'fg/persistent_dhcp_rh1350830'
https://bugzilla.redhat.com/show_bug.cgi?id=1350830
2017-09-18 18:45:48 +02:00
Francesco Giudici
e04c9af5fd nmcli: allow to set dhcp-timeout as "infinity"
DHCP timeout may now be explicitly disabled by setting the
ipv[4,6].dhcp-timeout options to "infinity".
This will set the DHCP timeout value to MAXINT32.
2017-09-18 18:44:43 +02:00
Francesco Giudici
a245554984 dhcp: consider a timeout equal to MAXINT32 as infinity
This will avoid to spawn internally a timer for the lease to complete.
2017-09-18 18:44:43 +02:00
Beniamino Galvani
239c59a627 src/devices: use macros for property and signal names 2017-09-18 15:40:31 +02:00
Thomas Haller
289f0f703f core: fix tracking default-route during device's merge and apply
If we don't commit the IP config, we must merge the currently tracked
default route. Otherwise, on every non-commit call of
ip4_config_merge_and_apply(), the default-route gets lost.

Fixes: 77ec302714
2017-09-18 09:58:58 +02:00
Thomas Haller
2cc1813340 core: workaround configuring IPv6 routes with "src" (RTA_PREFSRC)
Kernel does not allow to add IPv6 routes with "src", as long as the
corresponding address is still tentative (related bug rh#1457196).

The workaround for this is cumbersome. First, when we fail to add such a
route with "pref_src", we guess that it happend due to this issue. In
that case, nm_ip6_config_commit() returns the list of routes that could
not be added for the moment (but hopefully can be added later).

We track this list in NMDevice, and keep trying to merge the routes
back into ip6_config. In order to not try indefinitely, keep track of a
timestamp when we tried to add this route for the first time.

Another uglyness is that pending tentative routes don't explicitly block
activation. In practice they may do, because for these routes we also have
an IPv6 address that is still doing DAD, so the IP configuration is
still pending due to that.

https://bugzilla.redhat.com/show_bug.cgi?id=1452684
2017-09-15 17:28:48 +02:00
Francesco Giudici
1cb4832f09 dhcp: dhclient: remove the --timeout argument from the command line
the --timeout command line option is a custom feature added in some
linux distributions (fedora). Passing that command line argument will
make dhclient fail if the binary does not support it, preventing
activation of dhcp based connections.
Worse, the option has just been recently changed from "-timeout", so
that we are currently incompatibile with Centos, RedHat and older
versions of Fedora too.

Leverage the "timeout" option in dhclient config file: it will produce
the expected behavior and will be universally supported.

Fixes test: dhcp-timeout
Fixes: fa46736013

https://bugzilla.redhat.com/show_bug.cgi?id=1491243
2017-09-15 12:15:55 +02:00
Thomas Haller
8198a3abed man: merge branch 'bg/man-cli-rh1182772'
https://bugzilla.redhat.com/show_bug.cgi?id=1482772
2017-09-13 17:20:16 +02:00
Beniamino Galvani
3a3f4fb9f7 man: nmcli: add missing aliases 2017-09-13 16:38:34 +02:00
Beniamino Galvani
f4aee0c58b man: nmcli: improve description of type, ip4, ip6 aliases
Clarify that the description refers to the alias, not to the property.

https://bugzilla.redhat.com/show_bug.cgi?id=1482772
2017-09-13 16:38:34 +02:00
Thomas Haller
b4c249959d core: merge branch 'th/ip-config-route-id'
https://github.com/NetworkManager/NetworkManager/pull/27
2017-09-13 14:49:36 +02:00
Thomas Haller
6698bf58bb core: track routes with source RTPROT_KERNEL (rtm_protocol) in NMIP4Config/NMIP6Config
Let's not treat those routes special. I think this was originally done, because
we relied on kernel to add the IPv4 device route, so we would ignore RTPROT_KERNEL
routes and not delete them.

We want to track them for various reasons:

 - for consistency, there is nothing special except that they might be
   added by kernel.
 - we expose the routes of NMIP4Config/NMIP6Config on D-Bus. That should
   include also routes such as device routes. Note, this commit changes
   that we now expose device routes on D-Bus too.
2017-09-13 08:17:31 +02:00
Thomas Haller
9a3117f1d3 core: track IPv4 device routes in NMIP4Config
For IPv6, we create device routes when processing the RA and add it to
NMIP6Config like any other route. For IPv4 we didn't do that. Instead
we created the list of device routes during nm_ip4_config_commit() and
passed it to nm_platform_ip_route_sync().
2017-09-13 08:17:31 +02:00
Thomas Haller
4b4efac3ab core: fix merging IP addresses in NMIP4Config/NMIP6Config
When merging IP addresses, we keep the best addr_source and the internally
configured timestamps. Since the check for the timestamp considers addr_source,
we must move the check before merging addr_source.
2017-09-13 08:17:31 +02:00
Thomas Haller
aee48dfd44 core: adjust route equality for NMIP4Config/NMIP6Config to what kernel does
For kernel, route ID compare identical according to NM_PLATFORM_IP_ROUTE_CMP_TYPE_ID.
Well, mostly. In practice, NM ignores several route properties that
kernel considers part of the ID too. This leaves the possibility that
kernel allows addition of two routes that compare idential for
NetworkManager.

Anyway, NMIP4Config/NMIP6Config should use the same equality as platform
cache. Otherwise, there is the odd situation that ip-config merges routes
that are treated as different by kernel.

For IP addresses the ID operator already corresponded to what kernel
does. There is no change for addresses.

Note that NMSettingIPConfig also uses a different algorithm for
comparing routes. But that doesn't really matter here, it it differed
before too.
2017-09-13 08:17:31 +02:00
Thomas Haller
e730ae7600 core/tests: add checks in test for test_add_route_with_source() 2017-09-13 08:17:31 +02:00
Thomas Haller
79cb13bc5c platform: use distinct hash seed for nmp_object_id_hash() of routes 2017-09-13 08:17:31 +02:00
Thomas Haller
944006d485 core: add nm_utils_ip4_address_same_prefix() function 2017-09-13 08:17:31 +02:00
Thomas Haller
846b02880d core: fix invalid assertion in nm_ip6_config_get_num_routes().
Fixes: cfd1851c00
2017-09-13 08:17:31 +02:00
Thomas Haller
121321542e libnm: fix uninitialized variable in get_system_encodings()
CC       libnm-core/libnm_core_libnm_core_la-nm-utils.lo
  libnm-core/nm-utils.c:210:6: error: variable 'encodings' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]
          if (lang) {
              ^~~~
  libnm-core/nm-utils.c:220:7: note: uninitialized use occurs here
          if (!encodings) {
               ^~~~~~~~~
  libnm-core/nm-utils.c:210:2: note: remove the 'if' if its condition is always true
          if (lang) {
          ^~~~~~~~~~
  libnm-core/nm-utils.c:198:30: note: initialize the variable 'encodings' to silence this warning
          const char *const *encodings;
                                      ^
                                       = NULL

Fixes: 28a0627481
2017-09-13 08:17:30 +02:00
Thomas Haller
eb948e793e core: fix invalid assertion in nm_ip4_config_get_num_routes()
Fixes: 935411e5c0
2017-09-13 08:17:30 +02:00
Beniamino Galvani
789f8a6b51 libnm-core: also consider LC_ALL and LC_CTYPE to guess SSID charset
Also consider LC_ALL and LC_CTYPE environment variables, in addition
to LANG, to determine the charset used for converting SSIDs to UTF-8.

https://bugzilla.gnome.org/show_bug.cgi?id=784415
2017-09-12 23:46:51 +02:00
Beniamino Galvani
28a0627481 libnm-core: cache the current character encoding
Instead of performing the parsing of environment variables and the
lookup for every string, cache the selected encoding.
2017-09-12 23:46:49 +02:00
Thomas Haller
6ece7d6dd3 cli: cleanup _get_fcn_gobject_int() and _set_fcn_gobject_int() 2017-09-12 16:52:49 +02:00
Thomas Haller
a8d2a4ebaf cli: implement dcb priority as plain int property
There are basically three options:

1)  use a separate _get_fcn_gobject_dcb_priority() getter and
    implement them as a new type _pt_gobject_dcb_priority.
2a) implement them as _pt_gobject_int and set nicks as value_infos,
    repeating the nicks 3 times.
2b) like 2a, but use a macro to define how the DCB priority shall
    behave at one place.

I think 1) is ugly. In the previous form, it also does not support
setting the property to "unset". We should implement properties as
types, and modify their behavior (by setting value_infos), instead
of implementing multiple, different types.

I slightly prefer 2b) over 2a) because it defines the behavior once,
but it's a bit harder to follow.
2017-09-12 16:34:17 +02:00
Thomas Haller
4c8673d978 cli: refactor connection.autoconnect-retires to use int-getter 2017-09-12 16:34:17 +02:00
Thomas Haller
e36ed195ba cli: refactor ipv4.dad-timeout to use int-getter
- Reduce duplicated code and implement the property according to
  best-practice for integer types.

- Do not translate the output

- This way, the setter also supprts the nick names
2017-09-12 16:03:05 +02:00
Thomas Haller
6ad53975b3 cli: fix _set_fcn_gobject_int_impl() to accept nick for setting int property
Fixes: e086cf1887
2017-09-12 16:02:39 +02:00
Thomas Haller
3c84dd15e0 core/dhcp: use addr-family parameter for instead of boolean
In many cases we want to treat IPv4 and IPv6 generically. That looks nicer
if we distingish by an @addr_family integer, instead of a boolean.

Replace the @is_ipv6 boolean with an @addr_family paramter. The @is_ipv6
boolean is inconsistent with other places where we use @is_ipv4 to
indicate the opposite. Eventually, we should use @addr_family
everywhere.

Also, at the call site it's not immediately clear what TRUE/FALSE means,
here AF_INET/AF_INET6 is better.
2017-09-11 15:05:57 +02:00
Thomas Haller
1aa36dde94 device: enable support for ipv6.dhcp-timeout
- cleanup data type and use guint32 consistently. We might want to
  introduce a new "infinity" value. But since libnm's
  NM_SETTING_IP_CONFIG_DHCP_TIMEOUT asserts against the range
  0 - G_MAXINT32, we cannot express it as -1 anyway. So, infinity
  will have the numerical value G_MAXINT32, hence guint32 is just
  fine.

- make use of existing ipv6.dhcp-timeout setting and add global
  default configuration in NetworkManager.conf

- instead of having subclasses call nm_device_set_dhcp_timeout(),
  add a virtual function get_dhcp_timeout().
2017-09-11 15:05:57 +02:00
Francesco Giudici
fa46736013 dhcp: dhclient: fix daemon start when dhcp-timeout is specified
A typo in the new dhcp-timeout option caused the dhclient daemon to exit
with error when the dhcp-timeout option was specified.
This prevents dhcp connection to be upped.

Fixes: 82ef497cc9
2017-09-11 14:52:51 +02:00
Thomas Haller
7d00a96d23 contrib/rpm: allow building RPM without fatal warnings
A newer compiler version might emit some warnings and break the build
of the RPM. Of course, such warnings must be fixed. But it is still very
inconvenient to break the build of an old RPM version without easy workaround.

When building without "test" (which is on by default), don't use fatal warnings
for compilation.
2017-09-11 14:22:10 +02:00
Thomas Haller
66a09b2192 contrib/NM-log: don't use exec in bash functions
When sourcing the file, using exec inside NM-show-journal is a bad idea,
because it replaces the calling shell.
2017-09-08 17:18:32 +02:00
Beniamino Galvani
44e71d70ea ppp: rename the interface only when necessary
Previously when the interface created by pppd was already the one we
expected, we would rename it to itself and remove the device from the
manager. Don't do it.

Fixes: 6c3195931e
2017-09-08 14:29:02 +02:00
Thomas Haller
4bc231e33a core: merge branch 'th/platform-route-pt4' (part 2)
Drop NMDefaultRouteManager.

https://github.com/NetworkManager/NetworkManager/pull/26
2017-09-08 13:50:33 +02:00
Thomas Haller
77ec302714 core: rework handling of default-routes and drop NMDefaultRouteManager
Remove NMDefaultRouteManager. Instead, add the default-route to the
NMIP4Config/NMIP6Config instance.

This basically reverts commit e8824f6a52.
We added NMDefaultRouteManager because we used the corresponding to `ip
route replace` when configuring routes. That would replace default-routes
on other interfaces so we needed a central manager to coordinate routes.
Now, we use the corresponding of `ip route append` to configure routes,
and each interface can configure routes indepdentently.

In NMDevice, when creating the default-route, ignore @auto_method for
external devices. We shall not touch these devices.

Especially the code in NMPolicy regarding selection of the best-device
seems wrong. It probably needs further adjustments in the future.
Especially get_best_ip_config() should be replaced, because this
distinction VPN vs. devices seems wrong to me.
Thereby, remove the @ignore_never_default argument. It was added by
commit bb75026004, I don't think it's
needed anymore.

This brings another change. Now that we track default-routes in
NMIP4Config/NMIP6Config, they are also exposed on D-Bus like regular
routes. I think that makes sense, but it is a change in behavior, as
previously such routes were not exposed there.
2017-09-08 11:11:21 +02:00
Thomas Haller
0918b4914d core: support tracking default-route in NMIP4Config/NMIP6Config
Default-routes are for the most part like regular routes. Add support to
track them like regular routes in NMIP4Config/NMIP6Config.

One thing is, sometimes we need to figure out whether an ip-config
instance has a default-route. For that, keep track of the best
default-route (there might be multiple) and expose it. That is
the most complicated part of this patch, because there are so many
places where the list of routes gets modified (replace, intersect,
subtract, merge, add), and they all need to take care of updating
the best default-route.

In a next patch, NMDefaultRouteManager will be dropped and default-routes
will be tracked by NMIP4Config/NMIP6Config.
2017-09-08 11:11:21 +02:00
Thomas Haller
a214f398e7 core: merge branch 'th/platform-route-pt4' (part 1)
Several patches with cleanup and in prepration for dropping
NMDefaultRouteManager.

https://github.com/NetworkManager/NetworkManager/pull/26
2017-09-08 11:09:42 +02:00