Skip to content

Commit

Permalink
Merge pull request #1 from intel-go/develop
Browse files Browse the repository at this point in the history
Bugfix release 0.6.2
  • Loading branch information
gshimansky authored Nov 6, 2018
2 parents 273bd0e + 36a5312 commit 3aed6fd
Show file tree
Hide file tree
Showing 21 changed files with 1,164 additions and 184 deletions.
23 changes: 20 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2017 Intel Corporation.
# Copyright 2017-2018 Intel Corporation.
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.

Expand All @@ -7,14 +7,31 @@ FROM ${USER_NAME}/nff-go-base

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

RUN dnf -y install iputils httpd wget; dnf clean all
RUN dnf -y install procps-ng iputils httpd wget; dnf clean all
RUN dd if=/dev/zero of=/var/www/html/10k.bin bs=1 count=10240
RUN dd if=/dev/zero of=/var/www/html/100k.bin bs=1 count=102400
RUN dd if=/dev/zero of=/var/www/html/1m.bin bs=1 count=1048576

# The following command cannot be executed at build stage but is
# required for IPv6 KNI interfaces, so it should be executed when
# container is ran
# RUN sysctl -w net.ipv6.conf.all.disable_ipv6=0

WORKDIR /workdir
COPY nat .

# NAT executables
COPY nff-go-nat .
COPY client/client .

# Configs without VLANs
COPY config.json .
COPY config-vlan.json .
COPY config-dhcp.json .

# Configs with VLANs
COPY config-kni.json .
COPY config-kni-vlan.json .
COPY config-kni-dhcp.json .

# Two ports config
COPY config2ports.json .
25 changes: 16 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,27 @@
.PHONY: all
all: nff-go-nat client/client

.PHONY: debug
debug: | .set-debug all

.PHONY: .set-debug
.set-debug:
$(eval GO_COMPILE_FLAGS := -gcflags=all='-N -l')

client/client: .check-env Makefile client/client.go
cd client && go build
cd client && go build $(GO_COMPILE_FLAGS)

nff-go-nat: .check-env Makefile nat.go $(wildcard nat/*.go)
go build
go build $(GO_COMPILE_FLAGS)

.PHONY: clean
clean:
-rm nat
-rm nff-go-nat
-rm client/client

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

IMAGENAME=nat
IMAGENAME=nff-go-nat
BASEIMAGE=nff-go-base
# Add user name to generated images
ifdef NFF_GO_IMAGE_PREFIX
Expand Down Expand Up @@ -71,23 +78,23 @@ cleanall: .check-deploy-env clean-images
# --------- Test execution rules

.PHONY: .check-test-env
.check-test-env: .check-defined-NFF_GO $(NFF_GO)/test/framework/main/tf
.check-test-env: .check-defined-NFF_GO .check-defined-NFF_GO_HOSTS $(NFF_GO)/test/framework/main/tf

.PHONY: test-stability
test-stability: .check-test-env test/stability-nat.json
$(NFF_GO)/test/framework/main/tf test/stability-nat.json
$(NFF_GO)/test/framework/main/tf -directory nat-stabilityresults -config test/stability-nat.json -hosts $(NFF_GO_HOSTS)

.PHONY: test-stability-vlan
test-stability-vlan: .check-test-env test/stability-nat-vlan.json
$(NFF_GO)/test/framework/main/tf test/stability-nat-vlan.json
$(NFF_GO)/test/framework/main/tf -directory nat-vlan-stabilityresults -config test/stability-nat-vlan.json -hosts $(NFF_GO_HOSTS)

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

.PHONY: test-performance-vlan
test-performance-vlan: .check-test-env test/perf-nat-vlan.json
$(NFF_GO)/test/framework/main/tf 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)

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

Expand Down
8 changes: 8 additions & 0 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ func (acra *addresChangeRequestArray) Set(value string) error {
if err != nil {
return err
}
ip4 := ip.To4()
if ip4 != nil {
ip = ip4
}
ones, _ := ipnet.Mask.Size()

*acra = append(*acra, &upd.InterfaceAddressChangeRequest{
Expand Down Expand Up @@ -145,6 +149,10 @@ func (pfra *portForwardRequestArray) Set(value string) error {
if ip == nil {
return fmt.Errorf("Bad IP address specified \"%s\"", parts[4])
}
ip4 := ip.To4()
if ip4 != nil {
ip = ip4
}

tport, err := strconv.ParseUint(parts[5], 10, 16)
if err != nil {
Expand Down
42 changes: 42 additions & 0 deletions config-kni-vlan.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"port-pairs": [
{
"private-port": {
"index": 0,
"subnet": "192.168.114.1/24",
"subnet6": "fd84::1/64",
"kni-name": "priv0",
"vlan-tag": 114
},
"public-port": {
"index": 1,
"subnet": "192.168.116.1/24",
"subnet6": "fd86::1/64",
"kni-name": "pub1",
"vlan-tag": 116,
"forward-ports": [
{
"port": 8080,
"destination": "192.168.114.2:80",
"protocol": "TCP"
},
{
"port": 8080,
"destination": "[fd84::2]:80",
"protocol": "TCP6"
},
{
"port": 2222,
"destination": "192.168.114.2:22",
"protocol": "TCP"
},
{
"port": 2222,
"destination": "[fd84::2]:22",
"protocol": "TCP6"
}
]
}
}
]
}
52 changes: 5 additions & 47 deletions config-kni.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,74 +5,32 @@
"index": 0,
"subnet": "192.168.14.1/24",
"subnet6": "fd14::1/64",
"kni-name": "priv0",
"forward-ports": [
{
"port": 22,
"destination": "0.0.0.0:22",
"protocol": "TCP"
},
{
"port": 22,
"destination": "[::]:22",
"protocol": "TCP6"
}
]
"kni-name": "priv0"
},
"public-port": {
"index": 1,
"subnet": "192.168.16.1/24",
"subnet6": "fd16::1/64",
"kni-name": "pub1",
"forward-ports": [
{
"port": 22,
"destination": "0.0.0.0:22",
"protocol": "TCP"
},
{
"port": 22,
"destination": "[::]:22",
"protocol": "TCP6"
},
{
"port": 8080,
"destination": "192.168.14.3:80",
"destination": "192.168.14.2:80",
"protocol": "TCP"
},
{
"port": 8080,
"destination": "[fd14::3]:80",
"destination": "[fd14::2]:80",
"protocol": "TCP6"
},
{
"port": 2222,
"destination": "192.168.14.3:22",
"destination": "192.168.14.2:22",
"protocol": "TCP"
},
{
"port": 2222,
"destination": "[fd14::3]:22",
"protocol": "TCP6"
},
{
"port": 8081,
"destination": "192.168.14.4:80",
"protocol": "TCP"
},
{
"port": 8081,
"destination": "[fd14::4]:80",
"protocol": "TCP6"
},
{
"port": 2223,
"destination": "192.168.14.4:22",
"protocol": "TCP"
},
{
"port": 2223,
"destination": "[fd14::4]:22",
"destination": "[fd14::2]:22",
"protocol": "TCP6"
}
]
Expand Down
26 changes: 25 additions & 1 deletion config-vlan.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,36 @@
"private-port": {
"index": 0,
"subnet": "192.168.114.1/24",
"subnet6": "fd84::1/64",
"vlan-tag": 114
},
"public-port": {
"index": 1,
"subnet": "192.168.116.1/24",
"vlan-tag": 116
"subnet6": "fd86::1/64",
"vlan-tag": 116,
"forward-ports": [
{
"port": 8080,
"destination": "192.168.114.2:80",
"protocol": "TCP"
},
{
"port": 8080,
"destination": "[fd84::2]:80",
"protocol": "TCP6"
},
{
"port": 2222,
"destination": "192.168.114.2:22",
"protocol": "TCP"
},
{
"port": 2222,
"destination": "[fd84::2]:22",
"protocol": "TCP6"
}
]
}
}
]
Expand Down
28 changes: 4 additions & 24 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,42 +13,22 @@
"forward-ports": [
{
"port": 8080,
"destination": "192.168.14.3:80",
"destination": "192.168.14.2:80",
"protocol": "TCP"
},
{
"port": 8080,
"destination": "[fd14::3]:80",
"destination": "[fd14::2]:80",
"protocol": "TCP6"
},
{
"port": 2222,
"destination": "192.168.14.3:22",
"destination": "192.168.14.2:22",
"protocol": "TCP"
},
{
"port": 2222,
"destination": "[fd14::3]:22",
"protocol": "TCP6"
},
{
"port": 8081,
"destination": "192.168.14.4:80",
"protocol": "TCP"
},
{
"port": 8081,
"destination": "[fd14::4]:80",
"protocol": "TCP6"
},
{
"port": 2223,
"destination": "192.168.14.4:22",
"protocol": "TCP"
},
{
"port": 2223,
"destination": "[fd14::4]:22",
"destination": "[fd14::2]:22",
"protocol": "TCP6"
}
]
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ module github.com/intel-go/nff-go-nat

require (
github.com/golang/protobuf v1.2.0
github.com/google/gopacket v1.1.15
github.com/intel-go/nff-go v0.6.1
github.com/google/gopacket v1.1.16-0.20181023151400-a35e09f9f224
github.com/intel-go/nff-go v0.0.0-20181025212503-86076d68cc4a
github.com/vishvananda/netlink v1.0.0
golang.org/x/net v0.0.0-20180926154720-4dfa2610cdf3
google.golang.org/grpc v1.15.0
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5y
github.com/google/gopacket v1.1.14/go.mod h1:UCLx9mCmAwsVbn6qQl1WIEt2SO7Nd2fD0th1TBAsqBw=
github.com/google/gopacket v1.1.15 h1:M6W3hwQXo5rq1wyhRByGhqOw0m9p+HWtUJ3Bj4/fT6E=
github.com/google/gopacket v1.1.15/go.mod h1:UCLx9mCmAwsVbn6qQl1WIEt2SO7Nd2fD0th1TBAsqBw=
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/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=
Expand All @@ -22,6 +24,8 @@ github.com/intel-go/nff-go v0.0.0-20181001202120-5db6c39a9191 h1:NS6qVx9y9FIEdve
github.com/intel-go/nff-go v0.0.0-20181001202120-5db6c39a9191/go.mod h1:a8QAG6+aP/tFdsETySIAsI6dEuLT4/iI549Cxz6CubQ=
github.com/intel-go/nff-go v0.0.0-20181002212532-f4887690e204 h1:qty4fLwai6XppC+fnDOk21OfCYWbnxYiBwnoN3eSE54=
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.6.1 h1:C4BX9X52MtzQbEaFhT0RFl/mbKNQq5byn5/byK0Q6Vs=
github.com/intel-go/nff-go v0.6.1/go.mod h1:n+oCFN0hmbHg1l3ifQcowWg7sRcHaGpm+OWm6s8NKBk=
github.com/jtolds/gls v4.2.1+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
Expand Down
18 changes: 10 additions & 8 deletions nat.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,22 @@ import (

func main() {
// Parse arguments
cores := flag.String("cores", "", "Specify CPU cores to use")
configFile := flag.String("config", "config.json", "Specify config file name")
flag.BoolVar(&nat.NoCalculateChecksum, "nocsum", false, "Specify whether to calculate checksums in modified packets")
flag.BoolVar(&nat.NoHWTXChecksum, "nohwcsum", false, "Specify whether to use hardware offloading for checksums calculation (requires -csum)")
noscheduler := flag.Bool("no-scheduler", false, "disable scheduler")
dpdkLogLevel := flag.String("dpdk", "--log-level=0", "Passes an arbitrary argument to dpdk EAL")
cores := flag.String("cores", "", "Specify CPU cores to use.")
configFile := flag.String("config", "config.json", "Specify config file name.")
flag.BoolVar(&nat.NoCalculateChecksum, "nocsum", false, "Specify whether to calculate checksums in modified packets.")
flag.BoolVar(&nat.NoHWTXChecksum, "nohwcsum", false, "Specify whether to use hardware offloading for checksums calculation (requires -csum).")
noscheduler := flag.Bool("no-scheduler", false, "Disable scheduler.")
setKniIP := flag.Bool("set-kni-IP", false, "Set IP addresses specified in config file to created KNI interfaces. Do not use if your system uses Network Manager! Use Network Manager configurations instead.")
bringUpKniInterfaces := flag.Bool("bring-up-kni", false, "Set IP addresses specified in config file to created KNI interfaces. Do not use if your system uses Network Manager! Use Network Manager configurations instead.")
dpdkLogLevel := flag.String("dpdk", "--log-level=0", "Passes an arbitrary argument to dpdk EAL.")
flag.Parse()

// Set up reaction to SIGINT (Ctrl-C)
c := make(chan os.Signal, 1)
signal.Notify(c, os.Interrupt)

// Read config
flow.CheckFatal(nat.ReadConfig(*configFile))
flow.CheckFatal(nat.ReadConfig(*configFile, *setKniIP, *bringUpKniInterfaces))

// Init NFF-GO system at 16 available cores
nffgoconfig := flow.Config{
Expand Down Expand Up @@ -61,7 +63,7 @@ func main() {
flow.CheckFatal(flow.SystemInitPortsAndMemory())

// Start DHCP client
if nat.NeedDHCP {
if nat.NeedDHCP || *setKniIP {
nat.StartDHCPClient()
}

Expand Down
Loading

0 comments on commit 3aed6fd

Please sign in to comment.