Skip to content

Commit b6e11fb

Browse files
authored
Merge pull request #653 from intel-go/develop
New release 0.9
2 parents 27d1256 + 4d10b8e commit b6e11fb

Some content is hidden

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

43 files changed

+1141
-168
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
# emacs
22
*~
33
doc
4+
GPATH
5+
GTAGS
6+
GRTAGS

.travis.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ services:
1212

1313
before_script:
1414
- sudo apt-get install -y linux-headers-$(uname -r)
15-
- docker pull ubuntu:cosmic
16-
- docker build --build-arg https_proxy=${https_proxy} -t test-cosmic .
17-
- 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
15+
- docker pull ubuntu:disco
16+
- docker build --build-arg https_proxy=${https_proxy} -t test-disco .
17+
- 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-disco /bin/bash
1818

1919
script:
2020
- docker exec -i test-nff-go go mod download

Dockerfile

+5-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,11 @@ RUN apt-get -q update && apt-get -q -y install \
2020
libmnl-dev \
2121
libibverbs-dev
2222

23-
RUN cd /opt && curl -L -s https://dl.google.com/go/go1.12.5.linux-amd64.tar.gz | tar zx
23+
RUN cd /opt && curl -L -s https://dl.google.com/go/go1.12.9.linux-amd64.tar.gz | tar zx
24+
RUN git clone -b v0.0.4 https://github.com/libbpf/libbpf
25+
RUN make -C libbpf/src all install
26+
RUN echo "/usr/lib64" > /etc/ld.so.conf.d/usrlib64.conf
27+
RUN ldconfig
2428

2529
RUN mkdir -p ${NFF_GO}
2630
COPY . ${NFF_GO}

README.md

+22-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ func main() {
3535
flow.CheckFatal(flow.SystemInit(&config))
3636

3737
// Get filtering rules from access control file.
38-
L3Rules, err := packet.GetL3ACLFromORIG("Firewall.conf")
38+
L3Rules, err := packet.GetL3ACLFromTextTable("Firewall.conf")
3939
flow.CheckFatal(err)
4040

4141
// Receive packets from zero port. Receive queue will be added automatically.
@@ -118,6 +118,27 @@ Use Go version 1.11.4 or higher. To check the version of Go, do:
118118

119119
go version
120120
121+
### AF_XDP support
122+
123+
AF_XDP support is enabled by default, and it requires you to install
124+
`libbpf` package. At the time of writing Ubuntu doesn't have this
125+
library among its packages, so it is necessary to build `libbpf` from
126+
sources or disable AF_XDP socket support.
127+
128+
To disable it set variable `NFF_GO_NO_BPF_SUPPORT` to some unempty
129+
value. When NFF_GO is built with it, AF_XDP support is disaled and
130+
using it results in errors.
131+
132+
If you want to build `libbpf` from sources you can do it in two
133+
different ways.
134+
* If you are using stock Linux kernel from distribution, [download
135+
`libbpf` from GitHub](https://github.com/libbpf/libbpf), then
136+
execute `cd src; make; sudo make install`. Add /usr/lib64 to your
137+
ldconfig path.
138+
* If you build Linux kernel from sources, you can build `libbpf` from
139+
Linux source tree using commands `cd tools/lib/bpf; make; sudo make
140+
install install_headers`. Add /usr/local/lib64 to your ldconfig path.
141+
121142
## Building NFF-GO
122143

123144
When Go compiler runs for the first time it downloads all dependent

common/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ include $(PATH_TO_MK)/include.mk
77

88
.PHONY: testing
99
testing: check-pktgen
10-
go test
10+
go test -tags "${GO_BUILD_TAGS}"
1111

1212
.PHONY: coverage
1313
coverage:

devices/misc.go

+9-3
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,18 @@ func GetDeviceID(nicName string) (string, error) {
4040
return "", err
4141
}
4242
// raw should be like /sys/devices/pci0002:00/0000:00:08.0/virtio2/net/ens8
43+
// or /sys/devices/pci0000:00/0000:00:01.0/0000:03:00.2/net/ens4f2
4344
raws := strings.Split(raw, "/")
44-
if len(raws) < 5 {
45+
if len(raws) < 6 {
4546
return "", fmt.Errorf("path not correct")
4647
}
47-
return raws[4], nil
48-
48+
if IsPciID.Match([]byte(raws[5])) {
49+
return raws[5], nil
50+
} else if IsPciID.Match([]byte(raws[4])) {
51+
return raws[4], nil
52+
} else {
53+
return "", fmt.Errorf("can't get device ID from path: %s", raw)
54+
}
4955
}
5056

5157
// IsModuleLoaded checks if the kernel has already loaded the driver or not.

dpdk/dpdk

Submodule dpdk updated from 07efd6d to b81660d

dpdk/pktgen-dpdk

Submodule pktgen-dpdk updated from ae5a88b to 7a4e0bc

examples/Makefile

+2-6
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,11 @@ EXECUTABLES = dump clonablePcapDumper kni copy errorHandling timer \
88
createPacket sendFixedPktsNumber gtpu pingReplay \
99
netlink gopacketParserExample devbind generate \
1010
OSforwarding jumbo decrementTTL
11+
SUBDIRS = tutorial antiddos demo fileReadWrite firewall forwarding ipsec lb nffPktgen
1112

12-
SUBDIRS = tutorial antiddos demo fileReadWrite firewall forwarding ipsec lb
13-
14-
.PHONY: dpi nffPktgen
13+
.PHONY: dpi
1514
dpi:
1615
$(MAKE) -C dpi
1716

18-
nffPktgen:
19-
$(MAKE) -C nffPktgen
20-
2117
include $(PATH_TO_MK)/intermediate.mk
2218
include $(PATH_TO_MK)/leaf.mk

examples/OSforwarding.go

+13-5
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,23 @@ import (
1010
)
1111

1212
func main() {
13+
// If you use af-xdp mode you need to configure queues:
14+
// e.g. ethtool -N my_device flow-type tcp4 dst-port 4242 action 16
15+
afXDP := flag.Bool("af-xdp", false, "use af-xdp. need to use ethtool to setup queues")
1316
inport := flag.String("in", "", "device for receiver")
17+
inQueue := flag.Int("in-queue", 16, "queue for receiver")
1418
outport := flag.String("out", "", "device for sender")
1519
flag.Parse()
1620

1721
flow.CheckFatal(flow.SystemInit(nil))
18-
19-
inputFlow, err := flow.SetReceiverOS(*inport)
20-
flow.CheckFatal(err)
21-
flow.CheckFatal(flow.SetSenderOS(inputFlow, *outport))
22-
22+
if *afXDP {
23+
inputFlow, err := flow.SetReceiverXDP(*inport, *inQueue)
24+
flow.CheckFatal(err)
25+
flow.CheckFatal(flow.SetSenderXDP(inputFlow, *outport))
26+
} else {
27+
inputFlow, err := flow.SetReceiverOS(*inport)
28+
flow.CheckFatal(err)
29+
flow.CheckFatal(flow.SetSenderOS(inputFlow, *outport))
30+
}
2331
flow.CheckFatal(flow.SystemStart())
2432
}

examples/errorHandling.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@ func main() {
4949
}
5050

5151
// Get splitting rules from access control file.
52-
l3Rules, err = packet.GetL3ACLFromORIG("wrong.conf")
53-
fmt.Printf("error from GetL3ACLFromORIG was: %+v\n", err)
52+
l3Rules, err = packet.GetL3ACLFromTextTable("wrong.conf")
53+
fmt.Printf("error from GetL3ACLFromTextTable was: %+v\n", err)
5454
if common.GetNFErrorCode(err) == common.FileErr {
5555
fmt.Printf("changing file name\n")
56-
l3Rules, err = packet.GetL3ACLFromORIG("Forwarding.conf")
56+
l3Rules, err = packet.GetL3ACLFromTextTable("Forwarding.conf")
5757
CheckFatal(err)
5858
}
5959

examples/firewall/firewall.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ func main() {
2929
flow.CheckFatal(flow.SystemInit(&config))
3030

3131
// Get filtering rules from access control file.
32-
l3Rules, err = packet.GetL3ACLFromORIG("firewall.conf")
32+
l3Rules, err = packet.GetL3ACLFromTextTable("firewall.conf")
3333
flow.CheckFatal(err)
3434

3535
// Receive packets from zero port. Receive queue will be added automatically.

examples/forwarding/forwarding.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ func main() {
3737
flow.CheckFatal(flow.SystemInit(&config))
3838

3939
// Get splitting rules from access control file.
40-
l3Rules, err = packet.GetL3ACLFromORIG("forwarding.conf")
40+
l3Rules, err = packet.GetL3ACLFromTextTable("forwarding.conf")
4141
flow.CheckFatal(err)
4242

4343
// Receive packets from zero port. Receive queue will be added automatically.

examples/nffPktgen/gtp-u/Dockerfile

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Copyright 2019 Intel Corporation.
2+
# Use of this source code is governed by a BSD-style
3+
# license that can be found in the LICENSE file.
4+
5+
ARG USER_NAME
6+
FROM ${USER_NAME}/nff-go-base
7+
8+
LABEL RUN docker run -it --privileged -v /sys/bus/pci/drivers:/sys/bus/pci/drivers -v /sys/kernel/mm/hugepages:/sys/kernel/mm/hugepages -v /sys/devices/system/node:/sys/devices/system/node -v /dev:/dev --name NAME -e NAME=NAME -e IMAGE=IMAGE IMAGE
9+
10+
WORKDIR /workdir
11+
COPY trafficgen .

examples/nffPktgen/gtp-u/trafficgen.go

+1
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ func initPortFlows(port *IpPort, myIPs generator.AddrRange, addEncapsulation boo
192192
flow.CheckFatal(flow.SetSender(outFlow, uint16(port.Index)))
193193
// Input flow
194194
inFlow, err := flow.SetReceiver(port.Index)
195+
flow.CheckFatal(err)
195196
flow.CheckFatal(flow.SetHandlerDrop(inFlow, receiveHandler, hc))
196197
flow.CheckFatal(flow.SetStopper(inFlow))
197198
}

examples/nffPktgen/testing/Dockerfile

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

1010
WORKDIR /workdir
1111
COPY sendGetBack .
12-
COPY perfTesting .
12+
COPY perfTest .
1313
COPY dump .

0 commit comments

Comments
 (0)