Skip to content

Commit 6ed16cd

Browse files
authored
Merge pull request #542 from intel-go/develop
Release 0.7.3
2 parents 08cf5a8 + 67eb5b7 commit 6ed16cd

Some content is hidden

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

58 files changed

+4181
-1266
lines changed

Dockerfile

+3-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ RUN apt-get -q update && apt-get -q -y install \
1717
hugepages \
1818
libnuma-dev \
1919
libhyperscan-dev \
20-
liblua5.3-dev
20+
liblua5.3-dev \
21+
libmnl-dev \
22+
libibverbs-dev
2123

2224
RUN cd /opt && curl -L -s https://dl.google.com/go/go1.11.4.linux-amd64.tar.gz | tar zx
2325

README.md

+10-1
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,15 @@ Requirements in the DPDK Getting Started Guide for
8484
Linux](http://dpdk.org/doc/guides/linux_gsg/sys_reqs.html) for more
8585
information.
8686

87+
Since NFF-Go is build with Mellanox cards support out of the box you
88+
need to install additional dependencies required for MLX network
89+
drivers. On Ubuntu they are called `libmnl-dev` and `libibverbs-dev`.
90+
91+
Additional dependencies are required for pktgen, especially if you are
92+
running RedHat or CentOS Linux distributions. See [this
93+
file](https://git.dpdk.org/apps/pktgen-dpdk/tree/INSTALL.md?h=pktgen-3.5.9&id=d469543f651506a8c9fb7c667a060950c5d92649)
94+
for details. LUA section for RedHat and CentOS is in its end.
95+
8796
After building a DPDK driver with the make command, you must register network
8897
cards to work with the DPDK driver, load necessary kernel modules, and bind
8998
cards to the modules. See [Compiling the DPDK Target from
@@ -95,7 +104,7 @@ in the DPDK Getting Started Guide for Linux for more information.
95104
The kernel module, which is required for DPDK user-mode drivers, is built but
96105
not installed into kernel directory. You can load it using the full path to the
97106
module file:
98-
$GOPATH/src/github.com/intel-go/nff-go/test/dpdk/dpdk-17.08/x86_64-native-linuxapp-gcc/kmod/igb_uio.ko
107+
nff-go/test/dpdk/dpdk/x86_64-native-linuxapp-gcc/kmod/igb_uio.ko
99108

100109
### Go
101110

dpdk/Makefile

+8-9
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2017 Intel Corporation.
1+
# Copyright 2017-2019 Intel Corporation.
22
# Use of this source code is governed by a BSD-style
33
# license that can be found in the LICENSE file.
44

@@ -8,9 +8,7 @@ IMAGENAME = nff-go-pktgen
88
# Pktgen variables
99
NOCHECK_PKTGEN = yes
1010

11-
# Main DPDK variables
12-
DPDK_INSTALL_DIR=$(RTE_TARGET)-install
13-
export WORKDIR=/workdir
11+
include $(PATH_TO_MK)/leaf.mk
1412

1513
# Disable FSGSBASE and F16C to run in VMs and Docker containers.
1614
export EXTRA_CFLAGS = -mno-fsgsbase -mno-f16c
@@ -25,7 +23,9 @@ all: pktgen
2523

2624
$(DPDK_DIR)/$(DPDK_INSTALL_DIR):
2725
$(MAKE) -C $(DPDK_DIR) config T=$(RTE_TARGET)
28-
$(MAKE) -C $(DPDK_DIR) install T=$(RTE_TARGET) DESTDIR=$(DPDK_INSTALL_DIR)
26+
sed -ri 's,(MLX._PMD=)n,\1y,' $(DPDK_DIR)/build/.config
27+
$(MAKE) -C $(DPDK_DIR)
28+
$(MAKE) -C $(DPDK_DIR) install DESTDIR=$(DPDK_INSTALL_DIR)
2929

3030
$(PKTGEN_DIR)/app/$(RTE_TARGET)/pktgen: $(DPDK_DIR)/$(DPDK_INSTALL_DIR)
3131
$(MAKE) -C $(PKTGEN_DIR)
@@ -34,8 +34,7 @@ pktgen: $(PKTGEN_DIR)/app/$(RTE_TARGET)/pktgen
3434
cp $(PKTGEN_DIR)/app/$(RTE_TARGET)/pktgen .
3535

3636
clean:
37-
-$(MAKE) -C $(DPDK_DIR) clean
38-
-rm -rf $(DPDK_DIR)/$(DPDK_INSTALL_DIR) $(DPDK_DIR)/build $(DPDK_DIR)/$(RTE_TARGET)
3937
-$(MAKE) -C $(PKTGEN_DIR) realclean
40-
41-
include $(PATH_TO_MK)/leaf.mk
38+
-rm pktgen
39+
-$(MAKE) -C $(DPDK_DIR) clean
40+
-rm -rf $(DPDK_DIR)/$(DPDK_INSTALL_DIR) $(DPDK_DIR)/build

examples/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ IMAGENAME = nff-go-examples
77
EXECUTABLES = dump clonablePcapDumper kni copy errorHandling timer \
88
createPacket sendFixedPktsNumber gtpu pingReplay \
99
netlink gopacketParserExample devbind
10-
SUBDIRS = tutorial antiddos demo fileReadWrite firewall forwarding
10+
SUBDIRS = tutorial antiddos demo fileReadWrite firewall forwarding ipsec
1111

1212
.PHONY: dpi nffPktgen
1313
dpi:

examples/devbind.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
package main
22

33
import (
4-
"log"
54
"flag"
5+
"log"
66

7+
"github.com/intel-go/nff-go/devices"
78
"github.com/intel-go/nff-go/flow"
89
"github.com/intel-go/nff-go/packet"
9-
"github.com/intel-go/nff-go/devices"
1010
)
1111

1212
// Example that shows how to bind a driver to a NIC

examples/gopacketParserExample.go

+2-8
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ var (
2020

2121
func main() {
2222
flag.BoolVar(&printOn, "print", false, "enable print of parsed layers")
23-
outport1 := flag.Uint("outport1", 1, "port for 1st sender")
24-
outport2 := flag.Uint("outport2", 1, "port for 2nd sender")
23+
outport := flag.Uint("outport", 1, "port for sender")
2524
inport := flag.Uint("inport", 0, "port for receiver")
2625
noscheduler := flag.Bool("no-scheduler", false, "disable scheduler")
2726
flag.Parse()
@@ -40,12 +39,7 @@ func main() {
4039
var ctx gopacketContext
4140
flow.CheckFatal(flow.SetHandler(firstFlow, gopacketHandleFunc, ctx))
4241

43-
// Split for two senders and send
44-
secondFlow, err := flow.SetPartitioner(firstFlow, 150, 150)
45-
flow.CheckFatal(err)
46-
47-
flow.CheckFatal(flow.SetSender(firstFlow, uint16(*outport1)))
48-
flow.CheckFatal(flow.SetSender(secondFlow, uint16(*outport2)))
42+
flow.CheckFatal(flow.SetSender(firstFlow, uint16(*outport)))
4943

5044
flow.SystemStart()
5145
}

examples/gtpu.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ func encap(current *packet.Packet, context flow.UserContext) bool {
8080
ipv4.NextProtoID = common.UDPNumber
8181
ipv4.SrcAddr = packet.BytesToIPv4(11, 22, 33, 44)
8282
ipv4.DstAddr = packet.BytesToIPv4(55, 66, 77, 88)
83-
ipv4.HdrChecksum = packet.CalculateIPv4Checksum(ipv4)
83+
ipv4.HdrChecksum = packet.SwapBytesUint16(packet.CalculateIPv4Checksum(ipv4))
8484

8585
current.ParseL4ForIPv4()
8686
udp := current.GetUDPNoCheck()

examples/ipsec/Makefile

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
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+
PATH_TO_MK = ../../mk
6+
SUBDIRS = stability perf
7+
8+
include $(PATH_TO_MK)/intermediate.mk

examples/ipsec/crypt.go

+122
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
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+
// Only IPv4, Only tunnel, Only ESP, Only AES-128-CBC
6+
package ipsec
7+
8+
import "github.com/intel-go/nff-go/examples/ipsec/crypto_mb"
9+
10+
import "crypto/aes"
11+
import "crypto/cipher"
12+
import "crypto/hmac"
13+
import "crypto/sha1"
14+
import "hash"
15+
16+
const VECTOR = 8
17+
18+
type SContext struct {
19+
mac123 hash.Hash
20+
modeEnc cipher.BlockMode
21+
modeDec cipher.BlockMode
22+
}
23+
24+
type VContext struct {
25+
mac123 crypto_mb.MultiHash
26+
modeEnc crypto_mb.MultiBlockMode
27+
modeDec crypto_mb.MultiBlockMode
28+
29+
vectorEncryptionPart [][]byte
30+
vectorIV [][]byte
31+
vectorAuthPart [][]byte
32+
vectorAuthPlace [][]byte
33+
34+
s SContext
35+
}
36+
37+
type SetIVerM interface {
38+
SetIV([][]byte)
39+
}
40+
41+
type SetIVer interface {
42+
SetIV([]byte)
43+
}
44+
45+
func InitSContext() interface{} {
46+
var auth123Key = []byte("qqqqqqqqqqqqqqqqqqqq")
47+
var crypt123Key = []byte("AES128Key-16Char")
48+
block123, _ := aes.NewCipher(crypt123Key)
49+
50+
tempScalarIV := make([]byte, 16)
51+
52+
n := new(SContext)
53+
n.mac123 = hmac.New(sha1.New, auth123Key)
54+
n.modeEnc = cipher.NewCBCEncrypter(block123, tempScalarIV)
55+
n.modeDec = cipher.NewCBCDecrypter(block123, tempScalarIV)
56+
return n
57+
}
58+
59+
func InitVContext() interface{} {
60+
var auth123Key = []byte("qqqqqqqqqqqqqqqqqqqq")
61+
var crypt123Key = []byte("AES128Key-16Char")
62+
block123 := crypto_mb.NewAESMultiBlock(crypt123Key)
63+
64+
tempVectorIV := make([][]byte, VECTOR, VECTOR)
65+
for i := 0; i < VECTOR; i++ {
66+
tempVectorIV[i] = make([]byte, 16)
67+
}
68+
69+
n := new(VContext)
70+
n.mac123 = crypto_mb.NewHmac(crypto_mb.New, auth123Key)
71+
n.modeEnc = crypto_mb.NewMultiCBCEncrypter(block123, tempVectorIV)
72+
n.modeDec = crypto_mb.NewMultiCBCDecrypter(block123, tempVectorIV)
73+
n.vectorEncryptionPart = make([][]byte, VECTOR, VECTOR)
74+
n.vectorIV = make([][]byte, VECTOR, VECTOR)
75+
n.vectorAuthPart = make([][]byte, VECTOR, VECTOR)
76+
n.vectorAuthPlace = make([][]byte, VECTOR, VECTOR)
77+
n.s = *InitSContext().(*SContext)
78+
return n
79+
}
80+
81+
func (c SContext) Copy() interface{} {
82+
return InitSContext()
83+
}
84+
85+
func (c VContext) Copy() interface{} {
86+
return InitVContext()
87+
}
88+
89+
func (c SContext) Delete() {
90+
}
91+
92+
func (c VContext) Delete() {
93+
}
94+
95+
func Encrypt(EncryptionPart [][]byte, where [][]byte, IV [][]byte, Z uint, context *VContext) {
96+
if Z != VECTOR {
97+
for t := uint(0); t < Z; t++ {
98+
context.s.modeEnc.(SetIVer).SetIV(IV[t])
99+
context.s.modeEnc.CryptBlocks(EncryptionPart[t], where[t])
100+
}
101+
} else {
102+
context.modeEnc.(SetIVerM).SetIV(IV[:])
103+
context.modeEnc.CryptManyBlocks(EncryptionPart, where)
104+
}
105+
}
106+
107+
func Authenticate(AuthenticationPart [][]byte, where [][]byte, Z uint, context *VContext) {
108+
if Z != VECTOR {
109+
for t := uint(0); t < Z; t++ {
110+
context.s.mac123.Reset()
111+
context.s.mac123.Write(where[t])
112+
copy(where[t], context.s.mac123.Sum(nil))
113+
}
114+
} else {
115+
context.mac123.Reset()
116+
context.mac123.Write(context.vectorAuthPart)
117+
temp := context.mac123.Sum(nil)
118+
for t := uint(0); t < VECTOR; t++ {
119+
copy(where[t], temp[t])
120+
}
121+
}
122+
}

examples/ipsec/crypto_mb/aes.go

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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+
package crypto_mb
6+
7+
//TODO check cpuid
8+
9+
type aes_x8 struct {
10+
blockSize int
11+
enc []uint32
12+
dec []uint32
13+
}
14+
15+
func (this *aes_x8) BlockSize() int {
16+
return this.blockSize
17+
}
18+
19+
func (this *aes_x8) VecSize() int {
20+
return 8
21+
}
22+
23+
//TODO accept number of blocks
24+
func NewAESMultiBlock(key []byte) MultiBlock {
25+
if len(key) != 16 {
26+
// TODO return error?
27+
panic("For now only 16-byte keys are supported")
28+
}
29+
n := len(key) + 28
30+
rounds := 10
31+
c := aes_x8{len(key), make([]uint32, n), make([]uint32, n)}
32+
expandKeyAsm(rounds, &key[0], &c.enc[0], &c.dec[0])
33+
return &c
34+
}
35+
36+
// in aes.s
37+
//go:noescape
38+
func encrypt8BlocksAsm(xk *uint32, dst, src [][]byte)
39+
40+
func (this *aes_x8) DecryptMany(dst, src [][]byte) {
41+
panic("Not implemented yet")
42+
}

0 commit comments

Comments
 (0)