mirror of
https://github.com/vishvananda/netlink
synced 2025-02-18 05:07:11 +00:00
addr_linux: Skip BROADCAST and LABEL for non-ipv4
The attributes IFA_BROADCAST and IFA_LABEL are only valid for ipv4: they are not defined for ipv6 here: http://elixir.free-electrons.com/linux/v4.6/source/net/ipv6/addrconf.c#L4231 This ignores addr.Broadcast and addr.Label for non-ipv4 addresses.
This commit is contained in:
parent
1882fa99fc
commit
422ffe659e
@ -102,18 +102,20 @@ func (h *Handle) addrHandle(link Link, addr *Addr, req *nl.NetlinkRequest) error
|
||||
}
|
||||
}
|
||||
|
||||
if addr.Broadcast == nil {
|
||||
calcBroadcast := make(net.IP, masklen/8)
|
||||
for i := range localAddrData {
|
||||
calcBroadcast[i] = localAddrData[i] | ^addr.Mask[i]
|
||||
if family == FAMILY_V4 {
|
||||
if addr.Broadcast == nil {
|
||||
calcBroadcast := make(net.IP, masklen/8)
|
||||
for i := range localAddrData {
|
||||
calcBroadcast[i] = localAddrData[i] | ^addr.Mask[i]
|
||||
}
|
||||
addr.Broadcast = calcBroadcast
|
||||
}
|
||||
addr.Broadcast = calcBroadcast
|
||||
}
|
||||
req.AddData(nl.NewRtAttr(unix.IFA_BROADCAST, addr.Broadcast))
|
||||
req.AddData(nl.NewRtAttr(unix.IFA_BROADCAST, addr.Broadcast))
|
||||
|
||||
if addr.Label != "" {
|
||||
labelData := nl.NewRtAttr(unix.IFA_LABEL, nl.ZeroTerminated(addr.Label))
|
||||
req.AddData(labelData)
|
||||
if addr.Label != "" {
|
||||
labelData := nl.NewRtAttr(unix.IFA_LABEL, nl.ZeroTerminated(addr.Label))
|
||||
req.AddData(labelData)
|
||||
}
|
||||
}
|
||||
|
||||
_, err := req.Execute(unix.NETLINK_ROUTE, 0)
|
||||
|
Loading…
Reference in New Issue
Block a user