Skip to content

Commit

Permalink
Bug fixes for arbitration & checks for null ptr (#174)
Browse files Browse the repository at this point in the history
Signed-off-by: nupurjai <[email protected]>
  • Loading branch information
nupurjai authored Jan 8, 2024
1 parent 9cbfd53 commit 2537427
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 14 deletions.
4 changes: 4 additions & 0 deletions deploy/es2k/infraagent-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,7 @@ insecure: false
# "Debug" (Default)
# "Trace"
logLevel: "Debug"
#Additional configurations for split mode
#managerAddr reflects the ACC comms interface IP Addr
#managerAddr : 10.10.0.2
#managerPort : 50002
5 changes: 5 additions & 0 deletions deploy/inframanager-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ Infrap4dGnmiServer:
# ca-cert: "/etc/pki/inframanager/client/ca.crt"
conn: mtls

# Possible manager addr configs
# split mode - IP address of the ACC comms interface.
# This is where inframanager listens for
# agent connections.
# host mode - loopback ip of local host
InfraManager:
addr: 127.0.0.1:50002
# - arp-mac
Expand Down
10 changes: 5 additions & 5 deletions example/service/tcp/iperf_tcp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,24 +57,24 @@ spec:
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: iperf-client
name: iperf-client-tcp
labels:
app: iperf-client
app: iperf-client-tcp
spec:
selector:
matchLabels:
app: iperf-client
app: iperf-client-tcp
template:
metadata:
labels:
app: iperf-client
app: iperf-client-tcp
spec:
tolerations:
- key: node-role.kubernetes.io/master
operator: Exists
effect: NoSchedule
containers:
- name: iperf-client
- name: iperf-client-tcp
image: lroktu/iperf
command: ['/bin/sh', '-c', 'sleep infinity']
terminationGracePeriodSeconds: 0
10 changes: 5 additions & 5 deletions example/service/udp/iperf_udp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,24 +58,24 @@ spec:
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: iperf-client
name: iperf-client-udp
labels:
app: iperf-client
app: iperf-client-udp
spec:
selector:
matchLabels:
app: iperf-client
app: iperf-client-udp
template:
metadata:
labels:
app: iperf-client
app: iperf-client-udp
spec:
tolerations:
- key: node-role.kubernetes.io/master
operator: Exists
effect: NoSchedule
containers:
- name: iperf-client
- name: iperf-client-udp
image: lroktu/iperf
command: ['/bin/sh', '-c', 'sleep infinity']
terminationGracePeriodSeconds: 0
2 changes: 2 additions & 0 deletions inframanager/api_handler/api_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ func OpenP4RtC(ctx context.Context, high uint64, low uint64, stopCh <-chan struc
}
log.Infof("P4Runtime server version is %s", resp.P4RuntimeApiVersion)

low = utils.MakeTimestampMilli()

electionID := p4_v1.Uint128{High: high, Low: low}
server.p4RtC = client.NewClient(c, config.DeviceId, &electionID)
log.Infof("Device id is: %v", config.DeviceId)
Expand Down
17 changes: 13 additions & 4 deletions pkg/inframanager/p4/service_es2k.go
Original file line number Diff line number Diff line change
Expand Up @@ -297,12 +297,17 @@ func InsertServiceRules(ctx context.Context, p4RtC *client.Client,
macByte = append(macByte, podmac)

InterfaceIDbyte = append(InterfaceIDbyte, ValueToBytes16(uint16(epEntry.InterfaceID))) //L2 forwarding port
} else {
err := fmt.Errorf("Endpoint %s not found, cannot program service %s",
ep.PodIpAddress, service.ClusterIp)
return err, store.Service{}
}

}
service.NumEndPoints = epNum

log.Debugf("group id: %d, service ip: %s, service mac: %s, service port: %d",
groupID, service.ClusterIp, service.MacAddr, service.Port)
log.Debugf("group id: %d, service ip: %s, service mac: %s, service port: %d, endpoints: %d",
groupID, service.ClusterIp, service.MacAddr, service.Port, service.NumEndPoints)

data := parseJson("service.json")
if data == nil {
Expand Down Expand Up @@ -330,9 +335,13 @@ func InsertServiceRules(ctx context.Context, p4RtC *client.Client,
}
entry := ep.GetFromStore()
epEntry := entry.(store.EndPoint)
if entry == nil {
err = fmt.Errorf("epEntry does not exist for DefaultRoute")
return
}
smacbyte, err := net.ParseMAC(epEntry.PodMacAddress)
if err != nil {
err = fmt.Errorf("Invalid MAC Address")
err = fmt.Errorf("Invalid MAC Address for DefaultRoute")
return
}
smac := []byte(smacbyte)
Expand Down Expand Up @@ -503,7 +512,7 @@ func DeleteServiceRules(ctx context.Context, p4RtC *client.Client,

//rx_src_ip
log.Debugf("Deleting from table RxSrcIpTable, NumEp: %d, service ip: %s, service port: %d",
NumEp, podipByte, portIDByte)
NumEp, service.ClusterIp, uint16(service.Port))
key = append(key, podipByte)
if service.Proto == "TCP" {
key = append(key, ValueToBytes8(uint8(PROTO_TCP)))
Expand Down
10 changes: 10 additions & 0 deletions pkg/utils/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"io"
"os"
"path"
"time"

log "github.com/sirupsen/logrus"
)
Expand Down Expand Up @@ -79,3 +80,12 @@ func LogInit(logDir string, logLevel string) error {
})
return nil
}

func unixMilli(t time.Time) uint64 {
s := t.Round(time.Millisecond).UnixNano() / (int64(time.Millisecond) / int64(time.Nanosecond))
return uint64(s)
}

func MakeTimestampMilli() uint64 {
return unixMilli(time.Now())
}

0 comments on commit 2537427

Please sign in to comment.