Package: systemd
Version: 240-6
Severity: normal
Tags: patch
User: ubuntu-de...@lists.ubuntu.com
Usertags: origin-ubuntu disco ubuntu-patch

Dear Maintainer,

When attaching multiple IPs on secondary interface the routing policy rules do 
not
apply for all IPs.
The rules that are applied after restarting networkd are random.
The issue has been reported and addressed upstream.
Bug : https://github.com/systemd/systemd/issues/11280
Fix : https://github.com/systemd/systemd/pull/11795/

In Ubuntu, the attached patch was applied to achieve the following:

lp-bug : https://launchpad.net/bugs/1818282

  * d/p/network-remove-routing-policy-rule-from-foreign-rule.patch:
    - Fix RoutingPolicyRule does not apply correctly (LP: #1818282)
  * d/p/network-do-not-remove-rule-when-it-is-requested-by-e.patch:
    - Fix RoutingPolicyRule does not apply correctly (LP: #1818282) 


Thanks for considering the patch.


-- System Information:
Debian Release: buster/sid
  APT prefers disco
  APT policy: (500, 'disco')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 4.19.0-13-generic (SMP w/8 CPU cores)
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8), 
LANGUAGE=en_GB:en (charmap=UTF-8)
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages systemd is related to:
pn  dracut           <none>
ii  initramfs-tools  0.131ubuntu17
ii  udev             240-6ubuntu2
diff -Nru systemd-240/debian/control systemd-240/debian/control
--- systemd-240/debian/control  2019-02-20 20:21:33.000000000 +0000
+++ systemd-240/debian/control  2019-03-04 10:32:19.000000000 +0000
@@ -1,8 +1,7 @@
 Source: systemd
 Section: admin
 Priority: optional
-Maintainer: Ubuntu Developers <ubuntu-devel-disc...@lists.ubuntu.com>
-XSBC-Original-Maintainer: Debian systemd Maintainers 
<pkg-systemd-maintain...@lists.alioth.debian.org>
+Maintainer: Debian systemd Maintainers 
<pkg-systemd-maintain...@lists.alioth.debian.org>
 Uploaders: Michael Biebl <bi...@debian.org>,
            Marco d'Itri <m...@linux.it>,
            Sjoerd Simons <sjo...@debian.org>,
diff -Nru 
systemd-240/debian/patches/network-do-not-remove-rule-when-it-is-requested-by-e.patch
 
systemd-240/debian/patches/network-do-not-remove-rule-when-it-is-requested-by-e.patch
--- 
systemd-240/debian/patches/network-do-not-remove-rule-when-it-is-requested-by-e.patch
       1970-01-01 01:00:00.000000000 +0100
+++ 
systemd-240/debian/patches/network-do-not-remove-rule-when-it-is-requested-by-e.patch
       2019-03-04 10:30:34.000000000 +0000
@@ -0,0 +1,58 @@
+Description: 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...
+
+Author: Yu Watanabe <watanabe.yu+git...@gmail.com>
+Subject: [PATCH] network: do not remove rule when it is requested by existing
+ links
+Origin: Upstream, 
https://github.com/systemd/systemd/pull/11795/commits/031fb59a984e5b51f3c72aa8125ecc50b08011fe
+Bug: https://github.com/systemd/systemd/issues/11280
+Bug-Ubuntu: https://launchpad.net/bugs/1818282
+---
+ src/network/networkd-routing-policy-rule.c | 26 ++++++++++++++++++++++
+ 1 file changed, 26 insertions(+)
+
+Index: systemd-240/src/network/networkd-routing-policy-rule.c
+===================================================================
+--- systemd-240.orig/src/network/networkd-routing-policy-rule.c
++++ systemd-240/src/network/networkd-routing-policy-rule.c
+@@ -1250,6 +1250,26 @@ int routing_policy_load_rules(const char
+         return 0;
+ }
+ 
++static bool manager_links_have_routing_policy_rule(Manager *m, 
RoutingPolicyRule *rule) {
++        RoutingPolicyRule *link_rule;
++        Iterator i;
++        Link *link;
++
++        assert(m);
++        assert(rule);
++
++        HASHMAP_FOREACH(link, m->links, i) {
++                if (!link->network)
++                        continue;
++
++                LIST_FOREACH(rules, link_rule, link->network->rules)
++                        if (routing_policy_rule_compare_func(link_rule, rule) 
== 0)
++                                return true;
++        }
++
++        return false;
++}
++
+ void routing_policy_rule_purge(Manager *m, Link *link) {
+         RoutingPolicyRule *rule, *existing;
+         Iterator i;
+@@ -1263,6 +1283,12 @@ void routing_policy_rule_purge(Manager *
+                 if (!existing)
+                         continue; /* Saved rule does not exist anymore. */
+ 
++                if (manager_links_have_routing_policy_rule(m, existing))
++                        continue; /* Existing links have the saved rule. */
++
++                /* Existing links do not have the saved rule. Let's drop the 
rule now, and re-configure it
++                 * later when it is requested. */
++
+                 r = routing_policy_rule_remove(existing, link, NULL);
+                 if (r < 0) {
+                         log_warning_errno(r, "Could not remove routing policy 
rules: %m");
diff -Nru 
systemd-240/debian/patches/network-remove-routing-policy-rule-from-foreign-rule.patch
 
systemd-240/debian/patches/network-remove-routing-policy-rule-from-foreign-rule.patch
--- 
systemd-240/debian/patches/network-remove-routing-policy-rule-from-foreign-rule.patch
       1970-01-01 01:00:00.000000000 +0100
+++ 
systemd-240/debian/patches/network-remove-routing-policy-rule-from-foreign-rule.patch
       2019-03-04 10:23:57.000000000 +0000
@@ -0,0 +1,51 @@
+Description: Network - remove routing policy from foreign rule database
+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.
+
+Author: Yu Watanabe <watanabe.yu+git...@gmail.com>
+Subject: [PATCH] network: remove routing policy rule from foreign rule
+ database when it is removed
+Origin: Upstream, 
https://github.com/systemd/systemd/pull/11795/commits/92cd00b9749141907a1110044cc7d1f01caff545
+Bug: https://github.com/systemd/systemd/issues/11280
+Bug-Ubuntu: https://launchpad.net/bugs/1818282
+---
+ src/network/networkd-routing-policy-rule.c | 19 +++++++++++--------
+ 1 file changed, 11 insertions(+), 8 deletions(-)
+
+Index: systemd-240/src/network/networkd-routing-policy-rule.c
+===================================================================
+--- systemd-240.orig/src/network/networkd-routing-policy-rule.c
++++ systemd-240/src/network/networkd-routing-policy-rule.c
+@@ -1260,15 +1260,18 @@ void routing_policy_rule_purge(Manager *
+ 
+         SET_FOREACH(rule, m->rules_saved, i) {
+                 existing = set_get(m->rules_foreign, rule);
+-                if (existing) {
++                if (!existing)
++                        continue; /* Saved rule does not exist anymore. */
+ 
+-                        r = routing_policy_rule_remove(rule, link, NULL);
+-                        if (r < 0) {
+-                                log_warning_errno(r, "Could not remove 
routing policy rules: %m");
+-                                continue;
+-                        }
+-
+-                        link->routing_policy_rule_remove_messages++;
++                r = routing_policy_rule_remove(existing, link, NULL);
++                if (r < 0) {
++                        log_warning_errno(r, "Could not remove routing policy 
rules: %m");
++                        continue;
+                 }
++
++                link->routing_policy_rule_remove_messages++;
++
++                assert_se(set_remove(m->rules_foreign, existing) == existing);
++                routing_policy_rule_free(existing);
+         }
+ }
diff -Nru systemd-240/debian/patches/series systemd-240/debian/patches/series
--- systemd-240/debian/patches/series   2019-02-20 20:37:16.000000000 +0000
+++ systemd-240/debian/patches/series   2019-03-04 10:24:49.000000000 +0000
@@ -95,3 +95,5 @@
 resolved-only-call-complete-with-zero-argument-in-LLMNR-c.patch
 resolved-add-comment-to-dns_stream_complete-about-its-err.patch
 resolved-keep-stub-stream-connections-up-for-as-long-as-c.patch
+network-remove-routing-policy-rule-from-foreign-rule.patch
+network-do-not-remove-rule-when-it-is-requested-by-e.patch

Reply via email to