History

netfilter: nf_tables: extend tracing infrastructure

nft monitor mode can then decode and display this trace data. Parts of LL/Network/Transport headers are provided as separate attributes. Otherwise, printing IP address data becomes virtually impossible for userspace since in the case of the netdev family we really don't want userspace to have to know all the possible link layer types and/or sizes just to display/print an ip address. We also don't want userspace to have to follow ipv6 header chains to get the s/dport info, the kernel already did this work for us. To avoid bloating nft_do_chain all data required for tracing is encapsulated in nft_traceinfo. The structure is initialized unconditionally(!) for each nft_do_chain invocation. This unconditionall call will be moved under a static key in a followup patch. With lots of help from Patrick McHardy and Pablo Neira.

Florian Westphal committed 10 years ago

Commit 33d5a7b1 parent 7ec3f7b8 files · +398 −19Browse files

Showing the changes to include/uapi (2 of 8 files). Show all

Unified · Split

2 files
  1. include/uapi/linux/netfilter/nf_tables.h +52 −0
  2. include/uapi/linux/netfilter/nfnetlink.h +2 −0
include/uapi/linux/netfilter/nf_tables.h+52−0
@@ -83,6 +83,7 @@ enum nft_verdicts { · 82 unmodified lines
83 * @NFT_MSG_DELSETELEM: delete a set element (enum nft_set_elem_attributes)83 * @NFT_MSG_DELSETELEM: delete a set element (enum nft_set_elem_attributes)
84 * @NFT_MSG_NEWGEN: announce a new generation, only for events (enum nft_gen_attributes)84 * @NFT_MSG_NEWGEN: announce a new generation, only for events (enum nft_gen_attributes)
85 * @NFT_MSG_GETGEN: get the rule-set generation (enum nft_gen_attributes)85 * @NFT_MSG_GETGEN: get the rule-set generation (enum nft_gen_attributes)
86 * @NFT_MSG_TRACE: trace event (enum nft_trace_attributes)
86 */87 */
87enum nf_tables_msg_types {88enum nf_tables_msg_types {
88 NFT_MSG_NEWTABLE,89 NFT_MSG_NEWTABLE,
@@ -102,6 +103,7 @@ enum nf_tables_msg_types { · 13 unmodified lines
102 NFT_MSG_DELSETELEM,103 NFT_MSG_DELSETELEM,
103 NFT_MSG_NEWGEN,104 NFT_MSG_NEWGEN,
104 NFT_MSG_GETGEN,105 NFT_MSG_GETGEN,
106 NFT_MSG_TRACE,
105 NFT_MSG_MAX,107 NFT_MSG_MAX,
106};108};
107 109
@@ -987,4 +989,54 @@ enum nft_gen_attributes { · 879 unmodified lines
987};989};
988#define NFTA_GEN_MAX (__NFTA_GEN_MAX - 1)990#define NFTA_GEN_MAX (__NFTA_GEN_MAX - 1)
989 991
992/**
993 * enum nft_trace_attributes - nf_tables trace netlink attributes
994 *
995 * @NFTA_TRACE_TABLE: name of the table (NLA_STRING)
996 * @NFTA_TRACE_CHAIN: name of the chain (NLA_STRING)
997 * @NFTA_TRACE_RULE_HANDLE: numeric handle of the rule (NLA_U64)
998 * @NFTA_TRACE_TYPE: type of the event (NLA_U32: nft_trace_types)
999 * @NFTA_TRACE_VERDICT: verdict returned by hook (NLA_NESTED: nft_verdicts)
1000 * @NFTA_TRACE_ID: pseudo-id, same for each skb traced (NLA_U32)
1001 * @NFTA_TRACE_LL_HEADER: linklayer header (NLA_BINARY)
1002 * @NFTA_TRACE_NETWORK_HEADER: network header (NLA_BINARY)
1003 * @NFTA_TRACE_TRANSPORT_HEADER: transport header (NLA_BINARY)
1004 * @NFTA_TRACE_IIF: indev ifindex (NLA_U32)
1005 * @NFTA_TRACE_IIFTYPE: netdev->type of indev (NLA_U16)
1006 * @NFTA_TRACE_OIF: outdev ifindex (NLA_U32)
1007 * @NFTA_TRACE_OIFTYPE: netdev->type of outdev (NLA_U16)
1008 * @NFTA_TRACE_MARK: nfmark (NLA_U32)
1009 * @NFTA_TRACE_NFPROTO: nf protocol processed (NLA_U32)
1010 * @NFTA_TRACE_POLICY: policy that decided fate of packet (NLA_U32)
1011 */
1012enum nft_trace_attibutes {
1013 NFTA_TRACE_UNSPEC,
1014 NFTA_TRACE_TABLE,
1015 NFTA_TRACE_CHAIN,
1016 NFTA_TRACE_RULE_HANDLE,
1017 NFTA_TRACE_TYPE,
1018 NFTA_TRACE_VERDICT,
1019 NFTA_TRACE_ID,
1020 NFTA_TRACE_LL_HEADER,
1021 NFTA_TRACE_NETWORK_HEADER,
1022 NFTA_TRACE_TRANSPORT_HEADER,
1023 NFTA_TRACE_IIF,
1024 NFTA_TRACE_IIFTYPE,
1025 NFTA_TRACE_OIF,
1026 NFTA_TRACE_OIFTYPE,
1027 NFTA_TRACE_MARK,
1028 NFTA_TRACE_NFPROTO,
1029 NFTA_TRACE_POLICY,
1030 __NFTA_TRACE_MAX
1031};
1032#define NFTA_TRACE_MAX (__NFTA_TRACE_MAX - 1)
1033
1034enum nft_trace_types {
1035 NFT_TRACETYPE_UNSPEC,
1036 NFT_TRACETYPE_POLICY,
1037 NFT_TRACETYPE_RETURN,
1038 NFT_TRACETYPE_RULE,
1039 __NFT_TRACETYPE_MAX
1040};
1041#define NFT_TRACETYPE_MAX (__NFT_TRACETYPE_MAX - 1)
990#endif /* _LINUX_NF_TABLES_H */1042#endif /* _LINUX_NF_TABLES_H */
include/uapi/linux/netfilter/nfnetlink.h+2−0
@@ -22,6 +22,8 @@ enum nfnetlink_groups { · 21 unmodified lines
22#define NFNLGRP_NFTABLES NFNLGRP_NFTABLES22#define NFNLGRP_NFTABLES NFNLGRP_NFTABLES
23 NFNLGRP_ACCT_QUOTA,23 NFNLGRP_ACCT_QUOTA,
24#define NFNLGRP_ACCT_QUOTA NFNLGRP_ACCT_QUOTA24#define NFNLGRP_ACCT_QUOTA NFNLGRP_ACCT_QUOTA
25 NFNLGRP_NFTRACE,
26#define NFNLGRP_NFTRACE NFNLGRP_NFTRACE
25 __NFNLGRP_MAX,27 __NFNLGRP_MAX,
26};28};
27#define NFNLGRP_MAX (__NFNLGRP_MAX - 1)29#define NFNLGRP_MAX (__NFNLGRP_MAX - 1)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t