Skip to content

Commit

Permalink
iproute: fix rule dump for the strict mode
Browse files Browse the repository at this point in the history
Bug-Url: #1224
  • Loading branch information
svinota committed Dec 23, 2024
1 parent 00e975f commit 1437e4a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pyroute2/iproute/linux.py
Original file line number Diff line number Diff line change
Expand Up @@ -2308,7 +2308,7 @@ async def rule(self, command, **kwarg):
'del': (RTM_DELRULE, 'req'),
'remove': (RTM_DELRULE, 'req'),
'delete': (RTM_DELRULE, 'req'),
'dump': (RTM_GETRULE, 'dump'),
'dump': (RTM_GETRULE, 'root'),
}
if isinstance(kwarg.get('match'), str):
kwarg['match'] = {'ifname': kwarg['match']}
Expand Down
3 changes: 3 additions & 0 deletions pyroute2/netlink/nlsocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,14 @@
NETLINK_LISTEN_ALL_NSID,
NLM_F_ACK,
NLM_F_APPEND,
NLM_F_ATOMIC,
NLM_F_CREATE,
NLM_F_DUMP,
NLM_F_ECHO,
NLM_F_EXCL,
NLM_F_REPLACE,
NLM_F_REQUEST,
NLM_F_ROOT,
SOL_NETLINK,
)
from pyroute2.netlink.core import (
Expand Down Expand Up @@ -419,6 +421,7 @@ class NetlinkRequest:
# request flags
flags = {
'dump': NLM_F_REQUEST | NLM_F_DUMP,
'root': NLM_F_REQUEST | NLM_F_ROOT | NLM_F_ATOMIC,
'get': NLM_F_REQUEST | NLM_F_ACK,
'req': NLM_F_REQUEST | NLM_F_ACK,
}
Expand Down
2 changes: 1 addition & 1 deletion pyroute2/requests/rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class RuleIPRouteFilter(IPRouteFilter):
def get_table(self, context, mode):
table = context.get('table', 0)
if mode == 'field':
return table if 0 < table < 255 else 254
return table if 0 <= table <= 255 else 252
return table

def set_action(self, context, value):
Expand Down

0 comments on commit 1437e4a

Please sign in to comment.