-
Notifications
You must be signed in to change notification settings - Fork 125
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
API for GRE #1445
API for GRE #1445
Conversation
@@ -22,6 +22,7 @@ message Interface { | |||
IPSEC_TUNNEL = 8; | |||
VMXNET3_INTERFACE = 9; | |||
BOND_INTERFACE = 10; | |||
GRE = 11; |
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.
This should be GRE_TUNNEL
to match with other tunnel types.
Type tunnel_type = 1; | ||
string src_addr = 2; | ||
string dst_addr = 3; | ||
uint32 outerFibID = 4; |
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.
Instance uint32 | ||
IsIPv6 uint8 | ||
TunnelType uint8 | ||
SrcAddress string |
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.
Using type net.IP
here, will allow you to get rid of IsIPv6
.
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.
not sure if this will help. As I understand, you are saying about checking IsIPv6
in dump function:
if greDetails.IsIPv6 == 1 { ...
But in greDetails
addresses comes as []byte
and, for example, ip 10.10.10.10
will be presented as [10 10 10 10 0 0 0 0 0 0 0 0 0 0 0 0]
, on the other hand ip 2019::8:23
will be presented as [32 25 0 0 0 0 0 0 0 0 0 0 0 8 0 35]
.
If I do not check IsIPv6
and not slice this slice if it's IPv4, then String()
method on such net.IP
in a case with 10.10.10.10
will return a0a:a0a::
and this is definitely not what I've expected to see.
One thing is actually redundant is calling To4()
and To16()
, because slice was already trimmed to proper size.
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.
What I meant was to use the net.IP
values parsed in dump:
vpp-agent/plugins/vpp/ifplugin/vppcalls/vpp1904/gre_vppcalls.go
Lines 108 to 109 in cd0dc98
srcAddr = net.IP(greDetails.SrcAddress).To16().String() | |
dstAddr = net.IP(greDetails.DstAddress).To16().String() |
And store as net.IP
here:
vpp-agent/plugins/vpp/ifplugin/vppcalls/vpp1904/gre_vppcalls.go
Lines 120 to 121 in cd0dc98
SrcAddress: srcAddr, | |
DstAddress: dstAddr, |
And the caller who calls dump can simply use the addresses directly without parsing them from string again. You can easily check if net.IP
is IPv4 or IPv6:
ip4 := net.ParseIP("10.0.1.1")
fmt.Println(ip4)
fmt.Printf("is IPv6: %v\n\n", ip4.To4() == nil) // prints false
ip6 := net.ParseIP("fe80::200:5aee:feaa:20a2")
fmt.Println(ip6)
fmt.Printf("is IPv6: %v\n", ip6.To4() == nil) // prints true
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.
oh I see now. Yes, it would be better to keep IP addresses as net.IP
t.Run(test.name, func(t *testing.T) { | ||
ifIdx, err := h.AddGreTunnel(fmt.Sprintf("test%d", i), test.greLink) | ||
|
||
if err != nil { |
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'm not sure this will handle test case where we expect some non-nil error, but it gets nil
.
Manual tests with localclient: VPP was not restarted during this tests Definition of ERSPAN GRE tunnel in code
var (
greInterface = &vpp_interfaces.Interface{
Name: "myGreInterface",
Type: vpp_interfaces.Interface_GRE_TUNNEL,
Enabled: true,
Link: &vpp_interfaces.Interface_Gre{
Gre: &vpp_interfaces.GreLink{
TunnelType: vpp_interfaces.GreLink_ERSPAN,
SrcAddr: "10.10.10.10",
DstAddr: "20.20.20.20",
},
},
}
) Create ERSPAN
Restart Agent (without restarting VPP)
Disable interface
Change "Source" for GRE tunnel
Enable interface
Stop Agent, change source address and start Agent again
Stop Agent, add one more GRE tunnel in code, start Agent
Output from vppctl after all of this
|
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.
Good job! Also thanks for the summary of manual tests. Soon we will have a framework to write end-to-end tests as Go UTs (just like we have integration tests for vppcalls), so it will be possible to automate all of that.
* Add GRE VPP calls. Add GRE type and link to inteface message * add basic validation and support of create and delete operations for GRE * Rename things. Store addresses as net.IP * add GRE to interfaces dump * Add UNKNOWN to types of GRE tunnel * Support vpp1901 and vpp1908 * Test also removing of GRE tunnel
This PR implements GRE tunnel interface from #1387