Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[neighbour-mac-noptf] Fix issue 2414 by always using static arp/neighbour entry #1026

Merged
merged 9 commits into from
Aug 1, 2019
76 changes: 28 additions & 48 deletions ansible/roles/test/tasks/neighbour-mac-noptf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,35 +31,31 @@
- name: init loganalyzer for later syslog analysis
include: roles/test/files/tools/loganalyzer/loganalyzer_init.yml

- name: gather DUT arp table
switch_arptable:

########## Test V4 mac address change #################
- name: pick IPv4 neighbor to test change mac behavior
- name: select Ethernet0 for testing on t1 and t0
set_fact:
v4_nei: "{{ item.key }}"
v4_intf: "{{ item.value['interface'] }}"
with_dict: "{{ arptable.v4 }}"
when:
- ('Ethernet' in item.value['interface']) or ('PortChannel' in item.value['interface'])
- arptable.v4 | length != 0
routing_interface: "Ethernet0"
when: testbed_type in ['t1', 't0']

- block:
- name: select Ethernet0 if cannot find a v4 neighbor for test
set_fact:
v4_intf: "Ethernet0"
v4_nei: "{{ v4_intf_nei }}"
- name: Startup {{routing_interface}} for t0
command: "config interface startup {{routing_interface}}"
when: testbed_type in ['t0']

- name: startup Ethernet0
command: "config interface startup Ethernet0"
- name: select PortChannel0002 for testing on t1-lag
set_fact:
routing_interface: "PortChannel0002"
when: testbed_type in ['t1-lag']

- name: add an ip entry for Ethernet0
command: "config interface ip add Ethernet0 {{ v4_intf_ip }}"
########## Test V4 mac address change #################
- name: pick {{routing_interface}} to test change mac behavior
set_fact:
v4_intf: "{{routing_interface}}"
v4_nei: "{{ v4_intf_nei }}"

- name: add neighbor of Ethernet0
command: "/sbin/ip neigh add {{ v4_intf_nei }} lladdr {{ v4_mac1 }} dev Ethernet0"
- name: add an ip entry for {{v4_intf}}
command: "config interface ip add {{ v4_intf }} {{ v4_intf_ip }}"

when: v4_nei is not defined
- name: add neighbor for {{v4_intf}}
command: "/sbin/ip neigh add {{ v4_intf_nei }} lladdr {{ v4_mac1 }} dev {{ v4_intf }}"

- name: change v4 neighbor mac address 1st time
command: "ip neigh change {{ v4_nei }} lladdr {{ v4_mac1 }} dev {{ v4_intf }}"
Expand Down Expand Up @@ -94,32 +90,16 @@
- assert: { that: "neighbour_mac.stdout | lower == v4_mac2" }

############## Test V6 mac change ##################
- name: pick IPv6 neighbor to test change mac address"
- name: pick {{routing_interface}} as test interface
set_fact:
v6_nei: "{{ item.key }}"
v6_intf: "{{ item.value['interface'] }}"
with_dict: "{{ arptable.v6 }}"
when:
- "'fe80::' not in item.key | lower"
- ('Ethernet' in item.value['interface']) or ('PortChannel' in item.value['interface'])
- arptable.v6 | length != 0

- block:
- name: pick Ethernet0 as test interface if cannot find v6 neighbor to test
set_fact:
v6_intf: "Ethernet0"
v6_nei: "{{ v6_intf_nei }}"

- name: startup Ethernet0
command: "config interface startup Ethernet0"

- name: add an ipv6 entry for Ethernet0 if no v6 neighbor was found
command: "config interface ip add Ethernet0 {{ v6_intf_ip }}"

- name: add an ipv6 neighbor for Ethernet0 if no v6 neighbor was found
command: "/sbin/ip neigh add {{ v6_intf_nei }} lladdr {{ v6_mac1 }} dev Ethernet0"

when: v6_nei is not defined
v6_intf: "{{routing_interface}}"
v6_nei: "{{ v6_intf_nei }}"

- name: add an ipv6 entry for {{v6_intf}}
command: "config interface ip add {{v6_intf}} {{ v6_intf_ip }}"

- name: add an ipv6 neighbor for {{v6_intf}}
command: "/sbin/ip neigh add {{ v6_intf_nei }} lladdr {{ v6_mac1 }} dev {{v6_intf}}"

- name: change v6 neighbor mac address 1st time
command: "ip -6 neigh change {{ v6_nei }} lladdr {{ v6_mac1 }} dev {{ v6_intf }}"
Expand Down