Skip to content

Commit 7d654d3

Browse files
kerumetogvisor-bot
authored andcommitted
Update Nftables Gettable
Updated Nftables Gettable to explicitly throw an error if a dump request is received (NLM_F_DUMP), to be implemented later. Also corrected the response message's type. PiperOrigin-RevId: 784337686
1 parent da551ec commit 7d654d3

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

pkg/sentry/socket/netlink/netfilter/protocol.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,12 @@ func (p *Protocol) updateTable(nft *nftables.NFTables, tab *nftables.Table, attr
233233
}
234234

235235
// getTable returns a table for the given family.
236-
func (p *Protocol) getTable(nft *nftables.NFTables, attrs map[uint16]nlmsg.BytesView, family stack.AddressFamily, flags uint16, ms *nlmsg.MessageSet) *syserr.AnnotatedError {
236+
func (p *Protocol) getTable(nft *nftables.NFTables, attrs map[uint16]nlmsg.BytesView, family stack.AddressFamily, msgFlags uint16, ms *nlmsg.MessageSet) *syserr.AnnotatedError {
237+
if (msgFlags & linux.NLM_F_DUMP) != 0 {
238+
// TODO: b/421437663 - Support dump requests for tables.
239+
return syserr.NewAnnotatedError(syserr.ErrNotSupported, fmt.Sprintf("Nftables: Table dump is not currently supported"))
240+
}
241+
237242
// The table name is required.
238243
tabNameBytes, ok := attrs[linux.NFTA_TABLE_NAME]
239244
if !ok {
@@ -250,8 +255,9 @@ func (p *Protocol) getTable(nft *nftables.NFTables, attrs map[uint16]nlmsg.Bytes
250255
if err != nil {
251256
return err
252257
}
258+
// From net/netfilter/nf_tables_api.c:nf_tables_gettable
253259
m := ms.AddMessage(linux.NetlinkMessageHeader{
254-
Type: uint16(linux.NFNL_SUBSYS_NFTABLES)<<8 | uint16(linux.NFT_MSG_GETTABLE),
260+
Type: uint16(linux.NFNL_SUBSYS_NFTABLES)<<8 | uint16(linux.NFT_MSG_NEWTABLE),
255261
})
256262

257263
m.Put(&linux.NetFilterGenMsg{

0 commit comments

Comments
 (0)