Skip to content
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

filter, action: Add support for tunnel_key #499

Merged
merged 1 commit into from
Dec 3, 2019

Conversation

zhiyuan0x
Copy link
Contributor

Add support for tunnel_key

@BSWANG
Copy link
Contributor

BSWANG commented Nov 19, 2019

LGTM

@zhiyuan0x zhiyuan0x force-pushed the feature/tunnel_key branch 2 times, most recently from af98a13 to 0677801 Compare November 27, 2019 12:12
@zhiyuan0x
Copy link
Contributor Author

@vishvananda @aboch can this PR be merged? thanks.

filter_linux.go Outdated
if v4 := action.SrcAddr.To4(); v4 != nil {
aopts.AddRtAttr(nl.TCA_TUNNEL_KEY_ENC_IPV4_SRC, v4[:])
} else {
aopts.AddRtAttr(nl.TCA_TUNNEL_KEY_ENC_IPV6_SRC, action.SrcAddr.To16()[:])
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why To16() if you already know it is a IPv6 address?
https://golang.org/src/net/ip.go?s=5477:5499#L199

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have fixed it. thanks.

@zhiyuan0x
Copy link
Contributor Author

@aboch fixed it. thanks.

aopts.AddRtAttr(nl.TCA_TUNNEL_KEY_ENC_KEY_ID, htonl(action.KeyID))
if v4 := action.SrcAddr.To4(); v4 != nil {
aopts.AddRtAttr(nl.TCA_TUNNEL_KEY_ENC_IPV4_SRC, v4[:])
} else if v6 := action.SrcAddr.To16(); v6 != nil {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aboch In golang, ip address is a simple slice and does not have an address family flag. So if IP.To4() return a nil and IP.To16() reutrn a not nil, It should be ipv6 address.
This is a similar code: https://golang.org/src/net/ip.go#L420 .

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

filter_linux.go Show resolved Hide resolved
@aboch
Copy link
Collaborator

aboch commented Dec 3, 2019

LGTM

@aboch aboch merged commit e25c252 into vishvananda:master Dec 3, 2019
@zhiyuan0x zhiyuan0x deleted the feature/tunnel_key branch December 6, 2019 01:07
zhiyuan0x pushed a commit to zhiyuan0x/terway that referenced this pull request Dec 9, 2019
The PR vishvananda/netlink#499 has been
merged, update vendor to point new commit.

Signed-off-by: Zhiyuan Hou <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants