Chain: add 'device' as hook attribute
NETDEV tables can specify a device the apply to. Add support for this by augmenting the `Chain` struct.
This commit is contained in:
parent
4dbe06f125
commit
8ffcbc2d36
6
chain.go
6
chain.go
|
@ -102,6 +102,7 @@ type Chain struct {
|
||||||
Priority *ChainPriority
|
Priority *ChainPriority
|
||||||
Type ChainType
|
Type ChainType
|
||||||
Policy *ChainPolicy
|
Policy *ChainPolicy
|
||||||
|
Device string
|
||||||
}
|
}
|
||||||
|
|
||||||
// AddChain adds the specified Chain. See also
|
// AddChain adds the specified Chain. See also
|
||||||
|
@ -119,6 +120,11 @@ func (cc *Conn) AddChain(c *Chain) *Chain {
|
||||||
{Type: unix.NFTA_HOOK_HOOKNUM, Data: binaryutil.BigEndian.PutUint32(uint32(*c.Hooknum))},
|
{Type: unix.NFTA_HOOK_HOOKNUM, Data: binaryutil.BigEndian.PutUint32(uint32(*c.Hooknum))},
|
||||||
{Type: unix.NFTA_HOOK_PRIORITY, Data: binaryutil.BigEndian.PutUint32(uint32(*c.Priority))},
|
{Type: unix.NFTA_HOOK_PRIORITY, Data: binaryutil.BigEndian.PutUint32(uint32(*c.Priority))},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if c.Device != "" {
|
||||||
|
hookAttr = append(hookAttr, netlink.Attribute{Type: unix.NFTA_HOOK_DEV, Data: []byte(c.Device + "\x00")})
|
||||||
|
}
|
||||||
|
|
||||||
data = append(data, cc.marshalAttr([]netlink.Attribute{
|
data = append(data, cc.marshalAttr([]netlink.Attribute{
|
||||||
{Type: unix.NLA_F_NESTED | unix.NFTA_CHAIN_HOOK, Data: cc.marshalAttr(hookAttr)},
|
{Type: unix.NLA_F_NESTED | unix.NFTA_CHAIN_HOOK, Data: cc.marshalAttr(hookAttr)},
|
||||||
})...)
|
})...)
|
||||||
|
|
Loading…
Reference in New Issue