diff --git a/SOURCES/0001-iproute-linux-try-to-improve-flags-when-sending-del-.patch b/SOURCES/0001-iproute-linux-try-to-improve-flags-when-sending-del-.patch new file mode 100644 index 0000000..ddb5061 --- /dev/null +++ b/SOURCES/0001-iproute-linux-try-to-improve-flags-when-sending-del-.patch @@ -0,0 +1,149 @@ +From a0c83226c3bb8e54a268d62ccce47d0098f534c1 Mon Sep 17 00:00:00 2001 +From: Florent Fourcot +Date: Fri, 22 Apr 2022 19:01:12 +0200 +Subject: [PATCH] iproute/linux: try to improve flags when sending del messages + +Flags are not the same between NEW and DELETE request. In file netlink.h +we can see: + + /* Modifiers to NEW request */ + #define NLM_F_REPLACE 0x100 /* Override existing */ + #define NLM_F_EXCL 0x200 /* Do not touch, if it exists */ + #define NLM_F_CREATE 0x400 /* Create, if it does not exist */ + #define NLM_F_APPEND 0x800 /* Add to end of list */ + + /* Modifiers to DELETE request */ + #define NLM_F_NONREC 0x100 /* Do not delete recursively */ + #define NLM_F_BULK 0x200 /* Delete multiple objects */ + +So NLM_F_BULK is the same value than NLM_F_EXCL. NLM_F_BULK has been +added in this kernel commit: + +https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git/commit/?id=a6cec0bcd34264be8887791594be793b3f12719f + +When this flag is set, pyroute now get a lot of error everywhere when +trying to delete objects. + +Note that kernel commit is not yet mainline, and still in developpment +branch. But it can have a huge impact on pyroute2 library + +(cherry picked from commit 1eb08312de30a083bcfddfaa9c1d5e124b6368df) +--- + pyroute2.core/pr2modules/iproute/linux.py | 44 +++++++++++------------ + 1 file changed, 22 insertions(+), 22 deletions(-) + +diff --git a/pyroute2.core/pr2modules/iproute/linux.py b/pyroute2.core/pr2modules/iproute/linux.py +index d3c4a54a..576fb358 100644 +--- a/pyroute2.core/pr2modules/iproute/linux.py ++++ b/pyroute2.core/pr2modules/iproute/linux.py +@@ -643,7 +643,7 @@ class RTNL_API(object): + # flush all addresses with IFA_LABEL='eth0': + ipr.flush_addr(label='eth0') + ''' +- flags = NLM_F_CREATE | NLM_F_EXCL | NLM_F_REQUEST ++ flags = NLM_F_CREATE | NLM_F_REQUEST + ret = [] + for addr in self.get_addr(*argv, **kwarg): + self.put(addr, msg_type=RTM_DELADDR, msg_flags=flags) +@@ -664,7 +664,7 @@ class RTNL_API(object): + # flush all IPv6 rules that point to table 250: + ipr.flush_rules(family=socket.AF_INET6, table=250) + ''' +- flags = NLM_F_CREATE | NLM_F_EXCL | NLM_F_REQUEST ++ flags = NLM_F_CREATE | NLM_F_REQUEST + ret = [] + for rule in self.get_rules(*argv, **kwarg): + self.put(rule, msg_type=RTM_DELRULE, msg_flags=flags) +@@ -1049,9 +1049,9 @@ class RTNL_API(object): + 'set': (RTM_NEWNEIGH, flags_replace), + 'replace': (RTM_NEWNEIGH, flags_replace), + 'change': (RTM_NEWNEIGH, flags_change), +- 'del': (RTM_DELNEIGH, flags_make), +- 'remove': (RTM_DELNEIGH, flags_make), +- 'delete': (RTM_DELNEIGH, flags_make), ++ 'del': (RTM_DELNEIGH, flags_base), ++ 'remove': (RTM_DELNEIGH, flags_base), ++ 'delete': (RTM_DELNEIGH, flags_base), + 'dump': (RTM_GETNEIGH, flags_dump), + 'get': (RTM_GETNEIGH, flags_base), + 'append': (RTM_NEWNEIGH, flags_append), +@@ -1428,11 +1428,11 @@ class RTNL_API(object): + 'set': (RTM_NEWLINK, flags_req), + 'update': (RTM_SETLINK, flags_create), + 'add': (RTM_NEWLINK, flags_create), +- 'del': (RTM_DELLINK, flags_create), ++ 'del': (RTM_DELLINK, flags_req), + 'property_add': (RTM_NEWLINKPROP, flag_append), + 'property_del': (RTM_DELLINKPROP, flags_req), +- 'remove': (RTM_DELLINK, flags_create), +- 'delete': (RTM_DELLINK, flags_create), ++ 'remove': (RTM_DELLINK, flags_req), ++ 'delete': (RTM_DELLINK, flags_req), + 'dump': (RTM_GETLINK, flags_dump), + 'get': (RTM_GETLINK, NLM_F_REQUEST), + } +@@ -1573,9 +1573,9 @@ class RTNL_API(object): + flags_replace = flags_base | NLM_F_REPLACE | NLM_F_CREATE + commands = { + 'add': (RTM_NEWADDR, flags_create), +- 'del': (RTM_DELADDR, flags_create), +- 'remove': (RTM_DELADDR, flags_create), +- 'delete': (RTM_DELADDR, flags_create), ++ 'del': (RTM_DELADDR, flags_base), ++ 'remove': (RTM_DELADDR, flags_base), ++ 'delete': (RTM_DELADDR, flags_base), + 'replace': (RTM_NEWADDR, flags_replace), + 'dump': (RTM_GETADDR, flags_dump), + } +@@ -1727,17 +1727,17 @@ class RTNL_API(object): + + commands = { + 'add': (RTM_NEWQDISC, flags_make), +- 'del': (RTM_DELQDISC, flags_make), +- 'remove': (RTM_DELQDISC, flags_make), +- 'delete': (RTM_DELQDISC, flags_make), ++ 'del': (RTM_DELQDISC, flags_base), ++ 'remove': (RTM_DELQDISC, flags_base), ++ 'delete': (RTM_DELQDISC, flags_base), + 'change': (RTM_NEWQDISC, flags_change), + 'replace': (RTM_NEWQDISC, flags_replace), + 'add-class': (RTM_NEWTCLASS, flags_make), +- 'del-class': (RTM_DELTCLASS, flags_make), ++ 'del-class': (RTM_DELTCLASS, flags_base), + 'change-class': (RTM_NEWTCLASS, flags_change), + 'replace-class': (RTM_NEWTCLASS, flags_replace), + 'add-filter': (RTM_NEWTFILTER, flags_make), +- 'del-filter': (RTM_DELTFILTER, flags_make), ++ 'del-filter': (RTM_DELTFILTER, flags_base), + 'change-filter': (RTM_NEWTFILTER, flags_change), + 'replace-filter': (RTM_NEWTFILTER, flags_replace), + } +@@ -2040,9 +2040,9 @@ class RTNL_API(object): + 'replace': (RTM_NEWROUTE, flags_replace), + 'change': (RTM_NEWROUTE, flags_change), + 'append': (RTM_NEWROUTE, flags_append), +- 'del': (RTM_DELROUTE, flags_make), +- 'remove': (RTM_DELROUTE, flags_make), +- 'delete': (RTM_DELROUTE, flags_make), ++ 'del': (RTM_DELROUTE, flags_base), ++ 'remove': (RTM_DELROUTE, flags_base), ++ 'delete': (RTM_DELROUTE, flags_base), + 'get': (RTM_GETROUTE, NLM_F_REQUEST), + 'show': (RTM_GETROUTE, flags_dump), + 'dump': (RTM_GETROUTE, flags_dump), +@@ -2192,9 +2192,9 @@ class RTNL_API(object): + + commands = { + 'add': (RTM_NEWRULE, flags_make), +- 'del': (RTM_DELRULE, flags_make), +- 'remove': (RTM_DELRULE, flags_make), +- 'delete': (RTM_DELRULE, flags_make), ++ 'del': (RTM_DELRULE, flags_base), ++ 'remove': (RTM_DELRULE, flags_base), ++ 'delete': (RTM_DELRULE, flags_base), + 'dump': (RTM_GETRULE, flags_dump), + } + if isinstance(command, int): +-- +2.40.0 + diff --git a/SPECS/python-pyroute2.spec b/SPECS/python-pyroute2.spec index e2fd359..af9e5c9 100644 --- a/SPECS/python-pyroute2.spec +++ b/SPECS/python-pyroute2.spec @@ -9,7 +9,7 @@ Name: python-%{srcname} Version: 0.6.9 -Release: 2%{?dist} +Release: 3%{?dist} Summary: Pure Python netlink library License: GPLv2+ URL: https://github.com/svinota/%{srcname} @@ -24,6 +24,8 @@ Source5: %{pypi_source pyroute2.ipset} Source6: %{pypi_source pyroute2.ipdb} Source7: %{pypi_source pyroute2.ndb} +Patch: 0001-iproute-linux-try-to-improve-flags-when-sending-del-.patch + %description PyRoute2 provides several levels of API to work with Netlink protocols, such as Generic Netlink, RTNL, TaskStats, NFNetlink, @@ -55,6 +57,9 @@ tar xzvf %SOURCE4 tar xzvf %SOURCE5 tar xzvf %SOURCE6 tar xzvf %SOURCE7 +cd pyroute2.core-%{version} +%patch -p2 +cd .. %build %py3_build @@ -98,6 +103,9 @@ cd ../pyroute2.ndb-%{version} %{python3_sitelib}/pr2modules %changelog +* Thu Jun 15 2023 Yatin Karel - 0.6.9-3 +- Backport https://github.com/svinota/pyroute2/commit/1eb08312 + * Thu Apr 21 2022 Karolina Kula - 0.6.9-2 - Update to 0.6.9 - Reintroduce condition for imporlib-metadata for CS8