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

IPv6 address not handled properly for Gretun #316

Closed
KireinaHoro opened this issue Jan 18, 2018 · 3 comments
Closed

IPv6 address not handled properly for Gretun #316

KireinaHoro opened this issue Jan 18, 2018 · 3 comments

Comments

@KireinaHoro
Copy link

In iproute2, IPv6 GRE tunnels are called "ip6gre"'s. The current implementation will result in mysterious "file exists" errors when trying to add a Gretun object.

@aboch
Copy link
Collaborator

aboch commented Jan 18, 2018

Thank you for reporting this. Please post a sample go code which shows the issue, and we will go from there, unless you are already working to a patch for it.

@KireinaHoro
Copy link
Author

@aboch

package main

import (
    "github.com/vishvananda/netlink"
    "log"
    "net"
    "fmt"
)

func main() {
    la := netlink.NewLinkAttrs()
    la.Name = "foobar"

    l, err := netlink.LinkByName(la.Name)
    if err == nil {
        log.Fatalf("Link with name %s already exists: %v", la.Name, err) // HERE
    } else {
        myGretun := &netlink.Gretun{LinkAttrs: la}
        myGretun.Remote = net.ParseIP("2001:da8::1")
        myGretun.Local = net.ParseIP("2001:da8::2")
        err := netlink.LinkAdd(myGretun)
        if err != nil {
            log.Fatalf("Could not add %s: %v", la.Name, err)
        }
        l = myGretun
    }
    fmt.Printf("Information about the created link: %v", l)
}

If the file exists comes from an existing interface foobar, we'll get the error message from the line where HERE marked. Yet it's not behaving that way. The message I get is:

2018/01/19 02:39:06 Could not add foobar: file exists

@aboch
Copy link
Collaborator

aboch commented Jan 19, 2018

Thank you.

Yes, the GRE link add part assumes local/remote addresses must be IPv4.
So when you pass v6 addresses, netlink msg to kernel will have nil local/remote IP.
The returned error is misleading.

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

No branches or pull requests

2 participants