Skip to content

Commit

Permalink
fix: removed logrus from vendor plugin and mod dependency
Browse files Browse the repository at this point in the history
Signed-off-by: atulpatel261194 <Atul.Patel@intel.com>
  • Loading branch information
atulpatel261194 authored and artek-koltun committed Sep 4, 2024
1 parent 3c94d46 commit d138860
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 156 deletions.
15 changes: 1 addition & 14 deletions cmd/evpn/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
// Copyright (C) 2023 Nordix Foundation.

// Package main is the main package of the application
//
//nolint:all
package main

Expand Down Expand Up @@ -40,7 +41,6 @@ import (

"github.com/grpc-ecosystem/go-grpc-middleware/v2/interceptors/logging"
"github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
ci_linux "github.com/opiproject/opi-evpn-bridge/pkg/LinuxCIModule"
gen_linux "github.com/opiproject/opi-evpn-bridge/pkg/LinuxGeneralModule"
frr "github.com/opiproject/opi-evpn-bridge/pkg/frr"
netlink "github.com/opiproject/opi-evpn-bridge/pkg/netlink"
Expand Down Expand Up @@ -75,11 +75,6 @@ var rootCmd = &cobra.Command{
intel_e2000_linux.Initialize()
frr.Initialize()
ipu_vendor.Initialize()

case "ci":
gen_linux.Initialize()
ci_linux.Initialize()
frr.Initialize()
default:
log.Panic(" ERROR: Could not find Build env ")
}
Expand Down Expand Up @@ -148,10 +143,6 @@ func cleanUp() {
ipu_vendor.DeInitialize()
close(p4driverapi.StopCh)

case "ci":
gen_linux.DeInitialize()
ci_linux.DeInitialize()
frr.DeInitialize()
default:
log.Panic(" ERROR: Could not find Build env ")
}
Expand All @@ -168,7 +159,6 @@ func main() {

// initialize cobra config
if err := initialize(); err != nil {
// log.Println(err)
log.Panicf("Error in initialize(): %v", err)
}

Expand All @@ -190,9 +180,6 @@ func main() {
default:
fmt.Println("Received unknown signal.")
}
// Perform any cleanup tasks here.
// ...

// Exit the program.
os.Exit(0)
}()
Expand Down
6 changes: 2 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ require (
github.com/onsi/ginkgo/v2 v2.14.0
github.com/opiproject/gospdk v0.0.0-20240415072512-98d71122a73b
github.com/opiproject/opi-api v0.0.0-20240415072823-bb755a5f6ecc
github.com/opiproject/opi-evpn-bridge v0.2.1-0.20240708154942-708f94826a3a
github.com/opiproject/opi-evpn-bridge v0.2.1-0.20240902142753-8f51de196b54
github.com/opiproject/opi-smbios-bridge v0.1.3-0.20240113044816-4401aa6a3d1a
github.com/opiproject/opi-spdk-bridge v0.1.2-0.20240417152307-a0f9ef0e5260
github.com/opiproject/opi-strongswan-bridge v0.1.2-0.20231211064623-e4ef0e4fa95f
Expand All @@ -19,7 +19,6 @@ require (
github.com/philippgille/gokv/gomap v0.6.0
github.com/philippgille/gokv/redis v0.6.0
github.com/roman-kachanovsky/go-binary-pack v0.0.0-20170214094030-e260e0dc6732
github.com/sirupsen/logrus v1.9.3
github.com/spf13/cobra v1.7.0
github.com/spf13/viper v1.16.0
github.com/vektra/mockery/v2 v2.38.0
Expand All @@ -30,8 +29,6 @@ require (
google.golang.org/protobuf v1.33.0
)

replace github.com/opiproject/opi-evpn-bridge v0.2.1-0.20240708154942-708f94826a3a => github.com/mardim91/opi-evpn-bridge v0.0.0-20240801134324-5b73532d930c

require (
4d63.com/gocheckcompilerdirectives v1.2.1 // indirect
4d63.com/gochecknoglobals v0.2.1 // indirect
Expand Down Expand Up @@ -180,6 +177,7 @@ require (
github.com/sashamelentyev/usestdlibvars v1.24.0 // indirect
github.com/securego/gosec/v2 v2.18.2 // indirect
github.com/shazow/go-diff v0.0.0-20160112020656-b6b7b6733b8c // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/sivchari/containedctx v1.0.3 // indirect
github.com/sivchari/nosnakecase v1.7.0 // indirect
github.com/sivchari/tenv v1.7.1 // indirect
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -406,8 +406,6 @@ github.com/maratori/testableexamples v1.0.0 h1:dU5alXRrD8WKSjOUnmJZuzdxWOEQ57+7s
github.com/maratori/testableexamples v1.0.0/go.mod h1:4rhjL1n20TUTT4vdh3RDqSizKLyXp7K2u6HgraZCGzE=
github.com/maratori/testpackage v1.1.1 h1:S58XVV5AD7HADMmD0fNnziNHqKvSdDuEKdPD1rNTU04=
github.com/maratori/testpackage v1.1.1/go.mod h1:s4gRK/ym6AMrqpOa/kEbQTV4Q4jb7WeLZzVhVVVOQMc=
github.com/mardim91/opi-evpn-bridge v0.0.0-20240801134324-5b73532d930c h1:n082jp285SAAAalI2e1Myb76aR37paZdvNEfSsbSgFw=
github.com/mardim91/opi-evpn-bridge v0.0.0-20240801134324-5b73532d930c/go.mod h1:Lnt6BnGJEKm/poq+/blpIoyF8Fq8blkKc4kAcNCKlZ8=
github.com/matoous/godox v0.0.0-20230222163458-006bad1f9d26 h1:gWg6ZQ4JhDfJPqlo2srm/LN17lpybq15AryXIRcWYLE=
github.com/matoous/godox v0.0.0-20230222163458-006bad1f9d26/go.mod h1:1BELzlh859Sh1c6+90blK8lbYy0kwQf1bYlBhBysy1s=
github.com/matryer/is v1.4.0 h1:sosSmIWwkYITGrxZ25ULNDeKiMNzFSr4V/eqBQP0PeE=
Expand Down Expand Up @@ -461,6 +459,8 @@ github.com/opiproject/gospdk v0.0.0-20240415072512-98d71122a73b h1:SlDLubL/Bo0eh
github.com/opiproject/gospdk v0.0.0-20240415072512-98d71122a73b/go.mod h1:9CMbTd9ptR6tl6HRRn8C33DPeWF85hTo4KZCa5iKftY=
github.com/opiproject/opi-api v0.0.0-20240415072823-bb755a5f6ecc h1:iBcdnHiFFCIKggBDOL5S2OUONKyu8m+x/zhJGxIT2UY=
github.com/opiproject/opi-api v0.0.0-20240415072823-bb755a5f6ecc/go.mod h1:92pv4ulvvPMuxCJ9ND3aYbmBfEMLx0VCjpkiR7ZTqPY=
github.com/opiproject/opi-evpn-bridge v0.2.1-0.20240902142753-8f51de196b54 h1:dBiCOF+XA5thXXULV5/UYma6CS3Q1VqvEF4OKsCmbrA=
github.com/opiproject/opi-evpn-bridge v0.2.1-0.20240902142753-8f51de196b54/go.mod h1:0SsCMInH7SAg4ML4aI/Ts8jt7iXyMmcqxBPUD3y4EgQ=
github.com/opiproject/opi-smbios-bridge v0.1.3-0.20240113044816-4401aa6a3d1a h1:JHNZJxcoWvrcoxyPRXLKEciaEZ5Dfsd6RQYd9km9MSM=
github.com/opiproject/opi-smbios-bridge v0.1.3-0.20240113044816-4401aa6a3d1a/go.mod h1:QhKBKdPcS25fDW89Rcsw9N1c07hdcj8OXsr2c+PgeIg=
github.com/opiproject/opi-spdk-bridge v0.1.2-0.20240417152307-a0f9ef0e5260 h1:bUzUhKxcC8k6MaApN2XSeYB6frZ0uubPcZjPvLBRG1E=
Expand Down
49 changes: 9 additions & 40 deletions pkg/evpn/vendor_plugins/intel-e2000/p4runtime/p4driverapi/p4ctl.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// Copyright (C) 2023 Nordix Foundation.

// Package p4driverapi handles p4 driver realted functionality
//
//nolint:all
package p4driverapi

Expand All @@ -11,15 +12,12 @@ import (
"context"
"encoding/binary"

// "encoding/hex"
"fmt"
"net"

// "strings"
"log"
"time"

logr "github.com/sirupsen/logrus"
"google.golang.org/grpc"

p4_v1 "github.com/p4lang/p4runtime/go/p4/v1"
Expand Down Expand Up @@ -90,30 +88,24 @@ func Buildmfs(tablefield TableField) (map[string]client.MatchInterface, bool, er
case net.HardwareAddr:
mfs[key] = &client.ExactMatch{Value: value[0].(net.HardwareAddr)}
case uint16:
// if value[1].(string) == lpmStr {
switch value[1].(string) {
case lpmStr:
mfs[key] = &client.LpmMatch{Value: uint16toBytes(value[0].(uint16)), PLen: 31}
// } else if value[1].(string) == ternaryStr {
case ternaryStr:
isTernary = true
mfs[key] = &client.TernaryMatch{Value: uint16toBytes(value[0].(uint16)), Mask: uint32toBytes(4294967295)}
// } else {
default:
mfs[key] = &client.ExactMatch{Value: uint16toBytes(value[0].(uint16))}
}
case *net.IPNet:
maskSize, _ := v.Mask.Size()
ip := v.IP.To4()
// if value[1].(string) == lpmStr {
switch value[1].(string) {
case lpmStr:
mfs[key] = &client.LpmMatch{Value: v.IP.To4(), PLen: int32(maskSize)}
// } else if value[1].(string) == ternaryStr {
case ternaryStr:
isTernary = true
mfs[key] = &client.TernaryMatch{Value: []byte(ip), Mask: uint32toBytes(4294967295)}
// } else {
default:
mfs[key] = &client.ExactMatch{Value: []byte(ip)}
}
Expand All @@ -123,11 +115,9 @@ func Buildmfs(tablefield TableField) (map[string]client.MatchInterface, bool, er
case lpmStr:

mfs[key] = &client.LpmMatch{Value: value[0].(net.IP).To4(), PLen: 24}
// } else if value[1].(string) == ternaryStr {
case ternaryStr:
isTernary = true
mfs[key] = &client.TernaryMatch{Value: []byte(v), Mask: uint32toBytes(4294967295)}
// } else {
default:
mfs[key] = &client.ExactMatch{Value: []byte(v)}
}
Expand All @@ -138,11 +128,9 @@ func Buildmfs(tablefield TableField) (map[string]client.MatchInterface, bool, er
case lpmStr:

mfs[key] = &client.LpmMatch{Value: uint32toBytes(value[0].(uint32)), PLen: 31}
// } else if value[1].(string) == ternaryStr {
case ternaryStr:
isTernary = true
mfs[key] = &client.TernaryMatch{Value: uint32toBytes(value[0].(uint32)), Mask: uint32toBytes(4294967295)}
// } else {
default:
mfs[key] = &client.ExactMatch{Value: uint32toBytes(value[0].(uint32))}
}
Expand Down Expand Up @@ -179,15 +167,6 @@ func DelEntry(entry TableEntry) error {
return P4RtC.DeleteTableEntry(Ctx, entryP)
}

/*// mustMarshal marshal the msg
func mustMarshal(msg proto.Message) []byte {
data, err := proto.Marshal(msg)
if err != nil {
panic(err) // You should handle errors appropriately in your code
}
return data
}*/

// AddEntry adds an entry
func AddEntry(entry TableEntry) error {
Options := &client.TableEntryOptions{
Expand Down Expand Up @@ -237,16 +216,6 @@ func AddEntry(entry TableEntry) error {
return P4RtC.InsertTableEntry(Ctx, entryP)
}

/*
// encodeMac encodes the mac from string
func encodeMac(macAddrString string) []byte {
str := strings.Replace(macAddrString, ":", "", -1)
decoded, _ := hex.DecodeString(str)
return decoded
}
*/

// StopCh is used to when to stop the p4rtc when a terminate signal is generated
var StopCh = make(chan struct{})

Expand All @@ -256,10 +225,10 @@ func NewP4RuntimeClient(binPath string, p4infoPath string, conn *grpc.ClientConn
c := p4_v1.NewP4RuntimeClient(conn)
resp, err := c.Capabilities(Ctx, &p4_v1.CapabilitiesRequest{})
if err != nil {
logr.Fatalf("intel-e2000: Error in Capabilities RPC: %v", err)
log.Printf("intel-e2000: Error in Capabilities RPC: %v", err)
return err
}
logr.Infof("intel-e2000: P4Runtime server version is %s", resp.P4RuntimeApiVersion)
log.Printf("intel-e2000: P4Runtime server version is %s", resp.P4RuntimeApiVersion)

electionID := &p4_v1.Uint128{High: 0, Low: 1}

Expand All @@ -277,13 +246,13 @@ func NewP4RuntimeClient(binPath string, p4infoPath string, conn *grpc.ClientConn
sent := false
for isPrimary := range arbitrationCh {
if isPrimary {
logr.Infof("We are the primary client!")
log.Println("We are the primary client!")
if !sent {
waitCh <- struct{}{}
sent = true
}
} else {
logr.Infof("We are not the primary client!")
log.Println("We are not the primary client!")
}
}
}()
Expand All @@ -294,15 +263,15 @@ func NewP4RuntimeClient(binPath string, p4infoPath string, conn *grpc.ClientConn
defer cancel()
select {
case <-Ctx2.Done():
logr.Fatalf("Could not become the primary client within %v", timeout)
log.Fatal("Could not become the primary client within ", timeout)
case <-errs:
logr.Fatalf("Could not get the client within %v", timeout)
log.Fatal("Could not get the client within ", timeout)
case <-waitCh:
}
}()
logr.Info("Setting forwarding pipe")
log.Println("Setting forwarding pipe")
if _, err := P4RtC.SetFwdPipe(Ctx, binPath, p4infoPath, 0); err != nil {
logr.Fatalf("Error when setting forwarding pipe: %v", err)
log.Fatal("Error when setting forwarding pipe: ", err)
return err
}
return nil
Expand Down
Loading

0 comments on commit d138860

Please # to comment.