Skip to content

Commit

Permalink
fix(evpn): fix unit test and ci
Browse files Browse the repository at this point in the history
Signed-off-by: atulpatel261194 <[email protected]>
  • Loading branch information
atulpatel261194 committed May 16, 2024
1 parent 2cecba0 commit ea1662f
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 7 deletions.
8 changes: 8 additions & 0 deletions pkg/bridge/bridge_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,14 @@ func Test_CreateLogicalBridge(t *testing.T) {
out: &pb.LogicalBridge{
Spec: &pb.LogicalBridgeSpec{
VlanId: 11,
VtepIpPrefix: &pc.IPPrefix{
Addr: &pc.IPAddress{
Af: pc.IpAf_IP_AF_INET,
V4OrV6: &pc.IPAddress_V4Addr{
V4Addr: 0,
},
},
},
},
Status: &pb.LogicalBridgeStatus{
OperStatus: pb.LBOperStatus_LB_OPER_STATUS_DOWN,
Expand Down
4 changes: 2 additions & 2 deletions pkg/netlink/netlink_watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -892,11 +892,11 @@ func neighborAnnotate(neighbor NeighStruct) NeighStruct {
}
}
if LB.Spec.Vni != nil {
vid, err := strconv.ParseInt(vID, 10, 64)
vid, err := strconv.Atoi(vID)
if err != nil {
panic(err)
}
fdbEntry := LatestFDB[FDBKey{int(vid), neighbor.Neigh0.HardwareAddr.String()}]
fdbEntry := LatestFDB[FDBKey{vid, neighbor.Neigh0.HardwareAddr.String()}]
neighbor.Metadata["l2_nh"] = fdbEntry.Nexthop
neighbor.Type = VXLAN // confirm this later
}
Expand Down
9 changes: 6 additions & 3 deletions pkg/utils/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
package utils

import (
"context"
"log"
"net"
"regexp"

"context"
"github.com/vishvananda/netlink"
"go.einride.tech/aip/fieldmask"
"google.golang.org/protobuf/proto"
Expand All @@ -34,15 +35,17 @@ func ValidateMacAddress(b []byte) error {

// GetIPAddress gets the ip address from link
func GetIPAddress(dev string) net.IPNet {
link, err := netlink.LinkByName(dev)
nlink := NewNetlinkWrapper()
ctx := context.Background()
link, err := nlink.LinkByName(ctx, dev)
if err != nil {
log.Printf("Error in LinkByName %+v\n", err)
return net.IPNet{
IP: net.ParseIP("0.0.0.0"),
}
}

addrs, err := netlink.AddrList(link, netlink.FAMILY_V4) // ip address show
addrs, err := nlink.AddrList(ctx, link, netlink.FAMILY_V4) // ip address show
if err != nil {
log.Printf("Error in AddrList\n")
return net.IPNet{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1369,7 +1369,7 @@ func (l L3Decoder) StaticAdditions() []interface{} {
},
)
for _, port := range l._grpcPorts {
var peerVsi, err = strconv.ParseInt(port.peer["vsi"], 10, 64)
var peerVsi, err = strconv.Atoi(port.peer["vsi"])
if err != nil {
panic(err)
}
Expand All @@ -1386,7 +1386,7 @@ func (l L3Decoder) StaticAdditions() []interface{} {
},
Action: p4client.Action{
ActionName: "linux_networking_control.fwd_to_port",
Params: []interface{}{uint32(_toEgressVsi(int(peerVsi)))},
Params: []interface{}{uint32(_toEgressVsi(peerVsi))},
},
},
p4client.TableEntry{
Expand Down
8 changes: 8 additions & 0 deletions pkg/vrf/vrf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,14 @@ func Test_CreateVrf(t *testing.T) {
},
Len: 24,
},
VtepIpPrefix: &pc.IPPrefix{
Addr: &pc.IPAddress{
Af: pc.IpAf_IP_AF_INET,
V4OrV6: &pc.IPAddress_V4Addr{
V4Addr: 0,
},
},
},
},
Status: &pb.VrfStatus{
OperStatus: pb.VRFOperStatus_VRF_OPER_STATUS_DOWN,
Expand Down

0 comments on commit ea1662f

Please sign in to comment.