Skip to content

Commit

Permalink
Add allmulti to link attributes
Browse files Browse the repository at this point in the history
Provide the status of the allmulticast option via the highlevel
link attributes instead of requiring raw flag handling.
  • Loading branch information
bjosv committed Apr 7, 2021
1 parent f5de759 commit 5611728
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions link.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ type LinkAttrs struct {
Alias string
Statistics *LinkStatistics
Promisc int
Allmulti int
Xdp *LinkXdp
EncapType string
Protinfo *Protinfo
Expand Down
6 changes: 4 additions & 2 deletions link_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@ func (h *Handle) LinkSetAllmulticastOn(link Link) error {
msg := nl.NewIfInfomsg(unix.AF_UNSPEC)
msg.Change = unix.IFF_ALLMULTI
msg.Flags = unix.IFF_ALLMULTI

msg.Index = int32(base.Index)
req.AddData(msg)

Expand Down Expand Up @@ -1624,7 +1623,7 @@ func execGetLink(req *nl.NetlinkRequest) (Link, error) {
}
}

// linkDeserialize deserializes a raw message received from netlink into
// LinkDeserialize deserializes a raw message received from netlink into
// a link object.
func LinkDeserialize(hdr *unix.NlMsghdr, m []byte) (Link, error) {
msg := nl.DeserializeIfInfomsg(m)
Expand All @@ -1642,6 +1641,9 @@ func LinkDeserialize(hdr *unix.NlMsghdr, m []byte) (Link, error) {
if msg.Flags&unix.IFF_PROMISC != 0 {
base.Promisc = 1
}
if msg.Flags&unix.IFF_ALLMULTI != 0 {
base.Allmulti = 1
}
var (
link Link
stats32 *LinkStatistics32
Expand Down
4 changes: 2 additions & 2 deletions link_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2647,7 +2647,7 @@ func TestLinkSetAllmulticast(t *testing.T) {
t.Fatal(err)
}

if link.Attrs().RawFlags&unix.IFF_ALLMULTI != uint32(unix.IFF_ALLMULTI) {
if link.Attrs().Allmulti != 1 {
t.Fatal("IFF_ALLMULTI was not set")
}

Expand All @@ -2660,7 +2660,7 @@ func TestLinkSetAllmulticast(t *testing.T) {
t.Fatal(err)
}

if link.Attrs().RawFlags&unix.IFF_ALLMULTI != 0 {
if link.Attrs().Allmulti != 0 {
t.Fatal("IFF_ALLMULTI is still set")
}

Expand Down

0 comments on commit 5611728

Please sign in to comment.