mirror of https://github.com/vishvananda/netlink
qdisc ingress_block support
This commit is contained in:
parent
e0988fd129
commit
7f2b136d34
|
@ -42,7 +42,14 @@ const (
|
||||||
TCA_FCNT
|
TCA_FCNT
|
||||||
TCA_STATS2
|
TCA_STATS2
|
||||||
TCA_STAB
|
TCA_STAB
|
||||||
TCA_MAX = TCA_STAB
|
TCA_PAD
|
||||||
|
TCA_DUMP_INVISIBLE
|
||||||
|
TCA_CHAIN
|
||||||
|
TCA_HW_OFFLOAD
|
||||||
|
TCA_INGRESS_BLOCK
|
||||||
|
TCA_EGRESS_BLOCK
|
||||||
|
TCA_DUMP_FLAGS
|
||||||
|
TCA_MAX = TCA_DUMP_FLAGS
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|
9
qdisc.go
9
qdisc.go
|
@ -32,10 +32,11 @@ type Qdisc interface {
|
||||||
// has a handle, a parent and a refcnt. The root qdisc of a device should
|
// has a handle, a parent and a refcnt. The root qdisc of a device should
|
||||||
// have parent == HANDLE_ROOT.
|
// have parent == HANDLE_ROOT.
|
||||||
type QdiscAttrs struct {
|
type QdiscAttrs struct {
|
||||||
LinkIndex int
|
LinkIndex int
|
||||||
Handle uint32
|
Handle uint32
|
||||||
Parent uint32
|
Parent uint32
|
||||||
Refcnt uint32 // read only
|
Refcnt uint32 // read only
|
||||||
|
IngressBlock *uint32
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q QdiscAttrs) String() string {
|
func (q QdiscAttrs) String() string {
|
||||||
|
|
|
@ -159,6 +159,9 @@ func (h *Handle) qdiscModify(cmd, flags int, qdisc Qdisc) error {
|
||||||
func qdiscPayload(req *nl.NetlinkRequest, qdisc Qdisc) error {
|
func qdiscPayload(req *nl.NetlinkRequest, qdisc Qdisc) error {
|
||||||
|
|
||||||
req.AddData(nl.NewRtAttr(nl.TCA_KIND, nl.ZeroTerminated(qdisc.Type())))
|
req.AddData(nl.NewRtAttr(nl.TCA_KIND, nl.ZeroTerminated(qdisc.Type())))
|
||||||
|
if qdisc.Attrs().IngressBlock != nil {
|
||||||
|
req.AddData(nl.NewRtAttr(nl.TCA_INGRESS_BLOCK, nl.Uint32Attr(*qdisc.Attrs().IngressBlock)))
|
||||||
|
}
|
||||||
|
|
||||||
options := nl.NewRtAttr(nl.TCA_OPTIONS, nil)
|
options := nl.NewRtAttr(nl.TCA_OPTIONS, nil)
|
||||||
|
|
||||||
|
@ -448,6 +451,10 @@ func (h *Handle) QdiscList(link Link) ([]Qdisc, error) {
|
||||||
|
|
||||||
// no options for ingress
|
// no options for ingress
|
||||||
}
|
}
|
||||||
|
case nl.TCA_INGRESS_BLOCK:
|
||||||
|
ingressBlock := new(uint32)
|
||||||
|
*ingressBlock = native.Uint32(attr.Value)
|
||||||
|
base.IngressBlock = ingressBlock
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*qdisc.Attrs() = base
|
*qdisc.Attrs() = base
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
//go:build linux
|
||||||
// +build linux
|
// +build linux
|
||||||
|
|
||||||
package netlink
|
package netlink
|
||||||
|
@ -590,10 +591,13 @@ func TestIngressAddDel(t *testing.T) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
ingressBlock := new(uint32)
|
||||||
|
*ingressBlock = 8
|
||||||
qdisc := &Ingress{
|
qdisc := &Ingress{
|
||||||
QdiscAttrs: QdiscAttrs{
|
QdiscAttrs: QdiscAttrs{
|
||||||
LinkIndex: link.Attrs().Index,
|
LinkIndex: link.Attrs().Index,
|
||||||
Parent: HANDLE_INGRESS,
|
Parent: HANDLE_INGRESS,
|
||||||
|
IngressBlock: ingressBlock,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
err = QdiscAdd(qdisc)
|
err = QdiscAdd(qdisc)
|
||||||
|
@ -607,6 +611,9 @@ func TestIngressAddDel(t *testing.T) {
|
||||||
if len(qdiscs) != 1 {
|
if len(qdiscs) != 1 {
|
||||||
t.Fatal("Failed to add qdisc")
|
t.Fatal("Failed to add qdisc")
|
||||||
}
|
}
|
||||||
|
if *qdiscs[0].Attrs().IngressBlock != *ingressBlock {
|
||||||
|
t.Fatal("IngressBlock does not match")
|
||||||
|
}
|
||||||
if err = QdiscDel(qdisc); err != nil {
|
if err = QdiscDel(qdisc); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue