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

Evpn refactor #6883

Merged
merged 20 commits into from
Aug 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
578c52e
tests: add EVPN IP learning tests
pjdruddy Apr 17, 2020
2d706c4
tests: remove ifindex from VNI JSON comparison
pjdruddy Jun 2, 2020
87d76d5
zebra: rename vni to evpn where appropriate
pjdruddy Jul 23, 2020
24268cd
zebra: clone zebra_vxlan.c to zebra_evpn_mac.c
pjdruddy Apr 21, 2020
b299808
zebra: extract evpn mac functions from zebra_vxlan.c
pjdruddy Jul 23, 2020
19fdd1b
zebra: split out mac_add code from process_remote_macip_add
pjdruddy Apr 22, 2020
d9d3455
zebra: extract local mac add code from vxlan
pjdruddy Jul 23, 2020
ad6ca5f
zebra: extract local mac del from zebra_vxlan.c
pjdruddy Apr 22, 2020
7bce353
zebra: extract gateway mac add from zebra_vxlan.c
pjdruddy Apr 22, 2020
6336e12
zebra: clone zebra_vxlan.c to zebra_evpn_neigh.c
pjdruddy Apr 23, 2020
7cbae20
zebra: extract neighbor functions from zebra_vxlan.c
pjdruddy Jul 23, 2020
036daac
zebra: extract neigbor processing from remote_macip_add
pjdruddy Apr 24, 2020
224315f
zebra: extract neigbor processing from zevpn_gw_macip_add
pjdruddy Apr 24, 2020
32fe7df
zebra: extract neighbor processing from process_remote_macip_del
pjdruddy Apr 24, 2020
33064a6
zebra: extract neighbor processing from kernel_neigh_del
pjdruddy Apr 24, 2020
6006414
zebra: clone zebra_vxlan.c to zebra_evpn.c
pjdruddy Apr 27, 2020
8b5fdf2
zebra: extract core EVPN functions from zebra_vxlan.c
pjdruddy Aug 10, 2020
1718bc7
zebra: fix SA NULL ptr access warning in evpn_mh
AnuradhaKaruppiah Aug 11, 2020
707b76d
zebra: Revert "zebra: probe local inactive neigh"
chiragshah6 Aug 7, 2020
2bdd446
zebra: clean up SA warning in EVPN code
pjdruddy Aug 12, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions tests/topotests/bgp-evpn-vxlan_topo1/PE1/evpn.vni.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
"type":"L2",
"vrf":"default",
"vxlanInterface":"vxlan101",
"ifindex":5,
"vtepIp":"10.10.10.10",
"mcastGroup":"0.0.0.0",
"advertiseGatewayMacip":"No",
"numMacs":5,
"numArpNd":2,
"numArpNd":3,
"numRemoteVteps":[
"10.30.30.30"
]
Expand Down
2 changes: 0 additions & 2 deletions tests/topotests/bgp-evpn-vxlan_topo1/PE1/zebra.conf
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ log file zebra.log
!
interface lo
ip address 10.10.10.10/32
interface PE1-eth0
ip address 10.10.1.1/24
interface PE1-eth1
ip address 10.20.1.1/24
!
3 changes: 1 addition & 2 deletions tests/topotests/bgp-evpn-vxlan_topo1/PE2/evpn.vni.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
"type":"L2",
"vrf":"default",
"vxlanInterface":"vxlan101",
"ifindex":5,
"vtepIp":"10.30.30.30",
"mcastGroup":"0.0.0.0",
"advertiseGatewayMacip":"No",
"numMacs":5,
"numArpNd":2,
"numArpNd":3,
"numRemoteVteps":[
"10.10.10.10"
]
Expand Down
2 changes: 0 additions & 2 deletions tests/topotests/bgp-evpn-vxlan_topo1/PE2/zebra.conf
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,4 @@ interface lo
ip address 10.30.30.30/32
interface PE2-eth0
ip address 10.20.2.3/24
interface PE2-eth1
ip address 10.10.1.3/24
!
119 changes: 112 additions & 7 deletions tests/topotests/bgp-evpn-vxlan_topo1/test_bgp_evpn_vxlan.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import sys
import json
from functools import partial
from time import sleep
import pytest

# Save the Current Working Directory to find configuration files.
Expand Down Expand Up @@ -97,6 +98,7 @@ def setup_module(mod):

# set up PE bridges with the EVPN member interfaces facing the CE hosts
pe1.run("ip link add name br101 type bridge stp_state 0")
pe1.run("ip addr add 10.10.1.1/24 dev br101")
pe1.run("ip link set dev br101 up")
pe1.run(
"ip link add vxlan101 type vxlan id 101 dstport 4789 local 10.10.10.10 nolearning"
Expand All @@ -106,6 +108,7 @@ def setup_module(mod):
pe1.run("ip link set dev PE1-eth0 master br101")

pe2.run("ip link add name br101 type bridge stp_state 0")
pe2.run("ip addr add 10.10.1.3/24 dev br101")
pe2.run("ip link set dev br101 up")
pe2.run(
"ip link add vxlan101 type vxlan id 101 dstport 4789 local 10.30.30.30 nolearning"
Expand Down Expand Up @@ -142,6 +145,15 @@ def teardown_module(mod):
tgen.stop_topology()


def show_vni_json_elide_ifindex(pe, vni, expected):
output_json = pe.vtysh_cmd("show evpn vni {} json".format(vni), isjson=True)

if "ifindex" in output_json:
output_json.pop("ifindex")

return topotest.json_cmp(output_json, expected)


def test_pe1_converge_evpn():
"Wait for protocol convergence"

Expand All @@ -154,9 +166,7 @@ def test_pe1_converge_evpn():
json_file = "{}/{}/evpn.vni.json".format(CWD, pe1.name)
expected = json.loads(open(json_file).read())

test_func = partial(
topotest.router_json_cmp, pe1, "show evpn vni 101 json", expected
)
test_func = partial(show_vni_json_elide_ifindex, pe1, 101, expected)
_, result = topotest.run_and_expect(test_func, None, count=125, wait=1)
assertmsg = '"{}" JSON output mismatches'.format(pe1.name)
assert result is None, assertmsg
Expand All @@ -175,9 +185,7 @@ def test_pe2_converge_evpn():
json_file = "{}/{}/evpn.vni.json".format(CWD, pe2.name)
expected = json.loads(open(json_file).read())

test_func = partial(
topotest.router_json_cmp, pe2, "show evpn vni 101 json", expected
)
test_func = partial(show_vni_json_elide_ifindex, pe2, 101, expected)
_, result = topotest.run_and_expect(test_func, None, count=125, wait=1)
assertmsg = '"{}" JSON output mismatches'.format(pe2.name)
assert result is None, assertmsg
Expand All @@ -194,7 +202,7 @@ def mac_learn_test(host, local):
mac_output = local.vtysh_cmd("show evpn mac vni 101 mac {} json".format(mac))
mac_output_json = json.loads(mac_output)
assertmsg = "Local MAC output does not match interface mac {}".format(mac)
assert mac_output_json[mac]["type"] == "local"
assert mac_output_json[mac]["type"] == "local", assertmsg


def mac_test_local_remote(local, remote):
Expand Down Expand Up @@ -275,6 +283,103 @@ def test_local_remote_mac_pe2():
# Memory leak test template


def ip_learn_test(tgen, host, local, remote, ip_addr):
"check the host IP gets learned by the VNI"
host_output = host.vtysh_cmd("show interface {}-eth0".format(host.name))
int_lines = host_output.splitlines()
mac_line = int_lines[7].split(": ")
mac = mac_line[1]
print(host_output)

# check we have a local association between the MAC and IP
local_output = local.vtysh_cmd("show evpn mac vni 101 mac {} json".format(mac))
print(local_output)
local_output_json = json.loads(local_output)
mac_type = local_output_json[mac]["type"]
assertmsg = "Failed to learn local IP address on host {}".format(host.name)
assert local_output_json[mac]["neighbors"] != "none", assertmsg
learned_ip = local_output_json[mac]["neighbors"]["active"][0]

assertmsg = "local learned mac wrong type: {} ".format(mac_type)
assert mac_type == "local", assertmsg

assertmsg = "learned address mismatch with configured address host: {} learned: {}".format(
ip_addr, learned_ip
)
assert ip_addr == learned_ip, assertmsg

# now lets check the remote
count = 0
converged = False
while count < 30:
remote_output = remote.vtysh_cmd(
"show evpn mac vni 101 mac {} json".format(mac)
)
print(remote_output)
remote_output_json = json.loads(remote_output)
type = remote_output_json[mac]["type"]
if not remote_output_json[mac]["neighbors"] == "none":
# due to a kernel quirk, learned IPs can be inactive
if (
remote_output_json[mac]["neighbors"]["active"]
or remote_output_json[mac]["neighbors"]["inactive"]
):
converged = True
break
count += 1
sleep(1)

print("tries: {}".format(count))
assertmsg = "{} remote learned mac no address: {} ".format(host.name, mac)
# some debug for this failure
if not converged == True:
log_output = remote.run("cat zebra.log")
print(log_output)

assert converged == True, assertmsg
if remote_output_json[mac]["neighbors"]["active"]:
learned_ip = remote_output_json[mac]["neighbors"]["active"][0]
else:
learned_ip = remote_output_json[mac]["neighbors"]["inactive"][0]
assertmsg = "remote learned mac wrong type: {} ".format(type)
assert type == "remote", assertmsg

assertmsg = "remote learned address mismatch with configured address host: {} learned: {}".format(
ip_addr, learned_ip
)
assert ip_addr == learned_ip, assertmsg


def test_ip_pe1_learn():
"run the IP learn test for PE1"

tgen = get_topogen()
host1 = tgen.gears["host1"]
pe1 = tgen.gears["PE1"]
pe2 = tgen.gears["PE2"]
pe2.vtysh_cmd("debug zebra vxlan")
pe2.vtysh_cmd("debug zebra kernel")
# lets populate that arp cache
host1.run("ping -c1 10.10.1.1")
ip_learn_test(tgen, host1, pe1, pe2, "10.10.1.55")
# tgen.mininet_cli()


def test_ip_pe2_learn():
"run the IP learn test for PE2"

tgen = get_topogen()
host2 = tgen.gears["host2"]
pe1 = tgen.gears["PE1"]
pe2 = tgen.gears["PE2"]
pe1.vtysh_cmd("debug zebra vxlan")
pe1.vtysh_cmd("debug zebra kernel")
# lets populate that arp cache
host2.run("ping -c1 10.10.1.3")
ip_learn_test(tgen, host2, pe2, pe1, "10.10.1.56")
# tgen.mininet_cli()


def test_memory_leak():
"Run the memory leak test and report results."
tgen = get_topogen()
Expand Down
2 changes: 2 additions & 0 deletions zebra/dplane_fpm_nl.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
#include "zebra/interface.h"
#include "zebra/zebra_dplane.h"
#include "zebra/zebra_router.h"
#include "zebra/zebra_evpn.h"
#include "zebra/zebra_evpn_mac.h"
#include "zebra/zebra_vxlan_private.h"
#include "zebra/kernel_netlink.h"
#include "zebra/rt_netlink.h"
Expand Down
7 changes: 7 additions & 0 deletions zebra/subdir.am
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ zebra_zebra_SOURCES = \
zebra/zebra_errors.c \
zebra/zebra_gr.c \
zebra/zebra_l2.c \
zebra/zebra_evpn.c \
zebra/zebra_evpn_mac.c \
zebra/zebra_evpn_neigh.c \
zebra/zebra_mlag.c \
zebra/zebra_mlag_vty.c \
zebra/zebra_memory.c \
Expand Down Expand Up @@ -147,6 +150,10 @@ noinst_HEADERS += \
zebra/zapi_msg.h \
zebra/zebra_dplane.h \
zebra/zebra_errors.h \
zebra/zebra_evpn.h \
zebra/zebra_evpn_mac.h \
zebra/zebra_evpn_neigh.h \
zebra/zebra_evpn_vxlan.h \
zebra/zebra_fpm_private.h \
zebra/zebra_l2.h \
zebra/zebra_memory.h \
Expand Down
19 changes: 0 additions & 19 deletions zebra/zebra_dplane.c
Original file line number Diff line number Diff line change
Expand Up @@ -3138,25 +3138,6 @@ enum zebra_dplane_result dplane_local_neigh_add(const struct interface *ifp,
return result;
}

/*
* Enqueue evpn neighbor update for the dataplane.
*/
enum zebra_dplane_result dplane_rem_neigh_update(const struct interface *ifp,
const struct ipaddr *ip,
const struct ethaddr *mac)
{
enum zebra_dplane_result result;
uint32_t update_flags = 0;

update_flags |= DPLANE_NEIGH_REMOTE;

result = neigh_update_internal(DPLANE_OP_NEIGH_UPDATE,
ifp, mac, ip, 0, DPLANE_NUD_PROBE,
update_flags);

return result;
}

/*
* Enqueue evpn neighbor delete for the dataplane.
*/
Expand Down
3 changes: 0 additions & 3 deletions zebra/zebra_dplane.h
Original file line number Diff line number Diff line change
Expand Up @@ -556,9 +556,6 @@ enum zebra_dplane_result dplane_local_neigh_add(const struct interface *ifp,
const struct ethaddr *mac,
bool set_router, bool set_static,
bool set_inactive);
enum zebra_dplane_result dplane_rem_neigh_update(const struct interface *ifp,
const struct ipaddr *ip,
const struct ethaddr *mac);
enum zebra_dplane_result dplane_rem_neigh_delete(const struct interface *ifp,
const struct ipaddr *ip);

Expand Down
Loading