node-uplink links answers each link's mac, master and parent (S1a links-mac, issue 1965)
mesh/delivery merged: source.main moved to novox/mesh-catalog@0ec8347786f4
mesh/check checking 700b37890bfd on 0ec8347786f4
mesh/delivery merged: source.main moved to novox/mesh-catalog@0ec8347786f4
mesh/check checking 700b37890bfd on 0ec8347786f4
Both holders' uplink-tools copies read address, master, link and
link_index/link_netnsid from the existing ip -j address show call. Fields
are left out where a link has none (L3); a parent in another namespace is
{index, namespace} (L2); the form lives in uplink.go only (L4); only the
tool description changes, not seat.json (L5); bridge fdb MACs are not
answered (L6); names mac, master, parent (L1).
Builds: design 48 10, design 08 code:, issue 1965 note 11 L1-L6
This commit is contained in:
@@ -103,8 +103,10 @@ func TestTheLinksCarryTheirDefaultRouteAndTheirNames(t *testing.T) {
|
||||
joined := strings.Join(args, " ")
|
||||
switch {
|
||||
case joined == "-j address show":
|
||||
return `[{"ifname":"lo","operstate":"UNKNOWN","link_type":"loopback","addr_info":[{"local":"127.0.0.1","prefixlen":8}]},
|
||||
{"ifname":"wlan0","operstate":"UP","link_type":"ether","addr_info":[{"local":"192.168.1.20","prefixlen":24}]},
|
||||
return `[{"ifname":"lo","operstate":"UNKNOWN","link_type":"loopback","address":"00:00:00:00:00:00","addr_info":[{"local":"127.0.0.1","prefixlen":8}]},
|
||||
{"ifname":"wlan0","operstate":"UP","link_type":"ether","address":"aa:bb:cc:00:00:01","addr_info":[{"local":"192.168.1.20","prefixlen":24}]},
|
||||
{"ifname":"veth1","operstate":"UP","link_type":"ether","address":"aa:bb:cc:00:00:02","master":"br-1","link":"veth2","addr_info":[]},
|
||||
{"ifname":"veth3","operstate":"UP","link_type":"ether","address":"aa:bb:cc:00:00:03","master":"br-1","link_index":7,"link_netnsid":2,"addr_info":[]},
|
||||
{"ifname":"vpn0","operstate":"UNKNOWN","link_type":"none","addr_info":[{"local":"172.16.9.9","prefixlen":32}]}]`, nil
|
||||
case joined == "-j -4 route show default":
|
||||
return `[{"dst":"default","dev":"wlan0","metric":600}]`, nil
|
||||
@@ -122,10 +124,20 @@ func TestTheLinksCarryTheirDefaultRouteAndTheirNames(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
links := answer["links"].([]Link)
|
||||
if len(links) != 3 || links[0].Name != "wlan0" || !links[0].Default || *links[0].Metric != 600 ||
|
||||
if len(links) != 5 || links[0].Name != "wlan0" || !links[0].Default || *links[0].Metric != 600 ||
|
||||
links[0].DNS == nil || links[0].DNS.Servers[0] != "192.168.1.1" {
|
||||
t.Fatalf("the links are %+v", links)
|
||||
}
|
||||
byName := map[string]Link{}
|
||||
for _, l := range links {
|
||||
byName[l.Name] = l
|
||||
}
|
||||
if byName["wlan0"].MAC != "aa:bb:cc:00:00:01" || byName["lo"].MAC != "00:00:00:00:00:00" ||
|
||||
byName["veth1"].Master != "br-1" || byName["veth1"].Parent != "veth2" ||
|
||||
byName["veth3"].Parent != (ParentPeer{Index: 7, Namespace: 2}) ||
|
||||
byName["vpn0"].MAC != "" || byName["vpn0"].Master != "" || byName["vpn0"].Parent != nil {
|
||||
t.Fatalf("mac, master and parent are %+v", byName)
|
||||
}
|
||||
for _, l := range links[1:] {
|
||||
if l.Default || (l.Name == "vpn0" && l.DNS != nil) {
|
||||
t.Fatalf("%+v", l)
|
||||
|
||||
Reference in New Issue
Block a user