Skip to contentSkip to conversation

netfilter: add support for matching IPv4 options

PATCH Applied Stephen Suryaputra 2 participants 2 messages Jun 20, 2019 – Jun 21, 2019

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH v5 1/1 netfilter: add support for matching IPv4 options

This is the kernel change for the overall changes with this description:
Add capability to have rules matching IPv4 options. This is developed mainly to support dropping of IP packets with loose and/or strict source route route options.

v2: Fix style issues. Make this work with NFPROTO_INET (inet tables),
NFPROTO_BRIDGE and the NFPROTO_NETDEV families. Check skb->protocol. Remove ability to input IP header offset for ipv4_find_option() function (all per Pablo Neira Ayuso).
v3: Remove unused ipv4_find_option() arguments (per Pablo Neira Ayuso).
v4: Change the code to not follow ipv6_find_hdr() and just do what are
needed to support source-route, record route and router alert (per Pablo Neira Ayuso). Fix bugs that are introduced while addressing review comments.
v5: Add nft_exthdr_ipv4_init(). Remove redundant check of IP version
(feedback from Pablo Neira Ayuso).

---
 include/uapi/linux/netfilter/nf_tables.h |   2 +
 net/ipv4/ip_options.c                    |   1 +
 net/netfilter/nft_exthdr.c               | 133 +++++++++++++++++++++++
 3 files changed, 136 insertions(+)
include/uapi/linux/netfilter/nf_tables.h +2 -0
index 505393c6e959..168d741f42c5 100644
@@ -730,10 +730,12 @@ enum nft_exthdr_flags {
  *
  * @NFT_EXTHDR_OP_IPV6: match against ipv6 extension headers
  * @NFT_EXTHDR_OP_TCP: match against tcp options
+ * @NFT_EXTHDR_OP_IPV4: match against ipv4 options
  */
 enum nft_exthdr_op {
 	NFT_EXTHDR_OP_IPV6,
 	NFT_EXTHDR_OP_TCPOPT,
+	NFT_EXTHDR_OP_IPV4,
 	__NFT_EXTHDR_OP_MAX
 };
 #define NFT_EXTHDR_OP_MAX	(__NFT_EXTHDR_OP_MAX - 1)
net/ipv4/ip_options.c +1 -0
index 3db31bb9df50..ddaa01ec2bce 100644
@@ -473,6 +473,7 @@ int __ip_options_compile(struct net *net,
 		*info = htonl((pp_ptr-iph)<<24);
 	return -EINVAL;
 }
+EXPORT_SYMBOL(__ip_options_compile);
 
 int ip_options_compile(struct net *net,
 		       struct ip_options *opt, struct sk_buff *skb)
net/netfilter/nft_exthdr.c +133 -0

157 lines not on this page · raw message

Signature · 1 line
2.17.1
maintainer Applied
#1 lore raw
Quoted 4 lines · Stephen Suryaputra

This is the kernel change for the overall changes with this description:
Add capability to have rules matching IPv4 options. This is developed mainly to support dropping of IP packets with loose and/or strict source route route options.

Applied, thanks Stephen.