Netfilter updates for net-next
Subsystems (5)
Pablo Neira Ayuso
maintainercover Netfilter updates for net-next
Hi David,
The following patchset contains the first batch of Netfilter updates for the upcoming 4.5 kernel. This batch contains userspace netfilter header compilation fixes, support for packet mangling in nf_tables, the new tracing infrastructure for nf_tables and cgroup2 support for iptables. More specifically, they are:
1) Two patches to include dependencies in our netfilter userspace headers to resolve compilation problems, from Mikko Rapeli.
2) Four comestic cleanup patches for the ebtables codebase, from Ian Morris.
3) Remove duplicate include in the netfilter reject infrastructure, from Stephen Hemminger.
4) Two patches to simplify the netfilter defragmentation code for IPv6, patch from Florian Westphal.
5) Fix root ownership of /proc/net netfilter for unpriviledged net namespaces, from Philip Whineray.
6) Get rid of unused fields in struct nft_pktinfo, from Florian Westphal.
7) Add mangling support to our nf_tables payload expression, from Patrick McHardy.
8) Introduce a new netlink-based tracing infrastructure for nf_tables, from Florian Westphal.
9) Change setter functions in nfnetlink_log to be void, from Rami Rosen.
10) Add netns support to the cttimeout infrastructure.
11) Add cgroup2 support to iptables, from Tejun Heo.
12) Introduce nfnl_dereference_protected() in nfnetlink, from Florian.
13) Add support for mangling pkttype in the nf_tables meta expression, also from Florian.
BTW, I need that you pull net into net-next, I have another batch that requires changes that I don't yet see in net.
You can pull these changes from:
git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf-next.git
Thanks!
----------------------------------------------------------------
The following changes since commit cb4396edd84ed73081635fb933d19c1410fafaf4:
drivers/net: fix eisa_driver probe section mismatch (2015-12-14 00:24:22 -0500)
are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf-next.git HEAD
for you to fetch changes up to b4aae759c22e71a3c32144f0b3bc4f2fa4aaae98:
netfilter: meta: add support for setting skb->pkttype (2015-12-18 14:12:56 +0100)
----------------------------------------------------------------
Florian Westphal (9):
netfilter: ipv6: nf_defrag: avoid/free clone operations
netfilter: ipv6: avoid nf_iterate recursion
netfilter: nf_tables: remove unused struct members
netfilter: nf_tables: extend tracing infrastructure
netfilter: nf_tables: wrap tracing with a static key
netfilter: ipv6: nf_defrag: fix NULL deref panic
netfilter: nf_tables: fix nf_log_trace based tracing
nfnetlink: add nfnl_dereference_protected helper
netfilter: meta: add support for setting skb->pkttype
Ian Morris (4):
netfilter-bridge: Cleanse indentation
netfilter-bridge: use netdev style comments
netfilter-bridge: brace placement
netfilter-bridge: layout of if statements
Marcelo Ricardo Leitner (1):
netfilter: nf_ct_sctp: move ip_ct_sctp away from UAPI
Mikko Rapeli (2):
netfilter: ebtables: use __u64 from linux/types.h
netfilter: fix include files for compilation
Pablo Neira (1):
netfilter: cttimeout: add netns support
Pablo Neira Ayuso (1):
Merge branch 'master' of git://git.kernel.org/.../davem/net-next
Patrick McHardy (1):
netfilter: nft_payload: add packet mangling support
Philip Whineray (1):
netfilter: Set /proc/net entries owner to root in namespace
Rosen, Rami (1):
netfilter: nfnetlink_log: Change setter functions to be void
Tejun Heo (2):
netfilter: prepare xt_cgroup for multi revisions
netfilter: implement xt_cgroup cgroup2 path match
stephen hemminger (1):
netfilter: remove duplicate include
include/linux/netfilter/nf_conntrack_sctp.h | 13 + include/net/net_namespace.h | 3 + include/net/netfilter/ipv6/nf_defrag_ipv6.h | 3 +- include/net/netfilter/nf_conntrack_timeout.h | 2 +- include/net/netfilter/nf_tables.h | 34 ++- include/net/netfilter/nf_tables_core.h | 10 + include/net/netfilter/nft_meta.h | 3 + include/uapi/linux/netfilter/ipset/ip_set_bitmap.h | 2 + include/uapi/linux/netfilter/ipset/ip_set_hash.h | 2 + include/uapi/linux/netfilter/ipset/ip_set_list.h | 2 + include/uapi/linux/netfilter/nf_conntrack_sctp.h | 12 +- .../linux/netfilter/nf_conntrack_tuple_common.h | 3 + include/uapi/linux/netfilter/nf_tables.h | 69 ++++++ include/uapi/linux/netfilter/nfnetlink.h | 2 + include/uapi/linux/netfilter/xt_HMARK.h | 1 + include/uapi/linux/netfilter/xt_RATEEST.h | 1 + include/uapi/linux/netfilter/xt_TEE.h | 2 + include/uapi/linux/netfilter/xt_TPROXY.h | 1 + include/uapi/linux/netfilter/xt_cgroup.h | 15 +- include/uapi/linux/netfilter/xt_hashlimit.h | 1 + include/uapi/linux/netfilter/xt_ipvs.h | 1 + include/uapi/linux/netfilter/xt_mac.h | 2 + include/uapi/linux/netfilter/xt_osf.h | 2 + include/uapi/linux/netfilter/xt_physdev.h | 2 +- include/uapi/linux/netfilter/xt_policy.h | 2 + include/uapi/linux/netfilter/xt_rateest.h | 1 + include/uapi/linux/netfilter/xt_recent.h | 1 + include/uapi/linux/netfilter/xt_sctp.h | 12 +- include/uapi/linux/netfilter_arp/arp_tables.h | 1 + include/uapi/linux/netfilter_bridge.h | 1 + include/uapi/linux/netfilter_bridge/ebt_arp.h | 1 + include/uapi/linux/netfilter_bridge/ebt_arpreply.h | 2 + include/uapi/linux/netfilter_bridge/ebt_ip6.h | 1 + include/uapi/linux/netfilter_bridge/ebt_nat.h | 2 + include/uapi/linux/netfilter_bridge/ebtables.h | 6 +- include/uapi/linux/netfilter_ipv4/ip_tables.h | 1 + include/uapi/linux/netfilter_ipv6/ip6_tables.h | 1 + include/uapi/linux/netfilter_ipv6/ip6t_rt.h | 2 +- net/bridge/netfilter/ebt_ip6.c | 4 +- net/bridge/netfilter/ebt_log.c | 9 +- net/bridge/netfilter/ebt_stp.c | 2 +- net/bridge/netfilter/ebt_vlan.c | 15 +- net/bridge/netfilter/ebtable_filter.c | 2 +- net/bridge/netfilter/ebtable_nat.c | 2 +- net/bridge/netfilter/ebtables.c | 139 ++++++----- net/bridge/netfilter/nft_meta_bridge.c | 1 + net/ipv4/netfilter/nf_reject_ipv4.c | 1 - net/ipv6/netfilter/nf_conntrack_reasm.c | 167 ++++++------- net/ipv6/netfilter/nf_defrag_ipv6_hooks.c | 20 +- net/ipv6/netfilter/nf_reject_ipv6.c | 1 - net/netfilter/Makefile | 2 +- net/netfilter/nf_conntrack_expect.c | 7 + net/netfilter/nf_conntrack_standalone.c | 7 + net/netfilter/nf_conntrack_timeout.c | 2 +- net/netfilter/nf_tables_api.c | 12 +- net/netfilter/nf_tables_core.c | 62 +++-- net/netfilter/nf_tables_trace.c | 275 +++++++++++++++++++++ net/netfilter/nfnetlink.c | 14 +- net/netfilter/nfnetlink_cttimeout.c | 82 +++--- net/netfilter/nfnetlink_log.c | 23 +- net/netfilter/nft_meta.c | 54 ++++ net/netfilter/nft_payload.c | 135 +++++++++- net/netfilter/x_tables.c | 12 + net/netfilter/xt_CT.c | 2 +- net/netfilter/xt_cgroup.c | 105 ++++++-- net/openvswitch/conntrack.c | 25 +- 66 files changed, 1062 insertions(+), 342 deletions(-) create mode 100644 include/linux/netfilter/nf_conntrack_sctp.h create mode 100644 net/netfilter/nf_tables_trace.c
Pablo Neira Ayuso
maintainerPATCH 1/23 netfilter: ebtables: use __u64 from linux/types.h
From: Mikko Rapeli <[email protected]>
Fixes userspace compilation error:
linux/netfilter_bridge/ebtables.h:38:2: error: unknown type name ‘uint64_t’
--- include/uapi/linux/netfilter_bridge/ebtables.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
include/uapi/linux/netfilter_bridge/ebtables.h +4 -2
@@ -12,6 +12,8 @@#ifndef _UAPI__LINUX_BRIDGE_EFF_H#define _UAPI__LINUX_BRIDGE_EFF_H +#include <linux/types.h> +#include <linux/if.h> #include <linux/netfilter_bridge.h> #define EBT_TABLE_MAXNAMELEN 32
@@ -33,8 +35,8 @@ struct xt_match;struct xt_target ;struct ebt_counter { -uint64_t pcnt; -uint64_t bcnt; +__u64 pcnt; +__u64 bcnt; };struct ebt_replace {
Signature · 1 line
2.1.4
Pablo Neira Ayuso
maintainerPATCH 2/23 netfilter: fix include files for compilation
In reply to Pablo Neira AyusoFrom: Mikko Rapeli <[email protected]>
Add missing header dependencies and other small changes so that each file compiles alone in userspace.
--- include/uapi/linux/netfilter/ipset/ip_set_bitmap.h | 2 ++ include/uapi/linux/netfilter/ipset/ip_set_hash.h | 2 ++ include/uapi/linux/netfilter/ipset/ip_set_list.h | 2 ++ include/uapi/linux/netfilter/nf_conntrack_tuple_common.h | 3 +++ include/uapi/linux/netfilter/xt_HMARK.h | 1 + include/uapi/linux/netfilter/xt_RATEEST.h | 1 + include/uapi/linux/netfilter/xt_TEE.h | 2 ++ include/uapi/linux/netfilter/xt_TPROXY.h | 1 + include/uapi/linux/netfilter/xt_hashlimit.h | 1 + include/uapi/linux/netfilter/xt_ipvs.h | 1 + include/uapi/linux/netfilter/xt_mac.h | 2 ++ include/uapi/linux/netfilter/xt_osf.h | 2 ++ include/uapi/linux/netfilter/xt_physdev.h | 2 +- include/uapi/linux/netfilter/xt_policy.h | 2 ++ include/uapi/linux/netfilter/xt_rateest.h | 1 + include/uapi/linux/netfilter/xt_recent.h | 1 + include/uapi/linux/netfilter/xt_sctp.h | 12 ++++++------ include/uapi/linux/netfilter_arp/arp_tables.h | 1 + include/uapi/linux/netfilter_bridge.h | 1 + include/uapi/linux/netfilter_bridge/ebt_arp.h | 1 + include/uapi/linux/netfilter_bridge/ebt_arpreply.h | 2 ++ include/uapi/linux/netfilter_bridge/ebt_ip6.h | 1 + include/uapi/linux/netfilter_bridge/ebt_nat.h | 2 ++ include/uapi/linux/netfilter_ipv4/ip_tables.h | 1 + include/uapi/linux/netfilter_ipv6/ip6_tables.h | 1 + include/uapi/linux/netfilter_ipv6/ip6t_rt.h | 2 +- 26 files changed, 42 insertions(+), 8 deletions(-)
include/uapi/linux/netfilter/ipset/ip_set_bitmap.h +2 -0
@@ -1,6 +1,8 @@#ifndef _UAPI__IP_SET_BITMAP_H#define _UAPI__IP_SET_BITMAP_H +#include <linux/netfilter/ipset/ip_set.h> +/* Bitmap type specific error codes */ enum { /* The element is out of the range of the set */
include/uapi/linux/netfilter/ipset/ip_set_hash.h +2 -0
@@ -1,6 +1,8 @@#ifndef _UAPI__IP_SET_HASH_H#define _UAPI__IP_SET_HASH_H +#include <linux/netfilter/ipset/ip_set.h> +/* Hash type specific error codes */ enum { /* Hash is full */
include/uapi/linux/netfilter/ipset/ip_set_list.h +2 -0
@@ -1,6 +1,8 @@#ifndef _UAPI__IP_SET_LIST_H#define _UAPI__IP_SET_LIST_H +#include <linux/netfilter/ipset/ip_set.h> +/* List type specific error codes */ enum { /* Set name to be added/deleted/tested does not exist. */
include/uapi/linux/netfilter/nf_conntrack_tuple_common.h +3 -0
@@ -1,6 +1,9 @@#ifndef _NF_CONNTRACK_TUPLE_COMMON_H#define _NF_CONNTRACK_TUPLE_COMMON_H +#include <linux/types.h> +#include <linux/netfilter.h> +enum ip_conntrack_dir {IP_CT_DIR_ORIGINAL , IP_CT_DIR_REPLY,
include/uapi/linux/netfilter/xt_HMARK.h +1 -0
@@ -2,6 +2,7 @@#define XT_HMARK_H_ #include <linux/types.h> +#include <linux/netfilter.h> enum {XT_HMARK_SADDR_MASK ,
include/uapi/linux/netfilter/xt_RATEEST.h +1 -0
@@ -2,6 +2,7 @@#define _XT_RATEEST_TARGET_H#include <linux/types.h> +#include <linux/if.h> struct xt_rateest_target_info {char name[IFNAMSIZ ];
include/uapi/linux/netfilter/xt_TEE.h +2 -0
@@ -1,6 +1,8 @@ #ifndef _XT_TEE_TARGET_H #define _XT_TEE_TARGET_H +#include <linux/netfilter.h> + struct xt_tee_tginfo { union nf_inet_addr gw; char oif[16];
include/uapi/linux/netfilter/xt_TPROXY.h +1 -0
@@ -2,6 +2,7 @@#define _XT_TPROXY_H#include <linux/types.h> +#include <linux/netfilter.h> /* TPROXY target is capable of marking the packet to perform * redirection. We can get rid of that whenever we get support for
include/uapi/linux/netfilter/xt_hashlimit.h +1 -0
@@ -2,6 +2,7 @@#define _UAPI_XT_HASHLIMIT_H#include <linux/types.h> +#include <linux/if.h> /* timings are in milliseconds. */ #define XT_HASHLIMIT_SCALE 10000
include/uapi/linux/netfilter/xt_ipvs.h +1 -0
@@ -2,6 +2,7 @@#define _XT_IPVS_H#include <linux/types.h> +#include <linux/netfilter.h> enum {XT_IPVS_IPVS_PROPERTY =1 <<0 ,/* all other options imply this one */
include/uapi/linux/netfilter/xt_mac.h +2 -0
@@ -1,6 +1,8 @@ #ifndef _XT_MAC_H #define _XT_MAC_H +#include <linux/if_ether.h> + struct xt_mac_info { unsigned char srcaddr[ETH_ALEN]; int invert;
include/uapi/linux/netfilter/xt_osf.h +2 -0
@@ -20,6 +20,8 @@#define _XT_OSF_H#include <linux/types.h> +#include <linux/ip.h> +#include <linux/tcp.h> #define MAXGENRELEN 32
include/uapi/linux/netfilter/xt_physdev.h +1 -1
@@ -2,7 +2,7 @@#define _UAPI_XT_PHYSDEV_H#include <linux/types.h> - +#include <linux/if.h> #define XT_PHYSDEV_OP_IN 0x01#define XT_PHYSDEV_OP_OUT 0x02
include/uapi/linux/netfilter/xt_policy.h +2 -0
@@ -2,6 +2,8 @@#define _XT_POLICY_H#include <linux/types.h> +#include <linux/in.h> +#include <linux/in6.h> #define XT_POLICY_MAX_ELEM 4
include/uapi/linux/netfilter/xt_rateest.h +1 -0
@@ -2,6 +2,7 @@#define _XT_RATEEST_MATCH_H#include <linux/types.h> +#include <linux/if.h> enum xt_rateest_match_flags {XT_RATEEST_MATCH_INVERT =1 <<0 ,
include/uapi/linux/netfilter/xt_recent.h +1 -0
@@ -2,6 +2,7 @@#define _LINUX_NETFILTER_XT_RECENT_H 1#include <linux/types.h> +#include <linux/netfilter.h> enum {XT_RECENT_CHECK =1 <<0 ,
include/uapi/linux/netfilter/xt_sctp.h +6 -6
@@ -66,26 +66,26 @@ struct xt_sctp_info {#define SCTP_CHUNKMAP_IS_CLEAR (chunkmap) \ __sctp_chunkmap_is_clear((chunkmap), ARRAY_SIZE(chunkmap)) -static inline bool +static inline _Bool __sctp_chunkmap_is_clear (const __u32 *chunkmap,unsigned int n) {unsigned int i;for (i =0 ; i < n; ++i)if (chunkmap[i]) -return false; -return true; +return 0 ; +return 1 ; }#define SCTP_CHUNKMAP_IS_ALL_SET (chunkmap) \ __sctp_chunkmap_is_all_set((chunkmap), ARRAY_SIZE(chunkmap)) -static inline bool +static inline _Bool __sctp_chunkmap_is_all_set (const __u32 *chunkmap,unsigned int n) {unsigned int i;for (i =0 ; i < n; ++i)if (chunkmap[i] != ~0U ) -return false; -return true; +return 0 ; +return 1 ; }#endif /* _XT_SCTP_H_ */
include/uapi/linux/netfilter_arp/arp_tables.h +1 -0
@@ -11,6 +11,7 @@#include <linux/types.h> #include <linux/compiler.h> +#include <linux/if.h> #include <linux/netfilter_arp.h> #include <linux/netfilter/x_tables.h>
include/uapi/linux/netfilter_bridge.h +1 -0
@@ -4,6 +4,7 @@/* bridge-specific defines for netfilter. */ +#include <linux/in.h> #include <linux/netfilter.h> #include <linux/if_ether.h> #include <linux/if_vlan.h>
include/uapi/linux/netfilter_bridge/ebt_arp.h +1 -0
@@ -2,6 +2,7 @@#define __LINUX_BRIDGE_EBT_ARP_H#include <linux/types.h> +#include <linux/if_ether.h> #define EBT_ARP_OPCODE 0x01#define EBT_ARP_HTYPE 0x02
include/uapi/linux/netfilter_bridge/ebt_arpreply.h +2 -0
@@ -1,6 +1,8 @@ #ifndef __LINUX_BRIDGE_EBT_ARPREPLY_H #define __LINUX_BRIDGE_EBT_ARPREPLY_H +#include <linux/if_ether.h> + struct ebt_arpreply_info { unsigned char mac[ETH_ALEN]; int target;
include/uapi/linux/netfilter_bridge/ebt_ip6.h +1 -0
@@ -13,6 +13,7 @@#define __LINUX_BRIDGE_EBT_IP6_H#include <linux/types.h> +#include <linux/in6.h> #define EBT_IP6_SOURCE 0x01#define EBT_IP6_DEST 0x02
include/uapi/linux/netfilter_bridge/ebt_nat.h +2 -0
@@ -1,6 +1,8 @@ #ifndef __LINUX_BRIDGE_EBT_NAT_H #define __LINUX_BRIDGE_EBT_NAT_H +#include <linux/if_ether.h> + #define NAT_ARP_BIT (0x00000010) struct ebt_nat_info { unsigned char mac[ETH_ALEN];
include/uapi/linux/netfilter_ipv4/ip_tables.h +1 -0
@@ -17,6 +17,7 @@#include <linux/types.h> #include <linux/compiler.h> +#include <linux/if.h> #include <linux/netfilter_ipv4.h> #include <linux/netfilter/x_tables.h>
include/uapi/linux/netfilter_ipv6/ip6_tables.h +1 -0
@@ -17,6 +17,7 @@#include <linux/types.h> #include <linux/compiler.h> +#include <linux/if.h> #include <linux/netfilter_ipv6.h> #include <linux/netfilter/x_tables.h>
include/uapi/linux/netfilter_ipv6/ip6t_rt.h +1 -1
@@ -2,7 +2,7 @@#define _IP6T_RT_H#include <linux/types.h> -/*#include <linux/in6.h>*/ +#include <linux/in6.h> #define IP6T_RT_HOPS 16
Signature · 1 line
2.1.4
Pablo Neira Ayuso
maintainerPATCH 3/23 netfilter-bridge: Cleanse indentation
In reply to Pablo Neira AyusoFrom: Ian Morris <[email protected]>
Fixes a bunch of issues detected by checkpatch with regards to code indentation.
No changes detected by objdiff.
--- net/bridge/netfilter/ebt_stp.c | 2 +- net/bridge/netfilter/ebtable_filter.c | 2 +- net/bridge/netfilter/ebtable_nat.c | 2 +- net/bridge/netfilter/ebtables.c | 44 +++++++++++++++++------------------ 4 files changed, 25 insertions(+), 25 deletions(-)
net/bridge/netfilter/ebt_stp.c +1 -1
@@ -41,7 +41,7 @@ struct stp_config_pdu {#define NR32 (p) ((p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3])static bool ebt_filter_config (const struct ebt_stp_info *info, -const struct stp_config_pdu *stpc) +const struct stp_config_pdu *stpc) {const struct ebt_stp_config_info *c;uint16_t v16;
net/bridge/netfilter/ebtable_filter.c +1 -1
@@ -12,7 +12,7 @@#include <linux/module.h> #define FILTER_VALID_HOOKS ((1 << NF_BR_LOCAL_IN) | (1 << NF_BR_FORWARD) | \ - (1 << NF_BR_LOCAL_OUT)) + (1 << NF_BR_LOCAL_OUT))static struct ebt_entries initial_chains[] = { {
net/bridge/netfilter/ebtable_nat.c +1 -1
@@ -12,7 +12,7 @@#include <linux/module.h> #define NAT_VALID_HOOKS ((1 << NF_BR_PRE_ROUTING) | (1 << NF_BR_LOCAL_OUT) | \ - (1 << NF_BR_POST_ROUTING)) + (1 << NF_BR_POST_ROUTING))static struct ebt_entries initial_chains[] = { {
net/bridge/netfilter/ebtables.c +22 -22
134 lines not on this page · raw message
Signature · 1 line
2.1.4
Pablo Neira Ayuso
maintainerPATCH 4/23 netfilter-bridge: use netdev style comments
In reply to Pablo Neira AyusoFrom: Ian Morris <[email protected]>
Changes comments to use netdev style.
No changes detected by objdiff.
--- net/bridge/netfilter/ebt_log.c | 3 +- net/bridge/netfilter/ebt_vlan.c | 15 +++++--- net/bridge/netfilter/ebtables.c | 84 +++++++++++++++++++++-------------------- 3 files changed, 56 insertions(+), 46 deletions(-)
net/bridge/netfilter/ebt_log.c +2 -1
@@ -152,7 +152,8 @@ ebt_log_packet(struct net *net, u_int8_t pf, unsigned int hooknum, ntohs(ah->ar_op));/* If it's for Ethernet and the lengths are OK, -* then log the ARP payload */ +* then log the ARP payload +*/ if (ah->ar_hrd ==htons (1 ) && ah->ar_hln ==ETH_ALEN && ah->ar_pln ==sizeof (__be32)) {
net/bridge/netfilter/ebt_vlan.c +10 -5
@@ -66,7 +66,8 @@ ebt_vlan_mt(const struct sk_buff *skb, struct xt_action_param *par)* - Canonical Format Indicator (CFI). The Canonical Format Indicator * (CFI) is a single bit flag value. Currently ignored. * - VLAN Identifier (VID). The VID is encoded as -* an unsigned binary number. */ +* an unsigned binary number. +*/ id =TCI &VLAN_VID_MASK ; prio = (TCI >>13 ) &0x7 ;
@@ -98,7 +99,8 @@ static int ebt_vlan_mt_check(const struct xt_mtchk_param *par) }/* Check for bitmask range -* True if even one bit is out of mask */ +* True if even one bit is out of mask +*/ if (info->bitmask & ~EBT_VLAN_MASK ) {pr_debug ("bitmask %2X is out of mask (%2X)\n" , info->bitmask,EBT_VLAN_MASK );
@@ -117,7 +119,8 @@ static int ebt_vlan_mt_check(const struct xt_mtchk_param *par)* 0 - The null VLAN ID. * 1 - The default Port VID (PVID) * 0x0FFF - Reserved for implementation use. -* if_vlan.h: VLAN_N_VID 4096. */ +* if_vlan.h: VLAN_N_VID 4096. +*/ if (GET_BITMASK (EBT_VLAN_ID )) {if (!!info->id) {/* if id!=0 => check vid range */ if (info->id >VLAN_N_VID ) {
@@ -128,7 +131,8 @@ static int ebt_vlan_mt_check(const struct xt_mtchk_param *par)/* Note: This is valid VLAN-tagged frame point. * Any value of user_priority are acceptable, * but should be ignored according to 802.1Q Std. -* So we just drop the prio flag. */ +* So we just drop the prio flag. +*/ info->bitmask &= ~EBT_VLAN_PRIO ; }/* Else, id=0 (null VLAN ID) => user_priority range (any?) */
@@ -143,7 +147,8 @@ static int ebt_vlan_mt_check(const struct xt_mtchk_param *par) }/* Check for encapsulated proto range - it is possible to be * any value for u_short range. -* if_ether.h: ETH_ZLEN 60 - Min. octets in frame sans FCS */ +* if_ether.h: ETH_ZLEN 60 - Min. octets in frame sans FCS +*/ if (GET_BITMASK (EBT_VLAN_ENCAP )) {if ((unsigned short )ntohs (info->encap) <ETH_ZLEN ) { pr_debug("encap frame length %d is less than "
net/bridge/netfilter/ebtables.c +44 -40
208 lines not on this page · raw message
Signature · 6 lines
2.1.4 -- To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Pablo Neira Ayuso
maintainerPATCH 5/23 netfilter-bridge: brace placement
In reply to Pablo Neira AyusoFrom: Ian Morris <[email protected]>
Change brace placement to eliminate checkpatch error.
No changes detected by objdiff.
--- net/bridge/netfilter/ebt_log.c | 6 ++---- net/bridge/netfilter/ebtables.c | 3 +-- 2 files changed, 3 insertions(+), 6 deletions(-)
net/bridge/netfilter/ebt_log.c +2 -4
@@ -36,14 +36,12 @@ static int ebt_log_tg_check(const struct xt_tgchk_param *par)return 0 ; } -struct tcpudphdr -{ +struct tcpudphdr {__be16 src;__be16 dst; }; -struct arppayload -{ +struct arppayload {unsigned char mac_src[ETH_ALEN ];unsigned char ip_src[4 ];unsigned char mac_dst[ETH_ALEN ];
net/bridge/netfilter/ebtables.c +1 -2
@@ -551,8 +551,7 @@ ebt_check_entry_size_and_hooks(const struct ebt_entry *e,return 0 ; } -struct ebt_cl_stack -{ +struct ebt_cl_stack {struct ebt_chainstack cs;int from;unsigned int hookmask;
Signature · 1 line
2.1.4
Pablo Neira Ayuso
maintainerPATCH 6/23 netfilter-bridge: layout of if statements
In reply to Pablo Neira AyusoFrom: Ian Morris <[email protected]>
Eliminate some checkpatch issues by improved layout of if statements.
No changes detected by objdiff.
--- net/bridge/netfilter/ebt_ip6.c | 4 ++-- net/bridge/netfilter/ebtables.c | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-)
net/bridge/netfilter/ebt_ip6.c +2 -2
@@ -65,8 +65,8 @@ ebt_ip6_mt(const struct sk_buff *skb, struct xt_action_param *par)return false;if (FWINV (info->protocol != nexthdr,EBT_IP6_PROTO ))return false; -if (!(info->bitmask & (EBT_IP6_DPORT | -EBT_IP6_SPORT |EBT_IP6_ICMP6 ))) +if (!(info->bitmask & (EBT_IP6_DPORT | +EBT_IP6_SPORT |EBT_IP6_ICMP6 )))return true;/* min icmpv6 headersize is 4, so sizeof(_pkthdr) is ok. */
net/bridge/netfilter/ebtables.c +4 -4
@@ -161,7 +161,7 @@ ebt_basic_match(const struct ebt_entry *e, const struct sk_buff *skb,for (i =0 ; i <6 ; i++) verdict |= (h->h_source[i] ^ e->sourcemac[i]) & e->sourcemsk[i]; -if (FWINV2 (verdict !=0 ,EBT_ISOURCE ) ) +if (FWINV2 (verdict !=0 ,EBT_ISOURCE ))return 1 ; }if (e->bitmask &EBT_DESTMAC ) {
@@ -169,7 +169,7 @@ ebt_basic_match(const struct ebt_entry *e, const struct sk_buff *skb,for (i =0 ; i <6 ; i++) verdict |= (h->h_dest[i] ^ e->destmac[i]) & e->destmsk[i]; -if (FWINV2 (verdict !=0 ,EBT_IDEST ) ) +if (FWINV2 (verdict !=0 ,EBT_IDEST ))return 1 ; }return 0 ;
@@ -673,7 +673,7 @@ ebt_check_entry(struct ebt_entry *e, struct net *net,BUGPRINT ("Unknown flag for inv bitmask\n" );return -EINVAL ; } -if ( (e->bitmask &EBT_NOPROTO ) && (e->bitmask &EBT_802_3 ) ) { +if ((e->bitmask &EBT_NOPROTO ) && (e->bitmask &EBT_802_3 )) {BUGPRINT ("NOPROTO & 802_3 not allowed\n" );return -EINVAL ; }
@@ -1370,7 +1370,7 @@ static inline int ebt_make_watchername(const struct ebt_entry_watcher *w,char name[EBT_FUNCTION_MAXNAMELEN ] = {};strlcpy (name, w->u.watcher->name,sizeof (name)); -if (copy_to_user (hlp , name,EBT_FUNCTION_MAXNAMELEN )) +if (copy_to_user (hlp, name,EBT_FUNCTION_MAXNAMELEN ))return -EFAULT ;return 0 ; }
Signature · 1 line
2.1.4
Pablo Neira Ayuso
maintainerPATCH 7/23 netfilter: nf_ct_sctp: move ip_ct_sctp away from UAPI
In reply to Pablo Neira AyusoFrom: Marcelo Ricardo Leitner <[email protected]>
ip_ct_sctp is an internal structure, embedded by the union nf_conntrack_proto to store sctp-specific information at conntrack entries. It has no business with UAPI.
This patch moves it from UAPI to a saner place, together with similar structs for other protocols.
--- include/linux/netfilter/nf_conntrack_sctp.h | 13 +++++++++++++ include/uapi/linux/netfilter/nf_conntrack_sctp.h | 12 +++--------- 2 files changed, 16 insertions(+), 9 deletions(-) create mode 100644 include/linux/netfilter/nf_conntrack_sctp.h
include/linux/netfilter/nf_conntrack_sctp.h new file +13 -0
@@ -0,0 +1,13 @@ +#ifndef _NF_CONNTRACK_SCTP_H +#define _NF_CONNTRACK_SCTP_H +/* SCTP tracking. */ + +#include <uapi/linux/netfilter/nf_conntrack_sctp.h> + +struct ip_ct_sctp { +enum sctp_conntrack state; + +__be32 vtag[IP_CT_DIR_MAX ]; +}; + +#endif /* _NF_CONNTRACK_SCTP_H */
include/uapi/linux/netfilter/nf_conntrack_sctp.h +3 -9
@@ -1,5 +1,5 @@ -#ifndef _NF_CONNTRACK_SCTP_H -#define _NF_CONNTRACK_SCTP_H +#ifndef _UAPI_NF_CONNTRACK_SCTP_H +#define _UAPI_NF_CONNTRACK_SCTP_H/* SCTP tracking. */ #include <linux/netfilter/nf_conntrack_tuple_common.h>
@@ -18,10 +18,4 @@ enum sctp_conntrack {SCTP_CONNTRACK_MAX }; -struct ip_ct_sctp { -enum sctp_conntrack state; - -__be32 vtag[IP_CT_DIR_MAX ]; -}; - -#endif /* _NF_CONNTRACK_SCTP_H */ +#endif /* _UAPI_NF_CONNTRACK_SCTP_H */
Signature · 1 line
2.1.4
Pablo Neira Ayuso
maintainerPATCH 8/23 netfilter: remove duplicate include
In reply to Pablo Neira AyusoFrom: stephen hemminger <[email protected]>
--- net/ipv4/netfilter/nf_reject_ipv4.c | 1 - net/ipv6/netfilter/nf_reject_ipv6.c | 1 - 2 files changed, 2 deletions(-)
net/ipv4/netfilter/nf_reject_ipv4.c +0 -1
@@ -14,7 +14,6 @@#include <net/netfilter/ipv4/nf_reject.h> #include <linux/netfilter_ipv4.h> #include <linux/netfilter_bridge.h> -#include <net/netfilter/ipv4/nf_reject.h> const struct tcphdr *nf_reject_ip_tcphdr_get (struct sk_buff *oldskb,struct tcphdr *_oth,int hook)
net/ipv6/netfilter/nf_reject_ipv6.c +0 -1
@@ -14,7 +14,6 @@#include <net/netfilter/ipv6/nf_reject.h> #include <linux/netfilter_ipv6.h> #include <linux/netfilter_bridge.h> -#include <net/netfilter/ipv6/nf_reject.h> const struct tcphdr *nf_reject_ip6_tcphdr_get(struct sk_buff *oldskb, struct tcphdr *otcph,
Signature · 1 line
2.1.4
Pablo Neira Ayuso
maintainerPATCH 9/23 netfilter: ipv6: nf_defrag: avoid/free clone operations
In reply to Pablo Neira AyusoFrom: Florian Westphal <[email protected]>
commit 6aafeef03b9d9ecf
("netfilter: push reasm skb through instead of original frag skbs") changed ipv6 defrag to not use the original skbs anymore.
So rather than keeping the original skbs around just to discard them afterwards just use the original skbs directly for the fraglist of the newly assembled skb and remove the extra clone/free operations.
The skb that completes the fragment queue is morphed into a the reassembled one instead, just like ipv4 defrag.
openvswitch doesn't need any additional skb_morph magic anymore to deal with this situation so just remove that.
A followup patch can then also remove the NF_HOOK (re)invocation in the ipv6 netfilter defrag hook.
--- include/net/netfilter/ipv6/nf_defrag_ipv6.h | 1 - net/ipv6/netfilter/nf_conntrack_reasm.c | 105 +++++++++++----------------- net/ipv6/netfilter/nf_defrag_ipv6_hooks.c | 6 -- net/openvswitch/conntrack.c | 14 ---- 4 files changed, 40 insertions(+), 86 deletions(-)
include/net/netfilter/ipv6/nf_defrag_ipv6.h +0 -1
@@ -6,7 +6,6 @@ void nf_defrag_ipv6_enable(void);int nf_ct_frag6_init (void );void nf_ct_frag6_cleanup (void );struct sk_buff *nf_ct_frag6_gather (struct net *net,struct sk_buff *skb,u32 user); -void nf_ct_frag6_consume_orig (struct sk_buff *skb);struct inet_frags_ctl ;
net/ipv6/netfilter/nf_conntrack_reasm.c +40 -65
181 lines not on this page · raw message
net/ipv6/netfilter/nf_defrag_ipv6_hooks.c +0 -6
@@ -69,12 +69,6 @@ static unsigned int ipv6_defrag(void *priv,if (reasm ==NULL )return NF_STOLEN ; -/* error occurred or not fragmented */ -if (reasm == skb) -return NF_ACCEPT ; - -nf_ct_frag6_consume_orig (reasm); -NF_HOOK_THRESH (NFPROTO_IPV6 , state->hook, state->net, state->sk, reasm, state->in, state->out, state->okfn,NF_IP6_PRI_CONNTRACK_DEFRAG +1 );
net/openvswitch/conntrack.c +0 -14
@@ -321,21 +321,7 @@ static int handle_fragments(struct net *net, struct sw_flow_key *key,if (!reasm)return -EINPROGRESS ; -if (skb == reasm) { -kfree_skb (skb); -return -EINVAL ; - } - -/* Don't free 'skb' even though it is one of the original -* fragments, as we're going to morph it into the head. -*/ -skb_get (skb); -nf_ct_frag6_consume_orig (reasm); - key->ip.proto =ipv6_hdr (reasm)->nexthdr; -skb_morph (skb, reasm); - skb->next = reasm->next; -consume_skb (reasm); ovs_cb.mru =IP6CB (skb)->frag_max_size;#endif }else {
Signature · 1 line
2.1.4
Pablo Neira Ayuso
maintainerPATCH 10/23 netfilter: ipv6: avoid nf_iterate recursion
In reply to Pablo Neira AyusoFrom: Florian Westphal <[email protected]>
The previous patch changed nf_ct_frag6_gather() to morph reassembled skb with the previous one.
This means that the return value is always NULL or the skb argument. So change it to an err value.
Instead of invoking NF_HOOK recursively with threshold to skip already-called hooks we can now just return NF_ACCEPT to move on to the next hook except for -EINPROGRESS (which means skb has been queued for reassembly), in which case we return NF_STOLEN.
--- include/net/netfilter/ipv6/nf_defrag_ipv6.h | 2 +- net/ipv6/netfilter/nf_conntrack_reasm.c | 71 +++++++++++++---------------- net/ipv6/netfilter/nf_defrag_ipv6_hooks.c | 14 ++---- net/openvswitch/conntrack.c | 11 ++--- 4 files changed, 42 insertions(+), 56 deletions(-)
include/net/netfilter/ipv6/nf_defrag_ipv6.h +1 -1
@@ -5,7 +5,7 @@ void nf_defrag_ipv6_enable(void);int nf_ct_frag6_init (void );void nf_ct_frag6_cleanup (void ); -struct sk_buff *nf_ct_frag6_gather (struct net *net,struct sk_buff *skb,u32 user); +int nf_ct_frag6_gather (struct net *net,struct sk_buff *skb,u32 user);struct inet_frags_ctl ;
net/ipv6/netfilter/nf_conntrack_reasm.c +31 -40
151 lines not on this page · raw message
net/ipv6/netfilter/nf_defrag_ipv6_hooks.c +5 -9
@@ -55,7 +55,7 @@ static unsigned int ipv6_defrag(void *priv,struct sk_buff *skb, const struct nf_hook_state *state) { - struct sk_buff *reasm; + int err;#if IS_ENABLED (CONFIG_NF_CONNTRACK )/* Previously seen (loopback)? */
@@ -63,17 +63,13 @@ static unsigned int ipv6_defrag(void *priv,return NF_ACCEPT ;#endif - reasm =nf_ct_frag6_gather (state->net, skb, -nf_ct6_defrag_user (state->hook, skb)); + err =nf_ct_frag6_gather (state->net, skb, +nf_ct6_defrag_user (state->hook, skb));/* queued */ -if (reasm ==NULL ) +if (err == -EINPROGRESS )return NF_STOLEN ; -NF_HOOK_THRESH (NFPROTO_IPV6 , state->hook, state->net, state->sk, reasm, - state->in, state->out, - state->okfn,NF_IP6_PRI_CONNTRACK_DEFRAG +1 ); - -return NF_STOLEN ; +return NF_ACCEPT ; }static struct nf_hook_ops ipv6_defrag_ops[] = {
net/openvswitch/conntrack.c +5 -6
@@ -300,10 +300,10 @@ static int handle_fragments(struct net *net, struct sw_flow_key *key, u16 zone, struct sk_buff *skb) { struct ovs_skb_cb ovs_cb = *OVS_CB(skb); +int err;if (key->eth.type ==htons (ETH_P_IP )) {enum ip_defrag_users user =IP_DEFRAG_CONNTRACK_IN + zone; -int err;memset (IPCB (skb),0 ,sizeof (struct inet_skb_parm )); err =ip_defrag (net, skb, user);
@@ -314,14 +314,13 @@ static int handle_fragments(struct net *net, struct sw_flow_key *key,#if IS_ENABLED (CONFIG_NF_DEFRAG_IPV6 ) } else if (key->eth.type == htons(ETH_P_IPV6)) {enum ip6_defrag_users user =IP6_DEFRAG_CONNTRACK_IN + zone; -struct sk_buff *reasm;memset (IP6CB (skb),0 ,sizeof (struct inet6_skb_parm )); - reasm =nf_ct_frag6_gather (net, skb, user); -if (!reasm) -return -EINPROGRESS ; + err =nf_ct_frag6_gather (net, skb, user); +if (err) +return err; - key->ip.proto =ipv6_hdr (reasm)->nexthdr; + key->ip.proto =ipv6_hdr (skb)->nexthdr; ovs_cb.mru =IP6CB (skb)->frag_max_size;#endif }else {
Signature · 1 line
2.1.4
Pablo Neira Ayuso
maintainerPATCH 11/23 netfilter: Set /proc/net entries owner to root in namespace
In reply to Pablo Neira AyusoFrom: Philip Whineray <[email protected]>
Various files are owned by root with 0440 permission. Reading them is impossible in an unprivileged user namespace, interfering with firewall tools. For instance, iptables-save relies on /proc/net/ip_tables_names contents to dump only loaded tables.
This patch assigned ownership of the following files to root in the current namespace:
- /proc/net/*_tables_names
- /proc/net/*_tables_matches
- /proc/net/*_tables_targets
- /proc/net/nf_conntrack
- /proc/net/nf_conntrack_expect
- /proc/net/netfilter/nfnetlink_log
A mapping for root must be available, so this order should be followed:
unshare(CLONE_NEWUSER);
/* Setup the mapping */unshare(CLONE_NEWNET);
--- net/netfilter/nf_conntrack_expect.c | 7 +++++++ net/netfilter/nf_conntrack_standalone.c | 7 +++++++ net/netfilter/nfnetlink_log.c | 15 +++++++++++++-- net/netfilter/x_tables.c | 12 ++++++++++++ 4 files changed, 39 insertions(+), 2 deletions(-)
net/netfilter/nf_conntrack_expect.c +7 -0
@@ -596,11 +596,18 @@ static int exp_proc_init(struct net *net) {#ifdef CONFIG_NF_CONNTRACK_PROCFS struct proc_dir_entry *proc; +kuid_t root_uid; +kgid_t root_gid; proc =proc_create ("nf_conntrack_expect" ,0440 , net->proc_net, &exp_file_ops);if (!proc)return -ENOMEM ; + + root_uid =make_kuid (net->user_ns,0 ); + root_gid =make_kgid (net->user_ns,0 ); +if (uid_valid (root_uid) &&gid_valid (root_gid)) +proc_set_user (proc, root_uid, root_gid);#endif /* CONFIG_NF_CONNTRACK_PROCFS */ return 0 ; }
net/netfilter/nf_conntrack_standalone.c +7 -0
@@ -392,11 +392,18 @@ static const struct file_operations ct_cpu_seq_fops = {static int nf_conntrack_standalone_init_proc (struct net *net) {struct proc_dir_entry *pde; +kuid_t root_uid; +kgid_t root_gid; pde =proc_create ("nf_conntrack" ,0440 , net->proc_net, &ct_file_ops);if (!pde) goto out_nf_conntrack; + root_uid =make_kuid (net->user_ns,0 ); + root_gid =make_kgid (net->user_ns,0 ); +if (uid_valid (root_uid) &&gid_valid (root_gid)) +proc_set_user (pde, root_uid, root_gid); + pde =proc_create ("nf_conntrack" ,S_IRUGO , net->proc_net_stat, &ct_cpu_seq_fops);if (!pde)
net/netfilter/nfnetlink_log.c +13 -2
@@ -1064,15 +1064,26 @@ static int __net_init nfnl_log_net_init(struct net *net) {unsigned int i;struct nfnl_log_net *log =nfnl_log_pernet (net); +#ifdef CONFIG_PROC_FS +struct proc_dir_entry *proc; +kuid_t root_uid; +kgid_t root_gid; +#endif for (i =0 ; i <INSTANCE_BUCKETS ; i++)INIT_HLIST_HEAD (&log->instance_table[i]);spin_lock_init (&log->instances_lock);#ifdef CONFIG_PROC_FS -if (!proc_create ("nfnetlink_log" ,0440 , - net->nf.proc_netfilter, &nful_file_ops)) + proc =proc_create ("nfnetlink_log" ,0440 , + net->nf.proc_netfilter, &nful_file_ops); +if (!proc)return -ENOMEM ; + + root_uid =make_kuid (net->user_ns,0 ); + root_gid =make_kgid (net->user_ns,0 ); +if (uid_valid (root_uid) &&gid_valid (root_gid)) +proc_set_user (proc, root_uid, root_gid);#endif return 0 ; }
net/netfilter/x_tables.c +12 -0
@@ -26,6 +26,7 @@#include <linux/mm.h> #include <linux/slab.h> #include <linux/audit.h> +#include <linux/user_namespace.h> #include <net/net_namespace.h> #include <linux/netfilter/x_tables.h>
@@ -1226,6 +1227,8 @@ int xt_proto_init(struct net *net, u_int8_t af)#ifdef CONFIG_PROC_FS char buf[XT_FUNCTION_MAXNAMELEN ];struct proc_dir_entry *proc; +kuid_t root_uid; +kgid_t root_gid;#endif if (af >=ARRAY_SIZE (xt_prefix))
@@ -1233,12 +1236,17 @@ int xt_proto_init(struct net *net, u_int8_t af)#ifdef CONFIG_PROC_FS + root_uid =make_kuid (net->user_ns,0 ); + root_gid =make_kgid (net->user_ns,0 ); +strlcpy (buf, xt_prefix[af],sizeof (buf));strlcat (buf,FORMAT_TABLES ,sizeof (buf)); proc =proc_create_data (buf,0440 , net->proc_net, &xt_table_ops, (void *)(unsigned long )af);if (!proc) goto out; +if (uid_valid (root_uid) &&gid_valid (root_gid)) +proc_set_user (proc, root_uid, root_gid);strlcpy (buf, xt_prefix[af],sizeof (buf));strlcat (buf,FORMAT_MATCHES ,sizeof (buf));
@@ -1246,6 +1254,8 @@ int xt_proto_init(struct net *net, u_int8_t af) (void *)(unsigned long)af);if (!proc) goto out_remove_tables; +if (uid_valid (root_uid) &&gid_valid (root_gid)) +proc_set_user (proc, root_uid, root_gid);strlcpy (buf, xt_prefix[af],sizeof (buf));strlcat (buf,FORMAT_TARGETS ,sizeof (buf));
@@ -1253,6 +1263,8 @@ int xt_proto_init(struct net *net, u_int8_t af) (void *)(unsigned long)af);if (!proc) goto out_remove_matches; +if (uid_valid (root_uid) &&gid_valid (root_gid)) +proc_set_user (proc, root_uid, root_gid);#endif return 0 ;
Signature · 1 line
2.1.4
Pablo Neira Ayuso
maintainerPATCH 12/23 netfilter: nf_tables: remove unused struct members
In reply to Pablo Neira AyusoFrom: Florian Westphal <[email protected]>
--- include/net/netfilter/nf_tables.h | 2 -- 1 file changed, 2 deletions(-)
include/net/netfilter/nf_tables.h +0 -2
@@ -19,8 +19,6 @@ struct nft_pktinfo {const struct net_device *out;u8 pf;u8 hook; -u8 nhoff; -u8 thoff;u8 tprot;/* for x_tables compatibility */ struct xt_action_param xt;
Signature · 1 line
2.1.4
Pablo Neira Ayuso
maintainerPATCH 13/23 netfilter: nft_payload: add packet mangling support
In reply to Pablo Neira AyusoFrom: Patrick McHardy <[email protected]>
Add support for mangling packet payload. Checksum for the specified base header is updated automatically if requested, however no updates for any kind of pseudo headers are supported, meaning no stateless NAT is supported.
For checksum updates different checksumming methods can be specified. The currently supported methods are NONE for no checksum updates, and INET for internet type checksums.
--- include/net/netfilter/nf_tables_core.h | 9 +++ include/uapi/linux/netfilter/nf_tables.h | 17 ++++ net/netfilter/nft_payload.c | 135 +++++++++++++++++++++++++++++-- 3 files changed, 155 insertions(+), 6 deletions(-)
include/net/netfilter/nf_tables_core.h +9 -0
@@ -47,6 +47,15 @@ struct nft_payload { enum nft_registers dreg:8; }; +struct nft_payload_set { +enum nft_payload_bases base:8 ; +u8 offset; +u8 len; +enum nft_registers sreg:8 ; +u8 csum_type; +u8 csum_offset; +}; +extern const struct nft_expr_ops nft_payload_fast_ops;int nft_payload_module_init (void );
include/uapi/linux/netfilter/nf_tables.h +17 -0
@@ -598,12 +598,26 @@ enum nft_payload_bases { };/** +* enum nft_payload_csum_types - nf_tables payload expression checksum types +* +* @NFT_PAYLOAD_CSUM_NONE: no checksumming +* @NFT_PAYLOAD_CSUM_INET: internet checksum (RFC 791) +*/ +enum nft_payload_csum_types { +NFT_PAYLOAD_CSUM_NONE , +NFT_PAYLOAD_CSUM_INET , +}; + +/** * enum nft_payload_attributes - nf_tables payload expression netlink attributes * * @NFTA_PAYLOAD_DREG: destination register to load data into (NLA_U32: nft_registers) * @NFTA_PAYLOAD_BASE: payload base (NLA_U32: nft_payload_bases) * @NFTA_PAYLOAD_OFFSET: payload offset relative to base (NLA_U32) * @NFTA_PAYLOAD_LEN: payload length (NLA_U32) +* @NFTA_PAYLOAD_SREG: source register to load data from (NLA_U32: nft_registers) +* @NFTA_PAYLOAD_CSUM_TYPE: checksum type (NLA_U32) +* @NFTA_PAYLOAD_CSUM_OFFSET: checksum offset relative to base (NLA_U32) */ enum nft_payload_attributes {NFTA_PAYLOAD_UNSPEC ,
@@ -611,6 +625,9 @@ enum nft_payload_attributes {NFTA_PAYLOAD_BASE ,NFTA_PAYLOAD_OFFSET ,NFTA_PAYLOAD_LEN , +NFTA_PAYLOAD_SREG , +NFTA_PAYLOAD_CSUM_TYPE , +NFTA_PAYLOAD_CSUM_OFFSET , __NFTA_PAYLOAD_MAX };#define NFTA_PAYLOAD_MAX (__NFTA_PAYLOAD_MAX - 1)
net/netfilter/nft_payload.c +129 -6
159 lines not on this page · raw message
Signature · 1 line
2.1.4
Pablo Neira Ayuso
maintainerPATCH 14/23 netfilter: nf_tables: extend tracing infrastructure
In reply to Pablo Neira AyusoFrom: Florian Westphal <[email protected]>
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.
--- include/net/netfilter/nf_tables.h | 32 ++++ include/uapi/linux/netfilter/nf_tables.h | 52 ++++++ include/uapi/linux/netfilter/nfnetlink.h | 2 + net/netfilter/Makefile | 2 +- net/netfilter/nf_tables_api.c | 12 +- net/netfilter/nf_tables_core.c | 45 +++-- net/netfilter/nf_tables_trace.c | 271 +++++++++++++++++++++++++++++++ net/netfilter/nfnetlink.c | 1 + 8 files changed, 398 insertions(+), 19 deletions(-) create mode 100644 net/netfilter/nf_tables_trace.c
include/net/netfilter/nf_tables.h +32 -0
@@ -888,6 +888,38 @@ void nft_unregister_chain_type(const struct nf_chain_type *);int nft_register_expr (struct nft_expr_type *);void nft_unregister_expr (struct nft_expr_type *); +int nft_verdict_dump (struct sk_buff *skb,int type, +const struct nft_verdict *v); + +/** +* struct nft_traceinfo - nft tracing information and state +* +* @pkt: pktinfo currently processed +* @basechain: base chain currently processed +* @chain: chain currently processed +* @rule: rule that was evaluated +* @verdict: verdict given by rule +* @type: event type (enum nft_trace_types) +* @packet_dumped: packet headers sent in a previous traceinfo message +* @trace: other struct members are initialised +*/ +struct nft_traceinfo { +const struct nft_pktinfo *pkt; +const struct nft_base_chain *basechain; +const struct nft_chain *chain; +const struct nft_rule *rule; +const struct nft_verdict *verdict; +enum nft_trace_types type; +bool packet_dumped; +bool trace; +}; + +void nft_trace_init (struct nft_traceinfo *info,const struct nft_pktinfo *pkt, +const struct nft_verdict *verdict, +const struct nft_chain *basechain); + +void nft_trace_notify (struct nft_traceinfo *info); +#define nft_dereference (p) \ nfnl_dereference(p, NFNL_SUBSYS_NFTABLES)
include/uapi/linux/netfilter/nf_tables.h +52 -0
68 lines not on this page · raw message
include/uapi/linux/netfilter/nfnetlink.h +2 -0
@@ -22,6 +22,8 @@ enum nfnetlink_groups {#define NFNLGRP_NFTABLES NFNLGRP_NFTABLES NFNLGRP_ACCT_QUOTA,#define NFNLGRP_ACCT_QUOTA NFNLGRP_ACCT_QUOTA + NFNLGRP_NFTRACE, +#define NFNLGRP_NFTRACE NFNLGRP_NFTRACE __NFNLGRP_MAX, };#define NFNLGRP_MAX (__NFNLGRP_MAX - 1)
net/netfilter/Makefile +1 -1
@@ -67,7 +67,7 @@ obj-$(CONFIG_NF_NAT_TFTP) += nf_nat_tftp.o obj-$(CONFIG_NETFILTER_SYNPROXY) += nf_synproxy_core.o # nf_tables -nf_tables-objs += nf_tables_core.o nf_tables_api.o +nf_tables-objs += nf_tables_core.o nf_tables_api.o nf_tables_trace.o nf_tables-objs += nft_immediate.o nft_cmp.o nft_lookup.o nft_dynset.o nf_tables-objs += nft_bitwise.o nft_byteorder.o nft_payload.o
net/netfilter/nf_tables_api.c +6 -6
@@ -4446,22 +4446,22 @@ static void nft_verdict_uninit(const struct nft_data *data) } } -static int nft_verdict_dump (struct sk_buff *skb,const struct nft_data *data) +int nft_verdict_dump (struct sk_buff *skb,int type,const struct nft_verdict *v) {struct nlattr *nest; - nest =nla_nest_start (skb,NFTA_DATA_VERDICT ); + nest =nla_nest_start (skb, type);if (!nest) goto nla_put_failure; -if (nla_put_be32 (skb,NFTA_VERDICT_CODE ,htonl (data->verdict.code))) +if (nla_put_be32 (skb,NFTA_VERDICT_CODE ,htonl (v->code))) goto nla_put_failure; -switch (data->verdict.code) { +switch (v->code) {case NFT_JUMP :case NFT_GOTO :if (nla_put_string (skb,NFTA_VERDICT_CHAIN , - data->verdict.chain->name)) + v->chain->name)) goto nla_put_failure; }nla_nest_end (skb, nest);
@@ -4572,7 +4572,7 @@ int nft_data_dump(struct sk_buff *skb, int attr, const struct nft_data *data, err =nft_value_dump (skb, data, len);break ;case NFT_DATA_VERDICT : - err =nft_verdict_dump (skb, data); + err =nft_verdict_dump (skb,NFTA_DATA_VERDICT , &data->verdict);break ;default : err = -EINVAL ;
net/netfilter/nf_tables_core.c +33 -12
97 lines not on this page · raw message
net/netfilter/nf_tables_trace.c new file +271 -0
271 lines not on this page · raw message
net/netfilter/nfnetlink.c +1 -0
@@ -49,6 +49,7 @@ static const int nfnl_group2type[NFNLGRP_MAX+1] = { [NFNLGRP_CONNTRACK_EXP_DESTROY] = NFNL_SUBSYS_CTNETLINK_EXP, [NFNLGRP_NFTABLES] = NFNL_SUBSYS_NFTABLES, [NFNLGRP_ACCT_QUOTA] = NFNL_SUBSYS_ACCT, + [NFNLGRP_NFTRACE] = NFNL_SUBSYS_NFTABLES, };void nfnl_lock (__u8 subsys_id)
Signature · 1 line
2.1.4
Pablo Neira Ayuso
maintainerPATCH 15/23 netfilter: nf_tables: wrap tracing with a static key
In reply to Pablo Neira AyusoFrom: Florian Westphal <[email protected]>
Only needed when meta nftrace rule(s) were added.
The assumption is that no such rules are active, so the call to nft_trace_init is "never" needed.
When nftrace rules are active, we always call the nft_trace_* functions, but will only send netlink messages when all of the following are true:
- traceinfo structure was initialised
- skb->nf_trace == 1
- at least one subscriber to trace group.
Adding an extra conditional
(static_branch ... && skb->nf_trace)
nft_trace_init( ..)
Is possible but results in a larger nft_do_chain footprint.
--- include/net/netfilter/nf_tables_core.h | 1 + include/net/netfilter/nft_meta.h | 3 +++ net/bridge/netfilter/nft_meta_bridge.c | 1 + net/netfilter/nf_tables_core.c | 9 ++++++--- net/netfilter/nf_tables_trace.c | 4 ++++ net/netfilter/nft_meta.c | 16 ++++++++++++++++ 6 files changed, 31 insertions(+), 3 deletions(-)
include/net/netfilter/nf_tables_core.h +1 -0
@@ -57,6 +57,7 @@ struct nft_payload_set { };extern const struct nft_expr_ops nft_payload_fast_ops; +extern struct static_key_false nft_trace_enabled;int nft_payload_module_init (void );void nft_payload_module_exit (void );
include/net/netfilter/nft_meta.h +3 -0
@@ -33,4 +33,7 @@ void nft_meta_set_eval(const struct nft_expr *expr,struct nft_regs *regs, const struct nft_pktinfo *pkt); +void nft_meta_set_destroy (const struct nft_ctx *ctx, +const struct nft_expr *expr); +#endif
net/bridge/netfilter/nft_meta_bridge.c +1 -0
@@ -84,6 +84,7 @@ static const struct nft_expr_ops nft_meta_bridge_set_ops = { .size = NFT_EXPR_SIZE(sizeof(struct nft_meta)), .eval = nft_meta_set_eval, .init = nft_meta_set_init, + .destroy = nft_meta_set_destroy, .dump = nft_meta_set_dump, };
net/netfilter/nf_tables_core.c +6 -3
@@ -16,6 +16,7 @@#include <linux/skbuff.h> #include <linux/netlink.h> #include <linux/netfilter.h> +#include <linux/static_key.h> #include <linux/netfilter/nfnetlink.h> #include <linux/netfilter/nf_tables.h> #include <net/netfilter/nf_tables_core.h>
@@ -50,7 +51,7 @@ static noinline void __nft_trace_packet(struct nft_traceinfo *info, {const struct nft_pktinfo *pkt = info->pkt; -if (!pkt->skb->nf_trace) +if (!info->trace || !pkt->skb->nf_trace)return ; info->chain = chain;
@@ -70,7 +71,7 @@ static inline void nft_trace_packet(struct nft_traceinfo *info,int rulenum, enum nft_trace_types type) { - if (unlikely(info->trace)) { + if (static_branch_unlikely(&nft_trace_enabled)) { info->rule = rule;__nft_trace_packet (info, chain, rulenum, type); }
@@ -137,7 +138,9 @@ nft_do_chain(struct nft_pktinfo *pkt, void *priv)unsigned int gencursor =nft_genmask_cur (net);struct nft_traceinfo info; -nft_trace_init (&info, pkt, ®s.verdict, basechain); + info.trace = false; +if (static_branch_unlikely (&nft_trace_enabled)) +nft_trace_init (&info, pkt, ®s.verdict, basechain); do_chain: rulenum =0 ; rule = list_entry(&chain->rules, struct nft_rule, list);
net/netfilter/nf_tables_trace.c +4 -0
@@ -8,6 +8,7 @@*/ #include <linux/module.h> +#include <linux/static_key.h> #include <linux/hash.h> #include <linux/jhash.h> #include <linux/if_vlan.h>
@@ -24,6 +25,9 @@#define NFT_TRACETYPE_NETWORK_HSIZE 40#define NFT_TRACETYPE_TRANSPORT_HSIZE 20 +DEFINE_STATIC_KEY_FALSE (nft_trace_enabled); +EXPORT_SYMBOL_GPL (nft_trace_enabled); +static int trace_fill_id (struct sk_buff *nlskb,struct sk_buff *skb) {__be32 id;
net/netfilter/nft_meta.c +16 -0
@@ -18,10 +18,12 @@#include <linux/ip.h> #include <linux/ipv6.h> #include <linux/smp.h> +#include <linux/static_key.h> #include <net/dst.h> #include <net/sock.h> #include <net/tcp_states.h> /* for TCP_TIME_WAIT */ #include <net/netfilter/nf_tables.h> +#include <net/netfilter/nf_tables_core.h> #include <net/netfilter/nft_meta.h> void nft_meta_get_eval(const struct nft_expr *expr,
@@ -297,6 +299,9 @@ int nft_meta_set_init(const struct nft_ctx *ctx,if (err <0 )return err; +if (priv->key ==NFT_META_NFTRACE ) +static_branch_inc (&nft_trace_enabled); +return 0 ; }EXPORT_SYMBOL_GPL (nft_meta_set_init);
@@ -334,6 +339,16 @@ nla_put_failure: }EXPORT_SYMBOL_GPL (nft_meta_set_dump); +void nft_meta_set_destroy (const struct nft_ctx *ctx, +const struct nft_expr *expr) +{ +const struct nft_meta *priv =nft_expr_priv (expr); + +if (priv->key ==NFT_META_NFTRACE ) +static_branch_dec (&nft_trace_enabled); +} +EXPORT_SYMBOL_GPL (nft_meta_set_destroy); +static struct nft_expr_type nft_meta_type;static const struct nft_expr_ops nft_meta_get_ops = { .type = &nft_meta_type,
@@ -348,6 +363,7 @@ static const struct nft_expr_ops nft_meta_set_ops = { .size = NFT_EXPR_SIZE(sizeof(struct nft_meta)), .eval = nft_meta_set_eval, .init = nft_meta_set_init, + .destroy = nft_meta_set_destroy, .dump = nft_meta_set_dump, };
Signature · 1 line
2.1.4
Pablo Neira Ayuso
maintainerPATCH 16/23 netfilter: ipv6: nf_defrag: fix NULL deref panic
In reply to Pablo Neira AyusoFrom: Florian Westphal <[email protected]>
Valdis reports NULL deref in nf_ct_frag6_gather.
Problem is bogus use of skb_queue_walk() -- we miss first skb in the list since we start with head->next instead of head.
In case the element we're looking for was head->next we won't find a result and then trip over NULL iter.
(defrag uses plain NULL-terminated list rather than one terminated by
head-of-list-pointer, which is what skb_queue_walk expects).
--- net/ipv6/netfilter/nf_conntrack_reasm.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
net/ipv6/netfilter/nf_conntrack_reasm.c +8 -5
@@ -441,11 +441,14 @@ nf_ct_frag6_reasm(struct frag_queue *fq, struct sk_buff *prev, struct net_devicreturn false; fp->next = prev->next; - skb_queue_walk(head, iter) { -if (iter->next != prev) -continue ; - iter->next = fp; -break ; + + iter = head; +while (iter) { +if (iter->next == prev) { + iter->next = fp; +break ; + } + iter = iter->next; }skb_morph (prev, head);
Signature · 1 line
2.1.4
Pablo Neira Ayuso
maintainerPATCH 17/23 netfilter: nfnetlink_log: Change setter functions to be void
In reply to Pablo Neira AyusoFrom: "Rosen, Rami" <[email protected]>
Change return type of nfulnl_set_timeout() and nfulnl_set_qthresh() to be void.
This patch changes the return type of the static methods nfulnl_set_timeout() and nfulnl_set_qthresh() to be void, as there is no justification and no need for these methods to return int.
--- net/netfilter/nfnetlink_log.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
net/netfilter/nfnetlink_log.c +2 -6
@@ -293,24 +293,20 @@ nfulnl_set_nlbufsiz(struct nfulnl_instance *inst, u_int32_t nlbufsiz)return status; } -static int +static void nfulnl_set_timeout (struct nfulnl_instance *inst,u_int32_t timeout) {spin_lock_bh (&inst->lock); inst->flushtimeout = timeout;spin_unlock_bh (&inst->lock); - -return 0 ; } -static int +static void nfulnl_set_qthresh (struct nfulnl_instance *inst,u_int32_t qthresh) {spin_lock_bh (&inst->lock); inst->qthreshold = qthresh;spin_unlock_bh (&inst->lock); - -return 0 ; } static int
Signature · 1 line
2.1.4
Pablo Neira Ayuso
maintainerPATCH 18/23 netfilter: nf_tables: fix nf_log_trace based tracing
In reply to Pablo Neira AyusoFrom: Florian Westphal <[email protected]>
nf_log_trace() outputs bogus 'TRACE:' strings because I forgot to update the comments array.
--- net/netfilter/nf_tables_core.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-)
net/netfilter/nf_tables_core.c +5 -11
@@ -23,16 +23,10 @@#include <net/netfilter/nf_tables.h> #include <net/netfilter/nf_log.h> -enum nft_trace { -NFT_TRACE_RULE , -NFT_TRACE_RETURN , -NFT_TRACE_POLICY , -}; - -static const char *const comments[] = { - [NFT_TRACE_RULE ] ="rule" , - [NFT_TRACE_RETURN ] ="return" , - [NFT_TRACE_POLICY ] ="policy" , +static const char *const comments[__NFT_TRACETYPE_MAX] = { + [NFT_TRACETYPE_POLICY ] ="policy" , + [NFT_TRACETYPE_RETURN ] ="return" , + [NFT_TRACETYPE_RULE ] ="rule" , };static struct nf_loginfo trace_loginfo = {
@@ -47,7 +41,7 @@ static struct nf_loginfo trace_loginfo = { static noinline void __nft_trace_packet(struct nft_traceinfo *info,const struct nft_chain *chain, -int rulenum,enum nft_trace type) +int rulenum,enum nft_trace_types type) {const struct nft_pktinfo *pkt = info->pkt;
Signature · 1 line
2.1.4
Pablo Neira Ayuso
maintainerPATCH 19/23 netfilter: cttimeout: add netns support
In reply to Pablo Neira AyusoFrom: Pablo Neira <[email protected]>
Add a per-netns list of timeout objects and adjust code to use it.
--- include/net/net_namespace.h | 3 + include/net/netfilter/nf_conntrack_timeout.h | 2 +- net/netfilter/nf_conntrack_timeout.c | 2 +- net/netfilter/nfnetlink_cttimeout.c | 82 +++++++++++++++++----------- net/netfilter/xt_CT.c | 2 +- 5 files changed, 57 insertions(+), 34 deletions(-)
include/net/net_namespace.h +3 -0
@@ -121,6 +121,9 @@ struct net {#if IS_ENABLED (CONFIG_NETFILTER_NETLINK_ACCT )struct list_head nfnl_acct_list;#endif +#if IS_ENABLED (CONFIG_NF_CT_NETLINK_TIMEOUT ) +struct list_head nfct_timeout_list; +#endif #endif #ifdef CONFIG_WEXT_CORE struct sk_buff_head wext_nlevents;
include/net/netfilter/nf_conntrack_timeout.h +1 -1
@@ -104,7 +104,7 @@ static inline void nf_conntrack_timeout_fini(void)#endif /* CONFIG_NF_CONNTRACK_TIMEOUT */ #ifdef CONFIG_NF_CONNTRACK_TIMEOUT -extern struct ctnl_timeout *(*nf_ct_timeout_find_get_hook)(const char *name); +extern struct ctnl_timeout *(*nf_ct_timeout_find_get_hook)(struct net *net,const char *name);extern void (*nf_ct_timeout_put_hook)(struct ctnl_timeout *timeout);#endif
net/netfilter/nf_conntrack_timeout.c +1 -1
@@ -25,7 +25,7 @@#include <net/netfilter/nf_conntrack_timeout.h> struct ctnl_timeout * -(*nf_ct_timeout_find_get_hook)(const char *name)__read_mostly ; +(*nf_ct_timeout_find_get_hook)(struct net *net,const char *name)__read_mostly ;EXPORT_SYMBOL_GPL (nf_ct_timeout_find_get_hook);void (*nf_ct_timeout_put_hook)(struct ctnl_timeout *timeout)__read_mostly ;
net/netfilter/nfnetlink_cttimeout.c +51 -31
203 lines not on this page · raw message
net/netfilter/xt_CT.c +1 -1
@@ -143,7 +143,7 @@ xt_ct_set_timeout(struct nf_conn *ct, const struct xt_tgchk_param *par, goto out; } - timeout =timeout_find_get (timeout_name); + timeout =timeout_find_get (par->net, timeout_name);if (timeout ==NULL ) { ret = -ENOENT ;pr_info ("No such timeout policy \"%s\"\n" , timeout_name);
Signature · 1 line
2.1.4
Pablo Neira Ayuso
maintainerPATCH 20/23 netfilter: prepare xt_cgroup for multi revisions
In reply to Pablo Neira AyusoFrom: Tejun Heo <[email protected]>
xt_cgroup will grow cgroup2 path based match. Postfix existing symbols with _v0 and prepare for multi revision registration.
--- include/uapi/linux/netfilter/xt_cgroup.h | 2 +- net/netfilter/xt_cgroup.c | 36 +++++++++++++++++--------------- 2 files changed, 20 insertions(+), 18 deletions(-)
include/uapi/linux/netfilter/xt_cgroup.h +1 -1
@@ -3,7 +3,7 @@#include <linux/types.h> -struct xt_cgroup_info { +struct xt_cgroup_info_v0 {__u32 id;__u32 invert; };
net/netfilter/xt_cgroup.c +19 -17
@@ -24,9 +24,9 @@ MODULE_DESCRIPTION("Xtables: process control group matching");MODULE_ALIAS ("ipt_cgroup" );MODULE_ALIAS ("ip6t_cgroup" ); -static int cgroup_mt_check (const struct xt_mtchk_param *par) +static int cgroup_mt_check_v0 (const struct xt_mtchk_param *par) { -struct xt_cgroup_info *info = par->matchinfo; +struct xt_cgroup_info_v0 *info = par->matchinfo;if (info->invert & ~1 )return -EINVAL ;
@@ -35,9 +35,9 @@ static int cgroup_mt_check(const struct xt_mtchk_param *par) }static bool -cgroup_mt (const struct sk_buff *skb,struct xt_action_param *par) +cgroup_mt_v0 (const struct sk_buff *skb,struct xt_action_param *par) { -const struct xt_cgroup_info *info = par->matchinfo; +const struct xt_cgroup_info_v0 *info = par->matchinfo;if (skb->sk ==NULL || !sk_fullsock (skb->sk))return false;
@@ -46,27 +46,29 @@ cgroup_mt(const struct sk_buff *skb, struct xt_action_param *par) info->invert; } -static struct xt_match cgroup_mt_reg__read_mostly = { - .name ="cgroup" , - .revision =0 , - .family =NFPROTO_UNSPEC , - .checkentry = cgroup_mt_check, - .match = cgroup_mt, - .matchsize =sizeof (struct xt_cgroup_info ), - .me =THIS_MODULE , - .hooks = (1 <<NF_INET_LOCAL_OUT ) | - (1 <<NF_INET_POST_ROUTING ) | - (1 <<NF_INET_LOCAL_IN ), +static struct xt_match cgroup_mt_reg[]__read_mostly = { + { + .name ="cgroup" , + .revision =0 , + .family =NFPROTO_UNSPEC , + .checkentry = cgroup_mt_check_v0, + .match = cgroup_mt_v0, + .matchsize =sizeof (struct xt_cgroup_info_v0 ), + .me =THIS_MODULE , + .hooks = (1 <<NF_INET_LOCAL_OUT ) | + (1 <<NF_INET_POST_ROUTING ) | + (1 <<NF_INET_LOCAL_IN ), + }, };static int __init cgroup_mt_init (void ) { -return xt_register_match (&cgroup_mt_reg); +return xt_register_matches (cgroup_mt_reg,ARRAY_SIZE (cgroup_mt_reg)); } static void __exit cgroup_mt_exit(void) { -xt_unregister_match (&cgroup_mt_reg); +xt_unregister_matches (cgroup_mt_reg,ARRAY_SIZE (cgroup_mt_reg)); }module_init (cgroup_mt_init);
Signature · 1 line
2.1.4
Pablo Neira Ayuso
maintainerPATCH 21/23 netfilter: implement xt_cgroup cgroup2 path match
In reply to Pablo Neira AyusoFrom: Tejun Heo <[email protected]>
This patch implements xt_cgroup path match which matches cgroup2 membership of the associated socket. The match is recursive and invertible.
For rationales on introducing another cgroup based match, please refer to a preceding commit "sock, cgroup: add sock->sk_cgroup".
v3: Folded into xt_cgroup as a new revision interface as suggested by
Pablo.
v2: Included linux/limits.h from xt_cgroup2.h for PATH_MAX. Added
explicit alignment to the priv field. Both suggested by Jan.
--- include/uapi/linux/netfilter/xt_cgroup.h | 13 ++++++ net/netfilter/xt_cgroup.c | 69 ++++++++++++++++++++++++++++++++ 2 files changed, 82 insertions(+)
include/uapi/linux/netfilter/xt_cgroup.h +13 -0
@@ -2,10 +2,23 @@#define _UAPI_XT_CGROUP_H#include <linux/types.h> +#include <linux/limits.h> struct xt_cgroup_info_v0 {__u32 id;__u32 invert; }; +struct xt_cgroup_info_v1 { +__u8 has_path; +__u8 has_classid; +__u8 invert_path; +__u8 invert_classid; +char path[PATH_MAX ]; +__u32 classid; + +/* kernel internal data */ +void *priv __attribute__((aligned (8 ))); +}; +#endif /* _UAPI_XT_CGROUP_H */
net/netfilter/xt_cgroup.c +69 -0
87 lines not on this page · raw message
Signature · 1 line
2.1.4
Pablo Neira Ayuso
maintainerPATCH 22/23 nfnetlink: add nfnl_dereference_protected helper
In reply to Pablo Neira AyusoFrom: Florian Westphal <[email protected]>
to avoid overly long line in followup patch.
--- net/netfilter/nfnetlink.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
net/netfilter/nfnetlink.c +7 -6
@@ -33,6 +33,10 @@ MODULE_LICENSE("GPL");MODULE_AUTHOR ("Harald Welte <[email protected]>" );MODULE_ALIAS_NET_PF_PROTO (PF_NETLINK ,NETLINK_NETFILTER ); +#define nfnl_dereference_protected (id) \ + rcu_dereference_protected(table[(id)].subsys, \ + lockdep_nfnl_is_held((id))) +static char __initdata nfversion[] ="0.30" ; static struct {
@@ -208,8 +212,7 @@ replay: }else {rcu_read_unlock ();nfnl_lock (subsys_id); -if (rcu_dereference_protected (table[subsys_id].subsys, -lockdep_is_held (&table[subsys_id].mutex)) != ss || +if (nfnl_dereference_protected (subsys_id) != ss ||nfnetlink_find_client (type, ss) != nc) err = -EAGAIN ;else if (nc->call)
@@ -299,15 +302,13 @@ replay: skb->sk = oskb->sk;nfnl_lock (subsys_id); - ss =rcu_dereference_protected (table[subsys_id].subsys, -lockdep_is_held (&table[subsys_id].mutex)); + ss =nfnl_dereference_protected (subsys_id);if (!ss) {#ifdef CONFIG_MODULES nfnl_unlock (subsys_id);request_module ("nfnetlink-subsys-%d" , subsys_id);nfnl_lock (subsys_id); - ss =rcu_dereference_protected (table[subsys_id].subsys, -lockdep_is_held (&table[subsys_id].mutex)); + ss =nfnl_dereference_protected (subsys_id); if (!ss)#endif {
Signature · 1 line
2.1.4
Pablo Neira Ayuso
maintainerPATCH 23/23 netfilter: meta: add support for setting skb->pkttype
In reply to Pablo Neira AyusoFrom: Florian Westphal <[email protected]>
This allows to redirect bridged packets to local machine:
ether type ip ether daddr set aa:53:08:12:34:56 meta pkttype set unicast Without 'set unicast', ip stack discards PACKET_OTHERHOST skbs.
It is also useful to add support for a '-m cluster like' nft rule (where switch floods packets to several nodes, and each cluster node
node processes a subset of packets for load distribution).
Mangling is restricted to HOST/OTHER/BROAD/MULTICAST, i.e. you cannot set skb->pkt_type to PACKET_KERNEL or change PACKET_LOOPBACK to PACKET_HOST.
--- net/netfilter/nft_meta.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+)
net/netfilter/nft_meta.c +38 -0
@@ -26,6 +26,8 @@#include <net/netfilter/nf_tables_core.h> #include <net/netfilter/nft_meta.h> +#include <uapi/linux/netfilter_bridge.h> /* NF_BR_PRE_ROUTING */ +void nft_meta_get_eval (const struct nft_expr *expr,struct nft_regs *regs,const struct nft_pktinfo *pkt)
@@ -190,6 +192,13 @@ err: }EXPORT_SYMBOL_GPL (nft_meta_get_eval); +/* don't change or set _LOOPBACK, _USER, etc. */ +static bool pkt_type_ok (u32 p) +{ +return p ==PACKET_HOST || p ==PACKET_BROADCAST || + p ==PACKET_MULTICAST || p ==PACKET_OTHERHOST ; +} +void nft_meta_set_eval (const struct nft_expr *expr,struct nft_regs *regs,const struct nft_pktinfo *pkt)
@@ -205,6 +214,11 @@ void nft_meta_set_eval(const struct nft_expr *expr,case NFT_META_PRIORITY : skb->priority = value;break ; +case NFT_META_PKTTYPE : +if (skb->pkt_type != value && +pkt_type_ok (value) &&pkt_type_ok (skb->pkt_type)) + skb->pkt_type = value; +break ;case NFT_META_NFTRACE : skb->nf_trace =1 ;break ;
@@ -273,6 +287,24 @@ int nft_meta_get_init(const struct nft_ctx *ctx, }EXPORT_SYMBOL_GPL (nft_meta_get_init); +static int nft_meta_set_init_pkttype (const struct nft_ctx *ctx) +{ +unsigned int hooks; + +switch (ctx->afi->family) { +case NFPROTO_BRIDGE : + hooks =1 <<NF_BR_PRE_ROUTING ; +break ; +case NFPROTO_NETDEV : + hooks =1 <<NF_NETDEV_INGRESS ; +break ; +default : +return -EOPNOTSUPP ; + } + +return nft_chain_validate_hooks (ctx->chain, hooks); +} +int nft_meta_set_init (const struct nft_ctx *ctx,const struct nft_expr *expr,const struct nlattr *const tb[])
@@ -290,6 +322,12 @@ int nft_meta_set_init(const struct nft_ctx *ctx,case NFT_META_NFTRACE : len =sizeof (u8);break ; +case NFT_META_PKTTYPE : + err =nft_meta_set_init_pkttype (ctx); +if (err) +return err; + len =sizeof (u8); +break ;default :return -EOPNOTSUPP ; }
Signature · 1 line
2.1.4
David Miller
maintainerFrom: Pablo Neira Ayuso <[email protected]>
Date: Fri, 18 Dec 2015 21:26:26 +0100
Quoted 5 lines
The following patchset contains the first batch of Netfilter updates for the upcoming 4.5 kernel. This batch contains userspace netfilter header compilation fixes, support for packet mangling in
nf_tables, the new tracing infrastructure fornf_tablesand cgroup2 support for iptables. More specifically, they are:
...
Pulled.
Quoted 2 lines
BTW, I need that you pull net into net-next, I have another batch that requires changes that I don't yet see in net.
I did that several hours ago.