Skip to content

Commit

Permalink
Fix for->IIC-364: After host reboot, host connection to ACC is lost
Browse files Browse the repository at this point in the history
It can take time for network-manager's state for each interface, to become
activated, when IP address is set, which can cause the IP address to not stick.
Removing the host and acc comm channel interfaces out of network-manager's mgmt.
  • Loading branch information
sudhar-krishnakumar committed Oct 16, 2024
1 parent bb735da commit 3186f76
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
5 changes: 5 additions & 0 deletions e2e/artefacts/k8s/vsp-ds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,13 @@ spec:
volumeMounts:
- name: vendor-plugin-sock
mountPath: /var/run/dpu-daemon/
- name: dbus-socket
mountPath: /var/run/dbus
volumes:
- name: vendor-plugin-sock
hostPath:
path: /var/run/dpu-daemon/
- name: dbus-socket
hostPath:
path: /var/run/dbus/

1 change: 1 addition & 0 deletions ipu-plugin/images/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,4 @@ RUN python3 -m pip install --no-cache-dir --break-system-packages /opt/p4/p4-cp-

RUN rm -rf /var/cache/apk/*
RUN apk add --update --no-cache openssh
RUN apk add --update --no-cache networkmanager-cli
29 changes: 28 additions & 1 deletion ipu-plugin/pkg/ipuplugin/lifecycleservice.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,31 +192,58 @@ func getCommPf(mode string, linkList []netlink.Link) (netlink.Link, error) {
return pf, nil
}

// It can take time for network-manager's state for each interface, to become
// activated, when IP address is set, which can cause the IP address to not stick
// Removing the host-acc comm channel interface out of network-manager's mgmt.
func nmcli_setup(link netlink.Link) error {
intfName := link.Attrs().Name
output, err := utils.ExecuteScript(`nmcli device set ` + intfName + ` managed no`)
if err != nil {
log.Errorf("nmcli err->%v, output->%v\n", err, output)
return fmt.Errorf("nmcli err->%v, output->%v\n", err, output)
}
output, err = utils.ExecuteScript(`ip link set ` + intfName + `up`)
if err != nil {
log.Errorf("ip link set err->%v, output->%v\n", err, output)
return fmt.Errorf("ip link set err->%v, output->%v\n", err, output)
}
return nil
}

func setIP(link netlink.Link, ip string) error {
list, err := networkHandler.AddrList(link, netlink.FAMILY_V4)

if err != nil {
log.Errorf("setIP: unable to get the ip address of link: %v\n", err)
return fmt.Errorf("unable to get the ip address of link: %v", err)
}

if len(list) == 0 {

if err = nmcli_setup(link); err != nil {
log.Errorf("setIP: err->%v from nmcli_setup\n", err)
return fmt.Errorf("setIP: err->%v from nmcli_setup", err)
}

ipAddr := net.ParseIP(ip)

if ipAddr.To4() == nil {
log.Errorf("setIP: invalid ip->%v\n", ipAddr)
return fmt.Errorf("not a valid IPv4 address: %v", err)
}

// Set the IP address on PF
addr := &netlink.Addr{IPNet: &net.IPNet{IP: ipAddr, Mask: net.CIDRMask(24, 32)}}

if err = networkHandler.AddrAdd(link, addr); err != nil {
log.Errorf("setIP: unable to add address: %v\n", err)
return fmt.Errorf("unable to add address: %v", err)
}
} else {
log.Errorf("address already set. Unset ip address for interface %s and run again\n", link.Attrs().Name)
return fmt.Errorf("address already set. Unset ip address for interface %s and run again", link.Attrs().Name)
}

log.Debugf("setIP: Address->%v, set for interface->%v\n", ip, link.Attrs().Name)
return nil
}

Expand Down

0 comments on commit 3186f76

Please sign in to comment.