Commit bcc91cac authored by Italo Cunha's avatar Italo Cunha Committed by Peter V. Saveliev

ipdb: let users choose RTNL groups IPDB listens to

IPDB listens to all netlink updates by default.  Some applications
might not require information about all netlink-managed entities.
Filtering the messages that the kernel sends IPDB alleviates CPU use
and might prevent buffer overflow errors that happen during netlink
broadcast storms.

parent fc2c8149
......@@ -531,7 +531,7 @@ import threading
from pyroute2 import config
from pyroute2.common import uuid32
from pyroute2.iproute import IPRoute
from pyroute2.netlink.rtnl import RTM_GETLINK
from pyroute2.netlink.rtnl import RTM_GETLINK, RTNL_GROUPS
from pyroute2.netlink.rtnl.ifinfmsg import ifinfmsg
from pyroute2.ipdb import rule
from pyroute2.ipdb import route
......@@ -581,6 +581,7 @@ class IPDB(object):
def __init__(self, nl=None, mode='implicit',
restart_on_error=None, nl_async=None,
ignore_rtables=None, callbacks=None,
self.mode = mode
......@@ -593,6 +594,7 @@ class IPDB(object):
self._nl_async = config.ipdb_nl_async if nl_async is None else True
self.mnl = None = nl
self.nl_bind_groups = nl_bind_groups
self._plugins = [interface, route, rule]
if isinstance(ignore_rtables, int):
self._ignore_rtables = [ignore_rtables, ]
......@@ -659,7 +661,7 @@ class IPDB(object):
# setup monitoring socket
self.mnl =
self.mnl.bind(groups=self.nl_bind_groups, async=self._nl_async)
if self._nl_own is None:
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment