|
rdobuilder |
949e4f |
From a674208832c217aba3d5e18ab312b1d80e63f133 Mon Sep 17 00:00:00 2001
|
|
rdobuilder |
949e4f |
From: Florent Fourcot <florent.fourcot@wifirst.fr>
|
|
rdobuilder |
949e4f |
Date: Fri, 22 Apr 2022 19:01:12 +0200
|
|
rdobuilder |
949e4f |
Subject: [PATCH] iproute/linux: try to improve flags when sending del messages
|
|
rdobuilder |
949e4f |
|
|
rdobuilder |
949e4f |
Flags are not the same between NEW and DELETE request. In file netlink.h
|
|
rdobuilder |
949e4f |
we can see:
|
|
rdobuilder |
949e4f |
|
|
rdobuilder |
949e4f |
/* Modifiers to NEW request */
|
|
rdobuilder |
949e4f |
#define NLM_F_REPLACE 0x100 /* Override existing */
|
|
rdobuilder |
949e4f |
#define NLM_F_EXCL 0x200 /* Do not touch, if it exists */
|
|
rdobuilder |
949e4f |
#define NLM_F_CREATE 0x400 /* Create, if it does not exist */
|
|
rdobuilder |
949e4f |
#define NLM_F_APPEND 0x800 /* Add to end of list */
|
|
rdobuilder |
949e4f |
|
|
rdobuilder |
949e4f |
/* Modifiers to DELETE request */
|
|
rdobuilder |
949e4f |
#define NLM_F_NONREC 0x100 /* Do not delete recursively */
|
|
rdobuilder |
949e4f |
#define NLM_F_BULK 0x200 /* Delete multiple objects */
|
|
rdobuilder |
949e4f |
|
|
rdobuilder |
949e4f |
So NLM_F_BULK is the same value than NLM_F_EXCL. NLM_F_BULK has been
|
|
rdobuilder |
949e4f |
added in this kernel commit:
|
|
rdobuilder |
949e4f |
|
|
rdobuilder |
949e4f |
https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git/commit/?id=a6cec0bcd34264be8887791594be793b3f12719f
|
|
rdobuilder |
949e4f |
|
|
rdobuilder |
949e4f |
When this flag is set, pyroute now get a lot of error everywhere when
|
|
rdobuilder |
949e4f |
trying to delete objects.
|
|
rdobuilder |
949e4f |
|
|
rdobuilder |
949e4f |
Note that kernel commit is not yet mainline, and still in developpment
|
|
rdobuilder |
949e4f |
branch. But it can have a huge impact on pyroute2 library
|
|
rdobuilder |
949e4f |
|
|
rdobuilder |
949e4f |
(cherry picked from commit 1eb08312de30a083bcfddfaa9c1d5e124b6368df)
|
|
rdobuilder |
949e4f |
Conflicts:
|
|
rdobuilder |
949e4f |
pyroute2.core/pr2modules/iproute/linux.py
|
|
rdobuilder |
949e4f |
---
|
|
rdobuilder |
949e4f |
pyroute2.core/pr2modules/iproute/linux.py | 44 +++++++++++------------
|
|
rdobuilder |
949e4f |
1 file changed, 22 insertions(+), 22 deletions(-)
|
|
rdobuilder |
949e4f |
|
|
rdobuilder |
949e4f |
diff --git a/pyroute2.core/pr2modules/iproute/linux.py b/pyroute2.core/pr2modules/iproute/linux.py
|
|
rdobuilder |
949e4f |
index 725cdb18..68665685 100644
|
|
rdobuilder |
949e4f |
--- a/pyroute2.core/pr2modules/iproute/linux.py
|
|
rdobuilder |
949e4f |
+++ b/pyroute2.core/pr2modules/iproute/linux.py
|
|
rdobuilder |
949e4f |
@@ -625,7 +625,7 @@ class RTNL_API(object):
|
|
rdobuilder |
949e4f |
# flush all addresses with IFA_LABEL='eth0':
|
|
rdobuilder |
949e4f |
ipr.flush_addr(label='eth0')
|
|
rdobuilder |
949e4f |
'''
|
|
rdobuilder |
949e4f |
- flags = NLM_F_CREATE | NLM_F_EXCL | NLM_F_REQUEST
|
|
rdobuilder |
949e4f |
+ flags = NLM_F_CREATE | NLM_F_REQUEST
|
|
rdobuilder |
949e4f |
ret = []
|
|
rdobuilder |
949e4f |
for addr in self.get_addr(*argv, **kwarg):
|
|
rdobuilder |
949e4f |
self.put(addr, msg_type=RTM_DELADDR, msg_flags=flags)
|
|
rdobuilder |
949e4f |
@@ -646,7 +646,7 @@ class RTNL_API(object):
|
|
rdobuilder |
949e4f |
# flush all IPv6 rules that point to table 250:
|
|
rdobuilder |
949e4f |
ipr.flush_rules(family=socket.AF_INET6, table=250)
|
|
rdobuilder |
949e4f |
'''
|
|
rdobuilder |
949e4f |
- flags = NLM_F_CREATE | NLM_F_EXCL | NLM_F_REQUEST
|
|
rdobuilder |
949e4f |
+ flags = NLM_F_CREATE | NLM_F_REQUEST
|
|
rdobuilder |
949e4f |
ret = []
|
|
rdobuilder |
949e4f |
for rule in self.get_rules(*argv, **kwarg):
|
|
rdobuilder |
949e4f |
self.put(rule, msg_type=RTM_DELRULE, msg_flags=flags)
|
|
rdobuilder |
949e4f |
@@ -1010,9 +1010,9 @@ class RTNL_API(object):
|
|
rdobuilder |
949e4f |
'set': (RTM_NEWNEIGH, flags_replace),
|
|
rdobuilder |
949e4f |
'replace': (RTM_NEWNEIGH, flags_replace),
|
|
rdobuilder |
949e4f |
'change': (RTM_NEWNEIGH, flags_change),
|
|
rdobuilder |
949e4f |
- 'del': (RTM_DELNEIGH, flags_make),
|
|
rdobuilder |
949e4f |
- 'remove': (RTM_DELNEIGH, flags_make),
|
|
rdobuilder |
949e4f |
- 'delete': (RTM_DELNEIGH, flags_make),
|
|
rdobuilder |
949e4f |
+ 'del': (RTM_DELNEIGH, flags_base),
|
|
rdobuilder |
949e4f |
+ 'remove': (RTM_DELNEIGH, flags_base),
|
|
rdobuilder |
949e4f |
+ 'delete': (RTM_DELNEIGH, flags_base),
|
|
rdobuilder |
949e4f |
'dump': (RTM_GETNEIGH, flags_dump),
|
|
rdobuilder |
949e4f |
'get': (RTM_GETNEIGH, flags_base),
|
|
rdobuilder |
949e4f |
'append': (RTM_NEWNEIGH, flags_append)}
|
|
rdobuilder |
949e4f |
@@ -1391,11 +1391,11 @@ class RTNL_API(object):
|
|
rdobuilder |
949e4f |
commands = {'set': (RTM_NEWLINK, flags_req),
|
|
rdobuilder |
949e4f |
'update': (RTM_SETLINK, flags_create),
|
|
rdobuilder |
949e4f |
'add': (RTM_NEWLINK, flags_create),
|
|
rdobuilder |
949e4f |
- 'del': (RTM_DELLINK, flags_create),
|
|
rdobuilder |
949e4f |
+ 'del': (RTM_DELLINK, flags_req),
|
|
rdobuilder |
949e4f |
'property_add': (RTM_NEWLINKPROP, flag_append),
|
|
rdobuilder |
949e4f |
'property_del': (RTM_DELLINKPROP, flags_req),
|
|
rdobuilder |
949e4f |
- 'remove': (RTM_DELLINK, flags_create),
|
|
rdobuilder |
949e4f |
- 'delete': (RTM_DELLINK, flags_create),
|
|
rdobuilder |
949e4f |
+ 'remove': (RTM_DELLINK, flags_req),
|
|
rdobuilder |
949e4f |
+ 'delete': (RTM_DELLINK, flags_req),
|
|
rdobuilder |
949e4f |
'dump': (RTM_GETLINK, flags_dump),
|
|
rdobuilder |
949e4f |
'get': (RTM_GETLINK, NLM_F_REQUEST)}
|
|
rdobuilder |
949e4f |
|
|
rdobuilder |
949e4f |
@@ -1525,9 +1525,9 @@ class RTNL_API(object):
|
|
rdobuilder |
949e4f |
flags_create = flags_base | NLM_F_CREATE | NLM_F_EXCL
|
|
rdobuilder |
949e4f |
flags_replace = flags_base | NLM_F_REPLACE | NLM_F_CREATE
|
|
rdobuilder |
949e4f |
commands = {'add': (RTM_NEWADDR, flags_create),
|
|
rdobuilder |
949e4f |
- 'del': (RTM_DELADDR, flags_create),
|
|
rdobuilder |
949e4f |
- 'remove': (RTM_DELADDR, flags_create),
|
|
rdobuilder |
949e4f |
- 'delete': (RTM_DELADDR, flags_create),
|
|
rdobuilder |
949e4f |
+ 'del': (RTM_DELADDR, flags_base),
|
|
rdobuilder |
949e4f |
+ 'remove': (RTM_DELADDR, flags_base),
|
|
rdobuilder |
949e4f |
+ 'delete': (RTM_DELADDR, flags_base),
|
|
rdobuilder |
949e4f |
'replace': (RTM_NEWADDR, flags_replace),
|
|
rdobuilder |
949e4f |
'dump': (RTM_GETADDR, flags_dump)}
|
|
rdobuilder |
949e4f |
(command, flags) = commands.get(command, command)
|
|
rdobuilder |
949e4f |
@@ -1674,17 +1674,17 @@ class RTNL_API(object):
|
|
rdobuilder |
949e4f |
flags_replace = flags_change | NLM_F_CREATE
|
|
rdobuilder |
949e4f |
|
|
rdobuilder |
949e4f |
commands = {'add': (RTM_NEWQDISC, flags_make),
|
|
rdobuilder |
949e4f |
- 'del': (RTM_DELQDISC, flags_make),
|
|
rdobuilder |
949e4f |
- 'remove': (RTM_DELQDISC, flags_make),
|
|
rdobuilder |
949e4f |
- 'delete': (RTM_DELQDISC, flags_make),
|
|
rdobuilder |
949e4f |
+ 'del': (RTM_DELQDISC, flags_base),
|
|
rdobuilder |
949e4f |
+ 'remove': (RTM_DELQDISC, flags_base),
|
|
rdobuilder |
949e4f |
+ 'delete': (RTM_DELQDISC, flags_base),
|
|
rdobuilder |
949e4f |
'change': (RTM_NEWQDISC, flags_change),
|
|
rdobuilder |
949e4f |
'replace': (RTM_NEWQDISC, flags_replace),
|
|
rdobuilder |
949e4f |
'add-class': (RTM_NEWTCLASS, flags_make),
|
|
rdobuilder |
949e4f |
- 'del-class': (RTM_DELTCLASS, flags_make),
|
|
rdobuilder |
949e4f |
+ 'del-class': (RTM_DELTCLASS, flags_base),
|
|
rdobuilder |
949e4f |
'change-class': (RTM_NEWTCLASS, flags_change),
|
|
rdobuilder |
949e4f |
'replace-class': (RTM_NEWTCLASS, flags_replace),
|
|
rdobuilder |
949e4f |
'add-filter': (RTM_NEWTFILTER, flags_make),
|
|
rdobuilder |
949e4f |
- 'del-filter': (RTM_DELTFILTER, flags_make),
|
|
rdobuilder |
949e4f |
+ 'del-filter': (RTM_DELTFILTER, flags_base),
|
|
rdobuilder |
949e4f |
'change-filter': (RTM_NEWTFILTER, flags_change),
|
|
rdobuilder |
949e4f |
'replace-filter': (RTM_NEWTFILTER, flags_replace)}
|
|
rdobuilder |
949e4f |
if isinstance(command, int):
|
|
rdobuilder |
949e4f |
@@ -1984,9 +1984,9 @@ class RTNL_API(object):
|
|
rdobuilder |
949e4f |
'replace': (RTM_NEWROUTE, flags_replace),
|
|
rdobuilder |
949e4f |
'change': (RTM_NEWROUTE, flags_change),
|
|
rdobuilder |
949e4f |
'append': (RTM_NEWROUTE, flags_append),
|
|
rdobuilder |
949e4f |
- 'del': (RTM_DELROUTE, flags_make),
|
|
rdobuilder |
949e4f |
- 'remove': (RTM_DELROUTE, flags_make),
|
|
rdobuilder |
949e4f |
- 'delete': (RTM_DELROUTE, flags_make),
|
|
rdobuilder |
949e4f |
+ 'del': (RTM_DELROUTE, flags_base),
|
|
rdobuilder |
949e4f |
+ 'remove': (RTM_DELROUTE, flags_base),
|
|
rdobuilder |
949e4f |
+ 'delete': (RTM_DELROUTE, flags_base),
|
|
rdobuilder |
949e4f |
'get': (RTM_GETROUTE, NLM_F_REQUEST),
|
|
rdobuilder |
949e4f |
'show': (RTM_GETROUTE, flags_dump),
|
|
rdobuilder |
949e4f |
'dump': (RTM_GETROUTE, flags_dump)}
|
|
rdobuilder |
949e4f |
@@ -2126,9 +2126,9 @@ class RTNL_API(object):
|
|
rdobuilder |
949e4f |
flags_dump = NLM_F_REQUEST | NLM_F_ROOT | NLM_F_ATOMIC
|
|
rdobuilder |
949e4f |
|
|
rdobuilder |
949e4f |
commands = {'add': (RTM_NEWRULE, flags_make),
|
|
rdobuilder |
949e4f |
- 'del': (RTM_DELRULE, flags_make),
|
|
rdobuilder |
949e4f |
- 'remove': (RTM_DELRULE, flags_make),
|
|
rdobuilder |
949e4f |
- 'delete': (RTM_DELRULE, flags_make),
|
|
rdobuilder |
949e4f |
+ 'del': (RTM_DELRULE, flags_base),
|
|
rdobuilder |
949e4f |
+ 'remove': (RTM_DELRULE, flags_base),
|
|
rdobuilder |
949e4f |
+ 'delete': (RTM_DELRULE, flags_base),
|
|
rdobuilder |
949e4f |
'dump': (RTM_GETRULE, flags_dump)}
|
|
rdobuilder |
949e4f |
if isinstance(command, int):
|
|
rdobuilder |
949e4f |
command = (command, flags_make)
|
|
rdobuilder |
949e4f |
--
|
|
rdobuilder |
949e4f |
2.40.0
|