From be97f91146d5717a1c6d43694fdb429b662846b3 Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Thu, 11 Jun 2015 20:43:54 +0200 Subject: chain: add netdev family support Add support for the new NFT_CHAIN_ATTR_DEV attribute that indicates that the basechain is attached to a net_device. This partially reworks 1dd9ba1ea23c ("table: add netdev family support"). Signed-off-by: Pablo Neira Ayuso --- tests/nft-chain-test.c | 4 ++++ tests/nft-table-test.c | 9 +++------ 2 files changed, 7 insertions(+), 6 deletions(-) (limited to 'tests') diff --git a/tests/nft-chain-test.c b/tests/nft-chain-test.c index 1ff8334..ff8afed 100644 --- a/tests/nft-chain-test.c +++ b/tests/nft-chain-test.c @@ -59,6 +59,9 @@ static void cmp_nft_chain(struct nft_chain *a, struct nft_chain *b) if (strcmp(nft_chain_attr_get_str(a, NFT_CHAIN_ATTR_TYPE), nft_chain_attr_get_str(b, NFT_CHAIN_ATTR_TYPE)) != 0) print_err("Chain type mismatches"); + if (strcmp(nft_chain_attr_get_str(a, NFT_CHAIN_ATTR_DEV), + nft_chain_attr_get_str(b, NFT_CHAIN_ATTR_DEV)) != 0) + print_err("Chain device mismatches"); } int main(int argc, char *argv[]) @@ -83,6 +86,7 @@ int main(int argc, char *argv[]) nft_chain_attr_set_u64(a, NFT_CHAIN_ATTR_BYTES, 0x1234567812345678); nft_chain_attr_set_u64(a, NFT_CHAIN_ATTR_HANDLE, 0x1234567812345678); nft_chain_attr_set_str(a, NFT_CHAIN_ATTR_TYPE, "Prueba"); + nft_chain_attr_set_str(a, NFT_CHAIN_ATTR_DEV, "eth0"); /* cmd extracted from include/linux/netfilter/nf_tables.h */ nlh = nft_chain_nlmsg_build_hdr(buf, NFT_MSG_NEWCHAIN, AF_INET, diff --git a/tests/nft-table-test.c b/tests/nft-table-test.c index 4714131..2096ea5 100644 --- a/tests/nft-table-test.c +++ b/tests/nft-table-test.c @@ -35,27 +35,24 @@ static void cmp_nft_table(struct nft_table *a, struct nft_table *b) if (nft_table_attr_get_u32(a, NFT_TABLE_ATTR_FAMILY) != nft_table_attr_get_u32(b, NFT_TABLE_ATTR_FAMILY)) print_err("tabke family mismatches"); - if (strcmp(nft_table_attr_get_str(a, NFT_TABLE_ATTR_DEV), - nft_table_attr_get_str(b, NFT_TABLE_ATTR_DEV)) != 0) - print_err("table name mismatches"); } int main(int argc, char *argv[]) { char buf[4096]; struct nlmsghdr *nlh; - struct nft_table *a; - struct nft_table *b; + struct nft_table *a = NULL; + struct nft_table *b = NULL; a = nft_table_alloc(); b = nft_table_alloc(); + if (a == NULL || b == NULL) print_err("OOM"); nft_table_attr_set_str(a, NFT_TABLE_ATTR_NAME, "test"); nft_table_attr_set_u32(a, NFT_TABLE_ATTR_FAMILY, AF_INET); nft_table_attr_set_u32(a, NFT_TABLE_ATTR_FLAGS, 0); - nft_table_attr_set_str(a, NFT_TABLE_ATTR_DEV, "test"); /* cmd extracted from include/linux/netfilter/nf_tables.h */ nlh = nft_table_nlmsg_build_hdr(buf, NFT_MSG_NEWTABLE, AF_INET, 0, -- cgit v1.2.3