Commit Graph

116 Commits

Author SHA1 Message Date
Yu Watanabe 0f7f27694e network: fixes related to NetworkConfigSection
- Do not allocate NetworkConfigSection when filename == NULL
- set .network element before calling hashmap_put()
- Always free NetworkConfigSection in each object.
2018-11-12 16:32:11 +09:00
Yu Watanabe 17f9c355d5 network: use structured initializers 2018-11-12 16:32:10 +09:00
Tobias Jungel 7ecf0c3e17 networkd: don't remove route
In case networkd is restarted this prevents a removal of an already existing
route that would be configured using networkd. With the proposed changes the
route will be kept on the interface without removing. This happens only on
physical hosts or VMs since networkd handles interface configuration slightly
different in containers.
2018-11-06 13:28:12 +01:00
Lennart Poettering c0815ca93d
Merge pull request #10407 from yuwata/netlink-slot
sd-netlink: introduce sd_netlink_slot object and relevant functions
2018-10-18 18:05:58 +02:00
Hui Yiqun 2d53f310de networkd: type support for "throw" in [Route] section 2018-10-16 17:09:21 +02:00
Yu Watanabe 8190a388a6 sd-netlink: make sd_netlink_slot take its description 2018-10-16 18:42:23 +09:00
Yu Watanabe ee38400bba sd-netlink: introduce sd_netlink_slot 2018-10-15 18:10:04 +09:00
Yu Watanabe e8d1666687 network: drop route_expire_callback() as it is duplicate of link_route_remove_handler() 2018-10-10 14:43:05 +09:00
Yu Watanabe 1046bf9b1a network: add destroy callbacks for asynchronous netlink calls 2018-10-10 14:43:05 +09:00
Yu Watanabe 545bab1f0a sd-netlink: add destroy_callback argument to sd_netlink_call_async() 2018-10-10 14:43:05 +09:00
Filipe Brandenburger a0edd02e43 tree-wide: Convert compare_func's to use CMP() macro wherever possible.
Looked for definitions of functions using the *_compare_func() suffix.

Tested:
- Unit tests passed (ninja -C build/ test)
- Installed this build and booted with it.
2018-08-06 19:26:35 -07:00
Zbigniew Jędrzejewski-Szmek d9b02e1697 tree-wide: drop copyright headers from frequent contributors
Fixes #9320.

for p in Shapovalov Chevalier Rozhkov Sievers Mack Herrmann Schmidt Rudenberg Sahani Landden Andersen Watanabe; do
  git grep -e 'Copyright.*'$p -l|xargs perl -i -0pe 's|/([*][*])?[*]\s+([*#]\s+)?Copyright[^\n]*'$p'[^\n]*\s*[*]([*][*])?/\n*|\n|gms; s|\s+([*#]\s+)?Copyright[^\n]*'$p'[^\n]*\n*|\n|gms'
done
2018-06-20 11:58:53 +02:00
Lennart Poettering 96b2fb93c5 tree-wide: beautify remaining copyright statements
Let's unify an beautify our remaining copyright statements, with a
unicode ©. This means our copyright statements are now always formatted
the same way. Yay.
2018-06-14 10:20:21 +02:00
Lennart Poettering 818bf54632 tree-wide: drop 'This file is part of systemd' blurb
This part of the copyright blurb stems from the GPL use recommendations:

https://www.gnu.org/licenses/gpl-howto.en.html

The concept appears to originate in times where version control was per
file, instead of per tree, and was a way to glue the files together.
Ultimately, we nowadays don't live in that world anymore, and this
information is entirely useless anyway, as people are very welcome to
copy these files into any projects they like, and they shouldn't have to
change bits that are part of our copyright header for that.

hence, let's just get rid of this old cruft, and shorten our codebase a
bit.
2018-06-14 10:20:20 +02:00
Zbigniew Jędrzejewski-Szmek aff4430136 network: avoid temporary variables for parsing, use TAKE_PTR (#9166)
We don't need a temporary variable when parsing just one number, because
our parsing functions do not touch the output variable on error.

TAKE_PTR is more expressive than 'n = NULL'.
2018-06-03 11:18:23 +09:00
Susant Sahani cea79e6643 networkd: Support the ability to set MTU in [Route] sections
Add support to set the route MTU.

Closes #9047
2018-05-24 16:42:40 +02:00
Yu Watanabe 26db55f39e network: make route_update() accept NULL
This also fixes a wrong argument for route_configure().

Fixes #8960.
2018-05-11 15:43:04 +09:00
Yu Watanabe 27efb52bc6 network: fix indentation 2018-05-11 15:30:39 +09:00
Lennart Poettering 8e766630f0 tree-wide: drop redundant _cleanup_ macros (#8810)
This drops a good number of type-specific _cleanup_ macros, and patches
all users to just use the generic ones.

In most recent code we abstained from defining type-specific macros, and
this basically removes all those added already, with the exception of
the really low-level ones.

Having explicit macros for this is not too useful, as the expression
without the extra macro is generally just 2ch wider. We should generally
emphesize generic code, unless there are really good reasons for
specific code, hence let's follow this in this case too.

Note that _cleanup_free_ and similar really low-level, libc'ish, Linux
API'ish macros continue to be defined, only the really high-level OO
ones are dropped. From now on this should really be the rule: for really
low-level stuff, such as memory allocation, fd handling and so one, go
ahead and define explicit per-type macros, but for high-level, specific
program code, just use the generic _cleanup_() macro directly, in order
to keep things simple and as readable as possible for the uninitiated.

Note that before this patch some of the APIs (notable libudev ones) were
already used with the high-level macros at some places and with the
generic _cleanup_ macro at others. With this patch we hence unify on the
latter.
2018-04-25 12:31:45 +02:00
Zbigniew Jędrzejewski-Szmek 11a1589223 tree-wide: drop license boilerplate
Files which are installed as-is (any .service and other unit files, .conf
files, .policy files, etc), are left as is. My assumption is that SPDX
identifiers are not yet that well known, so it's better to retain the
extended header to avoid any doubt.

I also kept any copyright lines. We can probably remove them, but it'd nice to
obtain explicit acks from all involved authors before doing that.
2018-04-06 18:58:55 +02:00
Yu Watanabe 1cc6c93a95 tree-wide: use TAKE_PTR() and TAKE_FD() macros 2018-04-05 14:26:26 +09:00
Daniel Dao f02ba16389 setup route expiration in kernel if supported
kernel >= 4.5 (with commit 32bc201e19) supports
RTA_EXPIRES netlink attribute to set router lifetime. This simply detect
the kernel version (>=4.5) and set the lifetime properly, fallback to
expiring route in userspace for kernel that doesnt support it.

Signed-off-by: Daniel Dao <dqminh89@gmail.com>
2018-03-12 11:36:25 +00:00
Susant Sahani 09f5dfad2c networkd: add quickack option to route (#7896)
This patch adds quickack option to enable/disable TCP quick ack
mode for per-route.
2018-01-20 08:49:15 +09:00
Susant Sahani 6b21ad33ab networkd: initcwn/initwnd use the right parsers
Closes #7765
2018-01-11 15:07:03 +01:00
Susant Sahani 323d9329e7 networkd: allow to configure default/initial send/recv congestion window and store persistentl (#7750)
Currently we can only change initcwnd/initrwnd in the following way, and it does not store persistently:
sudo ip route change default via 192.168.1.1 dev tun0 initcwnd 20
sudo ip route change default via 192.168.1.1 dev tun0 initrwnd 20

For more details about initcwnd/initrwnd, please look at:
http://hjzhao.blogspot.com/2012/05/increase-initcwnd-for-performance.html
http://www.cdnplanet.com/blog/tune-tcp-initcwnd-for-optimum-performance
or google 'initcwnd initrwnd'

This work allows to configure the initcwnd and initrwnd.

Closes #2118
2017-12-29 23:18:05 +09:00
Zbigniew Jędrzejewski-Szmek bbd1590085 networkd: fix reversed arguments
Found by coverity.

Also drop unused return value while at it.
2017-11-28 09:25:38 +01:00
Zbigniew Jędrzejewski-Szmek 53e1b68390 Add SPDX license identifiers to source files under the LGPL
This follows what the kernel is doing, c.f.
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=5fd54ace4721fc5ce2bb5aef6318fcf17f421460.
2017-11-19 19:08:15 +01:00
Susant Sahani 74d42cd923 networkd: remove route - drop route type from netlink message. (#7240)
During startup of networkd we try to drop the configs. While droping
routes we filling ip route type and because of which message like
```
host: Could not drop route: Invalid argument
host: Could not drop route: Invalid argument
```
are shown.

Closed #6929
2017-11-02 21:36:03 +09:00
Yu Watanabe 4c70109600 tree-wide: use IN_SET macro (#6977) 2017-10-04 16:01:32 +02:00
Susant Sahani 983226f35a networkd: route - support unicast,blackhole,unreachable and prohibited (#6861)
Resolves issues #797 and #967.

Conf

```
[Route]
Type=blackhole
Destination=202.54.1.2
```

ip route

```
blackhole 202.54.1.2 proto static
2017-09-19 16:28:26 +02:00
Susant Sahani 14d20d2bfb networkd: fix route table from unsigned char to uint32_t (#6083)
[zj: struct Route is defined with uint32_t route, so this makes the type of the function
parameter match the field it is assigned to.]
2017-06-06 12:02:31 -04:00
Zbigniew Jędrzejewski-Szmek ca3bad6504 networkd: remove unused variables (#5948)
Fixup for 36423ff433.
2017-05-12 04:53:12 +03:00
Zbigniew Jędrzejewski-Szmek d84ed2bd13 networkd: pretiffy message about invalid prefix
We know how the field we are parsing is called, let's put this information in
the error message:
"Route Source= prefix is invalid, ignoring assignment: ..."
"Route Destination= prefix is invalid, ignoring assignment: ..."
2017-05-11 14:01:14 -04:00
Susant Sahani 36423ff433 networkd: route replace parse prefix with generic in_addr_prefix_from_string 2017-05-11 10:12:54 +05:30
Susant Sahani c83ecc04d9 networkd: add support to configure route protocol. (#5890)
Closes: #5889
2017-05-09 20:01:25 +02:00
Zbigniew Jędrzejewski-Szmek ab8ee0f259 tree-wide: use SET_FLAG in more places (#5892) 2017-05-07 07:03:28 -04:00
Susant Sahani 4c7bd9cf6b networkd: route add missing search for route object.
Probaly this happened during rebase.
2017-04-25 19:59:39 +05:30
Susant Sahani b5bf6f645e networkd: make IPv6 route preference configurable (#5700)
The work supports route preference configurable.
i.e. able to set low, medium and high.
2017-04-25 09:32:59 +02:00
Susant Sahani 28959f7d3e networkd: route - support 'onlink' routes (#5734)
This work based on Tom's original patch
teg@1312172

By setting GatewayOnlink=yes, the kernel will assume that the gateway is onlink
even if there is no route to it.

Resolves issue #1283.
2017-04-21 11:22:30 +02:00
Susant Sahani fcc48287eb networkd: Do not set config to NULL immediately.
fd45e52 sets
n to NULL which leads to crash.

fixes: #5418
2017-02-22 10:55:03 +05:30
Zbigniew Jędrzejewski-Szmek 48317c39e2 network: change condition in if testing section presence
section_line and filename should be set together or not at all. Change the
if to test filename, since it's the first of the pair and it seems more natural
to test that.
2017-02-17 09:34:25 -05:00
Zbigniew Jędrzejewski-Szmek fd45e522dd networkd: immediately transfer ownership of route->section
The code was not incorrect previously, but I think it's easier to follow the
ownership (and the code is more likely to remain correct when updated later on),
if freeing of NetworkConfigSection* is immediately made the responsibility of
route_free(), so instead of relying on route_free() not freeing ->section
if adding to the network hashmap failed, make this freeing unconditional.
2017-02-17 09:28:17 -05:00
Susant Sahani f4859fc74c networkd: fix drop-in conf directory configs overwriting each other
Now we track the sections for example [Address] via line number.
Which was fine till we din't had dropins dir. If we have multiple
sections which have the ideantical line number in diffrent files
we are overwriting these since line number is the key.

This patch fixes this by taking filename and line number as key.
This fixes [Address] and [Route] section overwriting.

fixes: #5141
2017-02-16 10:31:42 +05:30
Susant Sahani d6fceaf1f7 networkd: handle MTU field in IPv6 RA (#4719)
This patch handles the custom MTU field in IPv6 RA.

fixes RFE #4464
2016-11-23 22:32:19 +01:00
Tom Gundersen 23f53b99b1 networkd: clean up main header file a bit
Rename networkd.h to networkd-manager.h, to more accurately describe what it
contains.
2016-11-14 01:05:06 +01:00
Zbigniew Jędrzejewski-Szmek 47d2d30d83 networkd: limit the number of routes to the kernel limit (#4007)
Fixes #3922.
2016-08-21 15:06:28 +02:00
Michael Chapman a0d95bbc38 networkd: use RT_TABLE_MAIN by default
The default route table used by sd-netlink (and iproute2) is
RT_TABLE_MAIN, not RT_TABLE_DEFAULT. Ensure networkd has the same idea.
2016-08-18 17:54:12 +10:00
Michael Chapman 3bdccf69ca networkd: do not touch link_messages when expiring routes
link_messages is used during link configuration to advance the link
state machine through SETTING_ADDRESSES -> SETTING_ROUTES -> CONFIGURED.

If a route expires in the middle of this, it is possible for
link_messages to hit zero inside route_expire_callback, rather than in
route_handler or address_handler where it would trigger the next step in
configuration. Should this happen, the link will not complete
configuration, and it may not have its static routes configured.

Since route_expire_callback does not need to do anything once the
expired route has been removed from the kernel, it is safe to simply not
account for the netlink request.
2016-08-18 17:53:53 +10:00
Michael Chapman 856e309d7b networkd: avoid NULL pointer dereference in route_add
If no result parameter is provided, do not attempt to write the
found/newly-created route to it. This is presently not an issue as all
callers currently provide a non-NULL result parameter, however we should
do this for symmetry with address_add and future code robustness.
2016-08-16 19:07:42 +10:00
Susant Sahani 1c4b11794b networkd: route priority replace parsing config_parse_uint32 with safe_atou32 (#3522) 2016-06-13 15:57:17 +02:00