Skip to content

Commit d7cf8be

Browse files
author
Milan Lenčo
authored
feat: Add support for VPP 21.01 (ligato#1785)
1 parent cc430d2 commit d7cf8be

File tree

328 files changed

+49215
-25805
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

328 files changed

+49215
-25805
lines changed

.travis.yml

+8-10
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,6 @@ jobs:
4747
- goveralls -coverprofile=/tmp/coverage.out -service=travis-ci
4848
- bash <(curl -s https://codecov.io/bash) -f /tmp/coverage.out -F unittests
4949

50-
- stage: Integration
51-
env: VPP_VERSION=1908
52-
script:
53-
- make verify-binapi
54-
- make integration-tests
5550
- env: VPP_VERSION=2001
5651
script:
5752
- make verify-binapi
@@ -64,24 +59,27 @@ jobs:
6459
script:
6560
- make verify-binapi
6661
- make integration-tests
62+
- env: VPP_VERSION=2101
63+
script:
64+
- make verify-binapi
65+
- make integration-tests
6766

68-
- stage: E2E
69-
env: VPP_VERSION=1908
67+
- env: VPP_VERSION=2001
7068
script:
7169
- make e2e-tests-cover
7270
after_success:
7371
- bash <(curl -s https://codecov.io/bash) -f /tmp/e2e-cov.out -F e2e
74-
- env: VPP_VERSION=2001
72+
- env: VPP_VERSION=2005
7573
script:
7674
- make e2e-tests-cover
7775
after_success:
7876
- bash <(curl -s https://codecov.io/bash) -f /tmp/e2e-cov.out -F e2e
79-
- env: VPP_VERSION=2005
77+
- env: VPP_VERSION=2009
8078
script:
8179
- make e2e-tests-cover
8280
after_success:
8381
- bash <(curl -s https://codecov.io/bash) -f /tmp/e2e-cov.out -F e2e
84-
- env: VPP_VERSION=2009
82+
- env: VPP_VERSION=2101
8583
script:
8684
- make e2e-tests-cover
8785
after_success:

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ dev-image: ## Build developer image
326326

327327
prod-image: ## Build production image
328328
@echo "# building prod image"
329-
IMAGE_TAG=$(IMAGE_TAG) ./docker/prod/build.sh
329+
IMAGE_TAG=$(IMAGE_TAG) VPP_VERSION=$(VPP_VERSION) ./docker/prod/build.sh
330330

331331

332332
.PHONY: help \

docker/dev/Dockerfile

+6
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,12 @@ COPY \
107107
COPY ./docker/dev/vpp.conf /etc/vpp/vpp.conf
108108
COPY ./docker/dev/init_hook.sh /usr/bin/
109109

110+
# handle differences in vpp.conf which are between supported VPP versions
111+
ARG VPP_VERSION
112+
COPY ./docker/dev/legacy-nat.conf /tmp/legacy-nat.conf
113+
RUN bash -c "if [[ \"$VPP_VERSION\" < "2101" ]]; then cat /tmp/legacy-nat.conf >> /etc/vpp/vpp.conf; fi"
114+
RUN rm /tmp/legacy-nat.conf
115+
110116
# Install agent
111117
WORKDIR /src/ligato/vpp-agent
112118

docker/dev/legacy-nat.conf

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
nat {
3+
endpoint-dependent
4+
translation hash buckets 1048576
5+
translation hash memory 268435456
6+
user hash buckets 1024
7+
max translations per user 10000
8+
}

docker/dev/vpp.conf

+1-8
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,4 @@ socksvr {
1919
statseg {
2020
socket-name /run/vpp/stats.sock
2121
per-node-counters on
22-
}
23-
nat {
24-
endpoint-dependent
25-
translation hash buckets 1048576
26-
translation hash memory 268435456
27-
user hash buckets 1024
28-
max translations per user 10000
29-
}
22+
}

docker/prod/Dockerfile

+12-6
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,6 @@ RUN set -eux; \
2929
rm *.deb; \
3030
rm -rf /var/lib/apt/lists/*;
3131

32-
# Final image
33-
FROM scratch
34-
COPY --from=base / /
35-
36-
WORKDIR /root/
37-
3832
# Copy configs
3933
COPY \
4034
etcd.conf \
@@ -45,13 +39,25 @@ COPY \
4539
COPY vpp.conf /etc/vpp/vpp.conf
4640
COPY init_hook.sh /usr/bin/
4741

42+
# handle differences in vpp.conf which are between supported VPP versions
43+
ARG VPP_VERSION
44+
COPY legacy-nat.conf /tmp/legacy-nat.conf
45+
RUN bash -c "if [[ \"$VPP_VERSION\" < "2101" ]]; then cat /tmp/legacy-nat.conf >> /etc/vpp/vpp.conf; fi"
46+
RUN rm /tmp/legacy-nat.conf
47+
4848
# Install agent
4949
COPY --from=devimg \
5050
/go/bin/agentctl \
5151
/go/bin/vpp-agent \
5252
/go/bin/vpp-agent-init \
5353
/bin/
5454

55+
# Final image
56+
FROM scratch
57+
COPY --from=base / /
58+
59+
WORKDIR /root/
60+
5561
ENV SUPERVISOR_CONFIG=/opt/vpp-agent/dev/supervisor.conf
5662

5763
CMD rm -f /dev/shm/db /dev/shm/global_vm /dev/shm/vpe-api && \

docker/prod/build.sh

+2
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,14 @@ echo "==============================================="
1515
echo " Image: ${IMAGE_TAG:=prod_vpp_agent}"
1616
echo "==============================================="
1717
echo " - dev image: ${DEV_IMG:=dev_vpp_agent}"
18+
echo " - VPP version: ${VPP_VERSION}"
1819
echo "==============================================="
1920

2021
set -x
2122

2223
docker build -f Dockerfile \
2324
--build-arg DEV_IMG=${DEV_IMG} \
25+
--build-arg VPP_VERSION=${VPP_VERSION} \
2426
--tag ${IMAGE_TAG} \
2527
${DOCKER_BUILD_ARGS-} .
2628

docker/prod/legacy-nat.conf

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
nat {
3+
endpoint-dependent
4+
}

docker/prod/vpp.conf

-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,4 @@ socksvr {
1515
statseg {
1616
socket-name /run/vpp/stats.sock
1717
per-node-counters on
18-
}
19-
nat {
20-
endpoint-dependent
2118
}

examples/govpp_call/main.go

+8-15
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import (
2626

2727
"go.ligato.io/vpp-agent/v3/cmd/vpp-agent/app"
2828
"go.ligato.io/vpp-agent/v3/plugins/govppmux"
29-
l2Api "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp1908/l2"
29+
l2Api "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2101/l2"
3030
l2 "go.ligato.io/vpp-agent/v3/proto/ligato/vpp/l2"
3131
)
3232

@@ -178,21 +178,14 @@ func buildData(name string) *l2.BridgeDomain {
178178
// Auxiliary method to transform agent model data to binary api format
179179
func buildBinapiMessage(data *l2.BridgeDomain, id uint32) *l2Api.BridgeDomainAddDel {
180180
req := &l2Api.BridgeDomainAddDel{}
181-
req.IsAdd = 1
181+
req.IsAdd = true
182182
req.BdID = id
183-
req.Flood = boolToInt(data.Flood)
184-
req.UuFlood = boolToInt(data.UnknownUnicastFlood)
185-
req.Forward = boolToInt(data.Forward)
186-
req.Learn = boolToInt(data.Learn)
187-
req.ArpTerm = boolToInt(data.ArpTermination)
183+
req.Flood = data.Flood
184+
req.UuFlood = data.UnknownUnicastFlood
185+
req.Forward = data.Forward
186+
req.Learn = data.Learn
187+
req.ArpTerm = data.ArpTermination
188188
req.MacAge = uint8(data.MacAge)
189189

190190
return req
191-
}
192-
193-
func boolToInt(input bool) uint8 {
194-
if input {
195-
return uint8(1)
196-
}
197-
return uint8(0)
198-
}
191+
}

examples/tutorials/07_vpp-connection/main.go

+20-17
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,15 @@ package main
1616

1717
import (
1818
"log"
19-
"net"
2019
"time"
2120

22-
"go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp1908/interfaces"
23-
2421
"git.fd.io/govpp.git/api"
2522

26-
"go.ligato.io/vpp-agent/v3/plugins/govppmux"
27-
2823
"go.ligato.io/cn-infra/v2/agent"
24+
25+
"go.ligato.io/vpp-agent/v3/plugins/govppmux"
26+
"go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2101/ethernet_types"
27+
"go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2101/interface"
2928
)
3029

3130
func main() {
@@ -76,13 +75,17 @@ func (p *HelloWorld) Init() (err error) {
7675

7776
func (p *HelloWorld) syncVppCall() {
7877
// prepare request
78+
mac, err := ethernet_types.ParseMacAddress("00:00:00:00:00:01")
79+
if err != nil {
80+
log.Panicf("ParseMacAddress failed: %v", err)
81+
}
7982
request := &interfaces.CreateLoopback{
80-
MacAddress: macParser("00:00:00:00:00:01"),
83+
MacAddress: mac,
8184
}
8285
// prepare reply
8386
reply := &interfaces.CreateLoopbackReply{}
8487
// send request and obtain reply
85-
err := p.vppChan.SendRequest(request).ReceiveReply(reply)
88+
err = p.vppChan.SendRequest(request).ReceiveReply(reply)
8689
if err != nil {
8790
panic(err)
8891
}
@@ -96,11 +99,19 @@ func (p *HelloWorld) syncVppCall() {
9699

97100
func (p *HelloWorld) asyncVppCall() {
98101
// prepare requests
102+
mac1, err := ethernet_types.ParseMacAddress("00:00:00:00:00:02")
103+
if err != nil {
104+
log.Panicf("ParseMacAddress failed: %v", err)
105+
}
106+
mac2, err := ethernet_types.ParseMacAddress("00:00:00:00:00:03")
107+
if err != nil {
108+
log.Panicf("ParseMacAddress failed: %v", err)
109+
}
99110
request1 := &interfaces.CreateLoopback{
100-
MacAddress: macParser("00:00:00:00:00:02"),
111+
MacAddress: mac1,
101112
}
102113
request2 := &interfaces.CreateLoopback{
103-
MacAddress: macParser("00:00:00:00:00:03"),
114+
MacAddress: mac2,
104115
}
105116

106117
// obtain contexts
@@ -151,11 +162,3 @@ func (p *HelloWorld) Close() error {
151162
log.Println("Goodbye World!")
152163
return nil
153164
}
154-
155-
func macParser(mac string) []byte {
156-
hw, err := net.ParseMAC(mac)
157-
if err != nil {
158-
panic(err)
159-
}
160-
return hw
161-
}

plugins/govppmux/plugin_impl_govppmux.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ import (
4040
"go.ligato.io/vpp-agent/v3/plugins/vpp"
4141
"go.ligato.io/vpp-agent/v3/plugins/vpp/binapi"
4242

43-
_ "go.ligato.io/vpp-agent/v3/plugins/govppmux/vppcalls/vpp1908"
4443
_ "go.ligato.io/vpp-agent/v3/plugins/govppmux/vppcalls/vpp2001"
4544
_ "go.ligato.io/vpp-agent/v3/plugins/govppmux/vppcalls/vpp2005"
4645
_ "go.ligato.io/vpp-agent/v3/plugins/govppmux/vppcalls/vpp2009"
46+
_ "go.ligato.io/vpp-agent/v3/plugins/govppmux/vppcalls/vpp2101"
4747
)
4848

4949
var (

plugins/govppmux/vppcalls/vpp1908/vpe_vppcalls.go plugins/govppmux/vppcalls/vpp2101/vpe_vppcalls.go

+17-16
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,19 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
package vpp1908
15+
package vpp2101
1616

1717
import (
18-
"bytes"
1918
"context"
2019
"fmt"
2120
"strings"
2221

22+
"git.fd.io/govpp.git/api"
2323
"github.com/pkg/errors"
2424

2525
"go.ligato.io/vpp-agent/v3/plugins/govppmux/vppcalls"
26-
"go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp1908/memclnt"
27-
"go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp1908/vpe"
26+
"go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2101/memclnt"
27+
"go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2101/vpe"
2828
)
2929

3030
// Ping sends VPP control ping.
@@ -77,7 +77,7 @@ func (h *VpeHandler) GetModules(ctx context.Context) ([]vppcalls.APIModule, erro
7777
var modules []vppcalls.APIModule
7878
for _, v := range versions.APIVersions {
7979
modules = append(modules, vppcalls.APIModule{
80-
Name: strings.TrimSuffix(cleanString(v.Name), ".api"),
80+
Name: strings.TrimSuffix(strings.TrimRight(v.Name, "\x00"), ".api"),
8181
Major: v.Major,
8282
Minor: v.Minor,
8383
Patch: v.Patch,
@@ -87,6 +87,11 @@ func (h *VpeHandler) GetModules(ctx context.Context) ([]vppcalls.APIModule, erro
8787
}
8888

8989
func (h *VpeHandler) GetPlugins(ctx context.Context) ([]vppcalls.PluginInfo, error) {
90+
const (
91+
pluginPathPrefix = "Plugin path is:"
92+
pluginNameSuffix = "_plugin.so"
93+
)
94+
9095
out, err := h.RunCli(ctx, "show plugins")
9196
if err != nil {
9297
return nil, err
@@ -96,9 +101,7 @@ func (h *VpeHandler) GetPlugins(ctx context.Context) ([]vppcalls.PluginInfo, err
96101
if len(lines) == 0 {
97102
return nil, fmt.Errorf("empty output for 'show plugins'")
98103
}
99-
100104
pluginPathLine := strings.TrimSpace(lines[0])
101-
const pluginPathPrefix = "Plugin path is:"
102105
if !strings.HasPrefix(pluginPathLine, pluginPathPrefix) {
103106
return nil, fmt.Errorf("unexpected output for 'show plugins'")
104107
}
@@ -121,7 +124,7 @@ func (h *VpeHandler) GetPlugins(ctx context.Context) ([]vppcalls.PluginInfo, err
121124
continue
122125
}
123126
plugin := vppcalls.PluginInfo{
124-
Name: strings.TrimSuffix(fields[1], "_plugin.so"),
127+
Name: strings.TrimSuffix(fields[1], pluginNameSuffix),
125128
Path: fields[1],
126129
Version: fields[2],
127130
Description: strings.Join(fields[3:], " "),
@@ -140,9 +143,9 @@ func (h *VpeHandler) GetThreads(ctx context.Context) ([]vppcalls.ThreadInfo, err
140143
threads := make([]vppcalls.ThreadInfo, len(resp.ThreadData))
141144
for i, thread := range resp.ThreadData {
142145
threads[i] = vppcalls.ThreadInfo{
143-
Name: string(thread.Name),
146+
Name: thread.Name,
144147
ID: thread.ID,
145-
Type: string(thread.Type),
148+
Type: thread.Type,
146149
PID: thread.PID,
147150
Core: thread.Core,
148151
CPUID: thread.CPUID,
@@ -154,15 +157,13 @@ func (h *VpeHandler) GetThreads(ctx context.Context) ([]vppcalls.ThreadInfo, err
154157

155158
// RunCli sends CLI command to VPP and returns response.
156159
func (h *VpeHandler) RunCli(ctx context.Context, cmd string) (string, error) {
157-
resp, err := h.vpe.CliInband(ctx, &vpe.CliInband{
160+
reply, err := h.vpe.CliInband(ctx, &vpe.CliInband{
158161
Cmd: cmd,
159162
})
160163
if err != nil {
161164
return "", errors.Wrapf(err, "VPP CLI command '%s' failed", cmd)
165+
} else if err = api.RetvalToVPPApiError(reply.Retval); err != nil {
166+
return "", err
162167
}
163-
return resp.Reply, nil
164-
}
165-
166-
func cleanString(b []byte) string {
167-
return string(bytes.SplitN(b, []byte{0x00}, 2)[0])
168+
return reply.Reply, nil
168169
}

0 commit comments

Comments
 (0)