Skip to content

Commit 3c791dd

Browse files
authored
Merge pull request #507 from intel-go/develop
Bugfix release 0.7.1. Bugfixes in development environment and tests
2 parents 881d8d9 + 3c95771 commit 3c791dd

19 files changed

+875
-334
lines changed

.travis.yml

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ before_script:
1717
- docker run -it -d --privileged -v /usr/src:/usr/src -v /lib/modules:/lib/modules -v /sys/devices/system/node:/sys/devices/system/node --name test-nff-go test-cosmic /bin/bash
1818

1919
script:
20+
- docker exec -i test-nff-go go mod download
2021
- docker exec -i test-nff-go make
2122
# Build standalone examples
2223
- docker exec -i test-nff-go bash -c "cd examples && make gopacketParserExample && cd .."

common/common.go

+1
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ const (
154154
WrongPort
155155
FailToInitDPDK
156156
FailToCreateKNI
157+
FailToReleaseKNI
157158
)
158159

159160
// NFError is error type returned by nff-go functions

dpdk/Dockerfile

+5-3
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@ LABEL RUN docker run -it --privileged -v /sys/bus/pci/drivers:/sys/bus/pci/drive
99

1010
EXPOSE 22022
1111

12-
RUN dnf -y install pciutils; dnf clean all
12+
#Uncomment for Fedora
13+
# RUN dnf -y install pciutils; dnf clean all
1314

1415
WORKDIR /workdir
1516
COPY pktgen .
16-
COPY Pktgen.lua .
17+
1718
# Workaround for linking agains libpcap.so.0.8 on Ubuntu
18-
RUN ln -s libpcap.so.1 /usr/lib64/libpcap.so.0.8
19+
# Uncomment for Fedora
20+
#RUN ln -s libpcap.so.1 /usr/lib64/libpcap.so.0.8
1921

2022
CMD ["./pktgen", "-c", "0x1ff", "-n", "4", "--", "-P", "-m", "[1:1-2].0, [3:3-4].1, [5-6:5].2, [7-8:7].3", "-G"]

dpdk/Makefile

-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ endif
2222
dpdk: all
2323

2424
all: pktgen
25-
cp $(PKTGEN_DIR)/Pktgen.lua .
2625

2726
$(DPDK_DIR)/$(DPDK_INSTALL_DIR):
2827
$(MAKE) -C $(DPDK_DIR) config T=$(RTE_TARGET)
@@ -35,7 +34,6 @@ pktgen: $(PKTGEN_DIR)/app/$(RTE_TARGET)/pktgen
3534
cp $(PKTGEN_DIR)/app/$(RTE_TARGET)/pktgen .
3635

3736
clean:
38-
-rm pktgen Pktgen.lua
3937
-$(MAKE) -C $(DPDK_DIR) clean
4038
-rm -rf $(DPDK_DIR)/$(DPDK_INSTALL_DIR) $(DPDK_DIR)/build $(DPDK_DIR)/$(RTE_TARGET)
4139
-$(MAKE) -C $(PKTGEN_DIR) realclean

flow/flow.go

+19-8
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,7 @@ type port struct {
375375
txQueuesNumber int16
376376
willReceive bool // will this port receive packets
377377
willKNI bool // will this port has assigned KNI device
378+
KNICoreIndex int
378379
port uint16
379380
MAC [common.EtherAddrLen]uint8
380381
InIndex int32
@@ -601,7 +602,7 @@ func SystemStart() error {
601602

602603
// SystemStop stops the system. All Flow functions plus resource releasing
603604
// Doesn't cleanup DPDK
604-
func SystemStop() {
605+
func SystemStop() error {
605606
// TODO we should release rings here
606607
schedState.systemStop()
607608
for i := range createdPorts {
@@ -611,8 +612,17 @@ func SystemStop() {
611612
createdPorts[i].txQueuesNumber = 0
612613
createdPorts[i].willReceive = false
613614
}
615+
if createdPorts[i].willKNI {
616+
err := low.FreeKNI(createdPorts[i].port)
617+
if err != nil {
618+
return err
619+
}
620+
schedState.setCoreByIndex(createdPorts[i].KNICoreIndex)
621+
createdPorts[i].willKNI = false
622+
}
614623
}
615624
low.FreeMempools()
625+
return nil
616626
}
617627

618628
// SystemReset stops whole framework plus cleanup DPDK
@@ -1566,19 +1576,20 @@ func CreateKniDevice(portId uint16, name string) (*Kni, error) {
15661576
if createdPorts[portId].willKNI {
15671577
return nil, common.WrapWithNFError(nil, "Requested KNI port already has KNI. Two KNIs for one port are prohibited.", common.MultipleKNIPort)
15681578
}
1569-
if core, _, err := schedState.getCore(); err != nil {
1579+
if core, coreIndex, err := schedState.getCore(); err != nil {
15701580
return nil, err
15711581
} else {
15721582
if err := low.CreateKni(portId, uint(core), name); err != nil {
15731583
return nil, err
15741584
}
1585+
kni := new(Kni)
1586+
// Port will be identifier of this KNI
1587+
// KNI structure itself is stored inside low.c
1588+
kni.portId = portId
1589+
createdPorts[portId].willKNI = true
1590+
createdPorts[portId].KNICoreIndex = coreIndex
1591+
return kni, nil
15751592
}
1576-
kni := new(Kni)
1577-
// Port will be identifier of this KNI
1578-
// KNI structure itself is stored inside low.c
1579-
kni.portId = portId
1580-
createdPorts[portId].willKNI = true
1581-
return kni, nil
15821593
}
15831594

15841595
func FillSliceFromMask(input []uintptr, mask *[burstSize]bool, output []uintptr) uint8 {

flow/scheduler.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ type scheduler struct {
171171
pAttempts []uint64
172172
maxInIndex int32
173173
measureRings low.Rings
174+
coreIndex int
174175
}
175176

176177
type core struct {
@@ -204,7 +205,7 @@ func newScheduler(cpus []int, schedulerOff bool, schedulerOffRemove bool, stopDe
204205
func (scheduler *scheduler) systemStart() (err error) {
205206
scheduler.stopFlag = process
206207
var core int
207-
if core, _, err = scheduler.getCore(); err != nil {
208+
if core, scheduler.coreIndex, err = scheduler.getCore(); err != nil {
208209
return err
209210
}
210211
common.LogDebug(common.Initialization, "Start SCHEDULER at", core, "core")
@@ -333,9 +334,9 @@ func (scheduler *scheduler) systemStop() {
333334
scheduler.ff[i].stopInstance(0, -1, scheduler)
334335
}
335336
}
336-
scheduler.setCoreByIndex(0) // scheduler
337+
scheduler.setCoreByIndex(scheduler.coreIndex)
337338
if scheduler.stopDedicatedCore {
338-
scheduler.setCoreByIndex(1) // stop
339+
scheduler.setCoreByIndex(scheduler.coreIndex + 1)
339340
}
340341
scheduler.ff = nil
341342
}

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ require (
1212
github.com/vishvananda/netns v0.0.0-20180720170159-13995c7128cc // indirect
1313
golang.org/x/net v0.0.0-20180926154720-4dfa2610cdf3 // indirect
1414
golang.org/x/sys v0.0.0-20181004145325-8469e314837c // indirect
15-
golang.org/x/tools v0.0.0-20181122213734-04b5d21e00f1 // indirect
15+
golang.org/x/tools v0.0.0-20181204185109-3832e276fb48 // indirect
1616
)

go.sum

+2
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,5 @@ golang.org/x/tools v0.0.0-20181002223833-cd09f19c2f7e h1:x8cnE8uLkl6ATwMpvL/N/wY
3333
golang.org/x/tools v0.0.0-20181002223833-cd09f19c2f7e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
3434
golang.org/x/tools v0.0.0-20181122213734-04b5d21e00f1 h1:bsEj/LXbv3BCtkp/rBj9Wi/0Nde4OMaraIZpndHAhdI=
3535
golang.org/x/tools v0.0.0-20181122213734-04b5d21e00f1/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
36+
golang.org/x/tools v0.0.0-20181204185109-3832e276fb48 h1:N6OJ2izGAYOu7TF6EHpWtlM+vFxWtFJoj/BxJI7UhSQ=
37+
golang.org/x/tools v0.0.0-20181204185109-3832e276fb48/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=

low/low.go

+7
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,13 @@ func StopPort(port uint16) {
515515
C.rte_eth_dev_stop(C.uint16_t(port))
516516
}
517517

518+
func FreeKNI(port uint16) error {
519+
if C.free_kni(C.uint16_t(port)) < 0 {
520+
return common.WrapWithNFError(nil, "Problem with KNI releasing\n", common.FailToReleaseKNI)
521+
}
522+
return nil
523+
}
524+
518525
// GetPortsNumber gets total number of available Ethernet devices.
519526
func GetPortsNumber() int {
520527
return int(C.rte_eth_dev_count())

low/low.h

+4
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,10 @@ int create_kni(uint16_t port, uint32_t core, char *name, struct rte_mempool *mbu
150150
return 0;
151151
}
152152

153+
int free_kni(uint16_t port) {
154+
return rte_kni_release(kni[port]);
155+
}
156+
153157
int checkRSSPacketCount(struct cPort *port, int16_t queue) {
154158
return rte_eth_rx_queue_count(port->PortId, queue);
155159
}

nff-go-base/Makefile

+15-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ IMAGENAME = nff-go-base
77
EXECUTABLES =
88
NOCHECK_PKTGEN = yes
99

10-
Dockerfile: Makefile
10+
# This will not be used from "make deploy" or "make images" by default
11+
# You should change images rule in mk/leaf.mk from "Dockerfile" to "Fedora"
12+
Fedora: Makefile
1113
echo 'ARG USER_NAME' > Dockerfile
1214
echo 'FROM fedora' >> Dockerfile
1315
if [ -n '${http_proxy}' ]; then \
@@ -19,6 +21,18 @@ Dockerfile: Makefile
1921
echo 'RUN dnf -y install numactl-libs.x86_64; dnf clean all' >> Dockerfile
2022
echo 'CMD ["/bin/bash"]' >> Dockerfile
2123

24+
Dockerfile: Makefile
25+
echo 'ARG USER_NAME' > Dockerfile
26+
echo 'FROM ubuntu:cosmic' >> Dockerfile
27+
if [ -n '${http_proxy}' ]; then \
28+
echo 'ENV http_proxy ${http_proxy}' >> Dockerfile; \
29+
echo 'ENV https_proxy ${http_proxy}' >> Dockerfile; \
30+
echo 'RUN echo Acquire::http::Proxy \"${http_proxy}\"\; >> /etc/apt/apt.conf' >> Dockerfile; \
31+
echo 'RUN echo Acquire::https::Proxy \"${https_proxy}\"\; >> /etc/apt/apt.conf' >> Dockerfile; \
32+
fi
33+
echo 'RUN apt-get update; apt-get install -y libnuma-dev; apt-get install -y libpcap0.8-dev; apt-get install -y liblua5.3-dev; apt-get clean all' >> Dockerfile
34+
echo 'CMD ["/bin/bash"]' >> Dockerfile
35+
2236
.PHONY: dpdk
2337
dpdk:
2438

scripts/get-depends.sh

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ go get -v github.com/Sirupsen/logrus
66
go get -v github.com/pkg/errors
77
go get -v golang.org/x/net/proxy
88
go get -v github.com/docker/go-connections
9-
go get -v golang.org/x/tools/cmd/stringer
109
go get -v github.com/vishvananda/netlink
1110
go get -v github.com/google/gopacket
1211

test/framework/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
PATH_TO_MK = ../../mk
66
SUBDIRS = main
77

8-
main: apptype_string.go
8+
main:
99

1010
%_string.go: types.go
1111
go generate

test/framework/dockerlauncher.go

+10-7
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ import (
2323

2424
// Pktgen commands constants
2525
const (
26-
PktgenGetPortsNumberCommand = "printf(\"%d\\n\", pktgen.portStats(\"all\", \"port\").n);"
26+
PktgenGetPortsNumberCommand = "io.write(string.format(\"%d\\n\", pktgen.portStats(\"all\", \"port\").n)); io.flush();"
2727
PktgenGetPortStatsCommand = "stat = pktgen.portStats(\"all\", \"rate\");"
28-
PktgenPrintPortStatsCommand = "printf(\"%%d %%d %%d %%d\\n\", stat[%d].pkts_tx, stat[%d].mbits_tx, stat[%d].pkts_rx, stat[%d].mbits_rx);"
28+
PktgenPrintPortStatsCommand = "io.write(string.format(\"%%d %%d %%d %%d\\n\", stat[%d].pkts_tx, stat[%d].mbits_tx, stat[%d].pkts_rx, stat[%d].mbits_rx)); io.flush();"
2929
PktgenExitCommand = "os.exit(0);"
3030

3131
PktgenGetPortsNumberFormat = "%d"
@@ -227,7 +227,7 @@ func (app *RunningApp) testRoutine(report chan<- TestReport, done <-chan struct{
227227
}
228228
}
229229

230-
func (app *RunningApp) testPktgenRoutine(report chan<- TestReport, done <-chan struct{}) {
230+
func (app *RunningApp) testPktgenRoutine(report chan<- TestReport, done <-chan struct{}, start bool) {
231231
var connection net.Conn
232232
var err error
233233
var scanner *bufio.Scanner
@@ -314,10 +314,13 @@ func (app *RunningApp) testPktgenRoutine(report chan<- TestReport, done <-chan s
314314
app.Logger.LogDebug("Got number of ports", numberOfPorts)
315315

316316
// Start generating packets on ports
317-
app.Logger.LogDebug("Executing startup commands")
318-
for _, cmd := range app.test.BenchConf.StartCommands {
319-
if writeData(cmd) {
320-
return
317+
// If we don't start generating - this pktgen will be used for receiving and counting
318+
if start {
319+
app.Logger.LogDebug("Executing startup commands")
320+
for _, cmd := range app.test.BenchConf.StartCommands {
321+
if writeData(cmd) {
322+
return
323+
}
321324
}
322325
}
323326

0 commit comments

Comments
 (0)