Documentation ¶
Overview ¶
Packet netlink provide access to low level Netlink sockets and messages.
Actual implementations are in: netlink_linux.go netlink_darwin.go
Index ¶
- Constants
- Variables
- func AddDefaultGw(ip, device string) error
- func AddRoute(destination, source, gateway, device string) error
- func AddToBridge(iface, master *net.Interface) error
- func ChangeName(iface *net.Interface, newName string) error
- func CreateBridge(name string, setMacAddr bool) error
- func DeleteBridge(name string) error
- func NetworkChangeName(iface *net.Interface, newName string) error
- func NetworkCreateVethPair(name1, name2 string, txQueueLen int) error
- func NetworkLinkAdd(name string, linkType string) error
- func NetworkLinkAddIp(iface *net.Interface, ip net.IP, ipNet *net.IPNet) error
- func NetworkLinkAddMacVlan(masterDev, macVlanDev string, mode string) error
- func NetworkLinkAddMacVtap(masterDev, macVlanDev string, mode string) error
- func NetworkLinkAddVlan(masterDev, vlanDev string, vlanId uint16) error
- func NetworkLinkDel(name string) error
- func NetworkLinkDelIp(iface *net.Interface, ip net.IP, ipNet *net.IPNet) error
- func NetworkLinkDown(iface *net.Interface) error
- func NetworkLinkUp(iface *net.Interface) error
- func NetworkSetMTU(iface *net.Interface, mtu int) error
- func NetworkSetMacAddress(iface *net.Interface, macaddr string) error
- func NetworkSetMaster(iface, master *net.Interface) error
- func NetworkSetNoMaster(iface *net.Interface) error
- func NetworkSetNsFd(iface *net.Interface, fd int) error
- func NetworkSetNsPid(iface *net.Interface, nspid int) error
- func NetworkSetTxQueueLen(iface *net.Interface, txQueueLen int) error
- func SetHairpinMode(iface *net.Interface, enabled bool) error
- func SetMacAddress(name, addr string) error
- type IfAddr
- type IfAddrmsg
- type IfInfomsg
- type MacVlanLink
- type NetlinkRequest
- type NetlinkRequestData
- type NetlinkSocket
- func (s *NetlinkSocket) CheckMessage(m syscall.NetlinkMessage, seq, pid uint32) error
- func (s *NetlinkSocket) Close()
- func (s *NetlinkSocket) GetPid() (uint32, error)
- func (s *NetlinkSocket) HandleAck(seq uint32) error
- func (s *NetlinkSocket) Receive() ([]syscall.NetlinkMessage, error)
- func (s *NetlinkSocket) Send(request *NetlinkRequest) error
- type Route
- type RtAttr
- type RtMsg
Constants ¶
const ( IFNAMSIZ = 16 DEFAULT_CHANGE = 0xFFFFFFFF IFLA_INFO_KIND = 1 IFLA_INFO_DATA = 2 VETH_INFO_PEER = 1 IFLA_MACVLAN_MODE = 1 IFLA_VLAN_ID = 1 IFLA_NET_NS_FD = 28 IFLA_ADDRESS = 1 IFLA_BRPORT_MODE = 4 SIOC_BRADDBR = 0x89a0 SIOC_BRDELBR = 0x89a1 SIOC_BRADDIF = 0x89a2 )
const ( MACVLAN_MODE_PRIVATE = 1 << iota MACVLAN_MODE_VEPA MACVLAN_MODE_BRIDGE MACVLAN_MODE_PASSTHRU )
Variables ¶
Functions ¶
func AddDefaultGw ¶
Add a new default gateway. Identical to: ip route add default via $ip
func AddRoute ¶
Add a new route table entry.
func AddToBridge ¶
Add a slave to abridge device. This is more backward-compatible than netlink.NetworkSetMaster and works on RHEL 6.
func CreateBridge ¶
Create the actual bridge device. This is more backward-compatible than netlink.NetworkLinkAdd and works on RHEL 6.
func NetworkChangeName ¶
Rname a particular interface to a different name !!! Note that you can't rename an active interface. You need to bring it down before renaming it. This is identical to running: ip link set dev ${oldName} name ${newName}
func NetworkCreateVethPair ¶
Add a new VETH pair link on the host This is identical to running: ip link add name $name type veth peer name $peername
func NetworkLinkAdd ¶
Add a new network link of a specified type. This is identical to running: ip link add $name type $linkType
func NetworkLinkAddIp ¶
Add an Ip address to an interface. This is identical to: ip addr add $ip/$ipNet dev $iface
func NetworkLinkAddMacVlan ¶
func NetworkLinkAddMacVtap ¶
func NetworkLinkAddVlan ¶
Add a new VLAN interface with masterDev as its upper device This is identical to running: ip link add name $name link $masterdev type vlan id $id
func NetworkLinkDel ¶
Delete a network link. This is identical to running: ip link del $name
func NetworkLinkDelIp ¶
Delete an IP address from an interface. This is identical to: ip addr del $ip/$ipNet dev $iface
func NetworkLinkDown ¶
Bring down a particular network interface. This is identical to running: ip link set $name down
func NetworkLinkUp ¶
Bring up a particular network interface. This is identical to running: ip link set dev $name up
func NetworkSetMTU ¶
Set link Maximum Transmission Unit This is identical to running: ip link set dev $name mtu $MTU bridge is a bitch here https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=292088 https://bugzilla.redhat.com/show_bug.cgi?id=697021 There is a discussion about how to deal with ifcs joining bridge with MTU > 1500 Regular network nterfaces do seem to work though!
func NetworkSetMacAddress ¶
Set link layer address ie. MAC Address. This is identical to running: ip link set dev $name address $macaddress
func NetworkSetMaster ¶
Add an interface to bridge. This is identical to running: ip link set $name master $master
func NetworkSetNoMaster ¶
Remove an interface from the bridge This is is identical to to running: ip link $name set nomaster
func NetworkSetNsFd ¶
Move a particular network interface to a particular mounted network namespace specified by file descriptor. This is idential to running: ip link set dev $name netns $fd
func NetworkSetNsPid ¶
Move a particular network interface to a particular network namespace specified by PID. This is idential to running: ip link set dev $name netns $pid
func NetworkSetTxQueueLen ¶
Set link queue length This is identical to running: ip link set dev $name txqueuelen $QLEN
Types ¶
type IfAddr ¶
An IfAddr defines IP network settings for a given network interface
type IfAddrmsg ¶
type IfInfomsg ¶
type MacVlanLink ¶
type MacVlanLink struct { MasterDev string SlaveDev string // contains filtered or unexported fields }
MacVlan link has LowerDev, UpperDev and operates in Mode mode This simplifies the code when creating MacVlan or MacVtap interface
func (MacVlanLink) Mode ¶
func (m MacVlanLink) Mode() uint32
type NetlinkRequest ¶
type NetlinkRequest struct { syscall.NlMsghdr Data []NetlinkRequestData }
func (*NetlinkRequest) AddData ¶
func (rr *NetlinkRequest) AddData(data NetlinkRequestData)
func (*NetlinkRequest) ToWireFormat ¶
func (rr *NetlinkRequest) ToWireFormat() []byte
type NetlinkSocket ¶
type NetlinkSocket struct {
// contains filtered or unexported fields
}
func (*NetlinkSocket) CheckMessage ¶
func (s *NetlinkSocket) CheckMessage(m syscall.NetlinkMessage, seq, pid uint32) error
func (*NetlinkSocket) Close ¶
func (s *NetlinkSocket) Close()
func (*NetlinkSocket) GetPid ¶
func (s *NetlinkSocket) GetPid() (uint32, error)
func (*NetlinkSocket) HandleAck ¶
func (s *NetlinkSocket) HandleAck(seq uint32) error
func (*NetlinkSocket) Receive ¶
func (s *NetlinkSocket) Receive() ([]syscall.NetlinkMessage, error)
func (*NetlinkSocket) Send ¶
func (s *NetlinkSocket) Send(request *NetlinkRequest) error
type Route ¶
A Route is a subnet associated with the interface to reach it.