mirror of
https://github.com/vishvananda/netlink
synced 2025-03-19 01:34:24 +00:00
disable broadcast if broadcast is set to net.IPv4zero
remove comments about broadcast when deleting address remove another comment about broadcast auto calculation
This commit is contained in:
parent
26ee0e2abe
commit
391c850512
@ -18,6 +18,7 @@ import (
|
||||
//
|
||||
// If `addr` is an IPv4 address and the broadcast address is not given, it
|
||||
// will be automatically computed based on the IP mask if /30 or larger.
|
||||
// If `net.IPv4zero` is given as the broadcast address, broadcast is disabled.
|
||||
func AddrAdd(link Link, addr *Addr) error {
|
||||
return pkgHandle.AddrAdd(link, addr)
|
||||
}
|
||||
@ -28,6 +29,7 @@ func AddrAdd(link Link, addr *Addr) error {
|
||||
//
|
||||
// If `addr` is an IPv4 address and the broadcast address is not given, it
|
||||
// will be automatically computed based on the IP mask if /30 or larger.
|
||||
// If `net.IPv4zero` is given as the broadcast address, broadcast is disabled.
|
||||
func (h *Handle) AddrAdd(link Link, addr *Addr) error {
|
||||
req := h.newNetlinkRequest(unix.RTM_NEWADDR, unix.NLM_F_CREATE|unix.NLM_F_EXCL|unix.NLM_F_ACK)
|
||||
return h.addrHandle(link, addr, req)
|
||||
@ -39,6 +41,7 @@ func (h *Handle) AddrAdd(link Link, addr *Addr) error {
|
||||
//
|
||||
// If `addr` is an IPv4 address and the broadcast address is not given, it
|
||||
// will be automatically computed based on the IP mask if /30 or larger.
|
||||
// If `net.IPv4zero` is given as the broadcast address, broadcast is disabled.
|
||||
func AddrReplace(link Link, addr *Addr) error {
|
||||
return pkgHandle.AddrReplace(link, addr)
|
||||
}
|
||||
@ -49,6 +52,7 @@ func AddrReplace(link Link, addr *Addr) error {
|
||||
//
|
||||
// If `addr` is an IPv4 address and the broadcast address is not given, it
|
||||
// will be automatically computed based on the IP mask if /30 or larger.
|
||||
// If `net.IPv4zero` is given as the broadcast address, broadcast is disabled.
|
||||
func (h *Handle) AddrReplace(link Link, addr *Addr) error {
|
||||
req := h.newNetlinkRequest(unix.RTM_NEWADDR, unix.NLM_F_CREATE|unix.NLM_F_REPLACE|unix.NLM_F_ACK)
|
||||
return h.addrHandle(link, addr, req)
|
||||
@ -57,18 +61,13 @@ func (h *Handle) AddrReplace(link Link, addr *Addr) error {
|
||||
// AddrDel will delete an IP address from a link device.
|
||||
//
|
||||
// Equivalent to: `ip addr del $addr dev $link`
|
||||
//
|
||||
// If `addr` is an IPv4 address and the broadcast address is not given, it
|
||||
// will be automatically computed based on the IP mask if /30 or larger.
|
||||
func AddrDel(link Link, addr *Addr) error {
|
||||
return pkgHandle.AddrDel(link, addr)
|
||||
}
|
||||
|
||||
// AddrDel will delete an IP address from a link device.
|
||||
// Equivalent to: `ip addr del $addr dev $link`
|
||||
//
|
||||
// If `addr` is an IPv4 address and the broadcast address is not given, it
|
||||
// will be automatically computed based on the IP mask if /30 or larger.
|
||||
// Equivalent to: `ip addr del $addr dev $link`
|
||||
func (h *Handle) AddrDel(link Link, addr *Addr) error {
|
||||
req := h.newNetlinkRequest(unix.RTM_DELADDR, unix.NLM_F_ACK)
|
||||
return h.addrHandle(link, addr, req)
|
||||
@ -142,6 +141,10 @@ func (h *Handle) addrHandle(link Link, addr *Addr, req *nl.NetlinkRequest) error
|
||||
addr.Broadcast = calcBroadcast
|
||||
}
|
||||
|
||||
if net.IPv4zero.Equal(addr.Broadcast) {
|
||||
addr.Broadcast = nil
|
||||
}
|
||||
|
||||
if addr.Broadcast != nil {
|
||||
req.AddData(nl.NewRtAttr(unix.IFA_BROADCAST, addr.Broadcast))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user