-
Notifications
You must be signed in to change notification settings - Fork 158
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #625 from intel-go/develop
New release 0.8.1
- Loading branch information
Showing
69 changed files
with
1,169 additions
and
224 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule pktgen-dpdk
updated
from 419955 to ae5a88
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,3 +13,5 @@ netlink | |
devbind | ||
OSforwarding | ||
generate | ||
jumbo | ||
decrementTTL |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,3 +21,5 @@ COPY timer . | |
COPY netlink . | ||
COPY generate . | ||
COPY OSforwarding . | ||
COPY jumbo . | ||
COPY decrementTTL . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// Copyright 2017 Intel Corporation. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
package main | ||
|
||
import ( | ||
"flag" | ||
|
||
"github.com/intel-go/nff-go/flow" | ||
"github.com/intel-go/nff-go/packet" | ||
) | ||
|
||
// Main function for constructing packet processing graph. | ||
func main() { | ||
inPort := flag.Uint("inPort", 0, "port for receiver") | ||
outPort := flag.Uint("outPort", 1, "port for sender") | ||
flag.Parse() | ||
|
||
flow.SystemInit(nil) | ||
inputFlow, _ := flow.SetReceiver(uint16(*inPort)) | ||
flow.SetHandlerDrop(inputFlow, decrementTTL, nil) | ||
flow.SetSender(inputFlow, uint16(*outPort)) | ||
flow.SystemStart() | ||
} | ||
|
||
func decrementTTL(current *packet.Packet, c flow.UserContext) bool { | ||
current.ParseL3() // must parse before header can be read | ||
header := current.GetIPv4() | ||
if header == nil { // not IPv4 | ||
return false | ||
} | ||
|
||
header.TimeToLive-- | ||
if header.TimeToLive == 0 { // TTL exceeded, drop | ||
return false | ||
} else { | ||
return true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
// Copyright 2019 Intel Corporation. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
package main | ||
|
||
import ( | ||
"flag" | ||
"fmt" | ||
"github.com/intel-go/nff-go/flow" | ||
"github.com/intel-go/nff-go/packet" | ||
"time" | ||
) | ||
|
||
// You need to enable memory jumbo for maxPacketSegment more than 2014. | ||
// Explanation: internal packet buffers are 2048 bytes, first packet will have | ||
// ethernet and ipv4 headers = 14 + 2 = 34 bytes. | ||
// Buffer will overflows if maxPacketSegment > 2048 - 34 = 2014 bytes | ||
|
||
// Note: usage of 1484 < maxPacketSegment < 2014 without memory jumbo can work | ||
// on some NICs, but is treated as underfined behaviour | ||
// Explanation: in this situation packet will be fit in internal buffers | ||
// however packet will be more than 1518 bytes - Ethernet max non-jumbo frame | ||
const maxPacketSegment = 1484 | ||
|
||
// You need to enale chained jumbo for requiredPacketLength > maxPacketSegment | ||
// Explanation: if required length is more than segment length packet will consist of | ||
// several chained segments. You should enable chained jumbo to correctly handle them | ||
|
||
// Note: usage of maxPacketSegment > 2014 and also requiredPacketLength > maxPacketSegment | ||
// is forbidden. If you decicde to chain packets you shouldn't chain non-standart packets | ||
// Explanation: in this situation you will need to enable both | ||
// memory and chained jumbo and this is forbidden | ||
const requiredPacketLength = 7000 | ||
|
||
func main() { | ||
chained := flag.Bool("chained", false, "enable chained jumbo") | ||
memory := flag.Bool("memory", false, "enalbe memory jumbo") | ||
flag.Parse() | ||
|
||
// Initialize NFF-GO library at 10 available cores | ||
config := flow.Config{ | ||
ChainedJumbo: *chained, | ||
MemoryJumbo: *memory, | ||
} | ||
|
||
flow.CheckFatal(flow.SystemInit(&config)) | ||
|
||
generated := flow.SetGenerator(generate, nil) | ||
flow.SetHandler(generated, dump, nil) | ||
flow.SetSender(generated, 0) | ||
|
||
received, _ := flow.SetReceiver(0) | ||
flow.SetHandler(received, dump, nil) | ||
flow.SetStopper(received) | ||
flow.SystemStart() | ||
} | ||
|
||
func generate(pkt *packet.Packet, context flow.UserContext) { | ||
remain := requiredPacketLength | ||
c := 0 | ||
diff, remain := m(maxPacketSegment, remain) | ||
if packet.InitEmptyIPv4Packet(pkt, diff) == false { | ||
fmt.Printf("maxPacketSegment %d is more than 2014 bytes without enabling memory jumbo\n", maxPacketSegment) | ||
time.Sleep(5 * time.Second) | ||
return | ||
} | ||
pkt.Ether.DAddr = [6]uint8{0x00, 0x11, 0x22, 0x33, 0x44, 0x55} | ||
for i := 0; i < maxPacketSegment; i++ { | ||
(*(*[maxPacketSegment]byte)(pkt.Data))[i] = byte(c % 10) | ||
c++ | ||
} | ||
for remain != 0 { | ||
diff, remain = m(maxPacketSegment, remain) | ||
pkt = packet.InitNextPacket(diff, pkt) | ||
for i := 0; i < maxPacketSegment; i++ { | ||
(*(*[maxPacketSegment]byte)(pkt.Data))[i] = byte(c % 10) | ||
c++ | ||
} | ||
} | ||
time.Sleep(1 * time.Second) | ||
} | ||
|
||
func m(max int, remain int) (uint, int) { | ||
if remain > max { | ||
return uint(max), remain - max | ||
} else { | ||
return uint(remain), 0 | ||
} | ||
} | ||
|
||
func dump(currentPacket *packet.Packet, context flow.UserContext) { | ||
fmt.Println("NEW PACKET") | ||
fmt.Printf("BLOCK\n%x\nEND_BLOCK\n", currentPacket.GetRawPacketBytes()) | ||
for currentPacket.Next != nil { | ||
currentPacket = currentPacket.Next | ||
fmt.Printf("BLOCK\n%x\nEND_BLOCK\n", currentPacket.GetRawPacketBytes()) | ||
} | ||
fmt.Println("END PACKET") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.