-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement draft-ietf-opsawg-ipfix-on-path-telemetry #21
Merged
Merged
Changes from 7 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
adc2718
Add func to get timestamp from packets into xdp
Yuya9786 e8db30c
Add ipfix path delay definitions
Yuya9786 1a17ef6
Add func to parse packets received from xdp
Yuya9786 2a48e32
Add getting IOAM timestamp from xdp into meter
Yuya9786 42d7c0b
Move modules related to parse packets to internal
Yuya9786 b2d0456
Add SPDX license identifiers to xdp codes
Yuya9786 dcb4c98
Update README
Yuya9786 dbfc2be
Update xdp test
Yuya9786 3f8b09e
Fix to use fmt.Errorf instead of errors.New
Yuya9786 1b7cdaa
Update README about the configuration of interval
Yuya9786 88babb2
Use last entry to parse srv6 segment list
Yuya9786 6e1766e
Fix required modules in tools
Yuya9786 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
package meter | ||
|
||
import ( | ||
"errors" | ||
"fmt" | ||
|
||
"github.com/google/gopacket" | ||
"github.com/google/gopacket/layers" | ||
) | ||
|
||
const MAX_SEGMENTLIST_ENTRIES = 10 | ||
|
||
type ProbeData struct { | ||
H_source string | ||
H_dest string | ||
V6Srcaddr string | ||
V6Dstaddr string | ||
NextHdr uint8 | ||
HdrExtLen uint8 | ||
RoutingType uint8 | ||
SegmentsLeft uint8 | ||
LastEntry uint8 | ||
Flags uint8 | ||
Tag uint16 | ||
Segments [MAX_SEGMENTLIST_ENTRIES]string | ||
} | ||
|
||
func Parse(data []byte) (*ProbeData, error) { | ||
var pd ProbeData | ||
packet := gopacket.NewPacket(data, layers.LayerTypeEthernet, gopacket.Default) | ||
|
||
ethLayer := packet.Layer(layers.LayerTypeEthernet) | ||
eth, ok := ethLayer.(*layers.Ethernet) | ||
if !ok { | ||
return nil, errors.New("Could not parse a packet with Ethernet") | ||
} | ||
|
||
pd.H_dest = eth.DstMAC.String() | ||
pd.H_source = eth.SrcMAC.String() | ||
|
||
ipv6Layer := packet.Layer(layers.LayerTypeIPv6) | ||
ipv6, ok := ipv6Layer.(*layers.IPv6) | ||
if !ok { | ||
return nil, errors.New("Could not parse a packet with IPv6") | ||
} | ||
|
||
pd.V6Srcaddr = ipv6.SrcIP.String() | ||
pd.V6Dstaddr = ipv6.DstIP.String() | ||
|
||
if ipv6.NextHeader != layers.IPProtocolIPv6HopByHop { | ||
return nil, errors.New(fmt.Sprintf("Next header is not IPv6 hop-by-hop(0): %d", ipv6.NextHeader)) | ||
} | ||
|
||
ipv6HBHLayer := packet.Layer(layers.LayerTypeIPv6HopByHop) | ||
hbh, ok := ipv6HBHLayer.(*layers.IPv6HopByHop) | ||
if !ok { | ||
return nil, errors.New("Could not parse a packet with ipv6 hop-by-hop option") | ||
} | ||
|
||
if hbh.NextHeader != layers.IPProtocolIPv6Routing { | ||
return nil, errors.New(fmt.Sprintf("Next header is not SRv6: %d", hbh.NextHeader)) | ||
} | ||
|
||
packet = gopacket.NewPacket(ipv6HBHLayer.LayerPayload(), Srv6LayerType, gopacket.Lazy) | ||
srv6Layer := packet.Layer(Srv6LayerType) | ||
srv6, ok := srv6Layer.(*Srv6Layer) | ||
if !ok { | ||
return nil, errors.New("Could not parse a packet with SRv6") | ||
} | ||
|
||
pd.NextHdr = srv6.NextHeader | ||
pd.HdrExtLen = srv6.HdrExtLen | ||
pd.RoutingType = srv6.RoutingType | ||
pd.SegmentsLeft = srv6.SegmentsLeft | ||
pd.LastEntry = srv6.LastEntry | ||
pd.Flags = srv6.Flags | ||
pd.Tag = srv6.Tag | ||
|
||
for idx := 0; idx < MAX_SEGMENTLIST_ENTRIES; idx++ { | ||
if idx >= len(srv6.Segments) { | ||
break | ||
} | ||
pd.Segments[idx] = srv6.Segments[idx].String() | ||
} | ||
|
||
return &pd, nil | ||
} |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Binary file not shown.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Binary file not shown.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice if the readme could understand how to use this option.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wrote how to configure interval in getting-started.md