mirror of
https://github.com/GNS3/gns3-server
synced 2024-12-26 00:38:10 +00:00
Ignore invalid BPF filters. Ref #1290.
This commit is contained in:
parent
00e781826b
commit
0fde1cf54a
@ -25,6 +25,7 @@ import asyncio
|
|||||||
import tempfile
|
import tempfile
|
||||||
import psutil
|
import psutil
|
||||||
import platform
|
import platform
|
||||||
|
import re
|
||||||
|
|
||||||
from gns3server.utils.interfaces import interfaces
|
from gns3server.utils.interfaces import interfaces
|
||||||
from ..compute.port_manager import PortManager
|
from ..compute.port_manager import PortManager
|
||||||
@ -598,15 +599,24 @@ class BaseNode:
|
|||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
def _ubridge_apply_filters(self, bridge_name, filters):
|
def _ubridge_apply_filters(self, bridge_name, filters):
|
||||||
"""
|
"""
|
||||||
Apply filter like rate limiting
|
Apply packet filters
|
||||||
|
|
||||||
:param bridge_name: bridge name in uBridge
|
:param bridge_name: bridge name in uBridge
|
||||||
:param filters: Array of filter dictionnary
|
:param filters: Array of filter dictionary
|
||||||
"""
|
"""
|
||||||
yield from self._ubridge_send('bridge reset_packet_filters ' + bridge_name)
|
yield from self._ubridge_send('bridge reset_packet_filters ' + bridge_name)
|
||||||
for filter in self._build_filter_list(filters):
|
for packet_filter in self._build_filter_list(filters):
|
||||||
cmd = 'bridge add_packet_filter {} {}'.format(bridge_name, filter)
|
cmd = 'bridge add_packet_filter {} {}'.format(bridge_name, packet_filter)
|
||||||
yield from self._ubridge_send(cmd)
|
try:
|
||||||
|
yield from self._ubridge_send(cmd)
|
||||||
|
except UbridgeError as e:
|
||||||
|
match = re.search("Cannot compile filter '(.*)': syntax error", str(e))
|
||||||
|
if match:
|
||||||
|
message = "Warning: ignoring BPF packet filter '{}' due to syntax error".format(self.name, match.group(1))
|
||||||
|
log.warning(message)
|
||||||
|
self.project.emit("log.warning", {"message": message})
|
||||||
|
else:
|
||||||
|
raise
|
||||||
|
|
||||||
def _build_filter_list(self, filters):
|
def _build_filter_list(self, filters):
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user