Skip to content

Conversation

@aboch
Copy link
Collaborator

@aboch aboch commented Jan 19, 2018

Fixes #316

Also the changes allow to re-enable TestLinkAddDelGretapFlowBased

@aboch
Copy link
Collaborator Author

aboch commented Jan 19, 2018

ping @KireinaHoro Please give it a try too.

Signed-off-by: Alessandro Boch <[email protected]>
@KireinaHoro
Copy link

The link-add part works now. I'm trying to find a way to add an address to the link and bring it up though...

@KireinaHoro
Copy link

Seems like it's working fine. I've tested with the following:

package main

import (
    "github.com/aboch/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", la.Name)
    }
    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
    addr, err := netlink.ParseAddr("172.16.0.1/32")
    if err != nil {
        netlink.LinkDel(myGretun)
        log.Fatalf("Failed to parse address: %v", err)
    }
    netlink.AddrAdd(l, addr)
    netlink.LinkSetUp(l)
    fmt.Printf("Information about the created link: %v", l)
}

@aboch
Copy link
Collaborator Author

aboch commented Jan 19, 2018

Thanks @KireinaHoro

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.

2 participants