nftables: update for package netlink constant renames (#13)
This commit is contained in:
parent
b8b6574812
commit
a975e10ef9
20
nftables.go
20
nftables.go
|
@ -40,7 +40,7 @@ func batch(messages []netlink.Message) []netlink.Message {
|
||||||
{
|
{
|
||||||
Header: netlink.Header{
|
Header: netlink.Header{
|
||||||
Type: netlink.HeaderType(unix.NFNL_MSG_BATCH_BEGIN),
|
Type: netlink.HeaderType(unix.NFNL_MSG_BATCH_BEGIN),
|
||||||
Flags: netlink.HeaderFlagsRequest,
|
Flags: netlink.Request,
|
||||||
},
|
},
|
||||||
Data: extraHeader(0, unix.NFNL_SUBSYS_NFTABLES),
|
Data: extraHeader(0, unix.NFNL_SUBSYS_NFTABLES),
|
||||||
},
|
},
|
||||||
|
@ -51,7 +51,7 @@ func batch(messages []netlink.Message) []netlink.Message {
|
||||||
batch = append(batch, netlink.Message{
|
batch = append(batch, netlink.Message{
|
||||||
Header: netlink.Header{
|
Header: netlink.Header{
|
||||||
Type: netlink.HeaderType(unix.NFNL_MSG_BATCH_END),
|
Type: netlink.HeaderType(unix.NFNL_MSG_BATCH_END),
|
||||||
Flags: netlink.HeaderFlagsRequest,
|
Flags: netlink.Request,
|
||||||
},
|
},
|
||||||
Data: extraHeader(0, unix.NFNL_SUBSYS_NFTABLES),
|
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{
|
cc.messages = append(cc.messages, netlink.Message{
|
||||||
Header: netlink.Header{
|
Header: netlink.Header{
|
||||||
Type: netlink.HeaderType((unix.NFNL_SUBSYS_NFTABLES << 8) | unix.NFT_MSG_NEWCHAIN),
|
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...),
|
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{
|
cc.messages = append(cc.messages, netlink.Message{
|
||||||
Header: netlink.Header{
|
Header: netlink.Header{
|
||||||
Type: ruleHeaderType,
|
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...),
|
Data: append(extraHeader(uint8(r.Table.Family), 0), data...),
|
||||||
})
|
})
|
||||||
|
@ -337,7 +337,7 @@ func (cc *Conn) FlushRuleset() {
|
||||||
cc.messages = append(cc.messages, netlink.Message{
|
cc.messages = append(cc.messages, netlink.Message{
|
||||||
Header: netlink.Header{
|
Header: netlink.Header{
|
||||||
Type: netlink.HeaderType((unix.NFNL_SUBSYS_NFTABLES << 8) | unix.NFT_MSG_DELTABLE),
|
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),
|
Data: extraHeader(0, 0),
|
||||||
})
|
})
|
||||||
|
@ -352,7 +352,7 @@ func (cc *Conn) DelTable(t *Table) {
|
||||||
cc.messages = append(cc.messages, netlink.Message{
|
cc.messages = append(cc.messages, netlink.Message{
|
||||||
Header: netlink.Header{
|
Header: netlink.Header{
|
||||||
Type: netlink.HeaderType((unix.NFNL_SUBSYS_NFTABLES << 8) | unix.NFT_MSG_DELTABLE),
|
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...),
|
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{
|
cc.messages = append(cc.messages, netlink.Message{
|
||||||
Header: netlink.Header{
|
Header: netlink.Header{
|
||||||
Type: netlink.HeaderType((unix.NFNL_SUBSYS_NFTABLES << 8) | unix.NFT_MSG_NEWTABLE),
|
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...),
|
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{
|
message := netlink.Message{
|
||||||
Header: netlink.Header{
|
Header: netlink.Header{
|
||||||
Type: netlink.HeaderType((unix.NFNL_SUBSYS_NFTABLES << 8) | unix.NFT_MSG_GETRULE),
|
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...),
|
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{
|
cc.messages = append(cc.messages, netlink.Message{
|
||||||
Header: netlink.Header{
|
Header: netlink.Header{
|
||||||
Type: netlink.HeaderType((unix.NFNL_SUBSYS_NFTABLES << 8) | unix.NFT_MSG_NEWOBJ),
|
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...),
|
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{
|
message := netlink.Message{
|
||||||
Header: netlink.Header{
|
Header: netlink.Header{
|
||||||
Type: netlink.HeaderType((unix.NFNL_SUBSYS_NFTABLES << 8) | msgType),
|
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...),
|
Data: append(extraHeader(uint8(o.family()), 0), data...),
|
||||||
}
|
}
|
||||||
|
|
14
set.go
14
set.go
|
@ -87,7 +87,7 @@ func (cc *Conn) SetAddElements(s *Set, vals []SetElement) error {
|
||||||
cc.messages = append(cc.messages, netlink.Message{
|
cc.messages = append(cc.messages, netlink.Message{
|
||||||
Header: netlink.Header{
|
Header: netlink.Header{
|
||||||
Type: netlink.HeaderType((unix.NFNL_SUBSYS_NFTABLES << 8) | unix.NFT_MSG_NEWSETELEM),
|
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)...),
|
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{
|
cc.messages = append(cc.messages, netlink.Message{
|
||||||
Header: netlink.Header{
|
Header: netlink.Header{
|
||||||
Type: netlink.HeaderType((unix.NFNL_SUBSYS_NFTABLES << 8) | unix.NFT_MSG_NEWSET),
|
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)...),
|
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{
|
cc.messages = append(cc.messages, netlink.Message{
|
||||||
Header: netlink.Header{
|
Header: netlink.Header{
|
||||||
Type: netlink.HeaderType((unix.NFNL_SUBSYS_NFTABLES << 8) | hdrType),
|
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)...),
|
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{
|
cc.messages = append(cc.messages, netlink.Message{
|
||||||
Header: netlink.Header{
|
Header: netlink.Header{
|
||||||
Type: netlink.HeaderType((unix.NFNL_SUBSYS_NFTABLES << 8) | unix.NFT_MSG_DELSET),
|
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...),
|
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{
|
cc.messages = append(cc.messages, netlink.Message{
|
||||||
Header: netlink.Header{
|
Header: netlink.Header{
|
||||||
Type: netlink.HeaderType((unix.NFNL_SUBSYS_NFTABLES << 8) | unix.NFT_MSG_DELSETELEM),
|
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)...),
|
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{
|
message := netlink.Message{
|
||||||
Header: netlink.Header{
|
Header: netlink.Header{
|
||||||
Type: netlink.HeaderType((unix.NFNL_SUBSYS_NFTABLES << 8) | unix.NFT_MSG_GETSET),
|
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...),
|
Data: append(extraHeader(uint8(t.Family), 0), data...),
|
||||||
}
|
}
|
||||||
|
@ -388,7 +388,7 @@ func (cc *Conn) GetSetElements(s *Set) ([]SetElement, error) {
|
||||||
message := netlink.Message{
|
message := netlink.Message{
|
||||||
Header: netlink.Header{
|
Header: netlink.Header{
|
||||||
Type: netlink.HeaderType((unix.NFNL_SUBSYS_NFTABLES << 8) | unix.NFT_MSG_GETSETELEM),
|
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...),
|
Data: append(extraHeader(uint8(s.Table.Family), 0), data...),
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue