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

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

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

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

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

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

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

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

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

0 commit comments

Comments
 (0)