BPF filter support

Fix https://github.com/GNS3/gns3-gui/issues/765
This commit is contained in:
Julien Duponchelle committed 2017-07-11 17:30:29 +02:00
1 parent 8eb060304a
commit 8a8de1e2df
5 files changed
+67 -18

No files matched your search

+13 -1
View File
@@ -139,9 +139,21 @@ def test_update_ubridge_udp_connection(node, async_run):
def test_ubridge_apply_filters(node, async_run):
filters = {
"latency": [10]
"latency": [10],
"bpf": ["icmp[icmptype] == 8\ntcp src port 53"]
}
node._ubridge_send = AsyncioMagicMock()
async_run(node._ubridge_apply_filters("VPCS-10", filters))
node._ubridge_send.assert_any_call("bridge reset_packet_filters VPCS-10")
node._ubridge_send.assert_any_call("bridge add_packet_filter VPCS-10 filter0 latency 10")
def test_ubridge_apply_bpf_filters(node, async_run):
filters = {
"bpf": ["icmp[icmptype] == 8\ntcp src port 53"]
}
node._ubridge_send = AsyncioMagicMock()
async_run(node._ubridge_apply_filters("VPCS-10", filters))
node._ubridge_send.assert_any_call("bridge reset_packet_filters VPCS-10")
node._ubridge_send.assert_any_call("bridge add_packet_filter VPCS-10 filter0 bpf \"icmp[icmptype] == 8\"")
node._ubridge_send.assert_any_call("bridge add_packet_filter VPCS-10 filter1 bpf \"tcp src port 53\"")
+4 -3
View File
@@ -369,9 +369,10 @@ def test_update_filters(async_run, project, compute):
link.update = AsyncioMagicMock()
assert link._created
async_run(link.update_filters({
"packet_loss": ["10"],
"delay": ["50", "10"],
"frequency_drop": ["0"]
"packet_loss": [10],
"delay": [50, 10],
"frequency_drop": [0],
"bpf": [" \n "]
}))
assert link.filters == {
"packet_loss": [10],
+5 -2
View File
@@ -373,11 +373,14 @@ def test_update(async_run, project):
}, timeout=120)
assert link.created
async_run(link.update_filters({"drop": [5]}))
async_run(link.update_filters({"drop": [5], "bpf": ["icmp[icmptype] == 8"]}))
compute1.put.assert_any_call("/projects/{}/vpcs/nodes/{}/adapters/0/ports/4/nio".format(project.id, node1.id), data={
"lport": 1024,
"rhost": "192.168.1.2",
"rport": 2048,
"type": "nio_udp",
"filters": {"drop": [5]}
"filters": {
"drop": [5],
"bpf": ["icmp[icmptype] == 8"]
}
}, timeout=120)