f-21: code: change from ip to interface type

Signed-off-by: GnomeZworc <nicolas.boufidjeline@g3e.fr>
This commit is contained in:
GnomeZworc 2026-04-21 21:28:20 +02:00
commit 9ec6e64327
Signed by: nicolas.boufideline
GPG key ID: 4406BBBF8845D632
8 changed files with 41 additions and 40 deletions

View file

@ -1,20 +1,22 @@
package netif
import (
"net"
"github.com/vishvananda/netlink"
)
func CreateVxlan(name string, vxlanID int, localIP net.IP) error {
func CreateVxlan(name string, vxlanID int, localIface string) error {
link, err := netlink.LinkByName(localIface)
if err != nil {
return err
}
vxlan := &netlink.Vxlan{
LinkAttrs: netlink.LinkAttrs{
Name: name,
},
VxlanId: vxlanID,
Port: 4789,
SrcAddr: localIP,
Learning: false,
VxlanId: vxlanID,
Port: 4789,
VtepDevIndex: link.Attrs().Index,
Learning: false,
}
return netlink.LinkAdd(vxlan)
}