Zbigniew Jędrzejewski-Szmek
de7fef4b6e
tree-wide: use set_ensure_put()
...
Patch contains a coccinelle script, but it only works in some cases. Many
parts were converted by hand.
Note: I did not fix errors in return value handing. This will be done separate
to keep the patch comprehensible. No functional change is intended in this
patch.
2020-06-22 16:32:37 +02:00
Naïm Favier
53e1ba280f
network: add SuppressPrefixLength option to RoutingPolicyRule ( #14736 )
...
Closes #14724 .
2020-02-03 08:25:48 +09:00
Yu Watanabe
ea471a4695
network: support UID based routing policy
...
Closes #14666 .
2020-02-02 22:43:38 +09:00
Yu Watanabe
98b0299479
network: append INTERFACE= attributes for logs corresponds to a netif
2020-01-07 22:20:43 +09:00
Yu Watanabe
5ecb131d94
network: include NLMSGERR_ATTR_MSG attribute in error message
2019-11-30 16:14:02 +09:00
Zbigniew Jędrzejewski-Szmek
314ed4f994
networkd: unbreak routing_policy_rule_compare_func()
...
!r is the same r == 0, so this was short-circuiting the comparison when
streq(a->iff, b->iff) or streq(a->off, b->off). Before the parent commit which
moved those comparisons to the end, this was short-circuiting quite a bit
of the comparison function.
2019-09-17 19:27:58 +02:00
Zbigniew Jędrzejewski-Szmek
67e05dd8cd
networkd: use same order in _hash_func() and _compare_func()
...
This makes it easier to see that the same data is handled in both cases.
No functional change.
2019-09-17 19:11:50 +02:00
Yu Watanabe
1520151268
network: add more debug messages
2019-09-15 22:33:11 +09:00
Zbigniew Jędrzejewski-Szmek
57ad760746
network: drop all checks of ipv6_disabled sysctl
...
*We* control the sysctl setting. If the user configured IPv6, then we apply the
settings, and just make sure that at some point during the configuration the
sysctl is disabled (i.e. ipv6 enabled) if we have IPv6 configured.
Replaces #13283 .
2019-08-27 15:31:48 +02:00
Yu Watanabe
f6c6ff97f5
network: add RoutingPolicyRule.Family= setting
...
Closes #13233 .
2019-08-16 22:02:17 +09:00
Yu Watanabe
01fc8e4f43
network: split out copying logic from routing_policy_rule_add_internal()
2019-08-16 22:02:17 +09:00
Yu Watanabe
ec863cdc20
network: add missing entry in serialization/deserialization
2019-08-16 22:01:17 +09:00
Yu Watanabe
43e08c78c7
network: serialize/deserialize address family
2019-08-16 22:01:17 +09:00
Yu Watanabe
0aabccc87d
network: refuse the case To= and From= are in different address family
2019-08-16 22:01:17 +09:00
Yu Watanabe
75a302b561
network: fix potential memleaks related to set_put()
2019-08-11 08:57:01 +09:00
Yu Watanabe
4ff296b024
network: make link enter failed state when a configuration fails
...
Some path of configuring address, route or etc., go to failed state, but
some do not. E.g., failure in address configuration which is provided by
DHCPv4 goes to failed state, but static address does not.
This is just for consistency. This should not change anything if
everything is fine.
This also voidify manager_rtnl_process_address().
2019-07-15 21:52:06 +09:00
Yu Watanabe
b80a511b1b
network: add missing entries in routing_policy_rule_{hash,compare}_func()
...
This also makes routing_policy_rule_get() or friends take
a RoutingPolicyRule object as an input.
2019-06-19 21:10:07 +09:00
Yu Watanabe
34715d8b03
network: make routing_policy_rule_get() require Manager
2019-06-18 13:10:23 +09:00
Yu Watanabe
bafa964144
network: read link specific sysctl value
...
This introduce link_sysctl_ipv6_enabled() and replaces
manager_sysctl_ipv6_enabled() with it.
2019-06-15 14:56:42 +02:00
Yu Watanabe
7ef7e5509b
network: ignore requested ipv6 routing policy rule when ipv6 is disabled by sysctl
2019-06-12 11:03:37 +09:00
Yu Watanabe
9ee92e7ed8
network: check stored object is euivalent to what we want to remove
...
When object A is stored in Manager::rules and B is in ::rules_foreign,
and compare function for the object cannot distinguish them,
then freeing A causes B to be removed from rules_foreign or vice versa.
Hopefully fixes #12731 .
2019-06-06 00:45:46 +09:00
Yu Watanabe
9f08a578a8
network: remove unused argument in routing_policy_rule_configure()
2019-06-04 16:23:18 +09:00
Yu Watanabe
d26267ddf1
network: fix double free on error path
2019-06-04 16:23:18 +09:00
Yu Watanabe
fcbf4cb727
network: drop sections contain invalid settings in network_verify()
...
If e.g., an [Address] section has an invalid setting, then
previously assigned settings in the section is freed, and
only later settings are stored. That may cause partially broken
section stored in Network object.
This makes if an invalid setting is found, then set 'invalid' flag
instead of freeing it. And invalid sections are dropped later by
network_verify().
2019-03-13 11:59:18 +09:00
Yu Watanabe
031fb59a98
network: do not remove rule when it is requested by existing links
...
Otherwise, the first link once removes all saved rules in the foreign
rule database, and the second or later links create again...
2019-02-27 10:59:10 +09:00
Yu Watanabe
92cd00b974
network: remove routing policy rule from foreign rule database when it is removed
...
Previously, When the first link configures rules, it removes all saved
rules, which were configured by networkd previously, in the foreign rule
database, but the rules themselves are still in the database.
Thus, when the second or later link configures rules, it errnously
treats the rules already exist.
This is the root of issue #11280 .
This removes rules from the foreign database when they are removed.
Fixes #11280 .
2019-02-27 10:58:09 +09:00
Yu Watanabe
434094864c
network: use netlink_message_append_{in_addr,sockaddr}_union()
2019-02-11 01:28:09 +09:00
Yu Watanabe
d40b01e44b
network: in_addr_is_null() may return negative errno
...
So, do not silently cast the returned value to boolean.
Exception is the case that family is trivially AF_INET or AF_INET6.
2019-02-11 01:28:09 +09:00
Susant Sahani
8b220643b1
networkd: RPDB rule - add support to configure inverted rule.
...
Closes #10706
2018-12-06 10:42:36 +05:30
Lennart Poettering
76b31bbb24
Merge pull request #10920 from yuwata/hashmap-destructor
...
hashmap: make hashmap_free() call destructors of key or value
2018-12-03 17:59:44 +01:00
Lennart Poettering
a20f73221a
Merge pull request #10976 from yuwata/typesafe-netlink-call
...
netlink: introduce typesafe netlink functions
2018-12-03 17:55:00 +01:00
Yu Watanabe
7934dede41
network: drop unnecessary buffers
2018-12-03 12:15:26 +01:00
Yu Watanabe
7a08d314f2
tree-wide: make hash_ops typesafe
2018-12-02 07:53:27 +01:00
Yu Watanabe
302a796f5a
network: use typesafe netlink_call_async() macro where applicable
2018-12-02 06:29:32 +01:00
Yu Watanabe
29889b4d24
network: set default callbacks for routing_policy_rule_configure() and routing_policy_rule_remove()
2018-12-02 06:23:45 +01:00
Yu Watanabe
3a269dcf51
network: make IPProtocol= also accept IP protocol number
2018-12-02 06:13:47 +01:00
Yu Watanabe
97f9df9e30
network: rename Protocol= in [RoutingPolicyRule] to IPProtocol=
2018-12-02 06:13:47 +01:00
Yu Watanabe
da96ad5ae2
util: rename socket_protocol_{from,to}_name() to ip_protocol_{from,to}_name()
2018-12-02 05:48:27 +01:00
Susant Sahani
58a02e4c97
ip rule: fix clang warning.
...
```
[2/1209] Compiling C object 'src/network/src@network@@networkd-core@sta/networkd-routing-policy-rule.c.o'.
FAILED: src/network/src@network@@networkd-core@sta/networkd-routing-policy-rule.c.o
clang -Isrc/network/src@network@@networkd-core@sta -Isrc/network -I../src/network -Isrc/basic -I../src/basic -Isrc/shared -I../src/shared -Isrc/systemd -I../src/systemd -Isrc/journal -I../src/journal -Isrc/journal-remote -I../src/journal-remote -Isrc/nspawn -I../src/nspawn -Isrc/resolve -I../src/resolve -Isrc/timesync -I../src/timesync -I../src/time-wait-sync -Isrc/login -I../src/login -Isrc/udev -I../src/udev -Isrc/libudev -I../src/libudev -Isrc/core -I../src/core -I../src/libsystemd/sd-bus -I../src/libsystemd/sd-device -I../src/libsystemd/sd-event -I../src/libsystemd/sd-hwdb -I../src/libsystemd/sd-id128 -I../src/libsystemd/sd-netlink -I../src/libsystemd/sd-network -Isrc/libsystemd-network -I../src/libsystemd-network -I. -I../ -Xclang -fcolor-diagnostics -pipe -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Werror -std=gnu99 -O0 -g -Wextra -Werror=undef -Wmissing-include-dirs -Wold-style-definition -Wpointer-arith -Winit-self -Wfloat-equal -Werror=missing-prototypes -Werror=implicit-function-declaration -Werror=missing-declarations -Werror=return-type -Werror=incompatible-pointer-types -Werror=format=2 -Wstrict-prototypes -Wredundant-decls -Wmissing-noreturn -Wshadow -Wendif-labels -Wstrict-aliasing=2 -Wwrite-strings -Werror=overflow -Werror=shift-count-overflow -Wdate-time -Wnested-externs -Wno-unused-parameter -Wno-missing-field-initializers -Wno-unused-result -Wno-error=nonnull -ffast-math -fno-common -fdiagnostics-show-option -fno-strict-aliasing -fvisibility=hidden -fstack-protector -fstack-protector-strong --param=ssp-buffer-size=4 -fPIE -Wno-typedef-redefinition -Wno-gnu-variable-sized-type-not-at-end -Werror=shadow -include config.h -fPIC -MD -MQ 'src/network/src@network@@networkd-core@sta/networkd-routing-policy-rule.c.o' -MF 'src/network/src@network@@networkd-core@sta/networkd-routing-policy-rule.c.o.d' -o 'src/network/src@network@@networkd-core@sta/networkd-routing-policy-rule.c.o' -c ../src/network/networkd-routing-policy-rule.c
../src/network/networkd-routing-policy-rule.c:1071:33: error: format specifies type 'unsigned char' but the argument has type '__u16' (aka 'unsigned short') [-Werror,-Wformat]
rule->sport.start, rule->sport.end);
^~~~~~~~~~~~~~~~~
../src/network/networkd-routing-policy-rule.c:1071:52: error: format specifies type 'unsigned char' but the argument has type '__u16' (aka 'unsigned short') [-Werror,-Wformat]
rule->sport.start, rule->sport.end);
^~~~~~~~~~~~~~~
../src/network/networkd-routing-policy-rule.c:1078:33: error: format specifies type 'unsigned char' but the argument has type '__u16' (aka 'unsigned short') [-Werror,-Wformat]
rule->dport.start, rule->dport.end);
^~~~~~~~~~~~~~~~~
../src/network/networkd-routing-policy-rule.c:1078:52: error: format specifies type 'unsigned char' but the argument has type '__u16' (aka 'unsigned short') [-Werror,-Wformat]
rule->dport.start, rule->dport.end);
^~~~~~~~~~~~~~~
4 errors generated.
```
2018-12-01 15:45:12 +01:00
Susant Sahani
926062f083
networkd: add support to configure ip rule port range and protocol.
...
Please see:
iprule: support for ip_proto, sport and dport match options
https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/commit/?id=f686f764682745daf6a93b0a6330ba42a961f858
Closes 10622
2018-11-28 20:06:28 +05:30
Yu Watanabe
3e5700428e
network: allocate hashmap objects when they are required
2018-11-12 16:32:11 +09:00
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
cb700a11d9
network: drop white space in log message
2018-11-01 23:41:29 +09:00
Yu Watanabe
0d7febd002
network: fix hash function for routing policy rule
2018-11-01 23:40:56 +09:00
Yu Watanabe
e6b65ab760
network: fix return value of routing_policy_rule_get()
...
To distinguish source of rule.
2018-11-01 23:38:11 +09:00
Yu Watanabe
a6276f0f3f
network: fix memleak in routing policy
...
As set_put() may fail if input is duplicated.
2018-11-01 23:24:20 +09: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
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