From a975e10ef9360c869f23f6575e3d11464a4cf136 Mon Sep 17 00:00:00 2001 From: Matt Layher Date: Sat, 2 Mar 2019 08:04:15 -0800 Subject: [PATCH] nftables: update for package netlink constant renames (#13) --- nftables.go | 20 ++++++++++---------- set.go | 14 +++++++------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/nftables.go b/nftables.go index d59769b..4a671ff 100644 --- a/nftables.go +++ b/nftables.go @@ -40,7 +40,7 @@ func batch(messages []netlink.Message) []netlink.Message { { Header: netlink.Header{ Type: netlink.HeaderType(unix.NFNL_MSG_BATCH_BEGIN), - Flags: netlink.HeaderFlagsRequest, + Flags: netlink.Request, }, Data: extraHeader(0, unix.NFNL_SUBSYS_NFTABLES), }, @@ -51,7 +51,7 @@ func batch(messages []netlink.Message) []netlink.Message { batch = append(batch, netlink.Message{ Header: netlink.Header{ Type: netlink.HeaderType(unix.NFNL_MSG_BATCH_END), - Flags: netlink.HeaderFlagsRequest, + Flags: netlink.Request, }, Data: extraHeader(0, unix.NFNL_SUBSYS_NFTABLES), }) @@ -136,7 +136,7 @@ func (cc *Conn) AddChain(c *Chain) *Chain { cc.messages = append(cc.messages, netlink.Message{ Header: netlink.Header{ Type: netlink.HeaderType((unix.NFNL_SUBSYS_NFTABLES << 8) | unix.NFT_MSG_NEWCHAIN), - Flags: netlink.HeaderFlagsRequest | netlink.HeaderFlagsAcknowledge | netlink.HeaderFlagsCreate, + Flags: netlink.Request | netlink.Acknowledge | netlink.Create, }, Data: append(extraHeader(uint8(c.Table.Family), 0), data...), }) @@ -294,7 +294,7 @@ func (cc *Conn) AddRule(r *Rule) *Rule { cc.messages = append(cc.messages, netlink.Message{ Header: netlink.Header{ Type: ruleHeaderType, - Flags: netlink.HeaderFlagsRequest | netlink.HeaderFlagsAcknowledge | netlink.HeaderFlagsCreate, + Flags: netlink.Request | netlink.Acknowledge | netlink.Create, }, Data: append(extraHeader(uint8(r.Table.Family), 0), data...), }) @@ -337,7 +337,7 @@ func (cc *Conn) FlushRuleset() { cc.messages = append(cc.messages, netlink.Message{ Header: netlink.Header{ Type: netlink.HeaderType((unix.NFNL_SUBSYS_NFTABLES << 8) | unix.NFT_MSG_DELTABLE), - Flags: netlink.HeaderFlagsRequest | netlink.HeaderFlagsAcknowledge | netlink.HeaderFlagsCreate, + Flags: netlink.Request | netlink.Acknowledge | netlink.Create, }, Data: extraHeader(0, 0), }) @@ -352,7 +352,7 @@ func (cc *Conn) DelTable(t *Table) { cc.messages = append(cc.messages, netlink.Message{ Header: netlink.Header{ Type: netlink.HeaderType((unix.NFNL_SUBSYS_NFTABLES << 8) | unix.NFT_MSG_DELTABLE), - Flags: netlink.HeaderFlagsRequest | netlink.HeaderFlagsAcknowledge, + Flags: netlink.Request | netlink.Acknowledge, }, Data: append(extraHeader(uint8(t.Family), 0), data...), }) @@ -368,7 +368,7 @@ func (cc *Conn) AddTable(t *Table) *Table { cc.messages = append(cc.messages, netlink.Message{ Header: netlink.Header{ Type: netlink.HeaderType((unix.NFNL_SUBSYS_NFTABLES << 8) | unix.NFT_MSG_NEWTABLE), - Flags: netlink.HeaderFlagsRequest | netlink.HeaderFlagsAcknowledge | netlink.HeaderFlagsCreate, + Flags: netlink.Request | netlink.Acknowledge | netlink.Create, }, Data: append(extraHeader(uint8(t.Family), 0), data...), }) @@ -419,7 +419,7 @@ func (cc *Conn) GetRule(t *Table, c *Chain) ([]*Rule, error) { message := netlink.Message{ Header: netlink.Header{ Type: netlink.HeaderType((unix.NFNL_SUBSYS_NFTABLES << 8) | unix.NFT_MSG_GETRULE), - Flags: netlink.HeaderFlagsRequest | netlink.HeaderFlagsAcknowledge | netlink.HeaderFlagsDump, + Flags: netlink.Request | netlink.Acknowledge | netlink.Dump, }, Data: append(extraHeader(uint8(t.Family), 0), data...), } @@ -509,7 +509,7 @@ func (cc *Conn) AddObj(o Obj) Obj { cc.messages = append(cc.messages, netlink.Message{ Header: netlink.Header{ Type: netlink.HeaderType((unix.NFNL_SUBSYS_NFTABLES << 8) | unix.NFT_MSG_NEWOBJ), - Flags: netlink.HeaderFlagsRequest | netlink.HeaderFlagsAcknowledge | netlink.HeaderFlagsCreate, + Flags: netlink.Request | netlink.Acknowledge | netlink.Create, }, Data: append(extraHeader(uint8(o.family()), 0), data...), }) @@ -589,7 +589,7 @@ func (cc *Conn) getObj(o Obj, msgType uint16) ([]Obj, error) { message := netlink.Message{ Header: netlink.Header{ Type: netlink.HeaderType((unix.NFNL_SUBSYS_NFTABLES << 8) | msgType), - Flags: netlink.HeaderFlagsRequest | netlink.HeaderFlagsAcknowledge | netlink.HeaderFlagsDump, + Flags: netlink.Request | netlink.Acknowledge | netlink.Dump, }, Data: append(extraHeader(uint8(o.family()), 0), data...), } diff --git a/set.go b/set.go index 5fd079f..bdc5abb 100644 --- a/set.go +++ b/set.go @@ -87,7 +87,7 @@ func (cc *Conn) SetAddElements(s *Set, vals []SetElement) error { cc.messages = append(cc.messages, netlink.Message{ Header: netlink.Header{ Type: netlink.HeaderType((unix.NFNL_SUBSYS_NFTABLES << 8) | unix.NFT_MSG_NEWSETELEM), - Flags: netlink.HeaderFlagsRequest | netlink.HeaderFlagsAcknowledge | netlink.HeaderFlagsCreate, + Flags: netlink.Request | netlink.Acknowledge | netlink.Create, }, Data: append(extraHeader(unix.NFTA_SET_NAME, 0), cc.marshalAttr(elements)...), }) @@ -186,7 +186,7 @@ func (cc *Conn) AddSet(s *Set, vals []SetElement) error { cc.messages = append(cc.messages, netlink.Message{ Header: netlink.Header{ Type: netlink.HeaderType((unix.NFNL_SUBSYS_NFTABLES << 8) | unix.NFT_MSG_NEWSET), - Flags: netlink.HeaderFlagsRequest | netlink.HeaderFlagsAcknowledge | netlink.HeaderFlagsCreate, + Flags: netlink.Request | netlink.Acknowledge | netlink.Create, }, Data: append(extraHeader(unix.NFTA_SET_NAME, 0), cc.marshalAttr(tableInfo)...), }) @@ -205,7 +205,7 @@ func (cc *Conn) AddSet(s *Set, vals []SetElement) error { cc.messages = append(cc.messages, netlink.Message{ Header: netlink.Header{ Type: netlink.HeaderType((unix.NFNL_SUBSYS_NFTABLES << 8) | hdrType), - Flags: netlink.HeaderFlagsRequest | netlink.HeaderFlagsAcknowledge | netlink.HeaderFlagsCreate, + Flags: netlink.Request | netlink.Acknowledge | netlink.Create, }, Data: append(extraHeader(unix.NFTA_SET_NAME, 0), cc.marshalAttr(elements)...), }) @@ -223,7 +223,7 @@ func (cc *Conn) DelSet(s *Set) { cc.messages = append(cc.messages, netlink.Message{ Header: netlink.Header{ Type: netlink.HeaderType((unix.NFNL_SUBSYS_NFTABLES << 8) | unix.NFT_MSG_DELSET), - Flags: netlink.HeaderFlagsRequest | netlink.HeaderFlagsAcknowledge, + Flags: netlink.Request | netlink.Acknowledge, }, Data: append(extraHeader(uint8(unix.NFTA_SET_NAME), 0), data...), }) @@ -242,7 +242,7 @@ func (cc *Conn) SetDeleteElements(s *Set, vals []SetElement) error { cc.messages = append(cc.messages, netlink.Message{ Header: netlink.Header{ Type: netlink.HeaderType((unix.NFNL_SUBSYS_NFTABLES << 8) | unix.NFT_MSG_DELSETELEM), - Flags: netlink.HeaderFlagsRequest | netlink.HeaderFlagsAcknowledge | netlink.HeaderFlagsCreate, + Flags: netlink.Request | netlink.Acknowledge | netlink.Create, }, Data: append(extraHeader(unix.NFTA_SET_NAME, 0), cc.marshalAttr(elements)...), }) @@ -344,7 +344,7 @@ func (cc *Conn) GetSets(t *Table) ([]*Set, error) { message := netlink.Message{ Header: netlink.Header{ Type: netlink.HeaderType((unix.NFNL_SUBSYS_NFTABLES << 8) | unix.NFT_MSG_GETSET), - Flags: netlink.HeaderFlagsRequest | netlink.HeaderFlagsAcknowledge | netlink.HeaderFlagsDump, + Flags: netlink.Request | netlink.Acknowledge | netlink.Dump, }, Data: append(extraHeader(uint8(t.Family), 0), data...), } @@ -388,7 +388,7 @@ func (cc *Conn) GetSetElements(s *Set) ([]SetElement, error) { message := netlink.Message{ Header: netlink.Header{ Type: netlink.HeaderType((unix.NFNL_SUBSYS_NFTABLES << 8) | unix.NFT_MSG_GETSETELEM), - Flags: netlink.HeaderFlagsRequest | netlink.HeaderFlagsAcknowledge | netlink.HeaderFlagsDump, + Flags: netlink.Request | netlink.Acknowledge | netlink.Dump, }, Data: append(extraHeader(uint8(s.Table.Family), 0), data...), }