Skip to content
This repository was archived by the owner on Apr 8, 2025. It is now read-only.

Commit 94aba27

Browse files
committed
update addip section to work with new api
Signed-off-by: John O'Loughlin <[email protected]>
1 parent 70c9cec commit 94aba27

File tree

1 file changed

+20
-19
lines changed

1 file changed

+20
-19
lines changed

Diff for: cnivpp/api/interface/interface.go

+20-19
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@ import (
2323
"fmt"
2424

2525
current "github.com/containernetworking/cni/pkg/types/100"
26-
"github.com/intel/userspace-cni-network-plugin/cnivpp/bin_api/interface"
26+
interfaces "github.com/intel/userspace-cni-network-plugin/cnivpp/bin_api/interface"
2727
"github.com/intel/userspace-cni-network-plugin/cnivpp/bin_api/interface_types"
28+
"github.com/intel/userspace-cni-network-plugin/cnivpp/bin_api/ip_types"
2829
"go.fd.io/govpp/api"
2930
)
3031

@@ -66,25 +67,25 @@ func AddDelIpAddress(ch api.Channel, swIfIndex interface_types.InterfaceIndex, i
6667
IsAdd: isAdd, // 1 = add, 0 = delete
6768
DelAll: false,
6869
}
70+
for _, ip := range ipResult.IPs {
71+
var addressWithPrefix ip_types.AddressWithPrefix
6972

70-
// for _, ip := range ipResult.IPs {
71-
// if ip.Version == "4" {
72-
// req.IsIPv6 = 0
73-
// req.Address = []byte(ip.Address.IP.To4())
74-
// prefix, _ := ip.Address.Mask.Size()
75-
// req.AddressLength = byte(prefix)
76-
// } else if ip.Version == "6" {
77-
// req.IsIPv6 = 1
78-
// req.Address = []byte(ip.Address.IP.To16())
79-
// prefix, _ := ip.Address.Mask.Size()
80-
// req.AddressLength = byte(prefix)
81-
// }
82-
83-
// // Only one address is currently supported.
84-
// if req.AddressLength != 0 {
85-
// break
86-
// }
87-
// }
73+
if prefix, _ := ip.Address.Mask.Size(); prefix == 4 {
74+
addressWithPrefix = ip_types.AddressWithPrefix{Address: ip_types.AddressFromIP(ip.Address.IP.To4()), Len: 4}
75+
76+
} else if prefix, _ := ip.Address.Mask.Size(); prefix == 16 {
77+
addressWithPrefix = ip_types.AddressWithPrefix{Address: ip_types.AddressFromIP(ip.Address.IP.To16()), Len: 16}
78+
} else {
79+
break
80+
}
81+
fmt.Println(addressWithPrefix)
82+
req.Prefix = addressWithPrefix
83+
84+
// Only one address is currently supported.
85+
if req.Prefix.Len != 0 {
86+
break
87+
}
88+
}
8889

8990
reply := &interfaces.SwInterfaceAddDelAddressReply{}
9091

0 commit comments

Comments
 (0)