diff --git a/chain.go b/chain.go index 5bc0e49..8d797be 100644 --- a/chain.go +++ b/chain.go @@ -102,6 +102,7 @@ type Chain struct { Priority *ChainPriority Type ChainType Policy *ChainPolicy + Device string } // 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_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{ {Type: unix.NLA_F_NESTED | unix.NFTA_CHAIN_HOOK, Data: cc.marshalAttr(hookAttr)}, })...)