Skip to content

Commit

Permalink
Merge pull request #2 from intel-go/develop
Browse files Browse the repository at this point in the history
Implemented performance tests based on wrk benchmark. Fixed TCP6 port reuse bug.
  • Loading branch information
gshimansky authored Nov 15, 2018
2 parents 3aed6fd + 2ea6357 commit 218f14b
Show file tree
Hide file tree
Showing 14 changed files with 1,142 additions and 100 deletions.
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,10 @@
*~
doc
nff-go-nat

nat-stabilityresults
nat-vlan-stabilityresults
nat-perfresults
nat-vlan-perfresults
linux-nat-perfresults
linux-nat-vlan-perfresults
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[submodule "test/wrk"]
path = test/wrk
url = https://github.com/wg/wrk.git
[submodule "test/httpperfserv"]
path = test/httpperfserv
url = https://github.com/gshimansky/httpperfserv
4 changes: 4 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ WORKDIR /workdir
COPY nff-go-nat .
COPY client/client .

# Test applications
COPY test/httpperfserv/httpperfserv .
COPY test/wrk/wrk .

# Configs without VLANs
COPY config.json .
COPY config-vlan.json .
Expand Down
20 changes: 19 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# --------- General build rules

.PHONY: all
all: nff-go-nat client/client
all: nff-go-nat client/client httpperfserv wrk

.PHONY: debug
debug: | .set-debug all
Expand All @@ -20,10 +20,20 @@ client/client: .check-env Makefile client/client.go
nff-go-nat: .check-env Makefile nat.go $(wildcard nat/*.go)
go build $(GO_COMPILE_FLAGS)

.PHONY: httpperfserv
httpperfserv:
cd test/httpperfserv && go build $(GO_COMPILE_FLAGS)

.PHONY: wrk
wrk:
$(MAKE) -C test/wrk

.PHONY: clean
clean:
-rm nff-go-nat
-rm client/client
-rm test/httpperfserv/httpperfserv
$(MAKE) -C test/wrk clean

# --------- Docker images build rules

Expand Down Expand Up @@ -96,6 +106,14 @@ test-performance: .check-test-env test/perf-nat.json
test-performance-vlan: .check-test-env test/perf-nat-vlan.json
$(NFF_GO)/test/framework/main/tf -directory nat-vlan-perfresults -config test/perf-nat-vlan.json -hosts $(NFF_GO_HOSTS)

.PHONY: test-linux-performance
test-linux-performance: .check-test-env test/perf-nat-linux.json
$(NFF_GO)/test/framework/main/tf -directory linux-nat-perfresults -config test/perf-nat-linux.json -hosts $(NFF_GO_HOSTS)

.PHONY: test-linux-performance-vlan
test-linux-performance-vlan: .check-test-env test/perf-nat-linux-vlan.json
$(NFF_GO)/test/framework/main/tf -directory linux-nat-vlan-perfresults -config test/perf-nat-linux-vlan.json -hosts $(NFF_GO_HOSTS)

# --------- Utility rules

.PHONY: .check-env
Expand Down
9 changes: 7 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,13 @@ module github.com/intel-go/nff-go-nat
require (
github.com/golang/protobuf v1.2.0
github.com/google/gopacket v1.1.16-0.20181023151400-a35e09f9f224
github.com/intel-go/nff-go v0.0.0-20181025212503-86076d68cc4a
github.com/gopherjs/gopherjs v0.0.0-20181103185306-d547d1d9531e // indirect
github.com/intel-go/nff-go v0.6.2
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d // indirect
github.com/smartystreets/goconvey v0.0.0-20181108003508-044398e4856c // indirect
github.com/vishvananda/netlink v1.0.0
golang.org/x/net v0.0.0-20180926154720-4dfa2610cdf3
golang.org/x/net v0.0.0-20181114220301-adae6a3d119a
golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8 // indirect
golang.org/x/tools v0.0.0-20181115190406-fc2e60c3c3d9 // indirect
google.golang.org/grpc v1.15.0
)
13 changes: 13 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ github.com/google/gopacket v1.1.15/go.mod h1:UCLx9mCmAwsVbn6qQl1WIEt2SO7Nd2fD0th
github.com/google/gopacket v1.1.16-0.20181023151400-a35e09f9f224 h1:78xLKlzgK/iEGI5iyrSMXEZu+kRRT+s08QqpSXonq7o=
github.com/google/gopacket v1.1.16-0.20181023151400-a35e09f9f224/go.mod h1:UCLx9mCmAwsVbn6qQl1WIEt2SO7Nd2fD0th1TBAsqBw=
github.com/gopherjs/gopherjs v0.0.0-20180825215210-0210a2f0f73c/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
github.com/gopherjs/gopherjs v0.0.0-20181103185306-d547d1d9531e/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk=
github.com/intel-go/nff-go v0.0.0-20180921201744-1fbebd4fd0f2 h1:KDM+zxw97jpFJq9oKfvHT4dguYvHVz45Ax9b5+VFZkk=
Expand All @@ -26,14 +27,20 @@ github.com/intel-go/nff-go v0.0.0-20181002212532-f4887690e204 h1:qty4fLwai6XppC+
github.com/intel-go/nff-go v0.0.0-20181002212532-f4887690e204/go.mod h1:a8QAG6+aP/tFdsETySIAsI6dEuLT4/iI549Cxz6CubQ=
github.com/intel-go/nff-go v0.0.0-20181025212503-86076d68cc4a h1:z1pdHMktxBobC29+8b4nhP5+QpImMHuoYND0cXrgpkQ=
github.com/intel-go/nff-go v0.0.0-20181025212503-86076d68cc4a/go.mod h1:n+oCFN0hmbHg1l3ifQcowWg7sRcHaGpm+OWm6s8NKBk=
github.com/intel-go/nff-go v0.0.0-20181115164934-cccb9e9ee2c8 h1:4dvw2gcszp0UN4lBZOHjTv3rS0JCCqhCxhcAHI9GHOQ=
github.com/intel-go/nff-go v0.0.0-20181115164934-cccb9e9ee2c8/go.mod h1:n+oCFN0hmbHg1l3ifQcowWg7sRcHaGpm+OWm6s8NKBk=
github.com/intel-go/nff-go v0.6.1 h1:C4BX9X52MtzQbEaFhT0RFl/mbKNQq5byn5/byK0Q6Vs=
github.com/intel-go/nff-go v0.6.1/go.mod h1:n+oCFN0hmbHg1l3ifQcowWg7sRcHaGpm+OWm6s8NKBk=
github.com/intel-go/nff-go v0.6.2 h1:IfIV8ucmQ4eQnQuStvx44gd2PyMS6xAauFPnWKXNGFg=
github.com/intel-go/nff-go v0.6.2/go.mod h1:n+oCFN0hmbHg1l3ifQcowWg7sRcHaGpm+OWm6s8NKBk=
github.com/jtolds/gls v4.2.1+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/pkg/errors v0.8.0 h1:WdK/asTD0HN+q6hsWO3/vpuAkAr+tw6aNJNDFFf0+qw=
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/smartystreets/assertions v0.0.0-20180820201707-7c9eb446e3cf/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
github.com/smartystreets/goconvey v0.0.0-20180222194500-ef6db91d284a/go.mod h1:XDJAKZRPZ1CvBcN2aX5YOUTYGHki24fSF0Iv48Ibg0s=
github.com/smartystreets/goconvey v0.0.0-20181108003508-044398e4856c/go.mod h1:XDJAKZRPZ1CvBcN2aX5YOUTYGHki24fSF0Iv48Ibg0s=
github.com/vishvananda/netlink v1.0.0 h1:bqNY2lgheFIu1meHUFSH3d7vG93AFyqg3oGbJCOJgSM=
github.com/vishvananda/netlink v1.0.0/go.mod h1:+SR5DhBJrl6ZM7CoCKvpw5BKroDKQ+PJqOg65H/2ktk=
github.com/vishvananda/netns v0.0.0-20180720170159-13995c7128cc h1:R83G5ikgLMxrBvLh22JhdfI8K6YXEPHx5P03Uu3DRs4=
Expand All @@ -42,17 +49,23 @@ golang.org/x/lint v0.0.0-20180702182130-06c8688daad7/go.mod h1:UVdnD1Gm6xHRNCYTk
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180926154720-4dfa2610cdf3 h1:dgd4x4kJt7G4k4m93AYLzM8Ni6h2qLTfh9n9vXJT3/0=
golang.org/x/net v0.0.0-20180926154720-4dfa2610cdf3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20181114220301-adae6a3d119a h1:gOpx8G595UYyvj8UK4+OFyY4rx037g3fmfhe5SasG3U=
golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f h1:wMNYb4v58l5UBM7MYRLPG6ZhfOqbKu7X5eyFl8ZhKvA=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522 h1:Ve1ORMCxvRmSXBwJK+t3Oy+V2vRW2OetUQBq4rJIkZE=
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20181004145325-8469e314837c h1:SJ7JoQNVl3mC7EWkkONgBWgCno8LcABIJwFMkWBC+EY=
golang.org/x/sys v0.0.0-20181004145325-8469e314837c/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8 h1:YoY1wS6JYVRpIfFngRf2HHo9R9dAne3xbkGOQ5rJXjU=
golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20181002223833-cd09f19c2f7e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20181115162256-f62bfb541538/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20181115190406-fc2e60c3c3d9/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8 h1:Nw54tB0rB7hY/N0NQvRW8DG4Yk3Q6T9cu9RcFQDu1tc=
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
Expand Down
3 changes: 2 additions & 1 deletion nat/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ const (
)

var (
zeroIPv6Addr = [common.IPv6AddrLen]uint8{}
zeroIPv6Addr = [common.IPv6AddrLen]uint8{}
portReuseSetLastusedTime = time.Duration(portReuseTimeout - connectionTimeout)
)

type hostPort struct {
Expand Down
8 changes: 4 additions & 4 deletions nat/translation.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func (pp *portPair) allocateNewEgressConnection(ipv6 bool, protocol uint8, privE
}
}

pp.PublicPort.getPortmap(ipv6, protocol)[port] = portMapEntry{
pp.getPublicPortPortmap(ipv6, protocol)[port] = portMapEntry{
lastused: time.Now(),
finCount: 0,
terminationDirection: 0,
Expand Down Expand Up @@ -380,7 +380,7 @@ func (pp *portPair) checkTCPTermination(ipv6 bool, hdr *packet.TCPHdr, port int,
// First check for FIN
pp.mutex.Lock()

pme := &pp.PublicPort.portmap[common.TCPNumber][port]
pme := &pp.getPublicPortPortmap(ipv6, common.TCPNumber)[port]
if pme.finCount == 0 {
pme.finCount = 1
pme.terminationDirection = dir
Expand All @@ -400,12 +400,12 @@ func (pp *portPair) checkTCPTermination(ipv6 bool, hdr *packet.TCPHdr, port int,
// FIN
pp.mutex.Lock()

pme := &pp.PublicPort.portmap[common.TCPNumber][port]
pme := &pp.getPublicPortPortmap(ipv6, common.TCPNumber)[port]
if pme.finCount == 2 {
pp.deleteOldConnection(ipv6, common.TCPNumber, port)
// Set some time while port cannot be used before
// connection timeout is reached
pme.lastused = time.Now().Add(time.Duration(portReuseTimeout - connectionTimeout))
pme.lastused = time.Now().Add(portReuseSetLastusedTime)
}

pp.mutex.Unlock()
Expand Down
1 change: 1 addition & 0 deletions test/httpperfserv
Submodule httpperfserv added at 269f1c
Loading

0 comments on commit 218f14b

Please sign in to comment.