Commit Graph

79 Commits

Author SHA1 Message Date
Denis Kenzior f7b5bd4a79 treewide: Use ell's useful.h header 2021-03-11 21:46:09 -06:00
Daniel Lin c68e9fc0a6 resolve: configure systemd-resolved's MulticastDNS= setting
When using iwd.conf:[General].EnableNetworkConfiguration=true, it is not
possible to configure systemd.network:[Network].MulticastDNS= as
systemd-networkd considers the link to be unmanaged. This patch allows
iwd to configure that setting on systemd-resolved directly.
2021-02-11 15:06:01 -06:00
Andrew Zaborowski 5c95c5cc16 netconfig: Set more correct buffer length
Use INET_ADDRSTRLEN as the IPv4 address buffer size to avoid confusion.
2021-01-25 14:01:58 -06:00
James Prestwood f39d1b4ac2 netconfig: add ACD client for static configuration
When the IP is configured to be static we can now use ACD in
order to check that the IP is available and not already in
use. If a conflict is found netconfig will be reset and no IP
will be set on the interface. The ACD client is left with
the default 'defend once' policy, and probes are not turned
off. This will increase connection time, but for static IP's
it is the best approach.
2020-12-08 16:29:09 -06:00
Denis Kenzior 278abc66be netconfig: Also set the domains obtained from IPv6 2020-12-02 10:55:05 -06:00
James Prestwood ccf265b943 netconfig: fix freeing invalid pointer
If l_rtnl_ifaddr4_extract does not set the values they would
get freed. Instead initialize to NULL so the cleanup free is
a no op.
2020-11-23 23:29:54 -06:00
Denis Kenzior ebc42ccecf netconfig: Don't re-create address on RENEWAL
==5279== 104 bytes in 2 blocks are definitely lost in loss record 1 of 1
==5279==    at 0x4C2F0CF: malloc (vg_replace_malloc.c:299)
==5279==    by 0x4655CD: l_malloc (util.c:61)
==5279==    by 0x47116B: l_rtnl_address_new (rtnl.c:136)
==5279==    by 0x438F4B: netconfig_get_dhcp4_address (netconfig.c:429)
==5279==    by 0x438F4B: netconfig_ipv4_dhcp_event_handler
(netconfig.c:735)
==5279==    by 0x491C77: dhcp_client_event_notify (dhcp.c:332)
==5279==    by 0x491C77: dhcp_client_rx_message (dhcp.c:810)
==5279==    by 0x492A88: _dhcp_default_transport_read_handler
(dhcp-transport.c:151)
==5279==    by 0x46BECB: io_callback (io.c:118)
==5279==    by 0x46B10C: l_main_iterate (main.c:477)
==5279==    by 0x46B1DB: l_main_run (main.c:524)
==5279==    by 0x46B3EA: l_main_run_with_signal (main.c:646)
==5279==    by 0x403ECE: main (main.c:490)
2020-11-23 14:59:20 -06:00
Denis Kenzior 69e86f4d21 netconfig: Remove tracking of addresses
Tracking of addresses that weren't set by us seemed a bit questionable.
Take this out for now.  If this is ever needed, then a queue with
l_rtnl_address objects should be used.
2020-11-19 14:19:17 -06:00
Denis Kenzior 6f5ec005e9 netconfig: Rework IPv4 address handling
Introduce a new v4_address member which will hold the currently
configured IPV4 address (static or obtained via DHCP).  Use the new
l_rtnl_address class for this.

As a side-effect, lease expiration will now properly remove the
configured address.
2020-11-19 14:19:13 -06:00
Denis Kenzior eb151efc81 netconfig: Rework static IPv6 address handling
This patch converts the code to use the new l_rtnl_address class.  The
settings parsing code will now return an l_rtnl_address object which
can be installed directly.

Also, address removal path for static addresses has been removed, since
netconfig_reset() sets disable_ipv6 setting to '1', which will remove
all IPV6 addresses for the interface.
2020-11-19 13:28:38 -06:00
Denis Kenzior b6cf9ef866 netconfig: Rework static IPv6 route handling
This patch converts the code to use the new l_rtnl_route class instead
of using l_rtnl_route6* utilities.  The settings parsing code will now
return an l_rtnl_route object which can be installed directly.

Also, the route removal path has been removed since netconfig_reset()
sets disable_ipv6 setting to '1' which will remove all IPV6 routes and
addresses for the interface.
2020-11-19 13:08:51 -06:00
Denis Kenzior 3890431090 netconfig: Install search domains obtained from DHCPv6 2020-11-18 12:00:17 -06:00
Denis Kenzior dcaf0150b9 netconfig: Re-start DHCPv6 client
If lease expired or was not obtained initially, re-start the DHCPv6
client.
2020-11-18 10:39:29 -06:00
Denis Kenzior c46a5d7c84 netconfig: Install DNS addresses obtained from DHCPv6
This also changes the resolve API a little bit to act as a 'set' API
instead of an incremental 'add' API.  This is actually easier to manage
in the resolve module since both systemd and resolvconf want changes
wholesale and not incrementally.
2020-11-18 10:39:16 -06:00
Denis Kenzior 53c9a692fa netconfig: Add configs for controlling IPV6 support 2020-11-16 16:02:24 -06:00
Denis Kenzior bb876953ac netconfig: Start RA & DHCPv6 clients
For now the RA client is ran automatically when DHCPv6 client starts.
RA takes care of installing / deleting prefix routes and installing the
default gateway.  If Router Advertisements indicate support DHCPv6, then
DHCPv6 transactions are kicked off and the address is set / removed
automatically.

Stateless configuration is not yet supported.
2020-11-12 15:36:56 -06:00
Andrew Zaborowski e1393501e7 netconfig: Don't bswap IP netmasks for __builtin_popcountl
The __builtin_popcountl() value shouldn't change with the endianness.
2020-09-14 11:45:18 -05:00
Denis Kenzior e58a818ce9 resolve: Refactor resolve module
Resolve module does not currently track any state that has been set on
a per ifindex basis.  This was okay while the set of information we
supported was quite small.  However, with dhcpv6 support being prepared,
a more flexible framework is needed.

Change the resolve API to allocate and return an instance for a given
ifindex that has the ability to track information that was provided.
2020-08-21 22:41:32 -05:00
Andrew Zaborowski bafd604834 netconfig: Implement netconfig_get_dhcp_server_ipv4
This uses l_dhcp_lease_get_server_id to get the IP of the server that
offered us our current lease.  l_dhcp_lease_get_server_id returns the
vaue of the L_DHCP_OPTION_SERVER_IDENTIFIER option, which is the address
that any unicast DHCP frames are supposed to be sent to so it seems to
be the best way to get the P2P group owner's IP address as a P2P-client.
2020-07-13 14:52:02 -05:00
Andrew Zaborowski c8edd36234 netconfig: Move EnableNetworkConfiguration check to station
Allow p2p to use netconfig even if not enabled for Infrastructure mode
connections.
2020-05-01 11:30:42 -05:00
Denis Kenzior 520f851564 netconfig: Use the global rtnl object 2020-04-08 12:35:02 -05:00
Daniel Wagner a40503427e rtnlutil: Remove used rtnlutil
The rtnl code has been added to ELL. There is caller left in iwd,
therefore remove the rtnlutil file.
2020-02-17 09:08:50 -06:00
Daniel Wagner 280658c73b netconfig: Use ell's rtnl API 2020-02-17 09:08:50 -06:00
Denis Kenzior 0e49561bb7 treewide: Use l_debug with at least one argument
By convention we should be passing at least an empty string to make it
clearer that no additional debug info is being printed
2019-12-17 16:15:05 -06:00
Tim Kourt fb338154a2 netconfig: Add IPv4 domain name helper and installer
The provided domain name helper allows to override the DHCP lease
option value with the static one from network configuration file.
2019-12-12 10:35:12 -06:00
Tim Kourt 1fd794a444 netconfig: Use CamelCase for IPv6 DNS setting 2019-12-11 00:57:29 -06:00
Tim Kourt ac9c87d012 netconfig: Use CamelCase for IPv6 gateway setting 2019-12-11 00:57:29 -06:00
Tim Kourt 2414a3ae51 netconfig: Use CamelCase for IPv6 address settings 2019-12-11 00:57:29 -06:00
Tim Kourt e7db478f97 netconfig: Use CamelCase for IPv4 DNS setting 2019-12-11 00:57:29 -06:00
Tim Kourt 994c1a4b5a netconfig: Use CamelCase for IPv4 gateway setting 2019-12-11 00:57:29 -06:00
Tim Kourt 0d9487d4ec netconfig: Use CamelCase for IPv4 address settings 2019-12-11 00:57:29 -06:00
Marcel Holtmann ab5742bb32 module: Move declarations into separate header file 2019-11-07 23:40:13 +01:00
Denis Kenzior 16f51f5b5e treewide: Use CamelCase for netconfig settings 2019-10-25 13:18:42 -05:00
Tim Kourt 8168b22233 netconfig: Don't clear IPv6 addresses on shutdown
Unlike IPv4, the IPv6 address are removed by the kernel.
2019-10-09 17:53:26 -05:00
Tim Kourt c4a17ed711 netconfig: Add netconfig event notifier
The notifier allows to subscribe for the netconfig events such as
‘connected’.
2019-10-09 17:51:57 -05:00
Tim Kourt beca75830c netconfig: Split route add/del callbacks 2019-10-09 14:18:07 -05:00
Tim Kourt e0651cf25b netconfig: Allow to override IPv6 DHCP DNSs with static addresses 2019-10-04 12:17:20 -05:00
Tim Kourt 0fdd27463e netconfig: Allow to override IPv4 DHCP DNSs with static addresses 2019-10-04 12:17:20 -05:00
Denis Kenzior 46a88744c1 netconfig: Remove unused member 2019-10-04 12:17:20 -05:00
Tim Kourt 3e634bfbcc netconfig: Optimize IPv4 address deletion
Decrease the queue traversals to a single pass
2019-10-03 10:56:07 -05:00
Tim Kourt 444491490e netconfig: Remove IPv6 default route
The IPv6 default route needs to be explicitly revoked. Unlike in IPv4,
there is no SRC address associated with the route and it will not be
removed on address removal.
2019-10-03 10:56:07 -05:00
Tim Kourt cd21d4d3e7 netconfig: Fix return type for module init 2019-10-03 10:56:07 -05:00
Tim Kourt c4ecf96942 netconfig: Install IPv6 DNS 2019-10-02 12:13:42 -05:00
Tim Kourt 95c3df3ccf netconfig: Install IPv6 default route 2019-10-02 12:10:00 -05:00
Tim Kourt ce5e481239 netconfig: Add IPv6 static address installation/removal
The network configuration options for IPv6 are grouped under [IPv6]
and include the following:
	ip= ADDRESS/PREFIX
	gateway=ADDRESS
	dns=ADDRESS

The placeholders for DHCPv6 are placed along the way and marked
as TODO items.
2019-10-02 12:09:00 -05:00
Tim Kourt 0a293ef538 netconfig: Request all known IPv6 addresses 2019-10-02 11:58:56 -05:00
Tim Kourt 577e638be3 netconfig: Subscribe for IPv6 address changes
The IPv6 addresses changes are maintained in ifaddr_list.
2019-10-02 11:58:07 -05:00
Tim Kourt 50a112e425 netconfig: Remove roaming logic
Previously, netconfig_ipv4_select_and_install was used to install
addresses on initial connection to a network and after we have roamed.
Now for the after roaming connection scenario we have
netconfig_reconfigure. Remove roaming related code from
netconfig_ipv4_select_and_install
2019-10-02 10:53:39 -05:00
Tim Kourt 332eec9f9d netconfig: Don't re-install IPv4 address on re-configure 2019-10-02 10:53:08 -05:00
Tim Kourt 77770b9566 netconfig: Switch to internal active network settings
As part of the de-coupling from station object, switch all of
the network settings inquiries to use active_settings. active_settings
are set with netconfig_configure by the owner of netconfig object
and removed with netconfig_reset once network disconnects.
2019-09-30 15:05:12 -05:00