-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Checks that address learned by the host and target match and were also learned by the correct network interface too. Signed-off-by: Florian Fainelli <[email protected]>
- Loading branch information
Showing
1 changed file
with
53 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
|
||
import unittest | ||
|
||
from dsatest.bench import bench | ||
|
||
class TestArp(unittest.TestCase): | ||
|
||
|
||
def setUp(self): | ||
links = bench.links | ||
if len(links) == 0: | ||
self.skipTest("Empty link list") | ||
|
||
for i, l in enumerate(links, start=1): | ||
l.host_if.flushAddresses() | ||
l.target_if.flushAddresses() | ||
|
||
def tearDown(self): | ||
pass | ||
|
||
def test_port_arp(self): | ||
links = bench.links | ||
|
||
for i, l in enumerate(links, start=1): | ||
host_addr = "192.168.10.{}/24".format(str(i * 2)) | ||
target_addr = "192.168.10.{}/24".format(str(i * 2 + 1)) | ||
|
||
l.host_if.addAddress(host_addr) | ||
l.target_if.addAddress(target_addr) | ||
|
||
host_addr = "192.168.10.{}".format(str(i * 2)) | ||
target_addr = "192.168.10.{}".format(str(i * 2 + 1)) | ||
|
||
l.host_if.ping(target_addr, count=1, deadline=10) | ||
|
||
""" | ||
Ask the host about the target IP address | ||
""" | ||
reply = l.host_if.arp.get(target_addr)[0] | ||
if reply.interface != l.host_if.name: | ||
raise ValueError("Interface mismatch. Got {}, expected {}". | ||
format(reply.interface, l.host_if.name)) | ||
""" | ||
Ask the target about the host IP address | ||
""" | ||
reply = l.target_if.arp.get(host_addr)[0] | ||
|
||
if reply.interface != l.target_if.name: | ||
raise ValueError("Interface mismatch. Got {}, expected {}". | ||
format(reply.interface, l.target_if.name)) | ||
|
||
l.host_if.flushAddresses() | ||
l.target_if.flushAddresses() |