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

File tree

19 files changed

+875
-334
lines changed

19 files changed

+875
-334
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 5 additions & 3 deletions
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

Lines changed: 0 additions & 2 deletions
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

Lines changed: 19 additions & 8 deletions
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

Lines changed: 4 additions & 3 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 2 additions & 0 deletions
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

Lines changed: 7 additions & 0 deletions
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

Lines changed: 4 additions & 0 deletions
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
}

0 commit comments

Comments
 (0)