Skip to content

Commit

Permalink
Save XDP attach mode into LinkXdp.
Browse files Browse the repository at this point in the history
  • Loading branch information
Konstantin Belyalov authored and fcrisciani committed Jan 27, 2020
1 parent 0f858a2 commit b237268
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
9 changes: 5 additions & 4 deletions link.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,10 +196,11 @@ type LinkStatistics64 struct {
}

type LinkXdp struct {
Fd int
Attached bool
Flags uint32
ProgId uint32
Fd int
Attached bool
AttachMode uint32
Flags uint32
ProgId uint32
}

// Device links cannot be created via netlink. These links
Expand Down
3 changes: 2 additions & 1 deletion link_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -2513,7 +2513,8 @@ func parseLinkXdp(data []byte) (*LinkXdp, error) {
case nl.IFLA_XDP_FD:
xdp.Fd = int(native.Uint32(attr.Value[0:4]))
case nl.IFLA_XDP_ATTACHED:
xdp.Attached = attr.Value[0] != 0
xdp.AttachMode = uint32(attr.Value[0])
xdp.Attached = xdp.AttachMode != 0
case nl.IFLA_XDP_FLAGS:
xdp.Flags = native.Uint32(attr.Value[0:4])
case nl.IFLA_XDP_PROG_ID:
Expand Down
8 changes: 8 additions & 0 deletions nl/link_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,14 @@ const (
IFLA_XDP_MAX = IFLA_XDP_PROG_ID
)

// XDP program attach mode (used as dump value for IFLA_XDP_ATTACHED)
const (
XDP_ATTACHED_NONE = iota
XDP_ATTACHED_DRV
XDP_ATTACHED_SKB
XDP_ATTACHED_HW
)

const (
IFLA_IPTUN_UNSPEC = iota
IFLA_IPTUN_LINK
Expand Down

0 comments on commit b237268

Please sign in to comment.